From 1fd5e000ace55b323124c7e556a7a864b972a5c4 Mon Sep 17 00:00:00 2001 From: Christopher Faylor Date: Thu, 17 Feb 2000 19:38:33 +0000 Subject: import winsup-2000-02-17 snapshot --- winsup/mingw/CRT_noglob.c | 17 + winsup/mingw/CRTfmode.c | 20 + winsup/mingw/CRTglob.c | 18 + winsup/mingw/CRTinit.c | 32 + winsup/mingw/ChangeLog | 430 ++++++ winsup/mingw/Makefile.in | 265 ++++ winsup/mingw/configure | 2169 ++++++++++++++++++++++++++++ winsup/mingw/configure.in | 143 ++ winsup/mingw/crt1.c | 234 +++ winsup/mingw/crtdll.def | 704 +++++++++ winsup/mingw/crtmt.c | 14 + winsup/mingw/crtst.c | 12 + winsup/mingw/ctype_old.c | 52 + winsup/mingw/dllcrt1.c | 89 ++ winsup/mingw/dllmain.c | 33 + winsup/mingw/gccmain.c | 85 ++ winsup/mingw/include/_mingw.h | 68 + winsup/mingw/include/assert.h | 71 + winsup/mingw/include/conio.h | 74 + winsup/mingw/include/ctype.h | 153 ++ winsup/mingw/include/dir.h | 26 + winsup/mingw/include/direct.h | 96 ++ winsup/mingw/include/dirent.h | 96 ++ winsup/mingw/include/dos.h | 123 ++ winsup/mingw/include/errno.h | 117 ++ winsup/mingw/include/excpt.h | 123 ++ winsup/mingw/include/fcntl.h | 135 ++ winsup/mingw/include/float.h | 219 +++ winsup/mingw/include/io.h | 258 ++++ winsup/mingw/include/limits.h | 110 ++ winsup/mingw/include/locale.h | 91 ++ winsup/mingw/include/malloc.h | 78 + winsup/mingw/include/math.h | 182 +++ winsup/mingw/include/mem.h | 8 + winsup/mingw/include/memory.h | 9 + winsup/mingw/include/process.h | 158 ++ winsup/mingw/include/setjmp.h | 72 + winsup/mingw/include/share.h | 44 + winsup/mingw/include/signal.h | 111 ++ winsup/mingw/include/stdarg.h | 109 ++ winsup/mingw/include/stddef.h | 373 +++++ winsup/mingw/include/stdio.h | 373 +++++ winsup/mingw/include/stdlib.h | 386 +++++ winsup/mingw/include/string.h | 197 +++ winsup/mingw/include/sys/fcntl.h | 8 + winsup/mingw/include/sys/file.h | 9 + winsup/mingw/include/sys/locking.h | 52 + winsup/mingw/include/sys/stat.h | 175 +++ winsup/mingw/include/sys/time.h | 3 + winsup/mingw/include/sys/timeb.h | 82 ++ winsup/mingw/include/sys/types.h | 118 ++ winsup/mingw/include/sys/unistd.h | 9 + winsup/mingw/include/sys/utime.h | 89 ++ winsup/mingw/include/tchar.h | 261 ++++ winsup/mingw/include/time.h | 219 +++ winsup/mingw/include/unistd.h | 10 + winsup/mingw/include/values.h | 4 + winsup/mingw/include/varargs.h | 98 ++ winsup/mingw/include/wchar.h | 212 +++ winsup/mingw/include/wctype.h | 99 ++ winsup/mingw/init.c | 84 ++ winsup/mingw/jamfile | 72 + winsup/mingw/main.c | 96 ++ winsup/mingw/moldname-crtdll.def | 135 ++ winsup/mingw/moldname-msvcrt.def | 139 ++ winsup/mingw/moldname.def | 137 ++ winsup/mingw/moldname.def.in | 139 ++ winsup/mingw/msvcrt.def | 737 ++++++++++ winsup/mingw/msvcrt20.def | 719 +++++++++ winsup/mingw/msvcrt40.def | 676 +++++++++ winsup/mingw/mthr.c | 206 +++ winsup/mingw/mthr_init.c | 76 + winsup/mingw/mthr_stub.c | 37 + winsup/mingw/profile/Makefile.in | 119 ++ winsup/mingw/profile/configure | 1037 +++++++++++++ winsup/mingw/profile/configure.in | 77 + winsup/mingw/profile/gcrt0.c | 52 + winsup/mingw/profile/gmon.c | 284 ++++ winsup/mingw/profile/gmon.h | 178 +++ winsup/mingw/profile/mcount.c | 180 +++ winsup/mingw/profile/profil.c | 185 +++ winsup/mingw/profile/profil.h | 49 + winsup/mingw/profile/profile.h | 63 + winsup/mingw/readme.txt | 685 +++++++++ winsup/mingw/samples/dirent/jamfile | 3 + winsup/mingw/samples/dirent/test.c | 91 ++ winsup/mingw/samples/dlltest/dll.c | 22 + winsup/mingw/samples/dlltest/dll.def | 3 + winsup/mingw/samples/dlltest/dll.h | 4 + winsup/mingw/samples/dlltest/exe.c | 23 + winsup/mingw/samples/dlltest/exe.exp | 8 + winsup/mingw/samples/dlltest/expexe.c | 17 + winsup/mingw/samples/dlltest/expexe.def | 2 + winsup/mingw/samples/dlltest/jamfile | 46 + winsup/mingw/samples/dlltest/loaddll.c | 40 + winsup/mingw/samples/dlltest/loadexe.c | 47 + winsup/mingw/samples/dlltest/readme.txt | 39 + winsup/mingw/samples/dlltest/silly.cpp | 55 + winsup/mingw/samples/dlltest/silly.def | 11 + winsup/mingw/samples/dlltest/silly.exp | 8 + winsup/mingw/samples/dlltest/silly.h | 27 + winsup/mingw/samples/dlltest/sillydll.cpp | 107 ++ winsup/mingw/samples/filehand/filehand.c | 57 + winsup/mingw/samples/filehand/jamfile | 3 + winsup/mingw/samples/filehand/junk.txt | 1 + winsup/mingw/samples/fixargv/fixargv.c | 290 ++++ winsup/mingw/samples/fixargv/fixargv.h | 24 + winsup/mingw/samples/fixargv/readme.txt | 85 ++ winsup/mingw/samples/fmode/all.c | 46 + winsup/mingw/samples/fmode/jamfile | 5 + winsup/mingw/samples/fmode/readme.txt | 5 + winsup/mingw/samples/fmode/test.c | 31 + winsup/mingw/samples/globbing/glob.c | 20 + winsup/mingw/samples/globbing/jamfile | 11 + winsup/mingw/samples/globbing/noglob.c | 22 + winsup/mingw/samples/globbing/readme.txt | 14 + winsup/mingw/samples/print/jamfile | 9 + winsup/mingw/samples/print/prntest.c | 65 + winsup/mingw/samples/seh/eh3.c | 112 ++ winsup/mingw/samples/seh/exutil.c | 68 + winsup/mingw/samples/seh/exutil.def | 3 + winsup/mingw/samples/seh/exutil.h | 23 + winsup/mingw/samples/seh/jamfile | 13 + winsup/mingw/samples/seh/sehfix.c | 60 + winsup/mingw/samples/seh/sehsub.c | 43 + winsup/mingw/samples/seh/sehtest.c | 72 + winsup/mingw/samples/simpledll/dll.c | 33 + winsup/mingw/samples/simpledll/dll.cpp | 44 + winsup/mingw/samples/simpledll/dll.def | 2 + winsup/mingw/samples/simpledll/exe.c | 13 + winsup/mingw/samples/simpledll/jamfile | 14 + winsup/mingw/samples/simpledll/makedll.bat | 23 + winsup/mingw/samples/test/jamfile | 9 + winsup/mingw/samples/test/test.c | 20 + winsup/mingw/samples/wintest/jamfile | 8 + winsup/mingw/samples/wintest/test.c | 212 +++ winsup/mingw/string_old.c | 47 + 137 files changed, 17847 insertions(+) create mode 100644 winsup/mingw/CRT_noglob.c create mode 100644 winsup/mingw/CRTfmode.c create mode 100644 winsup/mingw/CRTglob.c create mode 100644 winsup/mingw/CRTinit.c create mode 100644 winsup/mingw/ChangeLog create mode 100644 winsup/mingw/Makefile.in create mode 100755 winsup/mingw/configure create mode 100644 winsup/mingw/configure.in create mode 100644 winsup/mingw/crt1.c create mode 100644 winsup/mingw/crtdll.def create mode 100644 winsup/mingw/crtmt.c create mode 100644 winsup/mingw/crtst.c create mode 100644 winsup/mingw/ctype_old.c create mode 100644 winsup/mingw/dllcrt1.c create mode 100644 winsup/mingw/dllmain.c create mode 100644 winsup/mingw/gccmain.c create mode 100644 winsup/mingw/include/_mingw.h create mode 100644 winsup/mingw/include/assert.h create mode 100644 winsup/mingw/include/conio.h create mode 100644 winsup/mingw/include/ctype.h create mode 100644 winsup/mingw/include/dir.h create mode 100644 winsup/mingw/include/direct.h create mode 100644 winsup/mingw/include/dirent.h create mode 100644 winsup/mingw/include/dos.h create mode 100644 winsup/mingw/include/errno.h create mode 100644 winsup/mingw/include/excpt.h create mode 100644 winsup/mingw/include/fcntl.h create mode 100644 winsup/mingw/include/float.h create mode 100644 winsup/mingw/include/io.h create mode 100644 winsup/mingw/include/limits.h create mode 100644 winsup/mingw/include/locale.h create mode 100644 winsup/mingw/include/malloc.h create mode 100644 winsup/mingw/include/math.h create mode 100644 winsup/mingw/include/mem.h create mode 100644 winsup/mingw/include/memory.h create mode 100644 winsup/mingw/include/process.h create mode 100644 winsup/mingw/include/setjmp.h create mode 100644 winsup/mingw/include/share.h create mode 100644 winsup/mingw/include/signal.h create mode 100644 winsup/mingw/include/stdarg.h create mode 100644 winsup/mingw/include/stddef.h create mode 100644 winsup/mingw/include/stdio.h create mode 100644 winsup/mingw/include/stdlib.h create mode 100644 winsup/mingw/include/string.h create mode 100644 winsup/mingw/include/sys/fcntl.h create mode 100644 winsup/mingw/include/sys/file.h create mode 100644 winsup/mingw/include/sys/locking.h create mode 100644 winsup/mingw/include/sys/stat.h create mode 100644 winsup/mingw/include/sys/time.h create mode 100644 winsup/mingw/include/sys/timeb.h create mode 100644 winsup/mingw/include/sys/types.h create mode 100644 winsup/mingw/include/sys/unistd.h create mode 100644 winsup/mingw/include/sys/utime.h create mode 100644 winsup/mingw/include/tchar.h create mode 100644 winsup/mingw/include/time.h create mode 100644 winsup/mingw/include/unistd.h create mode 100644 winsup/mingw/include/values.h create mode 100644 winsup/mingw/include/varargs.h create mode 100644 winsup/mingw/include/wchar.h create mode 100644 winsup/mingw/include/wctype.h create mode 100644 winsup/mingw/init.c create mode 100644 winsup/mingw/jamfile create mode 100644 winsup/mingw/main.c create mode 100644 winsup/mingw/moldname-crtdll.def create mode 100644 winsup/mingw/moldname-msvcrt.def create mode 100644 winsup/mingw/moldname.def create mode 100644 winsup/mingw/moldname.def.in create mode 100644 winsup/mingw/msvcrt.def create mode 100644 winsup/mingw/msvcrt20.def create mode 100644 winsup/mingw/msvcrt40.def create mode 100644 winsup/mingw/mthr.c create mode 100644 winsup/mingw/mthr_init.c create mode 100644 winsup/mingw/mthr_stub.c create mode 100644 winsup/mingw/profile/Makefile.in create mode 100755 winsup/mingw/profile/configure create mode 100644 winsup/mingw/profile/configure.in create mode 100644 winsup/mingw/profile/gcrt0.c create mode 100644 winsup/mingw/profile/gmon.c create mode 100644 winsup/mingw/profile/gmon.h create mode 100644 winsup/mingw/profile/mcount.c create mode 100644 winsup/mingw/profile/profil.c create mode 100644 winsup/mingw/profile/profil.h create mode 100644 winsup/mingw/profile/profile.h create mode 100644 winsup/mingw/readme.txt create mode 100644 winsup/mingw/samples/dirent/jamfile create mode 100644 winsup/mingw/samples/dirent/test.c create mode 100644 winsup/mingw/samples/dlltest/dll.c create mode 100644 winsup/mingw/samples/dlltest/dll.def create mode 100644 winsup/mingw/samples/dlltest/dll.h create mode 100644 winsup/mingw/samples/dlltest/exe.c create mode 100644 winsup/mingw/samples/dlltest/exe.exp create mode 100644 winsup/mingw/samples/dlltest/expexe.c create mode 100644 winsup/mingw/samples/dlltest/expexe.def create mode 100644 winsup/mingw/samples/dlltest/jamfile create mode 100644 winsup/mingw/samples/dlltest/loaddll.c create mode 100644 winsup/mingw/samples/dlltest/loadexe.c create mode 100644 winsup/mingw/samples/dlltest/readme.txt create mode 100644 winsup/mingw/samples/dlltest/silly.cpp create mode 100644 winsup/mingw/samples/dlltest/silly.def create mode 100644 winsup/mingw/samples/dlltest/silly.exp create mode 100644 winsup/mingw/samples/dlltest/silly.h create mode 100644 winsup/mingw/samples/dlltest/sillydll.cpp create mode 100644 winsup/mingw/samples/filehand/filehand.c create mode 100644 winsup/mingw/samples/filehand/jamfile create mode 100644 winsup/mingw/samples/filehand/junk.txt create mode 100644 winsup/mingw/samples/fixargv/fixargv.c create mode 100644 winsup/mingw/samples/fixargv/fixargv.h create mode 100644 winsup/mingw/samples/fixargv/readme.txt create mode 100644 winsup/mingw/samples/fmode/all.c create mode 100644 winsup/mingw/samples/fmode/jamfile create mode 100644 winsup/mingw/samples/fmode/readme.txt create mode 100644 winsup/mingw/samples/fmode/test.c create mode 100644 winsup/mingw/samples/globbing/glob.c create mode 100644 winsup/mingw/samples/globbing/jamfile create mode 100644 winsup/mingw/samples/globbing/noglob.c create mode 100644 winsup/mingw/samples/globbing/readme.txt create mode 100644 winsup/mingw/samples/print/jamfile create mode 100644 winsup/mingw/samples/print/prntest.c create mode 100644 winsup/mingw/samples/seh/eh3.c create mode 100644 winsup/mingw/samples/seh/exutil.c create mode 100644 winsup/mingw/samples/seh/exutil.def create mode 100644 winsup/mingw/samples/seh/exutil.h create mode 100644 winsup/mingw/samples/seh/jamfile create mode 100644 winsup/mingw/samples/seh/sehfix.c create mode 100644 winsup/mingw/samples/seh/sehsub.c create mode 100644 winsup/mingw/samples/seh/sehtest.c create mode 100644 winsup/mingw/samples/simpledll/dll.c create mode 100644 winsup/mingw/samples/simpledll/dll.cpp create mode 100644 winsup/mingw/samples/simpledll/dll.def create mode 100644 winsup/mingw/samples/simpledll/exe.c create mode 100644 winsup/mingw/samples/simpledll/jamfile create mode 100644 winsup/mingw/samples/simpledll/makedll.bat create mode 100644 winsup/mingw/samples/test/jamfile create mode 100644 winsup/mingw/samples/test/test.c create mode 100644 winsup/mingw/samples/wintest/jamfile create mode 100644 winsup/mingw/samples/wintest/test.c create mode 100644 winsup/mingw/string_old.c (limited to 'winsup/mingw') diff --git a/winsup/mingw/CRT_noglob.c b/winsup/mingw/CRT_noglob.c new file mode 100644 index 000000000..442820cd8 --- /dev/null +++ b/winsup/mingw/CRT_noglob.c @@ -0,0 +1,17 @@ +/* + * noglob.c + * + * This file defines _CRT_glob to have a value of 0, which will + * turn off command line globbing. It is compiled into a separate object + * file which you can add to your link line to turn off globbing like + * this: + * + * gcc -o foo.exe foo.o noglob.o + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +int _CRT_glob = 0; diff --git a/winsup/mingw/CRTfmode.c b/winsup/mingw/CRTfmode.c new file mode 100644 index 000000000..d0db222f0 --- /dev/null +++ b/winsup/mingw/CRTfmode.c @@ -0,0 +1,20 @@ +/* + * CRTfmode.c + * + * Sets _CRT_fmode to be zero, which will cause _mingw32_init_fmode to leave + * all file modes in their default state (basically text mode). + * + * This file is part of the Mingw32 package. + * + * THIS FILE IS IN THE PUBLIC DOMAIN. + * + * Contributers: + * Created by Colin Peters + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +unsigned int _CRT_fmode = 0; diff --git a/winsup/mingw/CRTglob.c b/winsup/mingw/CRTglob.c new file mode 100644 index 000000000..09f858146 --- /dev/null +++ b/winsup/mingw/CRTglob.c @@ -0,0 +1,18 @@ +/* + * CRTglob.c + * + * This object file defines _CRT_glob to have a value of -1, which will + * turn on command line globbing by default. If you want to turn off + * command line globbing include a line + * + * int _CRT_glob = 0; + * + * in one of your source modules. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +int _CRT_glob = -1; diff --git a/winsup/mingw/CRTinit.c b/winsup/mingw/CRTinit.c new file mode 100644 index 000000000..fa0e7ba1f --- /dev/null +++ b/winsup/mingw/CRTinit.c @@ -0,0 +1,32 @@ +/* + * CRTinit.c + * + * A dummy version of _CRT_INIT for MS compatibility. Programs, or more often + * dlls, which use the static version of the MSVC run time are supposed to + * call _CRT_INIT to initialize the run time library in DllMain. This does + * not appear to be necessary when using crtdll or the dll versions of the + * MSVC runtime, so the dummy call simply does nothing. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +void +_CRT_INIT () +{ +} diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog new file mode 100644 index 000000000..347918343 --- /dev/null +++ b/winsup/mingw/ChangeLog @@ -0,0 +1,430 @@ +2000-02-03 Mumit Khan + + * Snapshot 2000-02-03. + + * include/{assert.h, conio.h, ctype.h, direct.h, dirent.h, fcntl.h, + float.h, io.h, locale.h, malloc.h, math.h, process.h, signal.h, + stdio.h, stdlib.h, string.h, time.h, wctype.h, sys/stat.h, + sys/timeb.h, sys/utime.h}: Remove parameter names to avoid namespace + pollution. + + * Makefile.in (all): Build CRT0S first. + (libmingwthrd.a): Remove thread support DLL from dependency. + +2000-01-21 Mumit Khan + + * Snapshot 2000-01-21. + +2000-01-20 Mumit Khan + + Merge in changes from Cygwin: + * configure.in (HEADER_SUBDIRS): New variable. Substitute. + (SUBDIRS): Likewise. + * Makefile.in (HEADER_SUBDIRS): New variable. + (install): Use to install Mingw headers to a subdirectory if building + under Cygwin. + (DLL_CC_STUFF): Add DLL entry point. + * configure: Regenerate. + +2000-01-19 Mumit Khan + + * include/stdio.h (fsetpos): Fix prototype. + (fpos_t): Fix for MSVCRT. + * include/float.h (fpreset): Add prototype. + * include/limits.h: Define UINT_MAX, USHRT_MAX and ULONG_MAX with + constant values. + * include/time.h: Don't define tzname as a macro for CRTDLL, and + export using libmoldname.a. + * crtdll.def: Add DATA tags. + * msvcrt.def: Likewise. + * moldname.def.in: Likewise. Add fpreset. Export tzname for + both MSVCRT and CRTDLL. + * moldname-crtdll.def: Regenerate. + * moldname-msvcrt.def: Regenerate. + +Tue Dec 21 02:22:14 1999 Mumit Khan + + * Snapshot 1999-12-21. + + * include/wctype.h: New file. + * include/ctype.h (MB_CUR_MAX): Define. + (wctype_t): Guard. + * include/stdlib.h (MB_CUR_MAX): Define. + * include/wchar.h: Define stat, _stat structures here as well. + * include/float.h: Add invalid subconditions (_SW) and floating + point error (_FPE) macros. + * include/time.h (_CLOCK_T): Rename macro to _CLOCK_T_DEFINED. + (_TIME_T): Rename macro to _TIME_T_DEFINED. + * include/sys/types.h: Likewise. + +Thu Nov 18 00:22:26 1999 Mumit Khan + + * Snapshot 1999-11-18. + +Sun Nov 7 02:50:09 1999 Mumit Khan + + Released 1999-11-07. + + * Makefile.in (CRT0S): Add crtst.o. + (install): Install in subdirs as well. + * dirent.h (struct _stat): Rename from struct stat. + * include/tchar.h: Add some new macros. Thanks to + Eric Kohl . + +Thu Nov 4 14:32:58 1999 Mumit Khan + + * Makefile.in: Add support for profile directory. + * configure.in: Likewise. + * configure: Regenerate. + +Wed Nov 3 16:26:44 1999 Mumit Khan + + * include/stdlib.h: Add wide character version of argv/environ. + Formatting changes. + * include/wchar.h: More wide character prototypes. + * include/sys/stat.h: Likewise. Add struct stat as well as _stat. + + * dllcrt1.c (init.c): Don't include. + (DllMainCRTStartup): Don't call _mingw32_init_mainargs(). + * Makefile.in: Remove init.c from dllcrt{1,2}.c dependency lists. + +Sat Oct 30 03:06:26 1999 Mumit Khan + + * moldname.def: Remove file. + * moldname.def.in: And add this. + * moldname-msvcrt.def: Generate from moldname.def.in. + * moldname-crtdll.def: Likewise. + + * mthr.c: New file for -mthread (thread-safe C++ EH) support. + * mthr_init.c: New file for -mthread (thread-safe C++ EH) support. + * mthr_stub.c: New file for -mthread (thread-safe C++ EH) support. + + * Makefile.in: Update. + * configure.in: Likewise. Also add *cygwin* target for building + under Cygwin winsup. + * configure: Regenerate. + +Fri Oct 1 11:10:30 1999 Mumit Khan + + * include/_mingw.h: Add version macros. + * include/direct.h (_diskfree_t, getdiskfree, getdrives): Add. + Also add wide character versions shared with wchar.h. + * include/dos.h (_diskfree_t, getdiskfree, getdrives): Add. + * include/io.h (sopen, _sopen): Fix prototype. + Add wide character prototypes. + * include/wchar.h: Likewise. + * include/stdlib.h (beep, seterrormode, sleep): Remove non- + underscored versions. Potential incompatibility. + * include/time.h (daylight, timezone, tzname): Fix MSVCRT cases. + Add wide character prototypes. + * include/sys/timeb.h (struct _timeb): Don't use macro, but real + definition. + +Wed Aug 18 18:38:39 1999 Mumit Khan + + * configure.in (RUNTIME, CRT_ID): Add to differentiate between + crtdll and msvcrt runtimes. Remove DLL_ENTRY and DEF_DLL_ENTRY + macros. + * configure: Rengerate. + * Makefile.in (RUNTIME, CRT_ID): Use to generate the correct + dll name and crt's. CRTDLL and MSVCRT are meant to created + separately, so remove all the *-msvcrt* targets. + (libmingwthr.a): New target. Dummy thread support archive. + (LIBS): Add libmingwthr.a. + (CRT0S): Use CRT_ID. Add crtmt.o. + (MINGW_OBJS): Add crtst.o. + * main.c (WinMain): Fix prototype. + * crtmt.c: New file. + * crtst.c: New file. + + * include/process.h (_beginthreadex): Fix prototype. + * include/_mingw.h (__int64): Define for __GNUC__. + * include/tchar.h (_ttol): Add macro. + * include/stdlib.h (_wtoi, _wtol, _i64toa, _ui64toa, _atoi64, + _i64tow, _ui64tow, _wtoi64): Add prototypes. + + Reported by Emanuele Aliberti : + * include/tchar.h (_ttoi): Add macro. + + Reported by Ulf Moeller <3umoelle@informatik.uni-hamburg.de>: + * include/stdio.h (_snprintf): Add prototype. + (_vsnprintf): Likewise. + +Sat Aug 7 18:00:00 1999 Mumit Khan + + Reported by Tor Lillqvist : + * include/stdlib.h (__p___argv): Fix return type. + +Fri Jul 30 22:07:06 1999 Mumit Khan + + Add UWIN support. + * include/errno.h (errno): It's linked in from startup, not imported. + * include/stdlib.h (errno): Likewise. + * include/io.h: Guard against conflicting macros and prototypes in + system headers. + * include/stdlib.h: Likewise. + * include/string.h: Likewise. + * include/time.h: Likewise. + +Fri Jul 30 13:47:34 1999 Mumit Khan + + * include/io.h (X_OK): Fix definition. Thanks to Jan Nijtmans. + * include/dos.h: Fix typo __MINGW_EXPORT->__MINGW_IMPORT. + * Makefile.in (INCLUDES): Remove old windows32 include directory. + + * crt1.c (_gnu_exception_handler): Fix prototype. + (__mingw_CRTStartup): New function based on mainCRTStartup. + (mainCRTStartup): Set the app type for MSVCRT and call + __mingw_CRTStartup. + (WinMainCRTStartup): Likewise. + * init.c (_startupinfo): Define. + (_getmainargs): Add 5th parameter. + (_mingw32_init_mainargs): Use. + + * ALL *.c files: Reformat according to GNU coding style. + +Fri Jul 16 00:46:04 1999 Mumit Khan + + * Makefile.in (INCLUDES): Add w32api include directory. + + * include/_mingw.h: New file. + * include/{assert.h,conio.h,ctype.h,direct.h,dirent.h,dos.h, + errno.h,excpt.h,fcntl.h,float.h,io.h,limits.h,locale.h,malloc.h, + math.h,process.h,setjmp.h,share.h,signal.h,stdarg.h,stdio.h, + stdlib.h,string.h,tchar.h,time.h,varargs.h,sys/locking.h, + sys/stat.h,sys/timeb.h,sys/types.h,sys/utime.h}: Include and + use the macros __DECLSPEC_SUPPORTED and __MINGW_IMPORT. + + * include/stdlib.h (atexit): Fix prototype. + +Mon Jun 14 18:38:49 1999 Mumit Khan + + * include/stdio.h (_tempnam): Fix prototype. + (tempnam): Likewise. + * include/stdlib.h: Replace with GCC's version, and guard + with RC_INVOKED. + + From Anders Norlander : + * include/stdlib.h (__argc): Declare. + (__argv): Likewise. + +Mon Apr 5 13:49:17 1999 Mumit Khan + + * crt1.c (_gnu_exception_handler): Acknowledge Jacob Navia's + contribution. + * Makefile.in (_libm_dummy.o): New target. + (libm.a): Use. + +Tue Mar 16 18:15:26 1999 Mumit Khan + + * Released 1999-03-16 along with egcs-1.1.2. + +Wed Feb 17 17:15:56 1999 Mumit Khan + + * Makefile.in (LIBS): Add libm.a. + (libm.a): Dummy libm.a. + + * Makefile.in: Update from winsup 1999-02-08 snapshot. + Preserve local changes. + (mkinstalldirs): In ../, not ../../. + (INCLUDES): Point to local windows32api headers and use -nostdinc. + (LIBGCC): Delete. + (LIBS): Add libmoldname-msvc.a. + (libmoldname-msvc.a): Add target. + (distclean): Add target. + +Tue Feb 9 00:26:05 1999 Mumit Khan + + * include/dir.h: Reintroduce as an obsolescent header. + * crt1.c (signal.h): Include. + (_gnu_exception_handler): New function to properly handle win32 + asynchronous signals. + (mainCRTStartup): Use. + +Sun Jan 3 23:52:25 1999 Mumit Khan + + * include/direct.h: Include io.h instead of dir.h + * include/dirent.h: Likewise. + * include/dos.h: Likewise. + * include/stdio.h: Replace reference to dir.h with io.h. + +Thu Dec 31 16:04:55 1998 Mumit Khan + + * 1999-01-01 release bundled with egcs-1.1.1. + + * include/io.h: Incorporate dir.h. + * include/dir.h: Remove. + * include/signal.h: Move RC_INVOKED up a bit. + +Tue Dec 29 15:04:38 1998 Mumit Khan + + * include/signal.h (sig_atomic_t): Define. + (NSIG): Define. + * include/malloc.h: Import defs from deprecated alloc.h. + * include/alloc.h: Remove. + + From "Daniel J. Rodriksson" : + * include/sys/types.h (_dev_t): Should be unsigned int for MSVCRT. + * include/sys/stat.h (struct stat): st_uid is of type short. Use + _off_t instead of long for st_size. + +Thu Sep 10 22:28:49 1998 Mumit Khan + + * include/errno.h (sys_errlist, sys_nerr): Move from here ... + * include/stdlib.h: Here. + + * include/netdb.h: Remove. + * include/arpa/inet.h: Remove. + * include/netinet/in.h: Remove. + * include/sys/socket.h: Remove. + +Fri Sep 4 15:09:11 1998 Mumit Khan + + * Release egcs-1.1. + + * include/{ctype.h,dos.h,io.h,string.h,time.h,sys/types.h, + sys/utime.h}: Protect stddef.h in RC_INVOKED macro. + +Thu Sep 3 10:43:29 1998 Mumit Khan + + * setjmp.h (_JBTYPE, _JBLEN): Define correctly. + (jmpbuf): typedef using above. + (setjmp, longjmp): Prototype using jmpbuf. + + Merge with Colin Peters' 980701 snapshot. I've ignored changes to + obsolescent imported names, ie., from __imp__ to _imp___. + + Also ignored empty include/sys/param.h and incorrect + include/sys/times.h. + + * CRTinit.c: New file. + * include/{errno.h,fcntl.h,math.h,process.h} (__MSVCRT__): Use #ifdef + instead of #if. + * include/io.h (umask): Fix prototype. + * include/stdlib.h (OS constants): Replace with Colin's. + * include/time.h (tzset, daylight, timezone): Replace with Colin's. + * include/sys/state.h: Merge. + +Thu Sep 3 09:49:07 1998 Mumit Khan + + * include/assert.h (assert): Lose the trailing semicolon. + +Thu Jul 30 21:18:49 1998 Mumit Khan + + * include/math.h (matherr): Declare. + * include/stdio.h (fileno, _fileno): Declare. + * include/stdlib.h (environ, _environ): Fix to use runtime DLL. + + From Earnie Boyd: + * include/stdio.h (fdopen, _fdopen): Add const. + (getw, putw): Declare. + * include/stdlib.h (MAX_{DRIVE,DIR,FNAME,EXT}): Fix. + +Sat Jun 13 18:19:41 1998 Mumit Khan + + * include/time.h (_timezone): Undefine. + * include/sys/timeb.h (struct timeb): Rename _timezone to timezone. + + * include/time.h (_daylight, _timezone, _tzname, _tzset): Remove + __cdecl for MSVCRT. + * include/stdlib.h (environ): Use DLL version. + * init.c (environ): Undefine it before use. + +Sun Mar 22 19:59:30 1998 Mumit Khan + + * Update to 980309 snapshot from Colin Peters. + + * include/utime.h: remove + * include/stdlib.h (__imp__osver_dll, __imp__winver_dll, + __imp__winmajor_dll, __imp__winminor_dll): Apply Jan-Jaap's + patches to define these. + * include/time.h (CLK_TCK): Renamed from CLK_TICK. + (_daylight, _timezone, _tzname, _tzset): Define. + + * include/netdb.h: Add from Colin's windows32api changes. + * include/sys/socket.h: Likewise. + * include/arpa/inet.h: Likewise. + * include/netinet/in.h: Likewise. + +Wed Feb 4 14:16:44 1998 Mumit Khan + + * Update to 980128 snapshot from Colin Peters. + +Sat Dec 6 21:30:35 1997 Mumit Khan + + * configure.in (AC_INIT): Use dllmain.c instead of defunct + oldnames.c + * configure: Regenerate. + +Fri Dec 5 15:57:36 1997 Mumit Khan + + * Update to 971205 snapshot from Colin Peters. Lots of changes. + Files renamed and include hierarchy loses directories named + nonansi. + + * include/dos.h: from Jan-Jaap. + +Thu Dec 4 21:48:13 1997 Mumit Khan + + Changes to conform to FSF tree. + + * crt1.c: Renamed from mcrt0.c. + * dllcrt1.c: Renamed from dllcrt0.c. + * Makefile.in: Update above. Also renamed libmoldnames.a to + libmoldname.a. + +Mon Dec 1 16:51:30 1997 Mumit Khan + + * crtdll.def: Export all functions but the ones with funny names. + * moldnames.def: Add fdopen since fileno is already there. + * include/nonansi/dos.h: New file from Jan-Jaap. + * include/errno.h: Add extern decl + various additions from JJ. + * include/stdio.h: Likewise. + * include/stdlib.h: Likewise. + * include/nonansi/io.h: Likewise. + * include/nonansi/process.h: Likewise. + * include/sys/types.h: Likewise. + +Tue Nov 4 14:51:01 1997 Mumit Khan + + * include/time.h (CLK_TCK): Renamed from CLK_TICK. + (CLK_TICK): Delete. + * include/stdlib.h (free): Fix prototype to return void, not void*. + * include/nonansi/process.h: Add P_* and WAIT_* defs. + + * dllcrt0.c: Delete now-unneeded '.section .idata$3' asm hack. + * mcrt0.c: Likewise. + + * Makefile.in (LIBS): Delete moldnames.dll from target libs. + (libmoldnames.a): Add explicit rule to create it. + +Fri Aug 15 18:23:43 1997 Rob Savoye + + New directory for the minimalist cygwin environment. + + * crtglob.c: New file. Turn on file globbing support. + * crt_noglob.c: New file. Turn off file globbing support. + * ctype_old.c: New file. Wrappers for functions that don't + have an underscore. + * dirent.c: New file. Directory routines readdir, opendir, closedir. + * dllcrt0.c: New file. Initialization code to use crtdll.dll. + * dllmain.c: New file. A stub DllMain function. + * hugeval.c: New file. A gross hack to define HUGE_VAL. + * init.c: New file. Common code to initialize standard file + handles and command line arguments. + * main.c: New file. A main for programs that only call WinMain. + * mcrt0.c: New file. Default crt0 for mingw32. + * oldnames.c: New File. Wrappers for functions that don't + have an underscore. + * string_old.c: New File. + * include/{assert.h,ctype.h,errno.h,float.h,limits.h,locale.h + math.h,nonansi,setjmp.h,signal.h,stdarg.h,stddef.h,stdio.h,stdlib.h + string.h,tchar.h,time.h,wchar.h}: New header files for mingw. + * include/sys/types.h: New header file for mingw. + * include/nonansi/{alloc.h,conio.h,dir.h,direct.h,dirent.h + fcntl.h,io.h,malloc.h,mem.h,memory.h,process.h,share.h,unistd.h + utime.h,values.h,varargs.h}: New header files for mingw. + * include/nonansi/sys/{fcntl.h,locking.h,stat.h,time.h + timeb.h,unistd.h}: New header files for mingw. + * Makefile.in,configure.in: Build and configure support. + * configure: Generated from autoconf 2.12 with Cygnus patches. diff --git a/winsup/mingw/Makefile.in b/winsup/mingw/Makefile.in new file mode 100644 index 000000000..442e32efc --- /dev/null +++ b/winsup/mingw/Makefile.in @@ -0,0 +1,265 @@ +# Makefile.in for the winsup/mingw directory. +# Copyright (c) 1995, 1996, 1997, 1998 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 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 makefile requires GNU make. + +VPATH = @srcdir@ +srcdir = @srcdir@ +objdir = . + +target_alias = @target_alias@ +prefix = @prefix@ + +program_transform_name = @program_transform_name@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +tooldir = $(exec_prefix)/$(target_alias) +datadir = @datadir@ +infodir = @infodir@ +includedir = @includedir@ + +# The Mingw headers are installed under a subdirectory of +# $(tooldir)/include when configuring in Cygwin. +HEADER_SUBDIR = @HEADER_SUBDIR@ + +SHELL = /bin/sh + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +mkinstalldirs = $(SHELL) @MKINSTALLDIRS@ + +CC = @CC@ +# FIXME: Which is it, CC or CC_FOR_TARGET? +CC_FOR_TARGET = $(CC) +AS_FOR_TARGET = $(AS) +CFLAGS = @CFLAGS@ +CXXFLAGS = @CXXFLAGS@ + +# compiling with Cygwin? +MNO_CYGWIN = @MNO_CYGWIN@ + +# Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2). +RUNTIME = @RUNTIME@ +CRT_ID = @CRT_ID@ + +# Needed for threading dll. +THREAD_DLL = @THREAD_DLL@ +THREAD_DLL_VERSION = 10 +THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll + +# Various libraries. +LIBM_A=@LIBM_A@ + +INCLUDES = -I$(srcdir)/include -I$(srcdir)/../w32api/include \ + -I$(srcdir)/../include \ + -nostdinc -nostdinc++ +ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(MNO_CYGWIN) +ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) $(MNO_CYGWIN) + +AS = @AS@ +AR = @AR@ +LD = @LD@ +AR_FLAGS = rcv +RANLIB = @RANLIB@ +DLLTOOL = @DLLTOOL@ +DLLTOOLFLAGS = +DLLTOOL_FOR_TARGET = $(DLLTOOL) +DLLTOOL_FLAGS = --as $(AS_FOR_TARGET) +DLLWRAP = @DLLWRAP@ +DLLWRAP_FOR_TARGET = $(DLLWRAP) +DLLWRAP_FLAGS = --dlltool $(DLLTOOL) --as $(AS) --driver-name $(CC) + +SUBDIRS := @SUBDIRS@ + +FLAGS_TO_PASS:=\ + AS="$(AS)" \ + CC="$(CC)" \ + CFLAGS="$(CFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \ + CXXFLAGS="$(CXXFLAGS) $(CFLAGS_COMMON) $(CFLAGS_CONFIG)" \ + EXE_LDFLAGS="$(EXE_LDFLAGS)" \ + AR="$(AR)" \ + RANLIB="$(RANLIB)" \ + LD="$(LD)" \ + DLLTOOL="$(DLLTOOL)" + +CRT0S = crt$(CRT_ID).o dllcrt$(CRT_ID).o CRT_noglob.o crtmt.o crtst.o +MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dirent.o dllmain.o gccmain.o \ + main.o crtst.o mthr_stub.o +MOLD_OBJS = ctype_old.o string_old.o + +LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \ + libmoldname.a $(LIBM_A) libmingwthrd.a + +DLLS = $(THREAD_DLL_NAME) + +all : $(CRT0S) $(LIBS) $(DLLS) + @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS) + +_libm_dummy.o: + rm -f _libm_dummy.c + echo "static int __mingw_libm_dummy;" > _libm_dummy.c + $(CC) -c $(ALL_CFLAGS) _libm_dummy.c + rm -f _libm_dummy.c + +libm.a: _libm_dummy.o + $(AR) rc $@ _libm_dummy.o + $(RANLIB) $@ + +libmingwthrd.a: crtmt.o mingwthrd.def + $(DLLTOOL) $(DLLTOOL_FLAGS) --dllname $(THREAD_DLL_NAME) \ + --def mingwthrd.def --output-lib $@ + $(AR) $(ARFLAGS) $@ crtmt.o + $(RANLIB) $@ + +# Using dllwrap would be so much easier, but Cygnus top-level configure +# Makefile.in etc don't pass the right variables yet. +xx_$(THREAD_DLL_NAME) xx_mingwthrd.def: mthr.o mthr_init.o + $(DLLWRAP) $(DLLWRAP_FLAGS) -o $(THREAD_DLL_NAME) \ + --output-def mingwthrd.def \ + mthr.o mthr_init.o + +DLL_OFILES = mthr.o mthr_init.o +DLL_CC_STUFF = -B./ -mdll $(MNO_CYGWIN) -Wl,--image-base,0x6FBC0000 \ + -Wl,--entry,_DllMainCRTStartup@12 \ + $(DLL_OFILES) +DLL_DLLTOOL_STUFF = --as=$(AS) --dllname $(THREAD_DLL_NAME) \ + --def mingwthrd.def \ + --base-file mingwthrd.base --output-exp mingwthrd.exp + +$(THREAD_DLL_NAME) mingwthrd.def: $(DLL_OFILES) Makefile + $(DLLTOOL) --as $(AS) --output-def mingwthrd.def $(DLL_OFILES) + $(CC) -Wl,--base-file=mingwthrd.base $(DLL_CC_STUFF) + $(DLLTOOL) $(DLL_DLLTOOL_STUFF) + $(CC) -Wl,--base-file=mingwthrd.base mingwthrd.exp $(DLL_CC_STUFF) + $(DLLTOOL) $(DLL_DLLTOOL_STUFF) + $(CC) mingwthrd.exp -o $(THREAD_DLL_NAME) $(DLL_CC_STUFF) + +libmingw32.a: $(MINGW_OBJS) + $(AR) rc $@ $(MINGW_OBJS) + $(RANLIB) $@ + +$(srcdir)/moldname-$(RUNTIME).def: moldname.def.in + $(CC) -DRUNTIME=$(RUNTIME) \ + -D__FILENAME__=moldname-${RUNTIME}.def \ + -D__`echo $(RUNTIME) | tr '[a-z]' '[A-Z]'`__ -c -E -P \ + -xc-header $? > $@ + +libmoldname.a: $(srcdir)/moldname-$(RUNTIME).def $(MOLD_OBJS) + $(DLLTOOL) --as $(AS) -k -U \ + --dllname $(RUNTIME).dll \ + --def $(srcdir)/moldname-$(RUNTIME).def \ + --output-lib $@ + $(AR) rc $@ $(MOLD_OBJS) + $(RANLIB) $@ + +# The special rule is necessary. +crt2.o dllcrt2.o: + $(CC) -c -D__MSVCRT__ $(ALL_CFLAGS) $< -o $@ + +clean: + -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp + -rm -f $(THREAD_DLL_NAME) + @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS) + +distclean: + @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS) + -rm -f *.o *.a *~ core a.out mingwthrd.def mingwthrd.base mingwthrd.exp + -rm -f $(THREAD_DLL_NAME) + -rm -f config.cache config.status config.log + -rm -f Makefile + +info: + +info-html: + +install-info: info + +install: all + $(mkinstalldirs) $(bindir) + for i in $(DLLS); do \ + $(INSTALL_PROGRAM) $$i $(bindir)/$$i ; \ + done + $(mkinstalldirs) $(tooldir)/lib + for i in $(LIBS); do \ + $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + done + for i in $(CRT0S); do \ + $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + done + for sub in . sys ; do \ + dstdir=$(tooldir)/include/$(HEADER_SUBDIR)/$$sub ; \ + $(mkinstalldirs) $$dstdir ; \ + for i in $(srcdir)/include/$$sub/*.h ; do \ + $(INSTALL_DATA) $$i $$dstdir/`basename $$i` ; \ + done ; \ + done + @$(MAKE) subdirs DO=$@ $(FLAGS_TO_PASS) + +subdirs: force + @for i in $(SUBDIRS); do \ + echo "Making $(DO) in $${i}..." ; \ + if [ -d ./$$i ] ; then \ + if (rootme=`pwd`/ ; export rootme ; \ + rootsrc=`cd $(srcdir); pwd`/ ; export rootsrc ; \ + cd ./$$i; \ + $(MAKE) $(FLAGS_TO_PASS) $(DO)) ; then true ; \ + else exit 1 ; fi ; \ + else true ; fi ; \ + done + +force: + +# +# Dependancies +# +libcrtdll.a: $(srcdir)/crtdll.def +libmsvcrt.a: $(srcdir)/msvcrt.def +libmsvcrt20.a: $(srcdir)/msvcrt20.def +libmsvcrt40.a: $(srcdir)/msvcrt40.def +CRT_noglob.o: $(srcdir)/CRT_noglob.c +CRTfmode.o: $(srcdir)/CRTfmode.c +CRTglob.o: $(srcdir)/CRTglob.c +CRTinit.o: $(srcdir)/CRTinit.c +crt1.o: $(srcdir)/crt1.c $(srcdir)/init.c +crt2.o: $(srcdir)/crt1.c $(srcdir)/init.c +crtmt.o: $(srcdir)/crtmt.c +crtst.o: $(srcdir)/crtst.c +ctype_old.o: $(srcdir)/ctype_old.c +dllcrt1.o: $(srcdir)/dllcrt1.c +dllcrt2.o: $(srcdir)/dllcrt1.c +dirent.o: $(srcdir)/dirent.c +dllmain.o: $(srcdir)/dllmain.c +main.o: $(srcdir)/main.c +oldnames.o: $(srcdir)/oldnames.c +string_old.o: $(srcdir)/string_old.c + +Makefile: Makefile.in config.status configure + $(SHELL) config.status + +config.status: configure + $(SHELL) config.status --recheck + +.SUFFIXES: .y $(SUFFIXES) .cc .def .a + +lib%.a:%.def + $(DLLTOOL) --as=$(AS) -k --dllname $*.dll --output-lib lib$*.a --def $< + +.c.o: + $(CC) -c $(ALL_CFLAGS) $< -o $@ + diff --git a/winsup/mingw/configure b/winsup/mingw/configure new file mode 100755 index 000000000..d35434fba --- /dev/null +++ b/winsup/mingw/configure @@ -0,0 +1,2169 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=dllmain.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + + + + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:555: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:576: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +if test $host != $build; then + ac_tool_prefix=${host_alias}- +else + ac_tool_prefix= +fi + +# Extract the first word of "${ac_tool_prefix}gcc", so it can be a program name with args. +set dummy ${ac_tool_prefix}gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:602: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="${ac_tool_prefix}gcc" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_CC"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "gcc", so it can be a program name with args. +set dummy gcc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:634: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_CC="gcc" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_CC" && ac_cv_prog_CC="gcc" +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + CC="gcc" +fi +fi + +if test -z "$CC"; then + # Extract the first word of "cc", so it can be a program name with args. +set dummy cc; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:670: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$CC"; then + ac_cv_prog_CC="$CC" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_prog_rejected=no + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + if test "$ac_dir/$ac_word" = "/usr/ucb/cc"; then + ac_prog_rejected=yes + continue + fi + ac_cv_prog_CC="cc" + break + fi + done + IFS="$ac_save_ifs" +if test $ac_prog_rejected = yes; then + # We found a bogon in the path, so make sure we never use it. + set dummy $ac_cv_prog_CC + shift + if test $# -gt 0; then + # We chose a different compiler from the bogus one. + # However, it has the same basename, so the bogon will be chosen + # first if we set CC to just the basename; use the full file name. + shift + set dummy "$ac_dir/$ac_word" "$@" + shift + ac_cv_prog_CC="$@" + fi +fi +fi +fi +CC="$ac_cv_prog_CC" +if test -n "$CC"; then + echo "$ac_t""$CC" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + test -z "$CC" && { echo "configure: error: no acceptable cc found in \$PATH" 1>&2; exit 1; } +fi + +echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6 +echo "configure:719: checking whether we are using GNU C" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.c <&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi +fi + +echo "$ac_t""$ac_cv_prog_gcc" 1>&6 + +if test $ac_cv_prog_gcc = yes; then + GCC=yes + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6 +echo "configure:743: checking whether ${CC-cc} accepts -g" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_cc_g=yes +else + ac_cv_prog_cc_g=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_prog_cc_g" 1>&6 + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi + if test "$ac_test_CXXFLAGS" != set; then + CXXFLAGS='$(CFLAGS)' + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi + + +# Extract the first word of "${ac_tool_prefix}ar", so it can be a program name with args. +set dummy ${ac_tool_prefix}ar; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:777: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="${ac_tool_prefix}ar" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_AR"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ar", so it can be a program name with args. +set dummy ar; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:809: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AR'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AR"; then + ac_cv_prog_AR="$AR" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AR="ar" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AR" && ac_cv_prog_AR="ar" +fi +fi +AR="$ac_cv_prog_AR" +if test -n "$AR"; then + echo "$ac_t""$AR" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + AR="ar" +fi +fi + + + +# Extract the first word of "${ac_tool_prefix}as", so it can be a program name with args. +set dummy ${ac_tool_prefix}as; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:846: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AS="${ac_tool_prefix}as" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_AS"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "as", so it can be a program name with args. +set dummy as; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:878: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_AS'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$AS"; then + ac_cv_prog_AS="$AS" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_AS="as" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_AS" && ac_cv_prog_AS="as" +fi +fi +AS="$ac_cv_prog_AS" +if test -n "$AS"; then + echo "$ac_t""$AS" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + AS="as" +fi +fi + + +# Extract the first word of "${ac_tool_prefix}ranlib", so it can be a program name with args. +set dummy ${ac_tool_prefix}ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:914: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="${ac_tool_prefix}ranlib" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_RANLIB"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ranlib", so it can be a program name with args. +set dummy ranlib; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:946: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$RANLIB"; then + ac_cv_prog_RANLIB="$RANLIB" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_RANLIB="ranlib" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_RANLIB" && ac_cv_prog_RANLIB="ranlib" +fi +fi +RANLIB="$ac_cv_prog_RANLIB" +if test -n "$RANLIB"; then + echo "$ac_t""$RANLIB" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + RANLIB="ranlib" +fi +fi + + +# Extract the first word of "${ac_tool_prefix}ld", so it can be a program name with args. +set dummy ${ac_tool_prefix}ld; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:982: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LD="${ac_tool_prefix}ld" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +LD="$ac_cv_prog_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_LD"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "ld", so it can be a program name with args. +set dummy ld; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1014: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_LD'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$LD"; then + ac_cv_prog_LD="$LD" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_LD="ld" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_LD" && ac_cv_prog_LD="ld" +fi +fi +LD="$ac_cv_prog_LD" +if test -n "$LD"; then + echo "$ac_t""$LD" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + LD="ld" +fi +fi + + +# Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1050: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLTOOL="${ac_tool_prefix}dlltool" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +DLLTOOL="$ac_cv_prog_DLLTOOL" +if test -n "$DLLTOOL"; then + echo "$ac_t""$DLLTOOL" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_DLLTOOL"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1082: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLTOOL'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLTOOL"; then + ac_cv_prog_DLLTOOL="$DLLTOOL" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLTOOL="dlltool" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_DLLTOOL" && ac_cv_prog_DLLTOOL="dlltool" +fi +fi +DLLTOOL="$ac_cv_prog_DLLTOOL" +if test -n "$DLLTOOL"; then + echo "$ac_t""$DLLTOOL" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + DLLTOOL="dlltool" +fi +fi + + +# Extract the first word of "${ac_tool_prefix}dlltool", so it can be a program name with args. +set dummy ${ac_tool_prefix}dlltool; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1118: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLWRAP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLWRAP"; then + ac_cv_prog_DLLWRAP="$DLLWRAP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLWRAP="${ac_tool_prefix}dlltool" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +DLLWRAP="$ac_cv_prog_DLLWRAP" +if test -n "$DLLWRAP"; then + echo "$ac_t""$DLLWRAP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_DLLWRAP"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "dlltool", so it can be a program name with args. +set dummy dlltool; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1150: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_DLLWRAP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$DLLWRAP"; then + ac_cv_prog_DLLWRAP="$DLLWRAP" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_DLLWRAP="dlltool" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_DLLWRAP" && ac_cv_prog_DLLWRAP="dlltool" +fi +fi +DLLWRAP="$ac_cv_prog_DLLWRAP" +if test -n "$DLLWRAP"; then + echo "$ac_t""$DLLWRAP" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + DLLWRAP="dlltool" +fi +fi + + +# Extract the first word of "${ac_tool_prefix}windres", so it can be a program name with args. +set dummy ${ac_tool_prefix}windres; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1186: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$WINDRES"; then + ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_WINDRES="${ac_tool_prefix}windres" + break + fi + done + IFS="$ac_save_ifs" +fi +fi +WINDRES="$ac_cv_prog_WINDRES" +if test -n "$WINDRES"; then + echo "$ac_t""$WINDRES" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + + +if test -z "$ac_cv_prog_WINDRES"; then +if test -n "$ac_tool_prefix"; then + # Extract the first word of "windres", so it can be a program name with args. +set dummy windres; ac_word=$2 +echo $ac_n "checking for $ac_word""... $ac_c" 1>&6 +echo "configure:1218: checking for $ac_word" >&5 +if eval "test \"`echo '$''{'ac_cv_prog_WINDRES'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test -n "$WINDRES"; then + ac_cv_prog_WINDRES="$WINDRES" # Let the user override the test. +else + IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS=":" + ac_dummy="$PATH" + for ac_dir in $ac_dummy; do + test -z "$ac_dir" && ac_dir=. + if test -f $ac_dir/$ac_word; then + ac_cv_prog_WINDRES="windres" + break + fi + done + IFS="$ac_save_ifs" + test -z "$ac_cv_prog_WINDRES" && ac_cv_prog_WINDRES="windres" +fi +fi +WINDRES="$ac_cv_prog_WINDRES" +if test -n "$WINDRES"; then + echo "$ac_t""$WINDRES" 1>&6 +else + echo "$ac_t""no" 1>&6 +fi + +else + WINDRES="windres" +fi +fi + + + +echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6 +echo "configure:1253: checking how to run the C preprocessor" >&5 +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +if eval "test \"`echo '$''{'ac_cv_prog_CPP'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1274: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -E -traditional-cpp" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1291: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP="${CC-cc} -nologo -E" + cat > conftest.$ac_ext < +Syntax Error +EOF +ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out" +{ (eval echo configure:1308: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; } +ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"` +if test -z "$ac_err"; then + : +else + echo "$ac_err" >&5 + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + CPP=/lib/cpp +fi +rm -f conftest* +fi +rm -f conftest* +fi +rm -f conftest* + ac_cv_prog_CPP="$CPP" +fi + CPP="$ac_cv_prog_CPP" +else + ac_cv_prog_CPP="$CPP" +fi +echo "$ac_t""$CPP" 1>&6 + +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +echo $ac_n "checking for working alloca.h""... $ac_c" 1>&6 +echo "configure:1335: checking for working alloca.h" >&5 +if eval "test \"`echo '$''{'ac_cv_header_alloca_h'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +int main() { +char *p = alloca(2 * sizeof(int)); +; return 0; } +EOF +if { (eval echo configure:1347: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_header_alloca_h=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_header_alloca_h=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_header_alloca_h" 1>&6 +if test $ac_cv_header_alloca_h = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA_H 1 +EOF + +fi + +echo $ac_n "checking for alloca""... $ac_c" 1>&6 +echo "configure:1368: checking for alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_func_alloca_works'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +# define alloca _alloca +# else +# if HAVE_ALLOCA_H +# include +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +# endif +#endif + +int main() { +char *p = (char *) alloca(1); +; return 0; } +EOF +if { (eval echo configure:1401: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + ac_cv_func_alloca_works=yes +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + ac_cv_func_alloca_works=no +fi +rm -f conftest* +fi + +echo "$ac_t""$ac_cv_func_alloca_works" 1>&6 +if test $ac_cv_func_alloca_works = yes; then + cat >> confdefs.h <<\EOF +#define HAVE_ALLOCA 1 +EOF + +fi + +if test $ac_cv_func_alloca_works = no; then + # The SVR3 libPW and SVR4 libucb both contain incompatible functions + # that cause trouble. Some versions do not even contain alloca or + # contain a buggy version. If you still want to use their alloca, + # use ar to extract alloca.o from them instead of compiling alloca.c. + ALLOCA=alloca.${ac_objext} + cat >> confdefs.h <<\EOF +#define C_ALLOCA 1 +EOF + + +echo $ac_n "checking whether alloca needs Cray hooks""... $ac_c" 1>&6 +echo "configure:1433: checking whether alloca needs Cray hooks" >&5 +if eval "test \"`echo '$''{'ac_cv_os_cray'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext <&5 | + egrep "webecray" >/dev/null 2>&1; then + rm -rf conftest* + ac_cv_os_cray=yes +else + rm -rf conftest* + ac_cv_os_cray=no +fi +rm -f conftest* + +fi + +echo "$ac_t""$ac_cv_os_cray" 1>&6 +if test $ac_cv_os_cray = yes; then +for ac_func in _getb67 GETB67 getb67; do + echo $ac_n "checking for $ac_func""... $ac_c" 1>&6 +echo "configure:1463: checking for $ac_func" >&5 +if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + cat > conftest.$ac_ext < +/* Override any gcc2 internal prototype to avoid an error. */ +/* We use char because int might match the return type of a gcc2 + builtin and then its argument prototype would still apply. */ +char $ac_func(); + +int main() { + +/* The GNU C library defines this for functions which it implements + to always fail with ENOSYS. Some functions are actually named + something starting with __ and the normal name is an alias. */ +#if defined (__stub_$ac_func) || defined (__stub___$ac_func) +choke me +#else +$ac_func(); +#endif + +; return 0; } +EOF +if { (eval echo configure:1491: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then + rm -rf conftest* + eval "ac_cv_func_$ac_func=yes" +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -rf conftest* + eval "ac_cv_func_$ac_func=no" +fi +rm -f conftest* +fi + +if eval "test \"`echo '$ac_cv_func_'$ac_func`\" = yes"; then + echo "$ac_t""yes" 1>&6 + cat >> confdefs.h <&6 +fi + +done +fi + +echo $ac_n "checking stack direction for C alloca""... $ac_c" 1>&6 +echo "configure:1518: checking stack direction for C alloca" >&5 +if eval "test \"`echo '$''{'ac_cv_c_stack_direction'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + if test "$cross_compiling" = yes; then + ac_cv_c_stack_direction=0 +else + cat > conftest.$ac_ext < addr) ? 1 : -1; +} +main () +{ + exit (find_stack_direction() < 0); +} +EOF +if { (eval echo configure:1545: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null +then + ac_cv_c_stack_direction=1 +else + echo "configure: failed program was:" >&5 + cat conftest.$ac_ext >&5 + rm -fr conftest* + ac_cv_c_stack_direction=-1 +fi +rm -fr conftest* +fi + +fi + +echo "$ac_t""$ac_cv_c_stack_direction" 1>&6 +cat >> confdefs.h <&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:1595: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:1616: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:1634: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +configdirs="" +SUBDIRS="" +HEADER_SUBDIR="" + +case "$target_os" in +*mingw32msvc*) + CRT_ID=2 + MNO_CYGWIN= + RUNTIME=msvcrt + THREAD_DLL=mingwm + LIBM_A=libm.a + LIBGMON_A=libgmon.a + SUBDIRS="profile" + configdirs="$configdirs profile" + ;; +*cygwin*) + CRT_ID=1 + MNO_CYGWIN=-mno-cygwin + RUNTIME=crtdll + THREAD_DLL=mingwc + configdirs="$configdirs" + # Do not build libm.a when building under Cygwin winsup. Otherwise, it'll + # overwrite Cygwin's one. Likewise for libgmon.a. + LIBM_A= + LIBGMON_A= + # Install mingw headers in mingw subdirectory. + HEADER_SUBDIR="mingw" + ;; +*) + # Build it for CRTDLL by default. + CRT_ID=1 + MNO_CYGWIN= + RUNTIME=crtdll + THREAD_DLL=mingwc + LIBM_A=libm.a + LIBGMON_A=libgmon.a + SUBDIRS="profile" + configdirs="$configdirs profile" + ;; +esac + +if test -n "$configdirs"; then + subdirs="$configdirs" + +fi + +MKINSTALLDIRS=$ac_aux_dir/mkinstalldirs + + + + + + + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:1726: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@CC@%$CC%g +s%@AR@%$AR%g +s%@AS@%$AS%g +s%@RANLIB@%$RANLIB%g +s%@LD@%$LD%g +s%@DLLTOOL@%$DLLTOOL%g +s%@DLLWRAP@%$DLLWRAP%g +s%@WINDRES@%$WINDRES%g +s%@CPP@%$CPP%g +s%@ALLOCA@%$ALLOCA%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@subdirs@%$subdirs%g +s%@MKINSTALLDIRS@%$MKINSTALLDIRS%g +s%@CRT_ID@%$CRT_ID%g +s%@RUNTIME@%$RUNTIME%g +s%@MNO_CYGWIN@%$MNO_CYGWIN%g +s%@THREAD_DLL@%$THREAD_DLL%g +s%@LIBM_A@%$LIBM_A%g +s%@LIBGMON_A@%$LIBGMON_A%g +s%@SUBDIRS@%$SUBDIRS%g +s%@HEADER_SUBDIR@%$HEADER_SUBDIR%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + +if test "$no_recursion" != yes; then + + # Remove --cache-file and --srcdir arguments so they do not pile up. + ac_sub_configure_args= + ac_prev= + for ac_arg in $ac_configure_args; do + if test -n "$ac_prev"; then + ac_prev= + continue + fi + case "$ac_arg" in + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + ;; + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + ;; + *) ac_sub_configure_args="$ac_sub_configure_args $ac_arg" ;; + esac + done + + for ac_config_dir in $configdirs; do + + # Do not complain, so a configure script can configure whichever + # parts of a large source tree are present. + if test ! -d $srcdir/$ac_config_dir; then + continue + fi + + echo configuring in $ac_config_dir + + case "$srcdir" in + .) ;; + *) + if test -d ./$ac_config_dir || mkdir ./$ac_config_dir; then :; + else + { echo "configure: error: can not create `pwd`/$ac_config_dir" 1>&2; exit 1; } + fi + ;; + esac + + ac_popdir=`pwd` + cd $ac_config_dir + + # A "../" for each directory in /$ac_config_dir. + ac_dots=`echo $ac_config_dir|sed -e 's%^\./%%' -e 's%[^/]$%&/%' -e 's%[^/]*/%../%g'` + + case "$srcdir" in + .) # No --srcdir option. We are building in place. + ac_sub_srcdir=$srcdir ;; + /*) # Absolute path. + ac_sub_srcdir=$srcdir/$ac_config_dir ;; + *) # Relative path. + ac_sub_srcdir=$ac_dots$srcdir/$ac_config_dir ;; + esac + + # Check for guested configure; otherwise get Cygnus style configure. + if test -f $ac_sub_srcdir/configure; then + ac_sub_configure=$ac_sub_srcdir/configure + elif test -f $ac_sub_srcdir/configure.in; then + ac_sub_configure=$ac_configure + else + echo "configure: warning: no configuration information is in $ac_config_dir" 1>&2 + ac_sub_configure= + fi + + # The recursion is here. + if test -n "$ac_sub_configure"; then + + # Make the cache file name correct relative to the subdirectory. + case "$cache_file" in + /*) ac_sub_cache_file=$cache_file ;; + *) # Relative path. + ac_sub_cache_file="$ac_dots$cache_file" ;; + esac + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo "running ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir" + # The eval makes quoting arguments work. + if eval ${CONFIG_SHELL-/bin/sh} $ac_sub_configure $ac_sub_configure_args --cache-file=$ac_sub_cache_file --srcdir=$ac_sub_srcdir + then : + else + { echo "configure: error: $ac_sub_configure failed for $ac_config_dir" 1>&2; exit 1; } + fi + fi + + cd $ac_popdir + done +fi + + diff --git a/winsup/mingw/configure.in b/winsup/mingw/configure.in new file mode 100644 index 000000000..1a6960b9a --- /dev/null +++ b/winsup/mingw/configure.in @@ -0,0 +1,143 @@ +dnl Process this file with autoconf to produce a configure script. + +dnl This file is part of winsup/mingw +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +AC_PREREQ(2.12) +AC_INIT(dllmain.c) + +dnl FIXME: We temporarily define our own version of AC_PROG_CC. This is +dnl copied from autoconf 2.12, but does not call AC_PROG_CC_WORKS. We +dnl are probably using a cross compiler, which will not be able to fully +dnl link an executable. This should really be fixed in autoconf +dnl itself. + +AC_DEFUN(LIB_AC_PROG_CC, +[AC_BEFORE([$0], [AC_PROG_CPP])dnl +AC_CHECK_TOOL(CC, gcc, gcc) +if test -z "$CC"; then + AC_CHECK_PROG(CC, cc, cc, , , /usr/ucb/cc) + test -z "$CC" && AC_MSG_ERROR([no acceptable cc found in \$PATH]) +fi + +AC_PROG_CC_GNU + +if test $ac_cv_prog_gcc = yes; then + GCC=yes +dnl Check whether -g works, even if CFLAGS is set, in case the package +dnl plays around with CFLAGS (such as to build both debugging and +dnl normal versions of a library), tasteless as that idea is. + ac_test_CFLAGS="${CFLAGS+set}" + ac_save_CFLAGS="$CFLAGS" + CFLAGS= + AC_PROG_CC_G + if test "$ac_test_CFLAGS" = set; then + CFLAGS="$ac_save_CFLAGS" + elif test $ac_cv_prog_cc_g = yes; then + CFLAGS="-g -O2" + else + CFLAGS="-O2" + fi + if test "$ac_test_CXXFLAGS" != set; then + CXXFLAGS='$(CFLAGS)' + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi +]) + +LIB_AC_PROG_CC + +AC_CHECK_TOOL(AR, ar, ar) + +AC_SUBST(AR) +AC_CHECK_TOOL(AS, as, as) +AC_SUBST(AS) +AC_CHECK_TOOL(RANLIB, ranlib, ranlib) +AC_SUBST(RANLIB) +AC_CHECK_TOOL(LD, ld, ld) +AC_SUBST(LD) +AC_CHECK_TOOL(DLLTOOL, dlltool, dlltool) +AC_SUBST(DLLTOOL) +AC_CHECK_TOOL(DLLWRAP, dlltool, dlltool) +AC_SUBST(DLLWRAP) +AC_CHECK_TOOL(WINDRES, windres, windres) +AC_SUBST(WINDRES) + +AC_ALLOCA + +AC_CANONICAL_SYSTEM + +configdirs="" +SUBDIRS="" +HEADER_SUBDIR="" + +case "$target_os" in +*mingw32msvc*) + CRT_ID=2 + MNO_CYGWIN= + RUNTIME=msvcrt + THREAD_DLL=mingwm + LIBM_A=libm.a + LIBGMON_A=libgmon.a + SUBDIRS="profile" + configdirs="$configdirs profile" + ;; +*cygwin*) + CRT_ID=1 + MNO_CYGWIN=-mno-cygwin + RUNTIME=crtdll + THREAD_DLL=mingwc + configdirs="$configdirs" + # Do not build libm.a when building under Cygwin winsup. Otherwise, it'll + # overwrite Cygwin's one. Likewise for libgmon.a. + LIBM_A= + LIBGMON_A= + # Install mingw headers in mingw subdirectory. + HEADER_SUBDIR="mingw" + ;; +*) + # Build it for CRTDLL by default. + CRT_ID=1 + MNO_CYGWIN= + RUNTIME=crtdll + THREAD_DLL=mingwc + LIBM_A=libm.a + LIBGMON_A=libgmon.a + SUBDIRS="profile" + configdirs="$configdirs profile" + ;; +esac + +if test -n "$configdirs"; then + AC_CONFIG_SUBDIRS($configdirs) +fi + +MKINSTALLDIRS=$ac_aux_dir/mkinstalldirs +AC_SUBST(MKINSTALLDIRS) +AC_SUBST(CRT_ID) +AC_SUBST(RUNTIME) +AC_SUBST(MNO_CYGWIN) +AC_SUBST(THREAD_DLL) +AC_SUBST(LIBM_A) +AC_SUBST(LIBGMON_A) +AC_SUBST(SUBDIRS) +AC_SUBST(HEADER_SUBDIR) + +AC_PROG_INSTALL +AC_OUTPUT(Makefile) + diff --git a/winsup/mingw/crt1.c b/winsup/mingw/crt1.c new file mode 100644 index 000000000..f91f1da28 --- /dev/null +++ b/winsup/mingw/crt1.c @@ -0,0 +1,234 @@ +/* + * crt1.c + * + * Source code for the startup proceedures used by all programs. This code + * is compiled to make crt1.o, which should be located in the library path. + * + * This code is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Maintained by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +/* NOTE: The code for initializing the _argv, _argc, and environ variables + * has been moved to a separate .c file which is included in both + * crt1.c and dllcrt1.c. This means changes in the code don't have to + * be manually synchronized, but it does lead to this not-generally- + * a-good-idea use of include. */ +#include "init.c" + +extern int main (int, char **, char **); + +/* + * Must have the correct app type for MSVCRT. + */ + +#ifdef __MSVCRT__ +#define __UNKNOWN_APP 0 +#define __CONSOLE_APP 1 +#define __GUI_APP 2 +__MINGW_IMPORT void __set_app_type(int); +#endif /* __MSVCRT__ */ + +/* + * Setup the default file handles to have the _CRT_fmode mode, as well as + * any new files created by the user. + */ +extern unsigned int _CRT_fmode; + +static void +_mingw32_init_fmode () +{ + /* Don't set the file mode if the user hasn't set any value for it. */ + if (_CRT_fmode) + { + _fmode = _CRT_fmode; + + /* + * This overrides the default file mode settings for stdin, + * stdout and stderr. At first I thought you would have to + * test with isatty, but it seems that the DOS console at + * least is smart enough to handle _O_BINARY stdout and + * still display correctly. + */ + if (stdin) + { + _setmode (_fileno (stdin), _CRT_fmode); + } + if (stdout) + { + _setmode (_fileno (stdout), _CRT_fmode); + } + if (stderr) + { + _setmode (_fileno (stderr), _CRT_fmode); + } + } +} + +/* This function will be called when a trap occurs. Thanks to Jacob + Navia for his contribution. */ +static CALLBACK long +_gnu_exception_handler (EXCEPTION_POINTERS * exception_data) +{ + void (*old_handler) (int); + long action = EXCEPTION_CONTINUE_SEARCH; + int reset_fpu = 0; + + switch (exception_data->ExceptionRecord->ExceptionCode) + { + case EXCEPTION_ACCESS_VIOLATION: + /* test if the user has set SIGSEGV */ + old_handler = signal (SIGSEGV, SIG_DFL); + if (old_handler == SIG_IGN) + { + /* this is undefined if the signal was raised by anything other + than raise (). */ + signal (SIGSEGV, SIG_IGN); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGSEGV); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + case EXCEPTION_FLT_INVALID_OPERATION: + case EXCEPTION_FLT_DIVIDE_BY_ZERO: + case EXCEPTION_FLT_DENORMAL_OPERAND: + case EXCEPTION_FLT_OVERFLOW: + case EXCEPTION_FLT_UNDERFLOW: + case EXCEPTION_FLT_INEXACT_RESULT: + reset_fpu = 1; + /* fall through. */ + + case EXCEPTION_INT_DIVIDE_BY_ZERO: + /* test if the user has set SIGFPE */ + old_handler = signal (SIGFPE, SIG_DFL); + if (old_handler == SIG_IGN) + { + signal (SIGFPE, SIG_IGN); + if (reset_fpu) + _fpreset (); + action = EXCEPTION_CONTINUE_EXECUTION; + } + else if (old_handler != SIG_DFL) + { + /* This means 'old' is a user defined function. Call it */ + (*old_handler) (SIGFPE); + action = EXCEPTION_CONTINUE_EXECUTION; + } + break; + + default: + break; + } + return action; +} + +/* + * The function mainCRTStartup is the entry point for all console programs. + */ +static int +__mingw_CRTStartup () +{ + int nRet; + + /* + * Set up the top-level exception handler so that signal handling + * works as expected. The mapping between ANSI/POSIX signals and + * Win32 SE is not 1-to-1, so caveat emptore. + * + */ + SetUnhandledExceptionFilter (_gnu_exception_handler); + + /* + * Initialize floating point unit. + */ + _fpreset (); /* Supplied by the runtime library. */ + + /* + * Set up __argc, __argv and _environ. + */ + _mingw32_init_mainargs (); + + /* + * Sets the default file mode for stdin, stdout and stderr, as well + * as files later opened by the user, to _CRT_fmode. + * NOTE: DLLs don't do this because that would be rude! + */ + _mingw32_init_fmode (); + + /* + * Call the main function. If the user does not supply one + * the one in the 'libmingw32.a' library will be linked in, and + * that one calls WinMain. See main.c in the 'lib' dir + * for more details. + */ + nRet = main (_argc, _argv, environ); + + /* + * Perform exit processing for the C library. This means + * flushing output and calling 'atexit' registered functions. + */ + _cexit (); + + ExitProcess (nRet); + + return 0; +} + +/* + * The function mainCRTStartup is the entry point for all console programs. + */ +int +mainCRTStartup () +{ +#ifdef __MSVCRT__ + __set_app_type (__CONSOLE_APP); +#endif + __mingw_CRTStartup (); + return 0; +} + +/* + * For now the GUI startup function is the same as the console one. + * This simply gets rid of the annoying warning about not being able + * to find WinMainCRTStartup when linking GUI applications. + */ +int +WinMainCRTStartup () +{ +#ifdef __MSVCRT__ + __set_app_type (__GUI_APP); +#endif + __mingw_CRTStartup (); +} + diff --git a/winsup/mingw/crtdll.def b/winsup/mingw/crtdll.def new file mode 100644 index 000000000..00ff624c8 --- /dev/null +++ b/winsup/mingw/crtdll.def @@ -0,0 +1,704 @@ +; +; crtdll.def +; +; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this +; should also work with the crtdll provided with Windows NT. +; +; Contributors: +; Created by Colin Peters +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +; $Revision$ +; $Author$ +; $Date$ +; +; These three functions appear to be name mangled in some way, so GCC is +; probably not going to be able to use them in any case. +; +; ??2@YAPAXI@Z +; ??3@YAXPAX@Z +; ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z +; +; These are functions for which I have not yet written prototypes or +; otherwise set up (they are still included below though unlike those +; first three). +; +; _CIacos +; _CIasin +; _CIatan +; _CIatan2 +; _CIcos +; _CIcosh +; _CIexp +; _CIfmod +; _CIlog +; _CIlog10 +; _CIpow +; _CIsin +; _CIsinh +; _CIsqrt +; _CItan +; _CItanh +; __dllonexit +; __mb_cur_max_dll +; __threadhandle +; __threadid +; _abnormal_termination +; _acmdln_dll +; _aexit_rtn_dll +; _amsg_exit +; _commit +; _commode_dll +; _cpumode_dll +; _ctype +; _expand +; _fcloseall +; _filbuf +; _fileinfo_dll +; _flsbuf +; _flushall +; _fmode_dll +; _fpieee_flt +; _fsopen +; _ftol +; _getdiskfree +; _getdllprocaddr +; _getdrive +; _getdrives +; _getsystime +; _initterm +; _ismbbalnum +; _ismbbalpha +; _ismbbgraph +; _ismbbkalnum +; _ismbbkana +; _ismbbkpunct +; _ismbblead +; _ismbbprint +; _ismbbpunct +; _ismbbtrail +; _ismbcalpha +; _ismbcdigit +; _ismbchira +; _ismbckata +; _ismbcl0 +; _ismbcl1 +; _ismbcl2 +; _ismbclegal +; _ismbclower +; _ismbcprint +; _ismbcspace +; _ismbcsymbol +; _ismbcupper +; _ismbslead +; _ismbstrail +; _lfind +; _loaddll +; _lrotl +; _lrotr +; _lsearch +; _makepath +; _matherr +; _mbbtombc +; _mbbtype +; _mbccpy +; _mbcjistojms +; _mbcjmstojis +; _mbclen +; _mbctohira +; _mbctokata +; _mbctolower +; _mbctombb +; _mbctoupper +; _mbctype +; _mbsbtype +; _mbscat +; _mbscmp +; _mbscpy +; _mbscspn +; _mbsdec +; _mbsdup +; _mbsicmp +; _mbsinc +; _mbslen +; _mbslwr +; _mbsnbcat +; _mbsnbcmp +; _mbsnbcnt +; _mbsnbcpy +; _mbsnbicmp +; _mbsnbset +; _mbsnccnt +; _mbsncmp +; _mbsncpy +; _mbsnextc +; _mbsnicmp +; _mbsninc +; _mbsnset +; _mbspbrk +; _mbsrchr +; _mbsrev +; _mbsset +; _mbsspn +; _mbsspnp +; _mbsstr +; _mbstrlen +; _mbsupr +; _onexit +; _osversion_dll +; _pctype_dll +; _purecall +; _pwctype_dll +; _rmtmp +; _rotl +; _rotr +; _setsystime +; _snprintf +; _snwprintf +; _splitpath +; _strdate +; _strdec +; _strinc +; _strncnt +; _strnextc +; _strninc +; _strspnp +; _strtime +; _tempnam +; _ultoa +; _unloaddll +; _vsnprintf +; _vsnwprintf +; _wtoi +; _wtol +; +EXPORTS +_CIacos +_CIasin +_CIatan +_CIatan2 +_CIcos +_CIcosh +_CIexp +_CIfmod +_CIlog +_CIlog10 +_CIpow +_CIsin +_CIsinh +_CIsqrt +_CItan +_CItanh +_HUGE_dll DATA +_XcptFilter +__GetMainArgs +__argc_dll DATA +__argv_dll DATA +__dllonexit +__doserrno +__fpecode +__isascii +__iscsym +__iscsymf +__mb_cur_max_dll DATA +__pxcptinfoptrs +__threadhandle +__threadid +__toascii +_abnormal_termination +_access +_acmdln_dll DATA +_aexit_rtn_dll DATA +_amsg_exit +_assert +_basemajor_dll DATA +_baseminor_dll DATA +_baseversion_dll DATA +_beep +_beginthread +_c_exit +_cabs +_cexit +_cgets +_chdir +_chdrive +_chgsign +_chmod +_chsize +_clearfp +_close +_commit +_commode_dll DATA +_control87 +_controlfp +_copysign +_cprintf +_cpumode_dll DATA +_cputs +_creat +_cscanf +_ctype +_cwait +_daylight_dll DATA +_dup +_dup2 +_ecvt +_endthread +_environ_dll DATA +_eof +_errno +_except_handler2 +_execl +_execle +_execlp +_execlpe +_execv +_execve +_execvp +_execvpe +_exit +_expand +_fcloseall +_fcvt +_fdopen +_fgetchar +_fgetwchar +_filbuf +_fileinfo_dll DATA +_filelength +_fileno +_findclose +_findfirst +_findnext +_finite +_flsbuf +_flushall +_fmode_dll DATA +_fpclass +_fpieee_flt +_fpreset +_fputchar +_fputwchar +_fsopen +_fstat +_ftime +_ftol +_fullpath +_futime +_gcvt +_get_osfhandle +_getch +_getche +_getcwd +_getdcwd +_getdiskfree +_getdllprocaddr +_getdrive +_getdrives +_getpid +_getsystime +_getw +_global_unwind2 +_heapchk +_heapmin +_heapset +_heapwalk +_hypot +_initterm +_iob DATA +_isatty +_isctype +_ismbbalnum +_ismbbalpha +_ismbbgraph +_ismbbkalnum +_ismbbkana +_ismbbkpunct +_ismbblead +_ismbbprint +_ismbbpunct +_ismbbtrail +_ismbcalpha +_ismbcdigit +_ismbchira +_ismbckata +_ismbcl0 +_ismbcl1 +_ismbcl2 +_ismbclegal +_ismbclower +_ismbcprint +_ismbcspace +_ismbcsymbol +_ismbcupper +_ismbslead +_ismbstrail +_isnan +_itoa +_j0 +_j1 +_jn +_kbhit +_lfind +_loaddll +_local_unwind2 +_locking +_logb +_lrotl +_lrotr +_lsearch +_lseek +_ltoa +_makepath +_matherr +_mbbtombc +_mbbtype +_mbccpy +_mbcjistojms +_mbcjmstojis +_mbclen +_mbctohira +_mbctokata +_mbctolower +_mbctombb +_mbctoupper +_mbctype +_mbsbtype +_mbscat +_mbschr +_mbscmp +_mbscpy +_mbscspn +_mbsdec +_mbsdup +_mbsicmp +_mbsinc +_mbslen +_mbslwr +_mbsnbcat +_mbsnbcmp +_mbsnbcnt +_mbsnbcpy +_mbsnbicmp +_mbsnbset +_mbsncat +_mbsnccnt +_mbsncmp +_mbsncpy +_mbsnextc +_mbsnicmp +_mbsninc +_mbsnset +_mbspbrk +_mbsrchr +_mbsrev +_mbsset +_mbsspn +_mbsspnp +_mbsstr +_mbstok +_mbstrlen +_mbsupr +_memccpy +_memicmp +_mkdir +_mktemp +_msize +_nextafter +_onexit +_open +_open_osfhandle +_osmajor_dll DATA +_osminor_dll DATA +_osmode_dll DATA +_osver_dll DATA +_osversion_dll DATA +_pclose +_pctype_dll DATA +_pgmptr_dll DATA +_pipe +_popen +_purecall +_putch +_putenv +_putw +_pwctype_dll DATA +_read +_rmdir +_rmtmp +_rotl +_rotr +_scalb +_searchenv +_seterrormode +_setjmp +_setmode +_setsystime +_sleep +_snprintf +_snwprintf +_sopen +_spawnl +_spawnle +_spawnlp +_spawnlpe +_spawnv +_spawnve +_spawnvp +_spawnvpe +_splitpath +_stat +_statusfp +_strcmpi +_strdate +_strdec +_strdup +_strerror +_stricmp +_stricoll +_strinc +_strlwr +_strncnt +_strnextc +_strnicmp +_strninc +_strnset +_strrev +_strset +_strspnp +_strtime +_strupr +_swab +_sys_errlist DATA +_sys_nerr_dll DATA +_tell +_tempnam +_timezone_dll DATA +_tolower +_toupper +_tzname DATA +_tzset +_ultoa +_umask +_ungetch +_unlink +_unloaddll +_utime +_vsnprintf +_vsnwprintf +_wcsdup +_wcsicmp +_wcsicoll +_wcslwr +_wcsnicmp +_wcsnset +_wcsrev +_wcsset +_wcsupr +_winmajor_dll DATA +_winminor_dll DATA +_winver_dll DATA +_write +_wtoi +_wtol +_y0 +_y1 +_yn +abort +abs +acos +asctime +asin +atan +atan2 +atexit +atof +atoi +atol +bsearch +calloc +ceil +clearerr +clock +cos +cosh +ctime +difftime +div +exit +exp +fabs +fclose +feof +ferror +fflush +fgetc +fgetpos +fgets +fgetwc +floor +fmod +fopen +fprintf +fputc +fputs +fputwc +fread +free +freopen +frexp +fscanf +fseek +fsetpos +ftell +fwprintf +fwrite +fwscanf +getc +getchar +getenv +gets +gmtime +is_wctype +isalnum +isalpha +iscntrl +isdigit +isgraph +isleadbyte +islower +isprint +ispunct +isspace +isupper +iswalnum +iswalpha +iswascii +iswcntrl +iswctype +iswdigit +iswgraph +iswlower +iswprint +iswpunct +iswspace +iswupper +iswxdigit +isxdigit +labs +ldexp +ldiv +localeconv +localtime +log +log10 +longjmp +malloc +mblen +mbstowcs +mbtowc +memchr +memcmp +memcpy +memmove +memset +mktime +modf +perror +pow +printf +putc +putchar +puts +qsort +raise +rand +realloc +remove +rename +rewind +scanf +setbuf +setlocale +setvbuf +signal +sin +sinh +sprintf +sqrt +srand +sscanf +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strerror +strftime +strlen +strncat +strncmp +strncpy +strpbrk +strrchr +strspn +strstr +strtod +strtok +strtol +strtoul +strxfrm +swprintf +swscanf +system +tan +tanh +time +tmpfile +tmpnam +tolower +toupper +towlower +towupper +ungetc +ungetwc +vfprintf +vfwprintf +vprintf +vsprintf +vswprintf +vwprintf +wcscat +wcschr +wcscmp +wcscoll +wcscpy +wcscspn +wcsftime +wcslen +wcsncat +wcsncmp +wcsncpy +wcspbrk +wcsrchr +wcsspn +wcsstr +wcstod +wcstok +wcstol +wcstombs +wcstoul +wcsxfrm +wctomb +wprintf +wscanf diff --git a/winsup/mingw/crtmt.c b/winsup/mingw/crtmt.c new file mode 100644 index 000000000..116d850f0 --- /dev/null +++ b/winsup/mingw/crtmt.c @@ -0,0 +1,14 @@ +/* + * crtmt.c + * + * This object file defines _CRT_MT to have a value of 1, which will + * turn on MT support in GCC runtime. This is only linked in when + * you specify -mthreads when linking with gcc. The Mingw support + * library, libmingw32.a, contains the complement, crtst.o, which + * sets this variable to 0. + * + * Mumit Khan + * + */ + +int _CRT_MT = 1; diff --git a/winsup/mingw/crtst.c b/winsup/mingw/crtst.c new file mode 100644 index 000000000..4835b0963 --- /dev/null +++ b/winsup/mingw/crtst.c @@ -0,0 +1,12 @@ +/* + * crtst.c + * + * This object file defines _CRT_MT to have a value of 0, which will + * turn off MT support in GCC runtime. This is linked by default unless + * you specify -mthreads when linking with gcc. + * + * Mumit Khan + * + */ + +int _CRT_MT = 0; diff --git a/winsup/mingw/ctype_old.c b/winsup/mingw/ctype_old.c new file mode 100644 index 000000000..07eaec1d8 --- /dev/null +++ b/winsup/mingw/ctype_old.c @@ -0,0 +1,52 @@ +/* + * ctype_old.c + * + * Oldnames from ANSI header ctype.h + * + * Some wrapper functions for those old name functions whose appropriate + * equivalents are not simply underscore prefixed. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include + +int +isascii (int c) +{ + return __isascii(c); +} + +int +toascii (int c) +{ + return __toascii(c); +} + +int +iscsymf (int c) +{ + return __iscsymf(c); +} + +int +iscsym (int c) +{ + return __iscsym(c); +} diff --git a/winsup/mingw/dllcrt1.c b/winsup/mingw/dllcrt1.c new file mode 100644 index 000000000..a0055d8b0 --- /dev/null +++ b/winsup/mingw/dllcrt1.c @@ -0,0 +1,89 @@ +/* + * dllcrt1.c + * + * Initialization code for DLLs. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * DLL support adapted from Gunther Ebert + * Maintained by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include +#include +#include +#include + +/* Unlike normal crt1, I don't initialize the FPU, because the process + * should have done that already. I also don't set the file handle modes, + * because that would be rude. */ + +#ifdef __GNUC__ +extern void __main (); +extern void __do_global_dtors (); +#endif + +extern BOOL WINAPI DllMain (HANDLE, DWORD, LPVOID); + +BOOL WINAPI +DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + BOOL bRet; + + if (dwReason == DLL_PROCESS_ATTACH) + { +#ifdef __GNUC__ + /* From libgcc.a, calls global class constructors. */ + __main (); +#endif + } + + /* + * Call the user-supplied DllMain subroutine + * NOTE: DllMain is optional, so libmingw32.a includes a stub + * which will be used if the user does not supply one. + */ + bRet = DllMain (hDll, dwReason, lpReserved); + +#ifdef __GNUC__ + if (dwReason == DLL_PROCESS_DETACH) + { + /* From libgcc.a, calls global class destructors. */ + __do_global_dtors (); + } +#endif + + return bRet; +} + +/* + * For the moment a dummy atexit. Atexit causes problems in DLLs, especially + * if they are dynamically loaded. For now atexit inside a DLL does nothing. + * NOTE: We need this even if the DLL author never calls atexit because + * the global constructor function __do_global_ctors called from __main + * will attempt to register __do_global_dtors using atexit. + * Thanks to Andrey A. Smirnov for pointing this one out. + */ +int +atexit (void (*pfn) ()) +{ + return 0; +} + diff --git a/winsup/mingw/dllmain.c b/winsup/mingw/dllmain.c new file mode 100644 index 000000000..40c4f4f37 --- /dev/null +++ b/winsup/mingw/dllmain.c @@ -0,0 +1,33 @@ +/* + * dllmain.c + * + * A stub DllMain function which will be called by DLLs which do not + * have a user supplied DllMain. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include + +BOOL WINAPI +DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + return TRUE; +} + diff --git a/winsup/mingw/gccmain.c b/winsup/mingw/gccmain.c new file mode 100644 index 000000000..5c438e98a --- /dev/null +++ b/winsup/mingw/gccmain.c @@ -0,0 +1,85 @@ +/* + * gccmain.c + * + * A separate version of __main, __do_global_ctors and __do_global_dtors for + * Mingw32 for use with Cygwin32 b19. Hopefully this object file will only + * be linked if the libgcc.a doesn't include __main, __do_global_dtors and + * __do_global_ctors. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Code supplied by Stan Cox + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +/* Needed for the atexit prototype. */ +#include + +typedef void (*func_ptr) (void); +extern func_ptr __CTOR_LIST__[]; +extern func_ptr __DTOR_LIST__[]; + +void +__do_global_dtors (void) +{ + static func_ptr *p = __DTOR_LIST__ + 1; + + /* + * Call each destructor in the destructor list until a null pointer + * is encountered. + */ + while (*p) + { + (*(p)) (); + p++; + } +} + +void +__do_global_ctors (void) +{ + unsigned long nptrs = (unsigned long) __CTOR_LIST__[0]; + unsigned i; + + /* + * If the first entry in the constructor list is -1 then the list + * is terminated with a null entry. Otherwise the first entry was + * the number of pointers in the list. + */ + if (nptrs == -1) + { + for (nptrs = 0; __CTOR_LIST__[nptrs + 1] != 0; nptrs++) + ; + } + + /* + * Go through the list backwards calling constructors. + */ + for (i = nptrs; i >= 1; i--) + { + __CTOR_LIST__[i] (); + } + + /* + * Register the destructors for processing on exit. + */ + atexit (__do_global_dtors); +} + +static int initialized = 0; + +void +__main (void) +{ + if (!initialized) + { + initialized = 1; + __do_global_ctors (); + } +} + diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h new file mode 100644 index 000000000..780cdda3a --- /dev/null +++ b/winsup/mingw/include/_mingw.h @@ -0,0 +1,68 @@ +/* + * _mingw.h + * + * Mingw specific macros included by ALL include files. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef __MINGW_H +#define __MINGW_H + +/* These are defined by the user (or the compiler) + to specify how identifiers are imported from a DLL. + + __DECLSPEC_SUPPORTED Defined if dllimport attribute is supported. + __MINGW_IMPORT The attribute definition to specify imported + variables/functions. + __MINGW32_VERSION Runtime version. + __MINGW32_MAJOR_VERSION Runtime major version. + __MINGW32_MINOR_VERSION Runtime minor version. + __MINGW32_BUILD_DATE Runtime build date. + + Other macros: + + __int64 define to be long long. Using a typedef can + tweak bugs in the C++ parser. + + All headers should include this first, and then use __DECLSPEC_SUPPORTED + to choose between the old ``__imp__name'' style or __MINGW_IMPORT + style declarations. */ + +#ifndef __GNUC__ +# define __MINGW_IMPORT __declspec(dllimport) +# define __DECLSPEC_SUPPORTED +#else /* __GNUC__ */ +# ifdef __declspec + /* note the extern at the end. This is needed to work around GCC's + limitations in handling dllimport attribute. */ +# define __MINGW_IMPORT __attribute__((dllimport)) extern +# define __DECLSPEC_SUPPORTED +# else +# undef __DECLSPEC_SUPPORTED +# undef __MINGW_IMPORT +# endif +# undef __int64 +# define __int64 long long +#endif /* __GNUC__ */ + +#define __MINGW32_VERSION 0.3 +#define __MINGW32_MAJOR_VERSION 0 +#define __MINGW32_MINOR_VERSION 3 + +#endif /* __MINGW_H */ + diff --git a/winsup/mingw/include/assert.h b/winsup/mingw/include/assert.h new file mode 100644 index 000000000..18deea166 --- /dev/null +++ b/winsup/mingw/include/assert.h @@ -0,0 +1,71 @@ +/* + * assert.h + * + * Define the assert macro for debug output. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _ASSERT_H_ +#define _ASSERT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef NDEBUG + +/* + * If not debugging, assert does nothing. + */ +#define assert(x) ((void)0); + +#else /* debugging enabled */ + +/* + * CRTDLL nicely supplies a function which does the actual output and + * call to abort. + */ +void _assert (const char*, const char*, int) +#ifdef __GNUC__ + __attribute__ ((noreturn)) +#endif + ; + +/* + * Definition of the assert macro. + */ +#define assert(e) ((e) ? (void)0 : _assert(#e, __FILE__, __LINE__)) +#endif /* NDEBUG */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _ASSERT_H_ */ + diff --git a/winsup/mingw/include/conio.h b/winsup/mingw/include/conio.h new file mode 100644 index 000000000..f4fa731d8 --- /dev/null +++ b/winsup/mingw/include/conio.h @@ -0,0 +1,74 @@ +/* + * conio.h + * + * Low level console I/O functions. Pretty please try to use the ANSI + * standard ones if you are writing new code. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _CONIO_H_ +#define _CONIO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + + +char* _cgets (char*); +int _cprintf (const char*, ...); +int _cputs (const char*); +int _cscanf (char*, ...); + +int _getch (void); +int _getche (void); +int _kbhit (void); +int _putch (int); +int _ungetch (int); + + +#ifndef _NO_OLDNAMES + +int getch (void); +int getche (void); +int kbhit (void); +int putch (int); +int ungetch (int); + +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _CONIO_H_ */ + +#endif /* Not __STRICT_ANSI__ */ diff --git a/winsup/mingw/include/ctype.h b/winsup/mingw/include/ctype.h new file mode 100644 index 000000000..e58b15321 --- /dev/null +++ b/winsup/mingw/include/ctype.h @@ -0,0 +1,153 @@ +/* + * ctype.h + * + * Functions for testing character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _CTYPE_H_ +#define _CTYPE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + + +/* + * The following flags are used to tell iswctype and _isctype what character + * types you are looking for. + */ +#define _UPPER 0x0001 +#define _LOWER 0x0002 +#define _DIGIT 0x0004 +#define _SPACE 0x0008 +#define _PUNCT 0x0010 +#define _CONTROL 0x0020 +#define _BLANK 0x0040 +#define _HEX 0x0080 +#define _LEADBYTE 0x8000 + +#define _ALPHA 0x0103 + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +int isalnum(int); +int isalpha(int); +int iscntrl(int); +int isdigit(int); +int isgraph(int); +int islower(int); +int isprint(int); +int ispunct(int); +int isspace(int); +int isupper(int); +int isxdigit(int); + +#ifndef __STRICT_ANSI__ +int _isctype (int, int); +#endif + +int tolower(int); +int toupper(int); + +/* + * NOTE: The above are not old name type wrappers, but functions exported + * explicitly by CRTDLL. However, underscored versions are also exported. + */ +#ifndef __STRICT_ANSI__ +int _tolower(int); +int _toupper(int); +#endif + +#ifndef WEOF +#define WEOF (wchar_t)(0xFFFF) +#endif + +/* Also defined in stdlib.h */ +#ifndef MB_CUR_MAX +# ifdef __MSVCRT__ +# define MB_CUR_MAX __mb_cur_max + __MINGW_IMPORT int __mb_cur_max; +# else /* not __MSVCRT */ +# define MB_CUR_MAX __mb_cur_max_dll + __MINGW_IMPORT int __mb_cur_max_dll; +# endif /* not __MSVCRT */ +#endif /* MB_CUR_MAX */ + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +/* Wide character equivalents */ +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswascii(wint_t); +int iswcntrl(wint_t); +int iswctype(wint_t, wctype_t); +int is_wctype(wint_t, wctype_t); /* Obsolete! */ +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); + +wchar_t towlower(wchar_t); +wchar_t towupper(wchar_t); + +int isleadbyte (int); + +#ifndef __STRICT_ANSI__ +int __isascii (int); +int __toascii (int); +int __iscsymf (int); /* Valid first character in C symbol */ +int __iscsym (int); /* Valid character in C symbol (after first) */ + +#ifndef _NO_OLDNAMES +int isascii (int); +int toascii (int); +int iscsymf (int); +int iscsym (int); +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _CTYPE_H_ */ + diff --git a/winsup/mingw/include/dir.h b/winsup/mingw/include/dir.h new file mode 100644 index 000000000..8f089f82c --- /dev/null +++ b/winsup/mingw/include/dir.h @@ -0,0 +1,26 @@ +/* + * dir.h + * + * This file OBSOLESCENT and only provided for backward compatibility. + * Please use io.h instead. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#include + diff --git a/winsup/mingw/include/direct.h b/winsup/mingw/include/direct.h new file mode 100644 index 000000000..cac11a8df --- /dev/null +++ b/winsup/mingw/include/direct.h @@ -0,0 +1,96 @@ +/* + * direct.h + * + * Functions for manipulating paths and directories (included from io.h) + * plus functions for setting the current drive. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DIRECT_H_ +#define _DIRECT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef _DISKFREE_T_DEFINED +/* needed by _getdiskfree (also in dos.h) */ +struct _diskfree_t { + unsigned total_clusters; + unsigned avail_clusters; + unsigned sectors_per_cluster; + unsigned bytes_per_sector; +}; +#define _DISKFREE_T_DEFINED +#endif + +/* + * You really shouldn't be using these. Use the Win32 API functions instead. + * However, it does make it easier to port older code. + */ +int _getdrive (void); +unsigned long _getdrives(void); +int _chdrive (int); +char* _getdcwd (int, char*, int); +unsigned _getdiskfree (unsigned, struct _diskfree_t *); + +#ifndef _NO_OLDNAMES +# define diskfree_t _diskfree_t +#endif + +#ifndef _WDIRECT_DEFINED + +/* wide character versions. Also in wchar.h */ + +int _wchdir(const wchar_t*); +wchar_t* _wgetcwd(wchar_t*, int); +wchar_t* _wgetdcwd(int, wchar_t*, int); +int _wmkdir(const wchar_t*); +int _wrmdir(const wchar_t*); + +#define _WDIRECT_DEFINED +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRECT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/dirent.h b/winsup/mingw/include/dirent.h new file mode 100644 index 000000000..3d484ee9b --- /dev/null +++ b/winsup/mingw/include/dirent.h @@ -0,0 +1,96 @@ +/* + * DIRENT.H (formerly DIRLIB.H) + * + * by M. J. Weinstein Released to public domain 1-Jan-89 + * + * Because I have heard that this feature (opendir, readdir, closedir) + * it so useful for programmers coming from UNIX or attempting to port + * UNIX code, and because it is reasonably light weight, I have included + * it in the Mingw32 package. I have also added an implementation of + * rewinddir, seekdir and telldir. + * - Colin Peters + * + * This code is distributed in the hope that is will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includeds but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DIRENT_H_ +#define _DIRENT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +struct dirent +{ + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + char* d_name; /* File name. */ + /* NOTE: The name in the dirent structure points to the name in the + * finddata_t structure in the DIR. */ +}; + +/* + * This is an internal data structure. Good programmers will not use it + * except as an argument to one of the functions below. + */ +typedef struct +{ + /* disk transfer area for this dir */ + struct _finddata_t dd_dta; + + /* dirent struct to return from dir (NOTE: this makes this thread + * safe as long as only one thread uses a particular DIR struct at + * a time) */ + struct dirent dd_dir; + + /* _findnext handle */ + long dd_handle; + + /* + * Status of search: + * 0 = not started yet (next entry to read is first entry) + * -1 = off the end + * positive = 0 based index of next entry + */ + short dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + char dd_name[1]; +} DIR; + + +DIR* opendir (const char*); +struct dirent* readdir (DIR*); +int closedir (DIR*); +void rewinddir (DIR*); +long telldir (DIR*); +void seekdir (DIR*, long); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DIRENT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/dos.h b/winsup/mingw/include/dos.h new file mode 100644 index 000000000..a67c19962 --- /dev/null +++ b/winsup/mingw/include/dos.h @@ -0,0 +1,123 @@ +/* + * dos.h + * + * DOS-specific functions and structures. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by J.J. van der Heijden + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _DOS_H_ +#define _DOS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +/* For DOS file attributes */ +#include + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __DECLSPEC_SUPPORTED + +extern char** __imp__pgmptr_dll; +#define _pgmptr (*__imp__pgmptr_dll) + +/* Wide character equivalent */ +extern wchar_t** __imp_wpgmptr_dll; +#define _wpgmptr (*__imp__wpgmptr_dll) + +extern unsigned int *__imp__basemajor_dll; +extern unsigned int *__imp__baseminor_dll; +extern unsigned int *__imp__baseversion_dll; +extern unsigned int *__imp__osmajor_dll; +extern unsigned int *__imp__osminor_dll; +extern unsigned int *__imp__osmode_dll; + +#define _basemajor (*__imp__basemajor_dll) +#define _baseminor (*__imp__baseminor_dll) +#define _baseversion (*__imp__baseversion_dll) +#define _osmajor (*__imp__osmajor_dll) +#define _osminor (*__imp__osminor_dll) +#define _osmode (*__imp__osmode_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT char* _pgmptr_dll; +#define _pgmptr _pgmptr_dll + +/* Wide character equivalent */ +__MINGW_IMPORT wchar_t* _wpgmptr_dll; +#define _wpgmptr _wpgmptr_dll + +__MINGW_IMPORT unsigned int _basemajor_dll; +__MINGW_IMPORT unsigned int _baseminor_dll; +__MINGW_IMPORT unsigned int _baseversion_dll; +__MINGW_IMPORT unsigned int _osmajor_dll; +__MINGW_IMPORT unsigned int _osminor_dll; +__MINGW_IMPORT unsigned int _osmode_dll; + +#define _basemajor _basemajor_dll +#define _baseminor _baseminor_dll +#define _baseversion _baseversion_dll +#define _osmajor _osmajor_dll +#define _osminor _osminor_dll +#define _osmode _osmode_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#ifndef _DISKFREE_T_DEFINED +/* needed by _getdiskfree (also in direct.h) */ +struct _diskfree_t { + unsigned total_clusters; + unsigned avail_clusters; + unsigned sectors_per_cluster; + unsigned bytes_per_sector; +}; +#define _DISKFREE_T_DEFINED +#endif + +unsigned _getdiskfree (unsigned, struct _diskfree_t *); + +#ifndef _NO_OLDNAMES +# define diskfree_t _diskfree_t +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _DOS_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/errno.h b/winsup/mingw/include/errno.h new file mode 100644 index 000000000..d731078f5 --- /dev/null +++ b/winsup/mingw/include/errno.h @@ -0,0 +1,117 @@ +/* + * errno.h + * + * Error numbers and access to error reporting. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _ERRNO_H_ +#define _ERRNO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Error numbers. + * TODO: Can't be sure of some of these assignments, I guessed from the + * names given by strerror and the defines in the Cygnus errno.h. A lot + * of the names from the Cygnus errno.h are not represented, and a few + * of the descriptions returned by strerror do not obviously match + * their error naming. + */ +#define EPERM 1 /* Operation not permitted */ +#define ENOFILE 2 /* No such file or directory */ +#define ENOENT 2 +#define ESRCH 3 /* No such process */ +#define EINTR 4 /* Interrupted function call */ +#define EIO 5 /* Input/output error */ +#define ENXIO 6 /* No such device or address */ +#define E2BIG 7 /* Arg list too long */ +#define ENOEXEC 8 /* Exec format error */ +#define EBADF 9 /* Bad file descriptor */ +#define ECHILD 10 /* No child processes */ +#define EAGAIN 11 /* Resource temporarily unavailable */ +#define ENOMEM 12 /* Not enough space */ +#define EACCES 13 /* Permission denied */ +#define EFAULT 14 /* Bad address */ +/* 15 - Unknown Error */ +#define EBUSY 16 /* strerror reports "Resource device" */ +#define EEXIST 17 /* File exists */ +#define EXDEV 18 /* Improper link (cross-device link?) */ +#define ENODEV 19 /* No such device */ +#define ENOTDIR 20 /* Not a directory */ +#define EISDIR 21 /* Is a directory */ +#define EINVAL 22 /* Invalid argument */ +#define ENFILE 23 /* Too many open files in system */ +#define EMFILE 24 /* Too many open files */ +#define ENOTTY 25 /* Inappropriate I/O control operation */ +/* 26 - Unknown Error */ +#define EFBIG 27 /* File too large */ +#define ENOSPC 28 /* No space left on device */ +#define ESPIPE 29 /* Invalid seek (seek on a pipe?) */ +#define EROFS 30 /* Read-only file system */ +#define EMLINK 31 /* Too many links */ +#define EPIPE 32 /* Broken pipe */ +#define EDOM 33 /* Domain error (math functions) */ +#define ERANGE 34 /* Result too large (possibly too small) */ +/* 35 - Unknown Error */ +#define EDEADLOCK 36 /* Resource deadlock avoided (non-Cyg) */ +#define EDEADLK 36 +/* 37 - Unknown Error */ +#define ENAMETOOLONG 38 /* Filename too long (91 in Cyg?) */ +#define ENOLCK 39 /* No locks available (46 in Cyg?) */ +#define ENOSYS 40 /* Function not implemented (88 in Cyg?) */ +#define ENOTEMPTY 41 /* Directory not empty (90 in Cyg?) */ +#define EILSEQ 42 /* Illegal byte sequence */ + +/* + * NOTE: ENAMETOOLONG and ENOTEMPTY conflict with definitions in the + * sockets.h header provided with windows32api-0.1.2. + * You should go and put an #if 0 ... #endif around the whole block + * of errors (look at the comment above them). + */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Definitions of errno. For _doserrno, sys_nerr and * sys_errlist, see + * stdlib.h. + */ +#ifdef _UWIN +#undef errno +extern int errno; +#else +int* _errno(); +#define errno (*_errno()) +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _ERRNO_H_ */ diff --git a/winsup/mingw/include/excpt.h b/winsup/mingw/include/excpt.h new file mode 100644 index 000000000..7bc032938 --- /dev/null +++ b/winsup/mingw/include/excpt.h @@ -0,0 +1,123 @@ +/* + * excpt.h + * + * Support for operating system level structured exception handling. + * + * NOTE: This is very preliminary stuff. I am also pretty sure it is + * completely Intel specific. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Based on code by Mikey + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _EXCPT_H_ +#define _EXCPT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef __STRICT_ANSI__ + +#include + +/* + * NOTE: The constants structs and typedefs below should be defined in the + * Win32 API headers. + */ +#define EH_NONCONTINUABLE 0x01 +#define EH_UNWINDING 0x02 +#define EH_EXIT_UNWIND 0x04 +#define EH_STACK_INVALID 0x08 +#define EH_NESTED_CALL 0x10 + +#ifndef RC_INVOKED + +typedef enum { + ExceptionContinueExecution, + ExceptionContinueSearch, + ExceptionNestedException, + ExceptionCollidedUnwind +} EXCEPTION_DISPOSITION; + + +/* + * End of stuff that should be in the Win32 API files. + */ + + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The type of function that is expected as an exception handler to be + * installed with _try1. + */ +typedef EXCEPTION_DISPOSITION (*PEXCEPTION_HANDLER) + (struct _EXCEPTION_RECORD*, void*, struct _CONTEXT*, void*); + +/* + * This is not entirely necessary, but it is the structure installed by + * the _try1 primitive below. + */ +typedef struct _EXCEPTION_REGISTRATION +{ + struct _EXCEPTION_REGISTRATION* prev; + PEXCEPTION_HANDLER handler; +} EXCEPTION_REGISTRATION, *PEXCEPTION_REGISTRATION; + +typedef EXCEPTION_REGISTRATION EXCEPTION_REGISTRATION_RECORD; +typedef PEXCEPTION_REGISTRATION PEXCEPTION_REGISTRATION_RECORD; + +/* + * A macro which installs the supplied exception handler. + * Push the pointer to the new handler onto the stack, + * then push the pointer to the old registration structure (at fs:0) + * onto the stack, then put a pointer to the new registration + * structure (i.e. the current stack pointer) at fs:0. + */ +#define __try1(pHandler) \ + __asm__ ("pushl %0;pushl %%fs:0;movl %%esp,%%fs:0;" : : "g" (pHandler)); + +/* + * A macro which (dispite its name) *removes* an installed + * exception handler. Should be used only in conjunction with the above + * install routine __try1. + * Move the pointer to the old reg. struct (at the current stack + * position) to fs:0, replacing the pointer we installed above, + * then add 8 to the stack pointer to get rid of the space we + * used when we pushed on our new reg. struct above. Notice that + * the stack must be in the exact state at this point that it was + * after we did _try1 or this will smash things. + */ +#define __except1 \ + __asm__ ("movl (%%esp),%%eax;movl %%eax,%%fs:0;addl $8,%%esp;" \ + : : : "%eax"); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not strict ANSI */ + +#endif /* _EXCPT_H_ not defined */ diff --git a/winsup/mingw/include/fcntl.h b/winsup/mingw/include/fcntl.h new file mode 100644 index 000000000..44b00097a --- /dev/null +++ b/winsup/mingw/include/fcntl.h @@ -0,0 +1,135 @@ +/* + * fcntl.h + * + * Access constants for _open. Note that the permissions constants are + * in sys/stat.h (ick). + * + * This code is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _FCNTL_H_ +#define _FCNTL_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * It appears that fcntl.h should include io.h for compatibility... + */ +#include + +/* Specifiy one of these flags to define the access mode. */ +#define _O_RDONLY 0 +#define _O_WRONLY 1 +#define _O_RDWR 2 + +/* Mask for access mode bits in the _open flags. */ +#define _O_ACCMODE (_O_RDONLY|_O_WRONLY|_O_RDWR) + +#define _O_APPEND 0x0008 /* Writes will add to the end of the file. */ + +#define _O_RANDOM 0x0010 +#define _O_SEQUENTIAL 0x0020 +#define _O_TEMPORARY 0x0040 /* Make the file dissappear after closing. + * WARNING: Even if not created by _open! */ +#define _O_NOINHERIT 0x0080 + +#define _O_CREAT 0x0100 /* Create the file if it does not exist. */ +#define _O_TRUNC 0x0200 /* Truncate the file if it does exist. */ +#define _O_EXCL 0x0400 /* Open only if the file does not exist. */ + +/* NOTE: Text is the default even if the given _O_TEXT bit is not on. */ +#define _O_TEXT 0x4000 /* CR-LF in file becomes LF in memory. */ +#define _O_BINARY 0x8000 /* Input and output is not translated. */ +#define _O_RAW _O_BINARY + +#ifndef _NO_OLDNAMES + +/* POSIX/Non-ANSI names for increased portability */ +#define O_RDONLY _O_RDONLY +#define O_WRONLY _O_WRONLY +#define O_RDWR _O_RDWR +#define O_ACCMODE _O_ACCMODE +#define O_APPEND _O_APPEND +#define O_CREAT _O_CREAT +#define O_TRUNC _O_TRUNC +#define O_EXCL _O_EXCL +#define O_TEXT _O_TEXT +#define O_BINARY _O_BINARY +#define O_TEMPORARY _O_TEMPORARY +#define O_NOINHERIT _O_NOINHERIT +#define O_SEQENTIAL _O_SEQUENTIAL +#define O_RANDOM _O_RANDOM + +#endif /* Not _NO_OLDNAMES */ + + +#ifndef RC_INVOKED + +/* + * This variable determines the default file mode. + * TODO: Which flags work? + */ +#ifndef __DECLSPEC_SUPPORTED + +#ifdef __MSVCRT__ +extern unsigned int* __imp__fmode; +#define _fmode (*__imp__fmode) +#else +/* CRTDLL */ +extern unsigned int* __imp__fmode_dll; +#define _fmode (*__imp__fmode_dll) +#endif + +#else /* __DECLSPEC_SUPPORTED */ + +#ifdef __MSVCRT__ +__MINGW_IMPORT unsigned int _fmode; +#else /* ! __MSVCRT__ */ +__MINGW_IMPORT unsigned int _fmode_dll; +#define _fmode _fmode_dll +#endif /* ! __MSVCRT__ */ + +#endif /* __DECLSPEC_SUPPORTED */ + + +#ifdef __cplusplus +extern "C" { +#endif + +int _setmode (int, int); + +#ifndef _NO_OLDNAMES +int setmode (int, int); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _FCNTL_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/float.h b/winsup/mingw/include/float.h new file mode 100644 index 000000000..af7c08614 --- /dev/null +++ b/winsup/mingw/include/float.h @@ -0,0 +1,219 @@ +/* + * float.h + * + * Constants related to floating point arithmetic. + * + * Also included here are some non-ANSI bits for accessing the floating + * point controller. + * + * NOTE: GCC provides float.h, and it is probably more accurate than this, + * but it doesn't include the non-standard stuff for accessing the + * fp controller. (TODO: Move those bits elsewhere?) Thus it is + * probably not a good idea to use the GCC supplied version instead + * of this header. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _FLOAT_H_ +#define _FLOAT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define FLT_ROUNDS 1 +#define FLT_GUARD 1 +#define FLT_NORMALIZE 1 + +/* + * The characteristics of float. + */ + +/* The radix for floating point representation. */ +#define FLT_RADIX 2 + +/* Decimal digits of precision. */ +#define FLT_DIG 6 + +/* Smallest number such that 1+x != 1 */ +#define FLT_EPSILON 1.19209290e-07F + +/* The number of base FLT_RADIX digits in the mantissa. */ +#define FLT_MANT_DIG 24 + +/* The maximum floating point number. */ +#define FLT_MAX 3.40282347e+38F + +/* Maximum n such that FLT_RADIX^n - 1 is representable. */ +#define FLT_MAX_EXP 128 + +/* Maximum n such that 10^n is representable. */ +#define FLT_MAX_10_EXP 38 + +/* Minimum normalized floating-point number. */ +#define FLT_MIN 1.17549435e-38F + +/* Minimum n such that FLT_RADIX^n is a normalized number. */ +#define FLT_MIN_EXP (-125) + +/* Minimum n such that 10^n is a normalized number. */ +#define FLT_MIN_10_EXP (-37) + + +/* + * The characteristics of double. + */ +#define DBL_DIG 15 +#define DBL_EPSILON 1.1102230246251568e-16 +#define DBL_MANT_DIG 53 +#define DBL_MAX 1.7976931348623157e+308 +#define DBL_MAX_EXP 1024 +#define DBL_MAX_10_EXP 308 +#define DBL_MIN 2.2250738585072014e-308 +#define DBL_MIN_EXP (-1021) +#define DBL_MIN_10_EXP (-307) + + +/* + * The characteristics of long double. + * NOTE: long double is the same as double. + */ +#define LDBL_DIG 15 +#define LDBL_EPSILON 1.1102230246251568e-16L +#define LDBL_MANT_DIG 53 +#define LDBL_MAX 1.7976931348623157e+308L +#define LDBL_MAX_EXP 1024 +#define LDBL_MAX_10_EXP 308 +#define LDBL_MIN 2.2250738585072014e-308L +#define LDBL_MIN_EXP (-1021) +#define LDBL_MIN_10_EXP (-307) + + +/* + * Functions and definitions for controlling the FPU. + */ +#ifndef __STRICT_ANSI__ + +/* TODO: These constants are only valid for x86 machines */ + +/* Control word masks for unMask */ +#define _MCW_EM 0x0008001F /* Error masks */ +#define _MCW_IC 0x00040000 /* Infinity */ +#define _MCW_RC 0x00000300 /* Rounding */ +#define _MCW_PC 0x00030000 /* Precision */ + +/* Control word values for unNew (use with related unMask above) */ +#define _EM_INVALID 0x00000010 +#define _EM_DENORMAL 0x00080000 +#define _EM_ZERODIVIDE 0x00000008 +#define _EM_OVERFLOW 0x00000004 +#define _EM_UNDERFLOW 0x00000002 +#define _EM_INEXACT 0x00000001 +#define _IC_AFFINE 0x00040000 +#define _IC_PROJECTIVE 0x00000000 +#define _RC_CHOP 0x00000300 +#define _RC_UP 0x00000200 +#define _RC_DOWN 0x00000100 +#define _RC_NEAR 0x00000000 +#define _PC_24 0x00020000 +#define _PC_53 0x00010000 +#define _PC_64 0x00000000 + +/* Return values for fpclass. */ +#define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ +#define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ +#define _FPCLASS_NINF 0x0004 /* Negative Infinity */ +#define _FPCLASS_NN 0x0008 /* Negative Normal */ +#define _FPCLASS_ND 0x0010 /* Negative Denormal */ +#define _FPCLASS_NZ 0x0020 /* Negative Zero */ +#define _FPCLASS_PZ 0x0040 /* Positive Zero */ +#define _FPCLASS_PD 0x0080 /* Positive Denormal */ +#define _FPCLASS_PN 0x0100 /* Positive Normal */ +#define _FPCLASS_PINF 0x0200 /* Positive Infinity */ + +/* invalid subconditions (_SW_INVALID also set) */ +#define _SW_UNEMULATED 0x0040 /* unemulated instruction */ +#define _SW_SQRTNEG 0x0080 /* square root of a neg number */ +#define _SW_STACKOVERFLOW 0x0200 /* FP stack overflow */ +#define _SW_STACKUNDERFLOW 0x0400 /* FP stack underflow */ + +/* Floating point error signals and return codes */ +#define _FPE_INVALID 0x81 +#define _FPE_DENORMAL 0x82 +#define _FPE_ZERODIVIDE 0x83 +#define _FPE_OVERFLOW 0x84 +#define _FPE_UNDERFLOW 0x85 +#define _FPE_INEXACT 0x86 +#define _FPE_UNEMULATED 0x87 +#define _FPE_SQRTNEG 0x88 +#define _FPE_STACKOVERFLOW 0x8a +#define _FPE_STACKUNDERFLOW 0x8b +#define _FPE_EXPLICITGEN 0x8c /* raise( SIGFPE ); */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* Set the FPU control word as cw = (cw & ~unMask) | (unNew & unMask), + * i.e. change the bits in unMask to have the values they have in unNew, + * leaving other bits unchanged. */ +unsigned int _controlfp (unsigned int unNew, unsigned int unMask); +unsigned int _control87 (unsigned int unNew, unsigned int unMask); + + +unsigned int _clearfp (); /* Clear the FPU status word */ +unsigned int _statusfp (); /* Report the FPU status word */ +#define _clear87 _clearfp +#define _status87 _statusfp + +void _fpreset (); /* Reset the FPU */ +void fpreset (); + +/* Global 'variable' for the current floating point error code. */ +int * __fpecode(); +#define _fpecode (*(__fpecode())) + +/* + * IEEE recommended functions + */ + +double _chgsign (double); +double _copysign (double, double); +double _logb (double); +double _nextafter (double, double); +double _scalb (double, long); + +int _finite (double); +int _fpclass (double); +int _isnan (double); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not __STRICT_ANSI__ */ + +#endif /* _FLOAT_H_ */ + diff --git a/winsup/mingw/include/io.h b/winsup/mingw/include/io.h new file mode 100644 index 000000000..e30f8687e --- /dev/null +++ b/winsup/mingw/include/io.h @@ -0,0 +1,258 @@ +/* + * io.h + * + * System level I/O functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _IO_H_ +#define _IO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* We need the definition of FILE anyway... */ +#include + +/* MSVC's io.h contains the stuff from dir.h, so I will too. + * NOTE: This also defines off_t, the file offset type, through + * an inclusion of sys/types.h */ +#ifndef __STRICT_ANSI__ + +#include /* To get time_t. */ + +/* + * Attributes of files as returned by _findfirst et al. + */ +#define _A_NORMAL 0x00000000 +#define _A_RDONLY 0x00000001 +#define _A_HIDDEN 0x00000002 +#define _A_SYSTEM 0x00000004 +#define _A_VOLID 0x00000008 +#define _A_SUBDIR 0x00000010 +#define _A_ARCH 0x00000020 + + +#ifndef RC_INVOKED + +#ifndef _FSIZE_T_DEFINED +typedef unsigned long _fsize_t; +#define _FSIZE_T_DEFINED +#endif + +/* + * The following structure is filled in by _findfirst or _findnext when + * they succeed in finding a match. + */ +struct _finddata_t +{ + unsigned attrib; /* Attributes, see constants above. */ + time_t time_create; + time_t time_access; /* always midnight local time */ + time_t time_write; + _fsize_t size; + char name[FILENAME_MAX]; /* may include spaces. */ +}; + +#ifndef _WFINDDATA_T_DEFINED +struct _wfinddata_t { + unsigned attrib; + time_t time_create; /* -1 for FAT file systems */ + time_t time_access; /* -1 for FAT file systems */ + time_t time_write; + _fsize_t size; + wchar_t name[FILENAME_MAX]; /* may include spaces. */ +}; +#define _WFINDDATA_T_DEFINED +#endif + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Functions for searching for files. _findfirst returns -1 if no match + * is found. Otherwise it returns a handle to be used in _findnext and + * _findclose calls. _findnext also returns -1 if no match could be found, + * and 0 if a match was found. Call _findclose when you are finished. + */ +int _findfirst (const char*, struct _finddata_t*); +int _findnext (int, struct _finddata_t*); +int _findclose (int); + +int _chdir (const char*); +char* _getcwd (char*, int); +int _mkdir (const char*); +char* _mktemp (char*); +int _rmdir (const char*); + + +#ifndef _NO_OLDNAMES + +#ifndef _UWIN +int chdir (const char*); +char* getcwd (char*, int); +int mkdir (const char*); +char* mktemp (char*); +int rmdir (const char*); +#endif /* _UWIN */ + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not __STRICT_ANSI__ */ + +/* TODO: Maximum number of open handles has not been tested, I just set + * it the same as FOPEN_MAX. */ +#define HANDLE_MAX FOPEN_MAX + + +/* Some defines for _access nAccessMode (MS doesn't define them, but + * it doesn't seem to hurt to add them). */ +#define F_OK 0 /* Check for file existence */ +#define X_OK 1 /* Check for execute permission. */ +#define W_OK 2 /* Check for write permission */ +#define R_OK 4 /* Check for read permission */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +int _access (const char*, int); +int _chsize (int, long); +int _close (int); + +/* NOTE: The only significant bit in unPermissions appears to be bit 7 (0x80), + * the "owner write permission" bit (on FAT). */ +int _creat (const char*, unsigned); + +int _dup (int); +int _dup2 (int, int); +long _filelength (int); +int _fileno (FILE*); +long _get_osfhandle (int); +int _isatty (int); + +/* In a very odd turn of events this function is excluded from those + * files which define _STREAM_COMPAT. This is required in order to + * build GNU libio because of a conflict with _eof in streambuf.h + * line 107. Actually I might just be able to change the name of + * the enum member in streambuf.h... we'll see. TODO */ +#ifndef _STREAM_COMPAT +int _eof (int); +#endif + +/* LK_... locking commands defined in sys/locking.h. */ +int _locking (int, int, long); + +long _lseek (int, long, int); + +/* Optional third argument is unsigned unPermissions. */ +int _open (const char*, int, ...); + +int _open_osfhandle (long, int); +int _pipe (int *, unsigned int, int); +int _read (int, void*, unsigned int); + +/* SH_... flags for nShFlags defined in share.h + * Optional fourth argument is unsigned unPermissions */ +int _sopen (const char*, int, int, ...); + +long _tell (int); +/* Should umask be in sys/stat.h and/or sys/types.h instead? */ +int _umask (int); +int _unlink (const char*); +int _write (int, const void*, unsigned int); + +/* Wide character versions. Also declared in wchar.h. */ +int _waccess(const wchar_t *, int); +int _wchmod(const wchar_t *, int); +int _wcreat(const wchar_t *, int); +long _wfindfirst(wchar_t *, struct _wfinddata_t *); +int _wfindnext(long, struct _wfinddata_t *); +int _wunlink(const wchar_t *); +int _wrename(const wchar_t *, const wchar_t *); +int _wopen(const wchar_t *, int, ...); +int _wsopen(const wchar_t *, int, int, ...); +wchar_t * _wmktemp(wchar_t *); + + +#ifndef _NO_OLDNAMES +/* + * Non-underscored versions of non-ANSI functions to improve portability. + * These functions live in libmoldname.a. + */ + +#ifndef _UWIN +int access (const char*, int); +int chsize (int, long ); +int close (int); +int creat (const char*, int); +int dup (int); +int dup2 (int, int); +int eof (int); +long filelength (int); +int fileno (FILE*); +int isatty (int); +long lseek (int, long, int); +int open (const char*, int, ...); +int read (int, void*, unsigned int); +int sopen (const char*, int, int, ...); +long tell (int); +int umask (int); +int unlink (const char*); +int write (int, const void*, unsigned int); +#endif /* _UWIN */ + +/* Wide character versions. Also declared in wchar.h. */ +int waccess(const wchar_t *, int); +int wchmod(const wchar_t *, int); +int wcreat(const wchar_t *, int); +long wfindfirst(wchar_t *, struct _wfinddata_t *); +int wfindnext(long, struct _wfinddata_t *); +int wunlink(const wchar_t *); +int wrename(const wchar_t *, const wchar_t *); +int wopen(const wchar_t *, int, ...); +int wsopen(const wchar_t *, int, int, ...); +wchar_t * wmktemp(wchar_t *); + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _IO_H_ not defined */ + +#endif /* Not strict ANSI */ + diff --git a/winsup/mingw/include/limits.h b/winsup/mingw/include/limits.h new file mode 100644 index 000000000..9bd3aab91 --- /dev/null +++ b/winsup/mingw/include/limits.h @@ -0,0 +1,110 @@ +/* + * limits.h + * + * Defines constants for the sizes of integral types. + * + * NOTE: GCC should supply a version of this header and it should be safe to + * use that version instead of this one (maybe safer). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _LIMITS_H_ +#define _LIMITS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * File system limits + * + * TODO: NAME_MAX and OPEN_MAX are file system limits or not? Are they the + * same as FILENAME_MAX and FOPEN_MAX from stdio.h? + * NOTE: Apparently the actual size of PATH_MAX is 260, but a space is + * required for the NUL. TODO: Test? + */ +#define PATH_MAX (259) + +/* + * Characteristics of the char data type. + * + * TODO: Is MB_LEN_MAX correct? + */ +#define CHAR_BIT 8 +#define MB_LEN_MAX 2 + +#define SCHAR_MIN (-128) +#define SCHAR_MAX 127 + +#define UCHAR_MAX 255 + +/* TODO: Is this safe? I think it might just be testing the preprocessor, + * not the compiler itself... */ +#if ('\x80' < 0) +#define CHAR_MIN SCHAR_MIN +#define CHAR_MAX SCHAR_MAX +#else +#define CHAR_MIN 0 +#define CHAR_MAX UCHAR_MAX +#endif + +/* + * Maximum and minimum values for ints. + */ +#define INT_MAX 2147483647 +#define INT_MIN (-INT_MAX-1) + +#define UINT_MAX 0xffffffff + +/* + * Maximum and minimum values for shorts. + */ +#define SHRT_MAX 32767 +#define SHRT_MIN (-SHRT_MAX-1) + +#define USHRT_MAX 0xffff + +/* + * Maximum and minimum values for longs and unsigned longs. + * + * TODO: This is not correct for Alphas, which have 64 bit longs. + */ +#define LONG_MAX 2147483647L + +#define LONG_MIN (-LONG_MAX-1) + +#define ULONG_MAX 0xffffffffUL + + +/* + * The GNU C compiler also allows 'long long int' + */ +#if !defined(__STRICT_ANSI__) && defined(__GNUC__) + +#define LONG_LONG_MAX 9223372036854775807LL +#define LONG_LONG_MIN (-LONG_LONG_MAX-1) + +#define ULONG_LONG_MAX (2ULL * LONG_LONG_MAX + 1) + +#endif /* Not Strict ANSI and GNU C compiler */ + + +#endif /* not _LIMITS_H_ */ diff --git a/winsup/mingw/include/locale.h b/winsup/mingw/include/locale.h new file mode 100644 index 000000000..4f751246c --- /dev/null +++ b/winsup/mingw/include/locale.h @@ -0,0 +1,91 @@ +/* + * locale.h + * + * Functions and types for localization (ie. changing the appearance of + * output based on the standards of a certain country). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _LOCALE_H_ +#define _LOCALE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * NOTE: I have tried to test this, but I am limited by my knowledge of + * locale issues. The structure does not bomb if you look at the + * values, and 'decimal_point' even seems to be correct. But the + * rest of the values are, by default, not particularly useful + * (read meaningless and not related to the international settings + * of the system). + */ + +#define LC_ALL 0 +#define LC_COLLATE 1 +#define LC_CTYPE 2 +#define LC_MONETARY 3 +#define LC_NUMERIC 4 +#define LC_TIME 5 + +#ifndef RC_INVOKED + +/* + * The structure returned by 'localeconv'. + */ +struct lconv +{ + char* decimal_point; + char* thousands_sep; + char* grouping; + char* int_curr_symbol; + char* currency_symbol; + char* mon_decimal_point; + char* mon_thousands_sep; + char* mon_grouping; + char* positive_sign; + char* negative_sign; + char int_frac_digits; + char frac_digits; + char p_cs_precedes; + char p_sep_by_space; + char n_cs_precedes; + char n_sep_by_space; + char p_sign_posn; + char n_sign_posn; +}; + +#ifdef __cplusplus +extern "C" { +#endif + +char* setlocale (int, const char*); +struct lconv* localeconv (void); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _LOCALE_H_ */ + diff --git a/winsup/mingw/include/malloc.h b/winsup/mingw/include/malloc.h new file mode 100644 index 000000000..90a96b618 --- /dev/null +++ b/winsup/mingw/include/malloc.h @@ -0,0 +1,78 @@ +/* + * malloc.h + * + * Support for programs which want to use malloc.h to get memory management + * functions. Unless you absolutely need some of these functions and they are + * not in the ANSI headers you should use the ANSI standard header files + * instead. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _MALLOC_H_ +#define _MALLOC_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include + +#ifndef RC_INVOKED + +/* + * The structure used to walk through the heap with _heapwalk. + * TODO: This is a guess at the internals of this structure. + */ +typedef struct _heapinfo +{ + void* ptr; + unsigned int size; + int in_use; +} _HEAPINFO; + + +#ifdef __cplusplus +extern "C" { +#endif + +int _heapwalk (_HEAPINFO*); + +#ifndef _NO_OLDNAMES +int heapwalk (_HEAPINFO*); +#endif /* Not _NO_OLDNAMES */ + +int _heapchk (void); /* Verify heap integrety. */ +int _heapmin (void); /* Return unused heap to the OS. */ +int _heapset (unsigned int); +size_t _msize (void*); + +#ifdef __cplusplus +} +#endif + +#endif RC_INVOKED + +#endif /* Not _MALLOC_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h new file mode 100644 index 000000000..8f2ba105d --- /dev/null +++ b/winsup/mingw/include/math.h @@ -0,0 +1,182 @@ +/* + * math.h + * + * Mathematical functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _MATH_H_ +#define _MATH_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Types for the _exception structure. + */ + +#define _DOMAIN 1 /* domain error in argument */ +#define _SING 2 /* singularity */ +#define _OVERFLOW 3 /* range overflow */ +#define _UNDERFLOW 4 /* range underflow */ +#define _TLOSS 5 /* total loss of precision */ +#define _PLOSS 6 /* partial loss of precision */ + +/* + * Exception types with non-ANSI names for compatibility. + */ + +#ifndef __STRICT_ANSI__ +#ifndef _NO_OLDNAMES + +#define DOMAIN _DOMAIN +#define SING _SING +#define OVERFLOW _OVERFLOW +#define UNDERFLOW _UNDERFLOW +#define TLOSS _TLOSS +#define PLOSS _PLOSS + +#endif /* Not _NO_OLDNAMES */ +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * HUGE_VAL is returned by strtod when the value would overflow the + * representation of 'double'. There are other uses as well. + * + * __imp__HUGE is a pointer to the actual variable _HUGE in + * MSVCRT.DLL. If we used _HUGE directly we would get a pointer + * to a thunk function. + * + * NOTE: The CRTDLL version uses _HUGE_dll instead. + */ + +#ifndef __DECLSPEC_SUPPORTED + +#ifdef __MSVCRT__ +extern double* __imp__HUGE; +#define HUGE_VAL (*__imp__HUGE) +#else +/* CRTDLL */ +extern double* __imp__HUGE_dll; +#define HUGE_VAL (*__imp__HUGE_dll) +#endif + +#else /* __DECLSPEC_SUPPORTED */ + +#ifdef __MSVCRT__ +__MINGW_IMPORT double _HUGE; +#define HUGE_VAL _HUGE +#else +/* CRTDLL */ +__MINGW_IMPORT double _HUGE_dll; +#define HUGE_VAL _HUGE_dll +#endif + +#endif /* __DECLSPEC_SUPPORTED */ + +struct _exception +{ + int type; + char *name; + double arg1; + double arg2; + double retval; +}; + + +double sin (double); +double cos (double); +double tan (double); +double sinh (double); +double cosh (double); +double tanh (double); +double asin (double); +double acos (double); +double atan (double); +double atan2 (double, double); +double exp (double); +double log (double); +double log10 (double); +double pow (double, double); +double sqrt (double); +double ceil (double); +double floor (double); +double fabs (double); +double ldexp (double, int); +double frexp (double, int*); +double modf (double, double*); +double fmod (double, double); + + +#ifndef __STRICT_ANSI__ + +/* Complex number (for cabs) */ +struct _complex +{ + double x; /* Real part */ + double y; /* Imaginary part */ +}; + +double _cabs (struct _complex); +double _hypot (double, double); +double _j0 (double); +double _j1 (double); +double _jn (int, double); +double _y0 (double); +double _y1 (double); +double _yn (int, double); +int _matherr (struct _exception *); + +#ifndef _NO_OLDNAMES + +/* + * Non-underscored versions of non-ANSI functions. These reside in + * liboldnames.a. Provided for extra portability. + */ +double cabs (struct _complex); +double hypot (double, double); +double j0 (double); +double j1 (double); +double jn (int, double); +double y0 (double); +double y1 (double); +double yn (int, double); + +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _MATH_H_ */ + diff --git a/winsup/mingw/include/mem.h b/winsup/mingw/include/mem.h new file mode 100644 index 000000000..20c8fa4a5 --- /dev/null +++ b/winsup/mingw/include/mem.h @@ -0,0 +1,8 @@ +/* + * This file is part of the Mingw32 package. + * + * mem.h maps to string.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/memory.h b/winsup/mingw/include/memory.h new file mode 100644 index 000000000..e0c91d635 --- /dev/null +++ b/winsup/mingw/include/memory.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * memory.h maps to the standard string.h header. + */ +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/process.h b/winsup/mingw/include/process.h new file mode 100644 index 000000000..dc138c390 --- /dev/null +++ b/winsup/mingw/include/process.h @@ -0,0 +1,158 @@ +/* + * process.h + * + * Function calls for spawning child processes. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _PROCESS_H_ +#define _PROCESS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* Includes a definition of _pid_t and pid_t */ +#include + +/* + * Constants for cwait actions. + * Obsolete for Win32. + */ +#define _WAIT_CHILD 0 +#define _WAIT_GRANDCHILD 1 + +#ifndef _NO_OLDNAMES +#define WAIT_CHILD _WAIT_CHILD +#define WAIT_GRANDCHILD _WAIT_GRANDCHILD +#endif /* Not _NO_OLDNAMES */ + +/* + * Mode constants for spawn functions. + */ +#define _P_WAIT 0 +#define _P_NOWAIT 1 +#define _P_OVERLAY 2 +#define _OLD_P_OVERLAY _P_OVERLAY +#define _P_NOWAITO 3 +#define _P_DETACH 4 + +#ifndef _NO_OLDNAMES +#define P_WAIT _P_WAIT +#define P_NOWAIT _P_NOWAIT +#define P_OVERLAY _P_OVERLAY +#define OLD_P_OVERLAY _OLD_P_OVERLAY +#define P_NOWAITO _P_NOWAITO +#define P_DETACH _P_DETACH +#endif /* Not _NO_OLDNAMES */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +void _cexit(void); +void _c_exit(void); + +int _cwait (int*, _pid_t, int); + +_pid_t _getpid(void); + +int _execl (const char*, const char*, ...); +int _execle (const char*, const char*, ...); +int _execlp (const char*, const char*, ...); +int _execlpe (const char*, const char*, ...); +int _execv (const char*, char* const*); +int _execve (const char*, char* const*, char* const*); +int _execvp (const char*, char* const*); +int _execvpe (const char*, char* const*, char* const*); + +int _spawnl (int, const char*, const char*, ...); +int _spawnle (int, const char*, const char*, ...); +int _spawnlp (int, const char*, const char*, ...); +int _spawnlpe (int, const char*, const char*, ...); +int _spawnv (int, const char*, char* const*); +int _spawnve (int, const char*, char* const*, char* const*); +int _spawnvp (int, const char*, char* const*); +int _spawnvpe (int, const char*, char* const*, char* const*); + +/* + * The functions _beginthreadex and _endthreadex are not provided by CRTDLL. + * They are provided by MSVCRT. + * + * NOTE: Apparently _endthread calls CloseHandle on the handle of the thread, + * making for race conditions if you are not careful. Basically you have to + * make sure that no-one is going to do *anything* with the thread handle + * after the thread calls _endthread or returns from the thread function. + * + * NOTE: No old names for these functions. Use the underscore. + */ +unsigned long + _beginthread (void (*)(void *), unsigned, void*); +void _endthread (void); + +#ifdef __MSVCRT__ +unsigned long + _beginthreadex (void *, unsigned, unsigned (__stdcall *) (void *), + void*, unsigned, unsigned*); +void _endthreadex (unsigned); +#endif + + +#ifndef _NO_OLDNAMES +/* + * Functions without the leading underscore, for portability. These functions + * live in liboldnames.a. + */ +int cwait (int*, pid_t, int); +pid_t getpid (void); +int execl (const char*, const char*, ...); +int execle (const char*, const char*, ...); +int execlp (const char*, const char*, ...); +int execlpe (const char*, const char*, ...); +int execv (const char*, char* const*); +int execve (const char*, char* const*, char* const*); +int execvp (const char*, char* const*); +int execvpe (const char*, char* const*, char* const*); +int spawnl (int, const char*, const char*, ...); +int spawnle (int, const char*, const char*, ...); +int spawnlp (int, const char*, const char*, ...); +int spawnlpe (int, const char*, const char*, ...); +int spawnv (int, const char*, char* const*); +int spawnve (int, const char*, char* const*, char* const*); +int spawnvp (int, const char*, char* const*); +int spawnvpe (int, const char*, char* const*, char* const*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _PROCESS_H_ not defined */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/setjmp.h b/winsup/mingw/include/setjmp.h new file mode 100644 index 000000000..9164178d4 --- /dev/null +++ b/winsup/mingw/include/setjmp.h @@ -0,0 +1,72 @@ +/* + * setjmp.h + * + * Declarations supporting setjmp and longjump, a method for avoiding + * the normal function call return sequence. (Bleah!) + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _SETJMP_H_ +#define _SETJMP_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * The buffer used by setjmp to store the information used by longjmp + * to perform it's evil goto-like work. The size of this buffer was + * determined through experimentation; it's contents are a mystery. + * NOTE: This was determined on an i386 (actually a Pentium). The + * contents could be different on an Alpha or something else. + */ +#define _JBLEN 16 +#define _JBTYPE int +typedef _JBTYPE jmp_buf[_JBLEN]; + +/* + * The function provided by CRTDLL which appears to do the actual work + * of setjmp. + */ +int _setjmp (jmp_buf); + +#define setjmp(x) _setjmp(x) + +/* + * Return to the last setjmp call and act as if setjmp had returned + * nVal (which had better be non-zero!). + */ +void longjmp (jmp_buf, int); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _SETJMP_H_ */ + diff --git a/winsup/mingw/include/share.h b/winsup/mingw/include/share.h new file mode 100644 index 000000000..8abf78736 --- /dev/null +++ b/winsup/mingw/include/share.h @@ -0,0 +1,44 @@ +/* + * share.h + * + * Constants for file sharing functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _SHARE_H_ +#define _SHARE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define SH_COMPAT 0x00 /* Compatibility */ +#define SH_DENYRW 0x10 /* Deny read/write */ +#define SH_DENYWR 0x20 /* Deny write */ +#define SH_DENYRD 0x30 /* Deny read */ +#define SH_DENYNO 0x40 /* Deny nothing */ + +#endif /* Not _SHARE_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/signal.h b/winsup/mingw/include/signal.h new file mode 100644 index 000000000..f4eb33a85 --- /dev/null +++ b/winsup/mingw/include/signal.h @@ -0,0 +1,111 @@ +/* + * signal.h + * + * A way to set handlers for exceptional conditions (also known as signals). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _SIGNAL_H_ +#define _SIGNAL_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * The actual signal values. Using other values with signal + * produces a SIG_ERR return value. + * + * NOTE: SIGINT is produced when the user presses Ctrl-C. + * SIGILL has not been tested. + * SIGFPE doesn't seem to work? + * SIGSEGV does not catch writing to a NULL pointer (that shuts down + * your app; can you say "segmentation violation core dump"?). + * SIGTERM comes from what kind of termination request exactly? + * SIGBREAK is indeed produced by pressing Ctrl-Break. + * SIGABRT is produced by calling abort. + * TODO: The above results may be related to not installing an appropriate + * structured exception handling frame. Results may be better if I ever + * manage to get the SEH stuff down. + */ +#define SIGINT 2 /* Interactive attention */ +#define SIGILL 4 /* Illegal instruction */ +#define SIGFPE 8 /* Floating point error */ +#define SIGSEGV 11 /* Segmentation violation */ +#define SIGTERM 15 /* Termination request */ +#define SIGBREAK 21 /* Control-break */ +#define SIGABRT 22 /* Abnormal termination (abort) */ + +#define NSIG 23 /* maximum signal number + 1 */ + +#ifndef RC_INVOKED + +#ifndef _SIG_ATOMIC_T_DEFINED +typedef int sig_atomic_t; +#define _SIG_ATOMIC_T_DEFINED +#endif + +/* + * The prototypes (below) are the easy part. The hard part is figuring + * out what signals are available and what numbers they are assigned + * along with appropriate values of SIG_DFL and SIG_IGN. + */ + +/* + * A pointer to a signal handler function. A signal handler takes a + * single int, which is the signal it handles. + */ +typedef void (*__p_sig_fn_t)(int); + +/* + * These are special values of signal handler pointers which are + * used to send a signal to the default handler (SIG_DFL), ignore + * the signal (SIG_IGN), or indicate an error return (SIG_ERR). + */ +#define SIG_DFL ((__p_sig_fn_t) 0) +#define SIG_IGN ((__p_sig_fn_t) 1) +#define SIG_ERR ((__p_sig_fn_t) -1) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Call signal to set the signal handler for signal sig to the + * function pointed to by handler. Returns a pointer to the + * previous handler, or SIG_ERR if an error occurs. Initially + * unhandled signals defined above will return SIG_DFL. + */ +__p_sig_fn_t signal(int, __p_sig_fn_t); + +/* + * Raise the signal indicated by sig. Returns non-zero on success. + */ +int raise (int); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _SIGNAL_H_ */ + diff --git a/winsup/mingw/include/stdarg.h b/winsup/mingw/include/stdarg.h new file mode 100644 index 000000000..6db01aa35 --- /dev/null +++ b/winsup/mingw/include/stdarg.h @@ -0,0 +1,109 @@ +/* + * stdarg.h + * + * Provides facilities for stepping through a list of function arguments of + * an unknown number and type. + * + * NOTE: Gcc should provide stdarg.h, and I believe their version will work + * with crtdll. If necessary I think you can replace this with the GCC + * stdarg.h. + * + * Note that the type used in va_arg is supposed to match the actual type + * *after default promotions*. Thus, va_arg (..., short) is not valid. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDARG_H_ +#define _STDARG_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Don't do any of this stuff for the resource compiler. + */ +#ifndef RC_INVOKED + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + + +/* + * Start variable argument list processing by setting AP to point to the + * argument after pN. + */ +#ifdef __GNUC__ +/* + * In GNU the stack is not necessarily arranged very neatly in order to + * pack shorts and such into a smaller argument list. Fortunately a + * neatly arranged version is available through the use of __builtin_next_arg. + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) __builtin_next_arg(pN))) +#else +/* + * For a simple minded compiler this should work (it works in GNU too for + * vararg lists that don't follow shorts and such). + */ +#define va_start(ap, pN) \ + ((ap) = ((va_list) (&pN) + __va_argsiz(pN))) +#endif + + +/* + * End processing of variable argument list. In this case we do nothing. + */ +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + +#endif /* Not RC_INVOKED */ + +#endif /* not _STDARG_H_ */ diff --git a/winsup/mingw/include/stddef.h b/winsup/mingw/include/stddef.h new file mode 100644 index 000000000..e953fca76 --- /dev/null +++ b/winsup/mingw/include/stddef.h @@ -0,0 +1,373 @@ +/* + * stddef.h + * + * Standard type definitions provided by the C library. + * + * NOTE: This is typically supplied by GCC, but there's a small gotcha - + * GCC's version doesn't guard typedefs via RC_INVOKED. This is + * GCC's version, with the guard macro. Since we install this in + * the tool include directory, it gets picked up before GCC's + * internal include directory, and we're safe. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#if (!defined(_STDDEF_H) && !defined(_STDDEF_H_) && !defined(_ANSI_STDDEF_H) \ + && !defined(__STDDEF_H__)) \ + || defined(__need_wchar_t) || defined(__need_size_t) \ + || defined(__need_ptrdiff_t) || defined(__need_NULL) \ + || defined(__need_wint_t) + +/* Any one of these symbols __need_* means that GNU libc + wants us just to define one data type. So don't define + the symbols that indicate this file's entire job has been done. */ +#if (!defined(__need_wchar_t) && !defined(__need_size_t) \ + && !defined(__need_ptrdiff_t) && !defined(__need_NULL) \ + && !defined(__need_wint_t)) +#define _STDDEF_H +#define _STDDEF_H_ +/* snaroff@next.com says the NeXT needs this. */ +#define _ANSI_STDDEF_H +/* Irix 5.1 needs this. */ +#define __STDDEF_H__ +#endif + +#ifndef RC_INVOKED + +#ifndef __sys_stdtypes_h +/* This avoids lossage on SunOS but only if stdtypes.h comes first. + There's no way to win with the other order! Sun lossage. */ + +/* On 4.3bsd-net2, make sure ansi.h is included, so we have + one less case to deal with in the following. */ +#if defined (__BSD_NET2__) || defined (____386BSD____) || defined (__FreeBSD__) || defined(__NetBSD__) +#include +#endif + +/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are + defined if the corresponding type is *not* defined. + FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */ +#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) +#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_) +#define _SIZE_T +#endif +#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_) +#define _PTRDIFF_T +#endif +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_. */ +#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_) +#ifndef _BSD_WCHAR_T_ +#define _WCHAR_T +#endif +#endif +/* Undef _FOO_T_ if we are supposed to define foo_t. */ +#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#if defined (__need_size_t) || defined (_STDDEF_H_) +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#if defined (__need_wchar_t) || defined (_STDDEF_H_) +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */ + +/* Sequent's header files use _PTRDIFF_T_ in some conflicting way. + Just ignore it. */ +#if defined (__sequent__) && defined (_PTRDIFF_T_) +#undef _PTRDIFF_T_ +#endif + +/* On VxWorks, may have defined macros like + _TYPE_size_t which will typedef size_t. fixincludes patched the + vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is + not defined, and so that defining this macro defines _GCC_SIZE_T. + If we find that the macros are still defined at this point, we must + invoke them so that the type is defined as expected. */ +#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_)) +_TYPE_ptrdiff_t; +#undef _TYPE_ptrdiff_t +#endif +#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_)) +_TYPE_size_t; +#undef _TYPE_size_t +#endif +#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_)) +_TYPE_wchar_t; +#undef _TYPE_wchar_t +#endif + +/* In case nobody has defined these types, but we aren't running under + GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and + __WCHAR_TYPE__ have reasonable values. This can happen if the + parts of GCC is compiled by an older compiler, that actually + include gstddef.h, such as collect2. */ + +/* Signed type of difference of two pointers. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_ptrdiff_t) +#ifndef _PTRDIFF_T /* in case has defined it. */ +#ifndef _T_PTRDIFF_ +#ifndef _T_PTRDIFF +#ifndef __PTRDIFF_T +#ifndef _PTRDIFF_T_ +#ifndef _BSD_PTRDIFF_T_ +#ifndef ___int_ptrdiff_t_h +#ifndef _GCC_PTRDIFF_T +#define _PTRDIFF_T +#define _T_PTRDIFF_ +#define _T_PTRDIFF +#define __PTRDIFF_T +#define _PTRDIFF_T_ +#define _BSD_PTRDIFF_T_ +#define ___int_ptrdiff_t_h +#define _GCC_PTRDIFF_T +#ifndef __PTRDIFF_TYPE__ +#define __PTRDIFF_TYPE__ long int +#endif +typedef __PTRDIFF_TYPE__ ptrdiff_t; +#endif /* _GCC_PTRDIFF_T */ +#endif /* ___int_ptrdiff_t_h */ +#endif /* _BSD_PTRDIFF_T_ */ +#endif /* _PTRDIFF_T_ */ +#endif /* __PTRDIFF_T */ +#endif /* _T_PTRDIFF */ +#endif /* _T_PTRDIFF_ */ +#endif /* _PTRDIFF_T */ + +/* If this symbol has done its job, get rid of it. */ +#undef __need_ptrdiff_t + +#endif /* _STDDEF_H or __need_ptrdiff_t. */ + +/* Unsigned type of `sizeof' something. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_size_t) +#ifndef __size_t__ /* BeOS */ +#ifndef _SIZE_T /* in case has defined it. */ +#ifndef _SYS_SIZE_T_H +#ifndef _T_SIZE_ +#ifndef _T_SIZE +#ifndef __SIZE_T +#ifndef _SIZE_T_ +#ifndef _BSD_SIZE_T_ +#ifndef _SIZE_T_DEFINED_ +#ifndef _SIZE_T_DEFINED +#ifndef ___int_size_t_h +#ifndef _GCC_SIZE_T +#ifndef _SIZET_ +#ifndef __size_t +#define __size_t__ /* BeOS */ +#define _SIZE_T +#define _SYS_SIZE_T_H +#define _T_SIZE_ +#define _T_SIZE +#define __SIZE_T +#define _SIZE_T_ +#define _BSD_SIZE_T_ +#define _SIZE_T_DEFINED_ +#define _SIZE_T_DEFINED +#define ___int_size_t_h +#define _GCC_SIZE_T +#define _SIZET_ +#define __size_t +#ifndef __SIZE_TYPE__ +#define __SIZE_TYPE__ long unsigned int +#endif +#if !(defined (__GNUG__) && defined (size_t)) +typedef __SIZE_TYPE__ size_t; +#ifdef __BEOS__ +typedef long ssize_t; +#endif /* __BEOS__ */ +#endif /* !(defined (__GNUG__) && defined (size_t)) */ +#endif /* __size_t */ +#endif /* _SIZET_ */ +#endif /* _GCC_SIZE_T */ +#endif /* ___int_size_t_h */ +#endif /* _SIZE_T_DEFINED */ +#endif /* _SIZE_T_DEFINED_ */ +#endif /* _BSD_SIZE_T_ */ +#endif /* _SIZE_T_ */ +#endif /* __SIZE_T */ +#endif /* _T_SIZE */ +#endif /* _T_SIZE_ */ +#endif /* _SYS_SIZE_T_H */ +#endif /* _SIZE_T */ +#endif /* __size_t__ */ +#undef __need_size_t +#endif /* _STDDEF_H or __need_size_t. */ + +/* Wide character type. + Locale-writers should change this as necessary to + be big enough to hold unique values not between 0 and 127, + and not (wchar_t) -1, for each defined multibyte character. */ + +/* Define this type if we are doing the whole job, + or if we want this type in particular. */ +#if defined (_STDDEF_H) || defined (__need_wchar_t) +#ifndef __wchar_t__ /* BeOS */ +#ifndef _WCHAR_T +#ifndef _T_WCHAR_ +#ifndef _T_WCHAR +#ifndef __WCHAR_T +#ifndef _WCHAR_T_ +#ifndef _BSD_WCHAR_T_ +#ifndef _WCHAR_T_DEFINED_ +#ifndef _WCHAR_T_DEFINED +#ifndef _WCHAR_T_H +#ifndef ___int_wchar_t_h +#ifndef __INT_WCHAR_T_H +#ifndef _GCC_WCHAR_T +#define __wchar_t__ /* BeOS */ +#define _WCHAR_T +#define _T_WCHAR_ +#define _T_WCHAR +#define __WCHAR_T +#define _WCHAR_T_ +#define _BSD_WCHAR_T_ +#define _WCHAR_T_DEFINED_ +#define _WCHAR_T_DEFINED +#define _WCHAR_T_H +#define ___int_wchar_t_h +#define __INT_WCHAR_T_H +#define _GCC_WCHAR_T + +/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ + instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other + symbols in the _FOO_T_ family, stays defined even after its + corresponding type is defined). If we define wchar_t, then we + must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if + we undef _WCHAR_T_, then we must also define rune_t, since + headers like runetype.h assume that if machine/ansi.h is included, + and _BSD_WCHAR_T_ is not defined, then rune_t is available. + machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of + the same type." */ +#ifdef _BSD_WCHAR_T_ +#undef _BSD_WCHAR_T_ +#ifdef _BSD_RUNE_T_ +#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) +typedef _BSD_RUNE_T_ rune_t; +#endif +#endif +#endif + +#ifndef __WCHAR_TYPE__ +#ifdef __BEOS__ +#define __WCHAR_TYPE__ unsigned char +#else +#define __WCHAR_TYPE__ int +#endif +#endif +#ifndef __cplusplus +typedef __WCHAR_TYPE__ wchar_t; +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif +#endif /* __wchar_t__ */ +#undef __need_wchar_t +#endif /* _STDDEF_H or __need_wchar_t. */ + +#if defined (_STDDEF_H) || defined (__need_wint_t) +#ifndef _WINT_T +#define _WINT_T + +#ifndef __WINT_TYPE__ +#define __WINT_TYPE__ unsigned int +#endif +typedef __WINT_TYPE__ wint_t; +#endif +#undef __need_wint_t +#endif + +/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. + are already defined. */ +/* BSD/OS 3.1 requires the MACHINE_ANSI_H check here. FreeBSD 2.x apparently + does not, even though there is a check for MACHINE_ANSI_H above. */ +#if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_)) +/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_ + are probably typos and should be removed before 2.8 is released. */ +#ifdef _GCC_PTRDIFF_T_ +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#ifdef _GCC_SIZE_T_ +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#ifdef _GCC_WCHAR_T_ +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +/* The following ones are the real ones. */ +#ifdef _GCC_PTRDIFF_T +#undef _PTRDIFF_T_ +#undef _BSD_PTRDIFF_T_ +#endif +#ifdef _GCC_SIZE_T +#undef _SIZE_T_ +#undef _BSD_SIZE_T_ +#endif +#ifdef _GCC_WCHAR_T +#undef _WCHAR_T_ +#undef _BSD_WCHAR_T_ +#endif +#endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */ + +#endif /* __sys_stdtypes_h */ + +#endif /* RC_INVOKED */ + +/* A null pointer constant. */ + +#if defined (_STDDEF_H) || defined (__need_NULL) +#undef NULL /* in case has defined it. */ +#ifdef __GNUG__ +#define NULL __null +#else /* G++ */ +#define NULL ((void *)0) +#endif /* G++ */ +#endif /* NULL not defined and or need NULL. */ +#undef __need_NULL + +#ifdef _STDDEF_H + +/* Offset of member MEMBER in a struct of type TYPE. */ + +#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) + +#endif /* _STDDEF_H was defined this time */ + +#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__ + || __need_XXX was not defined before */ diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h new file mode 100644 index 000000000..7922a24dd --- /dev/null +++ b/winsup/mingw/include/stdio.h @@ -0,0 +1,373 @@ +/* + * stdio.h + * + * Definitions of types and prototypes of functions for standard input and + * output. + * + * NOTE: The file manipulation functions provided by Microsoft seem to + * work with either slash (/) or backslash (\) as the path separator. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDIO_H_ +#define _STDIO_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_size_t +#define __need_NULL +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + + +/* Some flags for the iobuf structure provided by */ +#define _IOREAD 1 +#define _IOWRT 2 +#define _IORW 4 + +/* + * The three standard file pointers provided by the run time library. + * NOTE: These will go to the bit-bucket silently in GUI applications! + */ +#define STDIN_FILENO 0 +#define STDOUT_FILENO 1 +#define STDERR_FILENO 2 + +/* Returned by various functions on end of file condition or error. */ +#define EOF (-1) + +/* + * The maximum length of a file name. You should use GetVolumeInformation + * instead of this constant. But hey, this works. + * + * NOTE: This is used in the structure _finddata_t (see io.h) so changing it + * is probably not a good idea. + */ +#define FILENAME_MAX (260) + +/* + * The maximum number of files that may be open at once. I have set this to + * a conservative number. The actual value may be higher. + */ +#define FOPEN_MAX (20) + +/* + * The maximum size of name (including NUL) that will be put in the user + * supplied buffer caName for tmpnam. + * NOTE: This has not been determined by experiment, but based on the + * maximum file name length above it is probably reasonable. I could be + * wrong... + */ +#define L_tmpnam (260) + +/* + * The three possible buffering mode (nMode) values for setvbuf. + * NOTE: _IOFBF works, but _IOLBF seems to work like unbuffered... + * maybe I'm testing it wrong? + */ +#define _IOFBF 0 /* fully buffered */ +#define _IOLBF 1 /* line buffered */ +#define _IONBF 2 /* unbuffered */ + +/* + * The buffer size as used by setbuf such that it is equivalent to + * (void) setvbuf(fileSetBuffer, caBuffer, _IOFBF, BUFSIZ). + */ +#define BUFSIZ 512 + +/* Constants for nOrigin indicating the position relative to which fseek + * sets the file position. Enclosed in ifdefs because io.h could also + * define them. (Though not anymore since io.h includes this file now.) */ +#ifndef SEEK_SET +#define SEEK_SET (0) +#endif + +#ifndef SEEK_CUR +#define SEEK_CUR (1) +#endif + +#ifndef SEEK_END +#define SEEK_END (2) +#endif + + +#ifndef RC_INVOKED + +/* + * I used to include stdarg.h at this point, in order to allow for the + * functions later on in the file which use va_list. That conflicts with + * using stdio.h and varargs.h in the same file, so I do the typedef myself. + */ +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + +/* + * The structure underlying the FILE type. + * + * I still believe that nobody in their right mind should make use of the + * internals of this structure. Provided by Pedro A. Aranda Gutiirrez + * . + */ +#ifndef _FILE_DEFINED +#define _FILE_DEFINED +typedef struct _iobuf +{ + char* _ptr; + int _cnt; + char* _base; + int _flag; + int _file; + int _charbuf; + int _bufsiz; + char* _tmpfname; +} FILE; +#endif /* Not _FILE_DEFINED */ + + +/* + * The standard file handles + */ +#ifndef __DECLSPEC_SUPPORTED + +extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */ + +#define _iob (*__imp__iob) /* An array of FILE */ + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT FILE _iob[]; /* An array of FILE imported from DLL. */ + +#endif /* __DECLSPEC_SUPPORTED */ + +#define stdin (&_iob[STDIN_FILENO]) +#define stdout (&_iob[STDOUT_FILENO]) +#define stderr (&_iob[STDERR_FILENO]) + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * File Operations + */ + +FILE* fopen (const char*, const char*); +FILE* freopen (const char*, const char*, FILE*); +int fflush (FILE*); +int fclose (FILE*); +int remove (const char*); +int rename (const char*, const char*); +FILE* tmpfile (void); +char* tmpnam (char*); +char* _tempnam (const char*, const char*); + +#ifndef NO_OLDNAMES +char* tempnam (const char*, const char*); +#endif + +int setvbuf (FILE*, char*, int, size_t); + +void setbuf (FILE*, char*); + +/* + * Formatted Output + */ + +int fprintf (FILE*, const char*, ...); +int printf (const char*, ...); +int sprintf (char*, const char*, ...); +int _snprintf (char*, size_t, const char*, ...); +int vfprintf (FILE*, const char*, va_list); +int vprintf (const char*, va_list); +int vsprintf (char*, const char*, va_list); +int _vsnprintf (char*, size_t, const char*, va_list); + +/* Wide character versions */ +int fwprintf (FILE*, const wchar_t*, ...); +int wprintf (const wchar_t*, ...); +int swprintf (wchar_t*, const wchar_t*, ...); +int vfwprintf (FILE*, const wchar_t*, va_list); +int vwprintf (const wchar_t*, va_list); +int vswprintf (wchar_t*, const wchar_t*, va_list); + +/* + * Formatted Input + */ + +int fscanf (FILE*, const char*, ...); +int scanf (const char*, ...); +int sscanf (const char*, const char*, ...); + +/* Wide character versions */ +int fwscanf (FILE*, const wchar_t*, ...); +int wscanf (const wchar_t*, ...); +int swscanf (wchar_t*, const wchar_t*, ...); + +/* + * Character Input and Output Functions + */ + +int fgetc (FILE*); +char* fgets (char*, int, FILE*); +int fputc (int, FILE*); +int fputs (const char*, FILE*); +int getc (FILE*); +int getchar (void); +char* gets (char*); +int putc (int, FILE*); +int putchar (int); +int puts (const char*); +int ungetc (int, FILE*); + +/* Wide character versions */ +wint_t fgetwc (FILE*); +wint_t fputwc (wchar_t, FILE*); +wint_t ungetwc (wchar_t, FILE*); + + +#ifdef __MSVCRT__ +wchar_t* fgetws (wchar_t*, int, FILE*); +int fputws (const wchar_t*, FILE*); +wint_t getwc (FILE*); +wint_t getwchar (void); +wchar_t* _getws (wchar_t*); +wint_t putwc (wint_t, FILE*); +int _putws (const wchar_t*); +wint_t putwchar (wint_t); +#endif /* __MSVCRT__ */ + +/* + * Direct Input and Output Functions + */ + +size_t fread (void*, size_t, size_t, FILE*); +size_t fwrite (const void*, size_t, size_t, FILE*); + + +/* + * File Positioning Functions + */ + +int fseek (FILE*, long, int); +long ftell (FILE*); +void rewind (FILE*); + +/* + * An opaque data type used for storing file positions... The contents of + * this type are unknown, but we (the compiler) need to know the size + * because the programmer using fgetpos and fsetpos will be setting aside + * storage for fpos_t structres. Actually I tested using a byte array and + * it is fairly evident that the fpos_t type is a long (in CRTDLL.DLL). + * Perhaps an unsigned long? TODO? It's definitely a 64-bit number in + * MSVCRT however, and for now `long long' will do. + */ +#ifdef __MSVCRT__ +typedef long long fpos_t; +#else +typedef long fpos_t; +#endif + +int fgetpos (FILE*, fpos_t*); +int fsetpos (FILE*, const fpos_t*); + +/* + * Error Functions + */ + +void clearerr (FILE*); +int feof (FILE*); +int ferror (FILE*); +void perror (const char*); + + +#ifndef __STRICT_ANSI__ + +/* + * Pipes + */ +FILE* _popen (const char*, const char*); +int _pclose (FILE*); + +#ifndef NO_OLDNAMES +FILE* popen (const char*, const char*); +int pclose (FILE*); +#endif + +/* The wide character version, only available in MSVCRT DLL versions, not + * CRTDLL. */ +#ifdef __MSVCRT__ +FILE* _wpopen (const wchar_t*, const wchar_t*); + +#ifndef NO_OLDNAMES +#if 0 +FILE* wpopen (const wchar_t*, const wchar_t*); +#else /* Always true */ +/* + * The above prototypeing is not possible unless the wpopen export is added + * to moldnames, which can't be done unless we make separate moldnames.def + * files for every supported runtime. For the time being we use a define + * instead. Pedro's modified dlltool should take care of this I think. + */ +#define wpopen _wpopen +#endif /* Always true */ + +#endif /* not NO_OLDNAMES */ +#endif /* MSVCRT runtime */ + +/* + * Other Non ANSI functions + */ +int _fgetchar (void); +int _fputchar (int); +FILE* _fdopen (int, const char*); +wint_t _fgetwchar(void); +wint_t _fputwchar(wint_t); +int _fileno (FILE*); +int _getw (FILE*); +int _putw (int, FILE*); + +#ifndef _NO_OLDNAMES +int fgetchar (void); +int fputchar (int); +FILE* fdopen (int, const char*); +wint_t fgetwchar(void); +wint_t fputwchar(wint_t); +int fileno (FILE*); +int getw (FILE*); +int putw (int, FILE*); +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* _STDIO_H_ */ diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h new file mode 100644 index 000000000..fade92772 --- /dev/null +++ b/winsup/mingw/include/stdlib.h @@ -0,0 +1,386 @@ +/* + * stdlib.h + * + * Definitions for common types, variables, and functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STDLIB_H_ +#define _STDLIB_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + + +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#ifndef RC_INVOKED +#include +#endif /* RC_INVOKED */ + +/* + * RAND_MAX is the maximum value that may be returned by rand. + * The minimum is zero. + */ +#define RAND_MAX 0x7FFF + +/* + * These values may be used as exit status codes. + */ +#define EXIT_SUCCESS 0 +#define EXIT_FAILURE -1 + +/* + * Definitions for path name functions. + * NOTE: All of these values have simply been chosen to be conservatively high. + * Remember that with long file names we can no longer depend on + * extensions being short. + */ +#ifndef __STRICT_ANSI__ + +#ifndef MAX_PATH +#define MAX_PATH (260) +#endif + +#define _MAX_PATH MAX_PATH +#define _MAX_DRIVE (3) +#define _MAX_DIR 256 +#define _MAX_FNAME 256 +#define _MAX_EXT 256 + +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * This seems like a convenient place to declare these variables, which + * give programs using WinMain (or main for that matter) access to main-ish + * argc and argv. environ is a pointer to a table of environment variables. + * NOTE: Strings in _argv and environ are ANSI strings. + */ +extern int _argc; +extern char** _argv; + +/* imports from runtime dll of the above variables */ +#ifdef __MSVCRT__ + +extern int* __p___argc(void); +extern char*** __p___argv(void); +extern wchar_t*** __p___wargv(void); + +#define __argc (*__p___argc()) +#define __argv (*__p___argv()) +#define __wargv (*__p___wargv()) + +#else /* !MSVCRT */ + +#ifndef __DECLSPEC_SUPPORTED + +extern int* __imp___argc_dll; +extern char*** __imp___argv_dll; +#define __argc (*__imp___argc_dll) +#define __argv (*__imp___argv_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT int __argc_dll; +__MINGW_IMPORT char** __argv_dll; +#define __argc __argc_dll +#define __argv __argv_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* __MSVCRT */ + +/* + * Also defined in ctype.h. + */ + +#ifndef MB_CUR_MAX +# ifdef __MSVCRT__ +# define MB_CUR_MAX __mb_cur_max + __MINGW_IMPORT int __mb_cur_max; +# else /* not __MSVCRT */ +# define MB_CUR_MAX __mb_cur_max_dll + __MINGW_IMPORT int __mb_cur_max_dll; +# endif /* not __MSVCRT */ +#endif /* MB_CUR_MAX */ + +/* + * MS likes to declare errno in stdlib.h as well. + */ + +#ifdef _UWIN +#undef errno +extern int errno; +#else +int* _errno(void); +#define errno (*_errno()) +#endif +int* __doserrno(void); +#define _doserrno (*__doserrno()) + +/* + * Use environ from the DLL, not as a global. + */ + +#ifdef __MSVCRT__ + extern char *** __p__environ(); + extern wchar_t *** __p__wenviron(); +# define _environ (*__p__environ()) +# define _wenviron (*__p__wenviron()) +#else /* ! __MSVCRT__ */ +# ifndef __DECLSPEC_SUPPORTED + extern char *** __imp__environ_dll; +# define _environ (*__imp__environ_dll) +# else /* __DECLSPEC_SUPPORTED */ + __MINGW_IMPORT char ** _environ_dll; +# define _environ _environ_dll +# endif /* __DECLSPEC_SUPPORTED */ +#endif /* ! __MSVCRT__ */ + +#define environ _environ + +#ifdef __MSVCRT__ +/* One of the MSVCRTxx libraries */ + +#ifndef __DECLSPEC_SUPPORTED + extern int* __imp__sys_nerr; +# define sys_nerr (*__imp__sys_nerr) +#else /* __DECLSPEC_SUPPORTED */ + __MINGW_IMPORT int _sys_nerr; +# ifndef _UWIN +# define sys_nerr _sys_nerr +# endif /* _UWIN */ +#endif /* __DECLSPEC_SUPPORTED */ + +#else /* ! __MSVCRT__ */ + +/* CRTDLL run time library */ + +#ifndef __DECLSPEC_SUPPORTED + extern int* __imp__sys_nerr_dll; +# define sys_nerr (*__imp__sys_nerr_dll) +#else /* __DECLSPEC_SUPPORTED */ + __MINGW_IMPORT int _sys_nerr_dll; +# define sys_nerr _sys_nerr_dll +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* ! __MSVCRT__ */ + +#ifndef __DECLSPEC_SUPPORTED +extern char*** __imp__sys_errlist; +#define sys_errlist (*__imp__sys_errlist) +#else /* __DECLSPEC_SUPPORTED */ +__MINGW_IMPORT char* _sys_errlist[]; +#ifndef _UWIN +#define sys_errlist _sys_errlist +#endif /* _UWIN */ +#endif /* __DECLSPEC_SUPPORTED */ + +/* + * OS version and such constants. + */ +#ifndef __STRICT_ANSI__ + +#ifdef __MSVCRT__ +/* msvcrtxx.dll */ + +extern unsigned int* __p__osver(void); +extern unsigned int* __p__winver(void); +extern unsigned int* __p__winmajor(void); +extern unsigned int* __p__winminor(void); + +#define _osver (*__p__osver()) +#define _winver (*__p__winver()) +#define _winmajor (*__p__winmajor()) +#define _winminor (*__p__winminor()) + +#else +/* Not msvcrtxx.dll, thus crtdll.dll */ + +#ifndef __DECLSPEC_SUPPORTED + +extern unsigned int* _imp___osver_dll; +extern unsigned int* _imp___winver_dll; +extern unsigned int* _imp___winmajor_dll; +extern unsigned int* _imp___winminor_dll; + +#define _osver (*_imp___osver_dll) +#define _winver (*_imp___winver_dll) +#define _winmajor (*_imp___winmajor_dll) +#define _winminor (*_imp___winminor_dll) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT unsigned int _osver_dll; +__MINGW_IMPORT unsigned int _winver_dll; +__MINGW_IMPORT unsigned int _winmajor_dll; +__MINGW_IMPORT unsigned int _winminor_dll; + +#define _osver _osver_dll +#define _winver _winver_dll +#define _winmajor _winmajor_dll +#define _winminor _winminor_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif + +#endif /* Not __STRICT_ANSI__ */ + +#ifdef __GNUC__ +#define _ATTRIB_NORETURN __attribute__ ((noreturn)) +#else /* Not __GNUC__ */ +#define _ATTRIB_NORETURN +#endif /* __GNUC__ */ + +double atof (const char*); +int atoi (const char*); +long atol (const char*); + +double strtod (const char*, char**); +double wcstod (const wchar_t*, wchar_t**); +long strtol (const char*, char**, int); +long wcstol (const wchar_t*, wchar_t**, int); + +unsigned long strtoul (const char*, char**, int); +unsigned long wcstoul (const wchar_t*, wchar_t**, int); + +size_t wcstombs (char*, const wchar_t*, size_t); +int wctomb (char*, wchar_t); + +int mblen (const char*, size_t); +size_t mbstowcs (wchar_t*, const char*, size_t); +int mbtowc (wchar_t*, const char*, size_t); + +int rand (void); +void srand (unsigned int); + +void* calloc (size_t, size_t); +void* malloc (size_t); +void* realloc (void*, size_t); +void free (void*); + +void abort (void) _ATTRIB_NORETURN; +void exit (int) _ATTRIB_NORETURN; +int atexit (void (*)(void)); + +int system (const char*); +char* getenv (const char*); + +void* bsearch (const void*, const void*, size_t, size_t, + int (*)(const void*, const void*)); +void qsort (const void*, size_t, size_t, + int (*)(const void*, const void*)); + +int abs (int); +long labs (long); + +/* + * div_t and ldiv_t are structures used to return the results of div and + * ldiv. + * + * NOTE: div and ldiv appear not to work correctly unless + * -fno-pcc-struct-return is specified. This is included in the + * mingw32 specs file. + */ +typedef struct { int quot, rem; } div_t; +typedef struct { long quot, rem; } ldiv_t; + +div_t div (int, int); +ldiv_t ldiv (long, long); + + +#ifndef __STRICT_ANSI__ + +/* + * NOTE: Officially the three following functions are obsolete. The Win32 API + * functions SetErrorMode, Beep and Sleep are their replacements. + */ +void _beep (unsigned int, unsigned int); +void _seterrormode (int); +void _sleep (unsigned long); + +void _exit (int) _ATTRIB_NORETURN; + +int _putenv (const char*); +void _searchenv (const char*, const char*, char*); + +char* _itoa (int, char*, int); +char* _ltoa (long, char*, int); + +char* _ecvt (double, int, int*, int*); +char* _fcvt (double, int, int*, int*); +char* _gcvt (double, int, char*); + +void _makepath (char*, const char*, const char*, const char*, const char*); +void _splitpath (const char*, char*, char*, char*, char*); +char* _fullpath (char*, const char*, size_t); +int _wtoi (const wchar_t *); +long _wtol (const wchar_t *); + +char* _i64toa(__int64, char *, int); +char* _ui64toa(unsigned __int64, char *, int); +__int64 _atoi64(const char *); + +wchar_t* _i64tow(__int64, wchar_t *, int); +wchar_t* _ui64tow(unsigned __int64, wchar_t *, int); +__int64 _wtoi64(const wchar_t *); + + +#ifndef _NO_OLDNAMES + +int putenv (const char*); +void searchenv (const char*, const char*, char*); + +char* itoa (int, char*, int); +char* ltoa (long, char*, int); + +#ifndef _UWIN +char* ecvt (double, int, int*, int*); +char* fcvt (double, int, int*, int*); +char* gcvt (double, int, char*); +#endif /* _UWIN */ +#endif /* Not _NO_OLDNAMES */ + +#endif /* Not __STRICT_ANSI__ */ + +/* + * Undefine the no return attribute used in some function definitions + */ +#undef _ATTRIB_NORETURN + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STDLIB_H_ */ + diff --git a/winsup/mingw/include/string.h b/winsup/mingw/include/string.h new file mode 100644 index 000000000..f6ea7aa11 --- /dev/null +++ b/winsup/mingw/include/string.h @@ -0,0 +1,197 @@ +/* + * string.h + * + * Definitions for memory and string functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _STRING_H_ +#define _STRING_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * Define size_t, wchar_t and NULL + */ +#define __need_size_t +#define __need_wchar_t +#define __need_NULL +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +/* + * Prototypes of the ANSI Standard C library string functions. + */ +void* memchr (const void*, int, size_t); +int memcmp (const void*, const void*, size_t); +void* memcpy (void*, const void*, size_t); +void* memmove (void*, const void*, size_t); +void* memset (void*, int, size_t); +char* strcat (char*, const char*); +char* strchr (const char*, int); +int strcmp (const char*, const char*); +int strcoll (const char*, const char*); /* Compare using locale */ +char* strcpy (char*, const char*); +size_t strcspn (const char*, const char*); +char* strerror (int); /* NOTE: NOT an old name wrapper. */ +char* _strerror (int); +size_t strlen (const char*); +char* strncat (char*, const char*, size_t); +int strncmp (const char*, const char*, size_t); +char* strncpy (char*, const char*, size_t); +char* strpbrk (const char*, const char*); +char* strrchr (const char*, int); +size_t strspn (const char*, const char*); +char* strstr (const char*, const char*); +char* strtok (char*, const char*); +size_t strxfrm (char*, const char*, size_t); + +#ifndef __STRICT_ANSI__ +/* + * Extra non-ANSI functions provided by the CRTDLL library + */ +void* _memccpy (void*, const void*, int, size_t); +int _memicmp (const void*, const void*, size_t); +char* _strdup (const char*); +int _strcmpi (const char*, const char*); +int _stricmp (const char*, const char*); +int _stricoll (const char*, const char*); +char* _strlwr (char*); +int _strnicmp (const char*, const char*, size_t); +char* _strnset (char*, int, size_t); +char* _strrev (char*); +char* _strset (char*, int); +char* _strupr (char*); +void _swab (const char*, char*, size_t); + +/* + * Multi-byte character functions + */ +unsigned char* _mbschr (unsigned char*, unsigned char*); +unsigned char* _mbsncat (unsigned char*, const unsigned char*, size_t); +unsigned char* _mbstok (unsigned char*, unsigned char*); + +#endif /* Not __STRICT_ANSI__ */ + + +/* + * Unicode versions of the standard calls. + */ +wchar_t* wcscat (wchar_t*, const wchar_t*); +wchar_t* wcschr (const wchar_t*, wchar_t); +int wcscmp (const wchar_t*, const wchar_t*); +int wcscoll (const wchar_t*, const wchar_t*); +wchar_t* wcscpy (wchar_t*, const wchar_t*); +size_t wcscspn (const wchar_t*, const wchar_t*); +/* Note: No wcserror in CRTDLL. */ +size_t wcslen (const wchar_t*); +wchar_t* wcsncat (wchar_t*, const wchar_t*, size_t); +int wcsncmp(const wchar_t*, const wchar_t*, size_t); +wchar_t* wcsncpy(wchar_t*, const wchar_t*, size_t); +wchar_t* wcspbrk(const wchar_t*, const wchar_t*); +wchar_t* wcsrchr(const wchar_t*, wchar_t); +size_t wcsspn(const wchar_t*, const wchar_t*); +wchar_t* wcsstr(const wchar_t*, const wchar_t*); +wchar_t* wcstok(wchar_t*, const wchar_t*); +size_t wcsxfrm(wchar_t*, const wchar_t*, size_t); + + +#ifndef __STRICT_ANSI__ +/* + * Unicode versions of non-ANSI functions provided by CRTDLL. + */ + +/* NOTE: _wcscmpi not provided by CRTDLL, this define is for portability */ +#define _wcscmpi _wcsicmp + +wchar_t* _wcsdup (wchar_t*); +int _wcsicmp (const wchar_t*, const wchar_t*); +int _wcsicoll (const wchar_t*, const wchar_t*); +wchar_t* _wcslwr (wchar_t*); +int _wcsnicmp (const wchar_t*, const wchar_t*, size_t); +wchar_t* _wcsnset (wchar_t*, wchar_t, size_t); +wchar_t* _wcsrev (wchar_t*); +wchar_t* _wcsset (wchar_t*, wchar_t); +wchar_t* _wcsupr (wchar_t*); + +#endif /* Not __STRICT_ANSI__ */ + + +#ifndef __STRICT_ANSI__ +#ifndef _NO_OLDNAMES + +/* + * Non-underscored versions of non-ANSI functions. They live in liboldnames.a + * and provide a little extra portability. Also a few extra UNIX-isms like + * strcasecmp. + */ + +void* memccpy (void*, const void*, int, size_t); +int memicmp (const void*, const void*, size_t); +char* strdup (const char*); +int strcmpi (const char*, const char*); +int stricmp (const char*, const char*); +int strcasecmp (const char*, const char*); +int stricoll (const char*, const char*); +char* strlwr (char*); +int strnicmp (const char*, const char*, size_t); +int strncasecmp (const char*, const char*, size_t); +char* strnset (char*, int, size_t); +char* strrev (char*); +char* strset (char*, int); +char* strupr (char*); +#ifndef _UWIN +void swab (const char*, char*, size_t); +#endif /* _UWIN */ + +/* NOTE: There is no _wcscmpi, but this is for compatibility. */ +int wcscmpi (const wchar_t*, const wchar_t*); +wchar_t* wcsdup (wchar_t*); +int wcsicmp (const wchar_t*, const wchar_t*); +int wcsicoll (const wchar_t*, const wchar_t*); +wchar_t* wcslwr (wchar_t*); +int wcsnicmp (const wchar_t*, const wchar_t*, size_t); +wchar_t* wcsnset (wchar_t*, wchar_t, size_t); +wchar_t* wcsrev (wchar_t*); +wchar_t* wcsset (wchar_t*, wchar_t); +wchar_t* wcsupr (wchar_t*); + +#endif /* Not _NO_OLDNAMES */ +#endif /* Not strict ANSI */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STRING_H_ */ + diff --git a/winsup/mingw/include/sys/fcntl.h b/winsup/mingw/include/sys/fcntl.h new file mode 100644 index 000000000..b343f272f --- /dev/null +++ b/winsup/mingw/include/sys/fcntl.h @@ -0,0 +1,8 @@ +/* + * This file is part of the Mingw32 package. + * + * This fcntl.h maps to the root fcntl.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/sys/file.h b/winsup/mingw/include/sys/file.h new file mode 100644 index 000000000..96c49e117 --- /dev/null +++ b/winsup/mingw/include/sys/file.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * This file.h maps to the root fcntl.h + * TODO? + */ +#ifndef __STRICT_ANSI__ +#include +#endif diff --git a/winsup/mingw/include/sys/locking.h b/winsup/mingw/include/sys/locking.h new file mode 100644 index 000000000..cf33b5f03 --- /dev/null +++ b/winsup/mingw/include/sys/locking.h @@ -0,0 +1,52 @@ +/* + * locking.h + * + * Constants for the mode parameter of the locking function. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _LOCKING_H_ +#define _LOCKING_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define _LK_UNLOCK 0 /* Unlock */ +#define _LK_LOCK 1 /* Lock */ +#define _LK_NBLCK 2 /* Non-blocking lock */ +#define _LK_RLCK 3 /* Lock for read only */ +#define _LK_NBRLCK 4 /* Non-blocking lock for read only */ + +#ifndef NO_OLDNAMES +#define LK_UNLOCK _LK_UNLOCK +#define LK_LOCK _LK_LOCK +#define LK_NBLCK _LK_NBLCK +#define LK_RLCK _LK_RLCK +#define LK_NBRLCK _LK_NBRLCK +#endif /* Not NO_OLDNAMES */ + +#endif /* Not _LOCKING_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/stat.h b/winsup/mingw/include/sys/stat.h new file mode 100644 index 000000000..f1b327e46 --- /dev/null +++ b/winsup/mingw/include/sys/stat.h @@ -0,0 +1,175 @@ +/* + * stat.h + * + * Symbolic constants for opening and creating files, also stat, fstat and + * chmod functions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _STAT_H_ +#define _STAT_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_size_t +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#include + +/* + * Constants for the stat st_mode member. + */ +#define _S_IFIFO 0x1000 /* FIFO */ +#define _S_IFCHR 0x2000 /* Character */ +#define _S_IFBLK 0x3000 /* Block */ +#define _S_IFDIR 0x4000 /* Directory */ +#define _S_IFREG 0x8000 /* Regular */ + +#define _S_IFMT 0xF000 /* File type mask */ + +#define _S_IEXEC 0x0040 +#define _S_IWRITE 0x0080 +#define _S_IREAD 0x0100 + +#define _S_IRWXU (_S_IREAD | _S_IWRITE | _S_IEXEC) +#define _S_IXUSR _S_IEXEC +#define _S_IWUSR _S_IWRITE +#define _S_IRUSR _S_IREAD + +#define _S_ISDIR(m) ((m) & _S_IFDIR) +#define _S_ISFIFO(m) ((m) & _S_IFIFO) +#define _S_ISCHR(m) ((m) & _S_IFCHR) +#define _S_ISBLK(m) ((m) & _S_IFBLK) +#define _S_ISREG(m) ((m) & _S_IFREG) + +#ifndef _NO_OLDNAMES + +#define S_IFIFO _S_IFIFO +#define S_IFCHR _S_IFCHR +#define S_IFBLK _S_IFBLK +#define S_IFDIR _S_IFDIR +#define S_IFREG _S_IFREG +#define S_IFMT _S_IFMT +#define S_IEXEC _S_IEXEC +#define S_IWRITE _S_IWRITE +#define S_IREAD _S_IREAD +#define S_IRWXU _S_IRWXU +#define S_IXUSR _S_IXUSR +#define S_IWUSR _S_IWUSR +#define S_IRUSR _S_IRUSR + +#define S_ISDIR(m) ((m) & S_IFDIR) +#define S_ISFIFO(m) ((m) & S_IFIFO) +#define S_ISCHR(m) ((m) & S_IFCHR) +#define S_ISBLK(m) ((m) & S_IFBLK) +#define S_ISREG(m) ((m) & S_IFREG) + +#endif /* Not _NO_OLDNAMES */ + +#ifndef RC_INVOKED + +#ifndef _STAT_DEFINED +/* + * The structure manipulated and returned by stat and fstat. + * + * NOTE: If called on a directory the values in the time fields are not only + * invalid, they will cause localtime et. al. to return NULL. And calling + * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! + */ +struct _stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +struct stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +#define _STAT_DEFINED +#endif /* _STAT_DEFINED */ + +#ifdef __cplusplus +extern "C" { +#endif + +int _fstat (int, struct _stat*); +int _chmod (const char*, int); +int _stat (const char*, struct _stat*); + +#ifndef _WSTAT_DEFINED + +/* also declared in wchar.h */ + +int _wstat(const wchar_t*, struct _stat*); + +#define _WSTAT_DEFINED +#endif /* _WSTAT_DEFIND */ + +#ifndef _NO_OLDNAMES + +/* These functions live in liboldnames.a. */ +int fstat (int, struct stat*); +int chmod (const char*, int); +int stat (const char*, struct stat*); + +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _STAT_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/time.h b/winsup/mingw/include/sys/time.h new file mode 100644 index 000000000..39d85f67b --- /dev/null +++ b/winsup/mingw/include/sys/time.h @@ -0,0 +1,3 @@ + +#include + diff --git a/winsup/mingw/include/sys/timeb.h b/winsup/mingw/include/sys/timeb.h new file mode 100644 index 000000000..696a33404 --- /dev/null +++ b/winsup/mingw/include/sys/timeb.h @@ -0,0 +1,82 @@ +/* + * timeb.h + * + * Support for the UNIX System V ftime system call. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _TIMEB_H_ +#define _TIMEB_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#ifndef RC_INVOKED + +/* + * TODO: Structure not tested. + */ +struct _timeb +{ + long time; + short millitm; + short timezone; + short dstflag; +}; + +#ifndef _NO_OLDNAMES +/* + * TODO: Structure not tested. + */ +struct timeb +{ + long time; + short millitm; + short timezone; + short dstflag; +}; +#endif + + +#ifdef __cplusplus +extern "C" { +#endif + +/* TODO: Not tested. */ +void _ftime (struct _timeb*); + +#ifndef _NO_OLDNAMES +void ftime (struct timeb*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TIMEB_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/sys/types.h b/winsup/mingw/include/sys/types.h new file mode 100644 index 000000000..dce11f51d --- /dev/null +++ b/winsup/mingw/include/sys/types.h @@ -0,0 +1,118 @@ +/* + * types.h + * + * The definition of constants, data types and global variables. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Lots of types supplied by Pedro A. Aranda + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TYPES_H_ +#define _TYPES_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#define __need_ptrdiff_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#ifndef RC_INVOKED + +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + + +#ifndef __STRICT_ANSI__ + +#ifndef _OFF_T_ +#define _OFF_T_ +typedef long _off_t; + +#ifndef _NO_OLDNAMES +typedef _off_t off_t; +#endif +#endif /* Not _OFF_T_ */ + + +#ifndef _DEV_T_ +#define _DEV_T_ +#ifdef __MSVCRT__ +typedef unsigned int _dev_t; +#else +typedef short _dev_t; +#endif + +#ifndef _NO_OLDNAMES +typedef _dev_t dev_t; +#endif +#endif /* Not _DEV_T_ */ + + +#ifndef _INO_T_ +#define _INO_T_ +typedef short _ino_t; + +#ifndef _NO_OLDNAMES +typedef _ino_t ino_t; +#endif +#endif /* Not _INO_T_ */ + + +#ifndef _PID_T_ +#define _PID_T_ +typedef int _pid_t; + +#ifndef _NO_OLDNAMES +typedef _pid_t pid_t; +#endif +#endif /* Not _PID_T_ */ + + +#ifndef _MODE_T_ +#define _MODE_T_ +typedef unsigned short _mode_t; + +#ifndef _NO_OLDNAMES +typedef _mode_t mode_t; +#endif +#endif /* Not _MODE_T_ */ + + +#ifndef _SIGSET_T_ +#define _SIGSET_T_ +typedef int _sigset_t; + +#ifndef _NO_OLDNAMES +typedef _sigset_t sigset_t; +#endif +#endif /* Not _SIGSET_T_ */ + +#endif /* Not __STRICT_ANSI__ */ + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TYPES_H_ */ diff --git a/winsup/mingw/include/sys/unistd.h b/winsup/mingw/include/sys/unistd.h new file mode 100644 index 000000000..ed122d9dd --- /dev/null +++ b/winsup/mingw/include/sys/unistd.h @@ -0,0 +1,9 @@ +/* + * This file is part of the Mingw32 package. + * + * unistd.h maps (roughly) to io.h + */ +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/sys/utime.h b/winsup/mingw/include/sys/utime.h new file mode 100644 index 000000000..59d00fe2c --- /dev/null +++ b/winsup/mingw/include/sys/utime.h @@ -0,0 +1,89 @@ +/* + * utime.h + * + * Support for the utime function. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _UTIME_H_ +#define _UTIME_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ +#include + +#ifndef RC_INVOKED + +/* + * Structure used by _utime function. + */ +struct _utimbuf +{ + time_t actime; /* Access time */ + time_t modtime; /* Modification time */ +}; + + +#ifndef _NO_OLDNAMES +/* NOTE: Must be the same as _utimbuf above. */ +struct utimbuf +{ + time_t actime; + time_t modtime; +}; +#endif /* Not _NO_OLDNAMES */ + + +#ifdef __cplusplus +extern "C" { +#endif + +int _utime (const char*, struct _utimbuf*); +int _futime (int, struct _utimbuf*); + +/* The wide character version, only available for MSVCRT versions of the + * C runtime library. */ +#ifdef __MSVCRT__ +int _wutime (const wchar_t*, struct _utimbuf*); +#endif /* MSVCRT runtime */ +#ifndef _NO_OLDNAMES +int utime (const char*, struct utimbuf*); +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _UTIME_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/tchar.h b/winsup/mingw/include/tchar.h new file mode 100644 index 000000000..34fc3c9e7 --- /dev/null +++ b/winsup/mingw/include/tchar.h @@ -0,0 +1,261 @@ +/* + * tchar.h + * + * Unicode mapping layer for the standard C library. By including this + * file and using the 't' names for string functions + * (eg. _tprintf) you can make code which can be easily adapted to both + * Unicode and non-unicode environments. In a unicode enabled compile define + * _UNICODE before including tchar.h, otherwise the standard non-unicode + * library functions will be used. + * + * Note that you still need to include string.h or stdlib.h etc. to define + * the appropriate functions. Also note that there are several defines + * included for non-ANSI functions which are commonly available (but using + * the convention of prepending an underscore to non-ANSI library function + * names). + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TCHAR_H_ +#define _TCHAR_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * NOTE: This tests _UNICODE, which is different from the UNICODE define + * used to differentiate Win32 API calls. + */ +#ifdef _UNICODE + + +/* + * Use TCHAR instead of char or wchar_t. It will be appropriately translated + * if _UNICODE is correctly defined (or not). + */ +#ifndef _TCHAR_DEFINED +#ifndef RC_INVOKED +typedef wchar_t TCHAR; +#endif /* Not RC_INVOKED */ +#define _TCHAR_DEFINED +#endif + + +/* + * Enclose constant strings and literal characters in the _TEXT macro to make + * them unicode constant strings when _UNICODE is defined. + */ +#define _TEXT(x) L ## x + +#ifndef _T +#define _T(x) L ## x +#endif + +/* + * Unicode functions + */ + +#define _tprintf wprintf +#define _ftprintf fwprintf +#define _stprintf swprintf +#define _sntprintf _snwprintf +#define _vtprintf vwprintf +#define _vftprintf vfwprintf +#define _vstprintf vswprintf +#define _vsntprintf _vsnwprintf +#define _tscanf wscanf +#define _ftscanf fwscanf +#define _stscanf swscanf +#define _fgettc fgetwc +#define _fgettchar _fgetwchar +#define _fgetts fgetws +#define _fputtc fputwc +#define _fputtchar _fputwchar +#define _fputts fputws +#define _gettc getwc +#define _getts getws +#define _puttc putwc +#define _putts putws +#define _ungettc ungetwc +#define _tcstod wcstod +#define _tcstol wcstol +#define _tcstoul wcstoul +#define _itot _itow +#define _ltot _ltow +#define _ultot _ultow +#define _ttoi _wtoi +#define _ttol _wtol +#define _tcscat wcscat +#define _tcschr wcschr +#define _tcscmp wcscmp +#define _tcscpy wcscpy +#define _tcscspn wcscspn +#define _tcslen wcslen +#define _tcsncat wcsncat +#define _tcsncmp wcsncmp +#define _tcsncpy wcsncpy +#define _tcspbrk wcspbrk +#define _tcsrchr wcsrchr +#define _tcsspn wcsspn +#define _tcsstr wcsstr +#define _tcstok wcstok +#define _tcsdup _wcsdup +#define _tcsicmp _wcsicmp +#define _tcsnicmp _wcsnicmp +#define _tcsnset _wcsnset +#define _tcsrev _wcsrev +#define _tcsset _wcsset +#define _tcslwr _wcslwr +#define _tcsupr _wcsupr +#define _tcsxfrm wcsxfrm +#define _tcscoll wcscoll +#define _tcsicoll _wcsicoll +#define _istalpha iswalpha +#define _istupper iswupper +#define _istlower iswlower +#define _istdigit iswdigit +#define _istxdigit iswxdigit +#define _istspace iswspace +#define _istpunct iswpunct +#define _istalnum iswalnum +#define _istprint iswprint +#define _istgraph iswgraph +#define _istcntrl iswcntrl +#define _istascii iswascii +#define _totupper towupper +#define _totlower towlower +#define _tasctime _wasctime +#define _tctime _wctime +#define _tstrdate _wstrdate +#define _tstrtime _wstrtime +#define _tutime _wutime +#define _tcsftime wcsftime +#define _ttoi _wtoi +#define _ttol _wtol + +#else /* Not _UNICODE */ + +/* + * TCHAR, the type you should use instead of char. + */ +#ifndef _TCHAR_DEFINED +#ifndef RC_INVOKED +typedef char TCHAR; +#endif +#define _TCHAR_DEFINED +#endif + +/* + * Enclose constant strings and characters in the _TEXT macro. + */ +#define _TEXT(x) x + +#ifndef _T +#define _T(x) x +#endif + +/* + * Non-unicode (standard) functions + */ + +#define _tprintf printf +#define _ftprintf fprintf +#define _stprintf sprintf +#define _sntprintf _snprintf +#define _vtprintf vprintf +#define _vftprintf vfprintf +#define _vstprintf vsprintf +#define _vsntprintf _vsnprintf +#define _tscanf scanf +#define _ftscanf fscanf +#define _stscanf sscanf +#define _fgettc fgetc +#define _fgettchar _fgetchar +#define _fgetts fgets +#define _fputtc fputc +#define _fputtchar _fputchar +#define _fputts fputs +#define _gettc getc +#define _getts gets +#define _puttc putc +#define _putts puts +#define _ungettc ungetc +#define _tcstod strtod +#define _tcstol strtol +#define _tcstoul strtoul +#define _itot _itoa +#define _ltot _ltoa +#define _ultot _ultoa +#define _ttoi atoi +#define _ttol atol +#define _tcscat strcat +#define _tcschr strchr +#define _tcscmp strcmp +#define _tcscpy strcpy +#define _tcscspn strcspn +#define _tcslen strlen +#define _tcsncat strncat +#define _tcsncmp strncmp +#define _tcsncpy strncpy +#define _tcspbrk strpbrk +#define _tcsrchr strrchr +#define _tcsspn strspn +#define _tcsstr strstr +#define _tcstok strtok +#define _tcsdup _strdup +#define _tcsicmp _stricmp +#define _tcsnicmp _strnicmp +#define _tcsnset _strnset +#define _tcsrev _strrev +#define _tcsset _strset +#define _tcslwr _strlwr +#define _tcsupr _strupr +#define _tcsxfrm strxfrm +#define _tcscoll strcoll +#define _tcsicoll _stricoll +#define _istalpha isalpha +#define _istupper isupper +#define _istlower islower +#define _istdigit isdigit +#define _istxdigit isxdigit +#define _istspace isspace +#define _istpunct ispunct +#define _istalnum isalnum +#define _istprint isprint +#define _istgraph isgraph +#define _istcntrl iscntrl +#define _istascii isascii +#define _totupper toupper +#define _totlower tolower +#define _tasctime asctime +#define _tctime ctime +#define _tstrdate _strdate +#define _tstrtime _strtime +#define _tutime _utime +#define _tcsftime strftime +#define _ttoi atoi +#define _ttol atol + +#endif /* Not _UNICODE */ + +#endif /* Not _TCHAR_H_ */ + diff --git a/winsup/mingw/include/time.h b/winsup/mingw/include/time.h new file mode 100644 index 000000000..53dd86a5f --- /dev/null +++ b/winsup/mingw/include/time.h @@ -0,0 +1,219 @@ +/* + * time.h + * + * Date and time functions and types. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _TIME_H_ +#define _TIME_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_size_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +/* + * Need a definition of time_t. + */ +#include + +/* + * Number of clock ticks per second. A clock tick is the unit by which + * processor time is measured and is returned by 'clock'. + */ +#define CLOCKS_PER_SEC 1000.0 +#define CLK_TCK CLOCKS_PER_SEC + + +#ifndef RC_INVOKED + +/* + * A type for storing the current time and date. This is the number of + * seconds since midnight Jan 1, 1970. + * NOTE: Normally this is defined by the above include of sys/types.h + */ +#ifndef _TIME_T_DEFINED +typedef long time_t; +#define _TIME_T_DEFINED +#endif + +/* + * A type for measuring processor time (in clock ticks). + */ +#ifndef _CLOCK_T_DEFINED +typedef long clock_t; +#define _CLOCK_T_DEFINED +#endif + + +/* + * A structure for storing all kinds of useful information about the + * current (or another) time. + */ +struct tm +{ + int tm_sec; /* Seconds: 0-59 (K&R says 0-61?) */ + int tm_min; /* Minutes: 0-59 */ + int tm_hour; /* Hours since midnight: 0-23 */ + int tm_mday; /* Day of the month: 1-31 */ + int tm_mon; /* Months *since* january: 0-11 */ + int tm_year; /* Years since 1900 */ + int tm_wday; /* Days since Sunday (0-6) */ + int tm_yday; /* Days since Jan. 1: 0-365 */ + int tm_isdst; /* +1 Daylight Savings Time, 0 No DST, + * -1 don't know */ +}; + +#ifdef __cplusplus +extern "C" { +#endif + +clock_t clock (void); +time_t time (time_t*); +double difftime (time_t, time_t); +time_t mktime (struct tm*); + +/* + * These functions write to and return pointers to static buffers that may + * be overwritten by other function calls. Yikes! + * + * NOTE: localtime, and perhaps the others of the four functions grouped + * below may return NULL if their argument is not 'acceptable'. Also note + * that calling asctime with a NULL pointer will produce an Invalid Page + * Fault and crap out your program. Guess how I know. Hint: stat called on + * a directory gives 'invalid' times in st_atime etc... + */ +char* asctime (const struct tm*); +char* ctime (const time_t*); +struct tm* gmtime (const time_t*); +struct tm* localtime (const time_t*); + + +size_t strftime (char*, size_t, const char*, const struct tm*); + +size_t wcsftime (wchar_t*, size_t, const wchar_t*, const struct tm*); + +#ifndef __STRICT_ANSI__ +extern void _tzset (void); + +#ifndef _NO_OLDNAMES +extern void tzset (void); +#endif + +size_t strftime(char*, size_t, const char*, const struct tm*); +char* _strdate(char*); +char* _strtime(char*); + +#endif /* Not __STRICT_ANSI__ */ + +/* + * _daylight: non zero if daylight savings time is used. + * _timezone: difference in seconds between GMT and local time. + * _tzname: standard/daylight savings time zone names (an array with two + * elements). + */ +#ifdef __MSVCRT__ + +/* These are for compatibility with pre-VC 5.0 suppied MSVCRT. */ +extern int* __p__daylight (void); +extern long* __p__timezone (void); +extern char** __p__tzname (void); + +__MINGW_IMPORT int _daylight; +__MINGW_IMPORT long _timezone; +__MINGW_IMPORT char *_tzname[2]; + +#else /* not __MSVCRT (ie. crtdll) */ + +#ifndef __DECLSPEC_SUPPORTED + +extern int* __imp__daylight_dll; +extern long* __imp__timezone_dll; +extern char** __imp__tzname; + +#define _daylight (*__imp__daylight_dll) +#define _timezone (*__imp__timezone_dll) +#define _tzname (__imp__tzname) + +#else /* __DECLSPEC_SUPPORTED */ + +__MINGW_IMPORT int _daylight_dll; +__MINGW_IMPORT long _timezone_dll; +__MINGW_IMPORT char* _tzname[2]; + +#define _daylight _daylight_dll +#define _timezone _timezone_dll + +#endif /* __DECLSPEC_SUPPORTED */ + +#endif /* not __MSVCRT__ */ + +#ifndef _NO_OLDNAMES + +#ifdef __MSVCRT__ + +/* These go in the oldnames import library for MSVCRT. */ +__MINGW_IMPORT int daylight; +__MINGW_IMPORT long timezone; +__MINGW_IMPORT char *tzname[2]; + +#ifndef _WTIME_DEFINED + +/* wide function prototypes, also declared in wchar.h */ + +wchar_t * _wasctime(const struct tm*); +wchar_t * _wctime(const time_t*); +wchar_t* _wstrdate(wchar_t*); +wchar_t* _wstrtime(wchar_t*); + +#define _WTIME_DEFINED +#endif /* _WTIME_DEFINED */ + + +#else /* not __MSVCRT__ */ + +/* CRTDLL is royally messed up when it comes to these macros. + TODO: import and alias these via oldnames import library instead + of macros. */ + +#define daylight _daylight +/* NOTE: timezone not defined because it would conflict with sys/timeb.h. + Also, tzname used to a be macro, but now it's in moldname. */ +__MINGW_IMPORT char *tzname[2]; + +#endif /* not __MSVCRT__ */ + +#endif /* Not _NO_OLDNAMES */ + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _TIME_H_ */ + diff --git a/winsup/mingw/include/unistd.h b/winsup/mingw/include/unistd.h new file mode 100644 index 000000000..8f51f7661 --- /dev/null +++ b/winsup/mingw/include/unistd.h @@ -0,0 +1,10 @@ +/* + * This file is part of the Mingw32 package. + * + * unistd.h maps (roughly) to io.h + */ + +#ifndef __STRICT_ANSI__ +#include +#endif + diff --git a/winsup/mingw/include/values.h b/winsup/mingw/include/values.h new file mode 100644 index 000000000..10e16a281 --- /dev/null +++ b/winsup/mingw/include/values.h @@ -0,0 +1,4 @@ +/* + * TODO: Nothing here yet. Should provide UNIX compatibility constants + * comparible to those in limits.h and float.h. + */ diff --git a/winsup/mingw/include/varargs.h b/winsup/mingw/include/varargs.h new file mode 100644 index 000000000..48e203b24 --- /dev/null +++ b/winsup/mingw/include/varargs.h @@ -0,0 +1,98 @@ +/* + * varargs.h + * + * Old, non-ANSI facilities for stepping through a list of function + * arguments of an unknown number and type. + * TODO: Has not been tested. Essentially it copies the GCC version. + * + * NOTE: I believe GCC supplies a version of this header as well (in + * addition to stdarg.h and others). The GCC version is more + * complex, to deal with many alternate systems, but it is + * probably more trustworthy overall. It would probably be + * better to use the GCC version. + * + * NOTE: These are incompatible with the versions in stdarg.h and should + * NOT be mixed! All new code should use the ANSI compatible versions. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef __STRICT_ANSI__ + +#ifndef _VARARGS_H_ +#define _VARARGS_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +/* + * I was told that Win NT likes this. + */ +#ifndef _VA_LIST_DEFINED +#define _VA_LIST_DEFINED +#endif + +#ifndef RC_INVOKED + +#ifndef _VA_LIST +#define _VA_LIST +typedef char* va_list; +#endif + +/* + * Amount of space required in an argument list (ie. the stack) for an + * argument of type t. + */ +#define __va_argsiz(t) \ + (((sizeof(t) + sizeof(int) - 1) / sizeof(int)) * sizeof(int)) + +#define va_alist __builtin_va_alist + +/* + * Used in old style argument lists IIRC. The ellipsis forces the compiler + * to realize this is a vararg function. + */ +#define va_dcl int __builtin_va_alist; ... + +#define va_start(ap) \ + ((ap) = ((va_list) &__builtin_va_alist)) +#define va_end(ap) ((void)0) + + +/* + * Increment ap to the next argument in the list while returing a + * pointer to what ap pointed to first, which is of type t. + * + * We cast to void* and then to t* because this avoids a warning about + * increasing the alignment requirement. + */ + +#define va_arg(ap, t) \ + (((ap) = (ap) + __va_argsiz(t)), \ + *((t*) (void*) ((ap) - __va_argsiz(t)))) + + +#endif /* Not RC_INVOKED */ + +#endif /* Not _VARARGS_H_ */ + +#endif /* Not __STRICT_ANSI__ */ + diff --git a/winsup/mingw/include/wchar.h b/winsup/mingw/include/wchar.h new file mode 100644 index 000000000..d2bc09415 --- /dev/null +++ b/winsup/mingw/include/wchar.h @@ -0,0 +1,212 @@ +/* + * wchar.h + * + * Defines of all functions for supporting wide characters. Actually it + * just includes all those headers, which is not a good thing to do from a + * processing time point of view, but it does mean that everything will be + * in sync. + * + * This file is part of the Mingw32 package. + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _WCHAR_H_ +#define _WCHAR_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#include +#include +#include +#include +#include +#include + +#define __need_size_t +#define __need_wint_t +#define __need_wchar_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +#define WCHAR_MIN 0 +#define WCHAR_MAX ((wchar_t)-1) + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef __STRICT_ANSI__ + +#ifndef _FSIZE_T_DEFINED +typedef unsigned long _fsize_t; +#define _FSIZE_T_DEFINED +#endif + +#ifndef _WFINDDATA_T_DEFINED +struct _wfinddata_t { + unsigned attrib; + time_t time_create; /* -1 for FAT file systems */ + time_t time_access; /* -1 for FAT file systems */ + time_t time_write; + _fsize_t size; + wchar_t name[FILENAME_MAX]; /* may include spaces. */ +}; +#define _WFINDDATA_T_DEFINED +#endif + +/* Wide character versions. Also defined in io.h. */ +/* CHECK: I believe these only exist in MSVCRT, and not in CRTDLL. Also + applies to other wide character versions? */ +int _waccess(const wchar_t *, int); +int _wchmod(const wchar_t *, int); +int _wcreat(const wchar_t *, int); +long _wfindfirst(wchar_t *, struct _wfinddata_t *); +int _wfindnext(long, struct _wfinddata_t *); +int _wunlink(const wchar_t *); +int _wrename(const wchar_t *, const wchar_t *); +int _wremove (const wchar_t *); +int _wopen(const wchar_t *, int, ...); +int _wsopen(const wchar_t *, int, int, ...); +wchar_t * _wmktemp(wchar_t *); + +#ifndef _WDIRECT_DEFINED + +/* Also in direct.h */ + +int _wchdir(const wchar_t*); +wchar_t* _wgetcwd(wchar_t*, int); +wchar_t* _wgetdcwd(int, wchar_t*, int); +int _wmkdir(const wchar_t*); +int _wrmdir(const wchar_t*); + +#define _WDIRECT_DEFINED +#endif + +#ifndef _STAT_DEFINED +/* + * The structure manipulated and returned by stat and fstat. + * + * NOTE: If called on a directory the values in the time fields are not only + * invalid, they will cause localtime et. al. to return NULL. And calling + * asctime with a NULL pointer causes an Invalid Page Fault. So watch it! + */ +struct _stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +struct stat +{ + _dev_t st_dev; /* Equivalent to drive number 0=A 1=B ... */ + _ino_t st_ino; /* Always zero ? */ + _mode_t st_mode; /* See above constants */ + short st_nlink; /* Number of links. */ + short st_uid; /* User: Maybe significant on NT ? */ + short st_gid; /* Group: Ditto */ + _dev_t st_rdev; /* Seems useless (not even filled in) */ + _off_t st_size; /* File size in bytes */ + time_t st_atime; /* Accessed date (always 00:00 hrs local + * on FAT) */ + time_t st_mtime; /* Modified time */ + time_t st_ctime; /* Creation time */ +}; + +#define _STAT_DEFINED +#endif /* _STAT_DEFINED */ + +#ifndef _WSTAT_DEFINED + +/* also declared in sys/stat.h */ + +int _wstat(const wchar_t *, struct _stat *); + +#define _WSTAT_DEFINED +#endif /* _WSTAT_DEFINED */ + +#ifndef _WTIME_DEFINED +#ifdef __MSVCRT__ + +/* wide function prototypes, also declared in time.h */ + +wchar_t * _wasctime(const struct tm*); +wchar_t * _wctime(const time_t*); +wchar_t* _wstrdate(wchar_t*); +wchar_t* _wstrtime(wchar_t*); + +#endif /* __MSVCRT__ */ + +size_t wcsftime(wchar_t*, size_t, const wchar_t*, const struct tm*); + +#define _WTIME_DEFINED +#endif /* _WTIME_DEFINED */ + + +#ifndef _NO_OLDNAMES + +/* Wide character versions. Also declared in wchar.h. */ +/* CHECK: Are these in the olnames??? */ +int waccess(const wchar_t *, int); +int wchmod(const wchar_t *, int); +int wcreat(const wchar_t *, int); +long wfindfirst(wchar_t *, struct _wfinddata_t *); +int wfindnext(long, struct _wfinddata_t *); +int wunlink(const wchar_t *); +int wrename(const wchar_t *, const wchar_t *); +int wremove (const wchar_t *); +int wopen(const wchar_t *, int, ...); +int wsopen(const wchar_t *, int, int, ...); +wchar_t * wmktemp(wchar_t *); + +#endif /* _NO_OLDNAMES */ + +#endif /* not __STRICT_ANSI__ */ + +typedef int mbstate_t; +typedef wchar_t _Wint_t; + +wint_t btowc(int); +size_t mbrlen(const char *, size_t, mbstate_t *); +size_t mbrtowc(wchar_t *, const char *, size_t, mbstate_t *); +size_t mbsrtowcs(wchar_t *, const char **, size_t, mbstate_t *); + +size_t wcrtomb(char *, wchar_t, mbstate_t *); +size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *); +int wctob(wint_t); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* not _WCHAR_H_ */ + diff --git a/winsup/mingw/include/wctype.h b/winsup/mingw/include/wctype.h new file mode 100644 index 000000000..3dc5ae2df --- /dev/null +++ b/winsup/mingw/include/wctype.h @@ -0,0 +1,99 @@ +/* + * wctype.h + * + * Functions for testing wide character types and converting characters. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRANTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warranties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + */ + +#ifndef _WCTYPE_H_ +#define _WCTYPE_H_ + +/* All the headers include this file. */ +#include <_mingw.h> + +#define __need_wchar_t +#define __need_wint_t +#ifndef RC_INVOKED +#include +#endif /* Not RC_INVOKED */ + +/* + * The following flags are used to tell iswctype and _isctype what character + * types you are looking for. + */ +#define _UPPER 0x0001 +#define _LOWER 0x0002 +#define _DIGIT 0x0004 +#define _SPACE 0x0008 +#define _PUNCT 0x0010 +#define _CONTROL 0x0020 +#define _BLANK 0x0040 +#define _HEX 0x0080 +#define _LEADBYTE 0x8000 + +#define _ALPHA 0x0103 + +#ifndef RC_INVOKED + +#ifdef __cplusplus +extern "C" { +#endif + +#ifndef WEOF +#define WEOF (wchar_t)(0xFFFF) +#endif + +#ifndef _WCTYPE_T_DEFINED +typedef wchar_t wctype_t; +#define _WCTYPE_T_DEFINED +#endif + +/* Wide character equivalents */ +int iswalnum(wint_t); +int iswalpha(wint_t); +int iswascii(wint_t); +int iswcntrl(wint_t); +int iswctype(wint_t, wctype_t); +int is_wctype(wint_t, wctype_t); /* Obsolete! */ +int iswdigit(wint_t); +int iswgraph(wint_t); +int iswlower(wint_t); +int iswprint(wint_t); +int iswpunct(wint_t); +int iswspace(wint_t); +int iswupper(wint_t); +int iswxdigit(wint_t); + +wchar_t towlower(wchar_t); +wchar_t towupper(wchar_t); + +int isleadbyte (int); + +typedef wchar_t wctrans_t; +wint_t towctrans(wint_t, wctrans_t); +wctrans_t wctrans(const char*); +wctype_t wctype(const char*); + +#ifdef __cplusplus +} +#endif + +#endif /* Not RC_INVOKED */ + +#endif /* Not _WCTYPE_H_ */ + diff --git a/winsup/mingw/init.c b/winsup/mingw/init.c new file mode 100644 index 000000000..8fa4652fa --- /dev/null +++ b/winsup/mingw/init.c @@ -0,0 +1,84 @@ +/* + * init.c + * + * Code to initialize standard file handles and command line arguments. + * This file is #included in both crt1.c and dllcrt1.c. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Maintained by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +/* + * Access to a standard 'main'-like argument count and list. Also included + * is a table of environment variables. + */ +int _argc = 0; +char **_argv = 0; + +/* NOTE: Thanks to Pedro A. Aranda Gutiirrez for pointing + * this out to me. GetMainArgs (used below) takes a fourth argument + * which is an int that controls the globbing of the command line. If + * _CRT_glob is non-zero the command line will be globbed (e.g. *.* + * expanded to be all files in the startup directory). In the mingw32 + * library a _CRT_glob variable is defined as being -1, enabling + * this command line globbing by default. To turn it off and do all + * command line processing yourself (and possibly escape bogons in + * MS's globbing code) include a line in one of your source modules + * defining _CRT_glob and setting it to zero, like this: + * int _CRT_glob = 0; + */ +extern int _CRT_glob; + +#ifdef __MSVCRT__ +typedef struct { + int newmode; +} _startupinfo; +extern void __getmainargs (int *, char ***, char ***, int, _startupinfo *); +#else +extern void __GetMainArgs (int *, char ***, char ***, int); +#endif + +/* + * Initialize the _argc, _argv and environ variables. + */ +static void +_mingw32_init_mainargs () +{ + /* The environ variable is provided directly in stdlib.h through + * a dll function call. */ + char **dummy_environ; +#ifdef __MSVCRT__ + _startupinfo start_info; + start_info.newmode = 0; +#endif + + /* + * Microsoft's runtime provides a function for doing just that. + */ +#ifdef __MSVCRT__ + (void) __getmainargs (&_argc, &_argv, &dummy_environ, _CRT_glob, + &start_info); +#else + /* CRTDLL version */ + (void) __GetMainArgs (&_argc, &_argv, &dummy_environ, _CRT_glob); +#endif +} + diff --git a/winsup/mingw/jamfile b/winsup/mingw/jamfile new file mode 100644 index 000000000..1769d952d --- /dev/null +++ b/winsup/mingw/jamfile @@ -0,0 +1,72 @@ +# +# Jamfile for building various libraries and object files for the +# Minimalist GNU-Win32 package. +# +# $Revision$ +# $Author$ +# $Date$ +# + +# Change this line if you have installed Mingw32 in another directory. +# +LOCATE_TARGET = /mingw32/lib ; + +RUNTIME default = crtdll ; + +# Build the mingw32 library which contains startup code and extra support +# routines. +# +Library libmingw32.a : + CRTglob.c + CRTfmode.c + CRTinit.c + dirent.c + dllmain.c + gccmain.c + main.c + ; + + +# Build the startup object files for normal applications and for DLLs. +# The crt2 and dllcrt2 versions are for MSVCRTxx.DLL runtimes. crt1 and +# dllcrt1 are for the CRTDLL.DLL runtime. +# +Object crt1.o : crt1.c ; +Object crt2.o : crt1.c ; + +CCFLAGS on crt2.o += -D__MSVCRT__ ; + +Object dllcrt1.o : dllcrt1.c ; +Object dllcrt2.o : dllcrt1.c ; + +CCFLAGS on dllcrt2.o += -D__MSVCRT__ ; + +DEPENDS all : crt1.o dllcrt1.o crt2.o dllcrt2.o ; + + +# Build an object file which contains a single global variable initialized +# so that globbing will not be performed on the command line. +# +Object CRT_noglob.o : CRT_noglob.c ; +LOCATE on CRT_noglob.o = $(LOCATE_TARGET) ; + +DEPENDS all : CRT_noglob.o ; + + +# Build a special import library which contains mostly the imports defined +# in moldname.def, but with their leading underscores stripped off, plus the +# extra code in the C modules included. +# +ImportLib libmoldname.a : moldname.def ctype_old.c string_old.c ; + +DLLNAME on libmoldname.a = $(RUNTIME).dll ; +DLLTOOLFLAGS on libmoldname.a += -U ; + + +# Build import libraries for the various runtimes. +# +ImportLib libcrtdll.a : crtdll.def ; +ImportLib libmsvcrt.a : msvcrt.def ; +ImportLib libmsvcrt20.a : msvcrt20.def ; +ImportLib libmsvcrt40.a : msvcrt40.def ; + diff --git a/winsup/mingw/main.c b/winsup/mingw/main.c new file mode 100644 index 000000000..ea1dcd85e --- /dev/null +++ b/winsup/mingw/main.c @@ -0,0 +1,96 @@ +/* + * main.c + * + * Extra startup code for applications which do not have a main function + * of their own (but do have a WinMain). Generally these are GUI + * applications, but they don't *have* to be. + * + * This file is part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * Maintained by Mumit Khan + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include +#include +#include + +#define ISSPACE(a) (a == ' ' || a == '\t') + +extern int PASCAL WinMain (HINSTANCE hInst, HINSTANCE hPrevInst, + LPSTR szCmdLine, int nShow); + +int +main (int argc, char *argv[], char *environ[]) +{ + char *szCmd; + STARTUPINFO startinfo; + int nRet; + + /* Get the command line passed to the process. */ + szCmd = GetCommandLineA (); + GetStartupInfoA (&startinfo); + + /* Strip off the name of the application and any leading + * whitespace. */ + if (szCmd) + { + while (ISSPACE (*szCmd)) + { + szCmd++; + } + + /* On my system I always get the app name enclosed + * in quotes... */ + if (*szCmd == '\"') + { + do + { + szCmd++; + } + while (*szCmd != '\"' && *szCmd != '\0'); + + if (*szCmd == '\"') + { + szCmd++; + } + } + else + { + /* If no quotes then assume first token is program + * name. */ + while (!ISSPACE (*szCmd) && *szCmd != '\0') + { + szCmd++; + } + } + + while (ISSPACE (*szCmd)) + { + szCmd++; + } + } + + nRet = WinMain (GetModuleHandle (NULL), NULL, szCmd, + (startinfo.dwFlags & STARTF_USESHOWWINDOW) ? + startinfo.wShowWindow : SW_SHOWDEFAULT); + + return nRet; +} + diff --git a/winsup/mingw/moldname-crtdll.def b/winsup/mingw/moldname-crtdll.def new file mode 100644 index 000000000..3ead24436 --- /dev/null +++ b/winsup/mingw/moldname-crtdll.def @@ -0,0 +1,135 @@ +; +; moldname-crtdll.def +; +; Exports from the runtime except that these exports are actually preceeded +; by a underscore in the actual DLL. These correspond to functions which +; are non-ANSI and were prefixed with an underscore to avoid name space +; clutter. However many, in fact most programs still use a few of these +; functions without the underscore. This .def file is specially processed +; to make those non-underscored name function calls call the equivalent +; underscored functions. +; +; Contributors: +; Created by Colin Peters +; Maintained by Mumit Khan +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +EXPORTS +access +beep +cabs +chdir +chmod +chsize +close +creat +cwait + +dup +dup2 +ecvt +eof +execl +execle +execlp +execlpe +execv +execve +execvp +execvpe +fcvt +fdopen +fgetchar +fgetwchar +filelength +fileno +fpreset +fputchar +fputwchar +fstat +ftime +gcvt +getch +getche +getcwd +getpid +getw +heapwalk +hypot +isatty +itoa +j0 +j1 +jn +kbhit +lseek +ltoa +memccpy +memicmp +mkdir +mktemp +open +pclose +popen +putch +putenv +putw +read +rmdir +searchenv +seterrormode +setmode +sleep +sopen +spawnl +spawnle +spawnlp +spawnlpe +spawnv +spawnve +spawnvp +spawnvpe +stat +strcmpi +strdup +stricmp +stricoll +strlwr +strnicmp +strnset +strrev +strset +strupr +swab +tell +tempnam + +; export tzname for both. See +tzname DATA +tzset +umask +ungetch +unlink +utime +wcsdup +wcsicmp +wcsicoll +wcslwr +wcsnicmp +wcsnset +wcsrev +wcsset +wcsupr +write +y0 +y1 +yn diff --git a/winsup/mingw/moldname-msvcrt.def b/winsup/mingw/moldname-msvcrt.def new file mode 100644 index 000000000..0e0d39c31 --- /dev/null +++ b/winsup/mingw/moldname-msvcrt.def @@ -0,0 +1,139 @@ +; +; moldname-msvcrt.def +; +; Exports from the runtime except that these exports are actually preceeded +; by a underscore in the actual DLL. These correspond to functions which +; are non-ANSI and were prefixed with an underscore to avoid name space +; clutter. However many, in fact most programs still use a few of these +; functions without the underscore. This .def file is specially processed +; to make those non-underscored name function calls call the equivalent +; underscored functions. +; +; Contributors: +; Created by Colin Peters +; Maintained by Mumit Khan +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +EXPORTS +access +beep +cabs +chdir +chmod +chsize +close +creat +cwait + +daylight DATA + +dup +dup2 +ecvt +eof +execl +execle +execlp +execlpe +execv +execve +execvp +execvpe +fcvt +fdopen +fgetchar +fgetwchar +filelength +fileno +fpreset +fputchar +fputwchar +fstat +ftime +gcvt +getch +getche +getcwd +getpid +getw +heapwalk +hypot +isatty +itoa +j0 +j1 +jn +kbhit +lseek +ltoa +memccpy +memicmp +mkdir +mktemp +open +pclose +popen +putch +putenv +putw +read +rmdir +searchenv +seterrormode +setmode +sleep +sopen +spawnl +spawnle +spawnlp +spawnlpe +spawnv +spawnve +spawnvp +spawnvpe +stat +strcmpi +strdup +stricmp +stricoll +strlwr +strnicmp +strnset +strrev +strset +strupr +swab +tell +tempnam + +timezone DATA + +; export tzname for both. See +tzname DATA +tzset +umask +ungetch +unlink +utime +wcsdup +wcsicmp +wcsicoll +wcslwr +wcsnicmp +wcsnset +wcsrev +wcsset +wcsupr +write +y0 +y1 +yn diff --git a/winsup/mingw/moldname.def b/winsup/mingw/moldname.def new file mode 100644 index 000000000..369439b5c --- /dev/null +++ b/winsup/mingw/moldname.def @@ -0,0 +1,137 @@ +; +; moldname.def +; +; Exports from the runtime except that these exports are actually preceeded +; by a underscore in the actual DLL. These correspond to functions which +; are non-ANSI and were prefixed with an underscore to avoid name space +; clutter. However many, in fact most programs still use a few of these +; functions without the underscore. This .def file is specially processed +; to make those non-underscored name function calls call the equivalent +; underscored functions. +; +; NOTE: All the names currently included are available from both msvcrt and +; crtdll. This may change in the future and require a new .def to be +; created. +; +; Contributors: +; Created by Colin Peters +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +; $Revision$ +; $Author$ +; $Date$ +; +EXPORTS +access +beep +cabs +chdir +chmod +chsize +close +creat +cwait +dup +dup2 +ecvt +eof +execl +execle +execlp +execlpe +execv +execve +execvp +execvpe +fcvt +fdopen +fgetchar +fgetwchar +filelength +fileno +fputchar +fputwchar +fstat +ftime +gcvt +getch +getche +getcwd +getpid +getw +heapwalk +hypot +isatty +itoa +j0 +j1 +jn +kbhit +lseek +ltoa +memccpy +memicmp +mkdir +mktemp +open +pclose +popen +putch +putenv +putw +read +rmdir +searchenv +seterrormode +setmode +sleep +sopen +spawnl +spawnle +spawnlp +spawnlpe +spawnv +spawnve +spawnvp +spawnvpe +stat +strcmpi +strdup +stricmp +stricoll +strlwr +strnicmp +strnset +strrev +strset +strupr +swab +tell +tempnam +tzset +umask +ungetch +unlink +utime +wcsdup +wcsicmp +wcsicoll +wcslwr +wcsnicmp +wcsnset +wcsrev +wcsset +wcsupr +write +y0 +y1 +yn diff --git a/winsup/mingw/moldname.def.in b/winsup/mingw/moldname.def.in new file mode 100644 index 000000000..7e90cb374 --- /dev/null +++ b/winsup/mingw/moldname.def.in @@ -0,0 +1,139 @@ +; +; __FILENAME__ +; +; Exports from the runtime except that these exports are actually preceeded +; by a underscore in the actual DLL. These correspond to functions which +; are non-ANSI and were prefixed with an underscore to avoid name space +; clutter. However many, in fact most programs still use a few of these +; functions without the underscore. This .def file is specially processed +; to make those non-underscored name function calls call the equivalent +; underscored functions. +; +; Contributors: +; Created by Colin Peters +; Maintained by Mumit Khan +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +EXPORTS +access +beep +cabs +chdir +chmod +chsize +close +creat +cwait +#if (__MSVCRT__) +daylight DATA +#endif +dup +dup2 +ecvt +eof +execl +execle +execlp +execlpe +execv +execve +execvp +execvpe +fcvt +fdopen +fgetchar +fgetwchar +filelength +fileno +fpreset +fputchar +fputwchar +fstat +ftime +gcvt +getch +getche +getcwd +getpid +getw +heapwalk +hypot +isatty +itoa +j0 +j1 +jn +kbhit +lseek +ltoa +memccpy +memicmp +mkdir +mktemp +open +pclose +popen +putch +putenv +putw +read +rmdir +searchenv +seterrormode +setmode +sleep +sopen +spawnl +spawnle +spawnlp +spawnlpe +spawnv +spawnve +spawnvp +spawnvpe +stat +strcmpi +strdup +stricmp +stricoll +strlwr +strnicmp +strnset +strrev +strset +strupr +swab +tell +tempnam +#if (__MSVCRT__) +timezone DATA +#endif +; export tzname for both. See +tzname DATA +tzset +umask +ungetch +unlink +utime +wcsdup +wcsicmp +wcsicoll +wcslwr +wcsnicmp +wcsnset +wcsrev +wcsset +wcsupr +write +y0 +y1 +yn diff --git a/winsup/mingw/msvcrt.def b/winsup/mingw/msvcrt.def new file mode 100644 index 000000000..8a1b87210 --- /dev/null +++ b/winsup/mingw/msvcrt.def @@ -0,0 +1,737 @@ +; +; msvcrt.def +; +; Exports from msvcrt.dll. Msvcrt.dll appears to be distributed with +; Internet Explorer 4.0, and may be more common in the future, but +; right now it seems like a risky choice. There are differences, although +; they seem to be minor overall, between the exports from msvcrt and msvcrt20. +; However, for most purposes the two sets are interchangable. +; +; NOTE: All exports, except for what appeared to be C++ mangled names, +; are included. Not all functions have prototypes in the headers +; (and some aren't functions at all). +; +; Contributors: +; Created by Colin Peters +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +; $Revision$ +; $Author$ +; $Date$ +; +EXPORTS +_CIacos +_CIasin +_CIatan +_CIatan2 +_CIcos +_CIcosh +_CIexp +_CIfmod +_CIlog +_CIlog10 +_CIpow +_CIsin +_CIsinh +_CIsqrt +_CItan +_CItanh +_CxxThrowException +_EH_prolog +_Getdays +_Getmonths +_Gettnames +_HUGE DATA +_Strftime +_XcptFilter +__CxxFrameHandler +__CxxLongjmpUnwind +__RTCastToVoid +__RTDynamicCast +__RTtypeid +__STRINGTOLD +__argc DATA +__argv DATA +__badioinfo +__crtCompareStringA +__crtGetLocaleInfoW +__crtLCMapStringA +__dllonexit +__doserrno +__fpecode +__getmainargs +__initenv DATA +__isascii +__iscsym +__iscsymf +__lc_codepage +__lc_handle +__lconv_init +__mb_cur_max DATA +__p___argc +__p___argv +__p___initenv +__p___mb_cur_max +__p___wargv +__p___winitenv +__p__acmdln +__p__amblksiz +__p__commode +__p__daylight +__p__dstbias +__p__environ +__p__fileinfo +__p__fmode +__p__iob +__p__mbctype +__p__osver +__p__pctype +__p__pgmptr +__p__pwctype +__p__timezone +__p__tzname +__p__wcmdln +__p__wenviron +__p__winmajor +__p__winminor +__p__winver +__p__wpgmptr +__pioinfo +__pxcptinfoptrs +__set_app_type +__setlc_active +__setusermatherr +__threadhandle +__threadid +__toascii +__unDName +__unguarded_readlc_active +__wargv DATA +__wgetmainargs +__winitenv DATA +_abnormal_termination +_access +_acmdln DATA +_adj_fdiv_m16i +_adj_fdiv_m32 +_adj_fdiv_m32i +_adj_fdiv_m64 +_adj_fdiv_r +_adj_fdivr_m16i +_adj_fdivr_m32 +_adj_fdivr_m32i +_adj_fdivr_m64 +_adj_fpatan +_adj_fprem +_adj_fprem1 +_adj_fptan +_adjust_fdiv DATA +_aexit_rtn DATA +_amsg_exit +_assert +_atodbl +_atoi64 +_atoldbl +_beep +_beginthread +_beginthreadex +_c_exit +_cabs +_callnewh +_cexit +_cgets +_chdir +_chdrive +_chgsign +_chmod +_chsize +_clearfp +_close +_commit +_commode DATA +_control87 +_controlfp +_copysign +_cprintf +_cputs +_creat +_cscanf +_ctype DATA +_cwait +_daylight DATA +_dstbias +_dup +_dup2 +_ecvt +_endthread +_endthreadex +_environ DATA +_eof +_errno +_except_handler2 +_except_handler3 +_execl +_execle +_execlp +_execlpe +_execv +_execve +_execvp +_execvpe +_exit +_expand +_fcloseall +_fcvt +_fdopen +_fgetchar +_fgetwchar +_filbuf +_fileinfo DATA +_filelength +_filelengthi64 +_fileno +_findclose +_findfirst +_findfirsti64 +_findnext +_findnexti64 +_finite +_flsbuf +_flushall +_fmode DATA +_fpclass +_fpieee_flt +_fpreset +_fputchar +_fputwchar +_fsopen +_fstat +_fstati64 +_ftime +_ftol +_fullpath +_futime +_gcvt +_get_osfhandle +_get_sbh_threshold +_getch +_getche +_getcwd +_getdcwd +_getdiskfree +_getdllprocaddr +_getdrive +_getdrives +_getmaxstdio +_getmbcp +_getpid +_getsystime +_getw +_getws +_global_unwind2 +_heapadd +_heapchk +_heapmin +_heapset +_heapused +_heapwalk +_hypot +_i64toa +_i64tow +_initterm +_inp +_inpd +_inpw +_iob DATA +_isatty +_isctype +_ismbbalnum +_ismbbalpha +_ismbbgraph +_ismbbkalnum +_ismbbkana +_ismbbkprint +_ismbbkpunct +_ismbblead +_ismbbprint +_ismbbpunct +_ismbbtrail +_ismbcalnum +_ismbcalpha +_ismbcdigit +_ismbcgraph +_ismbchira +_ismbckata +_ismbcl0 +_ismbcl1 +_ismbcl2 +_ismbclegal +_ismbclower +_ismbcprint +_ismbcpunct +_ismbcspace +_ismbcsymbol +_ismbcupper +_ismbslead +_ismbstrail +_isnan +_itoa +_itow +_j0 +_j1 +_jn +_kbhit +_lfind +_loaddll +_local_unwind2 +_lock +_locking +_logb +_longjmpex +_lrotl +_lrotr +_lsearch +_lseek +_lseeki64 +_ltoa +_ltow +_makepath +_mbbtombc +_mbbtype +_mbccpy +_mbcjistojms +_mbcjmstojis +_mbclen +_mbctohira +_mbctokata +_mbctolower +_mbctombb +_mbctoupper +_mbctype DATA +_mbsbtype +_mbscat +_mbschr +_mbscmp +_mbscoll +_mbscpy +_mbscspn +_mbsdec +_mbsdup +_mbsicmp +_mbsicoll +_mbsinc +_mbslen +_mbslwr +_mbsnbcat +_mbsnbcmp +_mbsnbcnt +_mbsnbcoll +_mbsnbcpy +_mbsnbicmp +_mbsnbicoll +_mbsnbset +_mbsncat +_mbsnccnt +_mbsncmp +_mbsncoll +_mbsncpy +_mbsnextc +_mbsnicmp +_mbsnicoll +_mbsninc +_mbsnset +_mbspbrk +_mbsrchr +_mbsrev +_mbsset +_mbsspn +_mbsspnp +_mbsstr +_mbstok +_mbstrlen +_mbsupr +_memccpy +_memicmp +_mkdir +_mktemp +_msize +_nextafter +_onexit +_open +_open_osfhandle +_osver DATA +_outp +_outpd +_outpw +_pclose +_pctype DATA +_pgmptr DATA +_pipe +_popen +_purecall +_putch +_putenv +_putw +_putws +_pwctype DATA +_read +_rmdir +_rmtmp +_rotl +_rotr +_safe_fdiv +_safe_fdivr +_safe_fprem +_safe_fprem1 +_scalb +_searchenv +_seh_longjmp_unwind +_set_error_mode +_set_sbh_threshold +_seterrormode +_setjmp +_setjmp3 +_setmaxstdio +_setmbcp +_setmode +_setsystime +_sleep +_snprintf +_snwprintf +_sopen +_spawnl +_spawnle +_spawnlp +_spawnlpe +_spawnv +_spawnve +_spawnvp +_spawnvpe +_splitpath +_stat +_stati64 +_statusfp +_strcmpi +_strdate +_strdup +_strerror +_stricmp +_stricoll +_strlwr +_strncoll +_strnicmp +_strnicoll +_strnset +_strrev +_strset +_strtime +_strupr +_swab +_sys_errlist DATA +_sys_nerr DATA +_tell +_telli64 +_tempnam +_timezone DATA +_tolower +_toupper +_tzname DATA +_tzset +_ui64toa +_ui64tow +_ultoa +_ultow +_umask +_ungetch +_unlink +_unloaddll +_unlock +_utime +_vsnprintf +_vsnwprintf +_waccess +_wasctime +_wchdir +_wchmod +_wcmdln DATA +_wcreat +_wcsdup +_wcsicmp +_wcsicoll +_wcslwr +_wcsncoll +_wcsnicmp +_wcsnicoll +_wcsnset +_wcsrev +_wcsset +_wcsupr +_wctime +_wenviron DATA +_wexecl +_wexecle +_wexeclp +_wexeclpe +_wexecv +_wexecve +_wexecvp +_wexecvpe +_wfdopen +_wfindfirst +_wfindfirsti64 +_wfindnext +_wfindnexti64 +_wfopen +_wfreopen +_wfsopen +_wfullpath +_wgetcwd +_wgetdcwd +_wgetenv +_winmajor DATA +_winminor DATA +_winver DATA +_wmakepath +_wmkdir +_wmktemp +_wopen +_wperror +_wpgmptr DATA +_wpopen +_wputenv +_wremove +_wrename +_write +_wrmdir +_wsearchenv +_wsetlocale +_wsopen +_wspawnl +_wspawnle +_wspawnlp +_wspawnlpe +_wspawnv +_wspawnve +_wspawnvp +_wspawnvpe +_wsplitpath +_wstat +_wstati64 +_wstrdate +_wstrtime +_wsystem +_wtempnam +_wtmpnam +_wtoi +_wtoi64 +_wtol +_wunlink +_wutime +_y0 +_y1 +_yn +abort +abs +acos +asctime +asin +atan +atan2 +atexit +atof +atoi +atol +bsearch +calloc +ceil +clearerr +clock +cos +cosh +ctime +difftime +div +exit +exp +fabs +fclose +feof +ferror +fflush +fgetc +fgetpos +fgets +fgetwc +fgetws +floor +fmod +fopen +fprintf +fputc +fputs +fputwc +fputws +fread +free +freopen +frexp +fscanf +fseek +fsetpos +ftell +fwprintf +fwrite +fwscanf +getc +getchar +getenv +gets +getwc +getwchar +gmtime +is_wctype +isalnum +isalpha +iscntrl +isdigit +isgraph +isleadbyte +islower +isprint +ispunct +isspace +isupper +iswalnum +iswalpha +iswascii +iswcntrl +iswctype +iswdigit +iswgraph +iswlower +iswprint +iswpunct +iswspace +iswupper +iswxdigit +isxdigit +labs +ldexp +ldiv +localeconv +localtime +log +log10 +longjmp +malloc +mblen +mbstowcs +mbtowc +memchr +memcmp +memcpy +memmove +memset +mktime +modf +perror +pow +printf +putc +putchar +puts +putwc +putwchar +qsort +raise +rand +realloc +remove +rename +rewind +scanf +setbuf +setlocale +setvbuf +signal +sin +sinh +sprintf +sqrt +srand +sscanf +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strerror +strftime +strlen +strncat +strncmp +strncpy +strpbrk +strrchr +strspn +strstr +strtod +strtok +strtol +strtoul +strxfrm +swprintf +swscanf +system +tan +tanh +time +tmpfile +tmpnam +tolower +toupper +towlower +towupper +ungetc +ungetwc +vfprintf +vfwprintf +vprintf +vsprintf +vswprintf +vwprintf +wcscat +wcschr +wcscmp +wcscoll +wcscpy +wcscspn +wcsftime +wcslen +wcsncat +wcsncmp +wcsncpy +wcspbrk +wcsrchr +wcsspn +wcsstr +wcstod +wcstok +wcstol +wcstombs +wcstoul +wcsxfrm +wctomb +wprintf +wscanf + diff --git a/winsup/mingw/msvcrt20.def b/winsup/mingw/msvcrt20.def new file mode 100644 index 000000000..2f27ea04b --- /dev/null +++ b/winsup/mingw/msvcrt20.def @@ -0,0 +1,719 @@ +; +; msvcrt20.def +; +; Exports from msvcrt20.dll. I am hoping that msvcrt20.dll will be reasonably +; common on user systems (if not ubiquitous) so that, effectively, it can +; be considered part of the OS. Apparently it was included with the Windows 95 +; distribution, so it should be present there at least. +; +; NOTE: All exports, except for what appeared to be C++ mangled names, +; are included. Not all functions have prototypes in the headers +; (and some aren't functions at all). +; +; Contributors: +; Created by Colin Peters +; +; THIS SOFTWARE IS NOT COPYRIGHTED +; +; This source code is offered for use in the public domain. You may +; use, modify or distribute it freely. +; +; This code is distributed in the hope that it will be useful but +; WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY +; DISCLAMED. This includes but is not limited to warrenties of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. +; +; $Revision$ +; $Author$ +; $Date$ +; +EXPORTS +_CIacos +_CIasin +_CIatan +_CIatan2 +_CIcos +_CIcosh +_CIexp +_CIfmod +_CIlog +_CIlog10 +_CIpow +_CIsin +_CIsinh +_CIsqrt +_CItan +_CItanh +_CxxThrowException +_HUGE +_XcptFilter +__CxxFrameHandler +__CxxLongjmpUnwind +__STRINGTOLD +__argc +__argv +__dllonexit +__doserrno +__fpecode +__getmainargs +__initenv +__isascii +__iscsym +__iscsymf +__lconv_init +__mb_cur_max +__p___argc +__p___argv +__p___initenv +__p___mb_cur_max +__p___wargv +__p___winitenv +__p__acmdln +__p__amblksiz +__p__commode +__p__daylight +__p__environ +__p__fmode +__p__iob +__p__mbctype +__p__osver +__p__pctype +__p__pgmptr +__p__pwctype +__p__timezone +__p__tzname +__p__wcmdln +__p__wenviron +__p__winmajor +__p__winminor +__p__winver +__p__wpgmptr +__pxcptinfoptrs +__threadhandle +__threadid +__toascii +__wargv +__wgetmainargs +__winitenv +_abnormal_termination +_access +_acmdln +_adj_fdiv_m16i +_adj_fdiv_m32 +_adj_fdiv_m32i +_adj_fdiv_m64 +_adj_fdiv_r +_adj_fdivr_m16i +_adj_fdivr_m32 +_adj_fdivr_m32i +_adj_fdivr_m64 +_adj_fpatan +_adj_fprem +_adj_fprem1 +_adj_fptan +_adjust_fdiv +_aexit_rtn +_amsg_exit +_assert +_atodbl +_atoldbl +_beep +_beginthread +_beginthreadex +_c_exit +_cabs +_cexit +_cgets +_chdir +_chdrive +_chgsign +_chmod +_chsize +_clearfp +_close +_commit +_commode +_control87 +_controlfp +_copysign +_cprintf +_cputs +_creat +_cscanf +_ctype +_cwait +_daylight +_dup +_dup2 +_ecvt +_endthread +_endthreadex +_environ +_eof +_errno +_except_handler2 +_except_handler3 +_execl +_execle +_execlp +_execlpe +_execv +_execve +_execvp +_execvpe +_exit +_expand +_fcloseall +_fcvt +_fdopen +_fgetchar +_fgetwchar +_filbuf +_fileinfo +_filelength +_fileno +_findclose +_findfirst +_findnext +_finite +_flsbuf +_flushall +_fmode +_fpclass +_fpieee_flt +_fpreset +_fputchar +_fputwchar +_fsopen +_fstat +_ftime +_ftol +_fullpath +_futime +_gcvt +_get_osfhandle +_getch +_getche +_getcwd +_getdcwd +_getdiskfree +_getdllprocaddr +_getdrive +_getdrives +_getmbcp +_getpid +_getsystime +_getw +_getws +_global_unwind2 +_heapadd +_heapchk +_heapmin +_heapset +_heapused +_heapwalk +_hypot +_initterm +_iob +_isatty +_isctype +_ismbbalnum +_ismbbalpha +_ismbbgraph +_ismbbkalnum +_ismbbkana +_ismbbkprint +_ismbbkpunct +_ismbblead +_ismbbprint +_ismbbpunct +_ismbbtrail +_ismbcalnum +_ismbcalpha +_ismbcdigit +_ismbcgraph +_ismbchira +_ismbckata +_ismbcl0 +_ismbcl1 +_ismbcl2 +_ismbclegal +_ismbclower +_ismbcprint +_ismbcpunct +_ismbcspace +_ismbcsymbol +_ismbcupper +_ismbslead +_ismbstrail +_isnan +_itoa +_itow +_j0 +_j1 +_jn +_kbhit +_lfind +_loaddll +_local_unwind2 +_locking +_logb +_longjmpex +_lrotl +_lrotr +_lsearch +_lseek +_ltoa +_ltow +_makepath +_matherr +_mbbtombc +_mbbtype +_mbccpy +_mbcjistojms +_mbcjmstojis +_mbclen +_mbctohira +_mbctokata +_mbctolower +_mbctombb +_mbctoupper +_mbctype +_mbsbtype +_mbscat +_mbschr +_mbscmp +_mbscoll +_mbscpy +_mbscspn +_mbsdec +_mbsdup +_mbsicmp +_mbsicoll +_mbsinc +_mbslen +_mbslwr +_mbsnbcat +_mbsnbcmp +_mbsnbcnt +_mbsnbcoll +_mbsnbcpy +_mbsnbicmp +_mbsnbicoll +_mbsnbset +_mbsncat +_mbsnccnt +_mbsncmp +_mbsncoll +_mbsncpy +_mbsnextc +_mbsnicmp +_mbsnicoll +_mbsninc +_mbsnset +_mbspbrk +_mbsrchr +_mbsrev +_mbsset +_mbsspn +_mbsspnp +_mbsstr +_mbstok +_mbstrlen +_mbsupr +_memccpy +_memicmp +_mkdir +_mktemp +_msize +_mtlock +_mtunlock +_nextafter +_onexit +_open +_open_osfhandle +_osver +_pclose +_pctype +_pgmptr +_pipe +_popen +_purecall +_putch +_putenv +_putw +_putws +_pwctype +_read +_rmdir +_rmtmp +_rotl +_rotr +_safe_fdiv +_safe_fdivr +_safe_fprem +_safe_fprem1 +_scalb +_searchenv +__seh_longjmp_unwind@4 +_seterrormode +_setjmp +_setjmp3 +_setmbcp +_setmode +_setsystime +_sleep +_snprintf +_snwprintf +_sopen +_spawnl +_spawnle +_spawnlp +_spawnlpe +_spawnv +_spawnve +_spawnvp +_spawnvpe +_splitpath +_stat +_statusfp +_strcmpi +_strdate +_strdup +_strerror +_stricmp +_stricoll +_strlwr +_strncoll +_strnicmp +_strnicoll +_strnset +_strrev +_strset +_strtime +_strupr +_swab +_sys_errlist +_sys_nerr +_tccpy +_tclen +_tcschr +_tcsclen +_tcscmp +_tcscspn +_tcsdec +_tcsicmp +_tcsinc +_tcslwr +_tcsnbcnt +_tcsncat +_tcsnccat +_tcsnccmp +_tcsnccnt +_tcsnccpy +_tcsncicmp +_tcsncmp +_tcsncpy +_tcsncset +_tcsnextc +_tcsnicmp +_tcsninc +_tcsnset +_tcspbrk +_tcsrchr +_tcsrev +_tcsset +_tcsspn +_tcsspnp +_tcsstr +_tcstok +_tcsupr +_tell +_tempnam +_timezone +_tolower +_toupper +_tzname +_tzset +_ultoa +_ultow +_umask +_ungetch +_unlink +_unloaddll +_utime +_vsnprintf +_vsnwprintf +_waccess +_wasctime +_wchdir +_wchmod +_wcmdln +_wcreat +_wcsdup +_wcsicmp +_wcsicoll +_wcslwr +_wcsncoll +_wcsnicmp +_wcsnicoll +_wcsnset +_wcsrev +_wcsset +_wcsupr +_wctime +_wenviron +_wexecl +_wexecle +_wexeclp +_wexeclpe +_wexecv +_wexecve +_wexecvp +_wexecvpe +_wfdopen +_wfindfirst +_wfindnext +_wfopen +_wfreopen +_wfsopen +_wfullpath +_wgetcwd +_wgetdcwd +_wgetenv +_winmajor +_winminor +_winver +_wmakepath +_wmkdir +_wmktemp +_wopen +_wperror +_wpgmptr +_wpopen +_wputenv +_wremove +_wrename +_write +_wrmdir +_wsearchenv +_wsetlocale +_wsopen +_wspawnl +_wspawnle +_wspawnlp +_wspawnlpe +_wspawnv +_wspawnve +_wspawnvp +_wspawnvpe +_wsplitpath +_wstat +_wstrdate +_wstrtime +_wsystem +_wtempnam +_wtmpnam +_wtoi +_wtol +_wunlink +_wutime +_y0 +_y1 +_yn +abort +abs +acos +asctime +asin +atan +atan2 +atexit +atof +atoi +atol +bsearch +calloc +ceil +clearerr +clock +cos +cosh +ctime +difftime +div +exit +exp +fabs +fclose +feof +ferror +fflush +fgetc +fgetpos +fgets +fgetwc +fgetws +floor +fmod +fopen +fprintf +fputc +fputs +fputwc +fputws +fread +free +freopen +frexp +fscanf +fseek +fsetpos +ftell +fwprintf +fwrite +fwscanf +getc +getchar +getenv +gets +getwc +getwchar +gmtime +is_wctype +isalnum +isalpha +iscntrl +isdigit +isgraph +isleadbyte +islower +isprint +ispunct +isspace +isupper +iswalnum +iswalpha +iswascii +iswcntrl +iswctype +iswdigit +iswgraph +iswlower +iswprint +iswpunct +iswspace +iswupper +iswxdigit +isxdigit +labs +ldexp +ldiv +localeconv +localtime +log +log10 +longjmp +malloc +mblen +mbstowcs +mbtowc +memchr +memcmp +memcpy +memmove +memset +mktime +modf +perror +pow +printf +putc +putchar +puts +putwc +putwchar +qsort +raise +rand +realloc +remove +rename +rewind +scanf +setbuf +setlocale +setvbuf +signal +sin +sinh +sprintf +sqrt +srand +sscanf +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strerror +strftime +strlen +strncat +strncmp +strncpy +strpbrk +strrchr +strspn +strstr +strtod +strtok +strtol +strtoul +strxfrm +swprintf +swscanf +system +tan +tanh +time +tmpfile +tmpnam +tolower +toupper +towlower +towupper +ungetc +ungetwc +vfprintf +vfwprintf +vprintf +vsprintf +vswprintf +vwprintf +wcscat +wcschr +wcscmp +wcscoll +wcscpy +wcscspn +wcsftime +wcslen +wcsncat +wcsncmp +wcsncpy +wcspbrk +wcsrchr +wcsspn +wcsstr +wcstod +wcstok +wcstol +wcstombs +wcstoul +wcsxfrm +wctomb +wprintf +wscanf + diff --git a/winsup/mingw/msvcrt40.def b/winsup/mingw/msvcrt40.def new file mode 100644 index 000000000..7b1d2e84e --- /dev/null +++ b/winsup/mingw/msvcrt40.def @@ -0,0 +1,676 @@ +EXPORTS +$I10_OUTPUT +_CIacos +_CIasin +_CIatan +_CIatan2 +_CIcos +_CIcosh +_CIexp +_CIfmod +_CIlog +_CIlog10 +_CIpow +_CIsin +_CIsinh +_CIsqrt +_CItan +_CItanh +_CxxThrowException +_EH_prolog +_HUGE +_XcptFilter +__CxxFrameHandler +__CxxLongjmpUnwind +__RTCastToVoid +__RTDynamicCast +__RTtypeid +__STRINGTOLD +__argc +__argv +__dllonexit +__doserrno +__fpecode +__getmainargs +__initenv +__isascii +__iscsym +__iscsymf +__lconv_init +__mb_cur_max +__p___argc +__p___argv +__p___initenv +__p___mb_cur_max +__p___wargv +__p___winitenv +__p__acmdln +__p__amblksiz +__p__commode +__p__daylight +__p__environ +__p__fmode +__p__iob +__p__mbctype +__p__osver +__p__pctype +__p__pgmptr +__p__pwctype +__p__timezone +__p__tzname +__p__wcmdln +__p__wenviron +__p__winmajor +__p__winminor +__p__winver +__p__wpgmptr +__pxcptinfoptrs +__set_app_type +__setusermatherr +__threadhandle +__threadid +__toascii +__unDName +__wargv +__wgetmainargs +__winitenv +_abnormal_termination +_access +_acmdln +_adj_fdiv_m16i +_adj_fdiv_m32 +_adj_fdiv_m32i +_adj_fdiv_m64 +_adj_fdiv_r +_adj_fdivr_m16i +_adj_fdivr_m32 +_adj_fdivr_m32i +_adj_fdivr_m64 +_adj_fpatan +_adj_fprem +_adj_fprem1 +_adj_fptan +_adjust_fdiv +_aexit_rtn +_amsg_exit +_assert +_atodbl +_atoldbl +_beep +_beginthread +_beginthreadex +_c_exit +_cabs +_cexit +_cgets +_chdir +_chdrive +_chgsign +_chmod +_chsize +_clearfp +_close +_commit +_commode +_control87 +_controlfp +_copysign +_cprintf +_cputs +_creat +_cscanf +_ctype +_cwait +_daylight +_dup +_dup2 +_ecvt +_endthread +_endthreadex +_environ +_eof +_errno +_except_handler2 +_except_handler3 +_execl +_execle +_execlp +_execlpe +_execv +_execve +_execvp +_execvpe +_exit +_expand +_fcloseall +_fcvt +_fdopen +_fgetchar +_fgetwchar +_filbuf +_fileinfo +_filelength +_filelengthi64 +_fileno +_findclose +_findfirst +_findfirsti64 +_findnext +_findnexti64 +_finite +_flsbuf +_flushall +_fmode +_fpclass +_fpieee_flt +_fpreset +_fputchar +_fputwchar +_fsopen +_fstat +_fstati64 +_ftime +_ftol +_fullpath +_futime +_gcvt +_get_osfhandle +_getch +_getche +_getcwd +_getdcwd +_getdiskfree +_getdllprocaddr +_getdrive +_getdrives +_getmbcp +_getpid +_getsystime +_getw +_getws +_global_unwind2 +_heapadd +_heapchk +_heapmin +_heapset +_heapused +_heapwalk +_hypot +_initterm +_iob +_isatty +_isctype +_ismbbalnum +_ismbbalpha +_ismbbgraph +_ismbbkalnum +_ismbbkana +_ismbbkprint +_ismbbkpunct +_ismbblead +_ismbbprint +_ismbbpunct +_ismbbtrail +_ismbcalnum +_ismbcalpha +_ismbcdigit +_ismbcgraph +_ismbchira +_ismbckata +_ismbcl0 +_ismbcl1 +_ismbcl2 +_ismbclegal +_ismbclower +_ismbcprint +_ismbcpunct +_ismbcspace +_ismbcsymbol +_ismbcupper +_ismbslead +_ismbstrail +_isnan +_itoa +_itow +_j0 +_j1 +_jn +_kbhit +_lfind +_loaddll +_local_unwind2 +_locking +_logb +_longjmpex +_lrotl +_lrotr +_lsearch +_lseek +_lseeki64 +_ltoa +_ltow +_makepath +_mbbtombc +_mbbtype +_mbccpy +_mbcjistojms +_mbcjmstojis +_mbclen +_mbctohira +_mbctokata +_mbctolower +_mbctombb +_mbctoupper +_mbctype +_mbsbtype +_mbscat +_mbschr +_mbscmp +_mbscoll +_mbscpy +_mbscspn +_mbsdec +_mbsdup +_mbsicmp +_mbsicoll +_mbsinc +_mbslen +_mbslwr +_mbsnbcat +_mbsnbcmp +_mbsnbcnt +_mbsnbcoll +_mbsnbcpy +_mbsnbicmp +_mbsnbicoll +_mbsnbset +_mbsncat +_mbsnccnt +_mbsncmp +_mbsncoll +_mbsncpy +_mbsnextc +_mbsnicmp +_mbsnicoll +_mbsninc +_mbsnset +_mbspbrk +_mbsrchr +_mbsrev +_mbsset +_mbsspn +_mbsspnp +_mbsstr +_mbstok +_mbstrlen +_mbsupr +_memccpy +_memicmp +_mkdir +_mktemp +_msize +_mtlock +_mtunlock +_nextafter +_onexit +_open +_open_osfhandle +_osver +_pclose +_pctype +_pgmptr +_pipe +_popen +_purecall +_putch +_putenv +_putw +_putws +_pwctype +_read +_rmdir +_rmtmp +_rotl +_rotr +_safe_fdiv +_safe_fdivr +_safe_fprem +_safe_fprem1 +_scalb +_searchenv +_seh_longjmp_unwind +_set_error_mode +_seterrormode +_setjmp +_setjmp3 +_setmaxstdio +_setmbcp +_setmode +_setsystime +_sleep +_snprintf +_snwprintf +_sopen +_spawnl +_spawnle +_spawnlp +_spawnlpe +_spawnv +_spawnve +_spawnvp +_spawnvpe +_splitpath +_stat +_stati64 +_statusfp +_strcmpi +_strdate +_strdup +_strerror +_stricmp +_stricoll +_strlwr +_strncoll +_strnicmp +_strnicoll +_strnset +_strrev +_strset +_strtime +_strupr +_swab +_sys_errlist +_sys_nerr +_tell +_telli64 +_tempnam +_timezone +_tolower +_toupper +_tzname +_tzset +_ultoa +_ultow +_umask +_ungetch +_unlink +_unloaddll +_utime +_vsnprintf +_vsnwprintf +_waccess +_wasctime +_wchdir +_wchmod +_wcmdln +_wcreat +_wcsdup +_wcsicmp +_wcsicoll +_wcslwr +_wcsncoll +_wcsnicmp +_wcsnicoll +_wcsnset +_wcsrev +_wcsset +_wcsupr +_wctime +_wenviron +_wexecl +_wexecle +_wexeclp +_wexeclpe +_wexecv +_wexecve +_wexecvp +_wexecvpe +_wfdopen +_wfindfirst +_wfindfirsti64 +_wfindnext +_wfindnexti64 +_wfopen +_wfreopen +_wfsopen +_wfullpath +_wgetcwd +_wgetdcwd +_wgetenv +_winmajor +_winminor +_winver +_wmakepath +_wmkdir +_wmktemp +_wopen +_wperror +_wpgmptr +_wpopen +_wputenv +_wremove +_wrename +_write +_wrmdir +_wsearchenv +_wsetlocale +_wsopen +_wspawnl +_wspawnle +_wspawnlp +_wspawnlpe +_wspawnv +_wspawnve +_wspawnvp +_wspawnvpe +_wsplitpath +_wstat +_wstati64 +_wstrdate +_wstrtime +_wsystem +_wtempnam +_wtmpnam +_wtoi +_wtol +_wunlink +_wutime +_y0 +_y1 +_yn +abort +abs +acos +asctime +asin +atan +atan2 +atexit +atof +atoi +atol +bsearch +calloc +ceil +clearerr +clock +cos +cosh +ctime +difftime +div +exit +exp +fabs +fclose +feof +ferror +fflush +fgetc +fgetpos +fgets +fgetwc +fgetws +floor +fmod +fopen +fprintf +fputc +fputs +fputwc +fputws +fread +free +freopen +frexp +fscanf +fseek +fsetpos +ftell +fwprintf +fwrite +fwscanf +getc +getchar +getenv +gets +getwc +getwchar +gmtime +is_wctype +isalnum +isalpha +iscntrl +isdigit +isgraph +isleadbyte +islower +isprint +ispunct +isspace +isupper +iswalnum +iswalpha +iswascii +iswcntrl +iswctype +iswdigit +iswgraph +iswlower +iswprint +iswpunct +iswspace +iswupper +iswxdigit +isxdigit +labs +ldexp +ldiv +localeconv +localtime +log +log10 +longjmp +malloc +mblen +mbstowcs +mbtowc +memchr +memcmp +memcpy +memmove +memset +mktime +modf +perror +pow +printf +putc +putchar +puts +putwc +putwchar +qsort +raise +rand +realloc +remove +rename +rewind +scanf +setbuf +setlocale +setvbuf +signal +sin +sinh +sprintf +sqrt +srand +sscanf +strcat +strchr +strcmp +strcoll +strcpy +strcspn +strerror +strftime +strlen +strncat +strncmp +strncpy +strpbrk +strrchr +strspn +strstr +strtod +strtok +strtol +strtoul +strxfrm +swprintf +swscanf +system +tan +tanh +time +tmpfile +tmpnam +tolower +toupper +towlower +towupper +ungetc +ungetwc +vfprintf +vfwprintf +vprintf +vsprintf +vswprintf +vwprintf +wcscat +wcschr +wcscmp +wcscoll +wcscpy +wcscspn +wcsftime +wcslen +wcsncat +wcsncmp +wcsncpy +wcspbrk +wcsrchr +wcsspn +wcsstr +wcstod +wcstok +wcstol +wcstombs +wcstoul +wcsxfrm +wctomb +wprintf +wscanf + diff --git a/winsup/mingw/mthr.c b/winsup/mingw/mthr.c new file mode 100644 index 000000000..24855479a --- /dev/null +++ b/winsup/mingw/mthr.c @@ -0,0 +1,206 @@ +/* + * mthr.c + * + * Implement Mingw thread-support DLL . + * + * This file is used iff the following conditions are met: + * - gcc uses -mthreads option + * - user code uses C++ exceptions + * + * The sole job of the Mingw thread support DLL (MingwThr) is to catch + * all the dying threads and clean up the data allocated in the TLSs + * for exception contexts during C++ EH. Posix threads have key dtors, + * but win32 TLS keys do not, hence the magic. Without this, there's at + * least `6 * sizeof (void*)' bytes leaks for each catch/throw in each + * thread. The only public interface is __mingwthr_key_dtor(). + * + * Created by Mumit Khan + * + */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include + +/* To protect the thread/key association data structure modifications. */ +CRITICAL_SECTION __mingwthr_cs; + +typedef struct __mingwthr_thread __mingwthr_thread_t; +typedef struct __mingwthr_key __mingwthr_key_t; + +/* The list of threads active with key/dtor pairs. */ +struct __mingwthr_key { + DWORD key; + void (*dtor) (void *); + __mingwthr_key_t *next; +}; + +/* The list of key/dtor pairs for a particular thread. */ +struct __mingwthr_thread { + DWORD thread_id; + __mingwthr_key_t *keys; + __mingwthr_thread_t *next; +}; + +static __mingwthr_thread_t *__mingwthr_thread_list; + +/* + * __mingwthr_key_add: + * + * Add key/dtor association for this thread. If the thread entry does not + * exist, create a new one and add to the head of the threads list; add + * the new assoc at the head of the keys list. + * + */ + +static int +__mingwthr_add_key_dtor (DWORD thread_id, DWORD key, void (*dtor) (void *)) +{ + __mingwthr_thread_t *threadp; + __mingwthr_key_t *new_key; + + new_key = (__mingwthr_key_t *) calloc (1, sizeof (__mingwthr_key_t)); + if (new_key == NULL) + return -1; + + new_key->key = key; + new_key->dtor = dtor; + + /* This may be called by multiple threads, and so we need to protect + the whole process of adding the key/dtor pair. */ + EnterCriticalSection (&__mingwthr_cs); + + for (threadp = __mingwthr_thread_list; + threadp && (threadp->thread_id != thread_id); + threadp = threadp->next) + ; + + if (threadp == NULL) + { + threadp = (__mingwthr_thread_t *) + calloc (1, sizeof (__mingwthr_thread_t)); + if (threadp == NULL) + { + free (new_key); + LeaveCriticalSection (&__mingwthr_cs); + return -1; + } + threadp->thread_id = thread_id; + threadp->next = __mingwthr_thread_list; + __mingwthr_thread_list = threadp; + } + + new_key->next = threadp->keys; + threadp->keys = new_key; + + LeaveCriticalSection (&__mingwthr_cs); + +#ifdef DEBUG + printf ("%s: allocating: (%ld, %ld, %x)\n", + __FUNCTION__, thread_id, key, dtor); +#endif + + return 0; +} + +/* + * __mingwthr_run_key_dtors (DWORD thread_id): + * + * Callback from DllMain when thread detaches to clean up the key + * storage. + * + * Note that this does not delete the key itself, but just runs + * the dtor if the current value are both non-NULL. Note that the + * keys with NULL dtors are not added by __mingwthr_key_dtor, the + * only public interface, so we don't need to check. + * + */ + +void +__mingwthr_run_key_dtors (DWORD thread_id) +{ + __mingwthr_thread_t *prev_threadp, *threadp; + __mingwthr_key_t *keyp; + +#ifdef DEBUG + printf ("%s: Entering Thread id %ld\n", __FUNCTION__, thread_id); +#endif + + /* Since this is called just once per thread, we only need to protect + the part where we take out this thread's entry and reconfigure the + list instead of wrapping the whole process in a critical section. */ + EnterCriticalSection (&__mingwthr_cs); + + prev_threadp = NULL; + for (threadp = __mingwthr_thread_list; + threadp && (threadp->thread_id != thread_id); + prev_threadp = threadp, threadp = threadp->next) + ; + + if (threadp == NULL) + { + LeaveCriticalSection (&__mingwthr_cs); + return; + } + + /* take the damned thread out of the chain. */ + if (prev_threadp == NULL) /* first entry hit. */ + __mingwthr_thread_list = threadp->next; + else + prev_threadp->next = threadp->next; + + LeaveCriticalSection (&__mingwthr_cs); + + for (keyp = threadp->keys; keyp; ) + { + __mingwthr_key_t *prev_keyp; + LPVOID value = TlsGetValue (keyp->key); + if (GetLastError () == ERROR_SUCCESS) + { +#ifdef DEBUG + printf (" (%ld, %x)\n", keyp->key, keyp->dtor); +#endif + if (value) + (*keyp->dtor) (value); + } +#ifdef DEBUG + else + { + printf (" TlsGetValue FAILED (%ld, %x)\n", + keyp->key, keyp->dtor); + } +#endif + prev_keyp = keyp; + keyp = keyp->next; + free (prev_keyp); + } + + free (threadp); + +#ifdef DEBUG + printf ("%s: Exiting Thread id %ld\n", __FUNCTION__, thread_id); +#endif +} + +/* + * __mingwthr_register_key_dtor (DWORD key, void (*dtor) (void *)) + * + * Public interface called by C++ exception handling mechanism in + * libgcc (cf: __gthread_key_create). + * + */ + +__declspec(dllexport) +int +__mingwthr_key_dtor (DWORD key, void (*dtor) (void *)) +{ + if (dtor) + { + DWORD thread_id = GetCurrentThreadId (); + return __mingwthr_add_key_dtor (thread_id, key, dtor); + } + + return 0; +} + diff --git a/winsup/mingw/mthr_init.c b/winsup/mingw/mthr_init.c new file mode 100644 index 000000000..23f7966a0 --- /dev/null +++ b/winsup/mingw/mthr_init.c @@ -0,0 +1,76 @@ +/* + * mthr_init.c + * + * Do the thread-support DLL initialization. + * + * This file is used iff the following conditions are met: + * - gcc uses -mthreads option + * - user code uses C++ exceptions + * + * The sole job of the Mingw thread support DLL (MingwThr) is to catch + * all the dying threads and clean up the data allocated in the TLSs + * for exception contexts during C++ EH. Posix threads have key dtors, + * but win32 TLS keys do not, hence the magic. Without this, there's at + * least `24 * sizeof (void*)' bytes leaks for each catch/throw in each + * thread. + * + * See mthr.c for all the magic. + * + * Created by Mumit Khan + * + */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include + +BOOL APIENTRY DllMain (HANDLE hDllHandle, DWORD reason, + LPVOID reserved /* Not used. */ ); + +/* + *---------------------------------------------------------------------- + * + * DllMain -- + * + * This routine is called by the Mingw32, Cygwin32 or VC++ C run + * time library init code, or the Borland DllEntryPoint routine. It + * is responsible for initializing various dynamically loaded + * libraries. + * + * Results: + * TRUE on sucess, FALSE on failure. + * + * Side effects: + * + *---------------------------------------------------------------------- + */ +BOOL APIENTRY +DllMain (HANDLE hDllHandle /* Library instance handle. */, + DWORD reason /* Reason this function is being called. */, + LPVOID reserved /* Not used. */) +{ + + extern CRITICAL_SECTION __mingwthr_cs; + extern void __mingwthr_run_key_dtors (DWORD); + + switch (reason) + { + case DLL_PROCESS_ATTACH: + InitializeCriticalSection (&__mingwthr_cs); + break; + + case DLL_PROCESS_DETACH: + DeleteCriticalSection (&__mingwthr_cs); + break; + + case DLL_THREAD_ATTACH: + break; + + case DLL_THREAD_DETACH: + __mingwthr_run_key_dtors (GetCurrentThreadId ()); + break; + } + return TRUE; +} + diff --git a/winsup/mingw/mthr_stub.c b/winsup/mingw/mthr_stub.c new file mode 100644 index 000000000..b2d219c9e --- /dev/null +++ b/winsup/mingw/mthr_stub.c @@ -0,0 +1,37 @@ +/* + * mthr_stub.c + * + * Implement Mingw thread-support stubs for single-threaded C++ apps. + * + * This file is used by if gcc is built with --enable-threads=win32 and + * iff gcc does *NOT* use -mthreads option. + * + * The -mthreads implementation is in mthr.c. + * + * Created by Mumit Khan + * + */ + +#define WIN32_LEAN_AND_MEAN +#include +#undef WIN32_LEAN_AND_MEAN +#include + +/* + * __mingwthr_register_key_dtor (DWORD key, void (*dtor) (void *)) + * + * Public interface called by C++ exception handling mechanism in + * libgcc (cf: __gthread_key_create). + * + * THIS SHOULD NEVER BE CALLED! + * + */ + +int +__mingwthr_key_dtor (DWORD key, void (*dtor) (void *)) +{ + assert (0); + /* NOTREACHED */ + return 0; +} + diff --git a/winsup/mingw/profile/Makefile.in b/winsup/mingw/profile/Makefile.in new file mode 100644 index 000000000..4359aa82d --- /dev/null +++ b/winsup/mingw/profile/Makefile.in @@ -0,0 +1,119 @@ +# +# mingw/profile/Makefile.in: This file is part of Mingw runtime. +# +# This makefile requires GNU make. + +VPATH = @srcdir@ +srcdir = @srcdir@ +objdir = . + +target_alias = @target_alias@ +prefix = @prefix@ + +program_transform_name = @program_transform_name@ +exec_prefix = @exec_prefix@ +bindir = @bindir@ +libdir = @libdir@ +tooldir = $(exec_prefix)/$(target_alias) +datadir = @datadir@ +infodir = @infodir@ +includedir = @includedir@ + +SHELL = /bin/sh + +INSTALL = @INSTALL@ +INSTALL_DATA = @INSTALL_DATA@ +INSTALL_PROGRAM = @INSTALL_PROGRAM@ +mkinstalldirs = $(SHELL) $(srcdir)/../../mkinstalldirs + +CC = @CC@ +# FIXME: Which is it, CC or CC_FOR_TARGET? +CC_FOR_TARGET = $(CC) +AS_FOR_TARGET = $(AS) +CFLAGS = @CFLAGS@ +CXXFLAGS = @CXXFLAGS@ + +# compiling with Cygwin? +MNO_CYGWIN = @MNO_CYGWIN@ + +# Either crtdll (CRT_ID 1) or msvcrt (CRT_ID 2). +RUNTIME = @RUNTIME@ +CRT_ID = @CRT_ID@ + +# Needed for threading dll. +THREAD_DLL = @THREAD_DLL@ +THREAD_DLL_VERSION = 10 +THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll + +INCLUDES = -I$(srcdir) -I$(srcdir)/../include \ + -I$(srcdir)/../../w32api/include \ + -nostdinc -nostdinc++ +ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(MNO_CYGWIN) +ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) $(MNO_CYGWIN) + +AS = @AS@ +AR = @AR@ +LD = @LD@ +AR_FLAGS = rcv +RANLIB = @RANLIB@ +DLLTOOL = @DLLTOOL@ +DLLTOOLFLAGS = +DLLTOOL_FOR_TARGET = $(DLLTOOL) +DLLTOOL_FLAGS = --as $(AS_FOR_TARGET) + +LIBGMON_A = @LIBGMON_A@ +LIBGMON_OBJS = gmon.o mcount.o profil.o +CRT0S = gcrt$(CRT_ID).o + +LIBS = $(LIBGMON_A) +DLLS = + +all: $(LIBGMON_A) + +$(LIBGMON_A): $(LIBGMON_OBJS) $(CRT0S) + $(AR) $(ARFLAGS) $@ $(LIBGMON_OBJS) + $(RANLIB) $@ + +gcrt1.o: gcrt0.c + $(CC) -U__MSVCRT__ -c -o $@ $(CPPFLAGS) $(CFLAGS) $? + +gcrt2.o: gcrt0.c + $(CC) -D__MSVCRT__ -c -o $@ $(CPPFLAGS) $(CFLAGS) $? + +Makefile: Makefile.in config.status configure + $(SHELL) config.status + +config.status: configure + $(SHELL) config.status --recheck + +info: + +info-html: + +install-info: info + +install: all + $(mkinstalldirs) $(tooldir)/lib + for i in $(LIBS); do \ + $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + done + for i in $(CRT0S); do \ + $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + done + for sub in . ; do \ + $(mkinstalldirs) $(tooldir)/include/$$sub ; \ + for i in $(srcdir)/$$sub/*.h ; do \ + $(INSTALL_DATA) $$i $(tooldir)/include/$$sub/`basename $$i` ; \ + done ; \ + done + +clean: + -rm -f $(LIBGMON_OBJS) $(CRT0S) $(LIBGMON_A) + +distclean: + -rm -f *.o *.a *~ core a.out + -rm -f config.cache config.status config.log + -rm -f Makefile +.c.o: + $(CC) -c $(ALL_CPPFLAGS) $(ALL_CFLAGS) $< -o $@ + diff --git a/winsup/mingw/profile/configure b/winsup/mingw/profile/configure new file mode 100755 index 000000000..7d5b92b22 --- /dev/null +++ b/winsup/mingw/profile/configure @@ -0,0 +1,1037 @@ +#! /bin/sh + +# Guess values for system-dependent variables and create Makefiles. +# Generated automatically using autoconf version 2.13 +# Copyright (C) 1992, 93, 94, 95, 96 Free Software Foundation, Inc. +# +# This configure script is free software; the Free Software Foundation +# gives unlimited permission to copy, distribute and modify it. + +# Defaults: +ac_help= +ac_default_prefix=/usr/local +# Any additions from configure.in: + +# Initialize some variables set by options. +# The variables have the same names as the options, with +# dashes changed to underlines. +build=NONE +cache_file=./config.cache +exec_prefix=NONE +host=NONE +no_create= +nonopt=NONE +no_recursion= +prefix=NONE +program_prefix=NONE +program_suffix=NONE +program_transform_name=s,x,x, +silent= +site= +srcdir= +target=NONE +verbose= +x_includes=NONE +x_libraries=NONE +bindir='${exec_prefix}/bin' +sbindir='${exec_prefix}/sbin' +libexecdir='${exec_prefix}/libexec' +datadir='${prefix}/share' +sysconfdir='${prefix}/etc' +sharedstatedir='${prefix}/com' +localstatedir='${prefix}/var' +libdir='${exec_prefix}/lib' +includedir='${prefix}/include' +oldincludedir='/usr/include' +infodir='${prefix}/info' +mandir='${prefix}/man' + +# Initialize some other variables. +subdirs= +MFLAGS= MAKEFLAGS= +SHELL=${CONFIG_SHELL-/bin/sh} +# Maximum number of lines to put in a shell here document. +ac_max_here_lines=12 + +ac_prev= +for ac_option +do + + # If the previous option needs an argument, assign it. + if test -n "$ac_prev"; then + eval "$ac_prev=\$ac_option" + ac_prev= + continue + fi + + case "$ac_option" in + -*=*) ac_optarg=`echo "$ac_option" | sed 's/[-_a-zA-Z0-9]*=//'` ;; + *) ac_optarg= ;; + esac + + # Accept the important Cygnus configure options, so we can diagnose typos. + + case "$ac_option" in + + -bindir | --bindir | --bindi | --bind | --bin | --bi) + ac_prev=bindir ;; + -bindir=* | --bindir=* | --bindi=* | --bind=* | --bin=* | --bi=*) + bindir="$ac_optarg" ;; + + -build | --build | --buil | --bui | --bu) + ac_prev=build ;; + -build=* | --build=* | --buil=* | --bui=* | --bu=*) + build="$ac_optarg" ;; + + -cache-file | --cache-file | --cache-fil | --cache-fi \ + | --cache-f | --cache- | --cache | --cach | --cac | --ca | --c) + ac_prev=cache_file ;; + -cache-file=* | --cache-file=* | --cache-fil=* | --cache-fi=* \ + | --cache-f=* | --cache-=* | --cache=* | --cach=* | --cac=* | --ca=* | --c=*) + cache_file="$ac_optarg" ;; + + -datadir | --datadir | --datadi | --datad | --data | --dat | --da) + ac_prev=datadir ;; + -datadir=* | --datadir=* | --datadi=* | --datad=* | --data=* | --dat=* \ + | --da=*) + datadir="$ac_optarg" ;; + + -disable-* | --disable-*) + ac_feature=`echo $ac_option|sed -e 's/-*disable-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + eval "enable_${ac_feature}=no" ;; + + -enable-* | --enable-*) + ac_feature=`echo $ac_option|sed -e 's/-*enable-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_feature| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_feature: invalid feature name" 1>&2; exit 1; } + fi + ac_feature=`echo $ac_feature| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "enable_${ac_feature}='$ac_optarg'" ;; + + -exec-prefix | --exec_prefix | --exec-prefix | --exec-prefi \ + | --exec-pref | --exec-pre | --exec-pr | --exec-p | --exec- \ + | --exec | --exe | --ex) + ac_prev=exec_prefix ;; + -exec-prefix=* | --exec_prefix=* | --exec-prefix=* | --exec-prefi=* \ + | --exec-pref=* | --exec-pre=* | --exec-pr=* | --exec-p=* | --exec-=* \ + | --exec=* | --exe=* | --ex=*) + exec_prefix="$ac_optarg" ;; + + -gas | --gas | --ga | --g) + # Obsolete; use --with-gas. + with_gas=yes ;; + + -help | --help | --hel | --he) + # Omit some internal or obsolete options to make the list less imposing. + # This message is too long to be a string in the A/UX 3.1 sh. + cat << EOF +Usage: configure [options] [host] +Options: [defaults in brackets after descriptions] +Configuration: + --cache-file=FILE cache test results in FILE + --help print this message + --no-create do not create output files + --quiet, --silent do not print \`checking...' messages + --version print the version of autoconf that created configure +Directory and file names: + --prefix=PREFIX install architecture-independent files in PREFIX + [$ac_default_prefix] + --exec-prefix=EPREFIX install architecture-dependent files in EPREFIX + [same as prefix] + --bindir=DIR user executables in DIR [EPREFIX/bin] + --sbindir=DIR system admin executables in DIR [EPREFIX/sbin] + --libexecdir=DIR program executables in DIR [EPREFIX/libexec] + --datadir=DIR read-only architecture-independent data in DIR + [PREFIX/share] + --sysconfdir=DIR read-only single-machine data in DIR [PREFIX/etc] + --sharedstatedir=DIR modifiable architecture-independent data in DIR + [PREFIX/com] + --localstatedir=DIR modifiable single-machine data in DIR [PREFIX/var] + --libdir=DIR object code libraries in DIR [EPREFIX/lib] + --includedir=DIR C header files in DIR [PREFIX/include] + --oldincludedir=DIR C header files for non-gcc in DIR [/usr/include] + --infodir=DIR info documentation in DIR [PREFIX/info] + --mandir=DIR man documentation in DIR [PREFIX/man] + --srcdir=DIR find the sources in DIR [configure dir or ..] + --program-prefix=PREFIX prepend PREFIX to installed program names + --program-suffix=SUFFIX append SUFFIX to installed program names + --program-transform-name=PROGRAM + run sed PROGRAM on installed program names +EOF + cat << EOF +Host type: + --build=BUILD configure for building on BUILD [BUILD=HOST] + --host=HOST configure for HOST [guessed] + --target=TARGET configure for TARGET [TARGET=HOST] +Features and packages: + --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no) + --enable-FEATURE[=ARG] include FEATURE [ARG=yes] + --with-PACKAGE[=ARG] use PACKAGE [ARG=yes] + --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no) + --x-includes=DIR X include files are in DIR + --x-libraries=DIR X library files are in DIR +EOF + if test -n "$ac_help"; then + echo "--enable and --with options recognized:$ac_help" + fi + exit 0 ;; + + -host | --host | --hos | --ho) + ac_prev=host ;; + -host=* | --host=* | --hos=* | --ho=*) + host="$ac_optarg" ;; + + -includedir | --includedir | --includedi | --included | --include \ + | --includ | --inclu | --incl | --inc) + ac_prev=includedir ;; + -includedir=* | --includedir=* | --includedi=* | --included=* | --include=* \ + | --includ=* | --inclu=* | --incl=* | --inc=*) + includedir="$ac_optarg" ;; + + -infodir | --infodir | --infodi | --infod | --info | --inf) + ac_prev=infodir ;; + -infodir=* | --infodir=* | --infodi=* | --infod=* | --info=* | --inf=*) + infodir="$ac_optarg" ;; + + -libdir | --libdir | --libdi | --libd) + ac_prev=libdir ;; + -libdir=* | --libdir=* | --libdi=* | --libd=*) + libdir="$ac_optarg" ;; + + -libexecdir | --libexecdir | --libexecdi | --libexecd | --libexec \ + | --libexe | --libex | --libe) + ac_prev=libexecdir ;; + -libexecdir=* | --libexecdir=* | --libexecdi=* | --libexecd=* | --libexec=* \ + | --libexe=* | --libex=* | --libe=*) + libexecdir="$ac_optarg" ;; + + -localstatedir | --localstatedir | --localstatedi | --localstated \ + | --localstate | --localstat | --localsta | --localst \ + | --locals | --local | --loca | --loc | --lo) + ac_prev=localstatedir ;; + -localstatedir=* | --localstatedir=* | --localstatedi=* | --localstated=* \ + | --localstate=* | --localstat=* | --localsta=* | --localst=* \ + | --locals=* | --local=* | --loca=* | --loc=* | --lo=*) + localstatedir="$ac_optarg" ;; + + -mandir | --mandir | --mandi | --mand | --man | --ma | --m) + ac_prev=mandir ;; + -mandir=* | --mandir=* | --mandi=* | --mand=* | --man=* | --ma=* | --m=*) + mandir="$ac_optarg" ;; + + -nfp | --nfp | --nf) + # Obsolete; use --without-fp. + with_fp=no ;; + + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) + no_create=yes ;; + + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) + no_recursion=yes ;; + + -oldincludedir | --oldincludedir | --oldincludedi | --oldincluded \ + | --oldinclude | --oldinclud | --oldinclu | --oldincl | --oldinc \ + | --oldin | --oldi | --old | --ol | --o) + ac_prev=oldincludedir ;; + -oldincludedir=* | --oldincludedir=* | --oldincludedi=* | --oldincluded=* \ + | --oldinclude=* | --oldinclud=* | --oldinclu=* | --oldincl=* | --oldinc=* \ + | --oldin=* | --oldi=* | --old=* | --ol=* | --o=*) + oldincludedir="$ac_optarg" ;; + + -prefix | --prefix | --prefi | --pref | --pre | --pr | --p) + ac_prev=prefix ;; + -prefix=* | --prefix=* | --prefi=* | --pref=* | --pre=* | --pr=* | --p=*) + prefix="$ac_optarg" ;; + + -program-prefix | --program-prefix | --program-prefi | --program-pref \ + | --program-pre | --program-pr | --program-p) + ac_prev=program_prefix ;; + -program-prefix=* | --program-prefix=* | --program-prefi=* \ + | --program-pref=* | --program-pre=* | --program-pr=* | --program-p=*) + program_prefix="$ac_optarg" ;; + + -program-suffix | --program-suffix | --program-suffi | --program-suff \ + | --program-suf | --program-su | --program-s) + ac_prev=program_suffix ;; + -program-suffix=* | --program-suffix=* | --program-suffi=* \ + | --program-suff=* | --program-suf=* | --program-su=* | --program-s=*) + program_suffix="$ac_optarg" ;; + + -program-transform-name | --program-transform-name \ + | --program-transform-nam | --program-transform-na \ + | --program-transform-n | --program-transform- \ + | --program-transform | --program-transfor \ + | --program-transfo | --program-transf \ + | --program-trans | --program-tran \ + | --progr-tra | --program-tr | --program-t) + ac_prev=program_transform_name ;; + -program-transform-name=* | --program-transform-name=* \ + | --program-transform-nam=* | --program-transform-na=* \ + | --program-transform-n=* | --program-transform-=* \ + | --program-transform=* | --program-transfor=* \ + | --program-transfo=* | --program-transf=* \ + | --program-trans=* | --program-tran=* \ + | --progr-tra=* | --program-tr=* | --program-t=*) + program_transform_name="$ac_optarg" ;; + + -q | -quiet | --quiet | --quie | --qui | --qu | --q \ + | -silent | --silent | --silen | --sile | --sil) + silent=yes ;; + + -sbindir | --sbindir | --sbindi | --sbind | --sbin | --sbi | --sb) + ac_prev=sbindir ;; + -sbindir=* | --sbindir=* | --sbindi=* | --sbind=* | --sbin=* \ + | --sbi=* | --sb=*) + sbindir="$ac_optarg" ;; + + -sharedstatedir | --sharedstatedir | --sharedstatedi \ + | --sharedstated | --sharedstate | --sharedstat | --sharedsta \ + | --sharedst | --shareds | --shared | --share | --shar \ + | --sha | --sh) + ac_prev=sharedstatedir ;; + -sharedstatedir=* | --sharedstatedir=* | --sharedstatedi=* \ + | --sharedstated=* | --sharedstate=* | --sharedstat=* | --sharedsta=* \ + | --sharedst=* | --shareds=* | --shared=* | --share=* | --shar=* \ + | --sha=* | --sh=*) + sharedstatedir="$ac_optarg" ;; + + -site | --site | --sit) + ac_prev=site ;; + -site=* | --site=* | --sit=*) + site="$ac_optarg" ;; + + -srcdir | --srcdir | --srcdi | --srcd | --src | --sr) + ac_prev=srcdir ;; + -srcdir=* | --srcdir=* | --srcdi=* | --srcd=* | --src=* | --sr=*) + srcdir="$ac_optarg" ;; + + -sysconfdir | --sysconfdir | --sysconfdi | --sysconfd | --sysconf \ + | --syscon | --sysco | --sysc | --sys | --sy) + ac_prev=sysconfdir ;; + -sysconfdir=* | --sysconfdir=* | --sysconfdi=* | --sysconfd=* | --sysconf=* \ + | --syscon=* | --sysco=* | --sysc=* | --sys=* | --sy=*) + sysconfdir="$ac_optarg" ;; + + -target | --target | --targe | --targ | --tar | --ta | --t) + ac_prev=target ;; + -target=* | --target=* | --targe=* | --targ=* | --tar=* | --ta=* | --t=*) + target="$ac_optarg" ;; + + -v | -verbose | --verbose | --verbos | --verbo | --verb) + verbose=yes ;; + + -version | --version | --versio | --versi | --vers) + echo "configure generated by autoconf version 2.13" + exit 0 ;; + + -with-* | --with-*) + ac_package=`echo $ac_option|sed -e 's/-*with-//' -e 's/=.*//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-_a-zA-Z0-9]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + case "$ac_option" in + *=*) ;; + *) ac_optarg=yes ;; + esac + eval "with_${ac_package}='$ac_optarg'" ;; + + -without-* | --without-*) + ac_package=`echo $ac_option|sed -e 's/-*without-//'` + # Reject names that are not valid shell variable names. + if test -n "`echo $ac_package| sed 's/[-a-zA-Z0-9_]//g'`"; then + { echo "configure: error: $ac_package: invalid package name" 1>&2; exit 1; } + fi + ac_package=`echo $ac_package| sed 's/-/_/g'` + eval "with_${ac_package}=no" ;; + + --x) + # Obsolete; use --with-x. + with_x=yes ;; + + -x-includes | --x-includes | --x-include | --x-includ | --x-inclu \ + | --x-incl | --x-inc | --x-in | --x-i) + ac_prev=x_includes ;; + -x-includes=* | --x-includes=* | --x-include=* | --x-includ=* | --x-inclu=* \ + | --x-incl=* | --x-inc=* | --x-in=* | --x-i=*) + x_includes="$ac_optarg" ;; + + -x-libraries | --x-libraries | --x-librarie | --x-librari \ + | --x-librar | --x-libra | --x-libr | --x-lib | --x-li | --x-l) + ac_prev=x_libraries ;; + -x-libraries=* | --x-libraries=* | --x-librarie=* | --x-librari=* \ + | --x-librar=* | --x-libra=* | --x-libr=* | --x-lib=* | --x-li=* | --x-l=*) + x_libraries="$ac_optarg" ;; + + -*) { echo "configure: error: $ac_option: invalid option; use --help to show usage" 1>&2; exit 1; } + ;; + + *) + if test -n "`echo $ac_option| sed 's/[-a-z0-9.]//g'`"; then + echo "configure: warning: $ac_option: invalid host type" 1>&2 + fi + if test "x$nonopt" != xNONE; then + { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } + fi + nonopt="$ac_option" + ;; + + esac +done + +if test -n "$ac_prev"; then + { echo "configure: error: missing argument to --`echo $ac_prev | sed 's/_/-/g'`" 1>&2; exit 1; } +fi + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +# File descriptor usage: +# 0 standard input +# 1 file creation +# 2 errors and warnings +# 3 some systems may open it to /dev/tty +# 4 used on the Kubota Titan +# 6 checking for... messages and results +# 5 compiler messages saved in config.log +if test "$silent" = yes; then + exec 6>/dev/null +else + exec 6>&1 +fi +exec 5>./config.log + +echo "\ +This file contains any messages produced by compilers while +running configure, to aid debugging if configure makes a mistake. +" 1>&5 + +# Strip out --no-create and --no-recursion so they do not pile up. +# Also quote any args containing shell metacharacters. +ac_configure_args= +for ac_arg +do + case "$ac_arg" in + -no-create | --no-create | --no-creat | --no-crea | --no-cre \ + | --no-cr | --no-c) ;; + -no-recursion | --no-recursion | --no-recursio | --no-recursi \ + | --no-recurs | --no-recur | --no-recu | --no-rec | --no-re | --no-r) ;; + *" "*|*" "*|*[\[\]\~\#\$\^\&\*\(\)\{\}\\\|\;\<\>\?]*) + ac_configure_args="$ac_configure_args '$ac_arg'" ;; + *) ac_configure_args="$ac_configure_args $ac_arg" ;; + esac +done + +# NLS nuisances. +# Only set these to C if already set. These must not be set unconditionally +# because not all systems understand e.g. LANG=C (notably SCO). +# Fixing LC_MESSAGES prevents Solaris sh from translating var values in `set'! +# Non-C LC_CTYPE values break the ctype check. +if test "${LANG+set}" = set; then LANG=C; export LANG; fi +if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi +if test "${LC_MESSAGES+set}" = set; then LC_MESSAGES=C; export LC_MESSAGES; fi +if test "${LC_CTYPE+set}" = set; then LC_CTYPE=C; export LC_CTYPE; fi + +# confdefs.h avoids OS command line length limits that DEFS can exceed. +rm -rf conftest* confdefs.h +# AIX cpp loses on an empty file, so make sure it contains at least a newline. +echo > confdefs.h + +# A filename unique to this package, relative to the directory that +# configure is in, which we can look for to find out if srcdir is correct. +ac_unique_file=gcrt0.c + +# Find the source files, if location was not specified. +if test -z "$srcdir"; then + ac_srcdir_defaulted=yes + # Try the directory containing this script, then its parent. + ac_prog=$0 + ac_confdir=`echo $ac_prog|sed 's%/[^/][^/]*$%%'` + test "x$ac_confdir" = "x$ac_prog" && ac_confdir=. + srcdir=$ac_confdir + if test ! -r $srcdir/$ac_unique_file; then + srcdir=.. + fi +else + ac_srcdir_defaulted=no +fi +if test ! -r $srcdir/$ac_unique_file; then + if test "$ac_srcdir_defaulted" = yes; then + { echo "configure: error: can not find sources in $ac_confdir or .." 1>&2; exit 1; } + else + { echo "configure: error: can not find sources in $srcdir" 1>&2; exit 1; } + fi +fi +srcdir=`echo "${srcdir}" | sed 's%\([^/]\)/*$%\1%'` + +# Prefer explicitly selected file to automatically selected ones. +if test -z "$CONFIG_SITE"; then + if test "x$prefix" != xNONE; then + CONFIG_SITE="$prefix/share/config.site $prefix/etc/config.site" + else + CONFIG_SITE="$ac_default_prefix/share/config.site $ac_default_prefix/etc/config.site" + fi +fi +for ac_site_file in $CONFIG_SITE; do + if test -r "$ac_site_file"; then + echo "loading site script $ac_site_file" + . "$ac_site_file" + fi +done + +if test -r "$cache_file"; then + echo "loading cache $cache_file" + . $cache_file +else + echo "creating cache $cache_file" + > $cache_file +fi + +ac_ext=c +# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options. +ac_cpp='$CPP $CPPFLAGS' +ac_compile='${CC-cc} -c $CFLAGS $CPPFLAGS conftest.$ac_ext 1>&5' +ac_link='${CC-cc} -o conftest${ac_exeext} $CFLAGS $CPPFLAGS $LDFLAGS conftest.$ac_ext $LIBS 1>&5' +cross_compiling=$ac_cv_prog_cc_cross + +ac_exeext= +ac_objext=o +if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi + + + +CC=${CC-cc} + +AS=${AS-as} + +AR=${AR-ar} + +LD=${LD-ld} + +RANLIB=${RANLIB-ranlib} + +DLLTOOL=${DLLTOOL-dlltool} + +DLLWRAP=${DLLWRAP-dllwrap} + +ac_aux_dir= +for ac_dir in $srcdir $srcdir/.. $srcdir/../..; do + if test -f $ac_dir/install-sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install-sh -c" + break + elif test -f $ac_dir/install.sh; then + ac_aux_dir=$ac_dir + ac_install_sh="$ac_aux_dir/install.sh -c" + break + fi +done +if test -z "$ac_aux_dir"; then + { echo "configure: error: can not find install-sh or install.sh in $srcdir $srcdir/.. $srcdir/../.." 1>&2; exit 1; } +fi +ac_config_guess=$ac_aux_dir/config.guess +ac_config_sub=$ac_aux_dir/config.sub +ac_configure=$ac_aux_dir/configure # This should be Cygnus configure. + + +# Do some error checking and defaulting for the host and target type. +# The inputs are: +# configure --host=HOST --target=TARGET --build=BUILD NONOPT +# +# The rules are: +# 1. You are not allowed to specify --host, --target, and nonopt at the +# same time. +# 2. Host defaults to nonopt. +# 3. If nonopt is not specified, then host defaults to the current host, +# as determined by config.guess. +# 4. Target and build default to nonopt. +# 5. If nonopt is not specified, then target and build default to host. + +# The aliases save the names the user supplied, while $host etc. +# will get canonicalized. +case $host---$target---$nonopt in +NONE---*---* | *---NONE---* | *---*---NONE) ;; +*) { echo "configure: error: can only configure for one host and one target at a time" 1>&2; exit 1; } ;; +esac + + +# Make sure we can run config.sub. +if ${CONFIG_SHELL-/bin/sh} $ac_config_sub sun4 >/dev/null 2>&1; then : +else { echo "configure: error: can not run $ac_config_sub" 1>&2; exit 1; } +fi + +echo $ac_n "checking host system type""... $ac_c" 1>&6 +echo "configure:587: checking host system type" >&5 + +host_alias=$host +case "$host_alias" in +NONE) + case $nonopt in + NONE) + if host_alias=`${CONFIG_SHELL-/bin/sh} $ac_config_guess`; then : + else { echo "configure: error: can not guess host type; you must specify one" 1>&2; exit 1; } + fi ;; + *) host_alias=$nonopt ;; + esac ;; +esac + +host=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $host_alias` +host_cpu=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +host_vendor=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +host_os=`echo $host | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$host" 1>&6 + +echo $ac_n "checking target system type""... $ac_c" 1>&6 +echo "configure:608: checking target system type" >&5 + +target_alias=$target +case "$target_alias" in +NONE) + case $nonopt in + NONE) target_alias=$host_alias ;; + *) target_alias=$nonopt ;; + esac ;; +esac + +target=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $target_alias` +target_cpu=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +target_vendor=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +target_os=`echo $target | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$target" 1>&6 + +echo $ac_n "checking build system type""... $ac_c" 1>&6 +echo "configure:626: checking build system type" >&5 + +build_alias=$build +case "$build_alias" in +NONE) + case $nonopt in + NONE) build_alias=$host_alias ;; + *) build_alias=$nonopt ;; + esac ;; +esac + +build=`${CONFIG_SHELL-/bin/sh} $ac_config_sub $build_alias` +build_cpu=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\1/'` +build_vendor=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\2/'` +build_os=`echo $build | sed 's/^\([^-]*\)-\([^-]*\)-\(.*\)$/\3/'` +echo "$ac_t""$build" 1>&6 + +test "$host_alias" != "$target_alias" && + test "$program_prefix$program_suffix$program_transform_name" = \ + NONENONEs,x,x, && + program_prefix=${target_alias}- + + +case "$target_os" in +*mingw32msvc*) + CRT_ID=2 + MNO_CYGWIN= + RUNTIME=msvcrt + THREAD_DLL=mingwm + LIBM_A=libm.a + LIBGMON_A=libgmon.a + ;; +*cygwin*) + CRT_ID=1 + MNO_CYGWIN=-mno-cygwin + RUNTIME=crtdll + THREAD_DLL=mingwc + # Do not build libm.a when building under Cygwin winsup. Otherwise, it'll + # overwrite Cygwin's one. Likewise for libgmon.a. + LIBM_A= + LIBGMON_A= + ;; +*) + # Build it for CRTDLL by default. + CRT_ID=1 + MNO_CYGWIN= + RUNTIME=crtdll + THREAD_DLL=mingwc + LIBM_A=libm.a + LIBGMON_A=libgmon.a + ;; +esac + + + + + + + + +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AIX 4 /usr/bin/installbsd, which doesn't work without a -g flag +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6 +echo "configure:698: checking for a BSD compatible install" >&5 +if test -z "$INSTALL"; then +if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then + echo $ac_n "(cached) $ac_c" 1>&6 +else + IFS="${IFS= }"; ac_save_IFS="$IFS"; IFS=":" + for ac_dir in $PATH; do + # Account for people who put trailing slashes in PATH elements. + case "$ac_dir/" in + /|./|.//|/etc/*|/usr/sbin/*|/usr/etc/*|/sbin/*|/usr/afsws/bin/*|/usr/ucb/*) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + # Don't use installbsd from OSF since it installs stuff as root + # by default. + for ac_prog in ginstall scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_IFS" + +fi + if test "${ac_cv_path_install+set}" = set; then + INSTALL="$ac_cv_path_install" + else + # As a last resort, use the slow shell script. We don't cache a + # path for INSTALL within a source directory, because that will + # break other packages using the cache if that directory is + # removed, or if the path is relative. + INSTALL="$ac_install_sh" + fi +fi +echo "$ac_t""$INSTALL" 1>&6 + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' + +test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}' + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' + +trap '' 1 2 15 +cat > confcache <<\EOF +# This file is a shell script that caches the results of configure +# tests run on this system so they can be shared between configure +# scripts and configure runs. It is not useful on other systems. +# If it contains results you don't want to keep, you may remove or edit it. +# +# By default, configure uses ./config.cache as the cache file, +# creating it if it does not exist already. You can give configure +# the --cache-file=FILE option to use a different cache file; that is +# what configure does when it calls configure scripts in +# subdirectories, so they share the cache. +# Giving --cache-file=/dev/null disables caching, for debugging configure. +# config.status only pays attention to the cache file if you give it the +# --recheck option to rerun configure. +# +EOF +# The following way of writing the cache mishandles newlines in values, +# but we know of no workaround that is simple, portable, and efficient. +# So, don't put newlines in cache variables' values. +# Ultrix sh set writes to stderr and can't be redirected directly, +# and sets the high bit in the cache file unless we assign to the vars. +(set) 2>&1 | + case `(ac_space=' '; set | grep ac_space) 2>&1` in + *ac_space=\ *) + # `set' does not quote correctly, so add quotes (double-quote substitution + # turns \\\\ into \\, and sed turns \\ into \). + sed -n \ + -e "s/'/'\\\\''/g" \ + -e "s/^\\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\\)=\\(.*\\)/\\1=\${\\1='\\2'}/p" + ;; + *) + # `set' quotes correctly as required by POSIX, so do not add quotes. + sed -n -e 's/^\([a-zA-Z0-9_]*_cv_[a-zA-Z0-9_]*\)=\(.*\)/\1=${\1=\2}/p' + ;; + esac >> confcache +if cmp -s $cache_file confcache; then + : +else + if test -w $cache_file; then + echo "updating cache $cache_file" + cat confcache > $cache_file + else + echo "not updating unwritable cache $cache_file" + fi +fi +rm -f confcache + +trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15 + +test "x$prefix" = xNONE && prefix=$ac_default_prefix +# Let make expand exec_prefix. +test "x$exec_prefix" = xNONE && exec_prefix='${prefix}' + +# Any assignment to VPATH causes Sun make to only execute +# the first set of double-colon rules, so remove it if not needed. +# If there is a colon in the path, we need to keep it. +if test "x$srcdir" = x.; then + ac_vpsub='/^[ ]*VPATH[ ]*=[^:]*$/d' +fi + +trap 'rm -f $CONFIG_STATUS conftest*; exit 1' 1 2 15 + +# Transform confdefs.h into DEFS. +# Protect against shell expansion while executing Makefile rules. +# Protect against Makefile macro expansion. +cat > conftest.defs <<\EOF +s%#define \([A-Za-z_][A-Za-z0-9_]*\) *\(.*\)%-D\1=\2%g +s%[ `~#$^&*(){}\\|;'"<>?]%\\&%g +s%\[%\\&%g +s%\]%\\&%g +s%\$%$$%g +EOF +DEFS=`sed -f conftest.defs confdefs.h | tr '\012' ' '` +rm -f conftest.defs + + +# Without the "./", some shells look in PATH for config.status. +: ${CONFIG_STATUS=./config.status} + +echo creating $CONFIG_STATUS +rm -f $CONFIG_STATUS +cat > $CONFIG_STATUS </dev/null | sed 1q`: +# +# $0 $ac_configure_args +# +# Compiler output produced by configure, useful for debugging +# configure, is in ./config.log if it exists. + +ac_cs_usage="Usage: $CONFIG_STATUS [--recheck] [--version] [--help]" +for ac_option +do + case "\$ac_option" in + -recheck | --recheck | --rechec | --reche | --rech | --rec | --re | --r) + echo "running \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion" + exec \${CONFIG_SHELL-/bin/sh} $0 $ac_configure_args --no-create --no-recursion ;; + -version | --version | --versio | --versi | --vers | --ver | --ve | --v) + echo "$CONFIG_STATUS generated by autoconf version 2.13" + exit 0 ;; + -help | --help | --hel | --he | --h) + echo "\$ac_cs_usage"; exit 0 ;; + *) echo "\$ac_cs_usage"; exit 1 ;; + esac +done + +ac_given_srcdir=$srcdir +ac_given_INSTALL="$INSTALL" + +trap 'rm -fr `echo "Makefile" | sed "s/:[^ ]*//g"` conftest*; exit 1' 1 2 15 +EOF +cat >> $CONFIG_STATUS < conftest.subs <<\\CEOF +$ac_vpsub +$extrasub +s%@SHELL@%$SHELL%g +s%@CFLAGS@%$CFLAGS%g +s%@CPPFLAGS@%$CPPFLAGS%g +s%@CXXFLAGS@%$CXXFLAGS%g +s%@FFLAGS@%$FFLAGS%g +s%@DEFS@%$DEFS%g +s%@LDFLAGS@%$LDFLAGS%g +s%@LIBS@%$LIBS%g +s%@exec_prefix@%$exec_prefix%g +s%@prefix@%$prefix%g +s%@program_transform_name@%$program_transform_name%g +s%@bindir@%$bindir%g +s%@sbindir@%$sbindir%g +s%@libexecdir@%$libexecdir%g +s%@datadir@%$datadir%g +s%@sysconfdir@%$sysconfdir%g +s%@sharedstatedir@%$sharedstatedir%g +s%@localstatedir@%$localstatedir%g +s%@libdir@%$libdir%g +s%@includedir@%$includedir%g +s%@oldincludedir@%$oldincludedir%g +s%@infodir@%$infodir%g +s%@mandir@%$mandir%g +s%@CC@%$CC%g +s%@AS@%$AS%g +s%@AR@%$AR%g +s%@LD@%$LD%g +s%@RANLIB@%$RANLIB%g +s%@DLLTOOL@%$DLLTOOL%g +s%@DLLWRAP@%$DLLWRAP%g +s%@host@%$host%g +s%@host_alias@%$host_alias%g +s%@host_cpu@%$host_cpu%g +s%@host_vendor@%$host_vendor%g +s%@host_os@%$host_os%g +s%@target@%$target%g +s%@target_alias@%$target_alias%g +s%@target_cpu@%$target_cpu%g +s%@target_vendor@%$target_vendor%g +s%@target_os@%$target_os%g +s%@build@%$build%g +s%@build_alias@%$build_alias%g +s%@build_cpu@%$build_cpu%g +s%@build_vendor@%$build_vendor%g +s%@build_os@%$build_os%g +s%@CRT_ID@%$CRT_ID%g +s%@RUNTIME@%$RUNTIME%g +s%@MNO_CYGWIN@%$MNO_CYGWIN%g +s%@THREAD_DLL@%$THREAD_DLL%g +s%@LIBM_A@%$LIBM_A%g +s%@LIBGMON_A@%$LIBGMON_A%g +s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g +s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g +s%@INSTALL_DATA@%$INSTALL_DATA%g + +CEOF +EOF + +cat >> $CONFIG_STATUS <<\EOF + +# Split the substitutions into bite-sized pieces for seds with +# small command number limits, like on Digital OSF/1 and HP-UX. +ac_max_sed_cmds=90 # Maximum number of lines to put in a sed script. +ac_file=1 # Number of current file. +ac_beg=1 # First line for current file. +ac_end=$ac_max_sed_cmds # Line after last line for current file. +ac_more_lines=: +ac_sed_cmds="" +while $ac_more_lines; do + if test $ac_beg -gt 1; then + sed "1,${ac_beg}d; ${ac_end}q" conftest.subs > conftest.s$ac_file + else + sed "${ac_end}q" conftest.subs > conftest.s$ac_file + fi + if test ! -s conftest.s$ac_file; then + ac_more_lines=false + rm -f conftest.s$ac_file + else + if test -z "$ac_sed_cmds"; then + ac_sed_cmds="sed -f conftest.s$ac_file" + else + ac_sed_cmds="$ac_sed_cmds | sed -f conftest.s$ac_file" + fi + ac_file=`expr $ac_file + 1` + ac_beg=$ac_end + ac_end=`expr $ac_end + $ac_max_sed_cmds` + fi +done +if test -z "$ac_sed_cmds"; then + ac_sed_cmds=cat +fi +EOF + +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF +for ac_file in .. $CONFIG_FILES; do if test "x$ac_file" != x..; then + # Support "outfile[:infile[:infile...]]", defaulting infile="outfile.in". + case "$ac_file" in + *:*) ac_file_in=`echo "$ac_file"|sed 's%[^:]*:%%'` + ac_file=`echo "$ac_file"|sed 's%:.*%%'` ;; + *) ac_file_in="${ac_file}.in" ;; + esac + + # Adjust a relative srcdir, top_srcdir, and INSTALL for subdirectories. + + # Remove last slash and all that follows it. Not all systems have dirname. + ac_dir=`echo $ac_file|sed 's%/[^/][^/]*$%%'` + if test "$ac_dir" != "$ac_file" && test "$ac_dir" != .; then + # The file is in a subdirectory. + test ! -d "$ac_dir" && mkdir "$ac_dir" + ac_dir_suffix="/`echo $ac_dir|sed 's%^\./%%'`" + # A "../" for each directory in $ac_dir_suffix. + ac_dots=`echo $ac_dir_suffix|sed 's%/[^/]*%../%g'` + else + ac_dir_suffix= ac_dots= + fi + + case "$ac_given_srcdir" in + .) srcdir=. + if test -z "$ac_dots"; then top_srcdir=. + else top_srcdir=`echo $ac_dots|sed 's%/$%%'`; fi ;; + /*) srcdir="$ac_given_srcdir$ac_dir_suffix"; top_srcdir="$ac_given_srcdir" ;; + *) # Relative path. + srcdir="$ac_dots$ac_given_srcdir$ac_dir_suffix" + top_srcdir="$ac_dots$ac_given_srcdir" ;; + esac + + case "$ac_given_INSTALL" in + [/$]*) INSTALL="$ac_given_INSTALL" ;; + *) INSTALL="$ac_dots$ac_given_INSTALL" ;; + esac + + echo creating "$ac_file" + rm -f "$ac_file" + configure_input="Generated automatically from `echo $ac_file_in|sed 's%.*/%%'` by configure." + case "$ac_file" in + *Makefile*) ac_comsub="1i\\ +# $configure_input" ;; + *) ac_comsub= ;; + esac + + ac_file_inputs=`echo $ac_file_in|sed -e "s%^%$ac_given_srcdir/%" -e "s%:% $ac_given_srcdir/%g"` + sed -e "$ac_comsub +s%@configure_input@%$configure_input%g +s%@srcdir@%$srcdir%g +s%@top_srcdir@%$top_srcdir%g +s%@INSTALL@%$INSTALL%g +" $ac_file_inputs | (eval "$ac_sed_cmds") > $ac_file +fi; done +rm -f conftest.s* + +EOF +cat >> $CONFIG_STATUS <> $CONFIG_STATUS <<\EOF + +exit 0 +EOF +chmod +x $CONFIG_STATUS +rm -fr confdefs* $ac_clean_files +test "$no_create" = yes || ${CONFIG_SHELL-/bin/sh} $CONFIG_STATUS || exit 1 + + diff --git a/winsup/mingw/profile/configure.in b/winsup/mingw/profile/configure.in new file mode 100644 index 000000000..8f2846e70 --- /dev/null +++ b/winsup/mingw/profile/configure.in @@ -0,0 +1,77 @@ +dnl Process this file with autoconf to produce a configure script. + +dnl This file is part of Mingw runtime. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2 of the License, or +dnl (at your option) any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. + +AC_PREREQ(2.12) +AC_INIT(gcrt0.c) + +CC=${CC-cc} +AC_SUBST(CC) +AS=${AS-as} +AC_SUBST(AS) +AR=${AR-ar} +AC_SUBST(AR) +LD=${LD-ld} +AC_SUBST(LD) +RANLIB=${RANLIB-ranlib} +AC_SUBST(RANLIB) +DLLTOOL=${DLLTOOL-dlltool} +AC_SUBST(DLLTOOL) +DLLWRAP=${DLLWRAP-dllwrap} +AC_SUBST(DLLWRAP) +AC_CANONICAL_SYSTEM + +case "$target_os" in +*mingw32msvc*) + CRT_ID=2 + MNO_CYGWIN= + RUNTIME=msvcrt + THREAD_DLL=mingwm + LIBM_A=libm.a + LIBGMON_A=libgmon.a + ;; +*cygwin*) + CRT_ID=1 + MNO_CYGWIN=-mno-cygwin + RUNTIME=crtdll + THREAD_DLL=mingwc + # Do not build libm.a when building under Cygwin winsup. Otherwise, it'll + # overwrite Cygwin's one. Likewise for libgmon.a. + LIBM_A= + LIBGMON_A= + ;; +*) + # Build it for CRTDLL by default. + CRT_ID=1 + MNO_CYGWIN= + RUNTIME=crtdll + THREAD_DLL=mingwc + LIBM_A=libm.a + LIBGMON_A=libgmon.a + ;; +esac + +AC_SUBST(CRT_ID) +AC_SUBST(RUNTIME) +AC_SUBST(MNO_CYGWIN) +AC_SUBST(THREAD_DLL) +AC_SUBST(LIBM_A) +AC_SUBST(LIBGMON_A) + +AC_PROG_INSTALL +AC_OUTPUT(Makefile) + diff --git a/winsup/mingw/profile/gcrt0.c b/winsup/mingw/profile/gcrt0.c new file mode 100644 index 000000000..601b2758c --- /dev/null +++ b/winsup/mingw/profile/gcrt0.c @@ -0,0 +1,52 @@ +/* gcrt0.c + + Copyright 1998 Cygnus Solutions. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#include +#include + +#ifdef __MINGW32__ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#endif + +extern u_char etext asm ("etext"); +extern u_char eprol asm ("__eprol"); +extern void _mcleanup (void); +extern void monstartup (u_long, u_long); +void _monstartup (void) __attribute__((__constructor__)); + +/* startup initialization for -pg support */ + +void +_monstartup (void) +{ + static int called; + + /* Guard against multiple calls that may happen if DLLs are linked + with profile option set as well. Addede side benefit is that it + makes profiling backward compatible (GCC used to emit a call to + _monstartup when compiling main with profiling enabled). */ + if (called++) + return; + + monstartup ((u_long) &eprol, (u_long) &etext); + atexit (&_mcleanup); +} + +asm (".text"); +asm ("__eprol:"); + diff --git a/winsup/mingw/profile/gmon.c b/winsup/mingw/profile/gmon.c new file mode 100644 index 000000000..17398b8e2 --- /dev/null +++ b/winsup/mingw/profile/gmon.c @@ -0,0 +1,284 @@ +/*- + * Copyright (c) 1983, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if !defined(lint) && defined(LIBC_SCCS) +static char rcsid[] = "$OpenBSD: gmon.c,v 1.8 1997/07/23 21:11:27 kstailey Exp $"; +#endif + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#include +#include +#include +#ifndef __MINGW32__ +#include +#include +#endif +#include +#include + +#include + +/* XXX needed? */ +//extern char *minbrk __asm ("minbrk"); + +struct gmonparam _gmonparam = { GMON_PROF_OFF }; + +static int s_scale; +/* see profil(2) where this is describe (incorrectly) */ +#define SCALE_1_TO_1 0x10000L + +#define ERR(s) write(2, s, sizeof(s)) + +void moncontrol __P((int)); + +static void * +fake_sbrk(int size) +{ + return malloc(size); +} + +void +monstartup(lowpc, highpc) + u_long lowpc; + u_long highpc; +{ + register int o; + char *cp; + struct gmonparam *p = &_gmonparam; + + /* + * round lowpc and highpc to multiples of the density we're using + * so the rest of the scaling (here and in gprof) stays in ints. + */ + p->lowpc = ROUNDDOWN(lowpc, HISTFRACTION * sizeof(HISTCOUNTER)); + p->highpc = ROUNDUP(highpc, HISTFRACTION * sizeof(HISTCOUNTER)); + p->textsize = p->highpc - p->lowpc; + p->kcountsize = p->textsize / HISTFRACTION; + p->hashfraction = HASHFRACTION; + p->fromssize = p->textsize / p->hashfraction; + p->tolimit = p->textsize * ARCDENSITY / 100; + if (p->tolimit < MINARCS) + p->tolimit = MINARCS; + else if (p->tolimit > MAXARCS) + p->tolimit = MAXARCS; + p->tossize = p->tolimit * sizeof(struct tostruct); + + cp = fake_sbrk(p->kcountsize + p->fromssize + p->tossize); + if (cp == (char *)-1) { + ERR("monstartup: out of memory\n"); + return; + } +#ifdef notdef + bzero(cp, p->kcountsize + p->fromssize + p->tossize); +#endif + p->tos = (struct tostruct *)cp; + cp += p->tossize; + p->kcount = (u_short *)cp; + cp += p->kcountsize; + p->froms = (u_short *)cp; + + /* XXX minbrk needed? */ + //minbrk = fake_sbrk(0); + p->tos[0].link = 0; + + o = p->highpc - p->lowpc; + if (p->kcountsize < o) { +#ifndef notdef + s_scale = ((float)p->kcountsize / o ) * SCALE_1_TO_1; +#else /* avoid floating point */ + int quot = o / p->kcountsize; + + if (quot >= 0x10000) + s_scale = 1; + else if (quot >= 0x100) + s_scale = 0x10000 / quot; + else if (o >= 0x800000) + s_scale = 0x1000000 / (o / (p->kcountsize >> 8)); + else + s_scale = 0x1000000 / ((o << 8) / p->kcountsize); +#endif + } else + s_scale = SCALE_1_TO_1; + + moncontrol(1); +} + +void +_mcleanup() +{ + int fd; + int hz; + int fromindex; + int endfrom; + u_long frompc; + int toindex; + struct rawarc rawarc; + struct gmonparam *p = &_gmonparam; + struct gmonhdr gmonhdr, *hdr; + char *proffile; +#ifdef DEBUG + int log, len; + char dbuf[200]; +#endif + + if (p->state == GMON_PROF_ERROR) + ERR("_mcleanup: tos overflow\n"); + + hz = PROF_HZ; + moncontrol(0); + +#ifdef nope + if ((profdir = getenv("PROFDIR")) != NULL) { + extern char *__progname; + char *s, *t, *limit; + pid_t pid; + long divisor; + + /* If PROFDIR contains a null value, no profiling + output is produced */ + if (*profdir == '\0') { + return; + } + + limit = buf + sizeof buf - 1 - 10 - 1 - + strlen(__progname) - 1; + t = buf; + s = profdir; + while((*t = *s) != '\0' && t < limit) { + t++; + s++; + } + *t++ = '/'; + + /* + * Copy and convert pid from a pid_t to a string. For + * best performance, divisor should be initialized to + * the largest power of 10 less than PID_MAX. + */ + pid = getpid(); + divisor=10000; + while (divisor > pid) divisor /= 10; /* skip leading zeros */ + do { + *t++ = (pid/divisor) + '0'; + pid %= divisor; + } while (divisor /= 10); + *t++ = '.'; + + s = __progname; + while ((*t++ = *s++) != '\0') + ; + + proffile = buf; + } else { + proffile = "gmon.out"; + } +#else + proffile = "gmon.out"; +#endif + + fd = open(proffile , O_CREAT|O_TRUNC|O_WRONLY|O_BINARY, 0666); + if (fd < 0) { + perror( proffile ); + return; + } +#ifdef DEBUG + log = open("gmon.log", O_CREAT|O_TRUNC|O_WRONLY, 0664); + if (log < 0) { + perror("mcount: gmon.log"); + return; + } + len = sprintf(dbuf, "[mcleanup1] kcount 0x%x ssiz %d\n", + p->kcount, p->kcountsize); + write(log, dbuf, len); +#endif + hdr = (struct gmonhdr *)&gmonhdr; + hdr->lpc = p->lowpc; + hdr->hpc = p->highpc; + hdr->ncnt = p->kcountsize + sizeof(gmonhdr); + hdr->version = GMONVERSION; + hdr->profrate = hz; + write(fd, (char *)hdr, sizeof *hdr); + write(fd, p->kcount, p->kcountsize); + endfrom = p->fromssize / sizeof(*p->froms); + for (fromindex = 0; fromindex < endfrom; fromindex++) { + if (p->froms[fromindex] == 0) + continue; + + frompc = p->lowpc; + frompc += fromindex * p->hashfraction * sizeof(*p->froms); + for (toindex = p->froms[fromindex]; toindex != 0; + toindex = p->tos[toindex].link) { +#ifdef DEBUG + len = sprintf(dbuf, + "[mcleanup2] frompc 0x%x selfpc 0x%x count %d\n" , + frompc, p->tos[toindex].selfpc, + p->tos[toindex].count); + write(log, dbuf, len); +#endif + rawarc.raw_frompc = frompc; + rawarc.raw_selfpc = p->tos[toindex].selfpc; + rawarc.raw_count = p->tos[toindex].count; + write(fd, &rawarc, sizeof rawarc); + } + } + close(fd); +} + +/* + * Control profiling + * profiling is what mcount checks to see if + * all the data structures are ready. + */ +void +moncontrol(mode) + int mode; +{ + struct gmonparam *p = &_gmonparam; + + if (mode) { + /* start */ + profil((char *)p->kcount, p->kcountsize, p->lowpc, + s_scale); + p->state = GMON_PROF_ON; + } else { + /* stop */ + profil((char *)0, 0, 0, 0); + p->state = GMON_PROF_OFF; + } +} + + diff --git a/winsup/mingw/profile/gmon.h b/winsup/mingw/profile/gmon.h new file mode 100644 index 000000000..c9f1cac8f --- /dev/null +++ b/winsup/mingw/profile/gmon.h @@ -0,0 +1,178 @@ +/* $OpenBSD: gmon.h,v 1.3 1996/04/21 22:31:46 deraadt Exp $ */ +/* $NetBSD: gmon.h,v 1.5 1996/04/09 20:55:30 cgd Exp $ */ + +/*- + * Copyright (c) 1982, 1986, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)gmon.h 8.2 (Berkeley) 1/4/94 + */ + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#ifndef _SYS_GMON_H_ +#define _SYS_GMON_H_ + +#ifndef __P +#define __P(x) x +#endif + +#include + +#ifdef __MINGW32__ +typedef unsigned char u_char; +typedef unsigned short u_short; +typedef unsigned int u_int; +typedef unsigned long u_long; +#endif + +/* + * Structure prepended to gmon.out profiling data file. + */ +struct gmonhdr { + u_long lpc; /* base pc address of sample buffer */ + u_long hpc; /* max pc address of sampled buffer */ + int ncnt; /* size of sample buffer (plus this header) */ + int version; /* version number */ + int profrate; /* profiling clock rate */ + int spare[3]; /* reserved */ +}; +#define GMONVERSION 0x00051879 + +/* + * histogram counters are unsigned shorts (according to the kernel). + */ +#define HISTCOUNTER unsigned short + +/* + * fraction of text space to allocate for histogram counters here, 1/2 + */ +#define HISTFRACTION 2 + +/* + * Fraction of text space to allocate for from hash buckets. + * The value of HASHFRACTION is based on the minimum number of bytes + * of separation between two subroutine call points in the object code. + * Given MIN_SUBR_SEPARATION bytes of separation the value of + * HASHFRACTION is calculated as: + * + * HASHFRACTION = MIN_SUBR_SEPARATION / (2 * sizeof(short) - 1); + * + * For example, on the VAX, the shortest two call sequence is: + * + * calls $0,(r0) + * calls $0,(r0) + * + * which is separated by only three bytes, thus HASHFRACTION is + * calculated as: + * + * HASHFRACTION = 3 / (2 * 2 - 1) = 1 + * + * Note that the division above rounds down, thus if MIN_SUBR_FRACTION + * is less than three, this algorithm will not work! + * + * In practice, however, call instructions are rarely at a minimal + * distance. Hence, we will define HASHFRACTION to be 2 across all + * architectures. This saves a reasonable amount of space for + * profiling data structures without (in practice) sacrificing + * any granularity. + */ +#define HASHFRACTION 2 + +/* + * percent of text space to allocate for tostructs with a minimum. + */ +#define ARCDENSITY 2 +#define MINARCS 50 +#define MAXARCS ((1 << (8 * sizeof(HISTCOUNTER))) - 2) + +struct tostruct { + u_long selfpc; + long count; + u_short link; + u_short pad; +}; + +/* + * a raw arc, with pointers to the calling site and + * the called site and a count. + */ +struct rawarc { + u_long raw_frompc; + u_long raw_selfpc; + long raw_count; +}; + +/* + * general rounding functions. + */ +#define ROUNDDOWN(x,y) (((x)/(y))*(y)) +#define ROUNDUP(x,y) ((((x)+(y)-1)/(y))*(y)) + +/* + * The profiling data structures are housed in this structure. + */ +struct gmonparam { + int state; + u_short *kcount; + u_long kcountsize; + u_short *froms; + u_long fromssize; + struct tostruct *tos; + u_long tossize; + long tolimit; + u_long lowpc; + u_long highpc; + u_long textsize; + u_long hashfraction; +}; +extern struct gmonparam _gmonparam; + +/* + * Possible states of profiling. + */ +#define GMON_PROF_ON 0 +#define GMON_PROF_BUSY 1 +#define GMON_PROF_ERROR 2 +#define GMON_PROF_OFF 3 + +/* + * Sysctl definitions for extracting profiling information from the kernel. + */ +#define GPROF_STATE 0 /* int: profiling enabling variable */ +#define GPROF_COUNT 1 /* struct: profile tick count buffer */ +#define GPROF_FROMS 2 /* struct: from location hash bucket */ +#define GPROF_TOS 3 /* struct: destination/count structure */ +#define GPROF_GMONPARAM 4 /* struct: profiling parameters (see above) */ +#endif /* !_SYS_GMONH_ */ diff --git a/winsup/mingw/profile/mcount.c b/winsup/mingw/profile/mcount.c new file mode 100644 index 000000000..296f8c891 --- /dev/null +++ b/winsup/mingw/profile/mcount.c @@ -0,0 +1,180 @@ +/*- + * Copyright (c) 1983, 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#if !defined(lint) && !defined(_KERNEL) && defined(LIBC_SCCS) +static char rcsid[] = "$OpenBSD: mcount.c,v 1.6 1997/07/23 21:11:27 kstailey Exp $"; +#endif + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#ifndef __MINGW32__ +#include +#endif +#include +#include + +/* + * mcount is called on entry to each function compiled with the profiling + * switch set. _mcount(), which is declared in a machine-dependent way + * with _MCOUNT_DECL, does the actual work and is either inlined into a + * C routine or called by an assembly stub. In any case, this magic is + * taken care of by the MCOUNT definition in . + * + * _mcount updates data structures that represent traversals of the + * program's call graph edges. frompc and selfpc are the return + * address and function address that represents the given call graph edge. + * + * Note: the original BSD code used the same variable (frompcindex) for + * both frompcindex and frompc. Any reasonable, modern compiler will + * perform this optimization. + */ +//_MCOUNT_DECL __P((u_long frompc, u_long selfpc)); +_MCOUNT_DECL(frompc, selfpc) /* _mcount; may be static, inline, etc */ + register u_long frompc, selfpc; +{ + register u_short *frompcindex; + register struct tostruct *top, *prevtop; + register struct gmonparam *p; + register long toindex; + + p = &_gmonparam; + /* + * check that we are profiling + * and that we aren't recursively invoked. + */ + if (p->state != GMON_PROF_ON) + return; + p->state = GMON_PROF_BUSY; + /* + * check that frompcindex is a reasonable pc value. + * for example: signal catchers get called from the stack, + * not from text space. too bad. + */ + frompc -= p->lowpc; + if (frompc > p->textsize) + goto done; + +#if (HASHFRACTION & (HASHFRACTION - 1)) == 0 + if (p->hashfraction == HASHFRACTION) + frompcindex = + &p->froms[frompc / (HASHFRACTION * sizeof(*p->froms))]; + else +#endif + frompcindex = + &p->froms[frompc / (p->hashfraction * sizeof(*p->froms))]; + toindex = *frompcindex; + if (toindex == 0) { + /* + * first time traversing this arc + */ + toindex = ++p->tos[0].link; + if (toindex >= p->tolimit) + /* halt further profiling */ + goto overflow; + + *frompcindex = toindex; + top = &p->tos[toindex]; + top->selfpc = selfpc; + top->count = 1; + top->link = 0; + goto done; + } + top = &p->tos[toindex]; + 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 = ++p->tos[0].link; + if (toindex >= p->tolimit) + goto overflow; + + top = &p->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 = &p->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; + } + } +done: + p->state = GMON_PROF_ON; + return; +overflow: + p->state = GMON_PROF_ERROR; + return; +} + +/* + * Actual definition of mcount function. Defined in , + * which is included by + */ +MCOUNT + diff --git a/winsup/mingw/profile/profil.c b/winsup/mingw/profile/profil.c new file mode 100644 index 000000000..d2946210e --- /dev/null +++ b/winsup/mingw/profile/profil.c @@ -0,0 +1,185 @@ +/* profil.c -- win32 profil.c equivalent + + Copyright 1998 Cygnus Solutions. + + This file is part of Cygwin. + + This software is a copyrighted work licensed under the terms of the + Cygwin license. Please consult the file "CYGWIN_LICENSE" for + details. */ + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#include +#include +#include +#include +#include + +#include + +#define SLEEPTIME (1000 / PROF_HZ) + +/* global profinfo for profil() call */ +static struct profinfo prof; + +/* Get the pc for thread THR */ + +static u_long +get_thrpc (HANDLE thr) +{ + CONTEXT ctx; + u_long pc; + int res; + + res = SuspendThread (thr); + if (res == -1) + return (u_long) - 1; + ctx.ContextFlags = CONTEXT_CONTROL | CONTEXT_INTEGER; + pc = (u_long) - 1; + if (GetThreadContext (thr, &ctx)) + pc = ctx.Eip; + ResumeThread (thr); + return pc; +} + +/* Display cell of profile buffer */ +#if 0 +static void +print_prof (struct profinfo *p) +{ + printf ("profthr %x\ttarget thr %x\n", p->profthr, p->targthr); + printf ("pc: %x - %x\n", p->lowpc, p->highpc); + printf ("scale: %x\n", p->scale); + return; +} +#endif + +/* Everytime we wake up use the main thread pc to hash into the cell in the + profile buffer ARG. */ + +static DWORD CALLBACK +profthr_func (LPVOID arg) +{ + struct profinfo *p = (struct profinfo *) arg; + u_long pc, idx; + + for (;;) + { + pc = (u_long) get_thrpc (p->targthr); + if (pc >= p->lowpc && pc < p->highpc) + { + idx = PROFIDX (pc, p->lowpc, p->scale); + p->counter[idx]++; + } +#if 0 + print_prof (p); +#endif + Sleep (SLEEPTIME); + } + return 0; +} + +/* Stop profiling to the profiling buffer pointed to by P. */ + +static int +profile_off (struct profinfo *p) +{ + if (p->profthr) + { + TerminateThread (p->profthr, 0); + CloseHandle (p->profthr); + } + if (p->targthr) + CloseHandle (p->targthr); + return 0; +} + +/* Create a timer thread and pass it a pointer P to the profiling buffer. */ + +static int +profile_on (struct profinfo *p) +{ + DWORD thrid; + + /* get handle for this thread */ + if (!DuplicateHandle (GetCurrentProcess (), GetCurrentThread (), + GetCurrentProcess (), &p->targthr, 0, FALSE, + DUPLICATE_SAME_ACCESS)) + { + errno = ESRCH; + return -1; + } + + p->profthr = CreateThread (0, 0, profthr_func, (void *) p, 0, &thrid); + + /* Set profiler thread priority to highest to be sure that it gets the + processor as soon it request it (i.e. when the Sleep terminate) to get + the next data out of the profile. */ + + SetThreadPriority (p->profthr, THREAD_PRIORITY_TIME_CRITICAL); + + if (!p->profthr) + { + CloseHandle (p->targthr); + p->targthr = 0; + errno = EAGAIN; + return -1; + } + return 0; +} + +/* + * start or stop profiling + * + * profiling goes into the SAMPLES buffer of size SIZE (which is treated + * as an array of u_shorts of size size/2) + * + * each bin represents a range of pc addresses from OFFSET. The number + * of pc addresses in a bin depends on SCALE. (A scale of 65536 maps + * each bin to two addresses, A scale of 32768 maps each bin to 4 addresses, + * a scale of 1 maps each bin to 128k addreses). Scale may be 1 - 65536, + * or zero to turn off profiling + */ +int +profile_ctl (struct profinfo * p, char *samples, size_t size, + u_long offset, u_int scale) +{ + u_long maxbin; + + if (scale > 65536) + { + errno = EINVAL; + return -1; + } + + profile_off (p); + if (scale) + { + memset (samples, 0, size); + memset (p, 0, sizeof *p); + maxbin = size >> 1; + prof.counter = (u_short *) samples; + prof.lowpc = offset; + prof.highpc = PROFADDR (maxbin, offset, scale); + prof.scale = scale; + + return profile_on (p); + } + return 0; +} + +/* Equivalent to unix profil() + Every SLEEPTIME interval, the user's program counter (PC) is examined: + offset is subtracted and the result is multiplied by scale. + The word pointed to by this address is incremented. Buf is unused. */ + +int +profil (char *samples, size_t size, u_long offset, u_int scale) +{ + return profile_ctl (&prof, samples, size, offset, scale); +} + diff --git a/winsup/mingw/profile/profil.h b/winsup/mingw/profile/profil.h new file mode 100644 index 000000000..1e3ef479f --- /dev/null +++ b/winsup/mingw/profile/profil.h @@ -0,0 +1,49 @@ +/* profil.h: gprof profiling header file + + Copyright 1998 Cygnus Solutions. + +This file is part of Cygwin. + +This software is a copyrighted work licensed under the terms of the +Cygwin license. Please consult the file "CYGWIN_LICENSE" for +details. */ + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +/* profiling frequency. (No larger than 1000) */ +#define PROF_HZ 100 + +/* convert an addr to an index */ +#define PROFIDX(pc, base, scale) \ + ({ \ + size_t i = (pc - base) / 2; \ + if (sizeof (unsigned long long int) > sizeof (size_t)) \ + i = (unsigned long long int) i * scale / 65536; \ + else \ + i = i / 65536 * scale + i % 65536 * scale / 65536; \ + i; \ + }) + +/* convert an index into an address */ +#define PROFADDR(idx, base, scale) \ + ((base) + ((((idx) << 16) / (scale)) << 1)) + +/* convert a bin size into a scale */ +#define PROFSCALE(range, bins) (((bins) << 16) / ((range) >> 1)) + +typedef void *_WINHANDLE; + +struct profinfo { + _WINHANDLE targthr; /* thread to profile */ + _WINHANDLE profthr; /* profiling thread */ + u_short *counter; /* profiling counters */ + u_long lowpc, highpc; /* range to be profiled */ + u_int scale; /* scale value of bins */ +}; + +int profile_ctl(struct profinfo *, char *, size_t, u_long, u_int); +int profil(char *, size_t, u_long, u_int); + diff --git a/winsup/mingw/profile/profile.h b/winsup/mingw/profile/profile.h new file mode 100644 index 000000000..d578657f8 --- /dev/null +++ b/winsup/mingw/profile/profile.h @@ -0,0 +1,63 @@ +/* $NetBSD: profile.h,v 1.6 1995/03/28 18:17:08 jtc Exp $ */ + +/* + * Copyright (c) 1992, 1993 + * The Regents of the University of California. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. All advertising materials mentioning features or use of this software + * must display the following acknowledgement: + * This product includes software developed by the University of + * California, Berkeley and its contributors. + * 4. Neither the name of the University nor the names of its contributors + * may be used to endorse or promote products derived from this software + * without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + * + * @(#)profile.h 8.1 (Berkeley) 6/11/93 + */ + +/* + * This file is taken from Cygwin distribution. Please keep it in sync. + * The differences should be within __MINGW32__ guard. + */ + +#define _MCOUNT_DECL static inline void _mcount + +#define MCOUNT \ +void \ +mcount() \ +{ \ + int selfpc, frompcindex; \ + /* \ + * find the return address for mcount, \ + * and the return address for mcount's caller. \ + * \ + * selfpc = pc pushed by mcount call \ + */ \ + __asm("movl 4(%%ebp),%0" : "=r" (selfpc)); \ + /* \ + * frompcindex = pc pushed by call into self. \ + */ \ + __asm("movl (%%ebp),%0;movl 4(%0),%0" : "=r" (frompcindex)); \ + _mcount(frompcindex, selfpc); \ +} + diff --git a/winsup/mingw/readme.txt b/winsup/mingw/readme.txt new file mode 100644 index 000000000..4b680df48 --- /dev/null +++ b/winsup/mingw/readme.txt @@ -0,0 +1,685 @@ + Minimalist GNU-Win32 Readme + version 0.1.3 + March 20, 1997 + Colin Peters + + +0. Introduction + +Mingw32 is short for the Minimalist GNU-Win32 package, and it is a +package which allows you to use GCC (as supplied by Cygnus in their GNU- +Win32 or Cygwin32 package) the GNU compiler, on Win32 platforms like +Windows 95 or NT, to compile "native" programs. + +In this case "native" means programs which don't require extra DLLs like +the cygwin DLL. Mingw32 programs use CRTDLL.DLL to provide their C run +time library functions, and CRTDLL.DLL is supplied with all current +Win32 platforms. Thus the programs are light weight and easy to +distribute, they also do not automatically fall under the GNU Public +License as programs written with the GPL version of Cygwin32 do. + + +0.1 Archive Contents + +Mingw32 version 0.1.3 is distributed in two files, mingw32_013.tar.gz +and mingsrc013.tar.gz. The first file contains the following components: + + - Import libraries for building programs which use the + CRTDLL.DLL C run time library supplied with Win32 platforms. + + - crt0.o and dllcrt0.o, two "startup code" object files that + perform program or DLL initialization without using + CRTDLL.DLL (instead of CYGWIN.DLL). + + - specs, a configuration file for GCC which defines appropriate + options for creating executables which use the CRTDLL.DLL C + run time library. + + - Include files with appropriate type and macro definitions, + and function prototypes for use with CRTDLL.DLL. + +The source distribution (mingsrc013.tar.gz) contains the .def files and +source files used to create the various import libraries and object +files in the above list. + + +0.2 Usage Notes + +Unlike some previous releases of Mingw32 the current version defaults to +building console applications, the same way that GCC normally does when +installed from the Cygnus distribution. The Mingw32 specs file also +introduces two command line arguments to GCC which can be used to +conveniently specify a console or GUI type build. When building console +programs "-console" can be used on the GCC command line, while GUI +programs can be built by specifying "-windows" (I tried defining -gui, +and it works, but produces an annoying warning about -gui not being +supported (?)). For example: + + gcc -o hellogui.exe hellogui.c -luser32 -windows + +Although using different "crt0" files for GUI and console applications +has been suggested I have left the system more-or-less as it was in +0.1.1: crt0 sets up for and calls main, and if you don't supply a main +there is one in libmingw32.a, which in turn calls WinMain (actually +WinMain@16). This allows either main or WinMain entry points in console +or GUI applications, but if you don't supply main or WinMain, or don't +prototype WinMain as __stdcall__ you will get a linker error about an +"unresolved reference to WinMain@16." This is unfortunately cryptic, but +otherwise the system works quite well. + +An important note if you want to rebuild from the sources of Mingw32 or +otherwise use the special version of Jam made for Mingw32: you need to +have a version of "rm", the UNIX equivalent of del, somewhere in your +path to use the current Jambase (which is built into the Jam +executable). The version that comes with the Cygnus files is perfectly +adequate. + + +0.3 Fixes and Improvements + +Numerous small bug fixes have been made in the header files. + +Floating point initialization, originally added in version 0.1.2, has +been modified to use the _fpreset function from CRTDLL.DLL instead of +cryptic and possibly less portable assembly code. + +A new DLL-building option has been added to the specs file so that the +following link line will appropriately link in dllcrt0.o instead of the +normal crt0.o, and set the entry point correctly: + + gcc -dll -o dll.dll dll.o -Wl,dll.exp + +A bug that would cause the wrong include files to be included in dual +installations of Cygwin32 and Mingw32 has been fixed (I hope) in the +Mingw32 specs file. + +Alongside this release is a new release of Jam specially built for use +with Mingw32. It should be available from the same place you got this +file. This release of Jam includes rules for building DLLs, including +resources in your executables and creating import libraries. I also +intend to distribute a small set of example files showing how to do all +of these things with Mingw32 and Jam. + +In the "coming soon" category I have a version of the GNU Standard C++ +library ported to Mingw32. This means you can use iostreams, complex +numbers and all those neat STL (Standard Template Library) things +without needing the Cygwin DLL. I hope to put this port up for +downloading soon (along with the source of course). + + + +1. Installing + +1.1 Download and Unpack GNU-Win32 Beta 17.1 + +Because of the enormous size of the beta 17.1 release from Cygnus this +process will require about 85 MB or more of free disk space. The first +step, after downloading the Mingw32 package, is to download the GCC +binary distribution, all.tar.gz, from Cygnus (or a mirror), which is +about 10 MB. (Of course, if you just want the Cygwin32 install and are +not actually interested in adding on Mingw32 you don't need the Mingw32 +package at all.) + +Just to be safe, and if you have the 10 MB to spare, you should probably +copy the all.tar.gz file to a reasonably safe place at this point. This +will save you from the pain of downloading it again if something goes +wrong later. + +To complete this step you need a gzip program (or just gunzip) and a tar +program. You can use the ones supplied by Cygnus (although some people +seem to have trouble with them, especially if you try to use pipes) or +one of the other ports available from your favorite freeware/shareware +software site. + +First un-gzip the file with a command line like: + gunzip all.tar.gz +or + gzip -d all.tar.gz + +This will produce a all.tar file and erase the all.tar.gz file (there +are options for gzip if you want to keep the original around). The tar +file is about 40 MB. + +Make a directory for the cygnus stuff, such as C:\cygnus for example. +Move the tar file there (e.g. move \tmp\all.tar \cygnus). Don’t copy it +unless you like waiting and wasting 40 MB of disk space. + +Unpack the tar file into your new directory with a command line like: + tar xvf all.tar + +Run from the new directory (now containing the tar file). This is the +step where disk space usage reaches its peak, since the tar extraction +does not delete the all.tar file, and the amount of space taken by the +extracted files plus the tar file itself is well in excess of 80 MB +(mainly because, on my system at least, the files which are symbolic +links in the tar archive are copied as they are expanded onto the FAT +filesystem, so for example, a symbolic link to cygwin.dll, a 3 MB file, +takes an extra 3 MB, since the file is simply duplicated in the new +location). I could not actually do this on my laptop and had to extract +the tar file from a mounted network drive! + +NOTE: From here on I will refer to files as if you had installed in +C:\cygnus. If you installed somewhere else then just replace C:\cygnus +with the appropriate path wherever it occurs. + + +1.2 Setup Cygwin32 + +This step is not 100% necessary, but it helps at this point to determine +if you’ve gotten this far without any major problems. Also, if you +intend to use both Cygwin32 and Mingw32 you will have to do some of +these steps eventually. + +GCC and the other programs in the compiler suite all require cygwin.dll +to run. There are two copies of this file: one in C:\cygnus\H-i386- +cygwin32\bin (this might be a symbolic link), and one in C:\cygnus\H- +i386-cygwin32\i386-cygwin32\lib (the original). Since this DLL is +required by all Cygwin32 programs it makes sense to put one copy of it +in your C:\Windows\System directory (or equivalent) and remove the extra +copies. This will also save you headaches when the next release comes +along and you have to make sure that everything is using the latest +release of the DLL. + +After doing that run the cygwin32.bat batch file included with this +distribution, or otherwise perform the following settings: + + PATH=%PATH%;C:\cygnus\H-i386-cygwin32\bin + SET GCC_EXEC_PREFIX=C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386- + cygwin32\cygnus-2.7.2-961023 + SET LIBRARY_PATH=/cygnus/H-i386-cygwin32/lib/gcc-lib/i386- + cygwin32/cygnus-2.7.2-961023:/cygnus/H-i386-cygwin32/i386- + cygwin32/lib:/cygnus/H-i386-cygwin32/lib + SET C_INCLUDE_PATH=/cygnus/H-i386-cygwin32/lib/gcc-lib/i386- + cygwin32/cygnus-2.7.2-961023/include:/cygnus/H-i386- + cygwin32/i386-cygwin32/include:/cygnus/include + SET CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH% + +NOTE: You may need to increase the amount of environment space available +at the command prompt to get these extremely long environment variables +set. You can do this under Windows 95 by modifying the properties of the +command prompt shortcut you use under the "Program" tab, adding a +/e:#### argument to the command line COMMAND.COM, where #### is the +number of bytes to set aside for the environment. + +NOTE: Under Windows 95 changes made in your autoexec.bat file will not +show up in new DOS boxes unless you reboot your machine. + +Now write and compile a small test hello world program like this: + +#include + +int +main () +{ + printf ("Hello, world!\n"); + return 0; +} + +Then compile it like this (assuming your file is called hello.c): + + gcc -o hello.exe hello.c + +The compile should proceed without problems and you should be able to +run the hello program at the end. It should print "Hello, world!" +(without the quotes) to the console and then return to the command +prompt. + +If you wanted a full Cygwin32 install you now have it. With this setup +(say, by adding those lines above to your autoexec.bat or global +settings) you can port a great deal of UNIX code to run under Win32 +systems. No more steps are necessary. + +If you are a minimalist or otherwise want to save disk space you should +continue from here. Also if you intend to use the Minimalist GNU-Win32 +files to compile programs which don't use the Cygwin32 API you will need +to do some of the things mentioned below. + +If the compile didn't work for some reason check very carefully that you +followed the instructions above correctly and then check whether one or +more of the files in the download got corrupted. If neither of these +seems to be the case then your system is not behaving like my system. +Try looking at the troubleshooting section later in this file, and if +none of that helps then you can email me (colin@bird.fu.is.saga- +u.ac.jp), though I can't promise I'll be a lot of help. + + +1.3 Separating the Win32 API Files + +Mingw32 and Cygwin32 share the same set of Win32 API include files and +import libraries as included in the GCC distribution from Cygnus. In +order to use the Win32 API with a dual setup or with Mingw32 alone you +will have to separate those files from the bulk of the Cygwin32 API +files. + +Make a new directory to serve as the root for the Win32 API files. I put +mine under C:\cygnus and called it win32, but you can put it where you +like and just replace later references to C:\cygnus\win32 with your own +root directory. + +Move the following from C:\cygnus\H-i386-cygwin32\i386-cygwin32\include +to a new C:\cygnus\win32\include directory: + +windows.h, winadvapi.h, winbase.h, wincon.h, windef.h, windowsx.h, +winerror.h, wingdi.h, winkernel.h, winnt.h, wintypes.h, winuser.h, +winversion.h, commdlg.h, ddeml.h and the Windows32 sub-directory and all +its contents. + +Move the following files from C:\cygnus\H-i386-cygwin32\i386- +cygwin32\lib to a new C:\cygnus\win32\lib directory: + +libadvapi32.a, libcomctl32.a, libcomdlg32.a, libctl3d32.a, libgdi32.a, +libglaux.a, libglu32.a, libimm32.a, libkernel32.a, liblz32.a, +libmapi32.a, libmfcuia32.a, libmgmtapi.a, libmpr.a, libmsacm32.a, +libnddeapi.a, libnetapi32.a, libodbc32.a, libodbccp32.a, libole32.a, +liboleaut32.a, liboledlg.a, libolepro32.a, libopengl32.a, libpenwin32.a, +libpkpd32.a, librasapi32.a, librpcdce4.a, librpcndr.a, librpcns4.a, +librpcrt4.a, libscrnsave.a, libshell32.a, libsnmp.a, libsvrapi.a, +libtapi32.a, libth32.a, libthunk32.a, liburl.a libuser32.a, libvdmdbg.a, +libversion.a, libvfw32.a, libwin32spl.a, libwinmm.a, libwinserve.a, +libwinspool.a, libwinstrm.a, libwow32.a, libwsock32.a, libwst.a. + +That list is quite excessive for most basic Windows programming, which +will only require kernel32, user32, gdi32, shell32 and possibly a couple +of others like the common control and dialog libraries or advapi32. You +may not need the ODBC support, or OLE, or Pen Windows, TAPI and on and +on. Still, if you have the space and intend to use the Win32 API you +might as well keep the ones you’re not sure you’ll ever use around. + +The lists above can also act as lists of files you can safely delete if +you are never going to use the Win32 API in your programs except that +libkernel32.a is still required even if you don’t use the Win32 API +yourself. Note that this means that libkernel32.a must be on the library +path as well, even if you don’t use the Win32 API. (Actually this +appears to be an artifact of the specs file supplied with Cygwin32. If +you like, and feel up to it, you can play around with the specs file and +remove the reference to kernel32.) + +Here are the variable settings you need to make to allow GCC to find the +Win32 API files in their new positions: + + SET LIBRARY_PATH=%LIBRARY_PATH%:/cygnus/win32/lib + SET C_INCLUDE_PATH=%C_INCLUDE_PATH%:/cygnus/win32/include + SET CPLUS_INCLUDE_PATH=%CPLUS_INCLUDE_PATH%:/cygnus/win32/include + +The file win32-api.bat performs these settings. Run it after you run +cygwin32.bat (or mingw32.bat below). + +At this point you should be able to compile programs that use the Win32 +API, just as you could before. You might want to do a simple test +compile to find out, for example this code: + +#include + +int STDCALL +WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) +{ + MessageBox (NULL, "Test message", "Test", MB_OK); + return 0; +} + +Should compile with the following command line: + gcc -o test.exe test.c -lkernel32 -luser32 -Wl,--subsystem,windows + +It will produce a warning at link time about not finding +_WinMainCRTStartup, but this is harmless. + +If you have trouble check the troubleshooting section later in this +file. + + +1.4 Specs + +The file C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus- +2.7.2-961023\specs includes a set of options and defaults for GCC, +including such things as which libraries are automatically linked into +executables and such. A different specs file is required depending on +whether you use Cygwin32 or Mingw32. + +To avoid GCC accidentally using the wrong specs file move specs to +C:\cygnus\H-i386-cygwin32\i386-cygwin32\lib. + +You can verify what specs file is being used by attempting a compile +with the -v option to gcc. Note that if no specs file is mentioned the +compiler will default to Cygwin32 behavior. + + +1.5 The Mingw32 Files + +Now we can install the Mingw32 files and start making programs which +don’t use cygwin.dll or the Cygwin32 API. I install my copy under a +separate directory called C:\mingw32, but you could put them wherever +you like (e.g. C:\cygnus\mingw32). Again simply replace references to +C:\mingw32 with the directory where you perform your installation. + +After making the install directory copy mingw32_012.tgz to that +directory and run a command like this: + gunzip -d mingw32_012.tgz + +in that directory, followed by: + tar xvf mingw32_012.tar + +This will unpack the required files. Then you can use the following +environment variable settings (as included in mingw32.bat) to setup for +compiles using Mingw32: + + PATH=%PATH%;C:\cygnus\H-i386-cygwin32\bin + SET GCC_EXEC_PREFIX=C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386- + cygwin32\cygnus-2.7.2-961023\ + SET LIBRARY_PATH=/mingw32/lib + SET C_INCLUDE_PATH=/mingw32/include:/mingw32/include/nonansi + SET CPLUS_INCLUDE_PATH=%C_INCLUDE_PATH% + +The mingw32.bat file can be used the same way as the cygwin32.bat file. +Depending on which one you run you will be able to do Mingw32 compiles +or Cygwin32 compiles. Note that whichever one you use you must follow it +with an invocation of win32-api.bat so that libkernel32.a will be in the +library path. + +Setup is now complete, you have complete working Mingw32 and Cygwin32 +compiles available along with the bash shell, tons of UNIX-like +utilities. + +If you had trouble with any of the steps above then the next section is +for you. + + + +2. Troubleshooting Setup Problems + +If you ran into trouble at any stage in the section 1 here are a few +general guidelines as well as some solutions to common problems. + +2.1 Winzip, gunzip or tar Complains of Errors + +Winzip may complain that it could not create a file with garbage +characters in it's name. Gunzip, gzip or tar may complain about +formatting errors. Usually this means that the downloaded file is +corrupted. As of this writing this problem was most commonly caused when +downloading the files from Geocities using Netscape Navigator for +Windows 95 or NT. A combination of a badly set MIME type at Geocities +and a bug in Netscape will corrupt files saved with "Save Link As" (and +clicking on the links would display the files as garbage text). At this +time the only solutions are to use another browser (IE, or Netscape for +UNIX or Apple systems) or to download from the Japanese mirror +(http://www.fu.is.saga-u.ac.jp/~colin/gcc.html). Hopefully Geocities +will eventually fix their problem. + + +2.2 Compile and Link Time Problems: General Steps + +First, evaluate that your environment variables are what you expect them +to be by running the SET command with no arguments (if you are using the +bash shell then the output of env might also be illuminating). Do this +immediately before you attempt a compile in the same window as the +compile. + +Secondly include the '-v' option on the gcc command line. This will give +you far more information on what happens during the compile, especially +important are which specs file is being used and what include file +directories are being read, as well as the arguments to cpp and ld. + +If you send me email about a problem the output of these two general +steps will be very helpful in making a diagnosis. + + +2.3 Cannot exec 'cpp' + +On compiling you get an error message like this: + + GCC.EXE: installation problem, cannot exec `cpp': No such file + or directory + GCC.EXE: Internal compiler error: program cpp got fatal signal 127 + +This means more or less what it says. The program cpp is the C +preprocessor (it strips comments and interprets all those lines +beginning in '#') and running it is the first step in compiling a C or +C++ program. The problem here is that GCC.EXE cannot find CPP.EXE. +Normally CPP.EXE is in the directory C:\cygnus\H-i386-cygwin32\lib\gcc- +lib\i386-cygwin32\cygnus-2.7.2-961023\. If the file is there then +probably the GCC_EXEC_PREFIX environment variable is not correctly set. + + +2.4 Can't Find Include Files + +You get an error like this: + + hello.c:2: No include path in which to find stdio.h + +This, again, means what it says (more or less). The compiler cannot find +the file stdio.h which is #included in the source file hello.c at line +2. Of course the particular file names may differ in your case. If this +is not simply a case of including a really non-existent file or +misspelling the file name then probably your C_INCLUDE_PATH or +CPLUS_INCLUDE_PATH environment variable is wrong. (If not, see "But the +environment variables are right" below.) + + +2.5 Can't Find Libraries + +At link time you get an error like this: + + ld: cannot open -lkernel32: No such file or directory + +This one is a bit cryptic, mainly because the name of the file that +can't be opened is not "-lkernel32" but "libkernel32.a". "-lname" is the +ld command line syntax for linking the library named "libname.a". So +basically this error is saying it can't find libkernel32.a (or whatever +library matches the error you got). If you weren't trying to manually +link in a library that doesn't exist or was misspelled (by accidentally +including the 'lib' or '.a' on the command line for example) then +probably your LIBRARY_PATH environment variable is wrong. (If not, see +"But the environment variables are right" below.) + + +2.6 But the Environment Variables are Right! + +You had one of the problems with not finding include files or libraries +but the environment variables all seem to be pointing at the right +places and the files are all there. + +If you installed on a drive other than C: drive this may be your +problem. The Cygwin DLL, and thus all the basic compiler tools, +automatically map C: drive to (UNIX-style) '/'. Thus /cygnus is actually +C:\cygnus. There are a few ways to fix this (without reinstalling on C: +drive): + + - Map your actual install directory to /cygnus using mount + (mount.exe is included with the Cygnus distribution). Simply + type "mount D:\mydir /cygnus" (assuming you installed in the + directory \mydir on D: drive). Similar tricks can be used for + other directories which you may have installed on other drives. + + - Change the mount of C: to / to the actual install drive. This is + possible by using the registry editor (regedit) included with + Windows. Start the editor and go to the key (or folder) "My + Computer\HKEY_CURRENT_USER\Software\Cygnus Support\CYGWIN.DLL + setup\b15.0\mounts". Under this key there are several numbered + keys. One of them will have the variables "native" set to "c:" and + "unix" set to "/". Change the value of "native" to whatever drive + you did your install on and everything should be fixed. NOTE: You + should probably do this after a fresh boot with no Cygnus based + programs running. + + +2.7 Unresolved References to _impure_ptr and/or _ctype_ etc. + +At link time your code produces unresolved references to _impure_ptr, +_ctype_ and/or _errno, among others. + +This is the result of using the Cygwin header files but linking against +the Mingw32 libraries. I have hopefully managed to fix the bug that used +to cause this problem on any dual installation, but perhaps I haven't. +To check you can run gcc with the -v option and see if the list of +directories searched for include files contains any include directories +with Cygwin headers in them. If everything is working correctly you +should only see the directories on your C_INCLUDE_PATH in this list. + +If you have this problem then you may have to modify the Mingw32 specs +file, specifically the part that says: + +*cpp: +%{posix:-D_POSIX_SOURCE} -iprefix /mingw32/include/ + +These are options that get passed to the C preprocessor by gcc. Consult +the documentation for cpp and try options other than -iprefix. You may +have to use -nostdinc and/or -nostdinc++ plus -I options to get the +correct behavior. + + +2.8 My Program Doesn't Print Any Output OR My Windows Program Creates + A Console Window + +Your console application runs, but doesn't print any output, or your GUI +application runs fine, but always creates an extra console window when +run from Explorer or by double clicking on an icon. + +These are basically two sides of the same coin. You have created a GUI +(or console) application when you meant to create a console (or GUI) +application. By default gcc creates console applications. If you make a +windows GUI application with a WinMain and all that you will still get a +console application if you don't tell gcc what to do at link time. The +relevant options are "-windows" "-Wl,--subsystem,windows" or "-Wl,-- +subsystem,console". The first two, if used on a gcc link line, will +create a proper GUI application. The last will make sure you are making +a console application. + + + +3. Optimizing and Reducing Disk Space Usage + +There are still vast amounts of disk space used by the Cygwin32 +installation on your hard-drive, and much of it can be removed while +still maintaining a fully functional compiler system. The following +sections point out which files you actually need for certain tasks, so +that you won’t delete them. + + +3.1 Bare Minimum + +For C only, Mingw32 compiles which don’t use the Win32 API, and if you +don’t want to produce DLLs or do debugging with any of the GNU tools the +list of files required is as follows: + +In C:\cygnus\H-i386-cygwin32\bin: + ar.exe, as.exe, gcc.exe, ld.exe + +In C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2- +961023: + cc1.exe, cpp.exe, libgcc.a + +In C:\cygnus\win32\lib: + libkernel32.a + +Plus all the files in C:\mingw32\lib and C:\mingw32\include and their +subdirectories. + + +3.2 C++ Support + +To add C++ Support to the above the following extra files are required: + +In C:\cygnus\H-i386-cygwin32\lib\gcc-lib\i386-cygwin32\cygnus-2.7.2- +961023: + cc1plus.exe + +Note that this does not include support for the standard C++ libraries +(only the C run time libraries) or for iostreams. That support is still +only available with the Cygwin32 API. + + +3.3 Extra Utilities of Extreme Usefulness + +Even if you do not use the bash shell or UNIX utilities in general some +of the utilities in C:\cygnus\H-i386-cygwin32\bin are extremely useful +for debugging and probably shouldn’t be deleted if you intend to do any +actual programming using the system. + +These include: + dlltool.exe, gdb.exe, nm.exe, and strip.exe. + + +3.4 Jam + +Jam is a make replacement program that I use pretty much exclusively, +which is why you don't find any Makefile, makefile, makefile.mk or all +that in the stuff that I do. You do find jamfiles and the occaisional +mk.bat file. The executable of Jam is only 80 KB and the program is +incredibly useful, so I would encourage you do download the special +Mingw32 version and check it out. The Mingw32 version has built in rules +for adding resources, building DLLs and import libraries as well as +normal C and C++ files. The source code is, of course, freely available. + +The actual point of this section though, is to point out that to use Jam +you need not only the Jam executable but also rm.exe from the Cygwin +distribution. You also might want to download rcl.exe and res2coff.exe +as these are the helper programs Jam expects to use for resource script +handling. + + +4. Legalities + +All of the code in the Mingw32 package is available as public domain +source. You may use and modify the code as you like. Of course I +encourage you to write software which is free, either public domain or +under the GNU Public License for example, but that is up to you. Linking +with the libraries included with Mingw32 similarly does not impose any +licensing restrictions on your code or binaries. + +The library libgcc.a, which is linked into all code produced with GCC, +is under a special version of the LGPL (as far as I know, you should +check for yourself) which allows the distribution of programs which are +simply linked with unmodified versions of libgcc.a with no licensing +restrictions. + +Thus, using Mingw32, you should be able to produce code with no +licensing restrictions imposed by use of the compiler or libraries. The +Cygwin32 API, and the GNU libraries are another matter and you should +consult their license agreements. + +Again I must stress that I am not a lawyer and the above statements only +reflect my personal understanding of the situation. You would be well +advised to consult the actual text of the appropriate copyright notices +and license agreements if you have any concerns. + + +5. Support + +First of all, the Mingw32 code is supplied AS IS with NO WARRANTY either +EXPRESS or IMPLIED. + +There is also no support staff standing by to take your calls. There +are, however, a few people, including myself, using Mingw32 who might be +able to help you. If you have problems you can email me at +colin@bird.fu.is.saga-u.ac.jp and I will try to get back to you. No +guarantees, but I will do my best. + + +6. Suggestions and Contributions + +If you find a bug in the Mingw32 files themselves then feel free to +report it, or even better to supply a fix, by emailing me at +colin@bird.fu.is.saga-u.ac.jp. Any fixes I receive will probably go into +the next release, and if they seem high-priority I may put the patched +files on my web page until I can make a complete release. Please note +that if you supply code it must be in the public domain or I cannot +include it in Mingw32. Please attach an appropriate legal message to the +code or otherwise make sure that there are no copyright issues. Of +course if you just suggest a possible method for solving a problem or +point out a bug then there should be no need for all that. + +Note that the Win32 API header files are not actually part of the +Mingw32 package. I know there are many bugs and omissions, and I try to +keep informed about them, so I do appreciate mail pointing them out. +However I can’t fix these problems at the source. You should send email +to Scott Christley (the author of the GPL windows32-api) or possibly to +Cygnus. Sending email to me might get me to mention it on my homepage or +fix it in my personal copy of the header files, but that’s about it +(sorry). + +Aside from bug reports, suggestions for improvements, testing of the +header files and otherwise praise or criticism is all welcome in my +inbox. + +Good luck, +Colin Peters (colin@bird.fu.is.saga-u.ac.jp) + diff --git a/winsup/mingw/samples/dirent/jamfile b/winsup/mingw/samples/dirent/jamfile new file mode 100644 index 000000000..4bfdc2461 --- /dev/null +++ b/winsup/mingw/samples/dirent/jamfile @@ -0,0 +1,3 @@ + +Main test.exe : test.c ; + diff --git a/winsup/mingw/samples/dirent/test.c b/winsup/mingw/samples/dirent/test.c new file mode 100644 index 000000000..bb4629fea --- /dev/null +++ b/winsup/mingw/samples/dirent/test.c @@ -0,0 +1,91 @@ +/* + * A test which demonstrates the use of opendir and related functions + * declared in dirent.h. + */ + +#include +#include +#include + +#include + +int +main (int argc, char* argv[]) +{ + int i; + struct dirent* de; + DIR* dir; + long lPos; + + if (argc == 2) + { + printf ("Opening directory \"%s\"\n", argv[1]); + dir = opendir(argv[1]); + } + else + { + printf ("Opening \".\"\n"); + dir = opendir("."); + } + + if (!dir) + { + printf ("Directory open failed!\n"); + if (errno) + { + printf ("Error : %s\n", strerror(errno)); + } + return 1; + } + + i = 0; + lPos = -1; + + while (de = readdir (dir)) + { + i++; + printf ("%d : \"%s\" (tell %ld)\n", i, de->d_name, + telldir(dir)); + + if (i == 3) + { + printf ("We will seek here later.\n"); + lPos = telldir (dir); + } + } + + printf ("Rewind directory.\n"); + rewinddir (dir); + + if (de = readdir (dir)) + { + printf ("First entry : \"%s\"\n", de->d_name); + } + else + { + printf ("Empty directory.\n"); + } + + if (lPos != -1) + { + printf ("Seeking to fourth entry.\n"); + seekdir (dir, lPos); + + if (de = readdir (dir)) + { + printf ("Fourth entry : \"%s\"\n", de->d_name); + } + else + { + printf ("No fourth entry.\n"); + } + } + else + { + printf ("Seek position is past end of directory.\n"); + } + + printf ("Closing directory.\n"); + closedir (dir); +} + diff --git a/winsup/mingw/samples/dlltest/dll.c b/winsup/mingw/samples/dlltest/dll.c new file mode 100644 index 000000000..ba00fab3e --- /dev/null +++ b/winsup/mingw/samples/dlltest/dll.c @@ -0,0 +1,22 @@ +/* + * Source code of the functions inside our test DLL. Note that DllMain is + * not required (it will be provided by the stub in libmingw32.a). + */ + +#if 0 +#include +#endif + +int Add (int x, int y) +{ + printf ("In add!\nx = %d\ny = %d\n", x, y); + return (x + y); +} + + +double __attribute__((stdcall)) Sub (double x, double y) +{ + printf ("In sub!\nx = %f\ny = %f\n", x, y); + return (x - y); +} + diff --git a/winsup/mingw/samples/dlltest/dll.def b/winsup/mingw/samples/dlltest/dll.def new file mode 100644 index 000000000..4572319b3 --- /dev/null +++ b/winsup/mingw/samples/dlltest/dll.def @@ -0,0 +1,3 @@ +EXPORTS +Add +Sub@16 diff --git a/winsup/mingw/samples/dlltest/dll.h b/winsup/mingw/samples/dlltest/dll.h new file mode 100644 index 000000000..35faa4c32 --- /dev/null +++ b/winsup/mingw/samples/dlltest/dll.h @@ -0,0 +1,4 @@ + +int Add (int x, int y); +double __attribute__((stdcall)) Sub (double x, double y); + diff --git a/winsup/mingw/samples/dlltest/exe.c b/winsup/mingw/samples/dlltest/exe.c new file mode 100644 index 000000000..06a580a67 --- /dev/null +++ b/winsup/mingw/samples/dlltest/exe.c @@ -0,0 +1,23 @@ +#include + +#include "dll.h" + +int main() +{ + int i, j, k; + double dk; + + i = 10; + j = 13; + + k = Add(i, j); + + printf ("%d + %d = %d\n", i, j, k); + + dk = Sub(i, j); + + printf ("%d - %d = %f\n", i, j, dk); + + return 0; +} + diff --git a/winsup/mingw/samples/dlltest/exe.exp b/winsup/mingw/samples/dlltest/exe.exp new file mode 100644 index 000000000..584b5306b --- /dev/null +++ b/winsup/mingw/samples/dlltest/exe.exp @@ -0,0 +1,8 @@ +In add! +x = 10 +y = 13 +10 + 13 = 23 +In sub! +x = 10 +y = 13 +10 - 13 = -3 diff --git a/winsup/mingw/samples/dlltest/expexe.c b/winsup/mingw/samples/dlltest/expexe.c new file mode 100644 index 000000000..10a8f08b1 --- /dev/null +++ b/winsup/mingw/samples/dlltest/expexe.c @@ -0,0 +1,17 @@ + +#include + +int +ExportedFromExe () +{ + printf ("This output produced by ExportedFromExe.\n"); + return 0; +} + +int main() +{ + printf ("Hello, world\n"); + + return 0; +} + diff --git a/winsup/mingw/samples/dlltest/expexe.def b/winsup/mingw/samples/dlltest/expexe.def new file mode 100644 index 000000000..fa0aa2856 --- /dev/null +++ b/winsup/mingw/samples/dlltest/expexe.def @@ -0,0 +1,2 @@ +EXPORTS +ExportedFromExe diff --git a/winsup/mingw/samples/dlltest/jamfile b/winsup/mingw/samples/dlltest/jamfile new file mode 100644 index 000000000..5278d0379 --- /dev/null +++ b/winsup/mingw/samples/dlltest/jamfile @@ -0,0 +1,46 @@ + +# This option is required to successfully return doubles via STDCALL as in +# Sub function in dll.c. +CCFLAGS = -mno-fp-ret-in-387 ; + +Main exe.exe : exe.c ; + +LinkLibraries exe.exe : libdll.a ; + +DEPENDS exe.exe : dll.dll ; + +LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ; + + +Main loaddll.exe : loaddll.c ; + +DEPENDS loaddll.exe : dll.dll ; + + +Dll dll.dll : dll.c ; + +ImportLib libdll.a : dll.def ; + + +Main expexe.exe : expexe.c ; + +# Force the executable to include the expexe.def file. +Exports expexe.exe : expexe.def ; + +Main loadexe.exe : loadexe.c ; + +DEPENDS loadexe.exe : expexe.exe ; + + +Main silly.exe : silly.cpp ; + +LinkLibraries silly.exe : libsilly.a ; + +DEPENDS silly.exe : silly.dll ; + +LINKFLAGS on silly.exe += -L. ; + +Dll silly.dll : sillydll.cpp ; + +ImportLib libsilly.a : silly.def ; + diff --git a/winsup/mingw/samples/dlltest/loaddll.c b/winsup/mingw/samples/dlltest/loaddll.c new file mode 100644 index 000000000..bbb34a3c9 --- /dev/null +++ b/winsup/mingw/samples/dlltest/loaddll.c @@ -0,0 +1,40 @@ +/* + * This version attempts to load dll.dll dynamically, get the address of the + * Add function, and then call it. + */ + +#include +#include + +int (*Add)(int x, int y); + +int main() +{ + HINSTANCE hDll; + int i, j, k; + + hDll = LoadLibrary ("dll.dll"); + if (!hDll) + { + printf ("Error %d loading dll.\n", GetLastError()); + exit (-1); + } + + if (!(Add = GetProcAddress (hDll, "Add"))) + { + printf ("Error %d getting Add function.\n", GetLastError()); + exit (-1); + } + + i = 10; + j = 13; + + k = Add(i, j); + + printf ("i %d, j %d, k %d\n", i, j, k); + + FreeLibrary (hDll); + + return 0; +} + diff --git a/winsup/mingw/samples/dlltest/loadexe.c b/winsup/mingw/samples/dlltest/loadexe.c new file mode 100644 index 000000000..c5a84dc01 --- /dev/null +++ b/winsup/mingw/samples/dlltest/loadexe.c @@ -0,0 +1,47 @@ +/* + * This program attempts to load expexe.exe dynamically, get the address of the + * ExportedFromExe function, and then call it. + * + * This example DOES NOT WORK! I don't know exactly what can be done, but + * it simply seems that LoadLibrary refuses to load executables. + */ + +#include +#include + +int (*ExportedFromExe)(); + +int main() +{ + HINSTANCE hDll; + int i, j, k; + + hDll = LoadLibrary ("expexe.exe"); + if (!hDll) + { + printf ("Error %d loading exe.\n", GetLastError()); + exit (-1); + } + + if (!(ExportedFromExe = GetProcAddress (hDll, "ExportedFromExe"))) + { + printf ("Error %d getting ExportedFromExe function.\n", + GetLastError()); + exit (-1); + } + else + { + ExportedFromExe (); + } + + /* NOTE: Unlike a DLL the exe doesn't have an entry point which + * initializes global objects and adds __do_global_dtors to + * the atexit list. Thus it should be safe(?) to free the + * library. Of course, this also makes it unsafe to use + * executables at all in this manner. + */ + FreeLibrary (hDll); + + return 0; +} + diff --git a/winsup/mingw/samples/dlltest/readme.txt b/winsup/mingw/samples/dlltest/readme.txt new file mode 100644 index 000000000..a46dd23a5 --- /dev/null +++ b/winsup/mingw/samples/dlltest/readme.txt @@ -0,0 +1,39 @@ +This directory contains two examples of building DLLs. The exe.c and dll.c +files are used to build a very simple example DLL with a function that +adds two numbers together (and prints some text at the same time). The +exe.c program links to the DLL and prints the results of the function +call. + +The C++ example "silly" is more interesting because it involves a DLL which +contains the code for a C++ class. The CSilly class has all of its code in +the sillydll.cpp source file, which is used to build the silly.dll. The +silly.cpp source code builds the main silly.exe executable which makes a +dynamic instance of the object and calls its member functions. + +The C++ silly.def file was generated by doing a nm of sillydll.o after it +was generated and then getting the symbol names from that. Removing the +leading underscore produces the appropriate name to include in the EXPORTS +section. Notice there are a few weird functions. + +Since there are now several different versions of the GNU compiler capable +of doing this, and they each seem to have different requirements for exports +for classes, it has gotten kind of messy. The silly.def file here is for +use with the native Mingw32 build of the EGCS version of GCC. The silly.def.old +file was the def file I used when I was using Jan-Jaap's Mingw32 native port +of GCC. The Cygnus version is different again, if I recall correctly, but I +don't have it hanging around anymore. + +The jamfile builds all the components from the raw sources. + +The expected output of exe.exe and silly.exe are in the files exe.exp +and silly.exp. + + +The source code in this directory is in the PUBLIC DOMAIN and can be +used or abused as you see fit. There is NO WARRANTY for this code, +including (but not limited to) implied warranties of MERCHANTABILITY +or FITNESS FOR A PARTICULAR PURPOSE. + + +Colin Peters + diff --git a/winsup/mingw/samples/dlltest/silly.cpp b/winsup/mingw/samples/dlltest/silly.cpp new file mode 100644 index 000000000..70f5af5c7 --- /dev/null +++ b/winsup/mingw/samples/dlltest/silly.cpp @@ -0,0 +1,55 @@ +// +// C++ test of a dll which contains a C++ class. +// + +#include +#include + +// Interface of class. +#include "silly.h" + +#ifdef DERIVED_TEST +// Here is a derived class too. +class CMoreSilly : public CSilly +{ + public: + CMoreSilly (char* szNewName) : CSilly (szNewName) {}; + ~CMoreSilly (); + + WhatsYourName(); +}; + +CMoreSilly:: +~CMoreSilly () +{ + printf ("In CMoreSilly \"%s\" destructor!\n", szName); +} + +CMoreSilly:: +WhatsYourName () +{ + printf ("I'm more silly and my name is \"%s\"\n", szName); +} +#endif + +int +main () +{ + CSilly* psilly = new CSilly("silly"); + + psilly->WhatsYourName(); + psilly->Poke(); // Poke him, he should say "Ouch!" + psilly->Stab(4); // Stab him four times he should say "Ugh!!!!" + + delete psilly; + +#ifdef DERIVED_TEST + psilly = new CMoreSilly("more silly"); + psilly->WhatsYourName(); + psilly->Stab(5); + delete psilly; +#endif + + return 0; +} + diff --git a/winsup/mingw/samples/dlltest/silly.def b/winsup/mingw/samples/dlltest/silly.def new file mode 100644 index 000000000..6733e5df7 --- /dev/null +++ b/winsup/mingw/samples/dlltest/silly.def @@ -0,0 +1,11 @@ +EXPORTS +DllMain@12 +Poke__6CSilly +Stab__6CSillyi +WhatsYourName__6CSilly +_$_6CSilly +__6CSilly +__6CSillyPc +__tf6CSilly +__ti6CSilly +_vt$6CSilly diff --git a/winsup/mingw/samples/dlltest/silly.exp b/winsup/mingw/samples/dlltest/silly.exp new file mode 100644 index 000000000..386e81c1c --- /dev/null +++ b/winsup/mingw/samples/dlltest/silly.exp @@ -0,0 +1,8 @@ +I'm silly. +Ouch! +Ugh!!!! +In CSilly destructor. +I'm more silly and my name is "more silly" +Ugh!!!!! +In CMoreSilly "more silly" destructor! +In CSilly destructor. diff --git a/winsup/mingw/samples/dlltest/silly.h b/winsup/mingw/samples/dlltest/silly.h new file mode 100644 index 000000000..007b0f5d7 --- /dev/null +++ b/winsup/mingw/samples/dlltest/silly.h @@ -0,0 +1,27 @@ + +#define DERIVED_TEST 1 + +class CSilly +{ + protected: + char* szName; + + public: + CSilly(); + CSilly(char* szName); +#ifdef DERIVED_TEST + virtual ~CSilly(); +#else + ~CSilly(); +#endif + + Poke (); + Stab (int nTimes); +#ifdef DERIVED_TEST + virtual WhatsYourName (); +#else + WhatsYourName (); +#endif + +}; + diff --git a/winsup/mingw/samples/dlltest/sillydll.cpp b/winsup/mingw/samples/dlltest/sillydll.cpp new file mode 100644 index 000000000..bd5ccea30 --- /dev/null +++ b/winsup/mingw/samples/dlltest/sillydll.cpp @@ -0,0 +1,107 @@ + +#include +#include +#include +#include + + +#if 0 +#define STREAMS_VERSION +#endif + +#if defined(STREAMS_VERSION) +#include +#endif + +#include "silly.h" + +extern "C" +BOOL WINAPI DllMain(HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + return TRUE; +} + +CSilly:: +CSilly() +{ + szName = NULL; +} + +CSilly:: +CSilly(char* new_szName) +{ + szName = new char[strlen(new_szName)+1]; + + if (szName) + { + strcpy (szName, new_szName); + } +} + +CSilly:: +~CSilly() +{ + printf ("In CSilly destructor.\n"); + if (szName) + { + delete szName; + } +} + +CSilly:: +Poke () +{ +#ifndef STREAMS_VERSION + printf ("Ouch!\n"); +#else + cout << "Ouch!" << endl; +#endif +} + +CSilly:: +Stab (int nTimes) +{ +#ifndef STREAMS_VERSION + printf ("Ugh"); +#else + cout << "Ugh"; +#endif + + int i; + for (i = 0; i < nTimes; i++) + { +#ifndef STREAMS_VERSION + putchar('!'); +#else + cout << '!' ; +#endif + } + +#ifndef STREAMS_VERSION + putchar('\n'); +#else + cout << endl; +#endif +} + +CSilly:: +WhatsYourName () +{ + if (szName) + { +#ifndef STREAMS_VERSION + printf ("I'm %s.\n", szName); +#else + cout << "I'm " << szName << "." << endl; +#endif + } + else + { +#ifndef STREAMS_VERSION + printf ("I have no name.\n"); +#else + cout << "I have no name." << endl; +#endif + } +} + diff --git a/winsup/mingw/samples/filehand/filehand.c b/winsup/mingw/samples/filehand/filehand.c new file mode 100644 index 000000000..24e048c52 --- /dev/null +++ b/winsup/mingw/samples/filehand/filehand.c @@ -0,0 +1,57 @@ +/* + * An example showing how you can obtain the UNIX-ish file number from a + * FILE* and in turn how you can get the Win32 HANDLE of the file from + * the file number. + * + * This code is in the PUBLIC DOMAIN and has NO WARRANTY. + * + * Colin Peters + */ + +#include +#include +#include + +int +main (int argc, char* argv[]) +{ + char* szFileName; + FILE* fileIn; + int fnIn; + HANDLE hFileIn; + char caBuf[81]; + int nRead; + + if (argc >= 2) + { + szFileName = argv[1]; + } + else + { + szFileName = "junk.txt"; + } + + fileIn = fopen (szFileName, "r"); + + if (!fileIn) + { + printf ("Could not open %s for reading\n", szFileName); + exit(1); + } + + fnIn = fileno (fileIn); + hFileIn = (HANDLE) _get_osfhandle (fnIn); + + printf ("OS file handle %d\n", (int) hFileIn); + + ReadFile (hFileIn, caBuf, 80, &nRead, NULL); + + printf ("Read %d bytes using ReadFile.\n", nRead); + + caBuf[nRead] = '\0'; + + printf ("\"%s\"\n", caBuf); + + fclose (fileIn); +} + diff --git a/winsup/mingw/samples/filehand/jamfile b/winsup/mingw/samples/filehand/jamfile new file mode 100644 index 000000000..6f29c3758 --- /dev/null +++ b/winsup/mingw/samples/filehand/jamfile @@ -0,0 +1,3 @@ + +Main filehand.exe : filehand.c ; + diff --git a/winsup/mingw/samples/filehand/junk.txt b/winsup/mingw/samples/filehand/junk.txt new file mode 100644 index 000000000..f933c546e --- /dev/null +++ b/winsup/mingw/samples/filehand/junk.txt @@ -0,0 +1 @@ +This is a test file. diff --git a/winsup/mingw/samples/fixargv/fixargv.c b/winsup/mingw/samples/fixargv/fixargv.c new file mode 100644 index 000000000..50c24cd06 --- /dev/null +++ b/winsup/mingw/samples/fixargv/fixargv.c @@ -0,0 +1,290 @@ +/* + * fixargv.c + * + * A special function which "fixes" an argv array by replacing arguments + * that need quoting with quoted versions. + * + * NOTE: In order to be reasonably consistent there is some misuse of the + * const keyword here-- which leads to compilation warnings. These + * should be ok to ignore. + * + * This is a sample distributed as part of the Mingw32 package. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include +#include "fixargv.h" + +/* + * This takes a single string and fixes it, enclosing it in quotes if it + * contains any spaces and/or escaping the quotes it contains. + */ +char* +fix_arg (const char* szArg) +{ + int nQuoteAll; /* Does the whole arg need quoting? */ + int nBkSlRun; /* How may backslashes in a row? */ + char* sz; + char* szNew; + size_t sizeLen; + + nQuoteAll = 0; + nBkSlRun = 0; + sz = szArg; + sizeLen = 1; + + /* First we figure out how much bigger the new string has to be + * than the old one. */ + while (*sz != '\0') + { + /* + * Arguments containing whitespace of wildcards will be + * quoted to preserve tokenization and/or those special + * characters (i.e. wildcarding will NOT be done at the + * other end-- they will get the * and ? characters as is). + * TODO: Is this the best way? Do we want to enable wildcards? + * If so, when? + */ + if (!nQuoteAll && + (*sz == ' ' || *sz == '\t' || *sz == '*' || *sz == '?')) + { + nQuoteAll = 1; + } + else if (*sz == '\\') + { + nBkSlRun++; + } + else + { + if (*sz == '\"') + { + sizeLen += nBkSlRun + 1; + } + nBkSlRun = 0; + } + + sizeLen++; + sz++; + } + + if (nQuoteAll) + { + sizeLen += 2; + } + + /* + * Make a new string big enough. + */ + szNew = (char*) malloc (sizeLen); + if (!szNew) + { + return NULL; + } + sz = szNew; + + /* First enclosing quote for fully quoted args. */ + if (nQuoteAll) + { + *sz = '\"'; + sz++; + } + + /* + * Go through the string putting backslashes in front of quotes, + * and doubling all backslashes immediately in front of quotes. + */ + nBkSlRun = 0; + while (*szArg != '\0') + { + if (*szArg == '\\') + { + nBkSlRun++; + } + else + { + if (*szArg == '\"') + { + while (nBkSlRun > 0) + { + *sz = '\\'; + sz++; + nBkSlRun--; + } + *sz = '\\'; + sz++; + } + nBkSlRun = 0; + } + + *sz = *szArg; + sz++; + szArg++; + } + + /* Closing quote for fully quoted args. */ + if (nQuoteAll) + { + *sz = '\"'; + sz++; + } + + *sz = '\0'; + return szNew; +} + +/* + * Takes argc and argv and returns a new argv with escaped members. Pass + * this fixed argv (along with the old one) to free_fixed_argv after + * you finish with it. Pass in an argc of -1 and make sure the argv vector + * ends with a null pointer to have fix_argv count the arguments for you. + */ +char* const* +fix_argv (int argc, char* const* szaArgv) +{ + char** szaNew; + char* sz; + int i; + + if (!szaArgv) + { + return NULL; + } + + /* + * Count the arguments if asked. + */ + if (argc == -1) + { + for (i = 0; szaArgv[i]; i++) + ; + + argc = i; + } + + /* + * If there are no args or only one arg then do no escaping. + */ + if (argc < 2) + { + return szaArgv; + } + + for (i = 1, szaNew = NULL; i < argc; i++) + { + sz = szaArgv[i]; + + /* + * If an argument needs fixing, then fix it. + */ + if (strpbrk (sz, "\" \t*?")) + { + /* + * If we haven't created a new argv list already + * then make one. + */ + if (!szaNew) + { + szaNew = (char**) malloc ((argc + 1) * + sizeof (char*)); + if (!szaNew) + { + return NULL; + } + + /* + * Copy previous args from old to new. + */ + memcpy (szaNew, szaArgv, sizeof(char*) * i); + } + + /* + * Now do the fixing. + */ + szaNew[i] = fix_arg (sz); + if (!szaNew[i]) + { + /* Fixing failed, free up and return error. */ + free_fixed_argv (szaNew, szaArgv); + return NULL; + } + } + else if (szaNew) + { + szaNew[i] = sz; + } + } + + if (szaNew) + { + /* If we have created a new argv list then we might as well + * terminate it nicely. (And we depend on it in + * free_fixed_argv.) */ + szaNew[argc] = NULL; + } + else + { + /* If we didn't create a new argv list then return the + * original. */ + return szaArgv; + } + + return szaNew; +} + +void +free_fixed_argv (char* const* szaFixed, char* const* szaOld) +{ + char* const* sza; + + /* + * Check for error conditions. Also note that if no corrections + * were required the fixed argv will actually be the same as + * the old one, and we don't need to do anything. + */ + if (!szaFixed || !szaOld || szaFixed == szaOld) + { + return; + } + + /* + * Go through all members of the argv list. If any of the + * members in the fixed list are different from the old + * list we free those members. + * NOTE: The first member is never modified, so we don't need to + * check. + */ + sza = szaFixed + 1; + szaOld++; + while (*sza) + { + if (*sza != *szaOld) + { + free (*sza); + } + sza++; + szaOld++; + } + + /* + * Now we can free the array of char pointers itself. + */ + free (szaFixed); +} + diff --git a/winsup/mingw/samples/fixargv/fixargv.h b/winsup/mingw/samples/fixargv/fixargv.h new file mode 100644 index 000000000..0e6222660 --- /dev/null +++ b/winsup/mingw/samples/fixargv/fixargv.h @@ -0,0 +1,24 @@ +/* + * fixargv.h + * + * Prototypes of utility functions for 'properly' escaping argv vectors. + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#ifndef _FIXARGV_H_ +#define _FIXARGV_H_ + +char* fix_arg (const char* szArg); +char* const* fix_argv (int argc, char* const* szaArgv); +void free_fixed_argv (char* const* szaFixed, char* const* szaOld); + +#endif diff --git a/winsup/mingw/samples/fixargv/readme.txt b/winsup/mingw/samples/fixargv/readme.txt new file mode 100644 index 000000000..14048f534 --- /dev/null +++ b/winsup/mingw/samples/fixargv/readme.txt @@ -0,0 +1,85 @@ + +This code is a utility function I was considering adding to Mingw32. The +Microsoft versions of argc, argv construction use quotes and backslashes +to allow the user to pass arguments containing spaces (or quotes) to +programs they invoke. The rules are + + - Arguments containing spaces must be enclosed in quotes. + - A quote can be passed by preceeding it with a backslash. + - Backslashes immediately preceeding a quote must be doubled to avoid + escaping the quote. + +Thus an argument like: + + -D="Foo Bar\\" + +needs to be mangled as: + + "-D\"Foo Bar\\\\\"" + +in order to get to the program as what was intended above. + +The fix_argv set of functions is meant to be used with spawnv and the +like to allow a program to set up an argv array for the spawned program +and have that array duplicated *exactly* in the spawned program, no +matter what it contains (it also quotes 'globbing' characters like * +and ?, so it does not matter if the destination has globbing turned on +or not; it might be a reasonable extension to allow a flag to allow +globbing characters to pass through unmolested, but they would still +be quoted if the string contained whitespace). + +The reason for writing this came up because of problems with arguments +like -DBLAH="Foo Bar" to GCC (define BLAH as a preprocessor constant +being the string "Foo Bar", including the quotes). Because GCC simply +passes the argument directly to CPP (the preprocessor) it had to be +escaped *twice*: + + "-DBLAH=\"\\\"Foo Bar\\\"\"" + +This would reach GCC as + + -DBLAH="\"Foo Bar\"" + +And that would reach CPP as the desired + + -DBLAH="Foo Bar" + +One level of quoting and escaping is to be expected (although MS's +standard is, arguably, not very good), but forcing the user to know +how many different programs the argument is going to pass through, +and perform double quoting and escaping, seems unreasonable. If +GCC and friends all used fix_argv (they use their own version of +it now) then the original argument could be + + "-DBLAH=\"Foo Bar\"" + +And that would work fine, no matter how many different tools it +passed through. + +The only basic limitation with this code is that it assumes that all +the spawned programs use Microsoft-type escaping when interpreting +their command line. Most programs on Win32 machines do (anything +compiled with Mingw32 will). + +For now, this code has been relegated to 'sample' status. If you want +to use it, feel free (it is public domain after all). + +Colin. + +P.S. Just out of interest you might try writing your own little program + to look at the interaction of wildcards and quotes. Use the glob.exe + program in ../globbing and see what it does with + + glob "foo*.txt" + + even if there are files foo.txt and foobar.txt in the same directory. + + Note that + + del "My *.txt" + + works (i.e. it deletes all files starting with My). This could + not be done unless del does globbing *after* processing escapes and + quotes, which is not the way it seems to work normally (again see + the glob example). + diff --git a/winsup/mingw/samples/fmode/all.c b/winsup/mingw/samples/fmode/all.c new file mode 100644 index 000000000..52f93d1c1 --- /dev/null +++ b/winsup/mingw/samples/fmode/all.c @@ -0,0 +1,46 @@ +/* + * A sample program demonstrating how to use _CRT_fmode to change the default + * file opening mode to binary AND change stdin, stdout and stderr. Redirect + * stdout to a file from the command line to see the difference. + * + * Also try directing a file into stdin. If you type into stdin you will get + * \r\n at the end of every line... unlike UNIX. But at least if you + * redirect a file in you will get exactly the characters in the file as input. + * + * THIS CODE IS IN THE PUBLIC DOMAIN. + * + * Colin Peters + */ + +#include +#include + +unsigned int _CRT_fmode = _O_BINARY; + +main () +{ + char* sz = "This is line one.\nThis is line two.\n"; + FILE* fp; + int c; + + printf (sz); + + /* Note how this fopen does NOT indicate "wb" to open the file in + * binary mode. */ + fp = fopen ("all.out", "w"); + + fprintf (fp, sz); + + fclose (fp); + + if (_isatty (_fileno(stdin))) + { + fprintf (stderr, "Waiting for input, press Ctrl-Z to finish.\n"); + } + + while ((c = fgetc(stdin)) != EOF) + { + printf ("\'%c\' %02X\n", (char) c, c); + } +} + diff --git a/winsup/mingw/samples/fmode/jamfile b/winsup/mingw/samples/fmode/jamfile new file mode 100644 index 000000000..2c7f7d32f --- /dev/null +++ b/winsup/mingw/samples/fmode/jamfile @@ -0,0 +1,5 @@ + +Main test.exe : test.c ; + +Main all.exe : all.c ; + diff --git a/winsup/mingw/samples/fmode/readme.txt b/winsup/mingw/samples/fmode/readme.txt new file mode 100644 index 000000000..873b853d3 --- /dev/null +++ b/winsup/mingw/samples/fmode/readme.txt @@ -0,0 +1,5 @@ + +These two demos show how _fmode and _CRT_fmode can be used to modify the +default file opening mode (text vs. binary) and/or the mode of the standard +file handles. + diff --git a/winsup/mingw/samples/fmode/test.c b/winsup/mingw/samples/fmode/test.c new file mode 100644 index 000000000..f19e7e0ec --- /dev/null +++ b/winsup/mingw/samples/fmode/test.c @@ -0,0 +1,31 @@ +/* + * A sample program demonstrating how to use fmode to change the default + * file opening mode to binary. NOTE: Does not change stdin, stdout or + * stderr. + * + * THIS CODE IS IN THE PUBLIC DOMAIN. + * + * Colin Peters + */ + +#include +#include /* Required to get _fmode and _O_BINARY */ + +main () +{ + char* sz = "This is line one.\nThis is line two.\n"; + FILE* fp; + + _fmode = _O_BINARY; + + printf (sz); + + /* Note how this fopen does NOT indicate "wb" to open the file in + * binary mode. */ + fp = fopen ("test.out", "w"); + + fprintf (fp, sz); + + fclose (fp); +} + diff --git a/winsup/mingw/samples/globbing/glob.c b/winsup/mingw/samples/globbing/glob.c new file mode 100644 index 000000000..6bf8acaee --- /dev/null +++ b/winsup/mingw/samples/globbing/glob.c @@ -0,0 +1,20 @@ + +#include +#include +#include + +int +main (int argc, char* argv[]) +{ + int i; + + printf ("Command line (via GetCommandLine) \"%s\"\n", + GetCommandLine()); + + for (i = 0; i < argc; i++) + { + printf ("Argv[%d] \"%s\"\n", i, argv[i]); + } + + return 0; +} diff --git a/winsup/mingw/samples/globbing/jamfile b/winsup/mingw/samples/globbing/jamfile new file mode 100644 index 000000000..ff3a585d6 --- /dev/null +++ b/winsup/mingw/samples/globbing/jamfile @@ -0,0 +1,11 @@ + +Object glob.o : glob.c ; + +MainFromObjects glob.exe : glob.o ; + +Main noglob.exe : noglob.c ; + +LIBDIR = \\mingw32\\lib\\ ; + +MainFromObjects CRTnoglob.exe : glob.o $(LIBDIR)CRT_noglob.o ; + diff --git a/winsup/mingw/samples/globbing/noglob.c b/winsup/mingw/samples/globbing/noglob.c new file mode 100644 index 000000000..8bc4c82a3 --- /dev/null +++ b/winsup/mingw/samples/globbing/noglob.c @@ -0,0 +1,22 @@ + +#include +#include +#include + +/* This line turns off automatic command line globbing. */ +int _CRT_glob = 0; + +int +main (int argc, char* argv[]) +{ + int i; + + printf ("Command line (via GetCommandLine) \"%s\"\n", + GetCommandLine()); + for (i = 0; i < argc; i++) + { + printf ("Argv[%d] \"%s\"\n", i, argv[i]); + } + + return 0; +} diff --git a/winsup/mingw/samples/globbing/readme.txt b/winsup/mingw/samples/globbing/readme.txt new file mode 100644 index 000000000..5e20de826 --- /dev/null +++ b/winsup/mingw/samples/globbing/readme.txt @@ -0,0 +1,14 @@ + +This directory contains samples which demonstrate default (globbing on) +behavior, how to turn the globbing off with the _CRT_glob variable, and +how to turn it off with the CRT_noglob object file. + +Run jam and then run glob, noglob and CRTnoglob with an argument like +*.* to see the difference. + +The code in this directory is in the PUBLIC DOMAIN. It has NO WARRANTY, +including, but not restricted to, warranties of MERCHANTABILITY or +FITNESS FOR A PARTICULAR PURPOSE. + +Colin Peters . + diff --git a/winsup/mingw/samples/print/jamfile b/winsup/mingw/samples/print/jamfile new file mode 100644 index 000000000..f5395339d --- /dev/null +++ b/winsup/mingw/samples/print/jamfile @@ -0,0 +1,9 @@ +# +# A simple example which prints a message on a selected printer. This won't +# work right unless you make PRINTDLG a packed structure! +# + +Main prntest.exe : prntest.c ; + +Gui prntest.exe ; + diff --git a/winsup/mingw/samples/print/prntest.c b/winsup/mingw/samples/print/prntest.c new file mode 100644 index 000000000..801d1d885 --- /dev/null +++ b/winsup/mingw/samples/print/prntest.c @@ -0,0 +1,65 @@ + +#include +#include +#include +#include + +main () +{ + PRINTDLG pd; + DOCINFO di; + char* szMessage; + + memset (&pd, 0, sizeof(PRINTDLG)); + memset (&di, 0, sizeof(DOCINFO)); + + di.cbSize = sizeof(DOCINFO); + di.lpszDocName = "Test"; + + pd.lStructSize = sizeof(PRINTDLG); + pd.Flags = PD_PAGENUMS | PD_RETURNDC; + pd.nFromPage = 1; + pd.nToPage = 1; + pd.nMinPage = 1; + pd.nMaxPage = 1; + + szMessage = 0; + + if (PrintDlg (&pd)) + { + if (pd.hDC) + { + if (StartDoc (pd.hDC, &di) != SP_ERROR) + { + StartPage (pd.hDC); + + TextOut (pd.hDC, 0, 0, "Hello, printer!", 15); + + EndPage (pd.hDC); + + EndDoc (pd.hDC); + + szMessage = "Printed."; + } + else + { + szMessage = "Could not start document."; + } + } + else + { + szMessage = "Could not create device context."; + } + } + else + { + szMessage = "Canceled or printer could not be setup."; + } + + if (szMessage) + { + MessageBox (NULL, szMessage, "Print Test", MB_OK); + } + + return 0; +} diff --git a/winsup/mingw/samples/seh/eh3.c b/winsup/mingw/samples/seh/eh3.c new file mode 100644 index 000000000..e00201904 --- /dev/null +++ b/winsup/mingw/samples/seh/eh3.c @@ -0,0 +1,112 @@ +int +__except_handler3( + struct _EXCEPTION_RECORD* pExceptionRecord, + struct EXCEPTION_REGISTRATION* pRegistrationFrame, + struct _CONTEXT* pContextRecord, + void* pDispatcherContext + ) +{ + LONG filterFuncRet; + LONG trylevel; + EXCEPTION_POINTERS exceptPtrs; + PSCOPETABLE pScopeTable; + + + CLD // Clear the direction flag (make no assumptions!) + + // if neither the EXCEPTION_UNWINDING nor EXCEPTION_EXIT_UNWIND bit + // is set... This is true the first time through the handler (the + // non-unwinding case) + + if ( ! (pExceptionRecord->ExceptionFlags + & (EXCEPTION_UNWINDING | EXCEPTION_EXIT_UNWIND) + ) ) + { + // Build the EXCEPTION_POINTERS structure on the stack + exceptPtrs.ExceptionRecord = pExceptionRecord; + exceptPtrs.ContextRecord = pContextRecord; + + // Put the pointer to the EXCEPTION_POINTERS 4 bytes below the + // establisher frame. See ASM code for GetExceptionInformation + *(PDWORD)((PBYTE)pRegistrationFrame - 4) = &exceptPtrs; + + // Get initial "trylevel" value + trylevel = pRegistrationFrame->trylevel + + // Get a pointer to the scopetable array + scopeTable = pRegistrationFrame->scopetable; + +search_for_handler: + if ( pRegistrationFrame->trylevel != TRYLEVEL_NONE ) + { + if ( pRegistrationFrame->scopetable[trylevel].lpfnFilter ) + { + + PUSH EBP // Save this frame EBP + + // !!!Very Important!!! Switch to original EBP. This is + // what allows all locals in the frame to have the same + // value as before the exception occurred. + + EBP = &pRegistrationFrame->_ebp + + // Call the filter function + filterFuncRet = scopetable[trylevel].lpfnFilter(); + + POP EBP // Restore handler frame EBP + + if ( filterFuncRet != EXCEPTION_CONTINUE_SEARCH ) + { + if ( filterFuncRet < 0 ) // EXCEPTION_CONTINUE_EXECUTION + return ExceptionContinueExecution; + + // If we get here, EXCEPTION_EXECUTE_HANDLER was specified + scopetable == pRegistrationFrame->scopetable + + // Does the actual OS cleanup of registration frames + // Causes this function to recurse + __global_unwind2( pRegistrationFrame ); + + + // Once we get here, everything is all cleaned up, except + // for the last frame, where we'll continue execution + EBP = &pRegistrationFrame->_ebp + + __local_unwind2( pRegistrationFrame, trylevel ); + + // NLG == "non-local-goto" (setjmp/longjmp stuff) + __NLG_Notify( 1 ); // EAX == scopetable->lpfnHandler + + // Set the current trylevel to whatever SCOPETABLE entry + // was being used when a handler was found + pRegistrationFrame->trylevel = scopetable->previousTryLevel; + + // Call the _except {} block. Never returns. + pRegistrationFrame->scopetable[trylevel].lpfnHandler(); + } + } + + scopeTable = pRegistrationFrame->scopetable; + trylevel = scopeTable->previousTryLevel + + goto search_for_handler; + } + else // trylevel == TRYLEVEL_NONE + { + retvalue == DISPOSITION_CONTINUE_SEARCH; + } + } + else // EXCEPTION_UNWINDING or EXCEPTION_EXIT_UNWIND flags are set + { + PUSH EBP // Save EBP + + EBP = pRegistrationFrame->_ebp // Set EBP for __local_unwind2 + + __local_unwind2( pRegistrationFrame, TRYLEVEL_NONE ) + + POP EBP // Restore EBP + + retvalue == DISPOSITION_CONTINUE_SEARCH; + } +} + diff --git a/winsup/mingw/samples/seh/exutil.c b/winsup/mingw/samples/seh/exutil.c new file mode 100644 index 000000000..9d98d8350 --- /dev/null +++ b/winsup/mingw/samples/seh/exutil.c @@ -0,0 +1,68 @@ + +#include +#include +#include +#include + +#include "exutil.h" + +void +WalkExceptionHandlers () +{ + PEXCEPTION_REGISTRATION_RECORD p; + int i; + + __asm__("movl %%fs:0,%%eax;movl %%eax,%0" : "=g" (p) : : "%eax"); + + i = 0; + while (p != (PEXCEPTION_REGISTRATION_RECORD) -1 && p) + { + printf ("Registration %d at %08x : ", i, p); + printf ("Handler = %08x ", p->handler); + printf ("Next Registration = %08x\n", p->prev); + p = p->prev; + i++; + } + printf ("End of exception handler list.\n"); + fflush (stdout); +} + +void +DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec) +{ + printf ("Exception: Code = %08x Flags %08x", pExRec->ExceptionCode, + pExRec->ExceptionFlags); + + if (pExRec->ExceptionFlags) + { + printf (" ( "); + if (pExRec->ExceptionFlags & EH_NONCONTINUABLE) + { + printf ("EH_NONCONTINUABLE "); + } + if (pExRec->ExceptionFlags & EH_UNWINDING) + { + printf ("EH_UNWINDING "); + } + if (pExRec->ExceptionFlags & EH_EXIT_UNWIND) + { + printf ("EH_EXIT_UNWIND "); + } + if (pExRec->ExceptionFlags & EH_STACK_INVALID) + { + printf ("EH_STACK_INVALID "); + } + if (pExRec->ExceptionFlags & EH_NESTED_CALL) + { + printf ("EH_NESTED_CALL "); + } + printf (")\n"); + } + else + { + printf ("\n"); + } + + fflush(stdout); +} + diff --git a/winsup/mingw/samples/seh/exutil.def b/winsup/mingw/samples/seh/exutil.def new file mode 100644 index 000000000..bf20cc14f --- /dev/null +++ b/winsup/mingw/samples/seh/exutil.def @@ -0,0 +1,3 @@ +EXPORTS + WalkExceptionHandlers + DumpExceptionRecord diff --git a/winsup/mingw/samples/seh/exutil.h b/winsup/mingw/samples/seh/exutil.h new file mode 100644 index 000000000..79937f745 --- /dev/null +++ b/winsup/mingw/samples/seh/exutil.h @@ -0,0 +1,23 @@ +/* + * Definitions of some internal stuff for exception handling, including + * a version of the all-important EXCEPTION_REGISTRATION_RECORD. + */ + +#ifndef _EXUTIL_H_ +#define _EXUTIL_H_ + +#include +#include + +#ifdef __cplusplus +extern "C" { +#endif + +void WalkExceptionHandlers (); +void DumpExceptionRecord (struct _EXCEPTION_RECORD* pExRec); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/winsup/mingw/samples/seh/jamfile b/winsup/mingw/samples/seh/jamfile new file mode 100644 index 000000000..72b51b790 --- /dev/null +++ b/winsup/mingw/samples/seh/jamfile @@ -0,0 +1,13 @@ + +Dll exutil.dll : exutil.c ; + +ImportLib libexutil.a : exutil.def ; + +Main sehtest.exe : sehtest.c ; + +Main sehfix.exe : sehfix.c ; + +Main sehsub.exe : sehsub.c ; + +LinkLibraries sehtest.exe sehfix.exe sehsub.exe : libexutil.a ; + diff --git a/winsup/mingw/samples/seh/sehfix.c b/winsup/mingw/samples/seh/sehfix.c new file mode 100644 index 000000000..1a414e649 --- /dev/null +++ b/winsup/mingw/samples/seh/sehfix.c @@ -0,0 +1,60 @@ +/* + * sehfix.c + * + * A test program involving an exception handler that fixes the exception + * causing condition. + * + * In this code we install an exception handler my_handler and then a piece + * of inline assembly attempts to write at the address marked in eax, after + * setting eax to 10. This should produce an exception. The handler then + * changes the eax register of the exception context to be the address of + * a static variable and restarts the code. This should allow everything + * to continue. + */ + +#include +#include + +#include "exutil.h" + +int x; + +EXCEPTION_DISPOSITION +my_handler ( + struct _EXCEPTION_RECORD* pExceptionRec, + void* pEstablisherFrame, + struct _CONTEXT* pContextRecord, + void* pDispatcherContext + ) +{ + printf ("In my exception handler!\n"); + DumpExceptionRecord (pExceptionRec); + pContextRecord->Eax = (DWORD) &x; + return ExceptionContinueExecution; +} + +main () +{ + x = 2; + + printf ("x = %d\n", x); + + WalkExceptionHandlers(); + + __try1(my_handler) + + WalkExceptionHandlers(); + + /* This assembly code should produce an exception. */ + __asm__("movl $10,%%eax;movl $1,(%%eax);" : : : "%eax"); + + __except1 + + WalkExceptionHandlers(); + + printf ("x = %d\n", x); + + printf ("Finished!\n"); +} + + diff --git a/winsup/mingw/samples/seh/sehsub.c b/winsup/mingw/samples/seh/sehsub.c new file mode 100644 index 000000000..d2442850a --- /dev/null +++ b/winsup/mingw/samples/seh/sehsub.c @@ -0,0 +1,43 @@ +/* + * sehsub.c + * + * In an attempt to see what might be going on inside CRTDLL, this program + * walks the exception list after creating a new thread with _beginthread. + * + * It turns out that _beginthread DOES install an exception handler, as + * expected, but this handler is NOT exported by CRTDLL (it is certainly + * not _except_handler2 or _XcptFilter)... an odd and unpleasant turn of + * events. + */ + +#include +#include +#include + +#include "exutil.h" + +extern void* __imp__except_handler3; + +unsigned +my_thread (void * p) +{ + printf ("In my thread.\n"); + WalkExceptionHandlers(); + return 0; +} + +main () +{ + unsigned long h; + unsigned id; + printf ("In main.\n"); + WalkExceptionHandlers(); + + printf ("Except_handler3 %08x\n", __imp__except_handler3); + h = _beginthreadex (NULL, 0, my_thread, NULL, 0, &id); + + WaitForSingleObject ((HANDLE) h, INFINITE); + CloseHandle ((HANDLE) h); + return; +} + diff --git a/winsup/mingw/samples/seh/sehtest.c b/winsup/mingw/samples/seh/sehtest.c new file mode 100644 index 000000000..b7ac3357e --- /dev/null +++ b/winsup/mingw/samples/seh/sehtest.c @@ -0,0 +1,72 @@ +/* + * This file tests some of the basics of structured exception handling as + * implemented in excpt.h and the Windows API header files. + * + * The program installs two exception handlers, then attempts to write to + * a pointer to an invalid address. This causes an exception which passes + * through the exception handlers and on to the default system exception + * handler. That handler brings up the dialog box all Windows users know + * and love, and then the program is terminated. + * + * You might note that after the initial run up through our exception frames + * we get a second run up through them with the exception code + * STATUS_INVALID_DISPOSITION and the code EH_UNWINDING. This seems normal + * except that the code got changed from the previous STATUS_ACCESS_VIOLATION. + * I don't understand that bit particularly. + */ + +#include +#include + +#include "exutil.h" + +EXCEPTION_DISPOSITION +my_handler ( + struct _EXCEPTION_RECORD* pExceptionRec, + void* pEstablisherFrame, + struct _CONTEXT* pContextRecord, + void* pDispatcherContext + ) +{ + printf ("In my exception handler!\n"); + DumpExceptionRecord (pExceptionRec); + return ExceptionContinueSearch; +} + +EXCEPTION_DISPOSITION +my_handler2 ( + struct _EXCEPTION_RECORD* pExceptionRec, + void* pEstablisherFrame, + struct _CONTEXT* pContextRecord, + void* pDispatcherContext + ) +{ + printf ("In top exception handler!\n"); + DumpExceptionRecord (pExceptionRec); + return ExceptionContinueSearch; +} + +main () +{ + char* x; + + printf ("my_handler2 = %08x\n", my_handler2); + printf ("my_handler = %08x\n", my_handler); + + WalkExceptionHandlers(); + + __try1(my_handler2) + x = (char*) 10; + + WalkExceptionHandlers(); + + __try1(my_handler) + + WalkExceptionHandlers(); + + *x = 1; + __except1 + __except1 + printf ("Finished!\n"); +} + diff --git a/winsup/mingw/samples/simpledll/dll.c b/winsup/mingw/samples/simpledll/dll.c new file mode 100644 index 000000000..7f743bfcd --- /dev/null +++ b/winsup/mingw/samples/simpledll/dll.c @@ -0,0 +1,33 @@ + +#include + +BOOL WINAPI +DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + printf ("DLL Attached.\n"); + break; + + case DLL_PROCESS_DETACH: + printf ("DLL Detached.\n"); + break; + + case DLL_THREAD_ATTACH: + printf ("DLL Thread Attached.\n"); + break; + + case DLL_THREAD_DETACH: + printf ("DLL Thread Detached.\n"); + break; + } + return TRUE; +} + +void +Test () +{ + printf ("Test Function called!\n"); +} + diff --git a/winsup/mingw/samples/simpledll/dll.cpp b/winsup/mingw/samples/simpledll/dll.cpp new file mode 100644 index 000000000..0c0240685 --- /dev/null +++ b/winsup/mingw/samples/simpledll/dll.cpp @@ -0,0 +1,44 @@ +// +// This is a C++ version of the code in dll.c. NOTE that you need to put +// extern "C" { ... } around DllMain or it will not be called when your +// Dll starts up! (It will get name mangled as a C++ function and the C +// default version in libmingw32.a will get called instead.) +// + +#include + +#include + +extern "C" { + +BOOL WINAPI +DllMain (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) +{ + switch (dwReason) + { + case DLL_PROCESS_ATTACH: + cout << "Dll Attached" << endl ; + break; + + case DLL_PROCESS_DETACH: + cout << "Dll Detached" << endl ; + break; + + case DLL_THREAD_ATTACH: + printf ("DLL Thread Attached.\n"); + break; + + case DLL_THREAD_DETACH: + printf ("DLL Thread Detached.\n"); + break; + } + return TRUE; +} + +void +Test () +{ + printf ("Test Function called!\n"); +} + +}; diff --git a/winsup/mingw/samples/simpledll/dll.def b/winsup/mingw/samples/simpledll/dll.def new file mode 100644 index 000000000..0a623d6b5 --- /dev/null +++ b/winsup/mingw/samples/simpledll/dll.def @@ -0,0 +1,2 @@ +EXPORTS +Test diff --git a/winsup/mingw/samples/simpledll/exe.c b/winsup/mingw/samples/simpledll/exe.c new file mode 100644 index 000000000..cc44202ee --- /dev/null +++ b/winsup/mingw/samples/simpledll/exe.c @@ -0,0 +1,13 @@ +#include + +extern void Test(); + +int main() +{ + printf ("Program started.\n"); + Test (); + printf ("Program ends.\n"); + + return 0; +} + diff --git a/winsup/mingw/samples/simpledll/jamfile b/winsup/mingw/samples/simpledll/jamfile new file mode 100644 index 000000000..30704e68d --- /dev/null +++ b/winsup/mingw/samples/simpledll/jamfile @@ -0,0 +1,14 @@ + +Dll dll.dll : dll.c ; + +ImportLib libdll.a : dll.def ; + + +Main exe.exe : exe.c ; + +LinkLibraries exe.exe : libdll.a ; + +DEPENDS exe.exe : dll.dll ; + +LINKFLAGS on exe.exe = $(LINKFLAGS) -L. ; + diff --git a/winsup/mingw/samples/simpledll/makedll.bat b/winsup/mingw/samples/simpledll/makedll.bat new file mode 100644 index 000000000..c7f9b2ae8 --- /dev/null +++ b/winsup/mingw/samples/simpledll/makedll.bat @@ -0,0 +1,23 @@ +rem *** Create the import library for the dll *** +dlltool --dllname dll.dll --def dll.def --output-lib libdll.a + +rem *** Compile the dll *** +gcc -c -o dll.o dll.c + +rem *** Link the dll *** +gcc -s -mdll -o dll.dll -Wl,--base-file,dll.b dll.o +dlltool --dllname dll.dll --base-file dll.b --output-exp dll.e --def dll.def +gcc -s -mdll -o dll.dll -Wl,--base-file,dll.b dll.o -Wl,dll.e +dlltool --dllname dll.dll --base-file dll.b --output-exp dll.e --def dll.def +gcc -s -mdll -o dll.dll dll.o -Wl,dll.e + +rem *** Delete temporary files from dll linking *** +del dll.b +del dll.e + +rem *** Compile exe, which uses dll. *** +gcc -c -o exe.o exe.c + +rem *** Link exe.exe, which uses dll.dll *** +gcc -s -L. -o exe.exe exe.o libdll.a + diff --git a/winsup/mingw/samples/test/jamfile b/winsup/mingw/samples/test/jamfile new file mode 100644 index 000000000..332ac04b8 --- /dev/null +++ b/winsup/mingw/samples/test/jamfile @@ -0,0 +1,9 @@ +# +# A very simple example with which you can test your compiler/jam setup. +# Also an interesting example of a hybrid console/GUI application. +# + +Main test.exe : test.c ; + +GuiLibs test.exe ; + diff --git a/winsup/mingw/samples/test/test.c b/winsup/mingw/samples/test/test.c new file mode 100644 index 000000000..af8884c9c --- /dev/null +++ b/winsup/mingw/samples/test/test.c @@ -0,0 +1,20 @@ +/* + * This source code is in the PUBLIC DOMAIN and has NO WARRANTY. + * + * Colin Peters , April 15, 1997. + */ + +#include +#include + +int STDCALL +WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) +{ + char text[80]; + + printf ("Enter message box text:"); + fgets(text, 80, stdin); + MessageBox (NULL, text, "Test", MB_OK); + printf ("\nHello after message box.\n"); + return 0; +} diff --git a/winsup/mingw/samples/wintest/jamfile b/winsup/mingw/samples/wintest/jamfile new file mode 100644 index 000000000..8102fa067 --- /dev/null +++ b/winsup/mingw/samples/wintest/jamfile @@ -0,0 +1,8 @@ +# +# A example of Win32 GUI programming in C. +# + +Main test.exe : test.c ; + +Gui test.exe ; + diff --git a/winsup/mingw/samples/wintest/test.c b/winsup/mingw/samples/wintest/test.c new file mode 100644 index 000000000..961496fc1 --- /dev/null +++ b/winsup/mingw/samples/wintest/test.c @@ -0,0 +1,212 @@ +/* + * A basic example of Win32 programming in C. + * + * This source code is in the PUBLIC DOMAIN and has NO WARRANTY. + * + * Colin Peters + */ + +#include +#include + +/* + * This is the window function for the main window. Whenever a message is + * dispatched using DispatchMessage (or sent with SendMessage) this function + * gets called with the contents of the message. + */ +LRESULT CALLBACK +MainWndProc (HWND hwnd, UINT nMsg, WPARAM wParam, LPARAM lParam) +{ + /* The window handle for the "Click Me" button. */ + static HWND hwndButton = 0; + static int cx, cy; /* Height and width of our button. */ + + HDC hdc; /* A device context used for drawing */ + PAINTSTRUCT ps; /* Also used during window drawing */ + RECT rc; /* A rectangle used during drawing */ + + /* + * Perform processing based on what kind of message we got. + */ + switch (nMsg) + { + case WM_CREATE: + { + /* The window is being created. Create our button + * window now. */ + TEXTMETRIC tm; + + /* First we use the system fixed font size to choose + * a nice button size. */ + hdc = GetDC (hwnd); + SelectObject (hdc, GetStockObject (SYSTEM_FIXED_FONT)); + GetTextMetrics (hdc, &tm); + cx = tm.tmAveCharWidth * 30; + cy = (tm.tmHeight + tm.tmExternalLeading) * 2; + ReleaseDC (hwnd, hdc); + + /* Now create the button */ + hwndButton = CreateWindow ( + "button", /* Builtin button class */ + "Click Here", + WS_CHILD | WS_VISIBLE | BS_PUSHBUTTON, + 0, 0, cx, cy, + hwnd, /* Parent is this window. */ + (HMENU) 1, /* Control ID: 1 */ + ((LPCREATESTRUCT) lParam)->hInstance, + NULL + ); + + return 0; + break; + } + + case WM_DESTROY: + /* The window is being destroyed, close the application + * (the child button gets destroyed automatically). */ + PostQuitMessage (0); + return 0; + break; + + case WM_PAINT: + /* The window needs to be painted (redrawn). */ + hdc = BeginPaint (hwnd, &ps); + GetClientRect (hwnd, &rc); + + /* Draw "Hello, World" in the middle of the upper + * half of the window. */ + rc.bottom = rc.bottom / 2; + DrawText (hdc, "Hello, World", -1, &rc, + DT_SINGLELINE | DT_CENTER | DT_VCENTER); + + EndPaint (hwnd, &ps); + return 0; + break; + + case WM_SIZE: + /* The window size is changing. If the button exists + * then place it in the center of the bottom half of + * the window. */ + if (hwndButton && + (wParam == SIZEFULLSCREEN || + wParam == SIZENORMAL) + ) + { + rc.left = (LOWORD(lParam) - cx) / 2; + rc.top = HIWORD(lParam) * 3 / 4 - cy / 2; + MoveWindow ( + hwndButton, + rc.left, rc.top, cx, cy, TRUE); + } + break; + + case WM_COMMAND: + /* Check the control ID, notification code and + * control handle to see if this is a button click + * message from our child button. */ + if (LOWORD(wParam) == 1 && + HIWORD(wParam) == BN_CLICKED && + (HWND) lParam == hwndButton) + { + /* Our button was clicked. Close the window. */ + DestroyWindow (hwnd); + } + return 0; + break; + } + + /* If we don't handle a message completely we hand it to the system + * provided default window function. */ + return DefWindowProc (hwnd, nMsg, wParam, lParam); +} + + +int STDCALL +WinMain (HINSTANCE hInst, HINSTANCE hPrev, LPSTR lpCmd, int nShow) +{ + HWND hwndMain; /* Handle for the main window. */ + MSG msg; /* A Win32 message structure. */ + WNDCLASSEX wndclass; /* A window class structure. */ + char* szMainWndClass = "WinTestWin"; + /* The name of the main window class */ + + /* + * First we create a window class for our main window. + */ + + /* Initialize the entire structure to zero. */ + memset (&wndclass, 0, sizeof(WNDCLASSEX)); + + /* This class is called WinTestWin */ + wndclass.lpszClassName = szMainWndClass; + + /* cbSize gives the size of the structure for extensibility. */ + wndclass.cbSize = sizeof(WNDCLASSEX); + + /* All windows of this class redraw when resized. */ + wndclass.style = CS_HREDRAW | CS_VREDRAW; + + /* All windows of this class use the MainWndProc window function. */ + wndclass.lpfnWndProc = MainWndProc; + + /* This class is used with the current program instance. */ + wndclass.hInstance = hInst; + + /* Use standard application icon and arrow cursor provided by the OS */ + wndclass.hIcon = LoadIcon (NULL, IDI_APPLICATION); + wndclass.hIconSm = LoadIcon (NULL, IDI_APPLICATION); + wndclass.hCursor = LoadCursor (NULL, IDC_ARROW); + + /* Color the background white */ + wndclass.hbrBackground = (HBRUSH) GetStockObject (WHITE_BRUSH); + + /* + * Now register the window class for use. + */ + RegisterClassEx (&wndclass); + + /* + * Create our main window using that window class. + */ + hwndMain = CreateWindow ( + szMainWndClass, /* Class name */ + "Hello", /* Caption */ + WS_OVERLAPPEDWINDOW, /* Style */ + CW_USEDEFAULT, /* Initial x (use default) */ + CW_USEDEFAULT, /* Initial y (use default) */ + CW_USEDEFAULT, /* Initial x size (use default) */ + CW_USEDEFAULT, /* Initial y size (use default) */ + NULL, /* No parent window */ + NULL, /* No menu */ + hInst, /* This program instance */ + NULL /* Creation parameters */ + ); + + /* + * Display the window which we just created (using the nShow + * passed by the OS, which allows for start minimized and that + * sort of thing). + */ + ShowWindow (hwndMain, nShow); + UpdateWindow (hwndMain); + + /* + * The main message loop. All messages being sent to the windows + * of the application (or at least the primary thread) are retrieved + * by the GetMessage call, then translated (mainly for keyboard + * messages) and dispatched to the appropriate window procedure. + * This is the simplest kind of message loop. More complex loops + * are required for idle processing or handling modeless dialog + * boxes. When one of the windows calls PostQuitMessage GetMessage + * will return zero and the wParam of the message will be filled + * with the argument to PostQuitMessage. The loop will end and + * the application will close. + */ + while (GetMessage (&msg, NULL, 0, 0)) + { + TranslateMessage (&msg); + DispatchMessage (&msg); + } + return msg.wParam; +} + diff --git a/winsup/mingw/string_old.c b/winsup/mingw/string_old.c new file mode 100644 index 000000000..c1baeb47e --- /dev/null +++ b/winsup/mingw/string_old.c @@ -0,0 +1,47 @@ +/* + * string_old.c + * + * Oldnames from ANSI header string.h + * + * Some wrapper functions for those old name functions whose appropriate + * equivalents are not simply underscore prefixed. + * + * Contributors: + * Created by Colin Peters + * + * THIS SOFTWARE IS NOT COPYRIGHTED + * + * This source code is offered for use in the public domain. You may + * use, modify or distribute it freely. + * + * This code is distributed in the hope that it will be useful but + * WITHOUT ANY WARRANTY. ALL WARRENTIES, EXPRESS OR IMPLIED ARE HEREBY + * DISCLAMED. This includes but is not limited to warrenties of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * + * $Revision$ + * $Author$ + * $Date$ + * + */ + +#include + +int +strcasecmp (const char *sz1, const char *sz2) +{ + return _stricmp (sz1, sz2); +} + +int +strncasecmp (const char *sz1, const char *sz2, size_t sizeMaxCompare) +{ + return _strnicmp (sz1, sz2, sizeMaxCompare); +} + +int +wcscmpi (const wchar_t * ws1, const wchar_t * ws2) +{ + return _wcsicmp (ws1, ws2); +} + -- cgit v1.2.3