Index: trunk/src/emx/Makefile
===================================================================
--- trunk/src/emx/Makefile	(revision 119)
+++ trunk/src/emx/Makefile	(revision 123)
@@ -23,7 +23,11 @@
 OUT = out/
 # Base installation directory
-INS = out/install/
+INS = out/$(MODE)/install/
 # CPU type (pretend we are portable ;-)
 CPU = 386
+# The object file format to use for tools (emxomf, ld and friends)
+TOOLFMT.dbg = aout
+TOOLFMT.opt = omf
+TOOLFMT = $(TOOLFMT.$(MODE))
 
 # Use ash.exe which is quite fast (comparable to cmd.exe) but has more features
@@ -44,5 +48,6 @@
 CC = gcc -c
 # The C compiler flags
-CFLAGS = -Wall -Iinclude -Isrc/include $(CFLAGS.$(MODE)) $(CFLAGS.KIND)
+CFLAGS.INC = -Iinclude -Isrc/include
+CFLAGS = -Wall -mstack-arg-probe -Zmt $(CFLAGS.INC) $(CFLAGS.$(MODE)) $(CFLAGS.KIND)
 # The additional C compiler flags for different build modes
 CFLAGS.opt = -s -O3 -fomit-frame-pointer
@@ -50,6 +55,4 @@
 CFLAGS.aout =
 CFLAGS.omf = -Zomf
-CFLAGS.st =
-CFLAGS.mt = -Zmt
 CFLAGS.prof = -pg
 # The object files are put in subdirectory objectformat-targetkind,
@@ -63,5 +66,5 @@
 LD = gcc
 # Linker flags
-LDFLAGS = $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND)
+LDFLAGS = -Zmt $(LDFLAGS.$(MODE)) $(LDFLAGS.KIND)
 # Linker flags for different build modes
 LDFLAGS.opt = -s
@@ -69,8 +72,5 @@
 LDFLAGS.aout =
 LDFLAGS.omf = -Zomf -Zsys -Zsmall-conv -Zlinker /PM:VIO
-LDFLAGS.st =
-LDFLAGS.mt = -Zmt
-LDFLAGS.stp = -pg
-LDFLAGS.mtp = -pg -Zmt
+LDFLAGS.prof = -pg
 # Linker flags for different kinds of target
 LDFLAGS.KIND = $(foreach x,$(subst -, ,$(firstword $(subst /, ,$(subst $.,,$@)))),$(LDFLAGS.$x))
@@ -88,4 +88,13 @@
 ARFLAGS = crs
 DO.LIBRARY = $(AR) $(ARFLAGS) $@ $(^O)
+
+# How to create dependencies
+MAKEDEP = makedep
+MAKEDEPFLAGS = $(CFLAGS.INC)
+DO.DEPS = $(MAKEDEP) $(MAKEDEPFLAGS) \
+  -I$(subst $(SPACE), -I,$(sort $(dir $^))) -p$(@D)/ -c -S -f$@ $^
+
+# How to convert an a.out file to the OMF format
+DO.AOUT2OMF = emxomf $(strip $1 -o) $@ $<
 
 # How to filter just the object files from $^
@@ -109,6 +118,10 @@
 SEP := ==========================================================================
 
-# How to remove a file
+# How to remove one or more files without questions
 RM = rm -f $1
+# How to remove one or more directories without questions
+RMDIR = rm -rf $1
+# How to copy several files to a directory
+CP = cp $1 $2
 # Miscelaneous tools
 MKDIR = mkdir.exe -p $1
@@ -117,10 +130,6 @@
 ECHOIZE = $(subst $$,\$$,$1$(strip $(subst $(SPACE)$(COMMA),$(COMMA),$(foreach x,2 3 4 5 6 7 8 9,$(if $($x),$(COMMA) $($x))))))
 # How to output a text string (with appended newline)
-# bird: skip the .exe and ash will use internal echo implementation which is way faster
-#ECHO = echo.exe "$(call ECHOIZE,$1,$2,$3,$4,$5,$6,$7,$8,$9)"
 ECHO = echo "$(call ECHOIZE,$1,$2,$3,$4,$5,$6,$7,$8,$9)"
 # Same but append the text to a file (given with first argument)
-# bird: skip the .exe and ash will use internal echo implementation which is way faster
-#FECHO = echo.exe "$(call ECHOIZE,$2,$3,$4,$5,$6,$7,$8,$9)" >> "$1"
 FECHO = echo "$(call ECHOIZE,$2,$3,$4,$5,$6,$7,$8,$9)" >> "$1"
 # How to replace the source file extension with a .o extension
@@ -145,8 +154,10 @@
 # Build rules (_@_ replaced by name of generated makefile)
 RULES :=
-
-.PHONY: default help all clean install
+# The list of dependency files
+TARGDEPEND :=
+
+.PHONY: default help all clean install cleandep cleandepend dep depend depdone
 .SUFFIXES:
-.SUFFIXES: .c .cpp .asm .s .o .exe .dll .a .lib
+.SUFFIXES: .c .cpp .asm .s .o .exe .dll .a .lib .obj
 
 # Default target
@@ -172,4 +183,6 @@
 	@$(call ECHO,    clean - remove all generated files (remove all built files))
 	@$(call ECHO,    install - generate a installation tree in $(INS))
+	@$(call ECHO,    dep - generate dependency files for all changed targets)
+	@$(call ECHO,    cleandep - remove all dependency file)
 	@$(call ECHO,$(SEP))
 	@$(call ECHO,There are a number of variables than can be set in the make)
@@ -181,29 +194,38 @@
 	@$(call ECHO,$(SEP))
 
-all: $(MODULES)
+all: $(TARGDIRS) $(MODULES)
 
 clean:
-	rm -rf $(OUT)
-
-install: $(INSDIRS)
+	$(call RMDIR,$(OUT))
+
+cleandep cleandepend:
+	$(call RM,$(TARGDEPEND))
+
+dep depend:
+	@$(MAKE) --no-print-directory BUILD_DEPS=1 depdone
+
+depdone:
+	@$(call ECHO,Dependency files succesfully updated)
+
+install: all $(INSDIRS)
 	$(DO.INSTALL)
 
-$(OUT) $. $(INSDIRS) $(TARGDIRS):
+$. $(INSDIRS) $(TARGDIRS):
 	$(call MKDIR,$@)
 
-# bird: add rule for generating the rules.
-rules: rules-rm $(OUT)genrules.smak
-rules-rm:
-	@$(call RM,$(OUT)genrules.smak)
-	
-#$(OUT)genrules.smak: $(OUT) Makefile $(SUBMAK)
-# bird: depeding on $(OUT) make it unstable.
-$(OUT)genrules.smak: Makefile $(SUBMAK)
-	$(call MKDIR,$(@D))
-	@$(call ECHO,Please wait, rebuilding make rules $@ ...)
+$(OUT)genrules.smak: $(SUBMAK) # Makefile $(wildcard *.smak)
+	@$(call MKDIR,$(OUT))
+	@$(call ECHO,Please wait, rebuilding make rules ...)
 	@$(call RM,$@)
 	@$(call FECHO,$@,# Autogenerated file -- DO NOT EDIT!)
 	@$(subst _@,$@,$(RULES))
 
+# The general a.out -> OMF conversion rule for object files
+$.omf/%.obj: $.aout/%.o
+	$(call DO.AOUT2OMF)
+
+# The general a.out -> OMF conversion rule for libraries
+$.omf%.lib: $.aout%.a
+	$(call DO.AOUT2OMF)
+
 -include $(OUT)genrules.smak
-
Index: trunk/src/emx/build.txt
===================================================================
--- trunk/src/emx/build.txt	(revision 119)
+++ trunk/src/emx/build.txt	(revision 123)
@@ -95,4 +95,7 @@
   'make help' in the module list section.
 
+.MDEP - (optional) module dependencies. This is useful if current module
+  requires another module to be built first (e.g. a library).
+
 .TARGET - The name of target (e.g. executable or library file name without dir).
   For example: .TARGET=myfile.exe
@@ -100,7 +103,7 @@
 .TKIND - (optional) The kind of target. It can consist of up to three
   components, the first one defines the object file format (omf or aout,
-  if not defined defaults to omf), the second defines the threadness
-  (st or mt, defaults to st), third can be 'prof' to build in profiling mode.
-  Example: .TKIND=omf st prof
+  if not defined defaults to omf), the second can be 'prof' to build in
+  profiling mode.
+  Example: .TKIND=omf prof
 
 .TDEP - Dependencies for target (not built from a source file). For example,
@@ -141,5 +144,8 @@
 mklib.smak - this builder creates a library. It defines all rules required
   for building all object files and then runs the librarian which binds all
-  object files together in a single library.
+  object files together in a single library. Besides, if the file format is
+  a.out, it also defines a target called '$(.MODULE)@omf' (e.g. for module
+  zzz it also defines a module called zzz@omf) which will build the OMF
+  library from its a.out counterpart by using emxomf.
 
 Here is a simple example of a submakefile that will build a simple helloworld
@@ -195,5 +201,5 @@
 files from a single source file they are put under different output directories
 (e.g. single-threaded OMF object files go into $(OUT)/omf-st/ directory while
-multi-threaded a.out object files with profiling go into $(OUT)/aout-mt-prof/
+multi-threaded a.out object files with profiling go into $(OUT)/aout-prof/
 directory). This way, you can have several targets that are built from the
 same source files with different compilation options.
Index: trunk/src/emx/common.smak
===================================================================
--- trunk/src/emx/common.smak	(revision 119)
+++ trunk/src/emx/common.smak	(revision 123)
@@ -19,9 +19,4 @@
 .tmp := omf
 endif # neq ($(findstring aout,$(.TKIND)),)
-ifneq ($(findstring mt,$(.TKIND)),)
-.tmp += mt
-else
-.tmp += st
-endif # neq ($(findstring mt,$(.TKIND)),)
 ifneq ($(findstring prof,$(.TKIND)),)
 .tmp += prof
@@ -29,5 +24,6 @@
 .TKIND := $(.tmp)
 .TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
-.tmp :=
+
+ifdef .TARGET
 
 # .TARG is same as .TARGET except that it has a st/ or mt/ prefix
@@ -35,7 +31,24 @@
 
 ifdef .INSDIR
-DO.INSTALL += cp.exe $.$(.TARG) $(INS)$(.INSDIR)$(.TARGET)$(NL)
+DO.INSTALL += $(call CP,$.$(.TARG),$(INS)$(.INSDIR)$(.TARGET))$(NL)
 INSDIRS += $(INS)$(.INSDIR)
 endif # def .INSDIR
+
+# We know how to create dependency files for .c and .cpp files
+.tmp := $(strip $(filter %.c,$(.TSRC)) $(filter %.cpp,$(.TSRC)))
+ifdef .tmp
+# Read the dependency file
+-include $.$(.TKIND.DIR)dep-$(.TARGET).smak
+
+TARGDEPEND += $.$(.TKIND.DIR)dep-$(.TARGET).smak
+
+ifdef BUILD_DEPS
+# How to build the dependency file
+$.$(.TKIND.DIR)dep-$(.TARGET).smak: $(.tmp)
+	$(DO.DEPS)
+endif # BUILD_DEPS
+endif # def .tmp
+
+endif # def .TARGET
 
 # If module has any source files, find respective object file names
@@ -47,5 +60,12 @@
 TARGDIRS += $(.DIRS)
 
+ifdef .MDEP
+$(.MODULE): $(.MDEP)
+.MDEP :=
+endif
+
+ifdef .MODULE
 $(.MODULE): $(.DIRS) $.$(.TARG)
+endif
 
 # Remove the names of files for which we already generated build rules
@@ -61,7 +81,4 @@
 BUILD.RULES += $(.TSRC)
 .TSRC := $(filter-out $(.OBJS),$(subst :, ,$(.TSRC)))
-
-#.TSRC := $(foreach x,$(.TSRC),$(if $(findstring $(call OBJFILE,$x):$x,$(BUILD.RULES)),,$x))
-#BUILD.RULES += $(foreach x,$(.TSRC),$(if $(findstring $(call OBJFILE,$x):$x,$(BUILD.RULES)),,$(call OBJFILE,$x):$x))
 
 # Generate compilation rules for C files
Index: trunk/src/emx/include/ansidecl.h
===================================================================
--- trunk/src/emx/include/ansidecl.h	(revision 123)
+++ trunk/src/emx/include/ansidecl.h	(revision 123)
@@ -0,0 +1,295 @@
+/* ANSI and traditional C compatability macros
+   Copyright 1991, 1992, 1993, 1994, 1995, 1996, 1998, 1999, 2000, 2001
+   Free Software Foundation, Inc.
+   This file is part of the GNU C Library.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* ANSI and traditional C compatibility macros
+
+   ANSI C is assumed if __STDC__ is #defined.
+
+   Macro		ANSI C definition	Traditional C definition
+   -----		---- - ----------	----------- - ----------
+   ANSI_PROTOTYPES	1			not defined
+   PTR			`void *'		`char *'
+   PTRCONST		`void *const'		`char *'
+   LONG_DOUBLE		`long double'		`double'
+   const		not defined		`'
+   volatile		not defined		`'
+   signed		not defined		`'
+   VA_START(ap, var)	va_start(ap, var)	va_start(ap)
+
+   Note that it is safe to write "void foo();" indicating a function
+   with no return value, in all K+R compilers we have been able to test.
+
+   For declaring functions with prototypes, we also provide these:
+
+   PARAMS ((prototype))
+   -- for functions which take a fixed number of arguments.  Use this
+   when declaring the function.  When defining the function, write a
+   K+R style argument list.  For example:
+
+	char *strcpy PARAMS ((char *dest, char *source));
+	...
+	char *
+	strcpy (dest, source)
+	     char *dest;
+	     char *source;
+	{ ... }
+
+
+   VPARAMS ((prototype, ...))
+   -- for functions which take a variable number of arguments.  Use
+   PARAMS to declare the function, VPARAMS to define it.  For example:
+
+	int printf PARAMS ((const char *format, ...));
+	...
+	int
+	printf VPARAMS ((const char *format, ...))
+	{
+	   ...
+	}
+
+   For writing functions which take variable numbers of arguments, we
+   also provide the VA_OPEN, VA_CLOSE, and VA_FIXEDARG macros.  These
+   hide the differences between K+R <varargs.h> and C89 <stdarg.h> more
+   thoroughly than the simple VA_START() macro mentioned above.
+
+   VA_OPEN and VA_CLOSE are used *instead of* va_start and va_end.
+   Immediately after VA_OPEN, put a sequence of VA_FIXEDARG calls
+   corresponding to the list of fixed arguments.  Then use va_arg
+   normally to get the variable arguments, or pass your va_list object
+   around.  You do not declare the va_list yourself; VA_OPEN does it
+   for you.
+
+   Here is a complete example:
+
+	int
+	printf VPARAMS ((const char *format, ...))
+	{
+	   int result;
+
+	   VA_OPEN (ap, format);
+	   VA_FIXEDARG (ap, const char *, format);
+
+	   result = vfprintf (stdout, format, ap);
+	   VA_CLOSE (ap);
+
+	   return result;
+	}
+
+
+   You can declare variables either before or after the VA_OPEN,
+   VA_FIXEDARG sequence.  Also, VA_OPEN and VA_CLOSE are the beginning
+   and end of a block.  They must appear at the same nesting level,
+   and any variables declared after VA_OPEN go out of scope at
+   VA_CLOSE.  Unfortunately, with a K+R compiler, that includes the
+   argument list.  You can have multiple instances of VA_OPEN/VA_CLOSE
+   pairs in a single function in case you need to traverse the
+   argument list more than once.
+
+   For ease of writing code which uses GCC extensions but needs to be
+   portable to other compilers, we provide the GCC_VERSION macro that
+   simplifies testing __GNUC__ and __GNUC_MINOR__ together, and various
+   wrappers around __attribute__.  Also, __extension__ will be #defined
+   to nothing if it doesn't work.  See below.
+
+   This header also defines a lot of obsolete macros:
+   CONST, VOLATILE, SIGNED, PROTO, EXFUN, DEFUN, DEFUN_VOID,
+   AND, DOTS, NOARGS.  Don't use them.  */
+
+#ifndef	_ANSIDECL_H
+#define _ANSIDECL_H	1
+
+/* Every source file includes this file,
+   so they will all get the switch for lint.  */
+/* LINTLIBRARY */
+
+/* Using MACRO(x,y) in cpp #if conditionals does not work with some
+   older preprocessors.  Thus we can't define something like this:
+
+#define HAVE_GCC_VERSION(MAJOR, MINOR) \
+  (__GNUC__ > (MAJOR) || (__GNUC__ == (MAJOR) && __GNUC_MINOR__ >= (MINOR)))
+
+and then test "#if HAVE_GCC_VERSION(2,7)".
+
+So instead we use the macro below and test it against specific values.  */
+
+/* This macro simplifies testing whether we are using gcc, and if it
+   is of a particular minimum version. (Both major & minor numbers are
+   significant.)  This macro will evaluate to 0 if we are not using
+   gcc at all.  */
+#ifndef GCC_VERSION
+#define GCC_VERSION (__GNUC__ * 1000 + __GNUC_MINOR__)
+#endif /* GCC_VERSION */
+
+#if defined (__STDC__) || defined (_AIX) || (defined (__mips) && defined (_SYSTYPE_SVR4)) || defined(_WIN32)
+/* All known AIX compilers implement these things (but don't always
+   define __STDC__).  The RISC/OS MIPS compiler defines these things
+   in SVR4 mode, but does not define __STDC__.  */
+
+#define ANSI_PROTOTYPES	1
+#define PTR		void *
+#define PTRCONST	void *const
+#define LONG_DOUBLE	long double
+
+#define PARAMS(ARGS)		ARGS
+#define VPARAMS(ARGS)		ARGS
+#define VA_START(VA_LIST, VAR)	va_start(VA_LIST, VAR)
+
+/* variadic function helper macros */
+/* "struct Qdmy" swallows the semicolon after VA_OPEN/VA_FIXEDARG's
+   use without inhibiting further decls and without declaring an
+   actual variable.  */
+#define VA_OPEN(AP, VAR)	{ va_list AP; va_start(AP, VAR); { struct Qdmy
+#define VA_CLOSE(AP)		} va_end(AP); }
+#define VA_FIXEDARG(AP, T, N)	struct Qdmy
+ 
+#undef const
+#undef volatile
+#undef signed
+
+/* inline requires special treatment; it's in C99, and GCC >=2.7 supports
+   it too, but it's not in C89.  */
+#undef inline
+#if __STDC_VERSION__ > 199901L
+/* it's a keyword */
+#else
+# if GCC_VERSION >= 2007
+#  define inline __inline__   /* __inline__ prevents -pedantic warnings */
+# else
+#  define inline  /* nothing */
+# endif
+#endif
+
+/* These are obsolete.  Do not use.  */
+#ifndef IN_GCC
+#define CONST		const
+#define VOLATILE	volatile
+#define SIGNED		signed
+
+#define PROTO(type, name, arglist)	type name arglist
+#define EXFUN(name, proto)		name proto
+#define DEFUN(name, arglist, args)	name(args)
+#define DEFUN_VOID(name)		name(void)
+#define AND		,
+#define DOTS		, ...
+#define NOARGS		void
+#endif /* ! IN_GCC */
+
+#else	/* Not ANSI C.  */
+
+#undef  ANSI_PROTOTYPES
+#define PTR		char *
+#define PTRCONST	PTR
+#define LONG_DOUBLE	double
+
+#define PARAMS(args)		()
+#define VPARAMS(args)		(va_alist) va_dcl
+#define VA_START(va_list, var)	va_start(va_list)
+
+#define VA_OPEN(AP, VAR)		{ va_list AP; va_start(AP); { struct Qdmy
+#define VA_CLOSE(AP)			} va_end(AP); }
+#define VA_FIXEDARG(AP, TYPE, NAME)	TYPE NAME = va_arg(AP, TYPE)
+
+/* some systems define these in header files for non-ansi mode */
+#undef const
+#undef volatile
+#undef signed
+#undef inline
+#define const
+#define volatile
+#define signed
+#define inline
+
+#ifndef IN_GCC
+#define CONST
+#define VOLATILE
+#define SIGNED
+
+#define PROTO(type, name, arglist)	type name ()
+#define EXFUN(name, proto)		name()
+#define DEFUN(name, arglist, args)	name arglist args;
+#define DEFUN_VOID(name)		name()
+#define AND		;
+#define DOTS
+#define NOARGS
+#endif /* ! IN_GCC */
+
+#endif	/* ANSI C.  */
+
+/* Define macros for some gcc attributes.  This permits us to use the
+   macros freely, and know that they will come into play for the
+   version of gcc in which they are supported.  */
+
+#if (GCC_VERSION < 2007)
+# define __attribute__(x)
+#endif
+
+/* Attribute __malloc__ on functions was valid as of gcc 2.96. */
+#ifndef ATTRIBUTE_MALLOC
+# if (GCC_VERSION >= 2096)
+#  define ATTRIBUTE_MALLOC __attribute__ ((__malloc__))
+# else
+#  define ATTRIBUTE_MALLOC
+# endif /* GNUC >= 2.96 */
+#endif /* ATTRIBUTE_MALLOC */
+
+/* Attributes on labels were valid as of gcc 2.93. */
+#ifndef ATTRIBUTE_UNUSED_LABEL
+# if (GCC_VERSION >= 2093)
+#  define ATTRIBUTE_UNUSED_LABEL ATTRIBUTE_UNUSED
+# else
+#  define ATTRIBUTE_UNUSED_LABEL
+# endif /* GNUC >= 2.93 */
+#endif /* ATTRIBUTE_UNUSED_LABEL */
+
+#ifndef ATTRIBUTE_UNUSED
+#define ATTRIBUTE_UNUSED __attribute__ ((__unused__))
+#endif /* ATTRIBUTE_UNUSED */
+
+#ifndef ATTRIBUTE_NORETURN
+#define ATTRIBUTE_NORETURN __attribute__ ((__noreturn__))
+#endif /* ATTRIBUTE_NORETURN */
+
+#ifndef ATTRIBUTE_PRINTF
+#define ATTRIBUTE_PRINTF(m, n) __attribute__ ((__format__ (__printf__, m, n)))
+#define ATTRIBUTE_PRINTF_1 ATTRIBUTE_PRINTF(1, 2)
+#define ATTRIBUTE_PRINTF_2 ATTRIBUTE_PRINTF(2, 3)
+#define ATTRIBUTE_PRINTF_3 ATTRIBUTE_PRINTF(3, 4)
+#define ATTRIBUTE_PRINTF_4 ATTRIBUTE_PRINTF(4, 5)
+#define ATTRIBUTE_PRINTF_5 ATTRIBUTE_PRINTF(5, 6)
+#endif /* ATTRIBUTE_PRINTF */
+
+/* We use __extension__ in some places to suppress -pedantic warnings
+   about GCC extensions.  This feature didn't work properly before
+   gcc 2.8.  */
+#if GCC_VERSION < 2008
+#define __extension__
+#endif
+
+/* Bootstrap support:  Adjust certain macros defined by Autoconf,
+   which are only valid for the stage1 compiler.  If we detect
+   a modern version of GCC, we are probably in stage2 or beyond,
+   so unconditionally reset the values.  Note that const, inline,
+   etc. have been dealt with above.  */
+#if (GCC_VERSION >= 2007)
+# ifndef HAVE_LONG_DOUBLE
+#  define HAVE_LONG_DOUBLE 1
+# endif
+#endif /* GCC >= 2.7 */
+
+#endif	/* ansidecl.h	*/
Index: trunk/src/emx/include/ctype.h
===================================================================
--- trunk/src/emx/include/ctype.h	(revision 119)
+++ trunk/src/emx/include/ctype.h	(revision 123)
@@ -46,15 +46,15 @@
 #else
 
-#define isalnum(c)  ((_ctype+1)[c] & (_UPPER|_LOWER|_DIGIT))
-#define isalpha(c)  ((_ctype+1)[c] & (_UPPER|_LOWER))
-#define iscntrl(c)  ((_ctype+1)[c] & (_CNTRL))
-#define isdigit(c)  ((_ctype+1)[c] & (_DIGIT))
-#define isgraph(c)  ((_ctype+1)[c] & (_PUNCT|_UPPER|_LOWER|_DIGIT))
-#define islower(c)  ((_ctype+1)[c] & (_LOWER))
-#define isprint(c)  ((_ctype+1)[c] & (_PRINT))
-#define ispunct(c)  ((_ctype+1)[c] & (_PUNCT))
-#define isspace(c)  ((_ctype+1)[c] & (_SPACE))
-#define isupper(c)  ((_ctype+1)[c] & (_UPPER))
-#define isxdigit(c) ((_ctype+1)[c] & (_XDIGIT))
+#define isalnum(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER|_DIGIT))
+#define isalpha(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER|_LOWER))
+#define iscntrl(c)  ((_ctype+1)[(unsigned char)c] & (_CNTRL))
+#define isdigit(c)  ((_ctype+1)[(unsigned char)c] & (_DIGIT))
+#define isgraph(c)  ((_ctype+1)[(unsigned char)c] & (_PUNCT|_UPPER|_LOWER|_DIGIT))
+#define islower(c)  ((_ctype+1)[(unsigned char)c] & (_LOWER))
+#define isprint(c)  ((_ctype+1)[(unsigned char)c] & (_PRINT))
+#define ispunct(c)  ((_ctype+1)[(unsigned char)c] & (_PUNCT))
+#define isspace(c)  ((_ctype+1)[(unsigned char)c] & (_SPACE))
+#define isupper(c)  ((_ctype+1)[(unsigned char)c] & (_UPPER))
+#define isxdigit(c) ((_ctype+1)[(unsigned char)c] & (_XDIGIT))
 
 int (isalnum)(int);
Index: trunk/src/emx/include/demangle.h
===================================================================
--- trunk/src/emx/include/demangle.h	(revision 123)
+++ trunk/src/emx/include/demangle.h	(revision 123)
@@ -0,0 +1,163 @@
+/* Defs for interface to demanglers.
+   Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001
+   Free Software Foundation, Inc.
+   
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+
+#if !defined (DEMANGLE_H)
+#define DEMANGLE_H
+
+#include <ansidecl.h>
+
+/* Options passed to cplus_demangle (in 2nd parameter). */
+
+#define DMGL_NO_OPTS	 0		/* For readability... */
+#define DMGL_PARAMS	 (1 << 0)	/* Include function args */
+#define DMGL_ANSI	 (1 << 1)	/* Include const, volatile, etc */
+#define DMGL_JAVA	 (1 << 2)	/* Demangle as Java rather than C++. */
+#define DMGL_VERBOSE	 (1 << 3)	/* Include implementation details.  */
+#define DMGL_TYPES	 (1 << 4)	/* Also try to demangle type encodings.  */
+
+#define DMGL_AUTO	 (1 << 8)
+#define DMGL_GNU	 (1 << 9)
+#define DMGL_LUCID	 (1 << 10)
+#define DMGL_ARM	 (1 << 11)
+#define DMGL_HP 	 (1 << 12)       /* For the HP aCC compiler;
+                                            same as ARM except for
+                                            template arguments, etc. */
+#define DMGL_EDG	 (1 << 13)
+#define DMGL_GNU_V3	 (1 << 14)
+#define DMGL_GNAT	 (1 << 15)
+
+/* If none of these are set, use 'current_demangling_style' as the default. */
+#define DMGL_STYLE_MASK (DMGL_AUTO|DMGL_GNU|DMGL_LUCID|DMGL_ARM|DMGL_HP|DMGL_EDG|DMGL_GNU_V3|DMGL_JAVA|DMGL_GNAT)
+
+/* Enumeration of possible demangling styles.
+
+   Lucid and ARM styles are still kept logically distinct, even though
+   they now both behave identically.  The resulting style is actual the
+   union of both.  I.E. either style recognizes both "__pt__" and "__rf__"
+   for operator "->", even though the first is lucid style and the second
+   is ARM style. (FIXME?) */
+
+extern enum demangling_styles
+{
+  no_demangling = -1,
+  unknown_demangling = 0,
+  auto_demangling = DMGL_AUTO,
+  gnu_demangling = DMGL_GNU,
+  lucid_demangling = DMGL_LUCID,
+  arm_demangling = DMGL_ARM,
+  hp_demangling = DMGL_HP,
+  edg_demangling = DMGL_EDG,
+  gnu_v3_demangling = DMGL_GNU_V3,
+  java_demangling = DMGL_JAVA,
+  gnat_demangling = DMGL_GNAT
+} current_demangling_style;
+
+/* Define string names for the various demangling styles. */
+
+#define NO_DEMANGLING_STYLE_STRING            "none"
+#define AUTO_DEMANGLING_STYLE_STRING	      "auto"
+#define GNU_DEMANGLING_STYLE_STRING    	      "gnu"
+#define LUCID_DEMANGLING_STYLE_STRING	      "lucid"
+#define ARM_DEMANGLING_STYLE_STRING	      "arm"
+#define HP_DEMANGLING_STYLE_STRING	      "hp"
+#define EDG_DEMANGLING_STYLE_STRING	      "edg"
+#define GNU_V3_DEMANGLING_STYLE_STRING        "gnu-v3"
+#define JAVA_DEMANGLING_STYLE_STRING          "java"
+#define GNAT_DEMANGLING_STYLE_STRING          "gnat"
+
+/* Some macros to test what demangling style is active. */
+
+#define CURRENT_DEMANGLING_STYLE current_demangling_style
+#define AUTO_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_AUTO)
+#define GNU_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU)
+#define LUCID_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_LUCID)
+#define ARM_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_ARM)
+#define HP_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_HP)
+#define EDG_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_EDG)
+#define GNU_V3_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNU_V3)
+#define JAVA_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_JAVA)
+#define GNAT_DEMANGLING (((int) CURRENT_DEMANGLING_STYLE) & DMGL_GNAT)
+
+/* Provide information about the available demangle styles. This code is
+   pulled from gdb into libiberty because it is useful to binutils also.  */
+
+extern const struct demangler_engine
+{
+  const char *const demangling_style_name;
+  const enum demangling_styles demangling_style;
+  const char *const demangling_style_doc;
+} libiberty_demanglers[];
+
+extern char *
+cplus_demangle PARAMS ((const char *mangled, int options));
+
+extern int
+cplus_demangle_opname PARAMS ((const char *opname, char *result, int options));
+
+extern const char *
+cplus_mangle_opname PARAMS ((const char *opname, int options));
+
+/* Note: This sets global state.  FIXME if you care about multi-threading. */
+
+extern void
+set_cplus_marker_for_demangling PARAMS ((int ch));
+
+extern enum demangling_styles 
+cplus_demangle_set_style PARAMS ((enum demangling_styles style));
+
+extern enum demangling_styles 
+cplus_demangle_name_to_style PARAMS ((const char *name));
+
+/* V3 ABI demangling entry points, defined in cp-demangle.c.  */
+extern char*
+cplus_demangle_v3 PARAMS ((const char* mangled, int options));
+
+extern char*
+java_demangle_v3 PARAMS ((const char* mangled));
+
+
+enum gnu_v3_ctor_kinds {
+  gnu_v3_complete_object_ctor = 1,
+  gnu_v3_base_object_ctor,
+  gnu_v3_complete_object_allocating_ctor
+};
+
+/* Return non-zero iff NAME is the mangled form of a constructor name
+   in the G++ V3 ABI demangling style.  Specifically, return an `enum
+   gnu_v3_ctor_kinds' value indicating what kind of constructor
+   it is.  */
+extern enum gnu_v3_ctor_kinds
+	is_gnu_v3_mangled_ctor PARAMS ((const char *name));
+
+
+enum gnu_v3_dtor_kinds {
+  gnu_v3_deleting_dtor = 1,
+  gnu_v3_complete_object_dtor,
+  gnu_v3_base_object_dtor
+};
+
+/* Return non-zero iff NAME is the mangled form of a destructor name
+   in the G++ V3 ABI demangling style.  Specifically, return an `enum
+   gnu_v3_dtor_kinds' value, indicating what kind of destructor
+   it is.  */
+extern enum gnu_v3_dtor_kinds
+	is_gnu_v3_mangled_dtor PARAMS ((const char *name));
+
+#endif	/* DEMANGLE_H */
Index: trunk/src/emx/include/dyn-string.h
===================================================================
--- trunk/src/emx/include/dyn-string.h	(revision 123)
+++ trunk/src/emx/include/dyn-string.h	(revision 123)
@@ -0,0 +1,92 @@
+/* An abstract string datatype.
+   Copyright (C) 1998, 1999, 2000, 2002 Free Software Foundation, Inc.
+   Contributed by Mark Mitchell (mark@markmitchell.com).
+
+This file is part of GCC.
+   
+GCC is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+
+typedef struct dyn_string
+{
+  int allocated;	/* The amount of space allocated for the string.  */
+  int length;		/* The actual length of the string.  */
+  char *s;		/* The string itself, NUL-terminated.  */
+}* dyn_string_t;
+
+/* The length STR, in bytes, not including the terminating NUL.  */
+#define dyn_string_length(STR)                                          \
+  ((STR)->length)
+
+/* The NTBS in which the contents of STR are stored.  */
+#define dyn_string_buf(STR)                                             \
+  ((STR)->s)
+
+/* Compare DS1 to DS2 with strcmp.  */
+#define dyn_string_compare(DS1, DS2)                                    \
+  (strcmp ((DS1)->s, (DS2)->s))
+
+
+/* dyn_string functions are used in the demangling implementation
+   included in the G++ runtime library.  To prevent collisions with
+   names in user programs, the functions that are used in the
+   demangler are given implementation-reserved names.  */
+
+#if defined(IN_LIBGCC2) || defined(IN_GLIBCPP_V3)
+
+#define dyn_string_init                 __cxa_dyn_string_init
+#define dyn_string_new                  __cxa_dyn_string_new
+#define dyn_string_delete               __cxa_dyn_string_delete
+#define dyn_string_release              __cxa_dyn_string_release
+#define dyn_string_resize               __cxa_dyn_string_resize
+#define dyn_string_clear                __cxa_dyn_string_clear
+#define dyn_string_copy                 __cxa_dyn_string_copy
+#define dyn_string_copy_cstr            __cxa_dyn_string_copy_cstr
+#define dyn_string_prepend              __cxa_dyn_string_prepend
+#define dyn_string_prepend_cstr         __cxa_dyn_string_prepend_cstr
+#define dyn_string_insert               __cxa_dyn_string_insert
+#define dyn_string_insert_cstr          __cxa_dyn_string_insert_cstr
+#define dyn_string_insert_char          __cxa_dyn_string_insert_char
+#define dyn_string_append               __cxa_dyn_string_append
+#define dyn_string_append_cstr          __cxa_dyn_string_append_cstr
+#define dyn_string_append_char          __cxa_dyn_string_append_char
+#define dyn_string_substring            __cxa_dyn_string_substring
+#define dyn_string_eq                   __cxa_dyn_string_eq
+
+#endif /* IN_LIBGCC2 || IN_GLIBCPP_V3 */
+
+
+extern int dyn_string_init              PARAMS ((struct dyn_string *, int));
+extern dyn_string_t dyn_string_new      PARAMS ((int));
+extern void dyn_string_delete           PARAMS ((dyn_string_t));
+extern char *dyn_string_release         PARAMS ((dyn_string_t));
+extern dyn_string_t dyn_string_resize   PARAMS ((dyn_string_t, int));
+extern void dyn_string_clear            PARAMS ((dyn_string_t));
+extern int dyn_string_copy              PARAMS ((dyn_string_t, dyn_string_t));
+extern int dyn_string_copy_cstr         PARAMS ((dyn_string_t, const char *));
+extern int dyn_string_prepend           PARAMS ((dyn_string_t, dyn_string_t));
+extern int dyn_string_prepend_cstr      PARAMS ((dyn_string_t, const char *));
+extern int dyn_string_insert            PARAMS ((dyn_string_t, int,
+						 dyn_string_t));
+extern int dyn_string_insert_cstr       PARAMS ((dyn_string_t, int,
+						 const char *));
+extern int dyn_string_insert_char       PARAMS ((dyn_string_t, int, int));
+extern int dyn_string_append            PARAMS ((dyn_string_t, dyn_string_t));
+extern int dyn_string_append_cstr       PARAMS ((dyn_string_t, const char *));
+extern int dyn_string_append_char       PARAMS ((dyn_string_t, int));
+extern int dyn_string_substring         PARAMS ((dyn_string_t, 
+						 dyn_string_t, int, int));
+extern int dyn_string_eq                PARAMS ((dyn_string_t, dyn_string_t));
Index: trunk/src/emx/include/emx/fnmatch.h
===================================================================
--- trunk/src/emx/include/emx/fnmatch.h	(revision 123)
+++ trunk/src/emx/include/emx/fnmatch.h	(revision 123)
@@ -0,0 +1,46 @@
+/* fnmatch.h (emx+gcc) */
+
+#ifndef _FNMATCH_H
+#define _FNMATCH_H
+
+#if defined (__cplusplus)
+extern "C" {
+#endif
+
+/* POSIX.2 */
+
+#define FNM_NOMATCH        1
+
+#define FNM_NOESCAPE       16
+#define FNM_PATHNAME       32
+#define FNM_PERIOD         64
+
+int fnmatch (__const__ char *, __const__ char *, int);
+
+
+#if !defined (_POSIX_SOURCE) || defined (_WITH_UNDERSCORE)
+
+/* emx extensions */
+
+#define _FNM_MATCH         0
+#define _FNM_ERR           2
+
+#define _FNM_STYLE_MASK    15
+
+#define _FNM_POSIX         0
+#define _FNM_OS2           1
+#define _FNM_DOS           2
+
+#define _FNM_IGNORECASE    128
+#define _FNM_PATHPREFIX    256
+
+int _fnmatch (__const__ char *, __const__ char *, int);
+
+#endif
+
+
+#if defined (__cplusplus)
+}
+#endif
+
+#endif /* not _FNMATCH_H */
Index: trunk/src/emx/include/fibheap.h
===================================================================
--- trunk/src/emx/include/fibheap.h	(revision 123)
+++ trunk/src/emx/include/fibheap.h	(revision 123)
@@ -0,0 +1,81 @@
+/* A Fibonacci heap datatype.
+   Copyright 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
+   Contributed by Daniel Berlin (dan@cgsoftware.com).
+
+This file is part of GCC.
+   
+GCC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* Fibonacci heaps are somewhat complex, but, there's an article in
+   DDJ that explains them pretty well:
+
+   http://www.ddj.com/articles/1997/9701/9701o/9701o.htm?topic=algoritms
+
+   Introduction to algorithms by Corman and Rivest also goes over them.
+
+   The original paper that introduced them is "Fibonacci heaps and their
+   uses in improved network optimization algorithms" by Tarjan and
+   Fredman (JACM 34(3), July 1987).
+
+   Amortized and real worst case time for operations:
+
+   ExtractMin: O(lg n) amortized. O(n) worst case.
+   DecreaseKey: O(1) amortized.  O(lg n) worst case. 
+   Insert: O(2) amortized. O(1) actual.  
+   Union: O(1) amortized. O(1) actual.  */
+
+#ifndef _FIBHEAP_H_
+#define _FIBHEAP_H_
+
+#include <ansidecl.h>
+
+typedef long fibheapkey_t;
+
+typedef struct fibheap
+{
+  size_t nodes;
+  struct fibnode *min;
+  struct fibnode *root;
+} *fibheap_t;
+
+typedef struct fibnode
+{
+  struct fibnode *parent;
+  struct fibnode *child;
+  struct fibnode *left;
+  struct fibnode *right;
+  fibheapkey_t key;
+  void *data;
+  unsigned int degree : 31;
+  unsigned int mark : 1;
+} *fibnode_t;
+
+extern fibheap_t fibheap_new PARAMS ((void));
+extern fibnode_t fibheap_insert PARAMS ((fibheap_t, fibheapkey_t, void *));
+extern int fibheap_empty PARAMS ((fibheap_t));
+extern fibheapkey_t fibheap_min_key PARAMS ((fibheap_t));
+extern fibheapkey_t fibheap_replace_key PARAMS ((fibheap_t, fibnode_t,
+						 fibheapkey_t));
+extern void *fibheap_replace_key_data PARAMS ((fibheap_t, fibnode_t,
+					       fibheapkey_t, void *));
+extern void *fibheap_extract_min PARAMS ((fibheap_t));
+extern void *fibheap_min PARAMS ((fibheap_t));
+extern void *fibheap_replace_data PARAMS ((fibheap_t, fibnode_t, void *));
+extern void *fibheap_delete_node PARAMS ((fibheap_t, fibnode_t));
+extern void fibheap_delete PARAMS ((fibheap_t));
+extern fibheap_t fibheap_union PARAMS ((fibheap_t, fibheap_t));
+
+#endif /* _FIBHEAP_H_ */
Index: trunk/src/emx/include/floatformat.h
===================================================================
--- trunk/src/emx/include/floatformat.h	(revision 123)
+++ trunk/src/emx/include/floatformat.h	(revision 123)
@@ -0,0 +1,122 @@
+/* IEEE floating point support declarations, for GDB, the GNU Debugger.
+   Copyright 1991, 1994, 1995, 1997, 2000 Free Software Foundation, Inc.
+
+This file is part of GDB.
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#if !defined (FLOATFORMAT_H)
+#define FLOATFORMAT_H 1
+
+#include "ansidecl.h"
+
+/* A floatformat consists of a sign bit, an exponent and a mantissa.  Once the
+   bytes are concatenated according to the byteorder flag, then each of those
+   fields is contiguous.  We number the bits with 0 being the most significant
+   (i.e. BITS_BIG_ENDIAN type numbering), and specify which bits each field
+   contains with the *_start and *_len fields.  */
+
+/* What is the order of the bytes. */
+
+enum floatformat_byteorders {
+
+  /* Standard little endian byte order.
+     EX: 1.2345678e10 => 00 00 80 c5 e0 fe 06 42 */
+
+  floatformat_little,
+
+  /* Standard big endian byte order.
+     EX: 1.2345678e10 => 42 06 fe e0 c5 80 00 00 */
+
+  floatformat_big,
+
+  /* Little endian byte order but big endian word order.
+     EX: 1.2345678e10 => e0 fe 06 42 00 00 80 c5 */
+
+  floatformat_littlebyte_bigword
+
+};
+
+enum floatformat_intbit { floatformat_intbit_yes, floatformat_intbit_no };
+
+struct floatformat
+{
+  enum floatformat_byteorders byteorder;
+  unsigned int totalsize;	/* Total size of number in bits */
+
+  /* Sign bit is always one bit long.  1 means negative, 0 means positive.  */
+  unsigned int sign_start;
+
+  unsigned int exp_start;
+  unsigned int exp_len;
+  /* Amount added to "true" exponent.  0x3fff for many IEEE extendeds.  */
+  unsigned int exp_bias;
+  /* Exponent value which indicates NaN.  This is the actual value stored in
+     the float, not adjusted by the exp_bias.  This usually consists of all
+     one bits.  */
+  unsigned int exp_nan;
+
+  unsigned int man_start;
+  unsigned int man_len;
+
+  /* Is the integer bit explicit or implicit?  */
+  enum floatformat_intbit intbit;
+
+  /* Internal name for debugging. */
+  const char *name;
+};
+
+/* floatformats for IEEE single and double, big and little endian.  */
+
+extern const struct floatformat floatformat_ieee_single_big;
+extern const struct floatformat floatformat_ieee_single_little;
+extern const struct floatformat floatformat_ieee_double_big;
+extern const struct floatformat floatformat_ieee_double_little;
+
+/* floatformat for ARM IEEE double, little endian bytes and big endian words */
+
+extern const struct floatformat floatformat_ieee_double_littlebyte_bigword;
+
+/* floatformats for various extendeds.  */
+
+extern const struct floatformat floatformat_i387_ext;
+extern const struct floatformat floatformat_m68881_ext;
+extern const struct floatformat floatformat_i960_ext;
+extern const struct floatformat floatformat_m88110_ext;
+extern const struct floatformat floatformat_m88110_harris_ext;
+extern const struct floatformat floatformat_arm_ext; /* deprecated. */
+extern const struct floatformat floatformat_arm_ext_big;
+extern const struct floatformat floatformat_arm_ext_littlebyte_bigword;
+/* IA-64 Floating Point register spilt into memory.  */
+extern const struct floatformat floatformat_ia64_spill_big;
+extern const struct floatformat floatformat_ia64_spill_little;
+extern const struct floatformat floatformat_ia64_quad_big;
+extern const struct floatformat floatformat_ia64_quad_little;
+
+/* Convert from FMT to a double.
+   FROM is the address of the extended float.
+   Store the double in *TO.  */
+
+extern void
+floatformat_to_double PARAMS ((const struct floatformat *, char *, double *));
+
+/* The converse: convert the double *FROM to FMT
+   and store where TO points.  */
+
+extern void
+floatformat_from_double PARAMS ((const struct floatformat *,
+				 double *, char *));
+
+#endif	/* defined (FLOATFORMAT_H) */
Index: trunk/src/emx/include/fnmatch.h
===================================================================
--- trunk/src/emx/include/fnmatch.h	(revision 119)
+++ trunk/src/emx/include/fnmatch.h	(revision 123)
@@ -1,46 +1,70 @@
-/* fnmatch.h (emx+gcc) */
+/* Copyright 1991, 1992, 1993, 1996 Free Software Foundation, Inc.
 
-#ifndef _FNMATCH_H
-#define _FNMATCH_H
+NOTE: The canonical source of this file is maintained with the GNU C Library.
+Bugs can be reported to bug-glibc@prep.ai.mit.edu.
 
-#if defined (__cplusplus)
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef	_FNMATCH_H
+
+#define	_FNMATCH_H	1
+
+#ifdef	__cplusplus
 extern "C" {
 #endif
 
-/* POSIX.2 */
-
-#define FNM_NOMATCH        1
-
-#define FNM_NOESCAPE       16
-#define FNM_PATHNAME       32
-#define FNM_PERIOD         64
-
-int fnmatch (__const__ char *, __const__ char *, int);
+#if defined (__cplusplus) || (defined (__STDC__) && __STDC__)
+#undef	__P
+#define	__P(args)	args
+#else /* Not C++ or ANSI C.  */
+#undef	__P
+#define	__P(args)	()
+/* We can get away without defining `const' here only because in this file
+   it is used only inside the prototype for `fnmatch', which is elided in
+   non-ANSI C where `const' is problematical.  */
+#endif /* C++ or ANSI C.  */
 
 
-#if !defined (_POSIX_SOURCE) || defined (_WITH_UNDERSCORE)
+/* We #undef these before defining them because some losing systems
+   (HP-UX A.08.07 for example) define these in <unistd.h>.  */
+#undef	FNM_PATHNAME
+#undef	FNM_NOESCAPE
+#undef	FNM_PERIOD
 
-/* emx extensions */
+/* Bits set in the FLAGS argument to `fnmatch'.  */
+#define	FNM_PATHNAME	(1 << 0) /* No wildcard can ever match `/'.  */
+#define	FNM_NOESCAPE	(1 << 1) /* Backslashes don't quote special chars.  */
+#define	FNM_PERIOD	(1 << 2) /* Leading `.' is matched only explicitly.  */
 
-#define _FNM_MATCH         0
-#define _FNM_ERR           2
-
-#define _FNM_STYLE_MASK    15
-
-#define _FNM_POSIX         0
-#define _FNM_OS2           1
-#define _FNM_DOS           2
-
-#define _FNM_IGNORECASE    128
-#define _FNM_PATHPREFIX    256
-
-int _fnmatch (__const__ char *, __const__ char *, int);
-
+#if !defined (_POSIX_C_SOURCE) || _POSIX_C_SOURCE < 2 || defined (_GNU_SOURCE)
+#define	FNM_FILE_NAME	FNM_PATHNAME /* Preferred GNU name.  */
+#define	FNM_LEADING_DIR	(1 << 3) /* Ignore `/...' after a match.  */
+#define	FNM_CASEFOLD	(1 << 4) /* Compare without regard to case.  */
 #endif
 
+/* Value returned by `fnmatch' if STRING does not match PATTERN.  */
+#define	FNM_NOMATCH	1
 
-#if defined (__cplusplus)
+/* Match STRING against the filename pattern PATTERN,
+   returning zero if it matches, FNM_NOMATCH if not.  */
+extern int fnmatch __P ((const char *__pattern, const char *__string,
+			 int __flags));
+
+#ifdef	__cplusplus
 }
 #endif
 
-#endif /* not _FNMATCH_H */
+#endif /* fnmatch.h */
Index: trunk/src/emx/include/getopt.h
===================================================================
--- trunk/src/emx/include/getopt.h	(revision 119)
+++ trunk/src/emx/include/getopt.h	(revision 123)
@@ -1,4 +1,5 @@
 /* Declarations for getopt.
-   Copyright (C) 1989,90,91,92,93,94,96,97 Free Software Foundation, Inc.
+   Copyright 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998, 2000
+   Free Software Foundation, Inc.
 
    NOTE: The canonical source of this file is maintained with the GNU C Library.
@@ -100,5 +101,10 @@
 
 #if defined (__STDC__) && __STDC__
-#ifdef __GNU_LIBRARY__
+/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1.  If it is
+   undefined, we haven't run the autoconf check so provide the
+   declaration without arguments.  If it is 0, we checked and failed
+   to find the declaration so provide a fully prototyped one.  If it
+   is 1, we found it so don't provide any declaration at all.  */
+#if defined (__GNU_LIBRARY__) || (defined (HAVE_DECL_GETOPT) && !HAVE_DECL_GETOPT)
 /* Many other libraries have conflicting prototypes for getopt, with
    differences in the consts, in stdlib.h.  To avoid compilation
@@ -106,5 +112,7 @@
 extern int getopt (int argc, char *const *argv, const char *shortopts);
 #else /* not __GNU_LIBRARY__ */
+# if !defined (HAVE_DECL_GETOPT) && !defined (__cplusplus)
 extern int getopt ();
+# endif
 #endif /* __GNU_LIBRARY__ */
 extern int getopt_long (int argc, char *const *argv, const char *shortopts,
Index: trunk/src/emx/include/hashtab.h
===================================================================
--- trunk/src/emx/include/hashtab.h	(revision 123)
+++ trunk/src/emx/include/hashtab.h	(revision 123)
@@ -0,0 +1,155 @@
+/* An expandable hash tables datatype.  
+   Copyright (C) 1999, 2000 Free Software Foundation, Inc.
+   Contributed by Vladimir Makarov (vmakarov@cygnus.com).
+
+This program is free software; you can redistribute it and/or modify
+it under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2 of the License, or
+(at your option) any later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+/* This package implements basic hash table functionality.  It is possible
+   to search for an entry, create an entry and destroy an entry.
+
+   Elements in the table are generic pointers.
+
+   The size of the table is not fixed; if the occupancy of the table
+   grows too high the hash table will be expanded.
+
+   The abstract data implementation is based on generalized Algorithm D
+   from Knuth's book "The art of computer programming".  Hash table is
+   expanded by creation of new hash table and transferring elements from
+   the old table to the new table.  */
+
+#ifndef __HASHTAB_H__
+#define __HASHTAB_H__
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ansidecl.h>
+
+/* The type for a hash code.  */
+typedef unsigned int hashval_t;
+
+/* Callback function pointer types.  */
+
+/* Calculate hash of a table entry.  */
+typedef hashval_t (*htab_hash) PARAMS ((const void *));
+
+/* Compare a table entry with a possible entry.  The entry already in
+   the table always comes first, so the second element can be of a
+   different type (but in this case htab_find and htab_find_slot
+   cannot be used; instead the variants that accept a hash value
+   must be used).  */
+typedef int (*htab_eq) PARAMS ((const void *, const void *));
+
+/* Cleanup function called whenever a live element is removed from
+   the hash table.  */
+typedef void (*htab_del) PARAMS ((void *));
+  
+/* Function called by htab_traverse for each live element.  The first
+   arg is the slot of the element (which can be passed to htab_clear_slot
+   if desired), the second arg is the auxiliary pointer handed to
+   htab_traverse.  Return 1 to continue scan, 0 to stop.  */
+typedef int (*htab_trav) PARAMS ((void **, void *));
+
+/* Hash tables are of the following type.  The structure
+   (implementation) of this type is not needed for using the hash
+   tables.  All work with hash table should be executed only through
+   functions mentioned below. */
+
+struct htab
+{
+  /* Pointer to hash function.  */
+  htab_hash hash_f;
+
+  /* Pointer to comparison function.  */
+  htab_eq eq_f;
+
+  /* Pointer to cleanup function.  */
+  htab_del del_f;
+
+  /* Table itself.  */
+  PTR *entries;
+
+  /* Current size (in entries) of the hash table */
+  size_t size;
+
+  /* Current number of elements including also deleted elements */
+  size_t n_elements;
+
+  /* Current number of deleted elements in the table */
+  size_t n_deleted;
+
+  /* The following member is used for debugging. Its value is number
+     of all calls of `htab_find_slot' for the hash table. */
+  unsigned int searches;
+
+  /* The following member is used for debugging.  Its value is number
+     of collisions fixed for time of work with the hash table. */
+  unsigned int collisions;
+
+  /* This is non-zero if we are allowed to return NULL for function calls
+     that allocate memory.  */
+  int return_allocation_failure;
+};
+
+typedef struct htab *htab_t;
+
+/* An enum saying whether we insert into the hash table or not.  */
+enum insert_option {NO_INSERT, INSERT};
+
+/* The prototypes of the package functions. */
+
+extern htab_t	htab_create	PARAMS ((size_t, htab_hash,
+					 htab_eq, htab_del));
+
+/* This function is like htab_create, but may return NULL if memory
+   allocation fails, and also signals that htab_find_slot_with_hash and
+   htab_find_slot are allowed to return NULL when inserting.  */
+extern htab_t	htab_try_create	PARAMS ((size_t, htab_hash,
+					 htab_eq, htab_del));
+extern void	htab_delete	PARAMS ((htab_t));
+extern void	htab_empty	PARAMS ((htab_t));
+
+extern PTR	htab_find	PARAMS ((htab_t, const void *));
+extern PTR     *htab_find_slot	PARAMS ((htab_t, const void *,
+					 enum insert_option));
+extern PTR	htab_find_with_hash	  PARAMS ((htab_t, const void *,
+						   hashval_t));
+extern PTR     *htab_find_slot_with_hash  PARAMS ((htab_t, const void *,
+						   hashval_t,
+						   enum insert_option));
+extern void	htab_clear_slot	PARAMS ((htab_t, void **));
+extern void	htab_remove_elt	PARAMS ((htab_t, void *));
+
+extern void	htab_traverse	PARAMS ((htab_t, htab_trav, void *));
+
+extern size_t	htab_size	PARAMS ((htab_t));
+extern size_t	htab_elements	PARAMS ((htab_t));
+extern double	htab_collisions	PARAMS ((htab_t));
+
+/* A hash function for pointers.  */
+extern htab_hash htab_hash_pointer;
+
+/* An equality function for pointers.  */
+extern htab_eq htab_eq_pointer;
+
+/* A hash function for null-terminated strings.  */
+extern hashval_t htab_hash_string PARAMS ((const PTR));
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* __HASHTAB_H */
Index: trunk/src/emx/include/libiberty.h
===================================================================
--- trunk/src/emx/include/libiberty.h	(revision 123)
+++ trunk/src/emx/include/libiberty.h	(revision 123)
@@ -0,0 +1,317 @@
+/* Function declarations for libiberty.
+
+   Copyright 2001, 2002 Free Software Foundation, Inc.
+   
+   Note - certain prototypes declared in this header file are for
+   functions whoes implementation copyright does not belong to the
+   FSF.  Those prototypes are present in this file for reference
+   purposes only and their presence in this file should not construed
+   as an indication of ownership by the FSF of the implementation of
+   those functions in any way or form whatsoever.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.
+   
+   Written by Cygnus Support, 1994.
+
+   The libiberty library provides a number of functions which are
+   missing on some operating systems.  We do not declare those here,
+   to avoid conflicts with the system header files on operating
+   systems that do support those functions.  In this file we only
+   declare those functions which are specific to libiberty.  */
+
+#ifndef LIBIBERTY_H
+#define LIBIBERTY_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+#include "ansidecl.h"
+
+#ifdef ANSI_PROTOTYPES
+/* Get a definition for size_t.  */
+#include <stddef.h>
+/* Get a definition for va_list.  */
+#include <stdarg.h>
+#endif
+
+/* Build an argument vector from a string.  Allocates memory using
+   malloc.  Use freeargv to free the vector.  */
+
+extern char **buildargv PARAMS ((const char *)) ATTRIBUTE_MALLOC;
+
+/* Free a vector returned by buildargv.  */
+
+extern void freeargv PARAMS ((char **));
+
+/* Duplicate an argument vector. Allocates memory using malloc.  Use
+   freeargv to free the vector.  */
+
+extern char **dupargv PARAMS ((char **)) ATTRIBUTE_MALLOC;
+
+
+/* Return the last component of a path name.  Note that we can't use a
+   prototype here because the parameter is declared inconsistently
+   across different systems, sometimes as "char *" and sometimes as
+   "const char *" */
+
+/* HAVE_DECL_* is a three-state macro: undefined, 0 or 1.  If it is
+   undefined, we haven't run the autoconf check so provide the
+   declaration without arguments.  If it is 0, we checked and failed
+   to find the declaration so provide a fully prototyped one.  If it
+   is 1, we found it so don't provide any declaration at all.  */
+#if defined (__GNU_LIBRARY__ ) || defined (__linux__) || defined (__FreeBSD__) || defined (__OpenBSD__) || defined (__CYGWIN__) || defined (__CYGWIN32__) || (defined (HAVE_DECL_BASENAME) && !HAVE_DECL_BASENAME)
+extern char *basename PARAMS ((const char *));
+#else
+# if !defined (HAVE_DECL_BASENAME)
+extern char *basename ();
+# endif
+#endif
+
+/* A well-defined basename () that is always compiled in.  */
+
+extern const char *lbasename PARAMS ((const char *));
+
+/* Concatenate an arbitrary number of strings.  You must pass NULL as
+   the last argument of this function, to terminate the list of
+   strings.  Allocates memory using xmalloc.  */
+
+extern char *concat PARAMS ((const char *, ...)) ATTRIBUTE_MALLOC;
+
+/* Concatenate an arbitrary number of strings.  You must pass NULL as
+   the last argument of this function, to terminate the list of
+   strings.  Allocates memory using xmalloc.  The first argument is
+   not one of the strings to be concatenated, but if not NULL is a
+   pointer to be freed after the new string is created, similar to the
+   way xrealloc works.  */
+
+extern char *reconcat PARAMS ((char *, const char *, ...)) ATTRIBUTE_MALLOC;
+
+/* Determine the length of concatenating an arbitrary number of
+   strings.  You must pass NULL as the last argument of this function,
+   to terminate the list of strings.  */
+
+extern unsigned long concat_length PARAMS ((const char *, ...));
+
+/* Concatenate an arbitrary number of strings into a SUPPLIED area of
+   memory.  You must pass NULL as the last argument of this function,
+   to terminate the list of strings.  The supplied memory is assumed
+   to be large enough.  */
+
+extern char *concat_copy PARAMS ((char *, const char *, ...));
+
+/* Concatenate an arbitrary number of strings into a GLOBAL area of
+   memory.  You must pass NULL as the last argument of this function,
+   to terminate the list of strings.  The supplied memory is assumed
+   to be large enough.  */
+
+extern char *concat_copy2 PARAMS ((const char *, ...));
+
+/* This is the global area used by concat_copy2.  */
+
+extern char *libiberty_concat_ptr;
+
+/* Concatenate an arbitrary number of strings.  You must pass NULL as
+   the last argument of this function, to terminate the list of
+   strings.  Allocates memory using alloca.  The arguments are
+   evaluated twice!  */
+#define ACONCAT(ACONCAT_PARAMS) \
+  (libiberty_concat_ptr = alloca (concat_length ACONCAT_PARAMS + 1), \
+   concat_copy2 ACONCAT_PARAMS)
+
+/* Check whether two file descriptors refer to the same file.  */
+
+extern int fdmatch PARAMS ((int fd1, int fd2));
+
+/* Get the working directory.  The result is cached, so don't call
+   chdir() between calls to getpwd().  */
+
+extern char * getpwd PARAMS ((void));
+
+/* Get the amount of time the process has run, in microseconds.  */
+
+extern long get_run_time PARAMS ((void));
+
+/* Choose a temporary directory to use for scratch files.  */
+
+extern char *choose_temp_base PARAMS ((void)) ATTRIBUTE_MALLOC;
+
+/* Return a temporary file name or NULL if unable to create one.  */
+
+extern char *make_temp_file PARAMS ((const char *)) ATTRIBUTE_MALLOC;
+
+/* Allocate memory filled with spaces.  Allocates using malloc.  */
+
+extern const char *spaces PARAMS ((int count));
+
+/* Return the maximum error number for which strerror will return a
+   string.  */
+
+extern int errno_max PARAMS ((void));
+
+/* Return the name of an errno value (e.g., strerrno (EINVAL) returns
+   "EINVAL").  */
+
+extern const char *strerrno PARAMS ((int));
+
+/* Given the name of an errno value, return the value.  */
+
+extern int strtoerrno PARAMS ((const char *));
+
+/* ANSI's strerror(), but more robust.  */
+
+extern char *xstrerror PARAMS ((int));
+
+/* Return the maximum signal number for which strsignal will return a
+   string.  */
+
+extern int signo_max PARAMS ((void));
+
+/* Return a signal message string for a signal number
+   (e.g., strsignal (SIGHUP) returns something like "Hangup").  */
+/* This is commented out as it can conflict with one in system headers.
+   We still document its existence though.  */
+
+/*extern const char *strsignal PARAMS ((int));*/
+
+/* Return the name of a signal number (e.g., strsigno (SIGHUP) returns
+   "SIGHUP").  */
+
+extern const char *strsigno PARAMS ((int));
+
+/* Given the name of a signal, return its number.  */
+
+extern int strtosigno PARAMS ((const char *));
+
+/* Register a function to be run by xexit.  Returns 0 on success.  */
+
+extern int xatexit PARAMS ((void (*fn) (void)));
+
+/* Exit, calling all the functions registered with xatexit.  */
+
+extern void xexit PARAMS ((int status)) ATTRIBUTE_NORETURN;
+
+/* Set the program name used by xmalloc.  */
+
+extern void xmalloc_set_program_name PARAMS ((const char *));
+
+/* Report an allocation failure.  */
+extern void xmalloc_failed PARAMS ((size_t)) ATTRIBUTE_NORETURN;
+
+/* Allocate memory without fail.  If malloc fails, this will print a
+   message to stderr (using the name set by xmalloc_set_program_name,
+   if any) and then call xexit.  */
+
+extern PTR xmalloc PARAMS ((size_t)) ATTRIBUTE_MALLOC;
+
+/* Reallocate memory without fail.  This works like xmalloc.  Note,
+   realloc type functions are not suitable for attribute malloc since
+   they may return the same address across multiple calls. */
+
+extern PTR xrealloc PARAMS ((PTR, size_t));
+
+/* Allocate memory without fail and set it to zero.  This works like
+   xmalloc.  */
+
+extern PTR xcalloc PARAMS ((size_t, size_t)) ATTRIBUTE_MALLOC;
+
+/* Copy a string into a memory buffer without fail.  */
+
+extern char *xstrdup PARAMS ((const char *)) ATTRIBUTE_MALLOC;
+
+/* Copy an existing memory buffer to a new memory buffer without fail.  */
+
+extern PTR xmemdup PARAMS ((const PTR, size_t, size_t)) ATTRIBUTE_MALLOC;
+
+/* hex character manipulation routines */
+
+#define _hex_array_size 256
+#define _hex_bad	99
+extern const char _hex_value[_hex_array_size];
+extern void hex_init PARAMS ((void));
+#define hex_p(c)	(hex_value (c) != _hex_bad)
+/* If you change this, note well: Some code relies on side effects in
+   the argument being performed exactly once.  */
+#define hex_value(c)	(_hex_value[(unsigned char) (c)])
+
+/* Definitions used by the pexecute routine.  */
+
+#define PEXECUTE_FIRST   1
+#define PEXECUTE_LAST    2
+#define PEXECUTE_ONE     (PEXECUTE_FIRST + PEXECUTE_LAST)
+#define PEXECUTE_SEARCH  4
+#define PEXECUTE_VERBOSE 8
+
+/* Execute a program.  */
+
+extern int pexecute PARAMS ((const char *, char * const *, const char *,
+			    const char *, char **, char **, int));
+
+/* Wait for pexecute to finish.  */
+
+extern int pwait PARAMS ((int, int *, int));
+
+/* Like sprintf but provides a pointer to malloc'd storage, which must
+   be freed by the caller.  */
+
+extern int asprintf PARAMS ((char **, const char *, ...)) ATTRIBUTE_PRINTF_2;
+
+/* Like vsprintf but provides a pointer to malloc'd storage, which
+   must be freed by the caller.  */
+
+extern int vasprintf PARAMS ((char **, const char *, va_list))
+  ATTRIBUTE_PRINTF(2,0);
+
+#define ARRAY_SIZE(a) (sizeof (a) / sizeof ((a)[0]))
+
+/* Drastically simplified alloca configurator.  If we're using GCC,
+   we use __builtin_alloca; otherwise we use the C alloca.  The C
+   alloca is always available.  You can override GCC by defining
+   USE_C_ALLOCA yourself.  The canonical autoconf macro C_ALLOCA is
+   also set/unset as it is often used to indicate whether code needs
+   to call alloca(0).  */
+extern PTR C_alloca PARAMS ((size_t)) ATTRIBUTE_MALLOC;
+#undef alloca
+#if GCC_VERSION >= 2000 && !defined USE_C_ALLOCA
+# define alloca(x) __builtin_alloca(x)
+# undef C_ALLOCA
+# define ASTRDUP(X) \
+  (__extension__ ({ const char *const libiberty_optr = (X); \
+   const unsigned long libiberty_len = strlen (libiberty_optr) + 1; \
+   char *const libiberty_nptr = alloca (libiberty_len); \
+   (char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len); }))
+#else
+# define alloca(x) C_alloca(x)
+# undef USE_C_ALLOCA
+# define USE_C_ALLOCA 1
+# undef C_ALLOCA
+# define C_ALLOCA 1
+extern const char *libiberty_optr;
+extern char *libiberty_nptr;
+extern unsigned long libiberty_len;
+# define ASTRDUP(X) \
+  (libiberty_optr = (X), \
+   libiberty_len = strlen (libiberty_optr) + 1, \
+   libiberty_nptr = alloca (libiberty_len), \
+   (char *) memcpy (libiberty_nptr, libiberty_optr, libiberty_len))
+#endif
+
+#ifdef __cplusplus
+}
+#endif
+
+
+#endif /* ! defined (LIBIBERTY_H) */
Index: trunk/src/emx/include/md5.h
===================================================================
--- trunk/src/emx/include/md5.h	(revision 123)
+++ trunk/src/emx/include/md5.h	(revision 123)
@@ -0,0 +1,142 @@
+/* md5.h - Declaration of functions and data types used for MD5 sum
+   computing library functions.
+   Copyright 1995, 1996, 2000 Free Software Foundation, Inc.
+   NOTE: The canonical source of this file is maintained with the GNU C
+   Library.  Bugs can be reported to bug-glibc@prep.ai.mit.edu.
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software Foundation,
+   Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef _MD5_H
+#define _MD5_H 1
+
+#include <stdio.h>
+
+#if defined HAVE_LIMITS_H || _LIBC
+# include <limits.h>
+#endif
+
+/* The following contortions are an attempt to use the C preprocessor
+   to determine an unsigned integral type that is 32 bits wide.  An
+   alternative approach is to use autoconf's AC_CHECK_SIZEOF macro, but
+   doing that would require that the configure script compile and *run*
+   the resulting executable.  Locally running cross-compiled executables
+   is usually not possible.  */
+
+#ifdef _LIBC
+# include <sys/types.h>
+typedef u_int32_t md5_uint32;
+#else
+#  define INT_MAX_32_BITS 2147483647
+
+/* If UINT_MAX isn't defined, assume it's a 32-bit type.
+   This should be valid for all systems GNU cares about because
+   that doesn't include 16-bit systems, and only modern systems
+   (that certainly have <limits.h>) have 64+-bit integral types.  */
+
+# ifndef INT_MAX
+#  define INT_MAX INT_MAX_32_BITS
+# endif
+
+# if INT_MAX == INT_MAX_32_BITS
+   typedef unsigned int md5_uint32;
+# else
+#  if SHRT_MAX == INT_MAX_32_BITS
+    typedef unsigned short md5_uint32;
+#  else
+#   if LONG_MAX == INT_MAX_32_BITS
+     typedef unsigned long md5_uint32;
+#   else
+     /* The following line is intended to evoke an error.
+        Using #error is not portable enough.  */
+     "Cannot determine unsigned 32-bit data type."
+#   endif
+#  endif
+# endif
+#endif
+
+#undef __P
+#if defined (__STDC__) && __STDC__
+#define	__P(x) x
+#else
+#define	__P(x) ()
+#endif
+
+/* Structure to save state of computation between the single steps.  */
+struct md5_ctx
+{
+  md5_uint32 A;
+  md5_uint32 B;
+  md5_uint32 C;
+  md5_uint32 D;
+
+  md5_uint32 total[2];
+  md5_uint32 buflen;
+  char buffer[128];
+};
+
+/*
+ * The following three functions are build up the low level used in
+ * the functions `md5_stream' and `md5_buffer'.
+ */
+
+/* Initialize structure containing state of computation.
+   (RFC 1321, 3.3: Step 3)  */
+extern void md5_init_ctx __P ((struct md5_ctx *ctx));
+
+/* Starting with the result of former calls of this function (or the
+   initialization function update the context for the next LEN bytes
+   starting at BUFFER.
+   It is necessary that LEN is a multiple of 64!!! */
+extern void md5_process_block __P ((const void *buffer, size_t len,
+				    struct md5_ctx *ctx));
+
+/* Starting with the result of former calls of this function (or the
+   initialization function update the context for the next LEN bytes
+   starting at BUFFER.
+   It is NOT required that LEN is a multiple of 64.  */
+extern void md5_process_bytes __P ((const void *buffer, size_t len,
+				    struct md5_ctx *ctx));
+
+/* Process the remaining bytes in the buffer and put result from CTX
+   in first 16 bytes following RESBUF.  The result is always in little
+   endian byte order, so that a byte-wise output yields to the wanted
+   ASCII representation of the message digest.
+
+   IMPORTANT: On some systems it is required that RESBUF is correctly
+   aligned for a 32 bits value.  */
+extern void *md5_finish_ctx __P ((struct md5_ctx *ctx, void *resbuf));
+
+
+/* Put result from CTX in first 16 bytes following RESBUF.  The result is
+   always in little endian byte order, so that a byte-wise output yields
+   to the wanted ASCII representation of the message digest.
+
+   IMPORTANT: On some systems it is required that RESBUF is correctly
+   aligned for a 32 bits value.  */
+extern void *md5_read_ctx __P ((const struct md5_ctx *ctx, void *resbuf));
+
+
+/* Compute MD5 message digest for bytes read from STREAM.  The
+   resulting message digest number will be written into the 16 bytes
+   beginning at RESBLOCK.  */
+extern int md5_stream __P ((FILE *stream, void *resblock));
+
+/* Compute MD5 message digest for LEN bytes beginning at BUFFER.  The
+   result is always in little endian byte order, so that a byte-wise
+   output yields to the wanted ASCII representation of the message
+   digest.  */
+extern void *md5_buffer __P ((const char *buffer, size_t len, void *resblock));
+
+#endif
Index: trunk/src/emx/include/objalloc.h
===================================================================
--- trunk/src/emx/include/objalloc.h	(revision 123)
+++ trunk/src/emx/include/objalloc.h	(revision 123)
@@ -0,0 +1,115 @@
+/* objalloc.h -- routines to allocate memory for objects
+   Copyright 1997, 2001 Free Software Foundation, Inc.
+   Written by Ian Lance Taylor, Cygnus Solutions.
+
+This program is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by the
+Free Software Foundation; either version 2, or (at your option) any
+later version.
+
+This program is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+GNU General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with this program; if not, write to the Free Software
+Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef OBJALLOC_H
+#define OBJALLOC_H
+
+#include "ansidecl.h"
+
+/* These routines allocate space for an object.  The assumption is
+   that the object will want to allocate space as it goes along, but
+   will never want to free any particular block.  There is a function
+   to free a block, which also frees all more recently allocated
+   blocks.  There is also a function to free all the allocated space.
+
+   This is essentially a specialization of obstacks.  The main
+   difference is that a block may not be allocated a bit at a time.
+   Another difference is that these routines are always built on top
+   of malloc, and always pass an malloc failure back to the caller,
+   unlike more recent versions of obstacks.  */
+
+/* This is what an objalloc structure looks like.  Callers should not
+   refer to these fields, nor should they allocate these structure
+   themselves.  Instead, they should only create them via
+   objalloc_init, and only access them via the functions and macros
+   listed below.  The structure is only defined here so that we can
+   access it via macros.  */
+
+struct objalloc
+{
+  char *current_ptr;
+  unsigned int current_space;
+  PTR chunks;
+};
+
+/* Work out the required alignment.  */
+
+struct objalloc_align { char x; double d; };
+
+#if defined (__STDC__) && __STDC__
+#ifndef offsetof
+#include <stddef.h>
+#endif
+#endif
+#ifndef offsetof
+#define offsetof(TYPE, MEMBER) ((unsigned long) &((TYPE *)0)->MEMBER)
+#endif
+#define OBJALLOC_ALIGN offsetof (struct objalloc_align, d)
+
+/* Create an objalloc structure.  Returns NULL if malloc fails.  */
+
+extern struct objalloc *objalloc_create PARAMS ((void));
+
+/* Allocate space from an objalloc structure.  Returns NULL if malloc
+   fails.  */
+
+extern PTR _objalloc_alloc PARAMS ((struct objalloc *, unsigned long));
+
+/* The macro version of objalloc_alloc.  We only define this if using
+   gcc, because otherwise we would have to evaluate the arguments
+   multiple times, or use a temporary field as obstack.h does.  */
+
+#if defined (__GNUC__) && defined (__STDC__) && __STDC__
+
+/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
+   does not implement __extension__.  But that compiler doesn't define
+   __GNUC_MINOR__.  */
+#if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
+#define __extension__
+#endif
+
+#define objalloc_alloc(o, l)						\
+  __extension__								\
+  ({ struct objalloc *__o = (o);					\
+     unsigned long __len = (l);						\
+     if (__len == 0)							\
+       __len = 1;							\
+     __len = (__len + OBJALLOC_ALIGN - 1) &~ (OBJALLOC_ALIGN - 1);	\
+     (__len <= __o->current_space					\
+      ? (__o->current_ptr += __len,					\
+	 __o->current_space -= __len,					\
+	 (PTR) (__o->current_ptr - __len))				\
+      : _objalloc_alloc (__o, __len)); })
+
+#else /* ! __GNUC__ */
+
+#define objalloc_alloc(o, l) _objalloc_alloc ((o), (l))
+
+#endif /* ! __GNUC__ */
+
+/* Free an entire objalloc structure.  */
+
+extern void objalloc_free PARAMS ((struct objalloc *));
+
+/* Free a block allocated by objalloc_alloc.  This also frees all more
+   recently allocated blocks.  */
+
+extern void objalloc_free_block PARAMS ((struct objalloc *, PTR));
+
+#endif /* OBJALLOC_H */
Index: trunk/src/emx/include/obstack.h
===================================================================
--- trunk/src/emx/include/obstack.h	(revision 123)
+++ trunk/src/emx/include/obstack.h	(revision 123)
@@ -0,0 +1,604 @@
+/* obstack.h - object stack macros
+   Copyright 1988, 1989, 1990, 1991, 1992, 1993, 1994, 1996, 1997, 1998,
+   1999, 2000
+   Free Software Foundation, Inc.
+
+
+   NOTE: The canonical source of this file is maintained with the GNU C Library.
+   Bugs can be reported to bug-glibc@gnu.org.
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
+
+/* Summary:
+
+All the apparent functions defined here are macros. The idea
+is that you would use these pre-tested macros to solve a
+very specific set of problems, and they would run fast.
+Caution: no side-effects in arguments please!! They may be
+evaluated MANY times!!
+
+These macros operate a stack of objects.  Each object starts life
+small, and may grow to maturity.  (Consider building a word syllable
+by syllable.)  An object can move while it is growing.  Once it has
+been "finished" it never changes address again.  So the "top of the
+stack" is typically an immature growing object, while the rest of the
+stack is of mature, fixed size and fixed address objects.
+
+These routines grab large chunks of memory, using a function you
+supply, called `obstack_chunk_alloc'.  On occasion, they free chunks,
+by calling `obstack_chunk_free'.  You must define them and declare
+them before using any obstack macros.
+
+Each independent stack is represented by a `struct obstack'.
+Each of the obstack macros expects a pointer to such a structure
+as the first argument.
+
+One motivation for this package is the problem of growing char strings
+in symbol tables.  Unless you are "fascist pig with a read-only mind"
+--Gosper's immortal quote from HAKMEM item 154, out of context--you
+would not like to put any arbitrary upper limit on the length of your
+symbols.
+
+In practice this often means you will build many short symbols and a
+few long symbols.  At the time you are reading a symbol you don't know
+how long it is.  One traditional method is to read a symbol into a
+buffer, realloc()ating the buffer every time you try to read a symbol
+that is longer than the buffer.  This is beaut, but you still will
+want to copy the symbol from the buffer to a more permanent
+symbol-table entry say about half the time.
+
+With obstacks, you can work differently.  Use one obstack for all symbol
+names.  As you read a symbol, grow the name in the obstack gradually.
+When the name is complete, finalize it.  Then, if the symbol exists already,
+free the newly read name.
+
+The way we do this is to take a large chunk, allocating memory from
+low addresses.  When you want to build a symbol in the chunk you just
+add chars above the current "high water mark" in the chunk.  When you
+have finished adding chars, because you got to the end of the symbol,
+you know how long the chars are, and you can create a new object.
+Mostly the chars will not burst over the highest address of the chunk,
+because you would typically expect a chunk to be (say) 100 times as
+long as an average object.
+
+In case that isn't clear, when we have enough chars to make up
+the object, THEY ARE ALREADY CONTIGUOUS IN THE CHUNK (guaranteed)
+so we just point to it where it lies.  No moving of chars is
+needed and this is the second win: potentially long strings need
+never be explicitly shuffled. Once an object is formed, it does not
+change its address during its lifetime.
+
+When the chars burst over a chunk boundary, we allocate a larger
+chunk, and then copy the partly formed object from the end of the old
+chunk to the beginning of the new larger chunk.  We then carry on
+accreting characters to the end of the object as we normally would.
+
+A special macro is provided to add a single char at a time to a
+growing object.  This allows the use of register variables, which
+break the ordinary 'growth' macro.
+
+Summary:
+	We allocate large chunks.
+	We carve out one object at a time from the current chunk.
+	Once carved, an object never moves.
+	We are free to append data of any size to the currently
+	  growing object.
+	Exactly one object is growing in an obstack at any one time.
+	You can run one obstack per control block.
+	You may have as many control blocks as you dare.
+	Because of the way we do it, you can `unwind' an obstack
+	  back to a previous state. (You may remove objects much
+	  as you would with a stack.)
+*/
+
+
+/* Don't do the contents of this file more than once.  */
+
+#ifndef _OBSTACK_H
+#define _OBSTACK_H 1
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+
+/* We use subtraction of (char *) 0 instead of casting to int
+   because on word-addressable machines a simple cast to int
+   may ignore the byte-within-word field of the pointer.  */
+
+#ifndef __PTR_TO_INT
+# define __PTR_TO_INT(P) ((P) - (char *) 0)
+#endif
+
+#ifndef __INT_TO_PTR
+# define __INT_TO_PTR(P) ((P) + (char *) 0)
+#endif
+
+/* We need the type of the resulting object.  If __PTRDIFF_TYPE__ is
+   defined, as with GNU C, use that; that way we don't pollute the
+   namespace with <stddef.h>'s symbols.  Otherwise, if <stddef.h> is
+   available, include it and use ptrdiff_t.  In traditional C, long is
+   the best that we can do.  */
+
+#ifdef __PTRDIFF_TYPE__
+# define PTR_INT_TYPE __PTRDIFF_TYPE__
+#else
+# ifdef HAVE_STDDEF_H
+#  include <stddef.h>
+#  define PTR_INT_TYPE ptrdiff_t
+# else
+#  define PTR_INT_TYPE long
+# endif
+#endif
+
+#if defined _LIBC || defined HAVE_STRING_H
+# include <string.h>
+# if defined __STDC__ && __STDC__
+#  define _obstack_memcpy(To, From, N) memcpy ((To), (From), (N))
+# else
+#  define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N))
+# endif
+#else
+# ifdef memcpy
+#  define _obstack_memcpy(To, From, N) memcpy ((To), (char *)(From), (N))
+# else
+#  define _obstack_memcpy(To, From, N) bcopy ((char *)(From), (To), (N))
+# endif
+#endif
+
+struct _obstack_chunk		/* Lives at front of each chunk. */
+{
+  char  *limit;			/* 1 past end of this chunk */
+  struct _obstack_chunk *prev;	/* address of prior chunk or NULL */
+  char	contents[4];		/* objects begin here */
+};
+
+struct obstack		/* control current object in current chunk */
+{
+  long	chunk_size;		/* preferred size to allocate chunks in */
+  struct _obstack_chunk *chunk;	/* address of current struct obstack_chunk */
+  char	*object_base;		/* address of object we are building */
+  char	*next_free;		/* where to add next char to current object */
+  char	*chunk_limit;		/* address of char after current chunk */
+  PTR_INT_TYPE temp;		/* Temporary for some macros.  */
+  int   alignment_mask;		/* Mask of alignment for each object. */
+#if defined __STDC__ && __STDC__
+  /* These prototypes vary based on `use_extra_arg', and we use
+     casts to the prototypeless function type in all assignments,
+     but having prototypes here quiets -Wstrict-prototypes.  */
+  struct _obstack_chunk *(*chunkfun) (void *, long);
+  void (*freefun) (void *, struct _obstack_chunk *);
+  void *extra_arg;		/* first arg for chunk alloc/dealloc funcs */
+#else
+  struct _obstack_chunk *(*chunkfun) (); /* User's fcn to allocate a chunk.  */
+  void (*freefun) ();		/* User's function to free a chunk.  */
+  char *extra_arg;		/* first arg for chunk alloc/dealloc funcs */
+#endif
+  unsigned use_extra_arg:1;	/* chunk alloc/dealloc funcs take extra arg */
+  unsigned maybe_empty_object:1;/* There is a possibility that the current
+				   chunk contains a zero-length object.  This
+				   prevents freeing the chunk if we allocate
+				   a bigger chunk to replace it. */
+  unsigned alloc_failed:1;	/* No longer used, as we now call the failed
+				   handler on error, but retained for binary
+				   compatibility.  */
+};
+
+/* Declare the external functions we use; they are in obstack.c.  */
+
+#if defined __STDC__ && __STDC__
+extern void _obstack_newchunk (struct obstack *, int);
+extern void _obstack_free (struct obstack *, void *);
+extern int _obstack_begin (struct obstack *, int, int,
+			    void *(*) (long), void (*) (void *));
+extern int _obstack_begin_1 (struct obstack *, int, int,
+			     void *(*) (void *, long),
+			     void (*) (void *, void *), void *);
+extern int _obstack_memory_used (struct obstack *);
+#else
+extern void _obstack_newchunk ();
+extern void _obstack_free ();
+extern int _obstack_begin ();
+extern int _obstack_begin_1 ();
+extern int _obstack_memory_used ();
+#endif
+
+
+#if defined __STDC__ && __STDC__
+
+/* Do the function-declarations after the structs
+   but before defining the macros.  */
+
+void obstack_init (struct obstack *obstack);
+
+void * obstack_alloc (struct obstack *obstack, int size);
+
+void * obstack_copy (struct obstack *obstack, void *address, int size);
+void * obstack_copy0 (struct obstack *obstack, void *address, int size);
+
+void obstack_free (struct obstack *obstack, void *block);
+
+void obstack_blank (struct obstack *obstack, int size);
+
+void obstack_grow (struct obstack *obstack, void *data, int size);
+void obstack_grow0 (struct obstack *obstack, void *data, int size);
+
+void obstack_1grow (struct obstack *obstack, int data_char);
+void obstack_ptr_grow (struct obstack *obstack, void *data);
+void obstack_int_grow (struct obstack *obstack, int data);
+
+void * obstack_finish (struct obstack *obstack);
+
+int obstack_object_size (struct obstack *obstack);
+
+int obstack_room (struct obstack *obstack);
+void obstack_make_room (struct obstack *obstack, int size);
+void obstack_1grow_fast (struct obstack *obstack, int data_char);
+void obstack_ptr_grow_fast (struct obstack *obstack, void *data);
+void obstack_int_grow_fast (struct obstack *obstack, int data);
+void obstack_blank_fast (struct obstack *obstack, int size);
+
+void * obstack_base (struct obstack *obstack);
+void * obstack_next_free (struct obstack *obstack);
+int obstack_alignment_mask (struct obstack *obstack);
+int obstack_chunk_size (struct obstack *obstack);
+int obstack_memory_used (struct obstack *obstack);
+
+#endif /* __STDC__ */
+
+/* Non-ANSI C cannot really support alternative functions for these macros,
+   so we do not declare them.  */
+
+/* Error handler called when `obstack_chunk_alloc' failed to allocate
+   more memory.  This can be set to a user defined function.  The
+   default action is to print a message and abort.  */
+#if defined __STDC__ && __STDC__
+extern void (*obstack_alloc_failed_handler) (void);
+#else
+extern void (*obstack_alloc_failed_handler) ();
+#endif
+
+/* Exit value used when `print_and_abort' is used.  */
+extern int obstack_exit_failure;
+
+
+/* Pointer to beginning of object being allocated or to be allocated next.
+   Note that this might not be the final address of the object
+   because a new chunk might be needed to hold the final size.  */
+
+#define obstack_base(h) ((h)->object_base)
+
+/* Size for allocating ordinary chunks.  */
+
+#define obstack_chunk_size(h) ((h)->chunk_size)
+
+/* Pointer to next byte not yet allocated in current chunk.  */
+
+#define obstack_next_free(h)	((h)->next_free)
+
+/* Mask specifying low bits that should be clear in address of an object.  */
+
+#define obstack_alignment_mask(h) ((h)->alignment_mask)
+
+/* To prevent prototype warnings provide complete argument list in
+   standard C version.  */
+#if defined __STDC__ && __STDC__
+
+# define obstack_init(h) \
+  _obstack_begin ((h), 0, 0, \
+		  (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
+
+# define obstack_begin(h, size) \
+  _obstack_begin ((h), (size), 0, \
+		  (void *(*) (long)) obstack_chunk_alloc, (void (*) (void *)) obstack_chunk_free)
+
+# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+  _obstack_begin ((h), (size), (alignment), \
+		    (void *(*) (long)) (chunkfun), (void (*) (void *)) (freefun))
+
+# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
+  _obstack_begin_1 ((h), (size), (alignment), \
+		    (void *(*) (void *, long)) (chunkfun), \
+		    (void (*) (void *, void *)) (freefun), (arg))
+
+# define obstack_chunkfun(h, newchunkfun) \
+  ((h) -> chunkfun = (struct _obstack_chunk *(*)(void *, long)) (newchunkfun))
+
+# define obstack_freefun(h, newfreefun) \
+  ((h) -> freefun = (void (*)(void *, struct _obstack_chunk *)) (newfreefun))
+
+#else
+
+# define obstack_init(h) \
+  _obstack_begin ((h), 0, 0, \
+		  (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
+
+# define obstack_begin(h, size) \
+  _obstack_begin ((h), (size), 0, \
+		  (void *(*) ()) obstack_chunk_alloc, (void (*) ()) obstack_chunk_free)
+
+# define obstack_specify_allocation(h, size, alignment, chunkfun, freefun) \
+  _obstack_begin ((h), (size), (alignment), \
+		    (void *(*) ()) (chunkfun), (void (*) ()) (freefun))
+
+# define obstack_specify_allocation_with_arg(h, size, alignment, chunkfun, freefun, arg) \
+  _obstack_begin_1 ((h), (size), (alignment), \
+		    (void *(*) ()) (chunkfun), (void (*) ()) (freefun), (arg))
+
+# define obstack_chunkfun(h, newchunkfun) \
+  ((h) -> chunkfun = (struct _obstack_chunk *(*)()) (newchunkfun))
+
+# define obstack_freefun(h, newfreefun) \
+  ((h) -> freefun = (void (*)()) (newfreefun))
+
+#endif
+
+#define obstack_1grow_fast(h,achar) (*((h)->next_free)++ = achar)
+
+#define obstack_blank_fast(h,n) ((h)->next_free += (n))
+
+#define obstack_memory_used(h) _obstack_memory_used (h)
+
+
+#if defined __GNUC__ && defined __STDC__ && __STDC__
+/* NextStep 2.0 cc is really gcc 1.93 but it defines __GNUC__ = 2 and
+   does not implement __extension__.  But that compiler doesn't define
+   __GNUC_MINOR__.  */
+# if __GNUC__ < 2 || (__NeXT__ && !__GNUC_MINOR__)
+#  define __extension__
+# endif
+
+/* For GNU C, if not -traditional,
+   we can define these macros to compute all args only once
+   without using a global variable.
+   Also, we can avoid using the `temp' slot, to make faster code.  */
+
+# define obstack_object_size(OBSTACK)					\
+  __extension__								\
+  ({ struct obstack *__o = (OBSTACK);					\
+     (unsigned) (__o->next_free - __o->object_base); })
+
+# define obstack_room(OBSTACK)						\
+  __extension__								\
+  ({ struct obstack *__o = (OBSTACK);					\
+     (unsigned) (__o->chunk_limit - __o->next_free); })
+
+# define obstack_make_room(OBSTACK,length)				\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   int __len = (length);						\
+   if (__o->chunk_limit - __o->next_free < __len)			\
+     _obstack_newchunk (__o, __len);					\
+   (void) 0; })
+
+# define obstack_empty_p(OBSTACK)					\
+  __extension__								\
+  ({ struct obstack *__o = (OBSTACK);					\
+     (__o->chunk->prev == 0 && __o->next_free - __o->chunk->contents == 0); })
+
+# define obstack_grow(OBSTACK,where,length)				\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   int __len = (length);						\
+   if (__o->next_free + __len > __o->chunk_limit)			\
+     _obstack_newchunk (__o, __len);					\
+   _obstack_memcpy (__o->next_free, (where), __len);			\
+   __o->next_free += __len;						\
+   (void) 0; })
+
+# define obstack_grow0(OBSTACK,where,length)				\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   int __len = (length);						\
+   if (__o->next_free + __len + 1 > __o->chunk_limit)			\
+     _obstack_newchunk (__o, __len + 1);				\
+   _obstack_memcpy (__o->next_free, (where), __len);			\
+   __o->next_free += __len;						\
+   *(__o->next_free)++ = 0;						\
+   (void) 0; })
+
+# define obstack_1grow(OBSTACK,datum)					\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   if (__o->next_free + 1 > __o->chunk_limit)				\
+     _obstack_newchunk (__o, 1);					\
+   *(__o->next_free)++ = (datum);					\
+   (void) 0; })
+
+/* These assume that the obstack alignment is good enough for pointers or ints,
+   and that the data added so far to the current object
+   shares that much alignment.  */
+
+# define obstack_ptr_grow(OBSTACK,datum)				\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   if (__o->next_free + sizeof (void *) > __o->chunk_limit)		\
+     _obstack_newchunk (__o, sizeof (void *));				\
+   *((void **)__o->next_free)++ = ((void *)datum);			\
+   (void) 0; })
+
+# define obstack_int_grow(OBSTACK,datum)				\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   if (__o->next_free + sizeof (int) > __o->chunk_limit)		\
+     _obstack_newchunk (__o, sizeof (int));				\
+   *((int *)__o->next_free)++ = ((int)datum);				\
+   (void) 0; })
+
+# define obstack_ptr_grow_fast(h,aptr) (*((void **) (h)->next_free)++ = (void *)aptr)
+# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
+
+# define obstack_blank(OBSTACK,length)					\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   int __len = (length);						\
+   if (__o->chunk_limit - __o->next_free < __len)			\
+     _obstack_newchunk (__o, __len);					\
+   __o->next_free += __len;						\
+   (void) 0; })
+
+# define obstack_alloc(OBSTACK,length)					\
+__extension__								\
+({ struct obstack *__h = (OBSTACK);					\
+   obstack_blank (__h, (length));					\
+   obstack_finish (__h); })
+
+# define obstack_copy(OBSTACK,where,length)				\
+__extension__								\
+({ struct obstack *__h = (OBSTACK);					\
+   obstack_grow (__h, (where), (length));				\
+   obstack_finish (__h); })
+
+# define obstack_copy0(OBSTACK,where,length)				\
+__extension__								\
+({ struct obstack *__h = (OBSTACK);					\
+   obstack_grow0 (__h, (where), (length));				\
+   obstack_finish (__h); })
+
+/* The local variable is named __o1 to avoid a name conflict
+   when obstack_blank is called.  */
+# define obstack_finish(OBSTACK)  					\
+__extension__								\
+({ struct obstack *__o1 = (OBSTACK);					\
+   void *value;								\
+   value = (void *) __o1->object_base;					\
+   if (__o1->next_free == value)					\
+     __o1->maybe_empty_object = 1;					\
+   __o1->next_free							\
+     = __INT_TO_PTR ((__PTR_TO_INT (__o1->next_free)+__o1->alignment_mask)\
+		     & ~ (__o1->alignment_mask));			\
+   if (__o1->next_free - (char *)__o1->chunk				\
+       > __o1->chunk_limit - (char *)__o1->chunk)			\
+     __o1->next_free = __o1->chunk_limit;				\
+   __o1->object_base = __o1->next_free;					\
+   value; })
+
+# define obstack_free(OBSTACK, OBJ)					\
+__extension__								\
+({ struct obstack *__o = (OBSTACK);					\
+   void *__obj = (OBJ);							\
+   if (__obj > (void *)__o->chunk && __obj < (void *)__o->chunk_limit)  \
+     __o->next_free = __o->object_base = __obj;				\
+   else (obstack_free) (__o, __obj); })
+
+
+#else /* not __GNUC__ or not __STDC__ */
+
+# define obstack_object_size(h) \
+ (unsigned) ((h)->next_free - (h)->object_base)
+
+# define obstack_room(h)		\
+ (unsigned) ((h)->chunk_limit - (h)->next_free)
+
+# define obstack_empty_p(h) \
+ ((h)->chunk->prev == 0 && (h)->next_free - (h)->chunk->contents == 0)
+
+/* Note that the call to _obstack_newchunk is enclosed in (..., 0)
+   so that we can avoid having void expressions
+   in the arms of the conditional expression.
+   Casting the third operand to void was tried before,
+   but some compilers won't accept it.  */
+
+# define obstack_make_room(h,length)					\
+( (h)->temp = (length),							\
+  (((h)->next_free + (h)->temp > (h)->chunk_limit)			\
+   ? (_obstack_newchunk ((h), (h)->temp), 0) : 0))
+
+# define obstack_grow(h,where,length)					\
+( (h)->temp = (length),							\
+  (((h)->next_free + (h)->temp > (h)->chunk_limit)			\
+   ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),			\
+  _obstack_memcpy ((h)->next_free, (where), (h)->temp),			\
+  (h)->next_free += (h)->temp)
+
+# define obstack_grow0(h,where,length)					\
+( (h)->temp = (length),							\
+  (((h)->next_free + (h)->temp + 1 > (h)->chunk_limit)			\
+   ? (_obstack_newchunk ((h), (h)->temp + 1), 0) : 0),			\
+  _obstack_memcpy ((h)->next_free, (where), (h)->temp),			\
+  (h)->next_free += (h)->temp,						\
+  *((h)->next_free)++ = 0)
+
+# define obstack_1grow(h,datum)						\
+( (((h)->next_free + 1 > (h)->chunk_limit)				\
+   ? (_obstack_newchunk ((h), 1), 0) : 0),				\
+  (*((h)->next_free)++ = (datum)))
+
+# define obstack_ptr_grow(h,datum)					\
+( (((h)->next_free + sizeof (char *) > (h)->chunk_limit)		\
+   ? (_obstack_newchunk ((h), sizeof (char *)), 0) : 0),		\
+  (*((char **) (((h)->next_free+=sizeof(char *))-sizeof(char *))) = ((char *) datum)))
+
+# define obstack_int_grow(h,datum)					\
+( (((h)->next_free + sizeof (int) > (h)->chunk_limit)			\
+   ? (_obstack_newchunk ((h), sizeof (int)), 0) : 0),			\
+  (*((int *) (((h)->next_free+=sizeof(int))-sizeof(int))) = ((int) datum)))
+
+# define obstack_ptr_grow_fast(h,aptr) (*((char **) (h)->next_free)++ = (char *) aptr)
+# define obstack_int_grow_fast(h,aint) (*((int *) (h)->next_free)++ = (int) aint)
+
+# define obstack_blank(h,length)					\
+( (h)->temp = (length),							\
+  (((h)->chunk_limit - (h)->next_free < (h)->temp)			\
+   ? (_obstack_newchunk ((h), (h)->temp), 0) : 0),			\
+  ((h)->next_free += (h)->temp))
+
+# define obstack_alloc(h,length)					\
+ (obstack_blank ((h), (length)), obstack_finish ((h)))
+
+# define obstack_copy(h,where,length)					\
+ (obstack_grow ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_copy0(h,where,length)					\
+ (obstack_grow0 ((h), (where), (length)), obstack_finish ((h)))
+
+# define obstack_finish(h)  						\
+( ((h)->next_free == (h)->object_base					\
+   ? (((h)->maybe_empty_object = 1), 0)					\
+   : 0),								\
+  (h)->temp = __PTR_TO_INT ((h)->object_base),				\
+  (h)->next_free							\
+    = __INT_TO_PTR ((__PTR_TO_INT ((h)->next_free)+(h)->alignment_mask)	\
+		    & ~ ((h)->alignment_mask)),				\
+  (((h)->next_free - (char *) (h)->chunk				\
+    > (h)->chunk_limit - (char *) (h)->chunk)				\
+   ? ((h)->next_free = (h)->chunk_limit) : 0),				\
+  (h)->object_base = (h)->next_free,					\
+  __INT_TO_PTR ((h)->temp))
+
+# if defined __STDC__ && __STDC__
+#  define obstack_free(h,obj)						\
+( (h)->temp = (char *) (obj) - (char *) (h)->chunk,			\
+  (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+   ? (int) ((h)->next_free = (h)->object_base				\
+	    = (h)->temp + (char *) (h)->chunk)				\
+   : (((obstack_free) ((h), (h)->temp + (char *) (h)->chunk), 0), 0)))
+# else
+#  define obstack_free(h,obj)						\
+( (h)->temp = (char *) (obj) - (char *) (h)->chunk,			\
+  (((h)->temp > 0 && (h)->temp < (h)->chunk_limit - (char *) (h)->chunk)\
+   ? (int) ((h)->next_free = (h)->object_base				\
+	    = (h)->temp + (char *) (h)->chunk)				\
+   : (_obstack_free ((h), (h)->temp + (char *) (h)->chunk), 0)))
+# endif
+
+#endif /* not __GNUC__ or not __STDC__ */
+
+#ifdef __cplusplus
+}	/* C++ */
+#endif
+
+#endif /* obstack.h */
Index: trunk/src/emx/include/partition.h
===================================================================
--- trunk/src/emx/include/partition.h	(revision 123)
+++ trunk/src/emx/include/partition.h	(revision 123)
@@ -0,0 +1,81 @@
+/* List implementation of a partition of consecutive integers.
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Contributed by CodeSourcery, LLC.
+
+   This file is part of GCC.
+
+   GCC is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2, or (at your option)
+   any later version.
+
+   GCC is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with GCC; see the file COPYING.  If not, write to
+   the Free Software Foundation, 59 Temple Place - Suite 330,
+   Boston, MA 02111-1307, USA.  */
+
+/* This package implements a partition of consecutive integers.  The
+   elements are partitioned into classes.  Each class is represented
+   by one of its elements, the canonical element, which is chosen
+   arbitrarily from elements in the class.  The principal operations
+   on a partition are FIND, which takes an element, determines its
+   class, and returns the canonical element for that class, and UNION,
+   which unites the two classes that contain two given elements into a
+   single class.
+
+   The list implementation used here provides constant-time finds.  By
+   storing the size of each class with the class's canonical element,
+   it is able to perform unions over all the classes in the partition
+   in O (N log N) time.  */
+
+#ifndef _PARTITION_H
+#define _PARTITION_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ansidecl.h>
+#include <stdio.h>
+
+struct partition_elem
+{
+  /* The canonical element that represents the class containing this
+     element.  */
+  int class_element;
+  /* The next element in this class.  Elements in each class form a
+     circular list.  */
+  struct partition_elem* next;
+  /* The number of elements in this class.  Valid only if this is the
+     canonical element for its class.  */
+  unsigned class_count;
+};
+
+typedef struct partition_def 
+{
+  /* The number of elements in this partition.  */
+  int num_elements;
+  /* The elements in the partition.  */
+  struct partition_elem elements[1];
+} *partition;
+
+extern partition partition_new          PARAMS((int));
+extern void partition_delete            PARAMS((partition));
+extern int partition_union              PARAMS((partition,
+						int,
+						int));
+extern void partition_print             PARAMS((partition,
+						FILE*));
+
+/* Returns the canonical element corresponding to the class containing
+   ELEMENT__ in PARTITION__.  */
+
+#define partition_find(partition__, element__) \
+    ((partition__)->elements[(element__)].class_element)
+
+#endif /* _PARTITION_H */
Index: trunk/src/emx/include/safe-ctype.h
===================================================================
--- trunk/src/emx/include/safe-ctype.h	(revision 123)
+++ trunk/src/emx/include/safe-ctype.h	(revision 123)
@@ -0,0 +1,103 @@
+/* <ctype.h> replacement macros.
+
+   Copyright (C) 2000, 2001 Free Software Foundation, Inc.
+   Contributed by Zack Weinberg <zackw@stanford.edu>.
+
+This file is part of the libiberty library.
+Libiberty is free software; you can redistribute it and/or
+modify it under the terms of the GNU Library General Public
+License as published by the Free Software Foundation; either
+version 2 of the License, or (at your option) any later version.
+
+Libiberty is distributed in the hope that it will be useful,
+but WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+Library General Public License for more details.
+
+You should have received a copy of the GNU Library General Public
+License along with libiberty; see the file COPYING.LIB.  If
+not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* This is a compatible replacement of the standard C library's <ctype.h>
+   with the following properties:
+
+   - Implements all isxxx() macros required by C99.
+   - Also implements some character classes useful when
+     parsing C-like languages.
+   - Does not change behavior depending on the current locale.
+   - Behaves properly for all values in the range of a signed or
+     unsigned char.
+
+   To avoid conflicts, this header defines the isxxx functions in upper
+   case, e.g. ISALPHA not isalpha.  */
+
+#ifndef SAFE_CTYPE_H
+#define SAFE_CTYPE_H
+
+#ifdef isalpha
+ #error "safe-ctype.h and ctype.h may not be used simultaneously"
+#else
+
+/* Categories.  */
+
+enum {
+  /* In C99 */
+  _sch_isblank  = 0x0001,	/* space \t */
+  _sch_iscntrl  = 0x0002,	/* nonprinting characters */
+  _sch_isdigit  = 0x0004,	/* 0-9 */
+  _sch_islower  = 0x0008,	/* a-z */
+  _sch_isprint  = 0x0010,	/* any printing character including ' ' */
+  _sch_ispunct  = 0x0020,	/* all punctuation */
+  _sch_isspace  = 0x0040,	/* space \t \n \r \f \v */
+  _sch_isupper  = 0x0080,	/* A-Z */
+  _sch_isxdigit = 0x0100,	/* 0-9A-Fa-f */
+
+  /* Extra categories useful to cpplib.  */
+  _sch_isidst	= 0x0200,	/* A-Za-z_ */
+  _sch_isvsp    = 0x0400,	/* \n \r */
+  _sch_isnvsp   = 0x0800,	/* space \t \f \v \0 */
+
+  /* Combinations of the above.  */
+  _sch_isalpha  = _sch_isupper|_sch_islower,	/* A-Za-z */
+  _sch_isalnum  = _sch_isalpha|_sch_isdigit,	/* A-Za-z0-9 */
+  _sch_isidnum  = _sch_isidst|_sch_isdigit,	/* A-Za-z0-9_ */
+  _sch_isgraph  = _sch_isalnum|_sch_ispunct,	/* isprint and not space */
+  _sch_iscppsp  = _sch_isvsp|_sch_isnvsp,	/* isspace + \0 */
+  _sch_isbasic  = _sch_isprint|_sch_iscppsp     /* basic charset of ISO C
+						   (plus ` and @)  */
+};
+
+/* Character classification.  */
+extern const unsigned short _sch_istable[256];
+
+#define _sch_test(c, bit) (_sch_istable[(c) & 0xff] & (unsigned short)(bit))
+
+#define ISALPHA(c)  _sch_test(c, _sch_isalpha)
+#define ISALNUM(c)  _sch_test(c, _sch_isalnum)
+#define ISBLANK(c)  _sch_test(c, _sch_isblank)
+#define ISCNTRL(c)  _sch_test(c, _sch_iscntrl)
+#define ISDIGIT(c)  _sch_test(c, _sch_isdigit)
+#define ISGRAPH(c)  _sch_test(c, _sch_isgraph)
+#define ISLOWER(c)  _sch_test(c, _sch_islower)
+#define ISPRINT(c)  _sch_test(c, _sch_isprint)
+#define ISPUNCT(c)  _sch_test(c, _sch_ispunct)
+#define ISSPACE(c)  _sch_test(c, _sch_isspace)
+#define ISUPPER(c)  _sch_test(c, _sch_isupper)
+#define ISXDIGIT(c) _sch_test(c, _sch_isxdigit)
+
+#define ISIDNUM(c)	_sch_test(c, _sch_isidnum)
+#define ISIDST(c)	_sch_test(c, _sch_isidst)
+#define IS_ISOBASIC(c)	_sch_test(c, _sch_isbasic)
+#define IS_VSPACE(c)	_sch_test(c, _sch_isvsp)
+#define IS_NVSPACE(c)	_sch_test(c, _sch_isnvsp)
+#define IS_SPACE_OR_NUL(c)	_sch_test(c, _sch_iscppsp)
+
+/* Character transformation.  */
+extern const unsigned char  _sch_toupper[256];
+extern const unsigned char  _sch_tolower[256];
+#define TOUPPER(c) _sch_toupper[(c) & 0xff]
+#define TOLOWER(c) _sch_tolower[(c) & 0xff]
+
+#endif /* no ctype.h */
+#endif /* SAFE_CTYPE_H */
Index: trunk/src/emx/include/sort.h
===================================================================
--- trunk/src/emx/include/sort.h	(revision 123)
+++ trunk/src/emx/include/sort.h	(revision 123)
@@ -0,0 +1,48 @@
+/* Sorting algorithms.
+   Copyright (C) 2000 Free Software Foundation, Inc.
+   Contributed by Mark Mitchell <mark@codesourcery.com>.
+
+This file is part of GCC.
+   
+GCC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+#ifndef SORT_H
+#define SORT_H
+
+#include <sys/types.h> /* For size_t */
+#ifdef __STDC__
+#include <stddef.h>
+#endif	/* __STDC__ */
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ansidecl.h>
+
+/* Sort an array of pointers.  */
+
+extern void sort_pointers PARAMS ((size_t, void **, void **));
+
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* SORT_H */
+
+
+   
+   
Index: trunk/src/emx/include/splay-tree.h
===================================================================
--- trunk/src/emx/include/splay-tree.h	(revision 123)
+++ trunk/src/emx/include/splay-tree.h	(revision 123)
@@ -0,0 +1,154 @@
+/* A splay-tree datatype.  
+   Copyright 1998, 1999, 2000 Free Software Foundation, Inc.
+   Contributed by Mark Mitchell (mark@markmitchell.com).
+
+This file is part of GCC.
+   
+GCC is free software; you can redistribute it and/or modify it
+under the terms of the GNU General Public License as published by
+the Free Software Foundation; either version 2, or (at your option)
+any later version.
+
+GCC is distributed in the hope that it will be useful, but
+WITHOUT ANY WARRANTY; without even the implied warranty of
+MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+General Public License for more details.
+
+You should have received a copy of the GNU General Public License
+along with GCC; see the file COPYING.  If not, write to
+the Free Software Foundation, 59 Temple Place - Suite 330,
+Boston, MA 02111-1307, USA.  */
+
+/* For an easily readable description of splay-trees, see:
+
+     Lewis, Harry R. and Denenberg, Larry.  Data Structures and Their
+     Algorithms.  Harper-Collins, Inc.  1991.  
+
+   The major feature of splay trees is that all basic tree operations
+   are amortized O(log n) time for a tree with n nodes.  */
+
+#ifndef _SPLAY_TREE_H
+#define _SPLAY_TREE_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif /* __cplusplus */
+
+#include <ansidecl.h>
+
+/* Use typedefs for the key and data types to facilitate changing
+   these types, if necessary.  These types should be sufficiently wide
+   that any pointer or scalar can be cast to these types, and then
+   cast back, without loss of precision.  */
+typedef unsigned long int splay_tree_key;
+typedef unsigned long int splay_tree_value;
+
+/* Forward declaration for a node in the tree.  */
+typedef struct splay_tree_node_s *splay_tree_node;
+
+/* The type of a function which compares two splay-tree keys.  The
+   function should return values as for qsort.  */
+typedef int (*splay_tree_compare_fn) PARAMS((splay_tree_key, splay_tree_key));
+
+/* The type of a function used to deallocate any resources associated
+   with the key.  */
+typedef void (*splay_tree_delete_key_fn) PARAMS((splay_tree_key));
+
+/* The type of a function used to deallocate any resources associated
+   with the value.  */
+typedef void (*splay_tree_delete_value_fn) PARAMS((splay_tree_value));
+
+/* The type of a function used to iterate over the tree.  */
+typedef int (*splay_tree_foreach_fn) PARAMS((splay_tree_node, void*));
+
+/* The type of a function used to allocate memory for tree root and
+   node structures.  The first argument is the number of bytes needed;
+   the second is a data pointer the splay tree functions pass through
+   to the allocator.  This function must never return zero.  */
+typedef void *(*splay_tree_allocate_fn) PARAMS((int, void *));
+
+/* The type of a function used to free memory allocated using the
+   corresponding splay_tree_allocate_fn.  The first argument is the
+   memory to be freed; the latter is a data pointer the splay tree
+   functions pass through to the freer.  */
+typedef void (*splay_tree_deallocate_fn) PARAMS((void *, void *));
+
+/* The nodes in the splay tree.  */
+struct splay_tree_node_s
+{
+  /* The key.  */
+  splay_tree_key key;
+
+  /* The value.  */
+  splay_tree_value value;
+
+  /* The left and right children, respectively.  */
+  splay_tree_node left;
+  splay_tree_node right;
+};
+
+/* The splay tree itself.  */
+typedef struct splay_tree_s
+{
+  /* The root of the tree.  */
+  splay_tree_node root;
+
+  /* The comparision function.  */
+  splay_tree_compare_fn comp;
+
+  /* The deallocate-key function.  NULL if no cleanup is necessary.  */
+  splay_tree_delete_key_fn delete_key;
+
+  /* The deallocate-value function.  NULL if no cleanup is necessary.  */
+  splay_tree_delete_value_fn delete_value;
+
+  /* Allocate/free functions, and a data pointer to pass to them.  */
+  splay_tree_allocate_fn allocate;
+  splay_tree_deallocate_fn deallocate;
+  void *allocate_data;
+
+} *splay_tree;
+
+extern splay_tree splay_tree_new        PARAMS((splay_tree_compare_fn,
+					        splay_tree_delete_key_fn,
+					        splay_tree_delete_value_fn));
+extern splay_tree splay_tree_new_with_allocator
+                                        PARAMS((splay_tree_compare_fn,
+					        splay_tree_delete_key_fn,
+					        splay_tree_delete_value_fn,
+                                                splay_tree_allocate_fn,
+                                                splay_tree_deallocate_fn,
+                                                void *));
+extern void splay_tree_delete           PARAMS((splay_tree));
+extern splay_tree_node splay_tree_insert          
+		                        PARAMS((splay_tree,
+					        splay_tree_key,
+					        splay_tree_value));
+extern void splay_tree_remove		PARAMS((splay_tree,
+						splay_tree_key));
+extern splay_tree_node splay_tree_lookup   
+                                        PARAMS((splay_tree,
+					        splay_tree_key));
+extern splay_tree_node splay_tree_predecessor
+                                        PARAMS((splay_tree,
+						splay_tree_key));
+extern splay_tree_node splay_tree_successor
+                                        PARAMS((splay_tree,
+						splay_tree_key));
+extern splay_tree_node splay_tree_max
+                                        PARAMS((splay_tree));
+extern splay_tree_node splay_tree_min
+                                        PARAMS((splay_tree));
+extern int splay_tree_foreach           PARAMS((splay_tree,
+					        splay_tree_foreach_fn,
+					        void*));
+extern int splay_tree_compare_ints      PARAMS((splay_tree_key,
+						splay_tree_key));
+extern int splay_tree_compare_pointers  PARAMS((splay_tree_key,
+						splay_tree_key));
+					       
+#ifdef __cplusplus
+}
+#endif /* __cplusplus */
+
+#endif /* _SPLAY_TREE_H */
Index: trunk/src/emx/include/symcat.h
===================================================================
--- trunk/src/emx/include/symcat.h	(revision 123)
+++ trunk/src/emx/include/symcat.h	(revision 123)
@@ -0,0 +1,49 @@
+/* Symbol concatenation utilities.
+
+   Copyright (C) 1998, 2000 Free Software Foundation, Inc.
+
+   This program is free software; you can redistribute it and/or modify
+   it under the terms of the GNU General Public License as published by
+   the Free Software Foundation; either version 2 of the License, or
+   (at your option) any later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+ 
+   You should have received a copy of the GNU General Public License along
+   with this program; if not, write to the Free Software Foundation, Inc.,
+   59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
+
+#ifndef SYM_CAT_H
+#define SYM_CAT_H
+
+#if defined (__STDC__) || defined (ALMOST_STDC) || defined (HAVE_STRINGIZE)
+#define CONCAT2(a,b)	 a##b
+#define CONCAT3(a,b,c)	 a##b##c
+#define CONCAT4(a,b,c,d) a##b##c##d
+#define STRINGX(s) #s
+#else
+/* Note one should never pass extra whitespace to the CONCATn macros,
+   e.g. CONCAT2(foo, bar) because traditonal C will keep the space between
+   the two labels instead of concatenating them.  Instead, make sure to
+   write CONCAT2(foo,bar).  */
+#define CONCAT2(a,b)	 a/**/b
+#define CONCAT3(a,b,c)	 a/**/b/**/c
+#define CONCAT4(a,b,c,d) a/**/b/**/c/**/d
+#define STRINGX(s) "s"
+#endif
+
+#define XCONCAT2(a,b)     CONCAT2(a,b)
+#define XCONCAT3(a,b,c)   CONCAT3(a,b,c)
+#define XCONCAT4(a,b,c,d) CONCAT4(a,b,c,d)
+
+/* Note the layer of indirection here is typically used to allow
+   stringification of the expansion of macros.  I.e. "#define foo
+   bar", "XSTRING(foo)", to yield "bar".  Be aware that this only
+   works for __STDC__, not for traditional C which will still resolve
+   to "foo".  */
+#define XSTRING(s) STRINGX(s) 
+
+#endif /* SYM_CAT_H */
Index: trunk/src/emx/include/sys/stat.h
===================================================================
--- trunk/src/emx/include/sys/stat.h	(revision 119)
+++ trunk/src/emx/include/sys/stat.h	(revision 123)
@@ -5,5 +5,5 @@
 
 #if !defined (_SYS_TYPES_H)
-#warning <sys/stat.h> requires <sys/types.h>
+ #warning <sys/stat.h> requires <sys/types.h>
 #include <sys/types.h>
 #endif
Index: trunk/src/emx/include/sys/types.h
===================================================================
--- trunk/src/emx/include/sys/types.h	(revision 119)
+++ trunk/src/emx/include/sys/types.h	(revision 123)
@@ -63,6 +63,8 @@
 #if !defined (FD_SETSIZE)
 #define	FD_SETSIZE      256
-#elif FD_SETSIZE < 256
-#error FD_SETSIZE must be at least 256
+#else
+#if FD_SETSIZE < 256
+ #error FD_SETSIZE must be at least 256
+#endif
 #endif
 
Index: trunk/src/emx/include/ternary.h
===================================================================
--- trunk/src/emx/include/ternary.h	(revision 123)
+++ trunk/src/emx/include/ternary.h	(revision 123)
@@ -0,0 +1,51 @@
+/* ternary.h - Ternary Search Trees
+   Copyright 2001 Free Software Foundation, Inc.
+
+   Contributed by Daniel Berlin (dan@cgsoftware.com)
+
+
+   This program is free software; you can redistribute it and/or modify it
+   under the terms of the GNU General Public License as published by the
+   Free Software Foundation; either version 2, or (at your option) any
+   later version.
+
+   This program is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+   GNU General Public License for more details.
+
+   You should have received a copy of the GNU General Public License
+   along with this program; if not, write to the Free Software
+   Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307,
+   USA.  */
+#ifndef TERNARY_H_
+#define TERNARY_H_
+/* Ternary search trees */
+
+typedef struct ternary_node_def *ternary_tree;
+
+typedef struct ternary_node_def
+{
+  char splitchar;
+  ternary_tree lokid;
+  ternary_tree eqkid;
+  ternary_tree hikid;
+}
+ternary_node;
+
+/* Insert string S into tree P, associating it with DATA. 
+   Return the data in the tree associated with the string if it's
+   already there, and replace is 0.
+   Otherwise, replaces if it it exists, inserts if it doesn't, and
+   returns the data you passed in. */
+PTR ternary_insert PARAMS ((ternary_tree *p, const char *s,
+			    PTR data, int replace));
+
+/* Delete the ternary search tree rooted at P. 
+   Does NOT delete the data you associated with the strings. */
+void ternary_cleanup PARAMS ((ternary_tree p));
+
+/* Search the ternary tree for string S, returning the data associated
+   with it if found. */
+PTR ternary_search PARAMS ((const ternary_node *p, const char *s));
+#endif
Index: trunk/src/emx/include/xregex.h
===================================================================
--- trunk/src/emx/include/xregex.h	(revision 123)
+++ trunk/src/emx/include/xregex.h	(revision 123)
@@ -0,0 +1,28 @@
+/* This file redefines all regex external names before including
+   a renamed copy of glibc's regex.h.  */
+
+#ifndef _XREGEX_H
+#define _XREGEX_H 1
+
+#  define regfree xregfree 
+#  define regexec xregexec
+#  define regcomp xregcomp
+#  define regerror xregerror
+#  define re_set_registers xre_set_registers
+#  define re_match_2 xre_match_2
+#  define re_match xre_match
+#  define re_search xre_search
+#  define re_compile_pattern xre_compile_pattern
+#  define re_set_syntax xre_set_syntax
+#  define re_search_2 xre_search_2
+#  define re_compile_fastmap xre_compile_fastmap
+#  define re_syntax_options xre_syntax_options
+#  define re_max_failures xre_max_failures
+
+#  define _REGEX_RE_COMP
+#  define re_comp xre_comp
+#  define re_exec xre_exec
+
+#include "xregex2.h"
+
+#endif /* xregex.h */
Index: trunk/src/emx/include/xregex2.h
===================================================================
--- trunk/src/emx/include/xregex2.h	(revision 123)
+++ trunk/src/emx/include/xregex2.h	(revision 123)
@@ -0,0 +1,577 @@
+/* Definitions for data structures and routines for the regular
+   expression library, version 0.12.
+   Copyright (C) 1985,1989-1993,1995-1998, 2000 Free Software Foundation, Inc.
+   This file is part of the GNU C Library.  Its master source is NOT part of
+   the C library, however.  The master source lives in /gd/gnu/lib.
+
+   The GNU C Library is free software; you can redistribute it and/or
+   modify it under the terms of the GNU Lesser General Public
+   License as published by the Free Software Foundation; either
+   version 2.1 of the License, or (at your option) any later version.
+
+   The GNU C Library is distributed in the hope that it will be useful,
+   but WITHOUT ANY WARRANTY; without even the implied warranty of
+   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+   Lesser General Public License for more details.
+
+   You should have received a copy of the GNU Lesser General Public
+   License along with the GNU C Library; if not, write to the Free
+   Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
+   02111-1307 USA.  */
+
+#ifndef _REGEX_H
+#define _REGEX_H 1
+
+/* Allow the use in C++ code.  */
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+/* POSIX says that <sys/types.h> must be included (by the caller) before
+   <regex.h>.  */
+
+#if !defined _POSIX_C_SOURCE && !defined _POSIX_SOURCE && defined VMS
+/* VMS doesn't have `size_t' in <sys/types.h>, even though POSIX says it
+   should be there.  */
+# include <stddef.h>
+#endif
+
+/* The following two types have to be signed and unsigned integer type
+   wide enough to hold a value of a pointer.  For most ANSI compilers
+   ptrdiff_t and size_t should be likely OK.  Still size of these two
+   types is 2 for Microsoft C.  Ugh... */
+typedef long int s_reg_t;
+typedef unsigned long int active_reg_t;
+
+/* The following bits are used to determine the regexp syntax we
+   recognize.  The set/not-set meanings are chosen so that Emacs syntax
+   remains the value 0.  The bits are given in alphabetical order, and
+   the definitions shifted by one from the previous bit; thus, when we
+   add or remove a bit, only one other definition need change.  */
+typedef unsigned long int reg_syntax_t;
+
+/* If this bit is not set, then \ inside a bracket expression is literal.
+   If set, then such a \ quotes the following character.  */
+#define RE_BACKSLASH_ESCAPE_IN_LISTS ((unsigned long int) 1)
+
+/* If this bit is not set, then + and ? are operators, and \+ and \? are
+     literals.
+   If set, then \+ and \? are operators and + and ? are literals.  */
+#define RE_BK_PLUS_QM (RE_BACKSLASH_ESCAPE_IN_LISTS << 1)
+
+/* If this bit is set, then character classes are supported.  They are:
+     [:alpha:], [:upper:], [:lower:],  [:digit:], [:alnum:], [:xdigit:],
+     [:space:], [:print:], [:punct:], [:graph:], and [:cntrl:].
+   If not set, then character classes are not supported.  */
+#define RE_CHAR_CLASSES (RE_BK_PLUS_QM << 1)
+
+/* If this bit is set, then ^ and $ are always anchors (outside bracket
+     expressions, of course).
+   If this bit is not set, then it depends:
+        ^  is an anchor if it is at the beginning of a regular
+           expression or after an open-group or an alternation operator;
+        $  is an anchor if it is at the end of a regular expression, or
+           before a close-group or an alternation operator.
+
+   This bit could be (re)combined with RE_CONTEXT_INDEP_OPS, because
+   POSIX draft 11.2 says that * etc. in leading positions is undefined.
+   We already implemented a previous draft which made those constructs
+   invalid, though, so we haven't changed the code back.  */
+#define RE_CONTEXT_INDEP_ANCHORS (RE_CHAR_CLASSES << 1)
+
+/* If this bit is set, then special characters are always special
+     regardless of where they are in the pattern.
+   If this bit is not set, then special characters are special only in
+     some contexts; otherwise they are ordinary.  Specifically,
+     * + ? and intervals are only special when not after the beginning,
+     open-group, or alternation operator.  */
+#define RE_CONTEXT_INDEP_OPS (RE_CONTEXT_INDEP_ANCHORS << 1)
+
+/* If this bit is set, then *, +, ?, and { cannot be first in an re or
+     immediately after an alternation or begin-group operator.  */
+#define RE_CONTEXT_INVALID_OPS (RE_CONTEXT_INDEP_OPS << 1)
+
+/* If this bit is set, then . matches newline.
+   If not set, then it doesn't.  */
+#define RE_DOT_NEWLINE (RE_CONTEXT_INVALID_OPS << 1)
+
+/* If this bit is set, then . doesn't match NUL.
+   If not set, then it does.  */
+#define RE_DOT_NOT_NULL (RE_DOT_NEWLINE << 1)
+
+/* If this bit is set, nonmatching lists [^...] do not match newline.
+   If not set, they do.  */
+#define RE_HAT_LISTS_NOT_NEWLINE (RE_DOT_NOT_NULL << 1)
+
+/* If this bit is set, either \{...\} or {...} defines an
+     interval, depending on RE_NO_BK_BRACES.
+   If not set, \{, \}, {, and } are literals.  */
+#define RE_INTERVALS (RE_HAT_LISTS_NOT_NEWLINE << 1)
+
+/* If this bit is set, +, ? and | aren't recognized as operators.
+   If not set, they are.  */
+#define RE_LIMITED_OPS (RE_INTERVALS << 1)
+
+/* If this bit is set, newline is an alternation operator.
+   If not set, newline is literal.  */
+#define RE_NEWLINE_ALT (RE_LIMITED_OPS << 1)
+
+/* If this bit is set, then `{...}' defines an interval, and \{ and \}
+     are literals.
+  If not set, then `\{...\}' defines an interval.  */
+#define RE_NO_BK_BRACES (RE_NEWLINE_ALT << 1)
+
+/* If this bit is set, (...) defines a group, and \( and \) are literals.
+   If not set, \(...\) defines a group, and ( and ) are literals.  */
+#define RE_NO_BK_PARENS (RE_NO_BK_BRACES << 1)
+
+/* If this bit is set, then \<digit> matches <digit>.
+   If not set, then \<digit> is a back-reference.  */
+#define RE_NO_BK_REFS (RE_NO_BK_PARENS << 1)
+
+/* If this bit is set, then | is an alternation operator, and \| is literal.
+   If not set, then \| is an alternation operator, and | is literal.  */
+#define RE_NO_BK_VBAR (RE_NO_BK_REFS << 1)
+
+/* If this bit is set, then an ending range point collating higher
+     than the starting range point, as in [z-a], is invalid.
+   If not set, then when ending range point collates higher than the
+     starting range point, the range is ignored.  */
+#define RE_NO_EMPTY_RANGES (RE_NO_BK_VBAR << 1)
+
+/* If this bit is set, then an unmatched ) is ordinary.
+   If not set, then an unmatched ) is invalid.  */
+#define RE_UNMATCHED_RIGHT_PAREN_ORD (RE_NO_EMPTY_RANGES << 1)
+
+/* If this bit is set, succeed as soon as we match the whole pattern,
+   without further backtracking.  */
+#define RE_NO_POSIX_BACKTRACKING (RE_UNMATCHED_RIGHT_PAREN_ORD << 1)
+
+/* If this bit is set, do not process the GNU regex operators.
+   If not set, then the GNU regex operators are recognized. */
+#define RE_NO_GNU_OPS (RE_NO_POSIX_BACKTRACKING << 1)
+
+/* If this bit is set, turn on internal regex debugging.
+   If not set, and debugging was on, turn it off.
+   This only works if regex.c is compiled -DDEBUG.
+   We define this bit always, so that all that's needed to turn on
+   debugging is to recompile regex.c; the calling code can always have
+   this bit set, and it won't affect anything in the normal case. */
+#define RE_DEBUG (RE_NO_GNU_OPS << 1)
+
+/* If this bit is set, a syntactically invalid interval is treated as
+   a string of ordinary characters.  For example, the ERE 'a{1' is
+   treated as 'a\{1'.  */
+#define RE_INVALID_INTERVAL_ORD (RE_DEBUG << 1)
+
+/* This global variable defines the particular regexp syntax to use (for
+   some interfaces).  When a regexp is compiled, the syntax used is
+   stored in the pattern buffer, so changing this does not affect
+   already-compiled regexps.  */
+extern reg_syntax_t re_syntax_options;
+
+
+/* Define combinations of the above bits for the standard possibilities.
+   (The [[[ comments delimit what gets put into the Texinfo file, so
+   don't delete them!)  */
+/* [[[begin syntaxes]]] */
+#define RE_SYNTAX_EMACS 0
+
+#define RE_SYNTAX_AWK							\
+  (RE_BACKSLASH_ESCAPE_IN_LISTS   | RE_DOT_NOT_NULL			\
+   | RE_NO_BK_PARENS              | RE_NO_BK_REFS			\
+   | RE_NO_BK_VBAR                | RE_NO_EMPTY_RANGES			\
+   | RE_DOT_NEWLINE		  | RE_CONTEXT_INDEP_ANCHORS		\
+   | RE_UNMATCHED_RIGHT_PAREN_ORD | RE_NO_GNU_OPS)
+
+#define RE_SYNTAX_GNU_AWK						\
+  ((RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS | RE_DEBUG)	\
+   & ~(RE_DOT_NOT_NULL | RE_INTERVALS | RE_CONTEXT_INDEP_OPS))
+
+#define RE_SYNTAX_POSIX_AWK 						\
+  (RE_SYNTAX_POSIX_EXTENDED | RE_BACKSLASH_ESCAPE_IN_LISTS		\
+   | RE_INTERVALS	    | RE_NO_GNU_OPS)
+
+#define RE_SYNTAX_GREP							\
+  (RE_BK_PLUS_QM              | RE_CHAR_CLASSES				\
+   | RE_HAT_LISTS_NOT_NEWLINE | RE_INTERVALS				\
+   | RE_NEWLINE_ALT)
+
+#define RE_SYNTAX_EGREP							\
+  (RE_CHAR_CLASSES        | RE_CONTEXT_INDEP_ANCHORS			\
+   | RE_CONTEXT_INDEP_OPS | RE_HAT_LISTS_NOT_NEWLINE			\
+   | RE_NEWLINE_ALT       | RE_NO_BK_PARENS				\
+   | RE_NO_BK_VBAR)
+
+#define RE_SYNTAX_POSIX_EGREP						\
+  (RE_SYNTAX_EGREP | RE_INTERVALS | RE_NO_BK_BRACES			\
+   | RE_INVALID_INTERVAL_ORD)
+
+/* P1003.2/D11.2, section 4.20.7.1, lines 5078ff.  */
+#define RE_SYNTAX_ED RE_SYNTAX_POSIX_BASIC
+
+#define RE_SYNTAX_SED RE_SYNTAX_POSIX_BASIC
+
+/* Syntax bits common to both basic and extended POSIX regex syntax.  */
+#define _RE_SYNTAX_POSIX_COMMON						\
+  (RE_CHAR_CLASSES | RE_DOT_NEWLINE      | RE_DOT_NOT_NULL		\
+   | RE_INTERVALS  | RE_NO_EMPTY_RANGES)
+
+#define RE_SYNTAX_POSIX_BASIC						\
+  (_RE_SYNTAX_POSIX_COMMON | RE_BK_PLUS_QM)
+
+/* Differs from ..._POSIX_BASIC only in that RE_BK_PLUS_QM becomes
+   RE_LIMITED_OPS, i.e., \? \+ \| are not recognized.  Actually, this
+   isn't minimal, since other operators, such as \`, aren't disabled.  */
+#define RE_SYNTAX_POSIX_MINIMAL_BASIC					\
+  (_RE_SYNTAX_POSIX_COMMON | RE_LIMITED_OPS)
+
+#define RE_SYNTAX_POSIX_EXTENDED					\
+  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
+   | RE_CONTEXT_INDEP_OPS   | RE_NO_BK_BRACES				\
+   | RE_NO_BK_PARENS        | RE_NO_BK_VBAR				\
+   | RE_CONTEXT_INVALID_OPS | RE_UNMATCHED_RIGHT_PAREN_ORD)
+
+/* Differs from ..._POSIX_EXTENDED in that RE_CONTEXT_INDEP_OPS is
+   removed and RE_NO_BK_REFS is added.  */
+#define RE_SYNTAX_POSIX_MINIMAL_EXTENDED				\
+  (_RE_SYNTAX_POSIX_COMMON  | RE_CONTEXT_INDEP_ANCHORS			\
+   | RE_CONTEXT_INVALID_OPS | RE_NO_BK_BRACES				\
+   | RE_NO_BK_PARENS        | RE_NO_BK_REFS				\
+   | RE_NO_BK_VBAR	    | RE_UNMATCHED_RIGHT_PAREN_ORD)
+/* [[[end syntaxes]]] */
+
+
+/* Maximum number of duplicates an interval can allow.  Some systems
+   (erroneously) define this in other header files, but we want our
+   value, so remove any previous define.  */
+#ifdef RE_DUP_MAX
+# undef RE_DUP_MAX
+#endif
+/* If sizeof(int) == 2, then ((1 << 15) - 1) overflows.  */
+#define RE_DUP_MAX (0x7fff)
+
+
+/* POSIX `cflags' bits (i.e., information for `regcomp').  */
+
+/* If this bit is set, then use extended regular expression syntax.
+   If not set, then use basic regular expression syntax.  */
+#define REG_EXTENDED 1
+
+/* If this bit is set, then ignore case when matching.
+   If not set, then case is significant.  */
+#define REG_ICASE (REG_EXTENDED << 1)
+
+/* If this bit is set, then anchors do not match at newline
+     characters in the string.
+   If not set, then anchors do match at newlines.  */
+#define REG_NEWLINE (REG_ICASE << 1)
+
+/* If this bit is set, then report only success or fail in regexec.
+   If not set, then returns differ between not matching and errors.  */
+#define REG_NOSUB (REG_NEWLINE << 1)
+
+
+/* POSIX `eflags' bits (i.e., information for regexec).  */
+
+/* If this bit is set, then the beginning-of-line operator doesn't match
+     the beginning of the string (presumably because it's not the
+     beginning of a line).
+   If not set, then the beginning-of-line operator does match the
+     beginning of the string.  */
+#define REG_NOTBOL 1
+
+/* Like REG_NOTBOL, except for the end-of-line.  */
+#define REG_NOTEOL (1 << 1)
+
+
+/* If any error codes are removed, changed, or added, update the
+   `re_error_msg' table in regex.c.  */
+typedef enum
+{
+#ifdef _XOPEN_SOURCE
+  REG_ENOSYS = -1,	/* This will never happen for this implementation.  */
+#endif
+
+  REG_NOERROR = 0,	/* Success.  */
+  REG_NOMATCH,		/* Didn't find a match (for regexec).  */
+
+  /* POSIX regcomp return error codes.  (In the order listed in the
+     standard.)  */
+  REG_BADPAT,		/* Invalid pattern.  */
+  REG_ECOLLATE,		/* Not implemented.  */
+  REG_ECTYPE,		/* Invalid character class name.  */
+  REG_EESCAPE,		/* Trailing backslash.  */
+  REG_ESUBREG,		/* Invalid back reference.  */
+  REG_EBRACK,		/* Unmatched left bracket.  */
+  REG_EPAREN,		/* Parenthesis imbalance.  */
+  REG_EBRACE,		/* Unmatched \{.  */
+  REG_BADBR,		/* Invalid contents of \{\}.  */
+  REG_ERANGE,		/* Invalid range end.  */
+  REG_ESPACE,		/* Ran out of memory.  */
+  REG_BADRPT,		/* No preceding re for repetition op.  */
+
+  /* Error codes we've added.  */
+  REG_EEND,		/* Premature end.  */
+  REG_ESIZE,		/* Compiled pattern bigger than 2^16 bytes.  */
+  REG_ERPAREN		/* Unmatched ) or \); not returned from regcomp.  */
+} reg_errcode_t;
+
+
+/* This data structure represents a compiled pattern.  Before calling
+   the pattern compiler, the fields `buffer', `allocated', `fastmap',
+   `translate', and `no_sub' can be set.  After the pattern has been
+   compiled, the `re_nsub' field is available.  All other fields are
+   private to the regex routines.  */
+
+#ifndef RE_TRANSLATE_TYPE
+# define RE_TRANSLATE_TYPE char *
+#endif
+
+struct re_pattern_buffer
+{
+/* [[[begin pattern_buffer]]] */
+	/* Space that holds the compiled pattern.  It is declared as
+          `unsigned char *' because its elements are
+           sometimes used as array indexes.  */
+  unsigned char *buffer;
+
+	/* Number of bytes to which `buffer' points.  */
+  unsigned long int allocated;
+
+	/* Number of bytes actually used in `buffer'.  */
+  unsigned long int used;
+
+        /* Syntax setting with which the pattern was compiled.  */
+  reg_syntax_t syntax;
+
+        /* Pointer to a fastmap, if any, otherwise zero.  re_search uses
+           the fastmap, if there is one, to skip over impossible
+           starting points for matches.  */
+  char *fastmap;
+
+        /* Either a translate table to apply to all characters before
+           comparing them, or zero for no translation.  The translation
+           is applied to a pattern when it is compiled and to a string
+           when it is matched.  */
+  RE_TRANSLATE_TYPE translate;
+
+	/* Number of subexpressions found by the compiler.  */
+  size_t re_nsub;
+
+        /* Zero if this pattern cannot match the empty string, one else.
+           Well, in truth it's used only in `re_search_2', to see
+           whether or not we should use the fastmap, so we don't set
+           this absolutely perfectly; see `re_compile_fastmap' (the
+           `duplicate' case).  */
+  unsigned can_be_null : 1;
+
+        /* If REGS_UNALLOCATED, allocate space in the `regs' structure
+             for `max (RE_NREGS, re_nsub + 1)' groups.
+           If REGS_REALLOCATE, reallocate space if necessary.
+           If REGS_FIXED, use what's there.  */
+#define REGS_UNALLOCATED 0
+#define REGS_REALLOCATE 1
+#define REGS_FIXED 2
+  unsigned regs_allocated : 2;
+
+        /* Set to zero when `regex_compile' compiles a pattern; set to one
+           by `re_compile_fastmap' if it updates the fastmap.  */
+  unsigned fastmap_accurate : 1;
+
+        /* If set, `re_match_2' does not return information about
+           subexpressions.  */
+  unsigned no_sub : 1;
+
+        /* If set, a beginning-of-line anchor doesn't match at the
+           beginning of the string.  */
+  unsigned not_bol : 1;
+
+        /* Similarly for an end-of-line anchor.  */
+  unsigned not_eol : 1;
+
+        /* If true, an anchor at a newline matches.  */
+  unsigned newline_anchor : 1;
+
+/* [[[end pattern_buffer]]] */
+};
+
+typedef struct re_pattern_buffer regex_t;
+
+
+/* Type for byte offsets within the string.  POSIX mandates this.  */
+typedef int regoff_t;
+
+
+/* This is the structure we store register match data in.  See
+   regex.texinfo for a full description of what registers match.  */
+struct re_registers
+{
+  unsigned num_regs;
+  regoff_t *start;
+  regoff_t *end;
+};
+
+
+/* If `regs_allocated' is REGS_UNALLOCATED in the pattern buffer,
+   `re_match_2' returns information about at least this many registers
+   the first time a `regs' structure is passed.  */
+#ifndef RE_NREGS
+# define RE_NREGS 30
+#endif
+
+
+/* POSIX specification for registers.  Aside from the different names than
+   `re_registers', POSIX uses an array of structures, instead of a
+   structure of arrays.  */
+typedef struct
+{
+  regoff_t rm_so;  /* Byte offset from string's start to substring's start.  */
+  regoff_t rm_eo;  /* Byte offset from string's start to substring's end.  */
+} regmatch_t;
+
+
+/* Declarations for routines.  */
+
+/* To avoid duplicating every routine declaration -- once with a
+   prototype (if we are ANSI), and once without (if we aren't) -- we
+   use the following macro to declare argument types.  This
+   unfortunately clutters up the declarations a bit, but I think it's
+   worth it.  */
+
+#if __STDC__
+
+# define _RE_ARGS(args) args
+
+#else /* not __STDC__ */
+
+# define _RE_ARGS(args) ()
+
+#endif /* not __STDC__ */
+
+/* Sets the current default syntax to SYNTAX, and return the old syntax.
+   You can also simply assign to the `re_syntax_options' variable.  */
+extern reg_syntax_t re_set_syntax _RE_ARGS ((reg_syntax_t syntax));
+
+/* Compile the regular expression PATTERN, with length LENGTH
+   and syntax given by the global `re_syntax_options', into the buffer
+   BUFFER.  Return NULL if successful, and an error string if not.  */
+extern const char *re_compile_pattern
+  _RE_ARGS ((const char *pattern, size_t length,
+             struct re_pattern_buffer *buffer));
+
+
+/* Compile a fastmap for the compiled pattern in BUFFER; used to
+   accelerate searches.  Return 0 if successful and -2 if was an
+   internal error.  */
+extern int re_compile_fastmap _RE_ARGS ((struct re_pattern_buffer *buffer));
+
+
+/* Search in the string STRING (with length LENGTH) for the pattern
+   compiled into BUFFER.  Start searching at position START, for RANGE
+   characters.  Return the starting position of the match, -1 for no
+   match, or -2 for an internal error.  Also return register
+   information in REGS (if REGS and BUFFER->no_sub are nonzero).  */
+extern int re_search
+  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
+            int length, int start, int range, struct re_registers *regs));
+
+
+/* Like `re_search', but search in the concatenation of STRING1 and
+   STRING2.  Also, stop searching at index START + STOP.  */
+extern int re_search_2
+  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
+             int length1, const char *string2, int length2,
+             int start, int range, struct re_registers *regs, int stop));
+
+
+/* Like `re_search', but return how many characters in STRING the regexp
+   in BUFFER matched, starting at position START.  */
+extern int re_match
+  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string,
+             int length, int start, struct re_registers *regs));
+
+
+/* Relates to `re_match' as `re_search_2' relates to `re_search'.  */
+extern int re_match_2
+  _RE_ARGS ((struct re_pattern_buffer *buffer, const char *string1,
+             int length1, const char *string2, int length2,
+             int start, struct re_registers *regs, int stop));
+
+
+/* Set REGS to hold NUM_REGS registers, storing them in STARTS and
+   ENDS.  Subsequent matches using BUFFER and REGS will use this memory
+   for recording register information.  STARTS and ENDS must be
+   allocated with malloc, and must each be at least `NUM_REGS * sizeof
+   (regoff_t)' bytes long.
+
+   If NUM_REGS == 0, then subsequent matches should allocate their own
+   register data.
+
+   Unless this function is called, the first search or match using
+   PATTERN_BUFFER will allocate its own register data, without
+   freeing the old data.  */
+extern void re_set_registers
+  _RE_ARGS ((struct re_pattern_buffer *buffer, struct re_registers *regs,
+             unsigned num_regs, regoff_t *starts, regoff_t *ends));
+
+#if defined _REGEX_RE_COMP || defined _LIBC
+# ifndef _CRAY
+/* 4.2 bsd compatibility.  */
+extern char *re_comp _RE_ARGS ((const char *));
+extern int re_exec _RE_ARGS ((const char *));
+# endif
+#endif
+
+/* GCC 2.95 and later have "__restrict"; C99 compilers have
+   "restrict", and "configure" may have defined "restrict".  */
+#ifndef __restrict
+# if ! (2 < __GNUC__ || (2 == __GNUC__ && 95 <= __GNUC_MINOR__))
+#  if defined restrict || 199901L <= __STDC_VERSION__
+#   define __restrict restrict
+#  else
+#   define __restrict
+#  endif
+# endif
+#endif
+
+/* GCC 3.1 and later support declaring arrays as non-overlapping
+   using the syntax array_name[restrict]  */
+#ifndef __restrict_arr
+# if ! (3 < __GNUC__ || (3 == __GNUC__ && 1 <= __GNUC_MINOR__)) || defined (__GNUG__)
+#  define __restrict_arr
+# else
+#  define __restrict_arr __restrict
+# endif
+#endif
+
+/* POSIX compatibility.  */
+extern int regcomp _RE_ARGS ((regex_t *__restrict __preg,
+			      const char *__restrict __pattern,
+			      int __cflags));
+
+extern int regexec _RE_ARGS ((const regex_t *__restrict __preg,
+			      const char *__restrict __string, size_t __nmatch,
+			      regmatch_t __pmatch[__restrict_arr],
+			      int __eflags));
+
+extern size_t regerror _RE_ARGS ((int __errcode, const regex_t *__preg,
+				  char *__errbuf, size_t __errbuf_size));
+
+extern void regfree _RE_ARGS ((regex_t *__preg));
+
+
+#ifdef __cplusplus
+}
+#endif	/* C++ */
+
+#endif /* regex.h */
+
+
+/*
+Local variables:
+make-backup-files: t
+version-control: t
+trim-versions-without-asking: nil
+End:
+*/
Index: trunk/src/emx/mklib.smak
===================================================================
--- trunk/src/emx/mklib.smak	(revision 119)
+++ trunk/src/emx/mklib.smak	(revision 123)
@@ -10,3 +10,24 @@
 	$(call FECHO,_@,	$$(DO.LIBRARY))$(NL)
 
+# The rule for building the OMF variant of library from a.out format
+ifneq ($(findstring aout,$(.TKIND)),)
+# Remove the .a suffix from library name
+.TARGET := $(patsubst %$A,%,$(.TARGET))
+# Replace 'aout' with 'omf' in .TKIND
+.TKIND := $(subst aout,omf,$(.TKIND))
+# Compute the new output file directory
+.TKIND.DIR := $(subst $(SPACE),-,$(.TKIND))/
+# Append the .lib suffix to target name
+.TARGET := $(.TARGET)$A
+# Compute the name of target file to build
+.TARG@OMF := $(.TKIND.DIR)$(.TARGET)
+# The rule for building the xxx@omf variant of target
+.PHONY: $(.MODULE)@omf
+MODULES += $(.MODULE)@omf
+DO.INSTALL += $(call CP,$.$(.TARG@OMF),$(INS)$(.INSDIR)$(.TARGET))$(NL)
+.DIRS@OMF := $(dir $.$(.TARG@OMF))
+TARGDIRS += $(.DIRS@OMF)
+$(.MODULE)@omf: $(.MODULE) $(.DIRS@OMF) $.$(.TARG@OMF)
+endif # neq ($(findstring aout,$(.TKIND)),)
+
 include comend.smak
Index: trunk/src/emx/src/emxbind/emxbind.smak
===================================================================
--- trunk/src/emx/src/emxbind/emxbind.smak	(revision 119)
+++ trunk/src/emx/src/emxbind/emxbind.smak	(revision 123)
@@ -1,7 +1,9 @@
 .MODULE := emxbind
 .MDESC  := Build a OS/2 LX executable/dll from linked a.out module
+.MDEP	:= moddef@omf
 .INSDIR := bin/
 
 .TARGET := emxbind.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emxbind/*.c)
 .TCF    := -DLIST_OPT=1
Index: trunk/src/emx/src/emxexp/cplus-de.c
===================================================================
--- trunk/src/emx/src/emxexp/cplus-de.c	(revision 119)
+++ 	(revision )
@@ -1,3290 +1,0 @@
-/* cplus-de.c -- changed for emx by Eberhard Mattes -- Mar 1998 */
-/* Demangler for GNU C++ 
-   Copyright 1989, 1991, 1994, 1995, 1996, 1997 Free Software Foundation, Inc.
-   Written by James Clark (jjc@jclark.uucp)
-   Rewritten by Fred Fish (fnf@cygnus.com) for ARM and Lucid demangling
-   
-This file is part of the libiberty library.
-Libiberty is free software; you can redistribute it and/or
-modify it under the terms of the GNU Library General Public
-License as published by the Free Software Foundation; either
-version 2 of the License, or (at your option) any later version.
-
-Libiberty is distributed in the hope that it will be useful,
-but WITHOUT ANY WARRANTY; without even the implied warranty of
-MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
-Library General Public License for more details.
-
-You should have received a copy of the GNU Library General Public
-License along with libiberty; see the file COPYING.LIB.  If
-not, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330,
-Boston, MA 02111-1307, USA.  */
-
-/* This file exports two functions; cplus_mangle_opname and cplus_demangle.
-
-   This file imports xmalloc and xrealloc, which are like malloc and
-   realloc except that they generate a fatal error if there is no
-   available memory.  */
-
-/* This file lives in both GCC and libiberty.  When making changes, please
-   try not to break either.  */
-
-#include <ctype.h>
-#include <string.h>
-#include <stdio.h>
-
-#include <demangle.h>
-#undef CURRENT_DEMANGLING_STYLE
-#define CURRENT_DEMANGLING_STYLE work->options
-
-extern char *xmalloc PARAMS((unsigned));
-extern char *xrealloc PARAMS((char *, unsigned));
-
-static const char *mystrstr PARAMS ((const char *, const char *));
-
-static const char *
-mystrstr (s1, s2)
-     const char *s1, *s2;
-{
-  register const char *p = s1;
-  register int len = strlen (s2);
-
-  for (; (p = strchr (p, *s2)) != 0; p++)
-    {
-      if (strncmp (p, s2, len) == 0)
-	{
-	  return (p);
-	}
-    }
-  return (0);
-}
-
-/* In order to allow a single demangler executable to demangle strings
-   using various common values of CPLUS_MARKER, as well as any specific
-   one set at compile time, we maintain a string containing all the
-   commonly used ones, and check to see if the marker we are looking for
-   is in that string.  CPLUS_MARKER is usually '$' on systems where the
-   assembler can deal with that.  Where the assembler can't, it's usually
-   '.' (but on many systems '.' is used for other things).  We put the
-   current defined CPLUS_MARKER first (which defaults to '$'), followed
-   by the next most common value, followed by an explicit '$' in case
-   the value of CPLUS_MARKER is not '$'.
-
-   We could avoid this if we could just get g++ to tell us what the actual
-   cplus marker character is as part of the debug information, perhaps by
-   ensuring that it is the character that terminates the gcc<n>_compiled
-   marker symbol (FIXME).  */
-
-#if !defined (CPLUS_MARKER)
-#define CPLUS_MARKER '$'
-#endif
-
-enum demangling_styles current_demangling_style = gnu_demangling;
-
-static char cplus_markers[] = { CPLUS_MARKER, '.', '$', '\0' };
-
-void
-set_cplus_marker_for_demangling (ch)
-     int ch;
-{
-  cplus_markers[0] = ch;
-}
-
-/* Stuff that is shared between sub-routines.
-   Using a shared structure allows cplus_demangle to be reentrant.  */
-
-struct work_stuff
-{
-  int options;
-  char **typevec;
-  int ntypes;
-  int typevec_size;
-  int constructor;
-  int destructor;
-  int static_type;	/* A static member function */
-  int const_type;	/* A const member function */
-  char **tmpl_argvec;   /* Template function arguments. */
-  int ntmpl_args;       /* The number of template function arguments. */
-};
-
-#define PRINT_ANSI_QUALIFIERS (work -> options & DMGL_ANSI)
-#define PRINT_ARG_TYPES       (work -> options & DMGL_PARAMS)
-
-static const struct optable
-{
-  const char *in;
-  const char *out;
-  int flags;
-} optable[] = {
-  {"nw",	  " new",	DMGL_ANSI},	/* new (1.92,	 ansi) */
-  {"dl",	  " delete",	DMGL_ANSI},	/* new (1.92,	 ansi) */
-  {"new",	  " new",	0},		/* old (1.91,	 and 1.x) */
-  {"delete",	  " delete",	0},		/* old (1.91,	 and 1.x) */
-  {"vn",	  " new []",	DMGL_ANSI},	/* GNU, pending ansi */
-  {"vd",	  " delete []",	DMGL_ANSI},	/* GNU, pending ansi */
-  {"as",	  "=",		DMGL_ANSI},	/* ansi */
-  {"ne",	  "!=",		DMGL_ANSI},	/* old, ansi */
-  {"eq",	  "==",		DMGL_ANSI},	/* old,	ansi */
-  {"ge",	  ">=",		DMGL_ANSI},	/* old,	ansi */
-  {"gt",	  ">",		DMGL_ANSI},	/* old,	ansi */
-  {"le",	  "<=",		DMGL_ANSI},	/* old,	ansi */
-  {"lt",	  "<",		DMGL_ANSI},	/* old,	ansi */
-  {"plus",	  "+",		0},		/* old */
-  {"pl",	  "+",		DMGL_ANSI},	/* ansi */
-  {"apl",	  "+=",		DMGL_ANSI},	/* ansi */
-  {"minus",	  "-",		0},		/* old */
-  {"mi",	  "-",		DMGL_ANSI},	/* ansi */
-  {"ami",	  "-=",		DMGL_ANSI},	/* ansi */
-  {"mult",	  "*",		0},		/* old */
-  {"ml",	  "*",		DMGL_ANSI},	/* ansi */
-  {"amu",	  "*=",		DMGL_ANSI},	/* ansi (ARM/Lucid) */
-  {"aml",	  "*=",		DMGL_ANSI},	/* ansi (GNU/g++) */
-  {"convert",	  "+",		0},		/* old (unary +) */
-  {"negate",	  "-",		0},		/* old (unary -) */
-  {"trunc_mod",	  "%",		0},		/* old */
-  {"md",	  "%",		DMGL_ANSI},	/* ansi */
-  {"amd",	  "%=",		DMGL_ANSI},	/* ansi */
-  {"trunc_div",	  "/",		0},		/* old */
-  {"dv",	  "/",		DMGL_ANSI},	/* ansi */
-  {"adv",	  "/=",		DMGL_ANSI},	/* ansi */
-  {"truth_andif", "&&",		0},		/* old */
-  {"aa",	  "&&",		DMGL_ANSI},	/* ansi */
-  {"truth_orif",  "||",		0},		/* old */
-  {"oo",	  "||",		DMGL_ANSI},	/* ansi */
-  {"truth_not",	  "!",		0},		/* old */
-  {"nt",	  "!",		DMGL_ANSI},	/* ansi */
-  {"postincrement","++",	0},		/* old */
-  {"pp",	  "++",		DMGL_ANSI},	/* ansi */
-  {"postdecrement","--",	0},		/* old */
-  {"mm",	  "--",		DMGL_ANSI},	/* ansi */
-  {"bit_ior",	  "|",		0},		/* old */
-  {"or",	  "|",		DMGL_ANSI},	/* ansi */
-  {"aor",	  "|=",		DMGL_ANSI},	/* ansi */
-  {"bit_xor",	  "^",		0},		/* old */
-  {"er",	  "^",		DMGL_ANSI},	/* ansi */
-  {"aer",	  "^=",		DMGL_ANSI},	/* ansi */
-  {"bit_and",	  "&",		0},		/* old */
-  {"ad",	  "&",		DMGL_ANSI},	/* ansi */
-  {"aad",	  "&=",		DMGL_ANSI},	/* ansi */
-  {"bit_not",	  "~",		0},		/* old */
-  {"co",	  "~",		DMGL_ANSI},	/* ansi */
-  {"call",	  "()",		0},		/* old */
-  {"cl",	  "()",		DMGL_ANSI},	/* ansi */
-  {"alshift",	  "<<",		0},		/* old */
-  {"ls",	  "<<",		DMGL_ANSI},	/* ansi */
-  {"als",	  "<<=",	DMGL_ANSI},	/* ansi */
-  {"arshift",	  ">>",		0},		/* old */
-  {"rs",	  ">>",		DMGL_ANSI},	/* ansi */
-  {"ars",	  ">>=",	DMGL_ANSI},	/* ansi */
-  {"component",	  "->",		0},		/* old */
-  {"pt",	  "->",		DMGL_ANSI},	/* ansi; Lucid C++ form */
-  {"rf",	  "->",		DMGL_ANSI},	/* ansi; ARM/GNU form */
-  {"indirect",	  "*",		0},		/* old */
-  {"method_call",  "->()",	0},		/* old */
-  {"addr",	  "&",		0},		/* old (unary &) */
-  {"array",	  "[]",		0},		/* old */
-  {"vc",	  "[]",		DMGL_ANSI},	/* ansi */
-  {"compound",	  ", ",		0},		/* old */
-  {"cm",	  ", ",		DMGL_ANSI},	/* ansi */
-  {"cond",	  "?:",		0},		/* old */
-  {"cn",	  "?:",		DMGL_ANSI},	/* pseudo-ansi */
-  {"max",	  ">?",		0},		/* old */
-  {"mx",	  ">?",		DMGL_ANSI},	/* pseudo-ansi */
-  {"min",	  "<?",		0},		/* old */
-  {"mn",	  "<?",		DMGL_ANSI},	/* pseudo-ansi */
-  {"nop",	  "",		0},		/* old (for operator=) */
-  {"rm",	  "->*",	DMGL_ANSI}	/* ansi */
-};
-
-
-typedef struct string		/* Beware: these aren't required to be */
-{				/*  '\0' terminated.  */
-  char *b;			/* pointer to start of string */
-  char *p;			/* pointer after last character */
-  char *e;			/* pointer after end of allocated space */
-} string;
-
-#define STRING_EMPTY(str)	((str) -> b == (str) -> p)
-#define PREPEND_BLANK(str)	{if (!STRING_EMPTY(str)) \
-    string_prepend(str, " ");}
-#define APPEND_BLANK(str)	{if (!STRING_EMPTY(str)) \
-    string_append(str, " ");}
-
-#define ARM_VTABLE_STRING "__vtbl__"	/* Lucid/ARM virtual table prefix */
-#define ARM_VTABLE_STRLEN 8		/* strlen (ARM_VTABLE_STRING) */
-
-/* Prototypes for local functions */
-
-static char *
-mop_up PARAMS ((struct work_stuff *, string *, int));
-
-#if 0
-static int
-demangle_method_args PARAMS ((struct work_stuff *work, const char **, string *));
-#endif
-
-static int
-demangle_template PARAMS ((struct work_stuff *, const char **, string *,
-			   string *, int));
-
-static int
-arm_pt PARAMS ((struct work_stuff *, const char *, int, const char **,
-		const char **));
-
-static void
-demangle_arm_pt PARAMS ((struct work_stuff *, const char **, int, string *));
-
-static int
-demangle_class_name PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-demangle_qualified PARAMS ((struct work_stuff *, const char **, string *,
-			    int, int));
-
-static int
-demangle_class PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-demangle_fund_type PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-demangle_signature PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-demangle_prefix PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-gnu_special PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-arm_special PARAMS ((struct work_stuff *, const char **, string *));
-
-static void
-string_need PARAMS ((string *, int));
-
-static void
-string_delete PARAMS ((string *));
-
-static void
-string_init PARAMS ((string *));
-
-static void
-string_clear PARAMS ((string *));
-
-#if 0
-static int
-string_empty PARAMS ((string *));
-#endif
-
-static void
-string_append PARAMS ((string *, const char *));
-
-static void
-string_appends PARAMS ((string *, string *));
-
-static void
-string_appendn PARAMS ((string *, const char *, int));
-
-static void
-string_prepend PARAMS ((string *, const char *));
-
-static void
-string_prependn PARAMS ((string *, const char *, int));
-
-static int
-get_count PARAMS ((const char **, int *));
-
-static int
-consume_count PARAMS ((const char **));
-
-static int 
-consume_count_with_underscores PARAMS ((const char**));
-
-static int
-demangle_args PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-do_type PARAMS ((struct work_stuff *, const char **, string *));
-
-static int
-do_arg PARAMS ((struct work_stuff *, const char **, string *));
-
-static void
-demangle_function_name PARAMS ((struct work_stuff *, const char **, string *,
-				const char *));
-
-static void
-remember_type PARAMS ((struct work_stuff *, const char *, int));
-
-static void
-forget_types PARAMS ((struct work_stuff *));
-
-static void
-string_prepends PARAMS ((string *, string *));
-
-/*  Translate count to integer, consuming tokens in the process.
-    Conversion terminates on the first non-digit character.
-    Trying to consume something that isn't a count results in
-    no consumption of input and a return of 0.  */
-
-static int
-consume_count (type)
-     const char **type;
-{
-  int count = 0;
-
-  while (isdigit (**type))
-    {
-      count *= 10;
-      count += **type - '0';
-      (*type)++;
-    }
-  return (count);
-}
-
-
-/* Like consume_count, but for counts that are preceded and followed
-   by '_' if they are greater than 10.  Also, -1 is returned for
-   failure, since 0 can be a valid value.  */
-
-static int
-consume_count_with_underscores (mangled)
-     const char **mangled;
-{
-  int idx;
-
-  if (**mangled == '_')
-    {
-      (*mangled)++;
-      if (!isdigit (**mangled))
-	return -1;
-
-      idx = consume_count (mangled);
-      if (**mangled != '_')
-	/* The trailing underscore was missing. */
-	return -1;
-	    
-      (*mangled)++;
-    }
-  else
-    {
-      if (**mangled < '0' || **mangled > '9')
-	return -1;
-	    
-      idx = **mangled - '0';
-      (*mangled)++;
-    }
-
-  return idx;
-}
-
-int
-cplus_demangle_opname (opname, result, options)
-     const char *opname;
-     char *result;
-     int options;
-{
-  int len, i, len1, ret;
-  string type;
-  struct work_stuff work[1];
-  const char *tem;
-
-  len = strlen(opname);
-  result[0] = '\0';
-  ret = 0;
-  work->options = options;
-  
-  if (opname[0] == '_' && opname[1] == '_'
-      && opname[2] == 'o' && opname[3] == 'p')
-    {
-      /* ANSI.  */
-      /* type conversion operator.  */
-      tem = opname + 4;
-      if (do_type (work, &tem, &type))
-	{
-	  strcat (result, "operator ");
-	  strncat (result, type.b, type.p - type.b);
-	  string_delete (&type);
-	  ret = 1;
-	}
-    }
-  else if (opname[0] == '_' && opname[1] == '_'
-	   && opname[2] >= 'a' && opname[2] <= 'z'
-	   && opname[3] >= 'a' && opname[3] <= 'z')
-    {
-      if (opname[4] == '\0')
-	{
-	  /* Operator.  */
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      if (strlen (optable[i].in) == 2
-		  && memcmp (optable[i].in, opname + 2, 2) == 0)
-		{
-		  strcat (result, "operator");
-		  strcat (result, optable[i].out);
-		  ret = 1;
-		  break;
-		}
-	    }
-	}
-      else
-	{
-	  if (opname[2] == 'a' && opname[5] == '\0')
-	    {
-	      /* Assignment.  */
-	      for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-		{
-		  if (strlen (optable[i].in) == 3
-		      && memcmp (optable[i].in, opname + 2, 3) == 0)
-		    {
-		      strcat (result, "operator");
-		      strcat (result, optable[i].out);
-		      ret = 1;
-		      break;
-		    }		      
-		}
-	    }
-	}
-    }
-  else if (len >= 3 
-	   && opname[0] == 'o'
-	   && opname[1] == 'p'
-	   && strchr (cplus_markers, opname[2]) != NULL)
-    {
-      /* see if it's an assignment expression */
-      if (len >= 10 /* op$assign_ */
-	  && memcmp (opname + 3, "assign_", 7) == 0)
-	{
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      len1 = len - 10;
-	      if (strlen (optable[i].in) == len1
-		  && memcmp (optable[i].in, opname + 10, len1) == 0)
-		{
-		  strcat (result, "operator");
-		  strcat (result, optable[i].out);
-		  strcat (result, "=");
-		  ret = 1;
-		  break;
-		}
-	    }
-	}
-      else
-	{
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      len1 = len - 3;
-	      if (strlen (optable[i].in) == len1 
-		  && memcmp (optable[i].in, opname + 3, len1) == 0)
-		{
-		  strcat (result, "operator");
-		  strcat (result, optable[i].out);
-		  ret = 1;
-		  break;
-		}
-	    }
-	}
-    }
-  else if (len >= 5 && memcmp (opname, "type", 4) == 0
-	   && strchr (cplus_markers, opname[4]) != NULL)
-    {
-      /* type conversion operator */
-      tem = opname + 5;
-      if (do_type (work, &tem, &type))
-	{
-	  strcat (result, "operator ");
-	  strncat (result, type.b, type.p - type.b);
-	  string_delete (&type);
-	  ret = 1;
-	}
-    }
-  return ret;
-
-}
-/* Takes operator name as e.g. "++" and returns mangled
-   operator name (e.g. "postincrement_expr"), or NULL if not found.
-
-   If OPTIONS & DMGL_ANSI == 1, return the ANSI name;
-   if OPTIONS & DMGL_ANSI == 0, return the old GNU name.  */
-
-const char *
-cplus_mangle_opname (opname, options)
-     const char *opname;
-     int options;
-{
-  int i;
-  int len;
-
-  len = strlen (opname);
-  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-    {
-      if (strlen (optable[i].out) == len
-	  && (options & DMGL_ANSI) == (optable[i].flags & DMGL_ANSI)
-	  && memcmp (optable[i].out, opname, len) == 0)
-	return optable[i].in;
-    }
-  return (0);
-}
-
-/* char *cplus_demangle (const char *mangled, int options)
-
-   If MANGLED is a mangled function name produced by GNU C++, then
-   a pointer to a malloced string giving a C++ representation
-   of the name will be returned; otherwise NULL will be returned.
-   It is the caller's responsibility to free the string which
-   is returned.
-
-   The OPTIONS arg may contain one or more of the following bits:
-
-   	DMGL_ANSI	ANSI qualifiers such as `const' and `void' are
-			included.
-	DMGL_PARAMS	Function parameters are included.
-
-   For example,
-   
-   cplus_demangle ("foo__1Ai", DMGL_PARAMS)		=> "A::foo(int)"
-   cplus_demangle ("foo__1Ai", DMGL_PARAMS | DMGL_ANSI)	=> "A::foo(int)"
-   cplus_demangle ("foo__1Ai", 0)			=> "A::foo"
-
-   cplus_demangle ("foo__1Afe", DMGL_PARAMS)		=> "A::foo(float,...)"
-   cplus_demangle ("foo__1Afe", DMGL_PARAMS | DMGL_ANSI)=> "A::foo(float,...)"
-   cplus_demangle ("foo__1Afe", 0)			=> "A::foo"
-
-   Note that any leading underscores, or other such characters prepended by
-   the compilation system, are presumed to have already been stripped from
-   MANGLED.  */
-
-char *
-cplus_demangle (mangled, options)
-     const char *mangled;
-     int options;
-{
-  string decl;
-  int success = 0;
-  struct work_stuff work[1];
-  char *demangled = NULL;
-
-  if ((mangled != NULL) && (*mangled != '\0'))
-    {
-      memset ((char *) work, 0, sizeof (work));
-      work -> options = options;
-      if ((work->options & DMGL_STYLE_MASK) == 0)
-	work->options |= (int)current_demangling_style & DMGL_STYLE_MASK;
-      
-      string_init (&decl);
-
-      /* First check to see if gnu style demangling is active and if the
-	 string to be demangled contains a CPLUS_MARKER.  If so, attempt to
-	 recognize one of the gnu special forms rather than looking for a
-	 standard prefix.  In particular, don't worry about whether there
-	 is a "__" string in the mangled string.  Consider "_$_5__foo" for
-	 example.  */
-
-      if ((AUTO_DEMANGLING || GNU_DEMANGLING))
-	{
-	  success = gnu_special (work, &mangled, &decl);
-	}
-      if (!success)
-	{
-	  success = demangle_prefix (work, &mangled, &decl);
-	}
-      if (success && (*mangled != '\0'))
-	{
-	  success = demangle_signature (work, &mangled, &decl);
-	}
-      if (work->constructor == 2)
-        {
-          string_prepend(&decl, "global constructors keyed to ");
-          work->constructor = 0;
-        }
-      else if (work->destructor == 2)
-        {
-          string_prepend(&decl, "global destructors keyed to ");
-          work->destructor = 0;
-        }
-      demangled = mop_up (work, &decl, success);
-    }
-  return (demangled);
-}
-
-static char *
-mop_up (work, declp, success)
-     struct work_stuff *work;
-     string *declp;
-     int success;
-{
-  char *demangled = NULL;
-
-  /* Discard the remembered types, if any.  */
-  
-  forget_types (work);
-  if (work -> typevec != NULL)
-    {
-      free ((char *) work -> typevec);
-    }
-  if (work->tmpl_argvec)
-    {
-      int i;
-
-      for (i = 0; i < work->ntmpl_args; i++)
-	if (work->tmpl_argvec[i])
-	  free ((char*) work->tmpl_argvec[i]);
-      
-      free ((char*) work->tmpl_argvec);
-    }
-
-  /* If demangling was successful, ensure that the demangled string is null
-     terminated and return it.  Otherwise, free the demangling decl.  */
-  
-  if (!success)
-    {
-      string_delete (declp);
-    }
-  else
-    {
-      string_appendn (declp, "", 1);
-      demangled = declp -> b;
-    }
-  return (demangled);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	demangle_signature -- demangle the signature part of a mangled name
-
-SYNOPSIS
-
-	static int
-	demangle_signature (struct work_stuff *work, const char **mangled,
-			    string *declp);
-
-DESCRIPTION
-
-	Consume and demangle the signature portion of the mangled name.
-
-	DECLP is the string where demangled output is being built.  At
-	entry it contains the demangled root name from the mangled name
-	prefix.  I.E. either a demangled operator name or the root function
-	name.  In some special cases, it may contain nothing.
-
-	*MANGLED points to the current unconsumed location in the mangled
-	name.  As tokens are consumed and demangling is performed, the
-	pointer is updated to continuously point at the next token to
-	be consumed.
-
-	Demangling GNU style mangled names is nasty because there is no
-	explicit token that marks the start of the outermost function
-	argument list.  */
-
-static int
-demangle_signature (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int success = 1;
-  int func_done = 0;
-  int expect_func = 0;
-  int expect_return_type = 0;
-  const char *oldmangled = NULL;
-  string trawname;
-  string tname;
-
-  while (success && (**mangled != '\0'))
-    {
-      switch (**mangled)
-	{
-	case 'Q':
-	  oldmangled = *mangled;
-	  success = demangle_qualified (work, mangled, declp, 1, 0);
-	  if (success)
-	    {
-	      remember_type (work, oldmangled, *mangled - oldmangled);
-	    }
-	  if (AUTO_DEMANGLING || GNU_DEMANGLING)
-	    {
-	      expect_func = 1;
-	    }
-	  oldmangled = NULL;
-	  break;
-	  
-	case 'S':
-	  /* Static member function */
-	  if (oldmangled == NULL)
-	    {
-	      oldmangled = *mangled;
-	    }
-	  (*mangled)++;
-	  work -> static_type = 1;
-	  break;
-
-	case 'C':
-	  /* a const member function */
-	  if (oldmangled == NULL)
-	    {
-	      oldmangled = *mangled;
-	    }
-	  (*mangled)++;
-	  work -> const_type = 1;
-	  break;
-	  
-	case '0': case '1': case '2': case '3': case '4':
-	case '5': case '6': case '7': case '8': case '9':
-	  if (oldmangled == NULL)
-	    {
-	      oldmangled = *mangled;
-	    }
-	  success = demangle_class (work, mangled, declp);
-	  if (success)
-	    {
-	      remember_type (work, oldmangled, *mangled - oldmangled);
-	    }
-	  if (AUTO_DEMANGLING || GNU_DEMANGLING)
-	    {
-	      expect_func = 1;
-	    }
-	  oldmangled = NULL;
-	  break;
-	  
-	case 'F':
-	  /* Function */
-	  /* ARM style demangling includes a specific 'F' character after
-	     the class name.  For GNU style, it is just implied.  So we can
-	     safely just consume any 'F' at this point and be compatible
-	     with either style.  */
-
-	  oldmangled = NULL;
-	  func_done = 1;
-	  (*mangled)++;
-
-	  /* For lucid/ARM style we have to forget any types we might
-	     have remembered up to this point, since they were not argument
-	     types.  GNU style considers all types seen as available for
-	     back references.  See comment in demangle_args() */
-
-	  if (LUCID_DEMANGLING || ARM_DEMANGLING)
-	    {
-	      forget_types (work);
-	    }
-	  success = demangle_args (work, mangled, declp);
-	  break;
-	  
-	case 't':
-	  /* G++ Template */
-	  string_init(&trawname); 
-	  string_init(&tname);
-	  if (oldmangled == NULL)
-	    {
-	      oldmangled = *mangled;
-	    }
-	  success = demangle_template (work, mangled, &tname, &trawname, 1);
-	  if (success)
-	    {
-	      remember_type (work, oldmangled, *mangled - oldmangled);
-	    }
-	  string_append(&tname, (work -> options & DMGL_JAVA) ? "." : "::");
-	  string_prepends(declp, &tname);
-	  if (work -> destructor & 1)
-	    {
-	      string_prepend (&trawname, "~");
-	      string_appends (declp, &trawname);
-	      work->destructor -= 1;
-	    }
-	  if ((work->constructor & 1) || (work->destructor & 1))
-	    {
-	      string_appends (declp, &trawname);
-	      work->constructor -= 1;
-	    }
-	  string_delete(&trawname);
-	  string_delete(&tname);
-	  oldmangled = NULL;
-	  expect_func = 1;
-	  break;
-
-	case '_':
-	  if (GNU_DEMANGLING && expect_return_type) 
-	    {
-	      /* Read the return type. */
-	      string return_type;
-	      string_init (&return_type);
-
-	      (*mangled)++;
-	      success = do_type (work, mangled, &return_type);
-	      APPEND_BLANK (&return_type);
-
-	      string_prepends (declp, &return_type);
-	      string_delete (&return_type);
-	      break;
-	    }
-	  else
-	    /* At the outermost level, we cannot have a return type specified,
-	       so if we run into another '_' at this point we are dealing with
-	       a mangled name that is either bogus, or has been mangled by
-	       some algorithm we don't know how to deal with.  So just
-	       reject the entire demangling.  */
-	    success = 0;
-	  break;
-
-	case 'H':
-	  if (GNU_DEMANGLING) 
-	    {
-	      /* A G++ template function.  Read the template arguments. */
-	      success = demangle_template (work, mangled, declp, 0, 0);
-	      expect_return_type = 1;
-	      (*mangled)++;
-	      break;
-	    }
-	  else
-	    /* fall through */
-	    ;
-
-	default:
-	  if (AUTO_DEMANGLING || GNU_DEMANGLING)
-	    {
-	      /* Assume we have stumbled onto the first outermost function
-		 argument token, and start processing args.  */
-	      func_done = 1;
-	      success = demangle_args (work, mangled, declp);
-	    }
-	  else
-	    {
-	      /* Non-GNU demanglers use a specific token to mark the start
-		 of the outermost function argument tokens.  Typically 'F',
-		 for ARM-demangling, for example.  So if we find something
-		 we are not prepared for, it must be an error.  */
-	      success = 0;
-	    }
-	  break;
-	}
-      /*
-	if (AUTO_DEMANGLING || GNU_DEMANGLING)
-	*/
-      {
-	if (success && expect_func)
-	  {
-	    func_done = 1;
-	    success = demangle_args (work, mangled, declp);
-	    /* Since template include the mangling of their return types,
-	       we must set expect_func to 0 so that we don't try do
-	       demangle more arguments the next time we get here.  */
-	    expect_func = 0;
-	  }
-      }
-    }
-  if (success && !func_done)
-    {
-      if (AUTO_DEMANGLING || GNU_DEMANGLING)
-	{
-	  /* With GNU style demangling, bar__3foo is 'foo::bar(void)', and
-	     bar__3fooi is 'foo::bar(int)'.  We get here when we find the
-	     first case, and need to ensure that the '(void)' gets added to
-	     the current declp.  Note that with ARM, the first case
-	     represents the name of a static data member 'foo::bar',
-	     which is in the current declp, so we leave it alone.  */
-	  success = demangle_args (work, mangled, declp);
-	}
-    }
-  if (success && work -> static_type && PRINT_ARG_TYPES)
-    {
-      string_append (declp, " static");
-    }
-  if (success && work -> const_type && PRINT_ARG_TYPES)
-    {
-      string_append (declp, " const");
-    }
-  return (success);
-}
-
-#if 0
-
-static int
-demangle_method_args (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int success = 0;
-
-  if (work -> static_type)
-    {
-      string_append (declp, *mangled + 1);
-      *mangled += strlen (*mangled);
-      success = 1;
-    }
-  else
-    {
-      success = demangle_args (work, mangled, declp);
-    }
-  return (success);
-}
-
-#endif
-
-static int
-demangle_template (work, mangled, tname, trawname, is_type)
-     struct work_stuff *work;
-     const char **mangled;
-     string *tname;
-     string *trawname;
-     int is_type;
-{
-  int i;
-  int is_pointer;
-  int is_real;
-  int is_integral;
-  int is_char;
-  int is_bool;
-  int r;
-  int need_comma = 0;
-  int success = 0;
-  int done;
-  const char *old_p;
-  const char *start;
-  int symbol_len;
-  int is_java_array = 0;
-  string temp;
-
-  (*mangled)++;
-  if (is_type)
-    {
-      start = *mangled;
-      /* get template name */
-      if ((r = consume_count (mangled)) == 0 || strlen (*mangled) < r)
-	{
-	  return (0);
-	}
-      if (trawname)
-	string_appendn (trawname, *mangled, r);
-      is_java_array = (work -> options & DMGL_JAVA)
-	&& strncmp (*mangled, "JArray1Z", 8) == 0;
-      if (! is_java_array)
-	{
-	  string_appendn (tname, *mangled, r);
-	}
-      *mangled += r;
-    }
-  if (!is_java_array)
-    string_append (tname, "<");
-  /* get size of template parameter list */
-  if (!get_count (mangled, &r))
-    {
-      return (0);
-    }
-  if (!is_type)
-    {
-      /* Create an array for saving the template argument values. */
-      work->tmpl_argvec = (char**) xmalloc (r * sizeof (char *));
-      work->ntmpl_args = r;
-      for (i = 0; i < r; i++)
-	work->tmpl_argvec[i] = 0;
-    }
-  for (i = 0; i < r; i++)
-    {
-      if (need_comma)
-	{
-	  string_append (tname, ", ");
-	}
-      /* Z for type parameters */
-      if (**mangled == 'Z')
-	{
-	  (*mangled)++;
-	  /* temp is initialized in do_type */
-	  success = do_type (work, mangled, &temp);
-	  if (success)
-	    {
-	      string_appends (tname, &temp);
-
-	      if (!is_type)
-		{
-		  /* Save the template argument. */
-		  int len = temp.p - temp.b;
-		  work->tmpl_argvec[i] = xmalloc (len + 1);
-		  memcpy (work->tmpl_argvec[i], temp.b, len);
-		  work->tmpl_argvec[i][len] = '\0';
-		}
-	    }
-	  string_delete(&temp);
-	  if (!success)
-	    {
-	      break;
-	    }
-	}
-      else
-	{
-	  string  param;
-	  string* s;
-
-	  /* otherwise, value parameter */
-	  old_p  = *mangled;
-	  is_pointer = 0;
-	  is_real = 0;
-	  is_integral = 0;
-          is_char = 0;
-	  is_bool = 0;
-	  done = 0;
-	  /* temp is initialized in do_type */
-	  success = do_type (work, mangled, &temp);
-	  /*
-	    if (success)
-	    {
-	    string_appends (s, &temp);
-	    }
-	    */
-	  string_delete(&temp);
-	  if (!success)
-	    {
-	      break;
-	    }
-	  /*
-	    string_append (s, "=");
-	    */
-
-	  if (!is_type)
-	    {
-	      s = &param;
-	      string_init (s);
-	    }
-	  else
-	    s = tname;
-
-	  while (*old_p && !done)
-	    {	
-	      switch (*old_p)
-		{
-		case 'P':
-		case 'p':
-		case 'R':
-		  done = is_pointer = 1;
-		  break;
-		case 'C':	/* const */
-		case 'S':	/* explicitly signed [char] */
-		case 'U':	/* unsigned */
-		case 'V':	/* volatile */
-		case 'F':	/* function */
-		case 'M':	/* member function */
-		case 'O':	/* ??? */
-		case 'J':	/* complex */
-		  old_p++;
-		  continue;
-		case 'Q':	/* qualified name */
-		  done = is_integral = 1;
-		  break;
-		case 'T':	/* remembered type */
-		  abort ();
-		  break;
-		case 'v':	/* void */
-		  abort ();
-		  break;
-		case 'x':	/* long long */
-		case 'l':	/* long */
-		case 'i':	/* int */
-		case 's':	/* short */
-		case 'w':	/* wchar_t */
-		  done = is_integral = 1;
-		  break;
-		case 'b':	/* bool */
-		  done = is_bool = 1;
-		  break;
-		case 'c':	/* char */
-		  done = is_char = 1;
-		  break;
-		case 'r':	/* long double */
-		case 'd':	/* double */
-		case 'f':	/* float */
-		  done = is_real = 1;
-		  break;
-		default:
-		  /* it's probably user defined type, let's assume
-		     it's integral, it seems hard to figure out
-		     what it really is */
-		  done = is_integral = 1;
-		}
-	    }
-	  if (**mangled == 'Y')
-	    {
-	      /* The next argument is a template parameter. */
-	      int idx;
-
-	      (*mangled)++;
-	      idx = consume_count_with_underscores (mangled);
-	      if (idx == -1 
-		  || (work->tmpl_argvec && idx >= work->ntmpl_args)
-		  || consume_count_with_underscores (mangled) == -1)
-		{
-		  success = 0;
-		  if (!is_type)
-		    string_delete (s);
-		  break;
-		}
-	      if (work->tmpl_argvec)
-		string_append (s, work->tmpl_argvec[idx]);
-	      else
-		{
-		  char buf[10];
-		  sprintf(buf, "T%d", idx);
-		  string_append (s, buf);
-		}
-	    }
-	  else if (is_integral)
-	    {
-	      if (**mangled == 'm')
-		{
-		  string_appendn (s, "-", 1);
-		  (*mangled)++;
-		}
-	      while (isdigit (**mangled))	
-		{
-		  string_appendn (s, *mangled, 1);
-		  (*mangled)++;
-		}
-	    }
-	  else if (is_char)
-	    {
-	      char tmp[2];
-	      int val;
-              if (**mangled == 'm')
-                {
-                  string_appendn (s, "-", 1);
-                  (*mangled)++;
-                }
-	      string_appendn (s, "'", 1);
-              val = consume_count(mangled);
-	      if (val == 0)
-		{
-		  success = 0;
-		  if (!is_type)
-		    string_delete (s);
-		  break;
-                }
-              tmp[0] = (char)val;
-              tmp[1] = '\0';
-              string_appendn (s, &tmp[0], 1);
-	      string_appendn (s, "'", 1);
-	    }
-	  else if (is_bool)
-	    {
-	      int val = consume_count (mangled);
-	      if (val == 0)
-		string_appendn (s, "false", 5);
-	      else if (val == 1)
-		string_appendn (s, "true", 4);
-	      else
-		success = 0;
-	    }
-	  else if (is_real)
-	    {
-	      if (**mangled == 'm')
-		{
-		  string_appendn (s, "-", 1);
-		  (*mangled)++;
-		}
-	      while (isdigit (**mangled))	
-		{
-		  string_appendn (s, *mangled, 1);
-		  (*mangled)++;
-		}
-	      if (**mangled == '.') /* fraction */
-		{
-		  string_appendn (s, ".", 1);
-		  (*mangled)++;
-		  while (isdigit (**mangled))	
-		    {
-		      string_appendn (s, *mangled, 1);
-		      (*mangled)++;
-		    }
-		}
-	      if (**mangled == 'e') /* exponent */
-		{
-		  string_appendn (s, "e", 1);
-		  (*mangled)++;
-		  while (isdigit (**mangled))	
-		    {
-		      string_appendn (s, *mangled, 1);
-		      (*mangled)++;
-		    }
-		}
-	    }
-	  else if (is_pointer)
-	    {
-	      symbol_len = consume_count (mangled);
-	      if (symbol_len == 0)
-		{
-		  success = 0;
-		  if (!is_type)
-		    string_delete (s);
-		  break;
-		}
-	      if (symbol_len == 0)
-		string_appendn (s, "0", 1);
-	      else
-		{
-		  char *p = xmalloc (symbol_len + 1), *q;
-		  strncpy (p, *mangled, symbol_len);
-		  p [symbol_len] = '\0';
-		  q = cplus_demangle (p, work->options);
-		  string_appendn (s, "&", 1);
-		  if (q)
-		    {
-		      string_append (s, q);
-		      free (q);
-		    }
-		  else
-		    string_append (s, p);
-		  free (p);
-		}
-	      *mangled += symbol_len;
-	    }
-	  if (!is_type)
-	    {
-	      int len = s->p - s->b;
-	      work->tmpl_argvec[i] = xmalloc (len + 1);
-	      memcpy (work->tmpl_argvec[i], s->b, len);
-	      work->tmpl_argvec[i][len] = '\0';
-	      
-	      string_appends (tname, s);
-	      string_delete (s);
-	    }
-	}
-      need_comma = 1;
-    }
-  if (is_java_array)
-    {
-      string_append (tname, "[]");
-    }
-  else
-    {
-      if (tname->p[-1] == '>')
-	string_append (tname, " ");
-      string_append (tname, ">");
-    }
-  
-  /*
-    if (work -> static_type)
-    {
-    string_append (declp, *mangled + 1);
-    *mangled += strlen (*mangled);
-    success = 1;
-    }
-    else
-    {
-    success = demangle_args (work, mangled, declp);
-    }
-    }
-    */
-  return (success);
-}
-
-static int
-arm_pt (work, mangled, n, anchor, args)
-     struct work_stuff *work;
-     const char *mangled;
-     int n;
-     const char **anchor, **args;
-{
-  /* ARM template? */
-  if (ARM_DEMANGLING && (*anchor = mystrstr (mangled, "__pt__")))
-    {
-      int len;
-      *args = *anchor + 6;
-      len = consume_count (args);
-      if (*args + len == mangled + n && **args == '_')
-	{
-	  ++*args;
-	  return 1;
-	}
-    }
-  return 0;
-}
-
-static void
-demangle_arm_pt (work, mangled, n, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     int n;
-     string *declp;
-{
-  const char *p;
-  const char *args;
-  const char *e = *mangled + n;
-
-  /* ARM template? */
-  if (arm_pt (work, *mangled, n, &p, &args))
-    {
-      string arg;
-      string_init (&arg);
-      string_appendn (declp, *mangled, p - *mangled);
-      string_append (declp, "<");
-      /* should do error checking here */
-      while (args < e) {
-	string_clear (&arg);
-	do_type (work, &args, &arg);
-	string_appends (declp, &arg);
-	string_append (declp, ",");
-      }
-      string_delete (&arg);
-      --declp->p;
-      string_append (declp, ">");
-    }
-  else
-    {
-      string_appendn (declp, *mangled, n);
-    }
-  *mangled += n;
-}
-
-static int
-demangle_class_name (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int n;
-  int success = 0;
-
-  n = consume_count (mangled);
-  if (strlen (*mangled) >= n)
-    {
-      demangle_arm_pt (work, mangled, n, declp);
-      success = 1;
-    }
-
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	demangle_class -- demangle a mangled class sequence
-
-SYNOPSIS
-
-	static int
-	demangle_class (struct work_stuff *work, const char **mangled,
-			strint *declp)
-
-DESCRIPTION
-
-	DECLP points to the buffer into which demangling is being done.
-
-	*MANGLED points to the current token to be demangled.  On input,
-	it points to a mangled class (I.E. "3foo", "13verylongclass", etc.)
-	On exit, it points to the next token after the mangled class on
-	success, or the first unconsumed token on failure.
-
-	If the CONSTRUCTOR or DESTRUCTOR flags are set in WORK, then
-	we are demangling a constructor or destructor.  In this case
-	we prepend "class::class" or "class::~class" to DECLP.
-
-	Otherwise, we prepend "class::" to the current DECLP.
-
-	Reset the constructor/destructor flags once they have been
-	"consumed".  This allows demangle_class to be called later during
-	the same demangling, to do normal class demangling.
-
-	Returns 1 if demangling is successful, 0 otherwise.
-
-*/
-
-static int
-demangle_class (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int success = 0;
-  string class_name;
-
-  string_init (&class_name);
-  if (demangle_class_name (work, mangled, &class_name))
-    {
-      if ((work->constructor & 1) || (work->destructor & 1))
-	{
-	  string_prepends (declp, &class_name);
-	  if (work -> destructor & 1)
-	    {
-	      string_prepend (declp, "~");
-              work -> destructor -= 1;
-	    }
-	  else
-	    {
-	      work -> constructor -= 1; 
-	    }
-	}
-      string_prepend (declp, (work -> options & DMGL_JAVA) ? "." : "::");
-      string_prepends (declp, &class_name);
-      success = 1;
-    }
-  string_delete (&class_name);
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	demangle_prefix -- consume the mangled name prefix and find signature
-
-SYNOPSIS
-
-	static int
-	demangle_prefix (struct work_stuff *work, const char **mangled,
-			 string *declp);
-
-DESCRIPTION
-
-	Consume and demangle the prefix of the mangled name.
-
-	DECLP points to the string buffer into which demangled output is
-	placed.  On entry, the buffer is empty.  On exit it contains
-	the root function name, the demangled operator name, or in some
-	special cases either nothing or the completely demangled result.
-
-	MANGLED points to the current pointer into the mangled name.  As each
-	token of the mangled name is consumed, it is updated.  Upon entry
-	the current mangled name pointer points to the first character of
-	the mangled name.  Upon exit, it should point to the first character
-	of the signature if demangling was successful, or to the first
-	unconsumed character if demangling of the prefix was unsuccessful.
-	
-	Returns 1 on success, 0 otherwise.
- */
-
-static int
-demangle_prefix (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int success = 1;
-  const char *scan;
-  int i;
-
-  if (strlen(*mangled) >= 11 && strncmp(*mangled, "_GLOBAL_", 8) == 0)
-    {
-      char *marker = strchr (cplus_markers, (*mangled)[8]);
-      if (marker != NULL && *marker == (*mangled)[10])
-	{
-	  if ((*mangled)[9] == 'D')
-	    {
-	      /* it's a GNU global destructor to be executed at program exit */
-	      (*mangled) += 11;
-	      work->destructor = 2;
-	      if (gnu_special (work, mangled, declp))
-		return success;
-	    }
-	  else if ((*mangled)[9] == 'I')
-	    {
-	      /* it's a GNU global constructor to be executed at program init */
-	      (*mangled) += 11;
-	      work->constructor = 2;
-	      if (gnu_special (work, mangled, declp))
-		return success;
-	    }
-	}
-    }
-  else if (ARM_DEMANGLING && strncmp(*mangled, "__std__", 7) == 0)
-    {
-      /* it's a ARM global destructor to be executed at program exit */
-      (*mangled) += 7;
-      work->destructor = 2;
-    }
-  else if (ARM_DEMANGLING && strncmp(*mangled, "__sti__", 7) == 0)
-    {
-      /* it's a ARM global constructor to be executed at program initial */
-      (*mangled) += 7;
-      work->constructor = 2;
-    }
-
-  /*  This block of code is a reduction in strength time optimization
-      of:
-      scan = mystrstr (*mangled, "__"); */
-
-  {
-    scan = *mangled;
-
-    do {
-      scan = strchr (scan, '_');
-    } while (scan != NULL && *++scan != '_');
-
-    if (scan != NULL) --scan;
-  }
-
-  if (scan != NULL)
-    {
-      /* We found a sequence of two or more '_', ensure that we start at
-	 the last pair in the sequence.  */
-      i = strspn (scan, "_");
-      if (i > 2)
-	{
-	  scan += (i - 2); 
-	}
-    }
- 
-  if (scan == NULL)
-    {
-      success = 0;
-    }
-  else if (work -> static_type)
-    {
-      if (!isdigit (scan[0]) && (scan[0] != 't'))
-	{
-	  success = 0;
-	}
-    }
-  else if ((scan == *mangled)
-	   && (isdigit (scan[2]) || (scan[2] == 'Q') || (scan[2] == 't')))
-    {
-      /* The ARM says nothing about the mangling of local variables.
-	 But cfront mangles local variables by prepending __<nesting_level>
-	 to them. As an extension to ARM demangling we handle this case.  */
-      if ((LUCID_DEMANGLING || ARM_DEMANGLING) && isdigit (scan[2]))
-	{
-	  *mangled = scan + 2;
-	  consume_count (mangled);
-	  string_append (declp, *mangled);
-	  *mangled += strlen (*mangled);
-	  success = 1; 
-	}
-      else
-	{
-	  /* A GNU style constructor starts with __[0-9Qt].  But cfront uses
-	     names like __Q2_3foo3bar for nested type names.  So don't accept
-	     this style of constructor for cfront demangling.  */
-	  if (!(LUCID_DEMANGLING || ARM_DEMANGLING))
-	    work -> constructor += 1;
-	  *mangled = scan + 2;
-	}
-    }
-  else if ((scan == *mangled) && !isdigit (scan[2]) && (scan[2] != 't'))
-    {
-      /* Mangled name starts with "__".  Skip over any leading '_' characters,
-	 then find the next "__" that separates the prefix from the signature.
-	 */
-      if (!(ARM_DEMANGLING || LUCID_DEMANGLING)
-	  || (arm_special (work, mangled, declp) == 0))
-	{
-	  while (*scan == '_')
-	    {
-	      scan++;
-	    }
-	  if ((scan = mystrstr (scan, "__")) == NULL || (*(scan + 2) == '\0'))
-	    {
-	      /* No separator (I.E. "__not_mangled"), or empty signature
-		 (I.E. "__not_mangled_either__") */
-	      success = 0;
-	    }
-	  else
-	    {
-	      demangle_function_name (work, mangled, declp, scan);
-	    }
-	}
-    }
-  else if (ARM_DEMANGLING && scan[2] == 'p' && scan[3] == 't')
-    {
-      /* Cfront-style parameterized type.  Handled later as a signature.  */
-      success = 1;
-
-      /* ARM template? */
-      demangle_arm_pt (work, mangled, strlen (*mangled), declp);
-    }
-  else if (*(scan + 2) != '\0')
-    {
-      /* Mangled name does not start with "__" but does have one somewhere
-	 in there with non empty stuff after it.  Looks like a global
-	 function name.  */
-      demangle_function_name (work, mangled, declp, scan);
-    }
-  else
-    {
-      /* Doesn't look like a mangled name */
-      success = 0;
-    }
-
-  if (!success && (work->constructor == 2 || work->destructor == 2))
-    {
-      string_append (declp, *mangled);
-      *mangled += strlen (*mangled);
-      success = 1;
-    } 
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	gnu_special -- special handling of gnu mangled strings
-
-SYNOPSIS
-
-	static int
-	gnu_special (struct work_stuff *work, const char **mangled,
-		     string *declp);
-
-
-DESCRIPTION
-
-	Process some special GNU style mangling forms that don't fit
-	the normal pattern.  For example:
-
-		_$_3foo		(destructor for class foo)
-		_vt$foo		(foo virtual table)
-		_vt$foo$bar	(foo::bar virtual table)
-		__vt_foo	(foo virtual table, new style with thunks)
-		_3foo$varname	(static data member)
-		_Q22rs2tu$vw	(static data member)
-		__t6vector1Zii	(constructor with template)
-		__thunk_4__$_7ostream (virtual function thunk)
- */
-
-static int
-gnu_special (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int n;
-  int success = 1;
-  const char *p;
-
-  if ((*mangled)[0] == '_'
-      && strchr (cplus_markers, (*mangled)[1]) != NULL
-      && (*mangled)[2] == '_')
-    {
-      /* Found a GNU style destructor, get past "_<CPLUS_MARKER>_" */
-      (*mangled) += 3;
-      work -> destructor += 1;
-    }
-  else if ((*mangled)[0] == '_'
-	   && (((*mangled)[1] == '_'
-		&& (*mangled)[2] == 'v'
-		&& (*mangled)[3] == 't'
-		&& (*mangled)[4] == '_')
-	       || ((*mangled)[1] == 'v'
-		   && (*mangled)[2] == 't'
-		   && strchr (cplus_markers, (*mangled)[3]) != NULL)))
-    {
-      /* Found a GNU style virtual table, get past "_vt<CPLUS_MARKER>"
-         and create the decl.  Note that we consume the entire mangled
-	 input string, which means that demangle_signature has no work
-	 to do.  */
-      if ((*mangled)[2] == 'v')
-	(*mangled) += 5; /* New style, with thunks: "__vt_" */
-      else
-	(*mangled) += 4; /* Old style, no thunks: "_vt<CPLUS_MARKER>" */
-      while (**mangled != '\0')
-	{
-	  p = strpbrk (*mangled, cplus_markers);
-	  switch (**mangled)
-	    {
-	    case 'Q':
-	      success = demangle_qualified (work, mangled, declp, 0, 1);
-	      break;
-	    case 't':
-	      success = demangle_template (work, mangled, declp, 0, 1);
-	      break;
-	    default:
-	      if (isdigit(*mangled[0]))
-		{
-		  n = consume_count(mangled);
-		}
-	      else
-		{
-		  n = strcspn (*mangled, cplus_markers);
-		}
-	      string_appendn (declp, *mangled, n);
-	      (*mangled) += n;
-	    }
-
-	  if (success && ((p == NULL) || (p == *mangled)))
-	    {
-	      if (p != NULL)
-		{
-		  string_append (declp,
-				 (work -> options & DMGL_JAVA) ? "." : "::");
-		  (*mangled)++;
-		}
-	    }
-	  else
-	    {
-	      success = 0;
-	      break;
-	    }
-	}
-      if (success)
-	string_append (declp, " virtual table");
-    }
-  else if ((*mangled)[0] == '_'
-	   && (strchr("0123456789Qt", (*mangled)[1]) != NULL)
-	   && (p = strpbrk (*mangled, cplus_markers)) != NULL)
-    {
-      /* static data member, "_3foo$varname" for example */
-      (*mangled)++;
-      switch (**mangled)
-	{
-	case 'Q':
-	  success = demangle_qualified (work, mangled, declp, 0, 1);
-	  break;
-	case 't':
-	  success = demangle_template (work, mangled, declp, 0, 1);
-	  break;
-	default:
-	  n = consume_count (mangled);
-	  string_appendn (declp, *mangled, n);
-	  (*mangled) += n;
-	}
-      if (success && (p == *mangled))
-	{
-	  /* Consumed everything up to the cplus_marker, append the
-	     variable name.  */
-	  (*mangled)++;
-	  string_append (declp, (work -> options & DMGL_JAVA) ? "." : "::");
-	  n = strlen (*mangled);
-	  string_appendn (declp, *mangled, n);
-	  (*mangled) += n;
-	}
-      else
-	{
-	  success = 0;
-	}
-    }
-  else if (strncmp (*mangled, "__thunk_", 8) == 0)
-    {
-      int delta = ((*mangled) += 8, consume_count (mangled));
-      char *method = cplus_demangle (++*mangled, work->options);
-      if (method)
-	{
-	  char buf[50];
-	  sprintf (buf, "virtual function thunk (delta:%d) for ", -delta);
-	  string_append (declp, buf);
-	  string_append (declp, method);
-	  free (method);
-	  n = strlen (*mangled);
-	  (*mangled) += n;
-	}
-      else
-	{
-	  success = 0;
-	}
-    }
-  else if (strncmp (*mangled, "__t", 3) == 0
-	   && ((*mangled)[3] == 'i' || (*mangled)[3] == 'f'))
-    {
-      p = (*mangled)[3] == 'i' ? " type_info node" : " type_info function";
-      (*mangled) += 4;
-      switch (**mangled)
-	{
-	case 'Q':
-	  success = demangle_qualified (work, mangled, declp, 0, 1);
-	  break;
-	case 't':
-	  success = demangle_template (work, mangled, declp, 0, 1);
-	  break;
-	default:
-	  success = demangle_fund_type (work, mangled, declp);
-	  break;
-	}
-      if (success && **mangled != '\0')
-	success = 0;
-      if (success)
-	string_append (declp, p);
-    }
-  else
-    {
-      success = 0;
-    }
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	arm_special -- special handling of ARM/lucid mangled strings
-
-SYNOPSIS
-
-	static int
-	arm_special (struct work_stuff *work, const char **mangled,
-			string *declp);
-
-
-DESCRIPTION
-
-	Process some special ARM style mangling forms that don't fit
-	the normal pattern.  For example:
-
-		__vtbl__3foo		(foo virtual table)
-		__vtbl__3foo__3bar	(bar::foo virtual table)
-
- */
-
-static int
-arm_special (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  int n;
-  int success = 1;
-  const char *scan;
-
-  if (strncmp (*mangled, ARM_VTABLE_STRING, ARM_VTABLE_STRLEN) == 0)
-    {
-      /* Found a ARM style virtual table, get past ARM_VTABLE_STRING
-         and create the decl.  Note that we consume the entire mangled
-	 input string, which means that demangle_signature has no work
-	 to do.  */
-      scan = *mangled + ARM_VTABLE_STRLEN;
-      while (*scan != '\0')        /* first check it can be demangled */
-        {
-          n = consume_count (&scan);
-          if (n==0)
-	    {
-	      return (0);           /* no good */
-	    }
-          scan += n;
-          if (scan[0] == '_' && scan[1] == '_')
-	    {
-	      scan += 2;
-	    }
-        }
-      (*mangled) += ARM_VTABLE_STRLEN;
-      while (**mangled != '\0')
-	{
-	  n = consume_count (mangled);
-	  string_prependn (declp, *mangled, n);
-	  (*mangled) += n;
-	  if ((*mangled)[0] == '_' && (*mangled)[1] == '_')
-	    {
-	      string_prepend (declp, "::");
-	      (*mangled) += 2;
-	    }
-	}
-      string_append (declp, " virtual table");
-    }
-  else
-    {
-      success = 0;
-    }
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	demangle_qualified -- demangle 'Q' qualified name strings
-
-SYNOPSIS
-
-	static int
-	demangle_qualified (struct work_stuff *, const char *mangled,
-			    string *result, int isfuncname, int append);
-
-DESCRIPTION
-
-	Demangle a qualified name, such as "Q25Outer5Inner" which is
-	the mangled form of "Outer::Inner".  The demangled output is
-	prepended or appended to the result string according to the
-	state of the append flag.
-
-	If isfuncname is nonzero, then the qualified name we are building
-	is going to be used as a member function name, so if it is a
-	constructor or destructor function, append an appropriate
-	constructor or destructor name.  I.E. for the above example,
-	the result for use as a constructor is "Outer::Inner::Inner"
-	and the result for use as a destructor is "Outer::Inner::~Inner".
-
-BUGS
-
-	Numeric conversion is ASCII dependent (FIXME).
-
- */
-
-static int
-demangle_qualified (work, mangled, result, isfuncname, append)
-     struct work_stuff *work;
-     const char **mangled;
-     string *result;
-     int isfuncname;
-     int append;
-{
-  int qualifiers;
-  int namelength;
-  int success = 1;
-  const char *p;
-  char num[2];
-  string temp;
-
-  string_init (&temp);
-  switch ((*mangled)[1])
-    {
-    case '_':
-      /* GNU mangled name with more than 9 classes.  The count is preceded
-	 by an underscore (to distinguish it from the <= 9 case) and followed
-	 by an underscore.  */
-      p = *mangled + 2;
-      qualifiers = atoi (p);
-      if (!isdigit (*p) || *p == '0')
-	success = 0;
-
-      /* Skip the digits.  */
-      while (isdigit (*p))
-	++p;
-
-      if (*p != '_')
-	success = 0;
-
-      *mangled = p + 1;
-      break;
-
-    case '1':
-    case '2':
-    case '3':
-    case '4':
-    case '5':
-    case '6':
-    case '7':
-    case '8':
-    case '9':
-      /* The count is in a single digit.  */
-      num[0] = (*mangled)[1];
-      num[1] = '\0';
-      qualifiers = atoi (num);
-
-      /* If there is an underscore after the digit, skip it.  This is
-	 said to be for ARM-qualified names, but the ARM makes no
-	 mention of such an underscore.  Perhaps cfront uses one.  */
-      if ((*mangled)[2] == '_')
-	{
-	  (*mangled)++;
-	}
-      (*mangled) += 2;
-      break;
-
-    case '0':
-    default:
-      success = 0;
-    }
-
-  if (!success)
-    return success;
-
-  /* Pick off the names and collect them in the temp buffer in the order
-     in which they are found, separated by '::'.  */
-
-  while (qualifiers-- > 0)
-    {
-      if (*mangled[0] == '_') 
-	*mangled = *mangled + 1;
-      if (*mangled[0] == 't')
-	{
-	  success = demangle_template(work, mangled, &temp, 0, 1);
-	  if (!success) break;
-	}
-      else if (*mangled[0] == 'X')
-	{
-	  success = do_type (work, mangled, &temp);
-	  if (!success) break;
-	}
-      else
-        {	
-	  namelength = consume_count (mangled);
-      	  if (strlen (*mangled) < namelength)
-	    {
-	      /* Simple sanity check failed */
-	      success = 0;
-	      break;
-	    }
-      	  string_appendn (&temp, *mangled, namelength);
-      	  *mangled += namelength;
-	}
-      if (qualifiers > 0)
-        {
-          string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
-        }
-    }
-
-  /* If we are using the result as a function name, we need to append
-     the appropriate '::' separated constructor or destructor name.
-     We do this here because this is the most convenient place, where
-     we already have a pointer to the name and the length of the name.  */
-
-  if (isfuncname && (work->constructor & 1 || work->destructor & 1))
-    {
-      string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
-      if (work -> destructor & 1)
-	{
-	  string_append (&temp, "~");
-	}
-      string_appendn (&temp, (*mangled) - namelength, namelength);
-    }
-
-  /* Now either prepend the temp buffer to the result, or append it, 
-     depending upon the state of the append flag.  */
-
-  if (append)
-    {
-      string_appends (result, &temp);
-    }
-  else
-    {
-      if (!STRING_EMPTY (result))
-	{
-	  string_append (&temp, (work -> options & DMGL_JAVA) ? "." : "::");
-	}
-      string_prepends (result, &temp);
-    }
-
-  string_delete (&temp);
-  return (success);
-}
-
-/*
-
-LOCAL FUNCTION
-
-	get_count -- convert an ascii count to integer, consuming tokens
-
-SYNOPSIS
-
-	static int
-	get_count (const char **type, int *count)
-
-DESCRIPTION
-
-	Return 0 if no conversion is performed, 1 if a string is converted.
-*/
-
-static int
-get_count (type, count)
-     const char **type;
-     int *count;
-{
-  const char *p;
-  int n;
-
-  if (!isdigit (**type))
-    {
-      return (0);
-    }
-  else
-    {
-      *count = **type - '0';
-      (*type)++;
-      if (isdigit (**type))
-	{
-	  p = *type;
-	  n = *count;
-	  do 
-	    {
-	      n *= 10;
-	      n += *p - '0';
-	      p++;
-	    } 
-	  while (isdigit (*p));
-	  if (*p == '_')
-	    {
-	      *type = p + 1;
-	      *count = n;
-	    }
-	}
-    }
-  return (1);
-}
-
-/* result will be initialised here; it will be freed on failure */
-
-static int
-do_type (work, mangled, result)
-     struct work_stuff *work;
-     const char **mangled;
-     string *result;
-{
-  int n;
-  int done;
-  int success;
-  string decl;
-  const char *remembered_type;
-  int constp;
-  int volatilep;
-
-  string_init (&decl);
-  string_init (result);
-
-  done = 0;
-  success = 1;
-  while (success && !done)
-    {
-      int member;
-      switch (**mangled)
-	{
-
-	  /* A pointer type */
-	case 'P':
-	case 'p':
-	  (*mangled)++;
-	  if (! (work -> options & DMGL_JAVA))
-	    string_prepend (&decl, "*");
-	  break;
-
-	  /* A reference type */
-	case 'R':
-	  (*mangled)++;
-	  string_prepend (&decl, "&");
-	  break;
-
-	  /* An array */
-	case 'A':
-	  {
-	    const char *p = ++(*mangled);
-
-	    string_prepend (&decl, "(");
-	    string_append (&decl, ")[");
-	    /* Copy anything up until the next underscore (the size of the
-	       array).  */
-	    while (**mangled && **mangled != '_')
-	      ++(*mangled);
-	    if (**mangled == '_')
-	      {
-		string_appendn (&decl, p, *mangled - p);
-		string_append (&decl, "]");             
-		*mangled += 1;
-	      }
-	    else
-	      success = 0;
-	    break;
-	  }
-
-	/* A back reference to a previously seen type */
-	case 'T':
-	  (*mangled)++;
-	  if (!get_count (mangled, &n) || n >= work -> ntypes)
-	    {
-	      success = 0;
-	    }
-	  else
-	    {
-	      remembered_type = work -> typevec[n];
-	      mangled = &remembered_type;
-	    }
-	  break;
-
-	  /* A function */
-	case 'F':
-	  (*mangled)++;
-	  if (!STRING_EMPTY (&decl) && decl.b[0] == '*')
-	    {
-	      string_prepend (&decl, "(");
-	      string_append (&decl, ")");
-	    }
-	  /* After picking off the function args, we expect to either find the
-	     function return type (preceded by an '_') or the end of the
-	     string.  */
-	  if (!demangle_args (work, mangled, &decl)
-	      || (**mangled != '_' && **mangled != '\0'))
-	    {
-	      success = 0;
-	    }
-	  if (success && (**mangled == '_'))
-	    {
-	      (*mangled)++;
-	    }
-	  break;
-
-	case 'M':
-	case 'O':
-	  {
-	    constp = 0;
-	    volatilep = 0;
-
-	    member = **mangled == 'M';
-	    (*mangled)++;
-	    if (!isdigit (**mangled) && **mangled != 't')
-	      {
-		success = 0;
-		break;
-	      }
-
-	    string_append (&decl, ")");
-	    string_prepend (&decl, (work -> options & DMGL_JAVA) ? "." : "::");
-	    if (isdigit (**mangled)) 
-	      {
-		n = consume_count (mangled);
-		if (strlen (*mangled) < n)
-		  {
-		    success = 0;
-		    break;
-		  }
-		string_prependn (&decl, *mangled, n);
-		*mangled += n;
-	      }
-	    else
-	      {
-		string temp;
-		string_init (&temp);
-		success = demangle_template (work, mangled, &temp, NULL, 1);
-		if (success)
-		  {
-		    string_prependn (&decl, temp.b, temp.p - temp.b);
-		    string_clear (&temp);
-		  }
-		else
-		  break;
-	      }
-	    string_prepend (&decl, "(");
-	    if (member)
-	      {
-		if (**mangled == 'C')
-		  {
-		    (*mangled)++;
-		    constp = 1;
-		  }
-		if (**mangled == 'V')
-		  {
-		    (*mangled)++;
-		    volatilep = 1;
-		  }
-		if (*(*mangled)++ != 'F')
-		  {
-		    success = 0;
-		    break;
-		  }
-	      }
-	    if ((member && !demangle_args (work, mangled, &decl))
-		|| **mangled != '_')
-	      {
-		success = 0;
-		break;
-	      }
-	    (*mangled)++;
-	    if (! PRINT_ANSI_QUALIFIERS)
-	      {
-		break;
-	      }
-	    if (constp)
-	      {
-		APPEND_BLANK (&decl);
-		string_append (&decl, "const");
-	      }
-	    if (volatilep)
-	      {
-		APPEND_BLANK (&decl);
-		string_append (&decl, "volatile");
-	      }
-	    break;
-	  }
-        case 'G':
-	  (*mangled)++;
-	  break;
-
-	case 'C':
-	  (*mangled)++;
-	  /*
-	    if ((*mangled)[1] == 'P')
-	    {
-	    */
-	  if (PRINT_ANSI_QUALIFIERS)
-	    {
-	      if (!STRING_EMPTY (&decl))
-		{
-		  string_prepend (&decl, " ");
-		}
-	      string_prepend (&decl, "const");
-	    }
-	  break;
-	  /*
-	    }
-	    */
-
-	  /* fall through */
-	default:
-	  done = 1;
-	  break;
-	}
-    }
-
-  switch (**mangled)
-    {
-      /* A qualified name, such as "Outer::Inner".  */
-    case 'Q':
-      success = demangle_qualified (work, mangled, result, 0, 1);
-      break;
-
-    case 'X':
-    case 'Y':
-      /* A template parm.  We substitute the corresponding argument. */
-      {
-	int idx;
-	int lvl;
-
-	(*mangled)++;
-	idx = consume_count_with_underscores (mangled);
-
-	if (idx == -1 
-	    || (work->tmpl_argvec && idx >= work->ntmpl_args)
-	    || consume_count_with_underscores (mangled) == -1)
-	  {
-	    success = 0;
-	    break;
-	  }
-
-	if (work->tmpl_argvec)
-	  string_append (result, work->tmpl_argvec[idx]);
-	else
-	  {
-	    char buf[10];
-	    sprintf(buf, "T%d", idx);
-	    string_append (result, buf);
-	  }
-
-	success = 1;
-      }
-    break;
-
-    default:
-      success = demangle_fund_type (work, mangled, result);
-      break;
-    }
-
-  if (success)
-    {
-      if (!STRING_EMPTY (&decl))
-	{
-	  string_append (result, " ");
-	  string_appends (result, &decl);
-	}
-    }
-  else
-    {
-      string_delete (result);
-    }
-  string_delete (&decl);
-  return (success);
-}
-
-/* Given a pointer to a type string that represents a fundamental type
-   argument (int, long, unsigned int, etc) in TYPE, a pointer to the
-   string in which the demangled output is being built in RESULT, and
-   the WORK structure, decode the types and add them to the result.
-
-   For example:
-
-   	"Ci"	=>	"const int"
-	"Sl"	=>	"signed long"
-	"CUs"	=>	"const unsigned short"
-
-   */
-
-static int
-demangle_fund_type (work, mangled, result)
-     struct work_stuff *work;
-     const char **mangled;
-     string *result;
-{
-  int done = 0;
-  int success = 1;
-
-  /* First pick off any type qualifiers.  There can be more than one.  */
-
-  while (!done)
-    {
-      switch (**mangled)
-	{
-	case 'C':
-	  (*mangled)++;
-	  if (PRINT_ANSI_QUALIFIERS)
-	    {
-	      APPEND_BLANK (result);
-	      string_append (result, "const");
-	    }
-	  break;
-	case 'U':
-	  (*mangled)++;
-	  APPEND_BLANK (result);
-	  string_append (result, "unsigned");
-	  break;
-	case 'S': /* signed char only */
-	  (*mangled)++;
-	  APPEND_BLANK (result);
-	  string_append (result, "signed");
-	  break;
-	case 'V':
-	  (*mangled)++;
-	  if (PRINT_ANSI_QUALIFIERS)
-	    {
-	      APPEND_BLANK (result);
-	      string_append (result, "volatile");
-	    }
-	  break;
-	case 'J':
-	  (*mangled)++;
-	  APPEND_BLANK (result);
-	  string_append (result, "__complex");
-	  break;
-	default:
-	  done = 1;
-	  break;
-	}
-    }
-
-  /* Now pick off the fundamental type.  There can be only one.  */
-
-  switch (**mangled)
-    {
-    case '\0':
-    case '_':
-      break;
-    case 'v':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "void");
-      break;
-    case 'x':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "long long");
-      break;
-    case 'l':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "long");
-      break;
-    case 'i':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "int");
-      break;
-    case 's':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "short");
-      break;
-    case 'b':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "bool");
-      break;
-    case 'c':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "char");
-      break;
-    case 'w':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "wchar_t");
-      break;
-    case 'r':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "long double");
-      break;
-    case 'd':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "double");
-      break;
-    case 'f':
-      (*mangled)++;
-      APPEND_BLANK (result);
-      string_append (result, "float");
-      break;
-    case 'G':
-      (*mangled)++;
-      if (!isdigit (**mangled))
-	{
-	  success = 0;
-	  break;
-	}
-      /* fall through */
-      /* An explicit type, such as "6mytype" or "7integer" */
-    case '0':
-    case '1':
-    case '2':
-    case '3':
-    case '4':
-    case '5':
-    case '6':
-    case '7':
-    case '8':
-    case '9':
-      APPEND_BLANK (result);
-      if (!demangle_class_name (work, mangled, result)) {
-	--result->p;
-	success = 0;
-      }
-      break;
-    case 't':
-      success = demangle_template(work,mangled, result, 0, 1);
-      break;
-    default:
-      success = 0;
-      break;
-    }
-
-  return (success);
-}
-
-/* `result' will be initialized in do_type; it will be freed on failure */
-
-static int
-do_arg (work, mangled, result)
-     struct work_stuff *work;
-     const char **mangled;
-     string *result;
-{
-  const char *start = *mangled;
-
-  if (!do_type (work, mangled, result))
-    {
-      return (0);
-    }
-  else
-    {
-      remember_type (work, start, *mangled - start);
-      return (1);
-    }
-}
-
-static void
-remember_type (work, start, len)
-     struct work_stuff *work;
-     const char *start;
-     int len;
-{
-  char *tem;
-
-  if (work -> ntypes >= work -> typevec_size)
-    {
-      if (work -> typevec_size == 0)
-	{
-	  work -> typevec_size = 3;
-	  work -> typevec
-	    = (char **) xmalloc (sizeof (char *) * work -> typevec_size);
-	}
-      else
-	{
-	  work -> typevec_size *= 2;
-	  work -> typevec
-	    = (char **) xrealloc ((char *)work -> typevec,
-				  sizeof (char *) * work -> typevec_size);
-	}
-    }
-  tem = xmalloc (len + 1);
-  memcpy (tem, start, len);
-  tem[len] = '\0';
-  work -> typevec[work -> ntypes++] = tem;
-}
-
-/* Forget the remembered types, but not the type vector itself.  */
-
-static void
-forget_types (work)
-     struct work_stuff *work;
-{
-  int i;
-
-  while (work -> ntypes > 0)
-    {
-      i = --(work -> ntypes);
-      if (work -> typevec[i] != NULL)
-	{
-	  free (work -> typevec[i]);
-	  work -> typevec[i] = NULL;
-	}
-    }
-}
-
-/* Process the argument list part of the signature, after any class spec
-   has been consumed, as well as the first 'F' character (if any).  For
-   example:
-
-   "__als__3fooRT0"		=>	process "RT0"
-   "complexfunc5__FPFPc_PFl_i"	=>	process "PFPc_PFl_i"
-
-   DECLP must be already initialised, usually non-empty.  It won't be freed
-   on failure.
-
-   Note that g++ differs significantly from ARM and lucid style mangling
-   with regards to references to previously seen types.  For example, given
-   the source fragment:
-
-     class foo {
-       public:
-       foo::foo (int, foo &ia, int, foo &ib, int, foo &ic);
-     };
-
-     foo::foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; }
-     void foo (int, foo &ia, int, foo &ib, int, foo &ic) { ia = ib = ic; }
-
-   g++ produces the names:
-
-     __3fooiRT0iT2iT2
-     foo__FiR3fooiT1iT1
-
-   while lcc (and presumably other ARM style compilers as well) produces:
-
-     foo__FiR3fooT1T2T1T2
-     __ct__3fooFiR3fooT1T2T1T2
-
-   Note that g++ bases it's type numbers starting at zero and counts all
-   previously seen types, while lucid/ARM bases it's type numbers starting
-   at one and only considers types after it has seen the 'F' character
-   indicating the start of the function args.  For lucid/ARM style, we
-   account for this difference by discarding any previously seen types when
-   we see the 'F' character, and subtracting one from the type number
-   reference.
-
- */
-
-static int
-demangle_args (work, mangled, declp)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-{
-  string arg;
-  int need_comma = 0;
-  int r;
-  int t;
-  const char *tem;
-  char temptype;
-
-  if (PRINT_ARG_TYPES)
-    {
-      string_append (declp, "(");
-      if (**mangled == '\0')
-	{
-	  string_append (declp, "void");
-	}
-    }
-
-  while (**mangled != '_' && **mangled != '\0' && **mangled != 'e')
-    {
-      if ((**mangled == 'N') || (**mangled == 'T'))
-	{
-	  temptype = *(*mangled)++;
-	  
-	  if (temptype == 'N')
-	    {
-	      if (!get_count (mangled, &r))
-		{
-		  return (0);
-		}
-	    }
-	  else
-	    {
-	      r = 1;
-	    }
-          if (ARM_DEMANGLING && work -> ntypes >= 10)
-            {
-              /* If we have 10 or more types we might have more than a 1 digit
-                 index so we'll have to consume the whole count here. This
-                 will lose if the next thing is a type name preceded by a
-                 count but it's impossible to demangle that case properly
-                 anyway. Eg if we already have 12 types is T12Pc "(..., type1,
-                 Pc, ...)"  or "(..., type12, char *, ...)" */
-              if ((t = consume_count(mangled)) == 0)
-                {
-                  return (0);
-                }
-            }
-          else
-	    {
-	      if (!get_count (mangled, &t))
-	    	{
-	          return (0);
-	    	}
-	    }
-	  if (LUCID_DEMANGLING || ARM_DEMANGLING)
-	    {
-	      t--;
-	    }
-	  /* Validate the type index.  Protect against illegal indices from
-	     malformed type strings.  */
-	  if ((t < 0) || (t >= work -> ntypes))
-	    {
-	      return (0);
-	    }
-	  while (--r >= 0)
-	    {
-	      tem = work -> typevec[t];
-	      if (need_comma && PRINT_ARG_TYPES)
-		{
-		  string_append (declp, ", ");
-		}
-	      if (!do_arg (work, &tem, &arg))
-		{
-		  return (0);
-		}
-	      if (PRINT_ARG_TYPES)
-		{
-		  string_appends (declp, &arg);
-		}
-	      string_delete (&arg);
-	      need_comma = 1;
-	    }
-	}
-      else
-	{
-	  if (need_comma & PRINT_ARG_TYPES)
-	    {
-	      string_append (declp, ", ");
-	    }
-	  if (!do_arg (work, mangled, &arg))
-	    {
-	      return (0);
-	    }
-	  if (PRINT_ARG_TYPES)
-	    {
-	      string_appends (declp, &arg);
-	    }
-	  string_delete (&arg);
-	  need_comma = 1;
-	}
-    }
-
-  if (**mangled == 'e')
-    {
-      (*mangled)++;
-      if (PRINT_ARG_TYPES)
-	{
-	  if (need_comma)
-	    {
-	      string_append (declp, ",");
-	    }
-	  string_append (declp, "...");
-	}
-    }
-
-  if (PRINT_ARG_TYPES)
-    {
-      string_append (declp, ")");
-    }
-  return (1);
-}
-
-static void
-demangle_function_name (work, mangled, declp, scan)
-     struct work_stuff *work;
-     const char **mangled;
-     string *declp;
-     const char *scan;
-{
-  int i;
-  int len;
-  string type;
-  const char *tem;
-
-  string_appendn (declp, (*mangled), scan - (*mangled));
-  string_need (declp, 1);
-  *(declp -> p) = '\0';
-
-  /* Consume the function name, including the "__" separating the name
-     from the signature.  We are guaranteed that SCAN points to the
-     separator.  */
-
-  (*mangled) = scan + 2;
-
-  if (LUCID_DEMANGLING || ARM_DEMANGLING)
-    {
-
-      /* See if we have an ARM style constructor or destructor operator.
-	 If so, then just record it, clear the decl, and return.
-	 We can't build the actual constructor/destructor decl until later,
-	 when we recover the class name from the signature.  */
-
-      if (strcmp (declp -> b, "__ct") == 0)
-	{
-	  work -> constructor += 1;
-	  string_clear (declp);
-	  return;
-	}
-      else if (strcmp (declp -> b, "__dt") == 0)
-	{
-	  work -> destructor += 1;
-	  string_clear (declp);
-	  return;
-	}
-    }
-
-  if (declp->p - declp->b >= 3 
-      && declp->b[0] == 'o'
-      && declp->b[1] == 'p'
-      && strchr (cplus_markers, declp->b[2]) != NULL)
-    {
-      /* see if it's an assignment expression */
-      if (declp->p - declp->b >= 10 /* op$assign_ */
-	  && memcmp (declp->b + 3, "assign_", 7) == 0)
-	{
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      len = declp->p - declp->b - 10;
-	      if (strlen (optable[i].in) == len
-		  && memcmp (optable[i].in, declp->b + 10, len) == 0)
-		{
-		  string_clear (declp);
-		  string_append (declp, "operator");
-		  string_append (declp, optable[i].out);
-		  string_append (declp, "=");
-		  break;
-		}
-	    }
-	}
-      else
-	{
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      int len = declp->p - declp->b - 3;
-	      if (strlen (optable[i].in) == len 
-		  && memcmp (optable[i].in, declp->b + 3, len) == 0)
-		{
-		  string_clear (declp);
-		  string_append (declp, "operator");
-		  string_append (declp, optable[i].out);
-		  break;
-		}
-	    }
-	}
-    }
-  else if (declp->p - declp->b >= 5 && memcmp (declp->b, "type", 4) == 0
-	   && strchr (cplus_markers, declp->b[4]) != NULL)
-    {
-      /* type conversion operator */
-      tem = declp->b + 5;
-      if (do_type (work, &tem, &type))
-	{
-	  string_clear (declp);
-	  string_append (declp, "operator ");
-	  string_appends (declp, &type);
-	  string_delete (&type);
-	}
-    }
-  else if (declp->b[0] == '_' && declp->b[1] == '_'
-	   && declp->b[2] == 'o' && declp->b[3] == 'p')
-    {
-      /* ANSI.  */
-      /* type conversion operator.  */
-      tem = declp->b + 4;
-      if (do_type (work, &tem, &type))
-	{
-	  string_clear (declp);
-	  string_append (declp, "operator ");
-	  string_appends (declp, &type);
-	  string_delete (&type);
-	}
-    }
-  else if (declp->b[0] == '_' && declp->b[1] == '_'
-	   && declp->b[2] >= 'a' && declp->b[2] <= 'z'
-	   && declp->b[3] >= 'a' && declp->b[3] <= 'z')
-    {
-      if (declp->b[4] == '\0')
-	{
-	  /* Operator.  */
-	  for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-	    {
-	      if (strlen (optable[i].in) == 2
-		  && memcmp (optable[i].in, declp->b + 2, 2) == 0)
-		{
-		  string_clear (declp);
-		  string_append (declp, "operator");
-		  string_append (declp, optable[i].out);
-		  break;
-		}
-	    }
-	}
-      else
-	{
-	  if (declp->b[2] == 'a' && declp->b[5] == '\0')
-	    {
-	      /* Assignment.  */
-	      for (i = 0; i < sizeof (optable) / sizeof (optable[0]); i++)
-		{
-		  if (strlen (optable[i].in) == 3
-		      && memcmp (optable[i].in, declp->b + 2, 3) == 0)
-		    {
-		      string_clear (declp);
-		      string_append (declp, "operator");
-		      string_append (declp, optable[i].out);
-		      break;
-		    }		      
-		}
-	    }
-	}
-    }
-}
-
-/* a mini string-handling package */
-
-static void
-string_need (s, n)
-     string *s;
-     int n;
-{
-  int tem;
-
-  if (s->b == NULL)
-    {
-      if (n < 32)
-	{
-	  n = 32;
-	}
-      s->p = s->b = xmalloc (n);
-      s->e = s->b + n;
-    }
-  else if (s->e - s->p < n)
-    {
-      tem = s->p - s->b;
-      n += tem;
-      n *= 2;
-      s->b = xrealloc (s->b, n);
-      s->p = s->b + tem;
-      s->e = s->b + n;
-    }
-}
-
-static void
-string_delete (s)
-     string *s;
-{
-  if (s->b != NULL)
-    {
-      free (s->b);
-      s->b = s->e = s->p = NULL;
-    }
-}
-
-static void
-string_init (s)
-     string *s;
-{
-  s->b = s->p = s->e = NULL;
-}
-
-static void 
-string_clear (s)
-     string *s;
-{
-  s->p = s->b;
-}
-
-#if 0
-
-static int
-string_empty (s)
-     string *s;
-{
-  return (s->b == s->p);
-}
-
-#endif
-
-static void
-string_append (p, s)
-     string *p;
-     const char *s;
-{
-  int n;
-  if (s == NULL || *s == '\0')
-    return;
-  n = strlen (s);
-  string_need (p, n);
-  memcpy (p->p, s, n);
-  p->p += n;
-}
-
-static void
-string_appends (p, s)
-     string *p, *s;
-{
-  int n;
-
-  if (s->b != s->p)
-    {
-      n = s->p - s->b;
-      string_need (p, n);
-      memcpy (p->p, s->b, n);
-      p->p += n;
-    }
-}
-
-static void
-string_appendn (p, s, n)
-     string *p;
-     const char *s;
-     int n;
-{
-  if (n != 0)
-    {
-      string_need (p, n);
-      memcpy (p->p, s, n);
-      p->p += n;
-    }
-}
-
-static void
-string_prepend (p, s)
-     string *p;
-     const char *s;
-{
-  if (s != NULL && *s != '\0')
-    {
-      string_prependn (p, s, strlen (s));
-    }
-}
-
-static void
-string_prepends (p, s)
-     string *p, *s;
-{
-  if (s->b != s->p)
-    {
-      string_prependn (p, s->b, s->p - s->b);
-    }
-}
-
-static void
-string_prependn (p, s, n)
-     string *p;
-     const char *s;
-     int n;
-{
-  char *q;
-
-  if (n != 0)
-    {
-      string_need (p, n);
-      for (q = p->p - 1; q >= p->b; q--)
-	{
-	  q[n] = q[0];
-	}
-      memcpy (p->b, s, n);
-      p->p += n;
-    }
-}
-
-/* To generate a standalone demangler program for testing purposes,
-   just compile and link this file with -DMAIN and libiberty.a.  When
-   run, it demangles each command line arg, or each stdin string, and
-   prints the result on stdout.  */
-
-#ifdef MAIN
-
-#include "getopt.h"
-
-static char *program_name;
-static char *program_version = VERSION;
-static int flags = DMGL_PARAMS | DMGL_ANSI;
-
-static void demangle_it PARAMS ((char *));
-static void usage PARAMS ((FILE *, int));
-static void fatal PARAMS ((char *));
-
-static void
-demangle_it (mangled_name)
-     char *mangled_name;
-{
-  char *result;
-
-  result = cplus_demangle (mangled_name, flags);
-  if (result == NULL)
-    {
-      printf ("%s\n", mangled_name);
-    }
-  else
-    {
-      printf ("%s\n", result);
-      free (result);
-    }
-}
-
-static void
-usage (stream, status)
-     FILE *stream;
-     int status;
-{    
-  fprintf (stream, "\
-Usage: %s [-_] [-n] [-s {gnu,lucid,arm}] [--strip-underscores]\n\
-      [--no-strip-underscores] [--format={gnu,lucid,arm}]\n\
-      [--help] [--version] [arg...]\n",
-	   program_name);
-  exit (status);
-}
-
-#define MBUF_SIZE 512
-char mbuffer[MBUF_SIZE];
-
-/* Defined in the automatically-generated underscore.c.  */
-extern int prepends_underscore;
-
-int strip_underscore = 0;
-
-static struct option long_options[] = {
-  {"strip-underscores", no_argument, 0, '_'},
-  {"format", required_argument, 0, 's'},
-  {"help", no_argument, 0, 'h'},
-  {"java", no_argument, 0, 'j'},
-  {"no-strip-underscores", no_argument, 0, 'n'},
-  {"version", no_argument, 0, 'v'},
-  {0, no_argument, 0, 0}
-};
-
-/* More 'friendly' abort that prints the line and file.
-   config.h can #define abort fancy_abort if you like that sort of thing.  */
-
-void
-fancy_abort ()
-{
-  fatal ("Internal gcc abort.");
-}
-
-int
-main (argc, argv)
-     int argc;
-     char **argv;
-{
-  char *result;
-  int c;
-
-  program_name = argv[0];
-
-  strip_underscore = prepends_underscore;
-
-  while ((c = getopt_long (argc, argv, "_ns:j", long_options, (int *) 0)) != EOF)
-    {
-      switch (c)
-	{
-	case '?':
-	  usage (stderr, 1);
-	  break;
-	case 'h':
-	  usage (stdout, 0);
-	case 'n':
-	  strip_underscore = 0;
-	  break;
-	case 'v':
-	  printf ("GNU %s version %s\n", program_name, program_version);
-	  exit (0);
-	case '_':
-	  strip_underscore = 1;
-	  break;
-	case 'j':
-	  flags |= DMGL_JAVA;
-	  break;
-	case 's':
-	  if (strcmp (optarg, "gnu") == 0)
-	    {
-	      current_demangling_style = gnu_demangling;
-	    }
-	  else if (strcmp (optarg, "lucid") == 0)
-	    {
-	      current_demangling_style = lucid_demangling;
-	    }
-	  else if (strcmp (optarg, "arm") == 0)
-	    {
-	      current_demangling_style = arm_demangling;
-	    }
-	  else
-	    {
-	      fprintf (stderr, "%s: unknown demangling style `%s'\n",
-		       program_name, optarg);
-	      exit (1);
-	    }
-	  break;
-	}
-    }
-
-  if (optind < argc)
-    {
-      for ( ; optind < argc; optind++)
-	{
-	  demangle_it (argv[optind]);
-	}
-    }
-  else
-    {
-      for (;;)
-	{
-	  int i = 0;
-	  c = getchar ();
-	  /* Try to read a label.  */
-	  while (c != EOF && (isalnum(c) || c == '_' || c == '$' || c == '.'))
-	    {
-	      if (i >= MBUF_SIZE-1)
-		break;
-	      mbuffer[i++] = c;
-	      c = getchar ();
-	    }
-	  if (i > 0)
-	    {
-	      int skip_first = 0;
-
-	      if (mbuffer[0] == '.')
-		++skip_first;
-	      if (strip_underscore && mbuffer[skip_first] == '_')
-		++skip_first;
-
-	      if (skip_first > i)
-		skip_first = i;
-
-	      mbuffer[i] = 0;
-	      
-	      result = cplus_demangle (mbuffer + skip_first, flags);
-	      if (result)
-		{
-		  if (mbuffer[0] == '.')
-		    putc ('.', stdout);
-		  fputs (result, stdout);
-		  free (result);
-		}
-	      else
-		fputs (mbuffer, stdout);
-
-	      fflush (stdout);
-	    }
-	  if (c == EOF)
-	    break;
-	  putchar (c);
-	}
-    }
-
-  exit (0);
-}
-
-static void
-fatal (str)
-     char *str;
-{
-  fprintf (stderr, "%s: %s\n", program_name, str);
-  exit (1);
-}
-
-char * malloc ();
-char * realloc ();
-
-char *
-xmalloc (size)
-     unsigned size;
-{
-  register char *value = (char *) malloc (size);
-  if (value == 0)
-    fatal ("virtual memory exhausted");
-  return value;
-}
-
-char *
-xrealloc (ptr, size)
-     char *ptr;
-     unsigned size;
-{
-  register char *value = (char *) realloc (ptr, size);
-  if (value == 0)
-    fatal ("virtual memory exhausted");
-  return value;
-}
-#endif	/* main */
Index: trunk/src/emx/src/emxexp/emxexp.smak
===================================================================
--- trunk/src/emx/src/emxexp/emxexp.smak	(revision 119)
+++ trunk/src/emx/src/emxexp/emxexp.smak	(revision 123)
@@ -1,8 +1,11 @@
 .MODULE := emxexp
 .MDESC  := Generate a list of DLL export entries
+.MDEP	:= omflib@omf
 .INSDIR := bin/
 
 .TARGET := emxexp.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emxexp/*.c)
-.TLDF   := -liberty -lomflib
+.TDEP   := @O@omflib$A
+.TLDF	:= -liberty
 include mkexe.smak
Index: trunk/src/emx/src/emximp/emximp.smak
===================================================================
--- trunk/src/emx/src/emximp/emximp.smak	(revision 119)
+++ trunk/src/emx/src/emximp/emximp.smak	(revision 123)
@@ -1,8 +1,10 @@
 .MODULE := emximp
 .MDESC  := Import library management tool
+.MDEP	:= omflib@omf moddef@omf
 .INSDIR := bin/
 
 .TARGET := emximp.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emximp/*.c)
-.TLDF   := -lomflib -lmoddef
+.TDEP	:= @O@omflib$A @O@moddef$A
 include mkexe.smak
Index: trunk/src/emx/src/emxload/emximp.smak
===================================================================
--- trunk/src/emx/src/emxload/emximp.smak	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-.MODULE := emxload
-.MDESC  := Fast loader daemon
-.INSDIR := bin/
-
-.TARGET := emxload.exe
-.TKIND  := mt
-.TSRC   := $(wildcard src/emxload/*.c)
-.TLDF   := 
-include mkexe.smak
Index: trunk/src/emx/src/emxload/emxload.smak
===================================================================
--- trunk/src/emx/src/emxload/emxload.smak	(revision 123)
+++ trunk/src/emx/src/emxload/emxload.smak	(revision 123)
@@ -0,0 +1,9 @@
+.MODULE := emxload
+.MDESC  := Fast loader daemon
+.INSDIR := bin/
+
+.TARGET := emxload.exe
+.TKIND	:= $(TOOLFMT)
+.TSRC   := $(wildcard src/emxload/*.c)
+.TLDF   := 
+include mkexe.smak
Index: trunk/src/emx/src/emxomf/emxomf.smak
===================================================================
--- trunk/src/emx/src/emxomf/emxomf.smak	(revision 119)
+++ trunk/src/emx/src/emxomf/emxomf.smak	(revision 123)
@@ -2,25 +2,31 @@
 .MDESC	:= a.out to OMF object file conversion utility
 .INSDIR	:= bin/
+.MDEP	:= omflib@omf moddef@omf
 
 .TARGET	:= emxomf.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC	:= $(addprefix src/emxomf/,emxomf.c stabshll.c grow.c)
-.TLDF	:= -lomflib
+.TDEP	:= @O@omflib$A
 include mkexe.smak
 
 .TARGET	:= emxomfar.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC	:= src/emxomf/emxomfar.c
-.TLDF	:= -lomflib
+.TDEP	:= @O@omflib$A
 include mkexe.smak
 
 .TARGET := emxomfld.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC	:= src/emxomf/emxomfld.c
-.TLDF	:= -lmoddef
+.TDEP	:= @O@moddef$A
 include mkexe.smak
 
 .TARGET := emxaout.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC	:= $(addprefix src/emxomf/,emxaout.c grow.c)
 include mkexe.smak
 
 .TARGET := listomf.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC	:= src/emxomf/listomf.c
 include mkexe.smak
Index: trunk/src/emx/src/emxstack/emxstack.smak
===================================================================
--- trunk/src/emx/src/emxstack/emxstack.smak	(revision 119)
+++ trunk/src/emx/src/emxstack/emxstack.smak	(revision 123)
@@ -4,4 +4,5 @@
 
 .TARGET := emxstack.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emxstack/*.c)
 include mkexe.smak
Index: trunk/src/emx/src/emxtsf/emxtsf.smak
===================================================================
--- trunk/src/emx/src/emxtsf/emxtsf.smak	(revision 119)
+++ trunk/src/emx/src/emxtsf/emxtsf.smak	(revision 123)
@@ -1,7 +1,9 @@
 .MODULE := emxtsf
 .MDESC  := Simplify construction of .TSF files
+.MDEP	:= moddef@omf
 .INSDIR := bin/
 
 .TARGET := emxtsf.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/emxtsf/*.c)
 .TLDF	:= -lmoddef
Index: trunk/src/emx/src/ld/ld.c
===================================================================
--- trunk/src/emx/src/ld/ld.c	(revision 119)
+++ trunk/src/emx/src/ld/ld.c	(revision 123)
@@ -29,5 +29,7 @@
 #include <process.h>        /* for running emxbind */
 #include <errno.h>
+#include <utime.h>
 #endif /* __EMX__ */
+#include <ctype.h>
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -81,4 +83,5 @@
 #define FIXSETBUG
 
+extern int DosCopy (char *, char *, int);
 #endif /* EMX */
 
@@ -1109,5 +1112,4 @@
 
 int parse ();
-void do_warnings ();
 void initialize_text_start ();
 void initialize_data_start ();
@@ -1132,4 +1134,5 @@
 char *get_file_name ();
 symbol *getsym (), *getsym_soft ();
+void do_warnings ();
 #ifdef EMX /* emxbind */
 void check_exe (void);
@@ -1144,4 +1147,5 @@
 #ifdef __EMX__
   _response (&argc, &argv);
+  _wildcard (&argc, &argv);
 #endif /* __EMX__ */
   page_size = getpagesize ();
@@ -1822,4 +1826,5 @@
 
   perror_file (entry);
+  /* NOTREACHED */
   return -1;
 }
@@ -2877,5 +2882,6 @@
 /* Handle a subentry for a file with no __.SYMDEF. */
 
-void process_subentry (desc, subentry, entry, prev_addr)
+void
+process_subentry (desc, subentry, entry, prev_addr)
      int desc;
      register struct file_entry *subentry;
@@ -3051,5 +3057,5 @@
 {
   register int i;
-  int setv_fill_count = 0;
+  int setv_fill_count;
 
   if (trace_files)
@@ -3433,5 +3439,5 @@
   fprintf (outfile, "\nFiles:\n\n");
 
-  each_file (describe_file_sections, (int)outfile);
+  each_file (describe_file_sections, outfile);
 
   fprintf (outfile, "\nGlobal symbols:\n\n");
@@ -3451,5 +3457,5 @@
     }
 
-  each_file (list_file_locals, (int)outfile);
+  each_file (list_file_locals, outfile);
 }
 
@@ -3868,6 +3874,6 @@
   struct line_debug_entry *text_scan, *data_scan;
   int i;
-  char *errfmt, *file_name = NULL;
-  int line_number = -1;
+  char *errfmt, *file_name;
+  int line_number;
   int dont_allow_symbol_name;
 
@@ -4016,5 +4022,5 @@
     return;
 
-  each_file (do_file_warnings, (int)outfile);
+  each_file (do_file_warnings, outfile);
 
   if (list_unresolved_refs || list_multiple_defs)
@@ -4041,5 +4047,5 @@
 initialize_a_out_text_start ()
 {
-  int magic = 0;
+  int magic;
 
   switch (output_style)
@@ -5043,8 +5049,8 @@
         {
           char execname[512];
-          _execname((char *)&execname, sizeof(execname));
-          strcpy(_getname((char *)&execname), "ldstub.bin");
+          _execname(execname, sizeof (execname));
+          strcpy(_getname(execname), "ldstub.bin");
           /* Copy stub into file */
-          if (DosCopy((char *)&execname, touch_filename, 4))
+          if (DosCopy(execname, touch_filename, 4))
           {
             errno = EACCES;
@@ -5719,5 +5725,5 @@
 
 #ifdef EMX
-          if (symtype = symptr->defined != (N_IMP1 | N_EXT))
+          if ((symtype = symptr->defined) != (N_IMP1 | N_EXT))
 #endif
 	    symtype = symptr->defined & ~N_EXT;
@@ -5883,5 +5889,5 @@
   /* Write the local symbols defined by the various files.  */
 
-  each_file (write_file_syms, (int)&syms_written);
+  each_file (write_file_syms, &syms_written);
   file_close ();
 
Index: trunk/src/emx/src/ld/ld.smak
===================================================================
--- trunk/src/emx/src/ld/ld.smak	(revision 119)
+++ trunk/src/emx/src/ld/ld.smak	(revision 123)
@@ -6,5 +6,7 @@
 
 .TARGET := ld.exe
+.TKIND	:= $(TOOLFMT)
 .TSRC   := $(wildcard src/ld/*.c)
+.TCF	:= -DEMX
 .TLDF   := -liberty
 include mkexe.smak
Index: trunk/src/emx/src/lib/app/app.smak
===================================================================
--- trunk/src/emx/src/lib/app/app.smak	(revision 119)
+++ trunk/src/emx/src/lib/app/app.smak	(revision 123)
@@ -2,8 +2,8 @@
 .MDESC	:= EMX.DLL 'replacement' for statically linked programs
 
-# Build four kinds of library c_app: single-threaded, multi-threaded,
-# single-threaded profile and multi-threaded profile
+# Build two kinds of library: aout and aout-profile.
+# The OMF libraries will be derived from them.
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= c_app$A
 .TSRC.386 := $(addprefix 386/,crt2.s crt3.s emxio.s inp8.s inp16.s inp32.s \
@@ -14,17 +14,9 @@
 .TCF.src/lib/app/stdio.c := -D_NFILES=40
 .TCF.src/lib/app/iodata.c := -D_NFILES=40
-.INSDIR	= lib/$(filter st mt,$(.TKIND))/
+.INSDIR	= lib/
 .TKEEP	:= 1
 include mklib.smak
 
-.TKIND	:= aout mt
-.TKEEP	:= 1
+.TKIND	:= aout prof
+.TARGET	:= c_app_p$A
 include mklib.smak
-
-.TKIND	:= aout st prof
-.TARGET	:= c_app_p$A
-.TKEEP	:= 1
-include mklib.smak
-
-.TKIND	:= aout mt prof
-include mklib.smak
Index: trunk/src/emx/src/lib/emxload/emxload.smak
===================================================================
--- trunk/src/emx/src/lib/emxload/emxload.smak	(revision 123)
+++ trunk/src/emx/src/lib/emxload/emxload.smak	(revision 123)
@@ -0,0 +1,1 @@
+libc.TSRC += $(wildcard src/lib/emxload/*.c)
Index: trunk/src/emx/src/lib/emxload/emxloadl.c
===================================================================
--- trunk/src/emx/src/lib/emxload/emxloadl.c	(revision 119)
+++ trunk/src/emx/src/lib/emxload/emxloadl.c	(revision 123)
@@ -8,6 +8,4 @@
 int _emxload_list_start (void)
 {
-  if (_osmode != OS2_MODE)
-    return -1;
   if (_emxload_do_connect (FALSE) != 0)
     return -1;
@@ -25,5 +23,5 @@
   answer ans;
 
-  if (_osmode != OS2_MODE || buf_size == 0)
+  if (buf_size == 0)
     return -1;
   if (_emxload_do_receive (&ans) != 0)
Index: trunk/src/emx/src/lib/emxload/emxloadr.c
===================================================================
--- trunk/src/emx/src/lib/emxload/emxloadr.c	(revision 119)
+++ trunk/src/emx/src/lib/emxload/emxloadr.c	(revision 123)
@@ -144,6 +144,4 @@
   int result;
 
-  if (_osmode != OS2_MODE)
-    return -1;
   switch (req_code)
     {
Index: trunk/src/emx/src/lib/end/end.smak
===================================================================
--- trunk/src/emx/src/lib/end/end.smak	(revision 119)
+++ trunk/src/emx/src/lib/end/end.smak	(revision 123)
@@ -2,12 +2,8 @@
 .MDESC	:= The C runtime library that should be linked last
 
-.TKIND	:= omf st
+.TKIND	:= omf
 .TARGET	:= end$A
 .TSRC.386 := $(wildcard src/lib/end/386/*.asm)
 .TSRC	:= $(.TSRC.$(CPU))
 .INSDIR	= lib/
-.TKEEP	:= 1
 include mklib.smak
-
-.TKIND	:= omf mt
-include mklib.smak
Index: trunk/src/emx/src/lib/io/_imphand.c
===================================================================
--- trunk/src/emx/src/lib/io/_imphand.c	(revision 119)
+++ trunk/src/emx/src/lib/io/_imphand.c	(revision 123)
@@ -8,5 +8,5 @@
 #include <emx/syscalls.h>
 
-int _fmode_bin;
+extern int _fmode_bin;
 
 int _imphandle (int handle)
Index: trunk/src/emx/src/lib/io/access.c
===================================================================
--- trunk/src/emx/src/lib/io/access.c	(revision 119)
+++ trunk/src/emx/src/lib/io/access.c	(revision 123)
@@ -8,5 +8,5 @@
 #include <emx/syscalls.h>
 
-int _access (const char *name, int mode)
+int access (const char *name, int mode)
 {
   int a, slash;
Index: trunk/src/emx/src/lib/io/chmod.c
===================================================================
--- trunk/src/emx/src/lib/io/chmod.c	(revision 119)
+++ trunk/src/emx/src/lib/io/chmod.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-int _chmod (const char *name, int pmode)
+int chmod (const char *name, int pmode)
 {
   int attr, rc;
Index: trunk/src/emx/src/lib/io/chsize.c
===================================================================
--- trunk/src/emx/src/lib/io/chsize.c	(revision 119)
+++ trunk/src/emx/src/lib/io/chsize.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-int _chsize (int handle, long length)
+int chsize (int handle, long length)
 {
   long n;
Index: trunk/src/emx/src/lib/io/close.c
===================================================================
--- trunk/src/emx/src/lib/io/close.c	(revision 119)
+++ trunk/src/emx/src/lib/io/close.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _close (int handle)
+int close (int handle)
 {
   if (_fd_flags (handle) == NULL)
Index: trunk/src/emx/src/lib/io/creat.c
===================================================================
--- trunk/src/emx/src/lib/io/creat.c	(revision 119)
+++ trunk/src/emx/src/lib/io/creat.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <fcntl.h>
 
-int _creat (const char *name, int pmode)
+int creat (const char *name, int pmode)
 {
   return _open (name, O_WRONLY|O_TRUNC|O_CREAT, pmode);
Index: trunk/src/emx/src/lib/io/dup.c
===================================================================
--- trunk/src/emx/src/lib/io/dup.c	(revision 119)
+++ trunk/src/emx/src/lib/io/dup.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _dup (int handle)
+int dup (int handle)
 {
   int new, *pflags1, *pflags2, *pla1, *pla2;
Index: trunk/src/emx/src/lib/io/dup2.c
===================================================================
--- trunk/src/emx/src/lib/io/dup2.c	(revision 119)
+++ trunk/src/emx/src/lib/io/dup2.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _dup2 (int handle1, int handle2)
+int dup2 (int handle1, int handle2)
 {
   int *pflags1, *pflags2, *pla1, *pla2;
Index: trunk/src/emx/src/lib/io/eadread.c
===================================================================
--- trunk/src/emx/src/lib/io/eadread.c	(revision 119)
+++ trunk/src/emx/src/lib/io/eadread.c	(revision 123)
@@ -66,18 +66,4 @@
 
   _ead_clear (ead);
-  if (_osmode != OS2_MODE)
-    {
-      if (path != NULL)
-        {
-          if (_access (path, 0) != 0)
-            return -1;
-        }
-      else
-        {
-          if (_tell (handle) == -1)
-            return -1;
-        }
-      return 0;
-    }
   gd.gea_alloc = sizeof (GEA2LIST);
   gd.gea_ptr = malloc (gd.gea_alloc);
Index: trunk/src/emx/src/lib/io/eadwrite.c
===================================================================
--- trunk/src/emx/src/lib/io/eadwrite.c	(revision 119)
+++ trunk/src/emx/src/lib/io/eadwrite.c	(revision 123)
@@ -51,6 +51,4 @@
 int _ead_write (_ead ead, const char *path, int handle, int flags)
 {
-  if (_osmode != OS2_MODE)
-    return 0;
   if (!(flags & _EAD_MERGE))
     {
Index: trunk/src/emx/src/lib/io/eaget.c
===================================================================
--- trunk/src/emx/src/lib/io/eaget.c	(revision 119)
+++ trunk/src/emx/src/lib/io/eaget.c	(revision 123)
@@ -26,18 +26,4 @@
   dst->size = 0;
   dst->value = NULL;
-  if (_osmode != OS2_MODE)
-    {
-      if (path != NULL)
-        {
-          if (_access (path, 0) != 0)
-            return -1;
-        }
-      else
-        {
-          if (_tell (handle) == -1)
-            return -1;
-        }
-      return 0;
-    }
   if (path != NULL)
     {
Index: trunk/src/emx/src/lib/io/eaput.c
===================================================================
--- trunk/src/emx/src/lib/io/eaput.c	(revision 119)
+++ trunk/src/emx/src/lib/io/eaput.c	(revision 123)
@@ -18,6 +18,4 @@
   int len, size;
 
-  if (_osmode != OS2_MODE)
-    return 0;
   len = strlen (name);
   size = sizeof (FEA2LIST) + len + src->size;
Index: trunk/src/emx/src/lib/io/eof.c
===================================================================
--- trunk/src/emx/src/lib/io/eof.c	(revision 119)
+++ trunk/src/emx/src/lib/io/eof.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/io.h>
 
-int _eof (int handle)
+int eof (int handle)
 {
   int *pflags;
Index: trunk/src/emx/src/lib/io/fcloseal.c
===================================================================
--- trunk/src/emx/src/lib/io/fcloseal.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fcloseal.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/io.h>
 
-int _fcloseall (void)
+int fcloseall (void)
 {
   int i, n, start;
Index: trunk/src/emx/src/lib/io/fcntl.c
===================================================================
--- trunk/src/emx/src/lib/io/fcntl.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fcntl.c	(revision 123)
@@ -60,5 +60,5 @@
 
 
-int _fcntl (int handle, int request, ...)
+int fcntl (int handle, int request, ...)
 {
   va_list va;
Index: trunk/src/emx/src/lib/io/fdopen.c
===================================================================
--- trunk/src/emx/src/lib/io/fdopen.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fdopen.c	(revision 123)
@@ -12,5 +12,5 @@
 /* Bug: doesn't check for compatible modes (O_ACCMODE) */
 
-FILE *_fdopen (int handle, const char *mode)
+FILE *fdopen (int handle, const char *mode)
 {
   char ok, bt;
Index: trunk/src/emx/src/lib/io/fgetchar.c
===================================================================
--- trunk/src/emx/src/lib/io/fgetchar.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fgetchar.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdio.h>
 
-int _fgetchar (void)
+int fgetchar (void)
 {
   return getchar ();
Index: trunk/src/emx/src/lib/io/fileleng.c
===================================================================
--- trunk/src/emx/src/lib/io/fileleng.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fileleng.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-long _filelength (int handle)
+long filelength (int handle)
 {
   long cur, n;
Index: trunk/src/emx/src/lib/io/flock.c
===================================================================
--- trunk/src/emx/src/lib/io/flock.c	(revision 119)
+++ trunk/src/emx/src/lib/io/flock.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/io.h>
 
-int _flock (int handle, int operation)
+int flock (int handle, int operation)
 {
   if (_fd_flags (handle) == NULL)
Index: trunk/src/emx/src/lib/io/flushall.c
===================================================================
--- trunk/src/emx/src/lib/io/flushall.c	(revision 119)
+++ trunk/src/emx/src/lib/io/flushall.c	(revision 123)
@@ -5,7 +5,8 @@
 #include <sys/rmutex.h>
 #include <stdio.h>
+#include <stdlib.h>
 #include <emx/io.h>
 
-int _flushall (void)
+int flushall (void)
 {
   int i, n;
Index: trunk/src/emx/src/lib/io/fputchar.c
===================================================================
--- trunk/src/emx/src/lib/io/fputchar.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fputchar.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdio.h>
 
-int _fputchar (int c)
+int fputchar (int c)
 {
   return putchar (c);
Index: trunk/src/emx/src/lib/io/fstat.c
===================================================================
--- trunk/src/emx/src/lib/io/fstat.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fstat.c	(revision 123)
@@ -8,5 +8,5 @@
 #include <emx/syscalls.h>
 
-int _fstat (int handle, struct stat *buffer)
+int fstat (int handle, struct stat *buffer)
 {
   int rc;
Index: trunk/src/emx/src/lib/io/fsync.c
===================================================================
--- trunk/src/emx/src/lib/io/fsync.c	(revision 119)
+++ trunk/src/emx/src/lib/io/fsync.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-int _fsync (int handle)
+int fsync (int handle)
 {
   return __fsync (handle);
Index: trunk/src/emx/src/lib/io/ftruncat.c
===================================================================
--- trunk/src/emx/src/lib/io/ftruncat.c	(revision 119)
+++ trunk/src/emx/src/lib/io/ftruncat.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _ftruncate (int handle, long length)
+int ftruncate (int handle, long length)
 {
   int *pflags;
Index: trunk/src/emx/src/lib/io/getw.c
===================================================================
--- trunk/src/emx/src/lib/io/getw.c	(revision 119)
+++ trunk/src/emx/src/lib/io/getw.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdio.h>
 
-int _getw (FILE *stream)
+int getw (FILE *stream)
 {
   int x;
Index: trunk/src/emx/src/lib/io/io.smak
===================================================================
--- trunk/src/emx/src/lib/io/io.smak	(revision 119)
+++ trunk/src/emx/src/lib/io/io.smak	(revision 123)
@@ -1,1 +1,18 @@
 libc.TSRC += $(wildcard src/lib/io/*.c)
+
+# Build some object files separately (not included in libraries)
+.MODULE :=
+.TKIND	:= aout
+.TSRC.386 := src/lib/io/386/binmode.s
+.TSRC	:= $(.TSRC.$(CPU))
+include common.smak
+
+.OBJS += $(patsubst %.o,%.obj,$(subst /aout/,/omf/,$(.OBJS)))
+.DIRS := $(sort $(dir $(.OBJS)))
+TARGDIRS += $(.DIRS)
+
+DO.INSTALL += $(call CP,$(.OBJS) $(INS)lib/)$(NL)
+
+libc: $(.DIRS) $(.OBJS)
+
+include comend.smak
Index: trunk/src/emx/src/lib/io/ioctl.c
===================================================================
--- trunk/src/emx/src/lib/io/ioctl.c	(revision 119)
+++ trunk/src/emx/src/lib/io/ioctl.c	(revision 123)
@@ -14,5 +14,5 @@
 #define FIONBIO         0x667e
 
-int _ioctl (int handle, int request, ...)
+int ioctl (int handle, int request, ...)
 {
   va_list va;
Index: trunk/src/emx/src/lib/io/isatty.c
===================================================================
--- trunk/src/emx/src/lib/io/isatty.c	(revision 119)
+++ trunk/src/emx/src/lib/io/isatty.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/io.h>
 
-int _isatty (int handle)
+int isatty (int handle)
 {
   int *pflags;
Index: trunk/src/emx/src/lib/io/lseek.c
===================================================================
--- trunk/src/emx/src/lib/io/lseek.c	(revision 119)
+++ trunk/src/emx/src/lib/io/lseek.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-long _lseek (int handle, long offset, int origin)
+long lseek (int handle, long offset, int origin)
 {
   int *pflags, *pla;
Index: trunk/src/emx/src/lib/io/mkstemp.c
===================================================================
--- trunk/src/emx/src/lib/io/mkstemp.c	(revision 119)
+++ trunk/src/emx/src/lib/io/mkstemp.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <errno.h>
 
-int _mkstemp (char *string)
+int mkstemp (char *string)
 {
   int fd, pid, n;
Index: trunk/src/emx/src/lib/io/mktemp.c
===================================================================
--- trunk/src/emx/src/lib/io/mktemp.c	(revision 119)
+++ trunk/src/emx/src/lib/io/mktemp.c	(revision 123)
@@ -6,10 +6,10 @@
 #include <errno.h>
 
-char *_mktemp (char *string)
+char *mktemp (char *string)
 {
   int pid, n, saved_errno;
   char *s;
 
-  pid = _getpid ();
+  pid = getpid ();
   s = strchr (string, 0);
   n = 0;
Index: trunk/src/emx/src/lib/io/open.c
===================================================================
--- trunk/src/emx/src/lib/io/open.c	(revision 119)
+++ trunk/src/emx/src/lib/io/open.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/io.h>
 
-int _open (const char *name, int oflag, ...)
+int open (const char *name, int oflag, ...)
 {
   va_list va;
Index: trunk/src/emx/src/lib/io/pclose.c
===================================================================
--- trunk/src/emx/src/lib/io/pclose.c	(revision 119)
+++ trunk/src/emx/src/lib/io/pclose.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/io.h>
 
-int _pclose (FILE *stream)
+int pclose (FILE *stream)
 {
   int rc, write_mode;
Index: trunk/src/emx/src/lib/io/pipe.c
===================================================================
--- trunk/src/emx/src/lib/io/pipe.c	(revision 119)
+++ trunk/src/emx/src/lib/io/pipe.c	(revision 123)
@@ -7,8 +7,8 @@
 #include <emx/syscalls.h>
 
-int _fmode_bin;
+extern int _fmode_bin;
 int _pipe_size;
 
-int _pipe (int *two_handles)
+int pipe (int *two_handles)
 {
   int *pflags1, *pflags2;
Index: trunk/src/emx/src/lib/io/popen.c
===================================================================
--- trunk/src/emx/src/lib/io/popen.c	(revision 119)
+++ trunk/src/emx/src/lib/io/popen.c	(revision 123)
@@ -82,5 +82,5 @@
 
 
-FILE *_popen (const char *command, const char *mode)
+FILE *popen (const char *command, const char *mode)
 {
   int ph[2];
Index: trunk/src/emx/src/lib/io/putw.c
===================================================================
--- trunk/src/emx/src/lib/io/putw.c	(revision 119)
+++ trunk/src/emx/src/lib/io/putw.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdio.h>
 
-int _putw (int x, FILE *stream)
+int putw (int x, FILE *stream)
 {
   return (fwrite (&x, sizeof (x), 1, stream) == 1 ? x : EOF);
Index: trunk/src/emx/src/lib/io/read.c
===================================================================
--- trunk/src/emx/src/lib/io/read.c	(revision 119)
+++ trunk/src/emx/src/lib/io/read.c	(revision 123)
@@ -37,5 +37,5 @@
 
 
-int _read (int handle, void *buf, size_t nbyte)
+int read (int handle, void *buf, size_t nbyte)
 {
   int n, *pflags, *pla;
Index: trunk/src/emx/src/lib/io/readv.c
===================================================================
--- trunk/src/emx/src/lib/io/readv.c	(revision 119)
+++ trunk/src/emx/src/lib/io/readv.c	(revision 123)
@@ -10,5 +10,5 @@
 #include <sys/uio.h>
 
-int _readv (int handle, const struct iovec *iov, int iovcnt)
+int readv (int handle, const struct iovec *iov, int iovcnt)
 {
   int i, n;
Index: trunk/src/emx/src/lib/io/select.c
===================================================================
--- trunk/src/emx/src/lib/io/select.c	(revision 119)
+++ trunk/src/emx/src/lib/io/select.c	(revision 123)
@@ -12,5 +12,5 @@
 #define MIN(a,b) (((a) < (b)) ? (a) : (b))
 
-int _select (int nfds, fd_set *readfds, fd_set *writefds,
+int select (int nfds, fd_set *readfds, fd_set *writefds,
              fd_set *exceptfds, struct timeval *timeout)
 {
Index: trunk/src/emx/src/lib/io/setbuffe.c
===================================================================
--- trunk/src/emx/src/lib/io/setbuffe.c	(revision 119)
+++ trunk/src/emx/src/lib/io/setbuffe.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdio.h>
 
-int _setbuffer (FILE *stream, char *buffer, size_t size)
+int setbuffer (FILE *stream, char *buffer, size_t size)
 {
   return setvbuf (stream, buffer, (buffer != NULL ? _IOFBF : _IONBF), size);
Index: trunk/src/emx/src/lib/io/setmode.c
===================================================================
--- trunk/src/emx/src/lib/io/setmode.c	(revision 119)
+++ trunk/src/emx/src/lib/io/setmode.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/io.h>
 
-int _setmode (int handle, int mode)
+int setmode (int handle, int mode)
 {
   int old_mode, *pflags;
Index: trunk/src/emx/src/lib/io/snprintf.c
===================================================================
--- trunk/src/emx/src/lib/io/snprintf.c	(revision 119)
+++ trunk/src/emx/src/lib/io/snprintf.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/io.h>
 
-int _snprintf (char *buffer, size_t n, const char *format, ...)
+int snprintf (char *buffer, size_t n, const char *format, ...)
 {
   va_list arg_ptr;
Index: trunk/src/emx/src/lib/io/sopen.c
===================================================================
--- trunk/src/emx/src/lib/io/sopen.c	(revision 119)
+++ trunk/src/emx/src/lib/io/sopen.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/io.h>
 
-int _sopen (const char *name, int oflag, int shflag, ...)
+int sopen (const char *name, int oflag, int shflag, ...)
 {
   va_list va;
Index: trunk/src/emx/src/lib/io/stat.c
===================================================================
--- trunk/src/emx/src/lib/io/stat.c	(revision 119)
+++ trunk/src/emx/src/lib/io/stat.c	(revision 123)
@@ -13,5 +13,5 @@
 #include <emx/syscalls.h>
 
-int _stat (const char *name, struct stat *buffer)
+int stat (const char *name, struct stat *buffer)
 {
   int rc, slash;
Index: trunk/src/emx/src/lib/io/tell.c
===================================================================
--- trunk/src/emx/src/lib/io/tell.c	(revision 119)
+++ trunk/src/emx/src/lib/io/tell.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-long _tell (int handle)
+long tell (int handle)
 {
   int *pflags, *pla;
Index: trunk/src/emx/src/lib/io/truncate.c
===================================================================
--- trunk/src/emx/src/lib/io/truncate.c	(revision 119)
+++ trunk/src/emx/src/lib/io/truncate.c	(revision 123)
@@ -4,13 +4,13 @@
 #include <fcntl.h>
 
-int _truncate (char *name, long length)
+int truncate (char *name, long length)
 {
   int handle, result;
 
-  handle = _open (name, O_RDWR);
+  handle = open (name, O_RDWR);
   if (handle == -1)
     return -1;
   result = _ftruncate (handle, length);
-  _close (handle);
+  close (handle);
   return result;
 }
Index: trunk/src/emx/src/lib/io/ttyname.c
===================================================================
--- trunk/src/emx/src/lib/io/ttyname.c	(revision 119)
+++ trunk/src/emx/src/lib/io/ttyname.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/thread.h>
 
-char *_ttyname (int handle)
+char *ttyname (int handle)
 {
 #if defined (__MT__)
Index: trunk/src/emx/src/lib/io/umask.c
===================================================================
--- trunk/src/emx/src/lib/io/umask.c	(revision 119)
+++ trunk/src/emx/src/lib/io/umask.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-int _umask (int pmode)
+int umask (int pmode)
 {
   return __umask (pmode);
Index: trunk/src/emx/src/lib/io/unlink.c
===================================================================
--- trunk/src/emx/src/lib/io/unlink.c	(revision 119)
+++ trunk/src/emx/src/lib/io/unlink.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-int _unlink (const char *name)
+int unlink (const char *name)
 {
   return __remove (name);       /* There are no links */
Index: trunk/src/emx/src/lib/io/utime.c
===================================================================
--- trunk/src/emx/src/lib/io/utime.c	(revision 119)
+++ trunk/src/emx/src/lib/io/utime.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-int _utime (const char *name, const struct utimbuf *times)
+int utime (const char *name, const struct utimbuf *times)
 {
   struct timeval tv[2];
Index: trunk/src/emx/src/lib/io/utimes.c
===================================================================
--- trunk/src/emx/src/lib/io/utimes.c	(revision 119)
+++ trunk/src/emx/src/lib/io/utimes.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _utimes (const char *name, const struct timeval *tvp)
+int utimes (const char *name, const struct timeval *tvp)
 {
   struct timeval tv[2];
Index: trunk/src/emx/src/lib/io/vsnprint.c
===================================================================
--- trunk/src/emx/src/lib/io/vsnprint.c	(revision 119)
+++ trunk/src/emx/src/lib/io/vsnprint.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/io.h>
 
-int _vsnprintf (char *buffer, size_t n, const char *format, va_list arg_ptr)
+int vsnprintf (char *buffer, size_t n, const char *format, va_list arg_ptr)
 {
   FILE trick;
Index: trunk/src/emx/src/lib/io/vsscanf.c
===================================================================
--- trunk/src/emx/src/lib/io/vsscanf.c	(revision 119)
+++ trunk/src/emx/src/lib/io/vsscanf.c	(revision 123)
@@ -3,4 +3,5 @@
 #include <stdio.h>
 #include <stdarg.h>
+#include <string.h>
 #include <limits.h>
 #include <emx/io.h>
Index: trunk/src/emx/src/lib/io/write.c
===================================================================
--- trunk/src/emx/src/lib/io/write.c	(revision 119)
+++ trunk/src/emx/src/lib/io/write.c	(revision 123)
@@ -137,5 +137,5 @@
 
 
-int _write (int handle, const void *buf, size_t nbyte)
+int write (int handle, const void *buf, size_t nbyte)
 {
   int n, *pflags;
Index: trunk/src/emx/src/lib/io/writev.c
===================================================================
--- trunk/src/emx/src/lib/io/writev.c	(revision 119)
+++ trunk/src/emx/src/lib/io/writev.c	(revision 123)
@@ -10,5 +10,5 @@
 #include <sys/uio.h>
 
-int _writev (int handle, const struct iovec *iov, int iovcnt)
+int writev (int handle, const struct iovec *iov, int iovcnt)
 {
   int i, n;
Index: trunk/src/emx/src/lib/libc.smak
===================================================================
--- trunk/src/emx/src/lib/libc.smak	(revision 119)
+++ trunk/src/emx/src/lib/libc.smak	(revision 123)
@@ -3,5 +3,5 @@
 # Utility function used in second-level submakefiles
 # Creates four versions of object file name for all kinds of outputs.
-.MVER = $(foreach x,aout-st aout-mt aout-st-prof aout-mt-prof,$.$x/src/lib/$1)
+.MVER = $(foreach x,aout aout-prof,$.$x/src/lib/$1)
 
 # First of all, include all second-level libc submakefiles
@@ -14,22 +14,14 @@
 .MDESC	:= The C library
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= c$A
 .TSRC	:= $(libc.TSRC.$(CPU)) $(libc.TSRC)
-.TDEP	:= $(libc.TDEP)
-.INSDIR	= lib/$(filter st mt,$(.TKIND))/
+.TDEP	:= $(libc.TDEP.$(CPU)) $(libc.TDEP)
+.INSDIR	= lib/
 .TKEEP	:= 1
 include mklib.smak
 
-.TKIND	:= aout mt
-.TKEEP	:= 1
-include mklib.smak
-
-.TKIND	:= aout st prof
+.TKIND	:= aout prof
 .TARGET	:= c_p$A
-.TKEEP	:= 1
-include mklib.smak
-
-.TKIND	:= aout mt prof
 include mklib.smak
 
@@ -38,3 +30,4 @@
 libc.TSRC.$(CPU) :=
 libc.TSRC :=
+libc.TDEP.$(CPU) :=
 libc.TDEP :=
Index: trunk/src/emx/src/lib/math/math.smak
===================================================================
--- trunk/src/emx/src/lib/math/math.smak	(revision 119)
+++ trunk/src/emx/src/lib/math/math.smak	(revision 123)
@@ -1,2 +1,15 @@
 libc.TSRC.386 += $(wildcard src/lib/math/386/*.s)
 libc.TSRC += $(wildcard src/lib/math/*.c)
+
+# Virtual targets, e.g. compiled from same input files but with different opts
+libc.TDEP.386 += $(addprefix @O@src/lib/math/386/, copysigf.o copysigl.o \
+  fpclassf.o fpclassl.o isfinf.o isfinl.o isnanf.o isnanl.o isnormf.o \
+  isnorml.o nextaftf.o nextaftl.o signbitf.o signbitl.o acosl.o asinl.o \
+  atanl.o atan2l.o ceill.o cosl.o coshl.o expl.o fabsl.o floorl.o fmodl.o \
+  frexpl.o fxaml.o hypotl.o ldexpl.o logl.o log10l.o modfl.o powl.o rintl.o \
+  sinl.o sinhl.o sqrtl.o tanl.o tanhl.o truncl.o)
+
+$(call .MVER,math/%f.o): src/lib/math/%.s
+	$(call DO.COMPILE.s, -DFLOAT)
+$(call .MVER,math/%l.o): src/lib/math/%.s
+	$(call DO.COMPILE.s, -DLONG_DOUBLE)
Index: trunk/src/emx/src/lib/misc/386/int86.s
===================================================================
--- trunk/src/emx/src/lib/misc/386/int86.s	(revision 119)
+++ trunk/src/emx/src/lib/misc/386/int86.s	(revision 123)
@@ -27,5 +27,5 @@
         movl    5*4(%ebx), %edi
         movl    1*4(%ebx), %ebx
-        call    (%esp)                  /* "call %esp" is undefined */
+        call    *(%esp)                 /* "call %esp" is undefined */
         movl    %ebx, 1*4(%esp)
         movl    9*4(%esp), %ebx         /* out_regs */
Index: trunk/src/emx/src/lib/misc/386/setjmp.s
===================================================================
--- trunk/src/emx/src/lib/misc/386/setjmp.s	(revision 119)
+++ trunk/src/emx/src/lib/misc/386/setjmp.s	(revision 123)
@@ -30,10 +30,8 @@
         movl    0*4(%esp), %eax         /* return address */
         movl    %eax, J_EIP(%edx)
-        cmpb    $0, __osmode            /* OS/2? */
-        je      1f                      /* No -> skip */
         fs
         movl    0, %eax                 /* Exception handler */
         movl    %eax, J_XCP(%edx)
-1:      xorl    %eax, %eax
+        xorl    %eax, %eax
         EPILOGUE(setjmp)
 
@@ -44,11 +42,9 @@
 _longjmp:
         PROFILE_NOFRAME
-        cmpb    $0, __osmode            /* OS/2? */
-        je      2f                      /* No -> skip */
         movl    1*4(%esp), %eax         /* there */
         pushl   J_XCP(%eax)
         call    ___unwind2              /* unwind signal handlers */
         addl    $4, %esp
-2:      movl    1*4(%esp), %edx         /* there */
+        movl    1*4(%esp), %edx         /* there */
         movl    2*4(%esp), %eax         /* n */
         testl   %eax, %eax
Index: trunk/src/emx/src/lib/misc/386/sigsetjm.s
===================================================================
--- trunk/src/emx/src/lib/misc/386/sigsetjm.s	(revision 119)
+++ trunk/src/emx/src/lib/misc/386/sigsetjm.s	(revision 123)
@@ -32,13 +32,11 @@
         movl    0*4(%esp), %eax         /* return address */
         movl    %eax, J_EIP(%edx)
-        cmpb    $0, __osmode            /* OS/2? */
-        je      1f                      /* No -> skip */
         fs
         movl    0, %eax                 /* Exception handler */
         movl    %eax, J_XCP(%edx)
-1:      movl    2*4(%esp), %eax         /* savemask */
+        movl    2*4(%esp), %eax         /* savemask */
         movl    %eax, J_SAVE(%edx)
         testl   %eax, %eax
-        je      2f
+        je      1f
         leal    J_MASK(%edx), %eax
         pushl   %eax                    /* oset */
@@ -47,5 +45,5 @@
         call    __sigprocmask
         addl    $12, %esp
-2:      xorl    %eax, %eax
+1:      xorl    %eax, %eax
         EPILOGUE(_sigsetjmp)
 
@@ -65,16 +63,14 @@
         call    __sigprocmask
         addl    $12, %esp
-1:      cmpb    $0, __osmode            /* OS/2? */
-        je      2f                      /* No -> skip */
-        movl    1*4(%esp), %eax         /* there */
+1:      movl    1*4(%esp), %eax         /* there */
         pushl   J_XCP(%eax)
         call    ___unwind2              /* unwind signal handlers */
         addl    $4, %esp
-2:      movl    1*4(%esp), %edx         /* there */
+        movl    1*4(%esp), %edx         /* there */
         movl    2*4(%esp), %eax         /* n */
         testl   %eax, %eax
-        jne     3f
+        jne     2f
         incl    %eax
-3:      movl    J_EBX(%edx), %ebx
+2:      movl    J_EBX(%edx), %ebx
         movl    J_ESI(%edx), %esi
         movl    J_EDI(%edx), %edi
Index: trunk/src/emx/src/lib/misc/abort.c
===================================================================
--- trunk/src/emx/src/lib/misc/abort.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/abort.c	(revision 123)
@@ -15,9 +15,9 @@
      and SIGABRT is not blocked: do not yet call _cleanup(). */
 
-  if (_sigaction (SIGABRT, NULL, &act) == 0
+  if (sigaction (SIGABRT, NULL, &act) == 0
       && act.sa_handler != SIG_IGN && act.sa_handler != SIG_DFL
-      && _sigemptyset (&set) == 0
-      && _sigprocmask (SIG_SETMASK, NULL, &set) == 0
-      && _sigismember (&set, SIGABRT) == 0)
+      && sigemptyset (&set) == 0
+      && sigprocmask (SIG_SETMASK, NULL, &set) == 0
+      && sigismember (&set, SIGABRT) == 0)
     {
       /* Raise SIGABRT.  Note that this is not guaranteed to terminate
@@ -30,7 +30,7 @@
 
   act.sa_handler = SIG_DFL;
-  _sigemptyset (&act.sa_mask);
+  sigemptyset (&act.sa_mask);
   act.sa_flags = 0;
-  _sigaction (SIGABRT, &act, NULL);
+  sigaction (SIGABRT, &act, NULL);
 
   /* Clean up the C library only once. */
@@ -41,7 +41,7 @@
   /* Unblock SIGABRT. */
 
-  _sigemptyset (&set);
-  _sigaddset (&set, SIGABRT);
-  _sigprocmask (SIG_UNBLOCK, &set, NULL);
+  sigemptyset (&set);
+  sigaddset (&set, SIGABRT);
+  sigprocmask (SIG_UNBLOCK, &set, NULL);
 
   /* Raise SIGABRT again. */
@@ -51,4 +51,4 @@
   /* This should not get reached. */
 
-  _exit (3);
+  exit (3);
 }
Index: trunk/src/emx/src/lib/misc/alarm.c
===================================================================
--- trunk/src/emx/src/lib/misc/alarm.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/alarm.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-unsigned _alarm (unsigned sec)
+unsigned alarm (unsigned sec)
 {
   return __alarm (sec);
Index: trunk/src/emx/src/lib/misc/brk.c
===================================================================
--- trunk/src/emx/src/lib/misc/brk.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/brk.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-void *_brk (void *addr)
+void *brk (void *addr)
 {
   return __brk (addr);
Index: trunk/src/emx/src/lib/misc/chdir.c
===================================================================
--- trunk/src/emx/src/lib/misc/chdir.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/chdir.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <emx/syscalls.h>
 
-int _chdir (const char *name)
+int chdir (const char *name)
 {
   size_t len;
Index: trunk/src/emx/src/lib/misc/cuserid.c
===================================================================
--- trunk/src/emx/src/lib/misc/cuserid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/cuserid.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <string.h>
 
-char *_cuserid (char *buffer)
+char *cuserid (char *buffer)
 {
   static char tmp_name[L_cuserid];
Index: trunk/src/emx/src/lib/misc/dirent.c
===================================================================
--- trunk/src/emx/src/lib/misc/dirent.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/dirent.c	(revision 123)
@@ -37,5 +37,5 @@
     const char *base);
 
-int _closedir (DIR *dirp)
+int closedir (DIR *dirp)
 {
   free_dircontents (dirp->dd_contents);
@@ -45,5 +45,5 @@
 
 
-struct dirent *_readdir (DIR *dirp)
+struct dirent *readdir (DIR *dirp)
 {
   if (dirp->dd_cp == NULL)
@@ -65,5 +65,5 @@
 
 
-void _seekdir (DIR *dirp, long off)
+void seekdir (DIR *dirp, long off)
 {
   long i;
@@ -83,5 +83,5 @@
 
 
-void _rewinddir (DIR *dirp)
+void rewinddir (DIR *dirp)
 {
   _seekdir (dirp, 0L);
@@ -89,5 +89,5 @@
 
 
-long _telldir (DIR *dirp)
+long telldir (DIR *dirp)
 {
   return dirp->dd_loc;
@@ -95,5 +95,5 @@
 
 
-DIR *_opendir (const char *name)
+DIR *opendir (const char *name)
 {
   struct stat statb;
Index: trunk/src/emx/src/lib/misc/dtread.c
===================================================================
--- trunk/src/emx/src/lib/misc/dtread.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/dtread.c	(revision 123)
@@ -170,5 +170,5 @@
   data.dir_pass = 1;
   if (strcmp (mask, "*.*") == 0
-      || (_osmode == OS2_MODE && strcmp (mask, "*") == 0))
+      || (strcmp (mask, "*") == 0))
     data.dir_pass = 0;
   data.attr = A_HIDDEN | A_SYSTEM;
Index: trunk/src/emx/src/lib/misc/fnmatch.c
===================================================================
--- trunk/src/emx/src/lib/misc/fnmatch.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/fnmatch.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <string.h>
 #include <ctype.h>
-#include <fnmatch.h>
+#include <emx/fnmatch.h>
 #include <sys/nls.h>
 
@@ -592,5 +592,5 @@
 /* This is the public entrypoint, with signed arguments. */
 
-int _fnmatch (const char *mask, const char *name, int flags)
+int fnmatch (const char *mask, const char *name, int flags)
 {
   return _fnmatch_unsigned (mask, name, flags);
Index: trunk/src/emx/src/lib/misc/fpathcon.c
===================================================================
--- trunk/src/emx/src/lib/misc/fpathcon.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/fpathcon.c	(revision 123)
@@ -7,5 +7,5 @@
 /* Return the POSIX.1  minimum values, for now. */
 
-long _fpathconf (int handle, int name)
+long fpathconf (int handle, int name)
 {
   switch (name)
Index: trunk/src/emx/src/lib/misc/ftw.c
===================================================================
--- trunk/src/emx/src/lib/misc/ftw.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/ftw.c	(revision 123)
@@ -66,7 +66,7 @@
 
 
-int _ftw (const char *path,
-          int (*fn)(const char *name, const struct stat *stat_ptr, int flag),
-          int depth)
+int ftw (const char *path,
+         int (*fn)(const char *name, const struct stat *stat_ptr, int flag),
+         int depth)
 {
   struct stat st;
Index: trunk/src/emx/src/lib/misc/getcwd.c
===================================================================
--- trunk/src/emx/src/lib/misc/getcwd.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getcwd.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-char *_getcwd (char *buffer, size_t size)
+char *getcwd (char *buffer, size_t size)
 {
   char tmp[MAXPATHLEN+1];
Index: trunk/src/emx/src/lib/misc/getegid.c
===================================================================
--- trunk/src/emx/src/lib/misc/getegid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getegid.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <sys/types.h>
 
-gid_t _getegid (void)
+gid_t getegid (void)
 {
   return 0;
Index: trunk/src/emx/src/lib/misc/geteuid.c
===================================================================
--- trunk/src/emx/src/lib/misc/geteuid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/geteuid.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <sys/types.h>
 
-uid_t _geteuid (void)
+uid_t geteuid (void)
 {
   return 0;
Index: trunk/src/emx/src/lib/misc/getgid.c
===================================================================
--- trunk/src/emx/src/lib/misc/getgid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getgid.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <sys/types.h>
 
-gid_t _getgid (void)
+gid_t getgid (void)
 {
   return 0;
Index: trunk/src/emx/src/lib/misc/getgrgid.c
===================================================================
--- trunk/src/emx/src/lib/misc/getgrgid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getgrgid.c	(revision 123)
@@ -7,5 +7,5 @@
 /* Dummy function */
 
-struct group *_getgrgid (gid_t gid)
+struct group *getgrgid (gid_t gid)
 {
   static struct group tmp_grp;
Index: trunk/src/emx/src/lib/misc/getgrnam.c
===================================================================
--- trunk/src/emx/src/lib/misc/getgrnam.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getgrnam.c	(revision 123)
@@ -7,5 +7,5 @@
 /* Dummy function */
 
-struct group *_getgrnam (const char *name)
+struct group *getgrnam (const char *name)
 {
   static struct group tmp_grp;
Index: trunk/src/emx/src/lib/misc/getgroup.c
===================================================================
--- trunk/src/emx/src/lib/misc/getgroup.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getgroup.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <sys/types.h>
 
-int _getgroups (int gidsetsize, gid_t grouplist [])
+int getgroups (int gidsetsize, gid_t grouplist [])
 {
   return 0;
Index: trunk/src/emx/src/lib/misc/getlogin.c
===================================================================
--- trunk/src/emx/src/lib/misc/getlogin.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getlogin.c	(revision 123)
@@ -6,5 +6,5 @@
 #include <unistd.h>
 
-char *_getlogin (void)
+char *getlogin (void)
 {
   static char tmp_name[L_cuserid];
Index: trunk/src/emx/src/lib/misc/getopt.c
===================================================================
--- trunk/src/emx/src/lib/misc/getopt.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getopt.c	(revision 123)
@@ -34,5 +34,5 @@
 /* Note: `argv' is not const as GETOPT_ANY reorders argv[]. */
 
-int _getopt (int argc, char * argv[], const char *opt_str)
+int getopt (int argc, char * argv[], const char *opt_str)
 {
   char c, *q;
Index: trunk/src/emx/src/lib/misc/getpages.c
===================================================================
--- trunk/src/emx/src/lib/misc/getpages.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getpages.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <stdlib.h>
 
-int _getpagesize (void)
+int getpagesize (void)
 {
   return 4096;
Index: trunk/src/emx/src/lib/misc/getpass.c
===================================================================
--- trunk/src/emx/src/lib/misc/getpass.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getpass.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <unistd.h>
 
-char *_getpass (const char *prompt)
+char *getpass (const char *prompt)
 {
   return _getpass2 (prompt, 1);
Index: trunk/src/emx/src/lib/misc/getpgrp.c
===================================================================
--- trunk/src/emx/src/lib/misc/getpgrp.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getpgrp.c	(revision 123)
@@ -5,6 +5,6 @@
 #include <sys/types.h>
 
-pid_t _getpgrp (void)
+pid_t getpgrp (void)
 {
-  return _getpid ();
+  return getpid ();
 }
Index: trunk/src/emx/src/lib/misc/getpwnam.c
===================================================================
--- trunk/src/emx/src/lib/misc/getpwnam.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getpwnam.c	(revision 123)
@@ -9,5 +9,5 @@
 /* Dummy function */
 
-struct passwd *_getpwnam (const char *name)
+struct passwd *getpwnam (const char *name)
 {
   if (name == NULL)
Index: trunk/src/emx/src/lib/misc/getpwuid.c
===================================================================
--- trunk/src/emx/src/lib/misc/getpwuid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getpwuid.c	(revision 123)
@@ -8,5 +8,5 @@
 /* Dummy function */
 
-struct passwd *_getpwuid (uid_t uid)
+struct passwd *getpwuid (uid_t uid)
 {
   return _getpw (uid, NULL);
Index: trunk/src/emx/src/lib/misc/getuid.c
===================================================================
--- trunk/src/emx/src/lib/misc/getuid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getuid.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <sys/types.h>
 
-uid_t _getuid (void)
+uid_t getuid (void)
 {
   return 0;
Index: trunk/src/emx/src/lib/misc/getvol.c
===================================================================
--- trunk/src/emx/src/lib/misc/getvol.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getvol.c	(revision 123)
@@ -25,27 +25,14 @@
     return NULL;
 
-  if (_osmode == OS2_MODE)
-    {
-      ULONG rc;
-      FSINFO fsinfo;
+  ULONG rc;
+  FSINFO fsinfo;
 
-      memset (&fsinfo, 0, sizeof (fsinfo));
-      rc = DosQueryFSInfo (drive - 'A' + 1, FSIL_VOLSER, &fsinfo,
-                           sizeof (fsinfo));
-      if (rc != 0)
-        return NULL;
-      strcpy (result, fsinfo.vol.szVolLabel);
-    }
-  else
-    {
-      static struct _find find;
-      char mask[7];
+  memset (&fsinfo, 0, sizeof (fsinfo));
+  rc = DosQueryFSInfo (drive - 'A' + 1, FSIL_VOLSER, &fsinfo,
+                       sizeof (fsinfo));
+  if (rc != 0)
+    return NULL;
+  strcpy (result, fsinfo.vol.szVolLabel);
 
-      mask[0] = drive;
-      strcpy (mask + 1, ":\\*.*");
-      if (__findfirst (mask, _A_VOLID, &find) != 0)
-        return NULL;
-      strcpy (result, find.name);
-    }
   return result;
 }
Index: trunk/src/emx/src/lib/misc/getwd.c
===================================================================
--- trunk/src/emx/src/lib/misc/getwd.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/getwd.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-char *_getwd (char *buffer)
+char *getwd (char *buffer)
 {
   if (buffer == NULL)
Index: trunk/src/emx/src/lib/misc/glob.c
===================================================================
--- trunk/src/emx/src/lib/misc/glob.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/glob.c	(revision 123)
@@ -5,5 +5,6 @@
 #include <errno.h>
 #include <unistd.h>
-#include <fnmatch.h>
+#include <alloca.h>
+#include <emx/fnmatch.h>
 #include <glob.h>
 #include <sys/types.h>
@@ -115,5 +116,5 @@
   /* TODO: Optimize for lpat not containing global characters. */
 
-  dir = _opendir (*base != 0 ? base : ".");
+  dir = opendir (*base != 0 ? base : ".");
   if (dir == NULL)
     {
@@ -124,7 +125,7 @@
       return 0;
     }
-  while ((ent = _readdir (dir)) != NULL)
-    {
-      if (_fnmatch (lpat, ent->d_name, fnm_flags) == 0)
+  while ((ent = readdir (dir)) != NULL)
+    {
+      if (fnmatch (lpat, ent->d_name, fnm_flags) == 0)
         {
           len = base_len + ent->d_namlen;
@@ -145,5 +146,5 @@
               if (!glob_add (pg, path))
                 {
-                  _closedir (dir);
+                  closedir (dir);
                   return GLOB_NOSPACE;
                 }
@@ -158,5 +159,5 @@
               if (r != 0)
                 {
-                  _closedir (dir);
+                  closedir (dir);
                   return r;
                 }
@@ -164,5 +165,5 @@
         }
     }
-  _closedir (dir);
+  closedir (dir);
   return 0;
 }
@@ -175,6 +176,6 @@
 
 
-int _glob (const char *pattern, int flags,
-           int (*errfun)(const char *e_path, int e_errno), glob_t *pglob)
+int glob (const char *pattern, int flags,
+          int (*errfun)(const char *e_path, int e_errno), glob_t *pglob)
 {
   struct globi g;
Index: trunk/src/emx/src/lib/misc/mkdir.c
===================================================================
--- trunk/src/emx/src/lib/misc/mkdir.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/mkdir.c	(revision 123)
@@ -5,7 +5,7 @@
 #include <emx/syscalls.h>
 
-int _mkdir (const char *name, long mode)
+int mkdir (const char *name, long mode)
 {
-  mode = 0;                     /* Keep the compiler happy */
+  (void)mode;                     /* Keep the compiler happy */
   if (__mkdir (name) == 0)
     return 0;
Index: trunk/src/emx/src/lib/misc/os2bad.c
===================================================================
--- trunk/src/emx/src/lib/misc/os2bad.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/os2bad.c	(revision 123)
@@ -9,4 +9,4 @@
 {
   __write (2, msg, sizeof (msg) - 1);
-  _exit (2);
+  exit (2);
 }
Index: trunk/src/emx/src/lib/misc/pathconf.c
===================================================================
--- trunk/src/emx/src/lib/misc/pathconf.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/pathconf.c	(revision 123)
@@ -7,5 +7,5 @@
 /* Return the POSIX.1  minimum values, for now. */
 
-long _pathconf (const char *path, int name)
+long pathconf (const char *path, int name)
 {
   switch (name)
Index: trunk/src/emx/src/lib/misc/perror.c
===================================================================
--- trunk/src/emx/src/lib/misc/perror.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/perror.c	(revision 123)
@@ -14,5 +14,5 @@
     }
   if (e >= 0 && e < _sys_nerr)
-    fputs (_sys_errlist[e], stderr);
+    fputs (sys_errlist[e], stderr);
   else
     fprintf (stderr, "Unknown error %d", e);
Index: trunk/src/emx/src/lib/misc/pwd.c
===================================================================
--- trunk/src/emx/src/lib/misc/pwd.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/pwd.c	(revision 123)
@@ -58,5 +58,5 @@
 
 
-struct passwd *_getpwent (void)
+struct passwd *getpwent (void)
 {
   return NULL;                  /* End of /etc/passwd reached */
@@ -64,10 +64,10 @@
 
 
-void _setpwent (void)
+void setpwent (void)
 {
 }
 
 
-void _endpwent (void)
+void endpwent (void)
 {
 }
Index: trunk/src/emx/src/lib/misc/rmdir.c
===================================================================
--- trunk/src/emx/src/lib/misc/rmdir.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/rmdir.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <emx/syscalls.h>
 
-int _rmdir (const char *name)
+int rmdir (const char *name)
 {
   if (__rmdir (name) == 0)
Index: trunk/src/emx/src/lib/misc/sbrk.c
===================================================================
--- trunk/src/emx/src/lib/misc/sbrk.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/sbrk.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-void *_sbrk (int incr)
+void *sbrk (int incr)
 {
   return __sbrk (incr);
Index: trunk/src/emx/src/lib/misc/scrsize.c
===================================================================
--- trunk/src/emx/src/lib/misc/scrsize.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/scrsize.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <emx/syscalls.h>
 
-void _scrsize (int *dst)
+void scrsize (int *dst)
 {
   __scrsize (dst);
Index: trunk/src/emx/src/lib/misc/searchen.c
===================================================================
--- trunk/src/emx/src/lib/misc/searchen.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/searchen.c	(revision 123)
@@ -12,5 +12,5 @@
   
   strcpy (path, file);
-  if (_access (path, 4) == 0)
+  if (access (path, 4) == 0)
     return;
   list = getenv (var);
@@ -30,5 +30,5 @@
               path[i++] = '\\';
             strcpy (path+i, file);
-            if (_access (path, 4) == 0)
+            if (access (path, 4) == 0)
               return;
           }
Index: trunk/src/emx/src/lib/misc/setgid.c
===================================================================
--- trunk/src/emx/src/lib/misc/setgid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/setgid.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <sys/types.h>
 
-int _setgid (gid_t gid)
+int setgid (gid_t gid)
 {
   if (gid != 0)
Index: trunk/src/emx/src/lib/misc/setpgid.c
===================================================================
--- trunk/src/emx/src/lib/misc/setpgid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/setpgid.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <sys/types.h>
 
-int _setpgid (pid_t pid, pid_t pgid)
+int setpgid (pid_t pid, pid_t pgid)
 {
   errno = ENOSYS;
Index: trunk/src/emx/src/lib/misc/setsid.c
===================================================================
--- trunk/src/emx/src/lib/misc/setsid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/setsid.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <sys/types.h>
 
-pid_t _setsid (void)
+pid_t setsid (void)
 {
   errno = EPERM;
Index: trunk/src/emx/src/lib/misc/setuid.c
===================================================================
--- trunk/src/emx/src/lib/misc/setuid.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/setuid.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <sys/types.h>
 
-int _setuid (uid_t uid)
+int setuid (uid_t uid)
 {
   if (uid != 0)
Index: trunk/src/emx/src/lib/misc/sleep.c
===================================================================
--- trunk/src/emx/src/lib/misc/sleep.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/sleep.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-unsigned _sleep (unsigned sec)
+unsigned sleep (unsigned sec)
 {
   return __sleep (sec);
Index: trunk/src/emx/src/lib/misc/sleep2.c
===================================================================
--- trunk/src/emx/src/lib/misc/sleep2.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/sleep2.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-unsigned _sleep2 (unsigned millisec)
+unsigned sleep2 (unsigned millisec)
 {
   return __sleep2 (millisec);
Index: trunk/src/emx/src/lib/misc/sysconf.c
===================================================================
--- trunk/src/emx/src/lib/misc/sysconf.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/sysconf.c	(revision 123)
@@ -8,5 +8,5 @@
 /* Return the POSIX.1  minimum values, for now. */
 
-long _sysconf (int name)
+long sysconf (int name)
 {
   switch (name)
Index: trunk/src/emx/src/lib/misc/syserr.c
===================================================================
--- trunk/src/emx/src/lib/misc/syserr.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/syserr.c	(revision 123)
@@ -1,5 +1,5 @@
 /* syserr.c (emx+gcc) -- Copyright (c) 1990-1998 by Eberhard Mattes */
 
-const char * const _sys_errlist[] =
+const char * const sys_errlist[] =
 {
   /*  0 EZERO          */ "Error 0",
@@ -72,3 +72,3 @@
 };
 
-const int _sys_nerr = sizeof (_sys_errlist) / sizeof (_sys_errlist[0]);
+const int sys_nerr = sizeof (sys_errlist) / sizeof (sys_errlist[0]);
Index: trunk/src/emx/src/lib/misc/syserrno.c
===================================================================
--- trunk/src/emx/src/lib/misc/syserrno.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/syserrno.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <emx/syscalls.h>
 
-int _syserrno (void)
+int syserrno (void)
 {
   return __syserrno ();
Index: trunk/src/emx/src/lib/misc/uflags.c
===================================================================
--- trunk/src/emx/src/lib/misc/uflags.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/uflags.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <emx/syscalls.h>
 
-int _uflags (int mask, int new_bits)
+int uflags (int mask, int new_bits)
 {
   return __uflags (mask, new_bits);
Index: trunk/src/emx/src/lib/misc/ulimit.c
===================================================================
--- trunk/src/emx/src/lib/misc/ulimit.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/ulimit.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-long _ulimit (int cmd, ...)
+long ulimit (int cmd, ...)
 {
   va_list arg_ptr;
Index: trunk/src/emx/src/lib/misc/uname.c
===================================================================
--- trunk/src/emx/src/lib/misc/uname.c	(revision 119)
+++ trunk/src/emx/src/lib/misc/uname.c	(revision 123)
@@ -9,18 +9,16 @@
 #define CHR(x)       (char)((x)+'0')
 
-int _uname (struct utsname *name)
+int uname (struct utsname *name)
 {
   char *host;
-  int dos;
 
-  dos = (_osmode == DOS_MODE && _osmajor < 10);
   host = getenv ("HOSTNAME");
   if (host == NULL)
     host = "standalone";
 
-  SET (sysname, (dos ? "MS-DOS" : "OS/2"));
+  SET (sysname, ("OS/2"));
   SET (nodename, host);
   SET (release, "1");
-  name->version[0] = (dos ? CHR (_osmajor) : CHR (_osmajor / 10));
+  name->version[0] = (CHR (_osmajor / 10));
   name->version[1] = '.';
   name->version[2] = CHR (_osminor / 10);
Index: trunk/src/emx/src/lib/moddef/moddef.smak
===================================================================
--- trunk/src/emx/src/lib/moddef/moddef.smak	(revision 119)
+++ trunk/src/emx/src/lib/moddef/moddef.smak	(revision 123)
@@ -2,5 +2,5 @@
 .MDESC	:= A library for working with .DEF files
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= moddef$A
 .TSRC	:= $(wildcard src/lib/moddef/*.c)
Index: trunk/src/emx/src/lib/omflib/omflib.smak
===================================================================
--- trunk/src/emx/src/lib/omflib/omflib.smak	(revision 119)
+++ trunk/src/emx/src/lib/omflib/omflib.smak	(revision 123)
@@ -2,5 +2,5 @@
 .MDESC	:= A library for reading/writing OMF object files
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= omflib$A
 .TSRC	:= $(wildcard src/lib/omflib/*.c)
Index: trunk/src/emx/src/lib/process/386/_errno.s
===================================================================
--- trunk/src/emx/src/lib/process/386/_errno.s	(revision 119)
+++ trunk/src/emx/src/lib/process/386/_errno.s	(revision 123)
@@ -14,6 +14,4 @@
 __errno:
 __errno_fun:
-        cmpb    $0, __osmode            /* _osmode == DOS_MODE? */
-        je      1f                      /* Yes -> */
         fs
         movl    12, %eax                /* ptib2 */
@@ -21,11 +19,5 @@
         movl    __thread_tab(,%eax,4), %eax
 /       addl    $0, %eax                /* address of errno */
-Lreturn:EPILOGUE(_errno)
-
-        ALIGN
-
-1:      movl    __thread_tab+4, %eax
-/       addl    $0, %eax                /* address of errno */
-        jmp     Lreturn
+        EPILOGUE(_errno)
 
 #else
Index: trunk/src/emx/src/lib/process/386/gettid.s
===================================================================
--- trunk/src/emx/src/lib/process/386/gettid.s	(revision 119)
+++ trunk/src/emx/src/lib/process/386/gettid.s	(revision 123)
@@ -10,12 +10,6 @@
 
 __gettid:
-        cmpb    $0, __osmode            /* _osmode == DOS_MODE? */
-        je      1f                      /* Yes -> */
         fs
         movl    12, %eax                /* ptib2 */
         movl    0(%eax), %eax           /* TID */
-Lreturn:EPILOGUE(_gettid)
-
-        ALIGN
-1:      movl    $1, %eax
-        jmp     Lreturn
+        EPILOGUE(_gettid)
Index: trunk/src/emx/src/lib/process/386/thread.s
===================================================================
--- trunk/src/emx/src/lib/process/386/thread.s	(revision 119)
+++ trunk/src/emx/src/lib/process/386/thread.s	(revision 123)
@@ -12,6 +12,4 @@
 
 __thread:
-        cmpb    $0, __osmode            /* _osmode == DOS_MODE? */
-        je      1f                      /* Yes -> */
         fs
         movl    12, %eax                /* ptib2 */
@@ -19,13 +17,9 @@
         movl    __thread_tab(,%edx,4), %eax
         testl   %eax, %eax
-        jz      2f
+        jz      1f
 Lreturn:EPILOGUE(_thread)
 
         ALIGN
-1:      movl    __thread_tab+4, %eax
-        jmp     Lreturn
-
-        ALIGN
-2:      pushl   %edx
+1:      pushl   %edx
         call    ___alloc_thread
         popl    %edx
Index: trunk/src/emx/src/lib/process/execl.c
===================================================================
--- trunk/src/emx/src/lib/process/execl.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execl.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _execl (const char *name, const char *arg0, ...)
+int execl (const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -14,5 +14,5 @@
   /* Note: Passing `arg_ptr' to spawnv() is not portable. */
 
-  result = _spawnv (P_OVERLAY, name, (char * const *)arg_ptr);
+  result = spawnv (P_OVERLAY, name, (char * const *)arg_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/execle.c
===================================================================
--- trunk/src/emx/src/lib/process/execle.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execle.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _execle (const char *name, const char *arg0, ...)
+int execle (const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -20,5 +20,5 @@
   /* Note: Passing `arg_ptr' to spawnve() is not portable. */
 
-  result = _spawnve (P_OVERLAY, name, (char * const *)arg_ptr, env_ptr);
+  result = spawnve (P_OVERLAY, name, (char * const *)arg_ptr, env_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/execlp.c
===================================================================
--- trunk/src/emx/src/lib/process/execlp.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execlp.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _execlp (const char *name, const char *arg0, ...)
+int execlp (const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -14,5 +14,5 @@
   /* Note: Passing `arg_ptr' to spawnvp() is not portable. */
 
-  result = _spawnvp (P_OVERLAY, name, (char * const *)arg_ptr);
+  result = spawnvp (P_OVERLAY, name, (char * const *)arg_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/execlpe.c
===================================================================
--- trunk/src/emx/src/lib/process/execlpe.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execlpe.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _execlpe (const char *name, const char *arg0, ...)
+int execlpe (const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -20,5 +20,5 @@
   /* Note: Passing `arg_ptr' to spawnvpe() is not portable. */
 
-  result = _spawnvpe (P_OVERLAY, name, (char * const *)arg_ptr, env_ptr);
+  result = spawnvpe (P_OVERLAY, name, (char * const *)arg_ptr, env_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/execv.c
===================================================================
--- trunk/src/emx/src/lib/process/execv.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execv.c	(revision 123)
@@ -3,6 +3,6 @@
 #include <process.h>
 
-int _execv (const char *name, char * const argv[])
+int execv (const char *name, char * const argv[])
 {
-  return _spawnv (P_OVERLAY, name, argv);
+  return spawnv (P_OVERLAY, name, argv);
 }
Index: trunk/src/emx/src/lib/process/execve.c
===================================================================
--- trunk/src/emx/src/lib/process/execve.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execve.c	(revision 123)
@@ -3,6 +3,6 @@
 #include <process.h>
 
-int _execve (const char *name, char * const argv[], char * const envp[])
+int execve (const char *name, char * const argv[], char * const envp[])
 {
-  return _spawnve (P_OVERLAY, name, argv, envp);
+  return spawnve (P_OVERLAY, name, argv, envp);
 }
Index: trunk/src/emx/src/lib/process/execvp.c
===================================================================
--- trunk/src/emx/src/lib/process/execvp.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execvp.c	(revision 123)
@@ -3,6 +3,6 @@
 #include <process.h>
 
-int _execvp (const char *name, char * const argv[])
+int execvp (const char *name, char * const argv[])
 {
-  return _spawnvp (P_OVERLAY, name, argv);
+  return spawnvp (P_OVERLAY, name, argv);
 }
Index: trunk/src/emx/src/lib/process/execvpe.c
===================================================================
--- trunk/src/emx/src/lib/process/execvpe.c	(revision 119)
+++ trunk/src/emx/src/lib/process/execvpe.c	(revision 123)
@@ -3,6 +3,6 @@
 #include <process.h>
 
-int _execvpe (const char *name, char * const argv[], char * const envp[])
+int execvpe (const char *name, char * const argv[], char * const envp[])
 {
-  return _spawnvpe (P_OVERLAY, name, argv, envp);
+  return spawnvpe (P_OVERLAY, name, argv, envp);
 }
Index: trunk/src/emx/src/lib/process/fmutex.c
===================================================================
--- trunk/src/emx/src/lib/process/fmutex.c	(revision 119)
+++ trunk/src/emx/src/lib/process/fmutex.c	(revision 123)
@@ -16,6 +16,4 @@
 {
   sem->fs = _FMS_AVAILABLE;
-  if (_osmode == DOS_MODE)
-    return 0;
   return DosCreateEventSem (NULL, (PHEV)&sem->hev,
                             (flags & _FMC_SHARED) ? DC_SEM_SHARED : 0,
@@ -26,6 +24,4 @@
 unsigned _fmutex_open (_fmutex *sem)
 {
-  if (_osmode == DOS_MODE)
-    return 0;
   return DosOpenEventSem (NULL, (PHEV)&sem->hev);
 }
@@ -34,6 +30,4 @@
 unsigned _fmutex_close (_fmutex *sem)
 {
-  if (_osmode == DOS_MODE)
-    return 0;
   return DosCloseEventSem (sem->hev);
 }
Index: trunk/src/emx/src/lib/process/fork.c
===================================================================
--- trunk/src/emx/src/lib/process/fork.c	(revision 119)
+++ trunk/src/emx/src/lib/process/fork.c	(revision 123)
@@ -6,5 +6,5 @@
 extern void _rmutex_fork (void);
 
-int _fork (void)
+int fork (void)
 {
   int pid;
Index: trunk/src/emx/src/lib/process/getpid.c
===================================================================
--- trunk/src/emx/src/lib/process/getpid.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* getpid.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <process.h>
-#include <emx/syscalls.h>
-
-int _getpid (void)
-{
-  return __getpid ();
-}
Index: trunk/src/emx/src/lib/process/getppid.c
===================================================================
--- trunk/src/emx/src/lib/process/getppid.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* getppid.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <process.h>
-#include <emx/syscalls.h>
-
-int _getppid (void)
-{
-  return __getppid ();
-}
Index: trunk/src/emx/src/lib/process/kill.c
===================================================================
--- trunk/src/emx/src/lib/process/kill.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* kill.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int _kill (int pid, int sig)
-{
-  return __kill (pid, sig);
-}
Index: trunk/src/emx/src/lib/process/pause.c
===================================================================
--- trunk/src/emx/src/lib/process/pause.c	(revision 119)
+++ 	(revision )
@@ -1,12 +1,0 @@
-/* pause.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <errno.h>
-#include <emx/syscalls.h>
-
-int _pause (void)
-{
-  __pause ();
-  errno = EINTR;
-  return -1;
-}
Index: trunk/src/emx/src/lib/process/profil.c
===================================================================
--- trunk/src/emx/src/lib/process/profil.c	(revision 119)
+++ 	(revision )
@@ -1,23 +1,0 @@
-/* profil.c (emx+gcc) -- Copyright (c) 1995-1996 by Eberhard Mattes */
-
-#include <stddef.h>
-#include <stdlib.h>
-#include <errno.h>
-#include <emx/syscalls.h>
-
-int _profil (void *buff, unsigned bufsiz, unsigned offset, unsigned scale)
-{
-  struct _profil data;
-
-  if (_osmode == OS2_MODE && *_threadid != 1)
-    {
-      errno = EINVAL;
-      return -1;
-    }
-  data.cb = sizeof (data);
-  data.buff = buff;
-  data.bufsiz = bufsiz;
-  data.offset = offset;
-  data.scale = scale;
-  return __profil (&data);
-}
Index: trunk/src/emx/src/lib/process/raise.c
===================================================================
--- trunk/src/emx/src/lib/process/raise.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* raise.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int raise (int sig)
-{
-  return __raise (sig);
-}
Index: trunk/src/emx/src/lib/process/sigactio.c
===================================================================
--- trunk/src/emx/src/lib/process/sigactio.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* sigactio.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int _sigaction (int sig, const struct sigaction *iact, struct sigaction *oact)
-{
-  return __sigaction (sig, iact, oact);
-}
Index: trunk/src/emx/src/lib/process/sigbsd.c
===================================================================
--- trunk/src/emx/src/lib/process/sigbsd.c	(revision 119)
+++ 	(revision )
@@ -1,10 +1,0 @@
-/* sigbsd.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <sys/uflags.h>
-
-static void sigbsd (void)
-{
-  _uflags (_UF_SIG_MODEL, _UF_SIG_BSD);
-}
-
-__asm__ ("\t.stabs \"___CTOR_LIST__\", 23, 0, 0, _sigbsd");
Index: trunk/src/emx/src/lib/process/signal.c
===================================================================
--- trunk/src/emx/src/lib/process/signal.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* signal.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-void (*signal (int sig, void (*handler)()))(int sig)
-{
-  return __signal (sig, handler);
-}
Index: trunk/src/emx/src/lib/process/sigpendi.c
===================================================================
--- trunk/src/emx/src/lib/process/sigpendi.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* sigpendi.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int _sigpending (sigset_t *set)
-{
-  return __sigpending (set);
-}
Index: trunk/src/emx/src/lib/process/sigprocm.c
===================================================================
--- trunk/src/emx/src/lib/process/sigprocm.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* sigprocm.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int _sigprocmask (int how, const sigset_t *iset, sigset_t *oset)
-{
-  return __sigprocmask (how, iset, oset);
-}
Index: trunk/src/emx/src/lib/process/sigsuspe.c
===================================================================
--- trunk/src/emx/src/lib/process/sigsuspe.c	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/* sigsuspe.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <signal.h>
-#include <emx/syscalls.h>
-
-int _sigsuspend (const sigset_t *mask)
-{
-  return __sigsuspend (mask);
-}
Index: trunk/src/emx/src/lib/process/sigsysv.c
===================================================================
--- trunk/src/emx/src/lib/process/sigsysv.c	(revision 119)
+++ 	(revision )
@@ -1,10 +1,0 @@
-/* sigsysv.c (emx+gcc) -- Copyright (c) 1994-1996 by Eberhard Mattes */
-
-#include <sys/uflags.h>
-
-static void sigsysv (void)
-{
-  _uflags (_UF_SIG_MODEL, _UF_SIG_SYSV);
-}
-
-__asm__ ("\t.stabs \"___CTOR_LIST__\", 23, 0, 0, _sigsysv");
Index: trunk/src/emx/src/lib/process/spawnl.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnl.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnl.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _spawnl (int mode, const char *name, const char *arg0, ...)
+int spawnl (int mode, const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -14,5 +14,5 @@
   /* Note: Passing `arg_ptr' to spawnv() is not portable. */
 
-  result = _spawnv (mode, name, (char * const *)arg_ptr);
+  result = spawnv (mode, name, (char * const *)arg_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/spawnle.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnle.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnle.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _spawnle (int mode, const char *name, const char *arg0, ...)
+int spawnle (int mode, const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -20,5 +20,5 @@
   /* Note: Passing `arg_ptr' to spawnve() is not portable. */
 
-  result = _spawnve (mode, name, (char * const *)arg_ptr, env_ptr);
+  result = spawnve (mode, name, (char * const *)arg_ptr, env_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/spawnlp.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnlp.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnlp.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _spawnlp (int mode, const char *name, const char *arg0, ...)
+int spawnlp (int mode, const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -14,5 +14,5 @@
   /* Note: Passing `arg_ptr' to spawnvp() is not portable. */
 
-  result = _spawnvp (mode, name, (char * const *)arg_ptr);
+  result = spawnvp (mode, name, (char * const *)arg_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/spawnlpe.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnlpe.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnlpe.c	(revision 123)
@@ -5,5 +5,5 @@
 #include <process.h>
 
-int _spawnlpe (int mode, const char *name, const char *arg0, ...)
+int spawnlpe (int mode, const char *name, const char *arg0, ...)
 {
   va_list arg_ptr;
@@ -20,5 +20,5 @@
   /* Note: Passing `arg_ptr' to spawnvpe() is not portable. */
 
-  result = _spawnvpe (mode, name, (char * const *)arg_ptr, env_ptr);
+  result = spawnvpe (mode, name, (char * const *)arg_ptr, env_ptr);
   va_end (arg_ptr);
   return result;
Index: trunk/src/emx/src/lib/process/spawnv.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnv.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnv.c	(revision 123)
@@ -4,6 +4,6 @@
 #include <process.h>
 
-int _spawnv (int mode, const char *name, char * const argv[])
+int spawnv (int mode, const char *name, char * const argv[])
 {
-  return _spawnve (mode, name, argv, NULL);
+  return spawnve (mode, name, argv, NULL);
 }
Index: trunk/src/emx/src/lib/process/spawnve.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnve.c	(revision 119)
+++ 	(revision )
@@ -1,71 +1,0 @@
-/* spawnve.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
-
-#include <stdlib.h>
-#include <string.h>
-#include <process.h>
-#include <errno.h>
-#include <emx/startup.h>
-#include <emx/syscalls.h>
-
-int _spawnve (int mode, const char *name, char * const argv[],
-              char * const envp[])
-{
-  struct _new_proc np;
-  int i, size, n;
-  const char * const *p;
-  char *d;
-  char exe[512];
-
-  /* Kludge alert: Unfortunately, the `mode' member was made only 16
-     bits wide originally.  Bit 15 is used to indicate that the
-     `mode2' member is used, which holds the upper 16 bits of MODE.
-     This allows using emx 0.8 applications with emx 0.9 as emx
-     doesn't look at `mode2' unless bit 15 of `mode' is set.  Of
-     course, this fails if an (old) application program sets bit 15 of
-     MODE. */
-
-  np.mode = (unsigned short)(mode | 0x8000);
-  np.mode2 = (unsigned short)((unsigned)mode >> 16);
-
-  if (envp == NULL) envp = _environ;
-  if (strlen (name) >= sizeof (exe) - 4)
-    {
-      errno = ENAMETOOLONG;
-      return -1;
-    }
-  strcpy (exe, name);
-  _defext (exe, "exe");
-  np.fname_off = (unsigned long)exe;
-  size = 1; n = 0;
-  for (p = (const char * const *)envp; *p != NULL; ++p)
-    {
-      ++n; size += 1 + strlen (*p);
-    }
-  d = alloca (size);
-  np.env_count = n; np.env_size = size;
-  np.env_off = (unsigned long)d;
-  for (p = (const char * const *)envp; *p != NULL; ++p)
-    {
-      i = strlen (*p);
-      memcpy (d, *p, i+1);
-      d += i+1;
-    }
-  *d = 0;
-  size = 0; n = 0;
-  for (p = (const char * const *)argv; *p != NULL; ++p)
-    {
-      ++n; size += 2 + strlen (*p);
-    }
-  d = alloca (size);
-  np.arg_count = n; np.arg_size = size;
-  np.arg_off = (unsigned long)d;
-  for (p = (const char * const *)argv; *p != NULL; ++p)
-    {
-      i = strlen (*p);
-      *d++ = _ARG_NONZERO;
-      memcpy (d, *p, i+1);
-      d += i+1;
-    }
-  i = __spawnve (&np);
-  return i;
-}
Index: trunk/src/emx/src/lib/process/spawnvp.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnvp.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnvp.c	(revision 123)
@@ -4,6 +4,6 @@
 #include <process.h>
 
-int _spawnvp (int mode, const char *name, char * const argv[])
+int spawnvp (int mode, const char *name, char * const argv[])
 {
-  return _spawnvpe (mode, name, argv, NULL);
+  return spawnvpe (mode, name, argv, NULL);
 }
Index: trunk/src/emx/src/lib/process/spawnvpe.c
===================================================================
--- trunk/src/emx/src/lib/process/spawnvpe.c	(revision 119)
+++ trunk/src/emx/src/lib/process/spawnvpe.c	(revision 123)
@@ -2,9 +2,10 @@
 
 #include <stdlib.h>
+#include <string.h>
 #include <process.h>
 #include <errno.h>
 
-int _spawnvpe (int mode, const char *name, char * const argv[],
-               char * const envp[])
+int spawnvpe (int mode, const char *name, char * const argv[],
+              char * const envp[])
 {
   char exe[512];
@@ -20,4 +21,4 @@
   if (_path (path, exe) != 0)
     return -1;
-  return _spawnve (mode, path, argv, envp);
+  return spawnve (mode, path, argv, envp);
 }
Index: trunk/src/emx/src/lib/process/system.c
===================================================================
--- trunk/src/emx/src/lib/process/system.c	(revision 119)
+++ trunk/src/emx/src/lib/process/system.c	(revision 123)
@@ -23,15 +23,16 @@
     return _access (sh, 0) == 0;
   if (*name == 0)
-    rc = _spawnlp (P_WAIT, sh, sh, (char *)0);
+    rc = spawnlp (P_WAIT, sh, sh, (char *)0);
   else
     {
       base = _getname (sh);
-      if (_stricmp (base, "cmd.exe") == 0 || _stricmp (base, "4os2.exe") == 0
-          || _stricmp (base, "command.com") == 0
-          || _stricmp (base, "4dos.com") == 0)
+      if (stricmp (base, "cmd.exe") == 0
+       || stricmp (base, "4os2.exe") == 0
+       || stricmp (base, "command.com") == 0
+       || stricmp (base, "4dos.com") == 0)
         opt = "/c";
       else
         opt = "-c";
-      rc = _spawnlp (P_WAIT, sh, sh, opt, name, (char *)0);
+      rc = spawnlp (P_WAIT, sh, sh, opt, name, (char *)0);
     }
   return rc;
Index: trunk/src/emx/src/lib/process/wait.c
===================================================================
--- trunk/src/emx/src/lib/process/wait.c	(revision 119)
+++ 	(revision )
@@ -1,15 +1,0 @@
-/* wait.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
-
-#include <stdlib.h>
-#include <process.h>
-#include <errno.h>
-#include <emx/syscalls.h>
-
-int _wait (int *status)
-{
-  int dummy;
-
-  if (status == NULL)
-    status = &dummy;
-  return __wait (status);
-}
Index: trunk/src/emx/src/lib/process/waitpid.c
===================================================================
--- trunk/src/emx/src/lib/process/waitpid.c	(revision 119)
+++ 	(revision )
@@ -1,15 +1,0 @@
-/* waitpid.c (emx+gcc) -- Copyright (c) 1993-1996 by Eberhard Mattes */
-
-#include <stdlib.h>
-#include <process.h>
-#include <errno.h>
-#include <emx/syscalls.h>
-
-int _waitpid (int pid, int *status, int options)
-{
-  int dummy;
-
-  if (status == NULL)
-    status = &dummy;
-  return __waitpid (pid, status, options);
-}
Index: trunk/src/emx/src/lib/startup/386/crt0.s
===================================================================
--- trunk/src/emx/src/lib/startup/386/crt0.s	(revision 119)
+++ trunk/src/emx/src/lib/startup/386/crt0.s	(revision 123)
@@ -13,17 +13,9 @@
 __text:
         push    $__data
-#if defined (OMF)
         call    __emx_init
-#else
-        call    __dos_init
-#endif
         jmp     __init
 
 ___syscall:
-#if defined (OMF)
         call    __emx_syscall
-#else
-        call    __dos_syscall
-#endif
         ret
 
@@ -55,19 +47,4 @@
 
 __data:
-#if defined (OMF)
-        .long   0
-        .long   0
-        .long   0
-        .long   0
-        .long   0
-        .long   0
-#else
-        .long   __text
-        .long   __etext
-        .long   __data
-        .long   __edata
-        .long   __edata
-        .long   __end
-#endif
 __heap_base:
         .long   0                       /* heap base address */
@@ -80,9 +57,5 @@
         .long   0                       /* stack base address */
         .long   0                       /* stack end address */
-#if defined (OMF)
         .long   0x02000002              /* flags: application, OMF */
-#else
-        .long   0x02000000              /* flags: application */
-#endif
         .long   0                       /* reserved */
         .long   0                       /* reserved */
@@ -92,10 +65,7 @@
 / first element of vector (N_SETA|N_EXT == 21)
 
-#if defined (OMF)
 __os2dll:
         .long   0, 0
-#else
-        .stabs  "__os2dll", 21, 0, 0, 0xffffffff
-#endif
+/       .stabs  "__os2dll", 21, 0, 0, 0xffffffff
 
         .stabs  "___CTOR_LIST__", 21, 0, 0, 0xffffffff
Index: trunk/src/emx/src/lib/startup/386/crt1.s
===================================================================
--- trunk/src/emx/src/lib/startup/386/crt1.s	(revision 119)
+++ trunk/src/emx/src/lib/startup/386/crt1.s	(revision 123)
@@ -14,5 +14,4 @@
         .globl  _errno
 #endif
-        .globl  __osmode
         .globl  __emx_env
         .globl  __emx_vcmp
@@ -37,6 +36,4 @@
         movl    %eax, __emx_vprt
         movb    $0, __emx_vprt+4
-        testl   $0x200, %edx
-        setne   __osmode
         EPILOGUE(_entry2)
 
@@ -46,5 +43,4 @@
 _errno: .long   0
 #endif
-__osmode:       .byte 1                         /* OS2_MODE = 1 */
         .comm   __emx_rev, 4
         .comm   __emx_env, 4
Index: trunk/src/emx/src/lib/startup/386/dll0.s
===================================================================
--- trunk/src/emx/src/lib/startup/386/dll0.s	(revision 119)
+++ trunk/src/emx/src/lib/startup/386/dll0.s	(revision 123)
@@ -13,18 +13,10 @@
 __text:
         push    $__data
-#if defined (OMF)
         call    __emx_init
-#else
-        call    __dos_init
-#endif
         jmp     __init
 
 
 ___syscall:
-#if defined (OMF)
         call    __emx_syscall
-#else
-        call    __dos_syscall
-#endif
         ret
 
@@ -61,9 +53,5 @@
         .long   0                       /* stack base address */
         .long   0                       /* stack end address */
-#if defined (OMF)
         .long   0x02000003              /* flags: DLL, OMF */
-#else
-        .long   0x02000001              /* flags: DLL */
-#endif
         .long   0                       /* reserved */
         .long   0                       /* reserved */
@@ -73,10 +61,7 @@
 / first element of vector (N_SETA|N_EXT == 21)
 
-#if defined (OMF)
 __os2dll:
         .long   0, 0
-#else
-        .stabs  "__os2dll", 21, 0, 0, 0xffffffff
-#endif
+/       .stabs  "__os2dll", 21, 0, 0, 0xffffffff
 
         .stabs  "___CTOR_LIST__", 21, 0, 0, 0xffffffff
Index: trunk/src/emx/src/lib/startup/386/res0.s
===================================================================
--- trunk/src/emx/src/lib/startup/386/res0.s	(revision 119)
+++ 	(revision )
@@ -1,9 +1,0 @@
-/ res0.s (emx+gcc) -- Copyright (c) 1993-1994 by Eberhard Mattes
-
-        .globl  __text
-
-        .text
-
-__text:
-        movl    $1, %eax
-        ret
Index: trunk/src/emx/src/lib/startup/ctor.c
===================================================================
--- trunk/src/emx/src/lib/startup/ctor.c	(revision 119)
+++ 	(revision )
@@ -1,30 +1,0 @@
-/* ctor.c (emx+gcc) -- Copyright (c) 1993-1998 by Eberhard Mattes */
-
-#include <stdlib.h>
-
-struct object
-{
-  void *pc_begin;
-  void *pc_end;
-  void *fde_begin;
-  void *fde_array;
-  size_t count;
-  struct object *next;
-};
-
-extern int __CTOR_LIST__, __eh_frame__;
-extern void __ctordtorInit1 (int *ptr);
-extern void __eh_frame_init (int *ptr, struct object *ob);
-
-void __ctordtorInit (void)
-{
-  static int done;
-  static struct object ob;
-
-  if (!done)
-    {
-      done = 1;
-      __eh_frame_init (&__eh_frame__, &ob);
-      __ctordtorInit1 (&__CTOR_LIST__);
-    }
-}
Index: trunk/src/emx/src/lib/startup/dtor.c
===================================================================
--- trunk/src/emx/src/lib/startup/dtor.c	(revision 119)
+++ 	(revision )
@@ -1,21 +1,0 @@
-/* dtor.c (emx+gcc) -- Copyright (c) 1993-1998 by Eberhard Mattes */
-
-extern int __DTOR_LIST__, __eh_frame__;
-extern void __ctordtorTerm1 (int *ptr);
-extern void __eh_frame_term (int *ptr);
-
-void __ctordtorTerm (void)
-{
-  static int done;
-
-  if (!done)
-    {
-      done = 1;
-      __ctordtorTerm1 (&__DTOR_LIST__);
-#if 0
-      /* OS/2 doesn't guarantee correct unloading sequence of DLLs,
-         therefore we cannot do this. */
-      __eh_frame_term (&__eh_frame__);
-#endif
-    }
-}
Index: trunk/src/emx/src/lib/startup/gmon.c
===================================================================
--- trunk/src/emx/src/lib/startup/gmon.c	(revision 119)
+++ trunk/src/emx/src/lib/startup/gmon.c	(revision 123)
@@ -32,31 +32,15 @@
  */
 
-#ifndef lint
-static char sccsid[] = "@(#)gmon.c	5.3 (Berkeley) 5/22/91";
-#endif /* not lint */
-
-#if 0
-#include <unistd.h>
-
-#endif
-#ifdef DEBUG
 #include <stdio.h>
-#endif
-
-#ifdef EMX
 #include <stdlib.h>
 #include <fcntl.h>
-#endif /* EMX */
+#include <unistd.h>
+#include <io.h>
 
 #include "gmon.h"
 
-#ifndef EMX
-extern mcount() asm ("mcount");
-extern char *minbrk asm ("minbrk");
-#endif /* not EMX */
-
-    /*
-     *	froms is actually a bunch of unsigned shorts indexing tos
-     */
+/*
+ *	froms is actually a bunch of unsigned shorts indexing tos
+ */
 static int		profiling = 3;
 static unsigned short	*froms;
@@ -70,9 +54,13 @@
 static char	*sbuf;
 static int	s_scale;
-    /* see profil(2) where this is describe (incorrectly) */
+/* see profil(2) where this is describe (incorrectly) */
 #define		SCALE_1_TO_1	0x10000L
 
 #define	MSG "No space for profiling buffer(s)\n"
 
+/* Forward definition */
+void moncontrol();
+
+void
 monstartup(lowpc, highpc)
     char	*lowpc;
@@ -119,7 +107,4 @@
 	return;
     }
-#ifndef EMX
-    minbrk = sbrk(0);
-#endif /* not EMX */
     tos[0].link = 0;
     sbuf = buffer;
@@ -133,20 +118,5 @@
     o = highpc - lowpc;
     if( monsize < o )
-#ifndef hp300
 	s_scale = ( (float) monsize / o ) * SCALE_1_TO_1;
-#else /* avoid floating point */
-    {
-	int quot = o / monsize;
-
-	if (quot >= 0x10000)
-		s_scale = 1;
-	else if (quot >= 0x100)
-		s_scale = 0x10000 / quot;
-	else if (o >= 0x800000)
-		s_scale = 0x1000000 / (o / (monsize >> 8));
-	else
-		s_scale = 0x1000000 / ((o << 8) / monsize);
-    }
-#endif
     else
 	s_scale = SCALE_1_TO_1;
@@ -154,4 +124,5 @@
 }
 
+void
 _mcleanup()
 {
@@ -164,15 +135,12 @@
 
     moncontrol(0);
-    fd = creat( "gmon.out" , 0666 );
-    if ( fd < 0 ) {
+    fd = open ("gmon.out" , O_WRONLY | O_TRUNC | O_CREAT | O_BINARY, 0666);
+    if (fd < 0) {
 	perror( "mcount: gmon.out" );
 	return;
     }
-#ifdef EMX
-    setmode (fd, O_BINARY);
-#endif /* EMX */
 #   ifdef DEBUG
 	fprintf( stderr , "[mcleanup] sbuf 0x%x ssiz %d\n" , sbuf , ssiz );
-#   endif DEBUG
+#   endif /* DEBUG */
     write( fd , sbuf , ssiz );
     endfrom = s_textsize / (HASHFRACTION * sizeof(*froms));
@@ -187,5 +155,5 @@
 			"[mcleanup] frompc 0x%x selfpc 0x%x count %d\n" ,
 			frompc , tos[toindex].selfpc , tos[toindex].count );
-#	    endif DEBUG
+#	    endif /* DEBUG */
 	    rawarc.raw_frompc = (unsigned long) frompc;
 	    rawarc.raw_selfpc = (unsigned long) tos[toindex].selfpc;
@@ -197,131 +165,127 @@
 }
 
-#ifdef EMX
+void
 _mcount()
-#else /* not EMX */
-mcount()
-#endif /* not EMX */
 {
-	register char			*selfpc;
-	register unsigned short		*frompcindex;
-	register struct tostruct	*top;
-	register struct tostruct	*prevtop;
-	register long			toindex;
-
+    register char *selfpc;
+    register unsigned short *frompcindex;
+    register struct tostruct *top;
+    register struct tostruct *prevtop;
+    register long toindex;
+
+    /*
+     *	find the return address for mcount,
+     *	and the return address for mcount's caller.
+     */
+
+    /* selfpc = pc pushed by mcount call.
+       This identifies the function that was just entered.  */
+    selfpc = (void *) __builtin_return_address (0);
+    /* frompcindex = pc in preceding frame.
+       This identifies the caller of the function just entered.  */
+    frompcindex = (void *) __builtin_return_address (1);
+    /*
+     *	check that we are profiling
+     *	and that we aren't recursively invoked.
+     */
+    if (profiling) {
+	goto out;
+    }
+
+    /* Profile thread 1 only. */
+    if (_gettid () != 1)
+	goto out;
+
+    profiling++;
+    /*
+     *	check that frompcindex is a reasonable pc value.
+     *	for example:	signal catchers get called from the stack,
+     *			not from text space.  too bad.
+     */
+    frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc);
+    if ((unsigned long)frompcindex > s_textsize) {
+	goto done;
+    }
+    frompcindex =
+	&froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
+    toindex = *frompcindex;
+    if (toindex == 0) {
 	/*
-	 *	find the return address for mcount,
-	 *	and the return address for mcount's caller.
+	 *	first time traversing this arc
 	 */
-
-	/* selfpc = pc pushed by mcount call.
-	   This identifies the function that was just entered.  */
-	selfpc = (void *) __builtin_return_address (0);
-	/* frompcindex = pc in preceding frame.
-	   This identifies the caller of the function just entered.  */
-	frompcindex = (void *) __builtin_return_address (1);
+	toindex = ++tos[0].link;
+	if (toindex >= tolimit) {
+	    goto overflow;
+	}
+	*frompcindex = toindex;
+	top = &tos[toindex];
+	top->selfpc = selfpc;
+	top->count = 1;
+	top->link = 0;
+	goto done;
+    }
+    top = &tos[toindex];
+    if (top->selfpc == selfpc) {
 	/*
-	 *	check that we are profiling
-	 *	and that we aren't recursively invoked.
+	 *	arc at front of chain; usual case.
 	 */
-	if (profiling) {
-		goto out;
-	}
-#ifdef EMX
-	/* Profile thread 1 only. */
-	if (_gettid () != 1)
-		goto out;
-#endif /* EMX */
-	profiling++;
+	top->count++;
+	goto done;
+    }
+    /*
+     *	have to go looking down chain for it.
+     *	top points to what we are looking at,
+     *	prevtop points to previous top.
+     *	we know it is not at the head of the chain.
+     */
+    for (; /* goto done */; ) {
+	if (top->link == 0) {
+	    /*
+	     *	top is end of the chain and none of the chain
+	     *	had top->selfpc == selfpc.
+	     *	so we allocate a new tostruct
+	     *	and link it to the head of the chain.
+	     */
+	    toindex = ++tos[0].link;
+	    if (toindex >= tolimit) {
+		goto overflow;
+	    }
+	    top = &tos[toindex];
+	    top->selfpc = selfpc;
+	    top->count = 1;
+	    top->link = *frompcindex;
+	    *frompcindex = toindex;
+	    goto done;
+	}
 	/*
-	 *	check that frompcindex is a reasonable pc value.
-	 *	for example:	signal catchers get called from the stack,
-	 *			not from text space.  too bad.
+	 *	otherwise, check the next arc on the chain.
 	 */
-	frompcindex = (unsigned short *)((long)frompcindex - (long)s_lowpc);
-	if ((unsigned long)frompcindex > s_textsize) {
-		goto done;
-	}
-	frompcindex =
-	    &froms[((long)frompcindex) / (HASHFRACTION * sizeof(*froms))];
-	toindex = *frompcindex;
-	if (toindex == 0) {
-		/*
-		 *	first time traversing this arc
-		 */
-		toindex = ++tos[0].link;
-		if (toindex >= tolimit) {
-			goto overflow;
-		}
-		*frompcindex = toindex;
-		top = &tos[toindex];
-		top->selfpc = selfpc;
-		top->count = 1;
-		top->link = 0;
-		goto done;
-	}
-	top = &tos[toindex];
+	prevtop = top;
+	top = &tos[top->link];
 	if (top->selfpc == selfpc) {
-		/*
-		 *	arc at front of chain; usual case.
-		 */
-		top->count++;
-		goto done;
-	}
-	/*
-	 *	have to go looking down chain for it.
-	 *	top points to what we are looking at,
-	 *	prevtop points to previous top.
-	 *	we know it is not at the head of the chain.
-	 */
-	for (; /* goto done */; ) {
-		if (top->link == 0) {
-			/*
-			 *	top is end of the chain and none of the chain
-			 *	had top->selfpc == selfpc.
-			 *	so we allocate a new tostruct
-			 *	and link it to the head of the chain.
-			 */
-			toindex = ++tos[0].link;
-			if (toindex >= tolimit) {
-				goto overflow;
-			}
-			top = &tos[toindex];
-			top->selfpc = selfpc;
-			top->count = 1;
-			top->link = *frompcindex;
-			*frompcindex = toindex;
-			goto done;
-		}
-		/*
-		 *	otherwise, check the next arc on the chain.
-		 */
-		prevtop = top;
-		top = &tos[top->link];
-		if (top->selfpc == selfpc) {
-			/*
-			 *	there it is.
-			 *	increment its count
-			 *	move it to the head of the chain.
-			 */
-			top->count++;
-			toindex = prevtop->link;
-			prevtop->link = top->link;
-			top->link = *frompcindex;
-			*frompcindex = toindex;
-			goto done;
-		}
-
-	}
+	    /*
+	     *	there it is.
+	     *	increment its count
+	     *	move it to the head of the chain.
+	     */
+	    top->count++;
+	    toindex = prevtop->link;
+	    prevtop->link = top->link;
+	    top->link = *frompcindex;
+	    *frompcindex = toindex;
+	    goto done;
+	}
+    }
 done:
-	profiling--;
-	/* and fall through */
+    profiling--;
+    /* and fall through */
 out:
-	return;		/* normal return restores saved registers */
+    return;		/* normal return restores saved registers */
 
 overflow:
-	profiling++; /* halt further profiling */
-#   define	TOLIMIT	"mcount: tos overflow\n"
-	write(2, TOLIMIT, sizeof(TOLIMIT));
-	goto out;
+    profiling++; /* halt further profiling */
+#define	TOLIMIT "mcount: tos overflow\n"
+    write(2, TOLIMIT, sizeof(TOLIMIT));
+    goto out;
 }
 
@@ -331,4 +295,5 @@
  *	all the data structures are ready.
  */
+void
 moncontrol(mode)
     int mode;
Index: trunk/src/emx/src/lib/str/memccpy.c
===================================================================
--- trunk/src/emx/src/lib/str/memccpy.c	(revision 119)
+++ trunk/src/emx/src/lib/str/memccpy.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <string.h>
 
-void *_memccpy (void *s1, const void *s2, int c, size_t n)
+void *memccpy (void *s1, const void *s2, int c, size_t n)
 {
   size_t i;
Index: trunk/src/emx/src/lib/str/memicmp.c
===================================================================
--- trunk/src/emx/src/lib/str/memicmp.c	(revision 119)
+++ trunk/src/emx/src/lib/str/memicmp.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <ctype.h>
 
-int _memicmp (const void *s1, const void *s2, size_t n)
+int memicmp (const void *s1, const void *s2, size_t n)
 {
   size_t i;
Index: trunk/src/emx/src/lib/str/strdup.c
===================================================================
--- trunk/src/emx/src/lib/str/strdup.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strdup.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <stdlib.h>
 
-char *_strdup (const char *string)
+char *strdup (const char *string)
 {
   char *p;
Index: trunk/src/emx/src/lib/str/strerror.c
===================================================================
--- trunk/src/emx/src/lib/str/strerror.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strerror.c	(revision 123)
@@ -19,5 +19,5 @@
 #endif
       memcpy (result, msg, sizeof (msg) - 1);
-      _itoa (errnum, result + sizeof (msg) - 1, 10);
+      itoa (errnum, result + sizeof (msg) - 1, 10);
       return result;
     }
Index: trunk/src/emx/src/lib/str/stricmp.c
===================================================================
--- trunk/src/emx/src/lib/str/stricmp.c	(revision 119)
+++ trunk/src/emx/src/lib/str/stricmp.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <ctype.h>
 
-int _stricmp (const char *string1, const char *string2)
+int stricmp (const char *string1, const char *string2)
 {
   int d;
Index: trunk/src/emx/src/lib/str/strlwr.c
===================================================================
--- trunk/src/emx/src/lib/str/strlwr.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strlwr.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <ctype.h>
 
-char *_strlwr (char *string)
+char *strlwr (char *string)
 {
   unsigned char *p;
@@ -10,5 +10,5 @@
   for (p = (unsigned char *)string; *p != 0; ++p)
     if (isupper (*p))
-      *p = (unsigned char)_tolower (*p);
+      *p = (unsigned char)tolower (*p);
   return string;
 }
Index: trunk/src/emx/src/lib/str/strnicmp.c
===================================================================
--- trunk/src/emx/src/lib/str/strnicmp.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strnicmp.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <ctype.h>
 
-int _strnicmp (const char *string1, const char *string2, size_t count)
+int strnicmp (const char *string1, const char *string2, size_t count)
 {
   int d;
Index: trunk/src/emx/src/lib/str/strnset.c
===================================================================
--- trunk/src/emx/src/lib/str/strnset.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strnset.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <string.h>
 
-char *_strnset (char *string, int c, size_t count)
+char *strnset (char *string, int c, size_t count)
 {
   char *dst;
Index: trunk/src/emx/src/lib/str/strrev.c
===================================================================
--- trunk/src/emx/src/lib/str/strrev.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strrev.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <string.h>
 
-char *_strrev (char *string)
+char *strrev (char *string)
 {
   char *p, *q, c;
Index: trunk/src/emx/src/lib/str/strset.c
===================================================================
--- trunk/src/emx/src/lib/str/strset.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strset.c	(revision 123)
@@ -3,5 +3,5 @@
 #include <string.h>
 
-char *_strset (char *string, int c)
+char *strset (char *string, int c)
 {
   char *dst;
Index: trunk/src/emx/src/lib/str/strtok.c
===================================================================
--- trunk/src/emx/src/lib/str/strtok.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strtok.c	(revision 123)
@@ -12,5 +12,5 @@
 #define next (tp->_th_strtok_ptr)
 #else
-    static unsigned char *next = NULL;
+  static unsigned char *next = NULL;
 #endif
   if (string1 != NULL)
Index: trunk/src/emx/src/lib/str/strupr.c
===================================================================
--- trunk/src/emx/src/lib/str/strupr.c	(revision 119)
+++ trunk/src/emx/src/lib/str/strupr.c	(revision 123)
@@ -4,5 +4,5 @@
 #include <ctype.h>
 
-char *_strupr (char *string)
+char *strupr (char *string)
 {
   unsigned char *p;
@@ -10,5 +10,5 @@
   for (p = (unsigned char *)string; *p != 0; ++p)
     if (islower (*p))
-      *p = (unsigned char)_toupper (*p);
+      *p = (unsigned char)toupper (*p);
   return string;
 }
Index: trunk/src/emx/src/lib/sys/386/thunk0.asm
===================================================================
--- trunk/src/emx/src/lib/sys/386/thunk0.asm	(revision 119)
+++ 	(revision )
@@ -1,34 +1,0 @@
-; thunk0.asm (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
-
-                .386
-
-                .MODEL  FLAT
-
-                PUBLIC  _emx_16to32
-                PUBLIC  _emx_32to16
-
-TEXT32          SEGMENT DWORD PUBLIC FLAT 'CODE'
-
-                EXTRN   DosFlatToSel:PROC
-                EXTRN   DosSelToFlat:PROC
-;
-;
-;
-                ALIGN  4
-_emx_32to16     PROC
-                MOV     EAX, [ESP+4]
-                JMP     DosFlatToSel
-_emx_32to16     ENDP
-
-;
-;
-;
-                ALIGN  4
-_emx_16to32     PROC
-                MOV     EAX, [ESP+4]
-                JMP     DosSelToFlat
-_emx_16to32     ENDP
-
-TEXT32          ENDS
-
-                END
Index: trunk/src/emx/src/lib/sys/386/thunk0.s
===================================================================
--- trunk/src/emx/src/lib/sys/386/thunk0.s	(revision 123)
+++ trunk/src/emx/src/lib/sys/386/thunk0.s	(revision 123)
@@ -0,0 +1,12 @@
+/ thunk0.asm (emx+gcc) -- Copyright (c) 1992-1993 by Eberhard Mattes
+
+		.globl  __emx_16to32
+                .globl  __emx_32to16
+
+		.p2align 2
+__emx_32to16:	movl	4(%esp),%eax
+		jmp	_DosFlatToSel
+
+		.p2align 2
+__emx_16to32:	movl	4(%esp),%eax
+		jmp	_DosSelToFlat
Index: trunk/src/emx/src/lib/sys/386/thunk1.asm
===================================================================
--- trunk/src/emx/src/lib/sys/386/thunk1.asm	(revision 119)
+++ 	(revision )
@@ -1,168 +1,0 @@
-; thunk1.asm (emx+gcc) -- Copyright (c) 1992-1994 by Eberhard Mattes
-
-                .386
-
-                .MODEL  FLAT
-
-                PUBLIC  _emx_thunk1
-
-TEXT32          SEGMENT DWORD PUBLIC FLAT 'CODE'
-
-;
-; unsigned long _emx_thunk1 (void *args, void *fun)
-;
-; Call 16-bit code
-;
-; In:   ARGS    Pointer to argument list. The first DWORD contains the
-;               number of argument bytes, excluding that DWORD. The
-;               remaining values are packed appropriately for calling
-;               a 16-bit function. Pointers have been converted to
-;               sel:offset format
-;
-;       FUN     16:16 address of 16-bit function to be called. Both
-;               `pascal' and `cdecl' calling conventions are supported.
-;               The function must not change the DI register
-;
-; Out:  EAX     Return value (DX:AX) of 16-bit function
-;
-; Stack on entry (1):
-;
-;       ...
-;       FUN
-;       ARGS
-; ESP-> return address
-; ---------------------------------------------------------------------------
-;
-; Stack after setting up stack frame (2):
-;
-;       ...
-;       FUN
-;       ARGS
-;       return address
-; EBP-> caller's EBP
-;       caller's ESI
-;       caller's EDI
-;       caller's EBX
-;       caller's ES
-; ---------------------------------------------------------------------------
-;
-; Stack before jumping to 16-bit code (3):
-;
-;       ...
-;       FUN
-;       ARGS
-;       return address
-; EBP-> caller's EBP
-;       caller's ESI
-;       caller's EDI
-;       caller's EBX
-;       caller's ES
-;       padding                                 (0 to 1000H-4 bytes)
-; DI->  SS:ESP -> caller's EBP                  (2 DWORDs, DWORD-aligned)
-; SP->  arguments                               (WORD aligned)
-; ---------------------------------------------------------------------------
-;
-; Stack after return from 16-bit code (4):
-;
-;       ...
-;       FUN
-;       ARGS
-;       return address
-;       caller's EBP
-;       caller's ESI
-;       caller's EDI
-;       caller's EBX
-;       caller's ES
-;       padding                                 (0 to 1000H-4 bytes)
-; DI->  SS:ESP -> caller's EBP                  (2 DWORDs, DWORD-aligned)
-; SP->  arguments                               (for cdecl functions)
-; ---------------------------------------------------------------------------
-;
-                ALIGN  4
-ARGS            EQU     (DWORD PTR [EBP+2*4])
-FUN             EQU     (DWORD PTR [EBP+3*4])
-_emx_thunk1     PROC                            ; (1)
-                PUSH    EBP                     ; Set up stack frame
-                MOV     EBP, ESP
-                PUSH    ESI                     ; Save ESI
-                PUSH    EDI                     ; Save EDI
-                PUSH    EBX                     ; Save EBX
-                PUSH    ES                      ; (2) Save ES
-                MOV     DX, SS                  ; Prepare conversion of
-                AND     DL, 3                   ; ESP to SS:SP
-                OR      DL, 4                   ; LDT
-                MOV     EAX, ESP                ; Check stack
-                CMP     AX, 1000H               ; 1000H bytes left in this 64K
-                JAE     SHORT THUNK1_1          ; segment? Yes => skip
-                XOR     AX, AX                  ; Move ESP down to next 64K seg
-                MOV     BYTE PTR [EAX], 0       ; Stack probe
-                XCHG    ESP, EAX                ; Set new ESP, EAX := old ESP
-THUNK1_1:       PUSH    SS                      ; Save original SS:ESP on
-                PUSH    EAX                     ; stack (points to saved EBX)
-;
-; Copy arguments
-;
-                MOV     ESI, ARGS
-                LODSD
-                MOV     ECX, EAX
-                SUB     ESP, ECX
-                MOV     EDI, ESP
-                SHR     ECX, 2
-                REP     MOVSD
-                MOV     ECX, EAX
-                AND     ECX, 03H
-                REP     MOVSB                   ; EDI now points to SS:ESP
-                LEA     ESI, FUN
-;
-; Convert ESP to SS:SP
-;
-                MOV     EAX, ESP
-                ROL     EAX, 16
-                SHL     AX, 3
-                OR      AL, DL
-                PUSH    EAX                     ; Push new SS
-                SHR     EAX, 16
-                PUSH    EAX                     ; Push new ESP
-                LSS     ESP, [ESP]              ; Switch to new SS:SP
-                JMP     FAR PTR TEXT16:THUNK16_CALL ; (3)
-;
-; Jump to 16-bit code
-;
-                RETF
-
-                ALIGN  4
-THUNK1_RET::    MOVZX   ESP, DI                 ; (4) Remove arguments
-                LSS     ESP, [ESP]              ; Get 32-bit stack pointer
-                POP     ES                      ; Restore ES
-                POP     EBX                     ; Restore EBX
-                POP     EDI                     ; Restore EDI
-                POP     ESI                     ; Restore ESI
-                POP     EBP                     ; Restore EBP
-                MOVZX   EAX, AX                 ; Compute return value
-                MOVZX   EDX, DX
-                SHL     EDX, 16
-                OR      EAX, EDX
-                RET                             ; Return to 32-bit code
-
-_emx_thunk1     ENDP
-
-TEXT32          ENDS
-
-;
-;
-;
-
-TEXT16          SEGMENT DWORD PUBLIC USE16 'CODE'
-
-;
-; Call 16-bit function
-;
-; In:    ESI    Points to 16:16 function address
-;
-                ALIGN  4
-THUNK16_CALL:   CALL    DWORD PTR [ESI]
-                JMP     FAR PTR FLAT:THUNK1_RET
-
-TEXT16          ENDS
-
-                END
Index: trunk/src/emx/src/lib/sys/386/thunk1.s
===================================================================
--- trunk/src/emx/src/lib/sys/386/thunk1.s	(revision 123)
+++ trunk/src/emx/src/lib/sys/386/thunk1.s	(revision 123)
@@ -0,0 +1,126 @@
+/ thunk1.asm (emx+gcc) -- Copyright (c) 1992-1994 by Eberhard Mattes
+
+		.globl	__emx_thunk1
+
+/
+/ unsigned long _emx_thunk1 (void *args, void *fun)
+/
+/ Call 16-bit code
+/
+/ In:   ARGS    Pointer to argument list. The first DWORD contains the
+/               number of argument bytes, excluding that DWORD. The
+/               remaining values are packed appropriately for calling
+/               a 16-bit function. Pointers have been converted to
+/               sel:offset format
+/
+/       FUN     16:16 address of 16-bit function to be called. Both
+/               `pascal' and `cdecl' calling conventions are supported.
+/               The function must not change the DI register
+/
+/ Out:  EAX     Return value (DX:AX) of 16-bit function
+/
+		.p2align 2
+
+		.set	ARGS, 4*4		# Offset to ARGS relative to %ebp
+		.set	FUN, 5*4		# Offset to FUN relative to %ebp
+		.set	RETADDR, -4*4		# Offset to spare space relative to FUN
+
+__emx_thunk1:	pushl	%ebp			# Leave two dwords spare
+		pushl	%ebp			# space for 32-bit return address
+		pushl	%ebp			# Set up stack frame
+		movl	%esp, %ebp
+		pushl	%esi			# Save %esi
+		pushl	%edi			# Save %edi
+		pushl	%ebx			# Save %ebx
+		pushl	%es			# (2) Save %es
+/		movw	%ss, %dx		# Prepare conversion of
+/		andb	$3, %dl			# %esp to %ss:%sp
+/		orb	$4, %dl			# LDT
+		movl	%esp, %eax		# Check	stack
+		cmpw	$0x1000, %ax 		# 1000H	bytes left in this 64K
+		jae	1f			# segment? Yes => skip
+		xorw	%ax, %ax		# Move %esp down to next 64K seg
+		movb	$0, (%eax)		# Stack	probe
+		xchgl	%esp, %eax		# Set new %esp, %eax := old %esp
+1:		pushl	%ss			# Save original	%ss:%esp on
+		pushl	%eax			# stack	(points	to saved %ebx)
+/
+/ Copy arguments
+/
+		movl	ARGS(%ebp), %esi
+		lodsl
+		movl	%eax, %ecx
+		subl	%ecx, %esp
+		movl	%esp, %edi
+		shrl	$2, %ecx
+		repne
+		movsl
+		movl	%eax, %ecx
+		andl	$3, %ecx
+		repne
+		movsb				# %edi now points to %ss:%esp
+		leal	FUN(%ebp), %esi
+/
+/ Convert %eip to %cs:%ip and %esp to %ss:%sp
+/
+		movw	%cs, RETADDR+4(%esi)
+		movl	$Lthunk1_ret, RETADDR(%esi)
+
+		movl	$Lthunk16_call, %eax
+		call	_DosFlatToSel
+		movzwl	%ax, %ecx		# %ecx = offset
+		shrl	$16, %eax		# %eax = segment
+		pushl	%eax
+		pushl	%ecx
+
+		movl	%esp, %eax
+		call	_DosFlatToSel
+		movzwl	%ax, %ecx		# %ecx = offset
+		shrl	$16, %eax		# %eax = segment
+		pushl	%eax
+		pushl	%ecx
+
+/
+/ Jump to 16-bit code
+/
+		lss	(%esp), %esp		# Switch to new	%ss:%sp
+		lret
+
+/
+/ Call 16-bit function
+/
+/ In:	 %esi	Points to 16:16	function address
+/ Note:  Actually this is 16-bit code. It is put inside the 32-bit code
+/        since a.out format does not support 16-bit segments.
+/
+		.p2align 2
+Lthunk16_call:
+/		lcall	*(%esi)
+		.byte	0x67,0xff,0x1e
+/		ljmp	*RETADDR(%esi)
+		.byte	0x67,0x66,0xff,0x6e,RETADDR
+
+/		movl	%esp, %eax
+/		roll	$16, %eax
+/		shlw	$3, %ax
+/		orb	%dl, %al
+/		pushl	%eax			# Push new %ss
+/		shrl	$16, %eax
+/		pushl	%eax			# Push new %esp
+/		lss	(%esp), %esp		# Switch to new	%ss:%sp
+/		jmpl	FAR PTR	TEXT16:THUNK16_CALL ; (3)
+
+		.p2align 2
+Lthunk1_ret:	movzwl	%di, %esp		# (4) Remove arguments
+		lss	(%esp),%esp		# Get 32-bit stack pointer
+		popl	%es			# Restore %es
+		popl	%ebx			# Restore %ebx
+		popl	%edi			# Restore %edi
+		popl	%esi			# Restore %esi
+		popl	%ebp			# Restore %ebp
+		addl	$4*2,%esp		# Skip spare space
+		movzwl	%ax, %eax		# Compute return value
+		movzwl	%dx, %edx
+		shll	$16, %edx
+		orl	%edx, %eax
+		ret				# Return to 32-bit code
Index: trunk/src/emx/src/lib/sys/__ftime.c
===================================================================
--- trunk/src/emx/src/lib/sys/__ftime.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/__ftime.c	(revision 123)
@@ -21,5 +21,5 @@
   tm.tm_year = now.year - 1900;
   tm.tm_isdst = -1;             /* unknown */
-  ptr->time = (time_t)_mktime (&tm);
+  ptr->time = (time_t)mktime (&tm);
   ptr->millitm = now.hundredths * 10;
   ptr->timezone = now.timezone;
Index: trunk/src/emx/src/lib/sys/__getdrive.c
===================================================================
--- trunk/src/emx/src/lib/sys/__getdrive.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/__getdrive.c	(revision 123)
@@ -19,3 +19,2 @@
     }
 }
-
Index: trunk/src/emx/src/lib/sys/__init.c
===================================================================
--- trunk/src/emx/src/lib/sys/__init.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/__init.c	(revision 123)
@@ -4,4 +4,5 @@
 #include <os2emx.h>
 #include <string.h>
+#include <alloca.h>
 #include <sys/builtin.h>
 #include <sys/fmutex.h>
Index: trunk/src/emx/src/lib/sys/__mkdir.c
===================================================================
--- trunk/src/emx/src/lib/sys/__mkdir.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/__mkdir.c	(revision 123)
@@ -4,5 +4,4 @@
 #include <emx/syscalls.h>
 #include "syscalls.h"
-
 
 int __mkdir (const char *name)
Index: trunk/src/emx/src/lib/sys/__rmdir.c
===================================================================
--- trunk/src/emx/src/lib/sys/__rmdir.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/__rmdir.c	(revision 123)
@@ -4,5 +4,4 @@
 #include <emx/syscalls.h>
 #include "syscalls.h"
-
 
 int __rmdir (const char *name)
Index: trunk/src/emx/src/lib/sys/__spawnve.c
===================================================================
--- trunk/src/emx/src/lib/sys/__spawnve.c	(revision 123)
+++ trunk/src/emx/src/lib/sys/__spawnve.c	(revision 123)
@@ -0,0 +1,164 @@
+/* sys/spawnve.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+
+#include <stdlib.h>
+#include <string.h>
+#include <process.h>
+#include <errno.h>
+#include <alloca.h>
+#define INCL_DOSPROCESS
+#include <os2emx.h>
+#include <emx/syscalls.h>
+#include "syscalls.h"
+
+/* Note: We are allowed to call _trealloc() as this module is not used
+   in an .a library. */
+
+#define ADD(n) do { \
+  while (arg_size + n > arg_alloc) \
+    { \
+      arg_alloc += 512; \
+      arg_buf = _trealloc (arg_buf, arg_alloc); \
+      if (arg_buf == NULL) \
+        { \
+          errno = ENOMEM; \
+          return -1; \
+        } \
+      arg_ptr = arg_buf + arg_size; \
+    } \
+  arg_size += n; } while (0)
+
+
+int ___spawnve (struct _new_proc *np)
+{
+  ULONG rc;
+  ULONG exec_flag, mode;
+  RESULTCODES res;
+  char obj[40], *arg_ptr, *arg_buf;
+  char *pgm_name, *base;
+  const char *src, *s;
+  size_t arg_size, arg_alloc, len;
+  int i, quote, bs, method;
+
+  arg_buf = NULL; arg_alloc = 0; arg_size = 0; arg_ptr = NULL;
+
+  mode = np->mode;
+  if (np->mode & 0x8000)
+    mode |= np->mode2 << 16;
+
+  switch (mode & 0xff)
+    {
+    case P_WAIT:
+      exec_flag = EXEC_SYNC;
+      break;
+    case P_NOWAIT:
+      exec_flag = EXEC_ASYNCRESULT;
+      break;
+    case P_OVERLAY:
+      exec_flag = EXEC_ASYNC;
+      break;
+    default:
+      errno = EINVAL;
+      return -1;
+    }
+  pgm_name = alloca (strlen ((const char *)np->fname_off) + 5);
+  strcpy (pgm_name, (const char *)np->fname_off);
+  _defext (pgm_name, "exe");
+  base = _getname (pgm_name);
+  method = 0;
+  if (stricmp (base, "cmd.exe") == 0 || stricmp (base, "4os2.exe") == 0)
+    method = 1;
+  src = (const char *)np->arg_off;
+  if (np->arg_count > 0)
+    {
+      ++src;                    /* skip flags byte */
+      len = strlen (src) + 1;
+      ADD (len);
+      memcpy (arg_ptr, src, len);
+      arg_ptr += len; src += len;
+    }
+  for (i = 1; i < np->arg_count; ++i)
+    {
+      if (i > 1)
+        {
+          ADD (1);
+          *arg_ptr++ = ' ';
+        }
+      ++src;                    /* skip flags byte */
+      quote = FALSE;
+      if (*src == 0)
+        quote = TRUE;
+      else if (mode & P_QUOTE)
+        {
+          if (src[0] == '@' && src[1] != 0)
+            quote = TRUE;
+          else
+            for (s = src; *s != 0; ++s)
+              if (*s == '?' || *s == '*')
+                {
+                  quote = TRUE;
+                  break;
+                }
+        }
+      if (!quote)
+        for (s = src; *s != 0; ++s)
+          if (*s == ' ' || *s == '\t' || (*s == '"' && method == 1))
+            {
+              quote = TRUE;
+              break;
+            }
+      if (quote)
+        {
+          ADD (1);
+          *arg_ptr++ = '"';
+        }
+      bs = 0;
+      while (*src != 0)
+        {
+          if (*src == '"' && method == 0)
+            {
+              ++bs;
+              ADD (bs);
+              memset (arg_ptr, '\\', bs); arg_ptr += bs;
+              bs = 0;
+            }
+          else if (*src == '\\' && method == 0)
+            ++bs;
+          else
+            bs = 0;
+          ADD (1);
+          *arg_ptr++ = *src;
+          ++src;
+        }
+      if (quote)
+        {
+          ADD (1+bs);
+          memset (arg_ptr, '\\', bs); arg_ptr += bs;
+          *arg_ptr++ = '"';
+        }
+      ++src;
+    }
+  ADD (1);
+  *arg_ptr++ = 0;
+  rc = DosExecPgm (obj, sizeof (obj), exec_flag, arg_buf,
+                   (const char *)np->env_off, &res, pgm_name);
+  if (arg_buf != NULL)
+    _tfree (arg_buf);
+  if (rc != 0)
+    {
+      _sys_set_errno (rc);
+      return -1;
+    }
+  switch (mode & 0xff)
+    {
+    case P_WAIT:
+      return res.codeResult;
+    case P_NOWAIT:
+      return res.codeTerminate;
+    case P_OVERLAY:
+      while (1)
+        DosExit (EXIT_PROCESS, 0);
+    default:
+      errno = EINVAL;
+      return -1;
+    }
+}
Index: trunk/src/emx/src/lib/sys/filesys.c
===================================================================
--- trunk/src/emx/src/lib/sys/filesys.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/filesys.c	(revision 123)
@@ -4,4 +4,5 @@
 #include <errno.h>
 #include <os2emx.h>
+#include <alloca.h>
 #include <emx/syscalls.h>
 #include "syscalls.h"
Index: trunk/src/emx/src/lib/sys/p2t.c
===================================================================
--- trunk/src/emx/src/lib/sys/p2t.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/p2t.c	(revision 123)
@@ -18,4 +18,4 @@
   tm.tm_year = d.year + 1980 - 1900;
   tm.tm_isdst = -1;             /* unknown */
-  return _mktime (&tm);
+  return mktime (&tm);
 }
Index: trunk/src/emx/src/lib/sys/pause.c
===================================================================
--- trunk/src/emx/src/lib/sys/pause.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/pause.c	(revision 123)
@@ -4,9 +4,12 @@
 #include <os2emx.h>
 #include <emx/syscalls.h>
+#include <errno.h>
 #include "syscalls.h"
 
-void __pause (void)
+int pause (void)
 {
   while (DosSleep (0xffffffff) == 0)
     ;
+  errno = EINTR;
+  return -1;
 }
Index: trunk/src/emx/src/lib/sys/sigaction.c
===================================================================
--- trunk/src/emx/src/lib/sys/sigaction.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/sigaction.c	(revision 123)
@@ -6,5 +6,4 @@
 #include <emx/syscalls.h>
 #include "syscalls.h"
-
 
 int __sigaction (int signo, const struct sigaction *iact,
Index: trunk/src/emx/src/lib/sys/spawnve.c
===================================================================
--- trunk/src/emx/src/lib/sys/spawnve.c	(revision 119)
+++ trunk/src/emx/src/lib/sys/spawnve.c	(revision 123)
@@ -1,3 +1,3 @@
-/* sys/spawnve.c (emx+gcc) -- Copyright (c) 1992-1996 by Eberhard Mattes */
+/* spawnve.c (emx+gcc) -- Copyright (c) 1990-1996 by Eberhard Mattes */
 
 #include <stdlib.h>
@@ -5,159 +5,68 @@
 #include <process.h>
 #include <errno.h>
-#define INCL_DOSPROCESS
-#include <os2emx.h>
+#include <alloca.h>
+#include <emx/startup.h>
 #include <emx/syscalls.h>
-#include "syscalls.h"
 
-/* Note: We are allowed to call _trealloc() as this module is not used
-   in an .a library. */
+int spawnve (int mode, const char *name, char * const argv[],
+               char * const envp[])
+{
+  struct _new_proc np;
+  int i, size, n;
+  const char * const *p;
+  char *d;
+  char exe[512];
 
-#define ADD(n) do { \
-  while (arg_size + n > arg_alloc) \
-    { \
-      arg_alloc += 512; \
-      arg_buf = _trealloc (arg_buf, arg_alloc); \
-      if (arg_buf == NULL) \
-        { \
-          errno = ENOMEM; \
-          return -1; \
-        } \
-      arg_ptr = arg_buf + arg_size; \
-    } \
-  arg_size += n; } while (0)
+  /* Kludge alert: Unfortunately, the `mode' member was made only 16
+     bits wide originally.  Bit 15 is used to indicate that the
+     `mode2' member is used, which holds the upper 16 bits of MODE.
+     This allows using emx 0.8 applications with emx 0.9 as emx
+     doesn't look at `mode2' unless bit 15 of `mode' is set.  Of
+     course, this fails if an (old) application program sets bit 15 of
+     MODE. */
 
+  np.mode = (unsigned short)(mode | 0x8000);
+  np.mode2 = (unsigned short)((unsigned)mode >> 16);
 
-int __spawnve (struct _new_proc *np)
-{
-  ULONG rc;
-  ULONG exec_flag, mode;
-  RESULTCODES res;
-  char obj[40], *arg_ptr, *arg_buf;
-  char *pgm_name, *base;
-  const char *src, *s;
-  size_t arg_size, arg_alloc, len;
-  int i, quote, bs, method;
-
-  arg_buf = NULL; arg_alloc = 0; arg_size = 0; arg_ptr = NULL;
-
-  mode = np->mode;
-  if (np->mode & 0x8000)
-    mode |= np->mode2 << 16;
-
-  switch (mode & 0xff)
+  if (envp == NULL) envp = _environ;
+  if (strlen (name) >= sizeof (exe) - 4)
     {
-    case P_WAIT:
-      exec_flag = EXEC_SYNC;
-      break;
-    case P_NOWAIT:
-      exec_flag = EXEC_ASYNCRESULT;
-      break;
-    case P_OVERLAY:
-      exec_flag = EXEC_ASYNC;
-      break;
-    default:
-      errno = EINVAL;
+      errno = ENAMETOOLONG;
       return -1;
     }
-  pgm_name = alloca (strlen ((const char *)np->fname_off) + 5);
-  strcpy (pgm_name, (const char *)np->fname_off);
-  _defext (pgm_name, "exe");
-  base = _getname (pgm_name);
-  method = 0;
-  if (stricmp (base, "cmd.exe") == 0 || stricmp (base, "4os2.exe") == 0)
-    method = 1;
-  src = (const char *)np->arg_off;
-  if (np->arg_count > 0)
+  strcpy (exe, name);
+  _defext (exe, "exe");
+  np.fname_off = (unsigned long)exe;
+  size = 1; n = 0;
+  for (p = (const char * const *)envp; *p != NULL; ++p)
     {
-      ++src;                    /* skip flags byte */
-      len = strlen (src) + 1;
-      ADD (len);
-      memcpy (arg_ptr, src, len);
-      arg_ptr += len; src += len;
+      ++n; size += 1 + strlen (*p);
     }
-  for (i = 1; i < np->arg_count; ++i)
+  d = alloca (size);
+  np.env_count = n; np.env_size = size;
+  np.env_off = (unsigned long)d;
+  for (p = (const char * const *)envp; *p != NULL; ++p)
     {
-      if (i > 1)
-        {
-          ADD (1);
-          *arg_ptr++ = ' ';
-        }
-      ++src;                    /* skip flags byte */
-      quote = FALSE;
-      if (*src == 0)
-        quote = TRUE;
-      else if (mode & P_QUOTE)
-        {
-          if (src[0] == '@' && src[1] != 0)
-            quote = TRUE;
-          else
-            for (s = src; *s != 0; ++s)
-              if (*s == '?' || *s == '*')
-                {
-                  quote = TRUE;
-                  break;
-                }
-        }
-      if (!quote)
-        for (s = src; *s != 0; ++s)
-          if (*s == ' ' || *s == '\t' || (*s == '"' && method == 1))
-            {
-              quote = TRUE;
-              break;
-            }
-      if (quote)
-        {
-          ADD (1);
-          *arg_ptr++ = '"';
-        }
-      bs = 0;
-      while (*src != 0)
-        {
-          if (*src == '"' && method == 0)
-            {
-              ++bs;
-              ADD (bs);
-              memset (arg_ptr, '\\', bs); arg_ptr += bs;
-              bs = 0;
-            }
-          else if (*src == '\\' && method == 0)
-            ++bs;
-          else
-            bs = 0;
-          ADD (1);
-          *arg_ptr++ = *src;
-          ++src;
-        }
-      if (quote)
-        {
-          ADD (1+bs);
-          memset (arg_ptr, '\\', bs); arg_ptr += bs;
-          *arg_ptr++ = '"';
-        }
-      ++src;
+      i = strlen (*p);
+      memcpy (d, *p, i+1);
+      d += i+1;
     }
-  ADD (1);
-  *arg_ptr++ = 0;
-  rc = DosExecPgm (obj, sizeof (obj), exec_flag, arg_buf,
-                   (const char *)np->env_off, &res, pgm_name);
-  if (arg_buf != NULL)
-    _tfree (arg_buf);
-  if (rc != 0)
+  *d = 0;
+  size = 0; n = 0;
+  for (p = (const char * const *)argv; *p != NULL; ++p)
     {
-      _sys_set_errno (rc);
-      return -1;
+      ++n; size += 2 + strlen (*p);
     }
-  switch (mode & 0xff)
+  d = alloca (size);
+  np.arg_count = n; np.arg_size = size;
+  np.arg_off = (unsigned long)d;
+  for (p = (const char * const *)argv; *p != NULL; ++p)
     {
-    case P_WAIT:
-      return res.codeResult;
-    case P_NOWAIT:
-      return res.codeTerminate;
-    case P_OVERLAY:
-      while (1)
-        DosExit (EXIT_PROCESS, 0);
-    default:
-      errno = EINVAL;
-      return -1;
+      i = strlen (*p);
+      *d++ = _ARG_NONZERO;
+      memcpy (d, *p, i+1);
+      d += i+1;
     }
+  i = __spawnve (&np);
+  return i;
 }
Index: trunk/src/emx/src/lib/sys/sys.smak
===================================================================
--- trunk/src/emx/src/lib/sys/sys.smak	(revision 123)
+++ trunk/src/emx/src/lib/sys/sys.smak	(revision 123)
@@ -0,0 +1,18 @@
+# Build two kinds of library: aout and aout-profile.
+# The OMF libraries will be derived from them.
+
+.MODULE	:= sys
+.MDESC	:= System-dependent libc backend
+
+.TKIND	:= aout
+.TARGET	:= sys$A
+.TSRC.386 := $(wildcard src/lib/sys/386/*.s)
+.TSRC	:= $(wildcard src/lib/sys/*.c)
+.TCF.src/lib/sys/heapsize.c := -DHEAPSIZE=0x2000000
+.INSDIR	= lib/
+.TKEEP	:= 1
+include mklib.smak
+
+.TKIND	:= aout prof
+.TARGET	:= sys_p$A
+include mklib.smak
Index: trunk/src/emx/src/lib/sys/syscalls.h
===================================================================
--- trunk/src/emx/src/lib/sys/syscalls.h	(revision 119)
+++ trunk/src/emx/src/lib/sys/syscalls.h	(revision 123)
@@ -52,10 +52,10 @@
    While this variable is NULL, no memory has been allocated. */
 
-struct heap_obj *_sys_top_heap_obj;
+EXTERN struct heap_obj *_sys_top_heap_obj;
 
 /* This array holds information on all the heap objects.  The heap
    objects are managed in LIFO fashion. */
 
-struct heap_obj _sys_heap_objs[MAX_HEAP_OBJS];
+EXTERN struct heap_obj _sys_heap_objs[MAX_HEAP_OBJS];
 
 /* This is the number of heap objects. */
Index: trunk/src/emx/src/lib/time/ftime.c
===================================================================
--- trunk/src/emx/src/lib/time/ftime.c	(revision 119)
+++ trunk/src/emx/src/lib/time/ftime.c	(revision 123)
@@ -6,9 +6,9 @@
 #include <emx/syscalls.h>
 
-void _ftime (struct timeb *ptr)
+void ftime (struct timeb *ptr)
 {
   time_t t_loc;
 
-  if (!_tzset_flag) _tzset ();
+  if (!_tzset_flag) tzset ();
   __ftime (ptr);
   t_loc = ptr->time;
Index: trunk/src/emx/src/lib/time/gettimeo.c
===================================================================
--- trunk/src/emx/src/lib/time/gettimeo.c	(revision 119)
+++ trunk/src/emx/src/lib/time/gettimeo.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-int _gettimeofday (struct timeval *tp, struct timezone *tzp)
+int gettimeofday (struct timeval *tp, struct timezone *tzp)
 {
   struct timeb tb;
Index: trunk/src/emx/src/lib/time/localtim.c
===================================================================
--- trunk/src/emx/src/lib/time/localtim.c	(revision 119)
+++ trunk/src/emx/src/lib/time/localtim.c	(revision 123)
@@ -22,5 +22,5 @@
   struct tm *p;
 
-  if (!_tzset_flag) _tzset ();
+  if (!_tzset_flag) tzset ();
   lt = *t;
   isdst = _gmt2loc (&lt);
Index: trunk/src/emx/src/lib/time/mktime.c
===================================================================
--- trunk/src/emx/src/lib/time/mktime.c	(revision 119)
+++ trunk/src/emx/src/lib/time/mktime.c	(revision 123)
@@ -11,7 +11,7 @@
   int dst;
 
-  if (!_tzset_flag) _tzset ();
+  if (!_tzset_flag) tzset ();
 
-  /* _mktime() requires that tm_mon is in range.  The other members
+  /* mktime() requires that tm_mon is in range.  The other members
      are not restricted. */
 
Index: trunk/src/emx/src/lib/time/settimeo.c
===================================================================
--- trunk/src/emx/src/lib/time/settimeo.c	(revision 119)
+++ trunk/src/emx/src/lib/time/settimeo.c	(revision 123)
@@ -7,5 +7,5 @@
 #include <emx/syscalls.h>
 
-int _settimeofday (const struct timeval *tp, const struct timezone *tzp)
+int settimeofday (const struct timeval *tp, const struct timezone *tzp)
 {
   struct timeval local;
@@ -17,5 +17,5 @@
       return -1;
     }
-  if (!_tzset_flag) _tzset ();
+  if (!_tzset_flag) tzset ();
   t = tp->tv_sec;
   local.tv_sec = _gmt2loc (&t);
Index: trunk/src/emx/src/lib/time/strptime.c
===================================================================
--- trunk/src/emx/src/lib/time/strptime.c	(revision 119)
+++ trunk/src/emx/src/lib/time/strptime.c	(revision 123)
@@ -265,5 +265,5 @@
 
 
-char *_strptime (const char *buf, const char *format, struct tm *tm)
+char *strptime (const char *buf, const char *format, struct tm *tm)
 {
   return (char *)parse_fmt ((const unsigned char *)buf,
Index: trunk/src/emx/src/lib/time/time.c
===================================================================
--- trunk/src/emx/src/lib/time/time.c	(revision 119)
+++ trunk/src/emx/src/lib/time/time.c	(revision 123)
@@ -8,5 +8,5 @@
   struct timeb tb;
 
-  _ftime (&tb);
+  ftime (&tb);
   if (t != NULL) *t = tb.time;
   return tb.time;
Index: trunk/src/emx/src/lib/time/times.c
===================================================================
--- trunk/src/emx/src/lib/time/times.c	(revision 119)
+++ trunk/src/emx/src/lib/time/times.c	(revision 123)
@@ -7,5 +7,5 @@
 /* Note: return value overflows */
 
-long _times (struct tms *buffer)
+long times (struct tms *buffer)
 {
   struct timeval tv;
@@ -15,5 +15,5 @@
   buffer->tms_cutime = 0;
   buffer->tms_cstime = 0;
-  if (_gettimeofday (&tv, NULL) != 0)
+  if (gettimeofday (&tv, NULL) != 0)
     return -1;
   return CLK_TCK * tv.tv_sec + (CLK_TCK * tv.tv_usec) / 1000000;
Index: trunk/src/emx/src/lib/time/tzset.c
===================================================================
--- trunk/src/emx/src/lib/time/tzset.c	(revision 119)
+++ trunk/src/emx/src/lib/time/tzset.c	(revision 123)
@@ -105,5 +105,5 @@
 
 
-void _tzset (void)
+void tzset (void)
 {
   struct _tzinfo ntz;
Index: trunk/src/emx/src/libend/end.smak
===================================================================
--- trunk/src/emx/src/libend/end.smak	(revision 119)
+++ trunk/src/emx/src/libend/end.smak	(revision 123)
@@ -2,12 +2,8 @@
 .MDESC	:= The C runtime library that should be linked last
 
-.TKIND	:= omf st
+.TKIND	:= omf
 .TARGET	:= end$A
 .TSRC.386 := $(wildcard src/lib/end/386/*.asm)
 .TSRC	:= $(.TSRC.$(CPU))
 .INSDIR	= lib/
-.TKEEP	:= 1
 include mklib.smak
-
-.TKIND	:= omf mt
-include mklib.smak
Index: trunk/src/emx/src/libmoddef/moddef.smak
===================================================================
--- trunk/src/emx/src/libmoddef/moddef.smak	(revision 119)
+++ trunk/src/emx/src/libmoddef/moddef.smak	(revision 123)
@@ -2,5 +2,5 @@
 .MDESC	:= A library for working with .DEF files
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= moddef$A
 .TSRC	:= $(wildcard src/lib/moddef/*.c)
Index: trunk/src/emx/src/libomflib/omflib.smak
===================================================================
--- trunk/src/emx/src/libomflib/omflib.smak	(revision 119)
+++ trunk/src/emx/src/libomflib/omflib.smak	(revision 123)
@@ -2,5 +2,5 @@
 .MDESC	:= A library for reading/writing OMF object files
 
-.TKIND	:= aout st
+.TKIND	:= aout
 .TARGET	:= omflib$A
 .TSRC	:= $(wildcard src/lib/omflib/*.c)
Index: trunk/src/emx/src/regexp/regexp.smak
===================================================================
--- trunk/src/emx/src/regexp/regexp.smak	(revision 119)
+++ trunk/src/emx/src/regexp/regexp.smak	(revision 123)
@@ -3,5 +3,5 @@
 .INSDIR := lib/
 
-.TARGET := regexp.a
+.TARGET := regexp$A
 .TSRC   := $(wildcard src/regexp/*.c)
 include mklib.smak
