diff options
120 files changed, 6602 insertions, 1177 deletions
diff --git a/winsup/mingw/CRT_fp10.c b/winsup/mingw/CRT_fp10.c new file mode 100644 index 0000000..a13fb00 --- /dev/null +++ b/winsup/mingw/CRT_fp10.c @@ -0,0 +1,16 @@ +/* + * CRT_FP10.c + * + * This defines _fpreset as asm ("fnint"). Calls to _fpreset + * will set default floating point precesion to 64-bit mantissa + * at app startup. + * + * Linking in CRT_FP10.o before libmingw.a will override the definition + * set in CRT_FP8.o. + */ + +/* Override library _fpreset() with asm fninit */ +void _fpreset (void) + { __asm__ ( "fninit" ) ;} + +void __attribute__ ((alias ("_fpreset"))) fpreset(void); diff --git a/winsup/mingw/CRT_fp8.c b/winsup/mingw/CRT_fp8.c new file mode 100644 index 0000000..d772d75 --- /dev/null +++ b/winsup/mingw/CRT_fp8.c @@ -0,0 +1,18 @@ +/* + * CRT_FP8.c + * + * This forces calls of _fpreset to the MSVCRT function + * exported from dll. Effectively it make default + * precison same as apps built with MSVC (53-bit mantissa). + + * + * To change to 64-bit mantissa, link in CRT_FP10.o before libmingw.a. + */ + +/* Link against the _fpreset visible in import lib */ + +extern void (*_imp___fpreset)(void) ; +void _fpreset (void) +{ (*_imp___fpreset)(); } + +void __attribute__ ((alias ("_fpreset"))) fpreset(void); diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index c2a4516..f85feb0 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,388 @@ +2002-06-13 Danny Smith <dannysmith@users.sourceforge.net> + + * include/_mingw.h: Increment version to 2.0. + * Makefile.in: Ditto. + + Merge in mingwex branch. + + 2002-06-11 Danny Smith <dannysmith@users.sourceforge.net> + * include/math.h (fdim, fdimf, fdiml): Add prototypes. + * mingwex/fdim.c: New file. + * mingwex/fdimf.c: New file. + * mingwex/fdiml.c: New file. + * mingwex/Makefile.in (DISTFILES): Add fdim.c, fdimf.c, + fdiml.c. + (MATHOBJS):Add fdim.o, fdimf.o. fdiml.o. + + 2002-05-23 Danny Smith <dannysmith@users.sourceforge.net> + * mingwex/Makefile.in (DISTFILES): Add truncf.c, truncl.c. + + 2002-05-22 Danny Smith <dannysmith@users.sourceforge.net> + * mingwex/isnanl.c: New file. + + 2002-05-21 Danny Smith <dannysmith@users.sourceforge.net> + * include/stdint.h: Include stddef.h to get + wchar_t and wint_t. + (WINT_MAX): Define to ((wint_t)-1). + + 2002-05-21 Danny Smith <dannysmith@users.sourceforge.net> + * include/wctype.h: Replace 'inline' with '__inline__'. + * include/inttypes.h: Likewise. + + 2002-05-16 Danny Smith <dannysmith@users.sourceforge.net> + * include/_mingw.h (__MINGW_IMPORT): Put extern at start + to avoid warnings. Thanks to: Oscar Fuentes <ofv@wanadoo.es>. + + 2002-05-16 Danny Smith <dannysmith@users.sourceforge.net> + * mingwex/snprintf.c: Split out vsnprintf to.... + * mingwex/vsnprintf.c: New file. + * mingwex/snwprintf.c: Split out vsnwprintf to... + * mingwex/vsnwprintf.c: New file. + * mingwex/Makefile.in: Adjust DISTFILES and STDIO_STUB_OBJS. + + 2002-05-15 Pascal Obry <obry@gnat.com> + * include/dirent.h (DIR): Change dd_stat type to int. + (_WDIR): Likewise. + + 2002-05-07 Danny Smith <dannysmith@users.sourceforge.net> + * include/stdio.h (vsnprintf): Change inline to __inline__; + (vsnwprintf): Likewise. + * include/wchar.h (vsnwprintf): Likewise. + (wcstof): Likewise. + (fwide): Likewise. + (mbsinit): Likewise. + + 2002-04-29 Danny Smith <dannysmith@users.sourceforge.net> + Change FP default precison from 53 to 64-bit mantissa. + * Makefile.in (CRT0S): Add CRT_fp8.o. + (MINGW_OBJS): Replace CRT_fp8.o with CRT_fp10.o. + * include/float.h: Replace standard float.h defines with + #include_next<float.h> to use GCC's defines. Adjust comments + to reflect change. + + 2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + * include/dos.h: Change prefix "__imp_" to "_imp__" for + __GNUC__ without __DECLSPEC_SUPPORTED. + * include/fnctl.h: Likewise. + * include/math.h: Likewise. + * include/stdio.h: Likewise. + * include/stdlib.h: Likewise. + * include/time.h: Likewise. + * include/wctype.h: Likewise. + * include/ctype.h: Likewise. + + 2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + Add atexit support for dlls. + * crt1.c (atexit): Force thunk to _imp__atexit. + (_onexit): Force thunk to _imp___onexit. + * dllcrt1.c (DllMainCRTStartup): Initialise private atexit + table on DLL_PROCESS_ATTACH, clean it up on DLL_PROCESS_DETACH. + (__dll_exit): New function to run atexit-registered functions + and flush output buffers on DLL_PROCESS_DETACH or failed + DLL_PROCESS_ATTACH. + (atexit): Force use of private atexit table via _dllonexit, + (_onexit): New function. Force use of private atexit table via + _dllonexit, + * mscvrt.def (atexit, _onexit): Add DATA keyword so that only + _imp_<_symbol> is visible in import lib. + * mscvrt20.def: Likewise. + * mscvrt40.def: Likewise. + * crtdll.def: Likewise. + + 2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + * include/fenv.h: Change header guard macro to _FENV_H_. + (fenv_t, fexcept_t): Move into block protected by + #ifndef RC_INVOKED. + Cleanup some whitespace. + * include/inttypes.h: Change header guard macro to + _INTTYPES_H_. + + 2002-04-26 Danny Smith <dannysmith@users.sourceforge.net> + * include/math.h (copysignl): Declare. + * mingwex/Makefile.in (DISTFILES): Add copysignl.S. + (MATHOBJS):Add copysignl.o. + + 2002-04-24 Danny Smith <dannysmith@users.sourceforge.net> + * include/math.h (__signbitl, __isnanl): Declare. + + 2002-04-24 Danny Smith <dannysmith@users.sourceforge.net> + * include/math.h (nanl, __fpcassifyl, fminl, fmaxl, rintl, + roundl, truncl, fmal, log2l): Declare. + Protect C99 declarations with _STDC_VERSION__ >= 199901L) + || !defined __STRICT_ANSI__. + * mingwex/fmax.c (fmax): Call __isnan, not _isnan. + * mingwex/fmin.c (fmin): Likewise. + * mingwex/fmaxf.c (fmaxf): Call __isnanf, not _isnan. + * mingwex/fminf.c (fminf): Likewise. + * mingwex/fmaxl.c: New file. + * mingwex/fminl.c: New file. + * mingwex/fpclassify.c (__fpclassifyf): Split out to ... + * mingwex/fpclassifyf.c: New file. + * mingwex/fpclassifyl.c: New file. + * mingwex/rint.c (rintf): Split out to... + * mingwex/rintf.c: New file. + * mingwex/rintl.c: New file. + * mingwex/round.c (roundf): Split out to... + * mingwex/roundf.c: New file. + * mingwex/roundl.c: New file. + * mingwex/trunc.c (truncf): Split out to... + * mingwex/truncf.c: New file. + * mingwex/truncl.c: New file. + * mingwex/signbit.c (signbitf): Split out to... + * mingwex/signbitf.c: New file. + * mingwex/signbitl.c: New file. + * mingwex/fmal.c: New file. + * mingwex/copysignl.S: New file. + * mingwex/log2l.c: New file. + * mingwex/fp_consts.c: Add nanl definition. + Comment out unused constants. + * mingwex/Makefile.in (DISTFILES): Add fmaxl.c, fminl.c, + fpclassifyf.c, fpclassifyl.c, rintf.c, rintl.c, roundf.c, + roundl.c, truncf.c truncl.c, signbitf.c signbitl.c, + fmal.c, log2l.c + (MATHOBJS): Add fmaxl.o, fminl.o, fpclassifyf.o, + fpclassifyl.o, rintf.o, rintl.o, roundf.o, roundl.o, + truncf.o truncl.o, signbitf.o signbitl.o, fmal.o, + log2l.o. + * mingwex/snwprintf.c (snwprintf, vsnwprintf): Correct typo. + + 2002-04-23 Danny Smith <dannysmith@users.sourceforge.net> + Make wide char versions of opendir and friends. + * include/dirent.h (_wdirent, _WDIR): Define wide versions of + struct dirent, DIR. + (_wopendir,_wreaddir,_wclosedir,_wrewinddir,_wtelldir, + _wseekdir): Add prototypes for wide versions of corresponding + standard functions. + * include/tchar.h; Add _UNICODE mappings for dirent.h + structures and functions. + * mingwex/dirent.c: Make _UNICODE neutral. + * mingwex/wdirent.c: New file to define _UNICODE before + including dirent.c. + * mingwex/Makefile.in (DISTFILES): Add wdirent.c. + (POSIX_OBJS): Add wdirent.o. + (wdirent.o): Specify dependency on dirent.c as well as + wdirent.c. + * samples/dirent/wtest.c: New file, wide version of test.c. + + 2002-04-17 Danny Smith <dannysmith@users.sourceforge.net> + * Makefile.in (INCLUDES): Add "-iwithprefixbefore include" to + ensure gcc include dir is searched despite -nostdinc. + * profile/Makefile.in (INCLUDES): Likewise. + * mingwex/Makefile.in (INCLUDES): Likewise. + * include/stdarg.h: Replace with stub that just guards the + real gcc system header with #ifndef RC_INVOKED + * include/varargs.h: Likewise. + * include/stddef.h: Likewise. + * include/stdio.h: Include stdarg.h after defining + __need___va_list. + (__VALIST): Define as __gnuc_va_list if __GNUC__, else char*. + Replace va_list with __VALIST throughout. + + 2002-04-17 Danny Smith <dannysmith@users.sourceforge.net> + * crt1.c: Revert changes of 2002-04-16. Use _fpreset again. + * msvcrt.def (_fpreset): Mark as DATA so that only + _imp___fpreset is exported. + * msvcrt20.def (_fpreset): Likewise. + * msvcrt40.def (_fpreset): Likewise. + * crtdll.def (_fpreset): Likewise. + * CRT_fp10.c (_fpreset): Overide library _fpreset with one + that calls fninit. + (fpreset): Add alias. + (__CRT_PC): Delete definition. _fpreset does it now. + * CRT_fp8.c (_fpreset): Force use of library _imp___fpreset. + (fpreset): Add alias. + (__CRT_PC): Delete definition. + * moldname.def.in: Comment out fpreset. + * moldname-msvcrt.def: Regenerate. + * moldname-crtdll.def: Regenerate. + * include/fenv.h (FE_DFL_ENV): Define as (fenv_t*)0. + * mingwex/fesetenv.c (FE_DFL_ENV): Use it to set environment + with the _fpreset determined by startup CRT_fp object. + + 2002-04-16 Danny Smith <dannysmith@users.sourceforge.net> + * CRT_fp8.c: New file. + * CRT_fp10.c: New file. + * crt1.c (__CRT_PC) Declare. + (__CRT_fesetenv): New static function, using _CRT_PC. + (__mingw_CRTStartup):Use __CRT_fesetenv instead of _fpreset. + (_gnu_exception_handler): Likewise. + * Makefile.in (CRT0S): Add CRT_fp10.o. + (MINGW_OBJS): Add CRT_fp8.o. + (SRCDIST_FILES): Add CRT_fp8.c, CRT_fp10.c. + Add CRT_fp8.o, CRT_fp10.o dependancies. + * include/float.h (_fpreset): Expand comment. + * include/fenv.h (FE_PC64_ENV): New define for Intel x87 + (extended precison) environmemt. + (FE_PC53_ENV): New define for MSVCRT default environmemt. + (FE_DFL_ENV): Define as FE_PC53_ENV. + * mingwex/fesetenv.c: Use FE_PC53_ENV, FE_PC64_ENV to determine + precision control for default environment. + + * include/math.h: Fix long comment line. + * profile/configure.in (CRT0S): Set to both gcrt1.o and gcrt2.o + for mingw. + * profile/configure: Regenerate. + + 2002-04-12 Danny Smith <dannysmith@users.sourceforge.net> + * mingwex/Makefile.in (DISTFILES): Add suffix to wcstof.c. + + 2002-04-10 Danny Smith <dannysmith@users.sourceforge.net> + * mingwex/mingw-fseek.c: New file, based on Mumit Khan + mingw-local patch to binutils. + Sun Nov 7 04:27:07 1999 Mumit Khan <khan@xraylith.wisc.edu> + (__mingw_fseek): New function to work around Win9x f/lseek bug. + (__mingw_fwrite): Likewise. + (__mingw_is_win9x): New helper function. + * include/stdio.h (__USE_MINGW_FSEEK): New define,guarding... + (__mingw_fseek): New prototype and define to replace fseek. + (__mingw_fwrite): New prototype and define to replace fwrite. + * mingwex/Makefile.in: Add mingw-fseek.o to libmingwex.a. + * moldname-crtdll.def: Remove CR from end of line. + * moldname-msvcrt.def: Ditto. + + 2002-04-09 Danny Smith <dannysmith@users.sourceforge.net> + * profile/configure.in (CRT0S): Configure name of gcrt?.o + based on target, building gcrt0.o for cygwin -mno-cygwin. + * profile/configure: Regenerate. + * profile/Makefile.in (CRT0S): Use name from configure. + (gcrt0.o): New rule. + (ALL_CRT0S): New define, used to cleanup all gcrt?.o's. + + 2002-04-04 Danny Smith <dannysmith@users.sourceforge.net> + * include/math.h (_controlfp, _control87, _clearfp, _statusfp, _fpreset, + _fpecode): Remove prototypes copied from float.h. + (nan, nanf): Move into block protected against RC_INVOKED + and __cplusplus. + * include/stdlib.h (_Exit): Change from static inline to + extern inline. + * mingwex/_Exit.c : New file. + * mingwex/Makefile.in: Add _Exit.o to libmingwex.a. + + 2002-04-04 Danny Smith <dannysmith@users.sourceforge.net> + Add libgmon.a and libmingwex.a for cygwin -mno-cygwin. + * configure.in (SUBDIRS): Add profile and mingwex to cygwin target. + (configdirs): Likewise. + (LIBGMON_A): Define for cygwin target as well. + * configure: Regenerate. + * profile/configure.in (THREAD_DLL): Remove define. + (LIBM_A): Remove define. + (LIBGMON_A): Define for cygwin target as well. + * profile/configure: Regenerate. + * profile/makefile.in (install): Install to inst_libdir and + inst_includedir. + * mingwex/makefile.in (CFLAGS): Move -fomit-frame-pointer to... + (OPTFLAGS): New define. + (ALL_CFLAGS): Add $(OPTFLAGS). + (ALL_CXXFLAGS): Same. + (.c.o:): Remove ALL_CXXFLAGS. + + 2002-03-29 Danny Smith <dannysmith@users.sourceforge.net> + * include/stdint.h: Add missing newline at eof. + * include/stdio.h (snprintf): Add prototype. + (vsnprintf): Add prototype and inline definition. + (snwprintf): Add prototype. + (vsnwprintf): Add prototype and inline definition. + * include/wchar.h (snwprintf): Add prototype. + (vsnwprintf): Add prototype and inline definition. + * mingwex/Makefile.in: Add snprintf.o, snwprintf.o + to libmingwex.a. + * mingwex/snprintf.c: New file. + * mingwex/snwprintf.c: New file. + + 2002-03-22 Danny Smith <dannysmith@users.sourceforge.net> + * configure.in: Add mingwex as SUBDIRS and configdirs. + * configure: Regenerate. + * Makefile.in (MINGW_OBJS): Remove dirent.o. + (SRC_DIST_FILES): Remove dirent.c. + * dirent.c: Remove. + * include/stdlib.h (_Exit): Add static inline + function. + (struct lldiv_t): Define. + (lldiv): Add prototype. + (llabs): Add extern inline function. + (strtoll,strtoull): Add prototypes. + (wcstol, wcstoul, wcstod): Group together. + (strtof, wcstof): Add extern inline definitions. + (atoll,lltoa,ulltoa, wtoll, lltow ulltow): Add prototypes + and extern inline definitions. + * include/wchar.h (fwide, wcstoll,wcstoull, wmemchr + wmemcmp, wmemcpy, wmemmove, wmemset. mbsinit): Add + prototypes. + (wcstol, wcstoul,wcstod): Copy prototypes from stdlib.h. + (wcstof): Add extern inline definition. + * include/math.h (nan, nanf): Add prototypes. + (NAN, INFINITE): Define constants. + (fpclassify, isnan ,signbit): Add macros and supporting float + and double functions. + (isfinite, isinf, isnormal): Add macros. + (isgreater, isless, isgreaterequal, islessequal,islessgreater): + Add macros. + (rint, rintf, round, roundf, trunc. truncf, fmax, fmaxf, + fmin, fminf, fma, fmaf, log2, log2f): Add prototypes. + (copysign, logb, nextafter, scalb): Add prototypes and + inline stubs for underscored versions in msvcrt.dll. + * include/inttypes.h: New file. + * include/fenv.h: New file + + Add new mingwex subdir and files. + * mingwex: New directory. + * mingwex/Makefile.in: New file. + * mingwex/configure.in: New file. + * mingwex/configure: Generate. + * mingwex/dirent.c: Moved here from parent dir. + * mingwex/atoll.c: New file. + * mingwex/feclearexcept.c: New file. + * mingwex/fegetenv.c: New file. + * mingwex/fegetexceptflag.c: New file. + * mingwex/fegetround.c: New file. + * mingwex/feholdexcept.c: New file. + * mingwex/feraiseexcept.c: New file. + * mingwex/fesetenv.c: New file. + * mingwex/fesetexceptflag.c: New file. + * mingwex/fesetround.o: New file. + * mingwex/fetestexcept.c: New file. + * mingwex/feupdateenv.c: New file. + * mingwex/fma.S: New file. + * mingwex/fmaf.S: New file. + * mingwex/fmax.c: New file. + * mingwex/fmaxf.c: New file. + * mingwex/fmin.c: New file. + * mingwex/fminf.c: New file. + * mingwex/fp_consts.c: New file. + * mingwex/fpclassify.c: New file. + * mingwex/fucom.c: New file. + * mingwex/fwide.c: New file. + * mingwex/imaxabs.c: New file. + * mingwex/imaxdiv.c: New file. + * mingwex/isnan.c: New file. + * mingwex/isnanf.c: New file. + * mingwex/lltoa.c: New file. + * mingwex/lltow.c: New file. + * mingwex/log2.c: New file. + * mingwex/log2f.c: New file. + * mingwex/math_stubs.c: New file. + * mingwex/mbsinit.c: New file. + * mingwex/rint.c: New file. + * mingwex/round.c: New file. + * mingwex/signbit.c: New file. + * mingwex/sitest.c: New file. + * mingwex/strtof.c: New file. + * mingwex/strtoimax.c: New file. + * mingwex/strtoumax.c: New file. + * mingwex/testwmem.c: New file. + * mingwex/trunc.c: New file. + * mingwex/ulltoa.c: New file. + * mingwex/ulltow.c: New file. + * mingwex/wcstof.c: New file. + * mingwex/wcstoimax.c: New file. + * mingwex/wcstoumax.c: New file. + * mingwex/wmemchr.c: New file. + * mingwex/wmemcmp.c: New file. + * mingwex/wmemcpy.c: New file. + * mingwex/wmemmove.c: New file. + * mingwex/wmemset.c: New file. + * mingwex/wtoll.c: New file. + 2002-04-20 Danny Smith <dannysmith@users.sourceforge.net> * include/mbstring.h: New file. diff --git a/winsup/mingw/Makefile.in b/winsup/mingw/Makefile.in index 2b13116..5f7c3e4 100644 --- a/winsup/mingw/Makefile.in +++ b/winsup/mingw/Makefile.in @@ -18,7 +18,7 @@ # This makefile requires GNU make. PACKAGE = mingw-runtime -VERSION = 1.4 +VERSION = 2.0 CYGRELEASE = 1 VPATH = @srcdir@ @@ -96,7 +96,8 @@ LIBM_A=@LIBM_A@ INCLUDES = -I$(srcdir)/include -I$(srcdir)/../w32api/include \ -I$(srcdir)/../include \ - -nostdinc -nostdinc++ + -nostdinc -nostdinc++ \ + -iwithprefixbefore include ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(MNO_CYGWIN) ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) $(MNO_CYGWIN) @@ -145,9 +146,10 @@ FLAGS_TO_PASS:=\ TARFLAGS="$(TARFLAGS)" \ TARFILEEXT="$(TARFILEEXT)" -CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.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 +CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \ + CRT_fp8.o CRT_fp10.o +MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \ + main.o crtst.o mthr_stub.o CRT_fp10.o MOLD_OBJS = ctype_old.o string_old.o LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \ @@ -157,10 +159,11 @@ DLLS = $(THREAD_DLL_NAME) SRCDIST_FILES = CRT_noglob.c CRTfmode.c CRTglob.c CRTinit.c ChangeLog \ Makefile.in README TODO config.guess config.sub configure configure.in \ -crt1.c crtdll.def crtmt.c crtst.c ctype_old.c dirent.c dllcrt1.c dllmain.c \ +crt1.c crtdll.def crtmt.c crtst.c ctype_old.c dllcrt1.c dllmain.c \ gccmain.c init.c install-sh jamfile main.c mkinstalldirs moldname-crtdll.def \ moldname-msvcrt.def moldname.def moldname.def.in msvcrt.def msvcrt20.def \ -msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c +msvcrt40.def mthr.c mthr_init.c mthr_stub.c readme.txt string_old.c \ +CRT_fp8.c CRT_fp10.c all_dlls_host = @all_dlls_host@ install_dlls_host = @install_dlls_host@ @@ -379,11 +382,13 @@ 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 +CRT_fp8.o: $(srcdir)/CRT_fp8.c +CRT_fp10.o: $(srcdir)/CRT_fp10.c + Makefile: Makefile.in config.status configure $(SHELL) config.status diff --git a/winsup/mingw/configure b/winsup/mingw/configure index 1570852..1d976f3 100755 --- a/winsup/mingw/configure +++ b/winsup/mingw/configure @@ -1659,20 +1659,16 @@ test "$host_alias" != "$target_alias" && NONENONEs,x,x, && program_prefix=${target_alias}- - -configdirs="" -SUBDIRS="" +SUBDIRS="profile mingwex" +configdirs="profile mingwex" HEADER_SUBDIR="" +LIBGMON_A=libgmon.a + case "$target_os" in *cygwin*) MNO_CYGWIN=-mno-cygwin - configdirs="$configdirs" - # FIXME MinGW versions of libm.a and libgmon.a needed for -mno-cygwin - # 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" ;; @@ -1680,9 +1676,6 @@ case "$target_os" in # Build it for MSVCRT by default. MNO_CYGWIN= LIBM_A=libm.a - LIBGMON_A=libgmon.a - SUBDIRS="profile" - configdirs="$configdirs profile" ;; esac @@ -1719,7 +1712,7 @@ MKINSTALLDIRS=$ac_aux_dir/mkinstalldirs # 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:1723: checking for a BSD compatible install" >&5 +echo "configure:1716: 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 diff --git a/winsup/mingw/configure.in b/winsup/mingw/configure.in index 3e98517..3fe9e1b 100644 --- a/winsup/mingw/configure.in +++ b/winsup/mingw/configure.in @@ -88,20 +88,16 @@ AC_SUBST(WINDRES) AC_ALLOCA AC_CANONICAL_SYSTEM - -configdirs="" -SUBDIRS="" +SUBDIRS="profile mingwex" +configdirs="profile mingwex" HEADER_SUBDIR="" +LIBGMON_A=libgmon.a + case "$target_os" in *cygwin*) MNO_CYGWIN=-mno-cygwin - configdirs="$configdirs" - # FIXME MinGW versions of libm.a and libgmon.a needed for -mno-cygwin - # 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" ;; @@ -109,9 +105,6 @@ case "$target_os" in # Build it for MSVCRT by default. MNO_CYGWIN= LIBM_A=libm.a - LIBGMON_A=libgmon.a - SUBDIRS="profile" - configdirs="$configdirs profile" ;; esac diff --git a/winsup/mingw/crt1.c b/winsup/mingw/crt1.c index f91f1da..a11c2fb 100644 --- a/winsup/mingw/crt1.c +++ b/winsup/mingw/crt1.c @@ -232,3 +232,20 @@ WinMainCRTStartup () __mingw_CRTStartup (); } +/* + * We force use of library version of atexit, which is only + * visible in import lib as _imp__atexit + */ +extern int (*_imp__atexit)(void (*)(void)); +int atexit (void (* pfn )(void) ) +{ + return ( (*_imp__atexit)(pfn)); +} + +/* Likewise for non-ANSI _onexit */ +extern _onexit_t (*_imp___onexit)(_onexit_t); +_onexit_t +_onexit (_onexit_t pfn ) +{ + return (*_imp___onexit)(pfn); +} diff --git a/winsup/mingw/crtdll.def b/winsup/mingw/crtdll.def index 00ff624..6f924fb 100644 --- a/winsup/mingw/crtdll.def +++ b/winsup/mingw/crtdll.def @@ -285,7 +285,7 @@ _flushall _fmode_dll DATA _fpclass _fpieee_flt -_fpreset +_fpreset DATA _fputchar _fputwchar _fsopen @@ -414,7 +414,7 @@ _mkdir _mktemp _msize _nextafter -_onexit +_onexit DATA _open _open_osfhandle _osmajor_dll DATA @@ -520,7 +520,7 @@ asctime asin atan atan2 -atexit +atexit DATA atof atoi atol diff --git a/winsup/mingw/dllcrt1.c b/winsup/mingw/dllcrt1.c index a0055d8..fe351eb 100644 --- a/winsup/mingw/dllcrt1.c +++ b/winsup/mingw/dllcrt1.c @@ -25,10 +25,11 @@ * $Date$ * */ - +#include <stdlib.h> #include <stdio.h> #include <io.h> #include <process.h> +#include <errno.h> #include <windows.h> /* Unlike normal crt1, I don't initialize the FPU, because the process @@ -40,8 +41,20 @@ extern void __main (); extern void __do_global_dtors (); #endif +typedef void (* p_atexit_fn )(void); +static p_atexit_fn* first_atexit; +static p_atexit_fn* next_atexit; + +static void +__dll_exit (void); + +/* This is based on the function in the Wine project's exit.c */ +p_atexit_fn __dllonexit (p_atexit_fn, p_atexit_fn**, p_atexit_fn**); + + extern BOOL WINAPI DllMain (HANDLE, DWORD, LPVOID); + BOOL WINAPI DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) { @@ -49,41 +62,135 @@ DllMainCRTStartup (HANDLE hDll, DWORD dwReason, LPVOID lpReserved) if (dwReason == DLL_PROCESS_ATTACH) { + /* Initialize private atexit table for this dll. + 32 is min size required by ANSI */ + + first_atexit = (p_atexit_fn*) malloc (32 * sizeof (p_atexit_fn)); + if (first_atexit == NULL ) /* can't allocate memory */ + { + errno=ENOMEM; + return FALSE; + } + *first_atexit = NULL; + next_atexit = first_atexit; + +#ifdef DEBUG + printf ("%s: DLL_PROCESS_ATTACH (%d)\n", __FUNCTION__); +#endif + + #ifdef __GNUC__ - /* From libgcc.a, calls global class constructors. */ + /* From libgcc.a, __main calls global class constructors, + __do_global_ctors, which registers __do_global_dtors + as the first entry of the private atexit table we + have just initialised */ __main (); + #endif - } + } /* - * Call the user-supplied DllMain subroutine + * Call the user-supplied DllMain subroutine. + * This has to come after initialization of atexit table and + * registration of global constructors. * 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); + /* Handle case where DllMain returns FALSE on attachment attempt. */ -#ifdef __GNUC__ - if (dwReason == DLL_PROCESS_DETACH) + if ( (dwReason == DLL_PROCESS_ATTACH) && !bRet) { - /* From libgcc.a, calls global class destructors. */ - __do_global_dtors (); - } +#ifdef DEBUG + printf ("%s: DLL_PROCESS_ATTACH failed, cleaning up\n", __FUNCTION__); #endif + __dll_exit (); /* Cleanup now. This will set first_atexit to NULL so we + know we've cleaned up */ + } + + if (dwReason == DLL_PROCESS_DETACH) + { +#ifdef DEBUG + printf ("%s: DLL_PROCESS_DETACH (%d)\n", __FUNCTION__); +#endif + /* If not attached, return FALSE. Cleanup already done above + if failed attachment attempt. */ + if (! first_atexit ) + bRet = FALSE; + else + /* + * We used to call __do_global_dtors () here. This is + * no longer necessary since __do_global_dtors is now + * registered at start (last out) of private atexit table. + */ + __dll_exit (); + } return bRet; } +static +void +__dll_exit(void) +/* Run LIFO terminators registered in private atexit table */ +{ + if ( first_atexit ) + { + p_atexit_fn* __last = next_atexit - 1; + while ( __last >= first_atexit ) + { + if ( *__last != NULL ) + { +#ifdef DEBUG + printf ("%s: Calling exit function 0x%x from 0x%x\n", + __FUNCTION__, (unsigned)(*__last),(unsigned)__last); +#endif + (**__last) (); + } + __last--; + } + free ( first_atexit ) ; + first_atexit = NULL ; + } + /* + Make sure output buffers opened by DllMain or + atexit-registered functions are flushed before detaching, + otherwise we can have problems with redirected output. + */ + fflush (NULL); +} + /* - * 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. + * The atexit exported from msvcrt.dll causes problems in DLLs. + * Here, we override the exported version of atexit with one that passes the + * private table initialised in DllMainCRTStartup to __dllonexit. + * That means we have to hide the mscvrt.dll atexit because the + * atexit defined here gets __dllonexit from the same lib. */ + int -atexit (void (*pfn) ()) +atexit (p_atexit_fn pfn ) { - return 0; +#ifdef DEBUG + printf ("%s: registering exit function 0x%x at 0x%x\n", + __FUNCTION__, (unsigned)pfn, (unsigned)next_atexit); +#endif + return (__dllonexit (pfn, &first_atexit, &next_atexit) + == NULL ? -1 : 0 ); } +/* + * Likewise for non-ANSI function _onexit that may be called by + * code in the dll. + */ + +_onexit_t +_onexit (_onexit_t pfn ) +{ +#ifdef DEBUG + printf ("%s: registering exit function 0x%x at 0x%x\n", + __FUNCTION__, (unsigned)pfn, (unsigned)next_atexit); +#endif + return ((_onexit_t) __dllonexit ((p_atexit_fn)pfn, &first_atexit, &next_atexit)); +} diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h index 274428d..f8b1261 100644 --- a/winsup/mingw/include/_mingw.h +++ b/winsup/mingw/include/_mingw.h @@ -48,9 +48,9 @@ # define __DECLSPEC_SUPPORTED #else /* __GNUC__ */ # ifdef __declspec - /* note the extern at the end. This is needed to work around GCC's + /* Note the extern. This is needed to work around GCC's limitations in handling dllimport attribute. */ -# define __MINGW_IMPORT __attribute__((dllimport)) extern +# define __MINGW_IMPORT extern __attribute__((dllimport)) # define __DECLSPEC_SUPPORTED # else # undef __DECLSPEC_SUPPORTED @@ -60,9 +60,9 @@ # define __int64 long long #endif /* __GNUC__ */ -#define __MINGW32_VERSION 1.4 -#define __MINGW32_MAJOR_VERSION 1 -#define __MINGW32_MINOR_VERSION 4 +#define __MINGW32_VERSION 2.0 +#define __MINGW32_MAJOR_VERSION 2 +#define __MINGW32_MINOR_VERSION 0 #endif /* __MINGW_H */ diff --git a/winsup/mingw/include/ctype.h b/winsup/mingw/include/ctype.h index bc7c60d..35a577b 100644 --- a/winsup/mingw/include/ctype.h +++ b/winsup/mingw/include/ctype.h @@ -95,22 +95,47 @@ int _toupper(int); /* Also defined in stdlib.h */ #ifndef MB_CUR_MAX +#ifdef __DECLSPEC_SUPPORTED # ifdef __MSVCRT__ # define MB_CUR_MAX __mb_cur_max __MINGW_IMPORT int __mb_cur_max; -# else /* not __MSVCRT */ +# else /* not __MSVCRT */ # define MB_CUR_MAX __mb_cur_max_dll __MINGW_IMPORT int __mb_cur_max_dll; -# endif /* not __MSVCRT */ +# endif /* not __MSVCRT */ + +#else /* ! __DECLSPEC_SUPPORTED */ +# ifdef __MSVCRT__ + extern int* _imp____mbcur_max +# define MB_CUR_MAX (*_imp____mb_cur_max) +# else /* not __MSVCRT */ + extern int* _imp____mbcur_max_dll +# define MB_CUR_MAX (*_imp____mb_cur_max_dll) +# endif /* not __MSVCRT */ +#endif /* __DECLSPEC_SUPPORTED */ #endif /* MB_CUR_MAX */ + +#ifdef __DECLSPEC_SUPPORTED __MINGW_IMPORT unsigned short _ctype[]; -#ifdef __MSVCRT__ -__MINGW_IMPORT unsigned short* _pctype; -#else /* CRTDLL */ -__MINGW_IMPORT unsigned short* _pctype_dll; -#define _pctype _pctype_dll -#endif +# ifdef __MSVCRT__ + __MINGW_IMPORT unsigned short* _pctype; +# else /* CRTDLL */ + __MINGW_IMPORT unsigned short* _pctype_dll; +# define _pctype _pctype_dll +# endif + +#else /* __DECLSPEC_SUPPORTED */ +extern unsigned short** _imp___ctype; +#define _ctype (*_imp___ctype) +# ifdef __MSVCRT__ + extern unsigned short** _imp___pctype; +# define _pctype (*_imp___pctype) +# else /* CRTDLL */ + extern unsigned short** _imp___pctype_dll; +# define _pctype (*_imp___pctype_dll) +# endif /* CRTDLL */ +#endif /* __DECLSPEC_SUPPORTED */ /* * Use inlines here rather than macros, because macros will upset diff --git a/winsup/mingw/include/dirent.h b/winsup/mingw/include/dirent.h index 92ec6b5..4df6bd9 100644 --- a/winsup/mingw/include/dirent.h +++ b/winsup/mingw/include/dirent.h @@ -50,6 +50,7 @@ struct dirent /* * This is an internal data structure. Good programmers will not use it * except as an argument to one of the functions below. + * dd_stat field is now int (was short in older versions). */ typedef struct { @@ -70,13 +71,12 @@ typedef struct * -1 = off the end * positive = 0 based index of next entry */ - short dd_stat; + int 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*); @@ -84,6 +84,57 @@ void rewinddir (DIR*); long telldir (DIR*); void seekdir (DIR*, long); + +/* wide char versions */ + +struct _wdirent +{ + long d_ino; /* Always zero. */ + unsigned short d_reclen; /* Always zero. */ + unsigned short d_namlen; /* Length of name in d_name. */ + wchar_t* d_name; /* File name. */ + /* NOTE: The name in the dirent structure points to the name in the * wfinddata_t structure in the _WDIR. */ +}; + +/* + * 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 _wfinddata_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 _wdirent 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 + */ + int dd_stat; + + /* given path for dir with search pattern (struct is extended) */ + wchar_t dd_name[1]; +} _WDIR; + + + +_WDIR* _wopendir (const wchar_t*); +struct _wdirent* _wreaddir (_WDIR*); +int _wclosedir (_WDIR*); +void _wrewinddir (_WDIR*); +long _wtelldir (_WDIR*); +void _wseekdir (_WDIR*, long); + + #ifdef __cplusplus } #endif diff --git a/winsup/mingw/include/dos.h b/winsup/mingw/include/dos.h index d0d7892..5374a7a 100644 --- a/winsup/mingw/include/dos.h +++ b/winsup/mingw/include/dos.h @@ -48,19 +48,19 @@ extern "C" { #ifndef __MSVCRT__ /* these are in CRTDLL, but not MSVCRT */ #ifndef __DECLSPEC_SUPPORTED -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) +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 */ diff --git a/winsup/mingw/include/fcntl.h b/winsup/mingw/include/fcntl.h index 61ed946..bcc7bca 100644 --- a/winsup/mingw/include/fcntl.h +++ b/winsup/mingw/include/fcntl.h @@ -93,12 +93,12 @@ #ifndef __DECLSPEC_SUPPORTED #ifdef __MSVCRT__ -extern unsigned int* __imp__fmode; -#define _fmode (*__imp__fmode) +extern unsigned int* _imp___fmode; +#define _fmode (*_imp___fmode) #else /* CRTDLL */ -extern unsigned int* __imp__fmode_dll; -#define _fmode (*__imp__fmode_dll) +extern unsigned int* _imp___fmode_dll; +#define _fmode (*_imp___fmode_dll) #endif #else /* __DECLSPEC_SUPPORTED */ diff --git a/winsup/mingw/include/fenv.h b/winsup/mingw/include/fenv.h new file mode 100644 index 0000000..e27095f --- /dev/null +++ b/winsup/mingw/include/fenv.h @@ -0,0 +1,91 @@ +#ifndef _FENV_H_ +#define _FENV_H_ + + +/* FPU status word exception flags */ +#define FE_INVALID 0x01 +#define FE_DENORMAL 0x02 +#define FE_DIVBYZERO 0x04 +#define FE_OVERFLOW 0x08 +#define FE_UNDERFLOW 0x10 +#define FE_INEXACT 0x20 +#define FE_ALL_EXCEPT (FE_INVALID | FE_DENORMAL | FE_DIVBYZERO \ + | FE_OVERFLOW | FE_UNDERFLOW | FE_INEXACT) + +/* FPU control word rounding flags */ +#define FE_TONEAREST 0x0000 +#define FE_DOWNWARD 0x0400 +#define FE_UPWARD 0x0800 +#define FE_TOWARDZERO 0x0c00 + +#ifndef RC_INVOKED +/* + For now, support only for the basic abstraction of flags that are + either set or clear. fexcept_t could be structure that holds more + info about the fp environment. +*/ +typedef unsigned short fexcept_t; + +/* This 28-byte struct represents the entire floating point + environment as stored by fnstenv or fstenv */ +typedef struct +{ + unsigned short __control_word; + unsigned short __unused0; + unsigned short __status_word; + unsigned short __unused1; + unsigned short __tag_word; + unsigned short __unused2; + unsigned int __ip_offset; /* instruction pointer offset */ + unsigned short __ip_selector; + unsigned short __opcode; + unsigned int __data_offset; + unsigned short __data_selector; + unsigned short __unused3; +} fenv_t; + + +/*The C99 standard (7.6.9) allows us to define implementation-specific macros for + different fp environments */ + +/* The default Intel x87 floating point environment (64-bit mantissa) */ +#define FE_PC64_ENV ((const fenv_t *)-1) + +/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */ +#define FE_PC53_ENV ((const fenv_t *)-2) + +/* The FE_DFL_ENV macro is required by standard. + fesetenv will use the environment set at app startup.*/ +#define FE_DFL_ENV ((const fenv_t *) 0) + +#ifdef __cplusplus +extern "C" { +#endif + +/*TODO: Some of these could be inlined */ +/* 7.6.2 Exception */ + +extern int feclearexcept (int); +extern int fegetexceptflag (fexcept_t * flagp, int excepts); +extern int feraiseexcept (int excepts ); +extern int fesetexceptflag (const fexcept_t *, int); +extern int fetestexcept (int excepts); + +/* 7.6.3 Rounding */ + +extern int fegetround (void); +extern int fesetround (int mode); + +/* 7.6.4 Environment */ + +extern int fegetenv (fenv_t * envp); +extern int fesetenv (const fenv_t * ); +extern int feupdateenv (const fenv_t *); +extern int feholdexcept (fenv_t *); + +#ifdef __cplusplus +} +#endif +#endif /* Not RC_INVOKED */ + +#endif /* ndef _FENV_H */ diff --git a/winsup/mingw/include/float.h b/winsup/mingw/include/float.h index 709f369..dbd0441 100644 --- a/winsup/mingw/include/float.h +++ b/winsup/mingw/include/float.h @@ -6,11 +6,10 @@ * 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. + * NOTE: GCC provides float.h, but it doesn't include the non-standard + * stuff for accessing the fp controller. We include_next the + * GCC-supplied header and just define the MS-specific extensions + * here. * * This file is part of the Mingw32 package. * @@ -33,79 +32,13 @@ * */ -#ifndef _FLOAT_H_ -#define _FLOAT_H_ +#ifndef _MINGW_FLOAT_H_ +#define _MINGW_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) - +#include_next<float.h> /* * Functions and definitions for controlling the FPU. @@ -191,7 +124,17 @@ unsigned int _statusfp (void); /* Report the FPU status word */ #define _clear87 _clearfp #define _status87 _statusfp -void _fpreset (void); /* Reset the FPU */ + +/* + MSVCRT.dll _fpreset initializes the control register to 0x27f, + the status register to zero and the tag word to 0FFFFh. + This differs from asm instruction finit/fninit which set control + word to 0x37f (64 bit mantissa precison rather than 53 bit). + By default, the mingw version of _fpreset sets fp control as + per fninit. To use the MSVCRT.dll _fpreset, include CRT_fp8.o when + building your application. +*/ +void _fpreset (void); void fpreset (void); /* Global 'variable' for the current floating point error code. */ @@ -199,7 +142,8 @@ int * __fpecode(void); #define _fpecode (*(__fpecode())) /* - * IEEE recommended functions + * IEEE recommended functions. MS puts them in float.h + * but they really belong in math.h. */ double _chgsign (double); diff --git a/winsup/mingw/include/inttypes.h b/winsup/mingw/include/inttypes.h new file mode 100644 index 0000000..70efb5f --- /dev/null +++ b/winsup/mingw/include/inttypes.h @@ -0,0 +1,275 @@ +/* 7.8 Format conversion of integer types <inttypes.h> */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + +#include <stdint.h> +#define __need_wchar_t +#include <stddef.h> + +#ifdef __cplusplus +extern "C" { +#endif + +typedef struct { + intmax_t quot; + intmax_t rem; + } imaxdiv_t; + +#if !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) + +/* 7.8.1 Macros for format specifiers + * + * MS runtime does not yet understand C9x standard "ll" + * length specifier. It appears to treat "ll" as "l". + * The non-standard I64 length specifier causes warning in GCC, + * but understood by MS runtime functions. + */ + +/* fprintf macros for signed types */ +#define PRId8 "d" +#define PRId16 "d" +#define PRId32 "d" +#define PRId64 "I64d" + +#define PRIdLEAST8 "d" +#define PRIdLEAST16 "d" +#define PRIdLEAST32 "d" +#define PRIdLEAST64 "I64d" + +#define PRIdFAST8 "d" +#define PRIdFAST16 "d" +#define PRIdFAST32 "d" +#define PRIdFAST64 "I64d" + +#define PRIdMAX "I64d" +#define PRIdPTR "d" + +#define PRIi8 "i" +#define PRIi16 "i" +#define PRIi32 "i" +#define PRIi64 "I64i" + +#define PRIiLEAST8 "i" +#define PRIiLEAST16 "i" +#define PRIiLEAST32 "i" +#define PRIiLEAST64 "I64i" + +#define PRIiFAST8 "i" +#define PRIiFAST16 "i" +#define PRIiFAST32 "i" +#define PRIiFAST64 "I64i" + +#define PRIiMAX "I64i" +#define PRIiPTR "i" + +#define PRIo8 "o" +#define PRIo16 "o" +#define PRIo32 "o" +#define PRIo64 "I64o" + +#define PRIoLEAST8 "o" +#define PRIoLEAST16 "o" +#define PRIoLEAST32 "o" +#define PRIoLEAST64 "I64o" + +#define PRIoFAST8 "o" +#define PRIoFAST16 "o" +#define PRIoFAST32 "o" +#define PRIoFAST64 "I64o" + +#define PRIoMAX "I64o" + +#define PRIoPTR "o" + +/* fprintf macros for unsigned types */ +#define PRIu8 "u" +#define PRIu16 "u" +#define PRIu32 "u" +#define PRIu64 "I64u" + + +#define PRIuLEAST8 "u" +#define PRIuLEAST16 "u" +#define PRIuLEAST32 "u" +#define PRIuLEAST64 "I64u" + +#define PRIuFAST8 "u" +#define PRIuFAST16 "u" +#define PRIuFAST32 "u" +#define PRIuFAST64 "I64u" + +#define PRIuMAX "I64u" +#define PRIuPTR "u" + +#define PRIx8 "x" +#define PRIx16 "x" +#define PRIx32 "x" +#define PRIx64 "I64x" + +#define PRIxLEAST8 "x" +#define PRIxLEAST16 "x" +#define PRIxLEAST32 "x" +#define PRIxLEAST64 "I64x" + +#define PRIxFAST8 "x" +#define PRIxFAST16 "x" +#define PRIxFAST32 "x" +#define PRIxFAST64 "I64x" + +#define PRIxMAX "I64x" +#define PRIxPTR "x" + +#define PRIX8 "X" +#define PRIX16 "X" +#define PRIX32 "X" +#define PRIX64 "I64X" + +#define PRIXLEAST8 "X" +#define PRIXLEAST16 "X" +#define PRIXLEAST32 "X" +#define PRIXLEAST64 "I64X" + +#define PRIXFAST8 "X" +#define PRIXFAST16 "X" +#define PRIXFAST32 "X" +#define PRIXFAST64 "I64X" + +#define PRIXMAX "I64X" +#define PRIXPTR "X" + +/* + * fscanf macros for signed int types + * NOTE: if 32-bit int is used for int_fast8_t and int_fast16_t + * (see stdint.h, 7.18.1.3), FAST8 and FAST16 should have + * no length identifiers + */ + +#define SCNd16 "hd" +#define SCNd32 "d" +#define SCNd64 "I64d" + +#define SCNdLEAST16 "hd" +#define SCNdLEAST32 "d" +#define SCNdLEAST64 "I64d" + +#define SCNdFAST16 "hd" +#define SCNdFAST32 "d" +#define SCNdFAST64 "I64d" + +#define SCNdMAX "I64d" +#define SCNdPTR "d" + +#define SCNi16 "hi" +#define SCNi32 "i" +#define SCNi64 "I64i" + +#define SCNiLEAST16 "hi" +#define SCNiLEAST32 "i" +#define SCNiLEAST64 "I64i" + +#define SCNiFAST16 "hi" +#define SCNiFAST32 "i" +#define SCNiFAST64 "I64i" + +#define SCNiMAX "I64i" +#define SCNiPTR "i" + +#define SCNo16 "ho" +#define SCNo32 "o" +#define SCNo64 "I64o" + +#define SCNoLEAST16 "ho" +#define SCNoLEAST32 "o" +#define SCNoLEAST64 "I64o" + +#define SCNoFAST16 "ho" +#define SCNoFAST32 "o" +#define SCNoFAST64 "I64o" + +#define SCNoMAX "I64o" +#define SCNoPTR "o" + +#define SCNx16 "hx" +#define SCNx32 "x" +#define SCNx64 "I64x" + +#define SCNxLEAST16 "hx" +#define SCNxLEAST32 "x" +#define SCNxLEAST64 "I64x" + +#define SCNxFAST16 "hx" +#define SCNxFAST32 "x" +#define SCNxFAST64 "I64x" + +#define SCNxMAX "I64x" +#define SCNxPTR "x" + + +/* fscanf macros for unsigned int types */ + +#define SCNu16 "hu" +#define SCNu32 "u" +#define SCNu64 "I64u" + +#define SCNuLEAST16 "hu" +#define SCNuLEAST32 "u" +#define SCNuLEAST64 "I64u" + +#define SCNuFAST16 "hu" +#define SCNuFAST32 "u" +#define SCNuFAST64 "I64u" + +#define SCNuMAX "I64u" +#define SCNuPTR "u" + +#if defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L +/* + * no length modifier for char types prior to C9x + * MS runtime scanf appears to treat "hh" as "h" + */ + +/* signed char */ +#define SCNd8 "hhd" +#define SCNdLEAST8 "hhd" +#define SCNdFAST8 "hhd" + +#define SCNi8 "hhi" +#define SCNiLEAST8 "hhi" +#define SCNiFAST8 "hhi" + +#define SCNo8 "hho" +#define SCNoLEAST8 "hho" +#define SCNoFAST8 "hho" + +#define SCNx8 "hhx" +#define SCNxLEAST8 "hhx" +#define SCNxFAST8 "hhx" + +/* unsigned char */ +#define SCNu8 "hhu" +#define SCNuLEAST8 "hhu" +#define SCNuFAST8 "hhu" +#endif /* __STDC_VERSION__ >= 199901 */ + +#endif /* !defined(__cplusplus) || defined(__STDC_FORMAT_MACROS) */ + +extern __inline__ intmax_t imaxabs (intmax_t j) + {return (j >= 0 ? j : -j);} +imaxdiv_t imaxdiv (intmax_t numer, intmax_t denom); + +/* 7.8.2 Conversion functions for greatest-width integer types */ + +intmax_t strtoimax (const char* __restrict__ nptr, char** __restrict__ endptr, int base); +uintmax_t strtoumax (const char* __restrict__ nptr, char** __restrict__ endptr, int base); + +intmax_t wcstoimax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr, + int base); +uintmax_t wcstoumax (const wchar_t* __restrict__ nptr, wchar_t** __restrict__ endptr, + int base); + +#ifdef __cplusplus +} +#endif + +#endif /* ndef _INTTYPES_H */ diff --git a/winsup/mingw/include/math.h b/winsup/mingw/include/math.h index d94a706..c87b616 100644 --- a/winsup/mingw/include/math.h +++ b/winsup/mingw/include/math.h @@ -64,6 +64,7 @@ #ifndef __STRICT_ANSI__ #ifndef __MINGW_FPCLASS_DEFINED #define __MINGW_FPCLASS_DEFINED 1 +/* IEEE 754 classication */ #define _FPCLASS_SNAN 0x0001 /* Signaling "Not a Number" */ #define _FPCLASS_QNAN 0x0002 /* Quiet "Not a Number" */ #define _FPCLASS_NINF 0x0004 /* Negative Infinity */ @@ -97,12 +98,12 @@ extern "C" { #ifndef __DECLSPEC_SUPPORTED #ifdef __MSVCRT__ -extern double* __imp__HUGE; -#define HUGE_VAL (*__imp__HUGE) +extern double* _imp___HUGE; +#define HUGE_VAL (*_imp___HUGE) #else /* CRTDLL */ -extern double* __imp__HUGE_dll; -#define HUGE_VAL (*__imp__HUGE_dll) +extern double* _imp___HUGE_dll; +#define HUGE_VAL (*_imp___HUGE_dll) #endif #else /* __DECLSPEC_SUPPORTED */ @@ -151,7 +152,6 @@ double frexp (double, int*); double modf (double, double*); double fmod (double, double); - #ifndef __STRICT_ANSI__ /* Complex number (for cabs) */ @@ -190,12 +190,15 @@ int _isnan (double); /* END FLOAT.H COPY */ -#ifndef _NO_OLDNAMES +#if !defined (_NO_OLDNAMES) \ + || (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L ) /* * Non-underscored versions of non-ANSI functions. These reside in - * liboldnames.a. Provided for extra portability. + * liboldnames.a. They are now also ISO C99 standand names. + * Provided for extra portability. */ + double cabs (struct _complex); double hypot (double, double); double j0 (double); @@ -212,8 +215,271 @@ double yn (int, double); #ifdef __cplusplus } #endif +#endif /* Not RC_INVOKED */ + + +#ifndef __NO_ISOCEXT +#ifndef RC_INVOKED +#ifdef __cplusplus +extern "C" { +#endif + +#if (defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L) \ + || !defined __STRICT_ANSI__ + +#define INFINITY HUGE_VAL +#define NAN (0.0F/0.0F) + +/* + Return values for fpclassify. + These are based on Intel x87 fpu condition codes + in the high byte of status word and differ from + the return values for MS IEEE 754 extension _fpclass() +*/ +#define FP_NAN 0x0100 +#define FP_NORMAL 0x0400 +#define FP_INFINITE (FP_NAN | FP_NORMAL) +#define FP_ZERO 0x4000 +#define FP_SUBNORMAL (FP_NORMAL | FP_ZERO) +/* 0x0200 is signbit mask */ + + +/* Return a NaN */ +double nan(const char *tagp); +float nanf(const char *tagp); +long double nanl(const char *tagp); + +#ifndef __STRICT_ANSI__ +#define nan() nan("") +#define nanf() nanf("") +#define nanl() nanl("") +#endif + +/* + We can't inline float or double, because we want to ensure truncation + to semantic type before classification. + (A normal long double value might become subnormal when + converted to double, and zero when converted to float.) +*/ + +extern int __fpclassifyf (float); +extern int __fpclassify (double); + +extern __inline__ int __fpclassifyl (long double x){ + unsigned short sw; + __asm__ ("fxam; fstsw %%ax;" : "=a" (sw): "t" (x)); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} + +#define fpclassify(x) (sizeof (x) == sizeof (float) ? __fpclassifyf (x) \ + : sizeof (x) == sizeof (double) ? __fpclassify (x) \ + : __fpclassifyl (x)) + +/* We don't need to worry about trucation here: + A NaN stays a NaN. */ +extern __inline__ int __isnan (double _x) +{ + unsigned short sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (sw) : "t" (_x)); + return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +extern __inline__ int __isnanf (float _x) +{ + unsigned short sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (sw) : "t" (_x)); + return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +extern __inline__ int __isnanl (long double _x) +{ + unsigned short sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (sw) : "t" (_x)); + return (sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} +#define isnan(x) (sizeof (x) == sizeof (float) ? __isnanf (x) \ + : sizeof (x) == sizeof (double) ? __isnan (x) \ + : __isnanl (x)) + +#define isfinite(x) ((fpclassify(x) & FP_NAN) == 0) +#define isinf(x) (fpclassify(x) == FP_INFINITE) +#define isnormal(x) (fpclassify(x) == FP_NORMAL) + + +extern __inline__ int __signbit (double x) { + unsigned short stw; + __asm__ ( "fxam; fstsw %%ax;": "=a" (stw) : "t" (x)); + return stw & 0x0200; +} + +extern __inline__ int __signbitf (float x) { + unsigned short stw; + __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x)); + return stw & 0x0200; +} +extern __inline__ int __signbitl (long double x) { + unsigned short stw; + __asm__ ("fxam; fstsw %%ax;": "=a" (stw) : "t" (x)); + return stw & 0x0200; +} + + +#define signbit(x) (sizeof (x) == sizeof (float) ? __signbitf (x) \ + : sizeof (x) == sizeof (double) ? __signbit (x) \ + : __signbitl (x)) + +/* + * With these functions, comparisons involving quiet NaNs set the FP + * condition code to "unordered". The IEEE floating-point spec + * dictates that the result of floating-point comparisons should be + * false whenever a NaN is involved, with the exception of the !=, + * which always returns true: yes, (NaN != NaN) is true). + */ + +#if __GNUC__ >= 3 + +#define isgreater(x, y) __builtin_isgreater(x, y) +#define isgreaterequal(x, y) __builtin_isgreaterequal(x, y) +#define isless(x, y) __builtin_isless(x, y) +#define islessequal(x, y) __builtin_islessequal(x, y) +#define islessgreater(x, y) __builtin_islessgreater(x, y) +#define isunordered(x, y) __builtin_isunordered(x, y) + +#else +/* helper */ +extern __inline__ int +__fp_unordered_compare (long double x, long double y){ + unsigned short retval; + __asm__ ("fucom %%st(1);" + "fnstsw;": "=a" (retval) : "t" (x), "u" (y)); + return retval; +} + +#define isgreater(x, y) ((__fp_unordered_compare(x, y) \ + & 0x4500) == 0) +#define isless(x, y) ((__fp_unordered_compare (y, x) \ + & 0x4500) == 0) +#define isgreaterequal(x, y) ((__fp_unordered_compare (x, y) \ + & FP_INFINITE) == 0) +#define islessequal(x, y) ((__fp_unordered_compare(y, x) \ + & FP_INFINITE) == 0) +#define islessgreater(x, y) ((__fp_unordered_compare(x, y) \ + & FP_SUBNORMAL) == 0) +#define isunordered(x, y) ((__fp_unordered_compare(x, y) \ + & 0x4500) == 0x4500) + +#endif + +/* round, using fpu control word settings */ +extern __inline__ double rint (double x) +{ + double retval; + __asm__ ("frndint;": "=t" (retval) : "0" (x)); + return retval; +} + +extern __inline__ float rintf (float x) +{ + float retval; + __asm__ ("frndint;" : "=t" (retval) : "0" (x) ); + return retval; +} + +extern __inline__ long double rintl (long double x) +{ + long double retval; + __asm__ ("frndint;" : "=t" (retval) : "0" (x) ); + return retval; +} + +/* round away from zero, regardless of fpu control word settings */ +extern double round (double); +extern float roundf (float); +extern long double roundl (long double); + + +/* round towards zero, regardless of fpu control word settings */ +extern double trunc (double); +extern float truncf (float); +extern long double truncl (long double); + + +/* fmax and fmin. + NaN arguments are treated as missing data: if one argument is a NaN + and the other numeric, then these functions choose the numeric + value. */ + +extern double fmax (double, double); +extern float fmaxf (float, float); +extern long double fmaxl (long double, long double); + +extern double fmin (double, double); +extern float fminf (float, float); +extern long double fminl (long double, long double); + +/* return x * y + z as a ternary op */ +extern double fma (double, double, double); +extern float fmaf (float, float, float); +extern long double fmal (long double, long double, long double); + +/* x > y ? (x - y) : 0.0 */ +extern double fdim (double, double); +extern float fdimf (float, float); +extern long double fdiml (long double, long double); + +/* one lonely transcendental */ +extern double log2 (double _x); +extern float log2f (float _x); +extern long double log2l (long double _x); +#endif /* __STDC_VERSION__ >= 199901L */ + + +/* The underscored versions for double are in MSVCRT.dll. + The stubs for float and double versions are in libmingwex.a */ + +double copysign (double, double); +float copysignf (float, float); +long double copysignl (long double, long double); + +double logb (double); +float logbf (float); +double nextafter (double, double); +float nextafterf (float, float); +double scalb (double, long); +float scalbf (float, long); + +#if !defined (__STRICT_ANSI__) /* inline using non-ANSI functions */ +extern __inline__ double copysign (double x, double y) + { return _copysign(x, y); } +extern __inline__ float copysignf (float x, float y) + { return _copysign(x, y); } +extern __inline__ double logb (double x) + { return _logb(x); } +extern __inline__ float logbf (float x) + { return _logb(x); } +extern __inline__ double nextafter(double x, double y) + { return _nextafter(x, y); } +extern __inline__ float nextafterf(float x, float y) + { return _nextafter(x, y); } +extern __inline__ double scalb (double x, long i) + { return _scalb (x, i); } +extern __inline__ float scalbf (float x, long i) + { return _scalb(x, i); } +#endif /* (__STRICT_ANSI__) */ + +#ifdef __cplusplus +} +#endif #endif /* Not RC_INVOKED */ +#endif /* __NO_ISOCEXT */ + #endif /* Not _MATH_H_ */ diff --git a/winsup/mingw/include/stdarg.h b/winsup/mingw/include/stdarg.h index 20169a1..90a2d95 100644 --- a/winsup/mingw/include/stdarg.h +++ b/winsup/mingw/include/stdarg.h @@ -1,112 +1,7 @@ /* - * 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 <colin@bird.fu.is.saga-u.ac.jp> - * - * 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 - * DISCLAIMED. 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. + * This is just an RC_INVOKED guard for the real stdarg.h + * fixincluded in gcc system dir. One day we will delete this file. */ #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 -#if defined __GNUC__ && __GNUC__ >= 3 -typedef __builtin_va_list va_list; -#else -typedef char* va_list; -#endif -#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))) +#include_next<stdarg.h> #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 index 7bdc2cf..ef9d5ff 100644 --- a/winsup/mingw/include/stddef.h +++ b/winsup/mingw/include/stddef.h @@ -1,373 +1,7 @@ /* - * 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 <colin@bird.fu.is.saga-u.ac.jp> - * - * 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 - * DISCLAIMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * + * This is just an RC_INVOKED guard for the real stddef.h + * fixincluded in gcc system dir. One day we will delete this file. */ - -#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 <machine/ansi.h> -#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, <type/vxTypesBase.h> 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 <sys/types.h> 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 <sys/types.h> 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_ +#include_next<stddef.h> #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 <stdio.h> has defined it. */ -#ifdef __GNUG__ -#define NULL __null -#else /* G++ */ -#define NULL ((void *)0) -#endif /* G++ */ -#endif /* NULL not defined and <stddef.h> 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/stdint.h b/winsup/mingw/include/stdint.h index c3a79c5..ec1566d 100644 --- a/winsup/mingw/include/stdint.h +++ b/winsup/mingw/include/stdint.h @@ -19,6 +19,9 @@ #ifndef _STDINT_H #define _STDINT_H +#define __need_wint_t +#define __need_wchar_t +#include <stddef.h> /* 7.18.1.1 Exact-width integer types */ typedef signed char int8_t; @@ -138,11 +141,10 @@ typedef unsigned long long uintmax_t; #endif /* - * wint_t is unsigned int in __MINGW32__, - * but unsigned short in MS runtime + * wint_t is unsigned short for compatibility with MS runtime */ #define WINT_MIN 0 -#define WINT_MAX UINT32_MAX +#define WINT_MAX ((wint_t)-1) /* UINT16_MAX */ #endif /* !defined ( __cplusplus) || defined __STDC_LIMIT_MACROS */ @@ -181,4 +183,4 @@ typedef unsigned long long uintmax_t; #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ -#endif
\ No newline at end of file +#endif diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h index b978abf..fd5827a 100644 --- a/winsup/mingw/include/stdio.h +++ b/winsup/mingw/include/stdio.h @@ -34,12 +34,14 @@ /* All the headers include this file. */ #include <_mingw.h> +#ifndef RC_INVOKED #define __need_size_t #define __need_NULL #define __need_wchar_t #define __need_wint_t -#ifndef RC_INVOKED #include <stddef.h> +#define __need___va_list +#include <stdarg.h> #endif /* Not RC_INVOKED */ @@ -122,19 +124,12 @@ #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 -#if defined __GNUC__ && __GNUC__ >= 3 -typedef __builtin_va_list va_list; +#ifdef __GNUC__ +#define __VALIST __gnuc_va_list #else -typedef char* va_list; -#endif +#define __VALIST char* #endif + /* * The structure underlying the FILE type. * @@ -163,9 +158,9 @@ typedef struct _iobuf */ #ifndef __DECLSPEC_SUPPORTED -extern FILE (*__imp__iob)[]; /* A pointer to an array of FILE */ +extern FILE (*_imp___iob)[]; /* A pointer to an array of FILE */ -#define _iob (*__imp__iob) /* An array of FILE */ +#define _iob (*_imp___iob) /* An array of FILE */ #else /* __DECLSPEC_SUPPORTED */ @@ -211,11 +206,17 @@ 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); - +int vfprintf (FILE*, const char*, __VALIST); +int vprintf (const char*, __VALIST); +int vsprintf (char*, const char*, __VALIST); +int _vsnprintf (char*, size_t, const char*, __VALIST); + +#ifndef __NO_ISOCEXT /* externs in libmingwex.a */ +int snprintf(char* s, size_t n, const char* format, ...); +extern __inline__ int vsnprintf (char* s, size_t n, const char* format, + __VALIST arg) + { return _vsnprintf ( s, n, format, arg); } +#endif /* * Formatted Input @@ -255,6 +256,18 @@ int fseek (FILE*, long, int); long ftell (FILE*); void rewind (FILE*); +#ifdef __USE_MINGW_FSEEK /* These are in libmingwex.a */ +/* + * Workaround for limitations on win9x where a file contents are + * not zero'd out if you seek past the end and then write. + */ + +int __mingw_fseek (FILE *, long, int); +int __mingw_fwrite (const void*, size_t, size_t, FILE*); +#define fseek(fp, offset, whence) __mingw_fseek(fp, offset, whence) +#define fwrite(buffer, size, count, fp) __mingw_fwrite(buffer, size, count, fp) +#endif /* __USE_MINGW_FSEEK */ + /* * 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 @@ -321,10 +334,10 @@ int fwprintf (FILE*, const wchar_t*, ...); int wprintf (const wchar_t*, ...); int swprintf (wchar_t*, const wchar_t*, ...); int _snwprintf (wchar_t*, size_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); -int _vsnwprintf (wchar_t*, size_t, const wchar_t*, va_list); +int vfwprintf (FILE*, const wchar_t*, __VALIST); +int vwprintf (const wchar_t*, __VALIST); +int vswprintf (wchar_t*, const wchar_t*, __VALIST); +int _vsnwprintf (wchar_t*, size_t, const wchar_t*, __VALIST); int fwscanf (FILE*, const wchar_t*, ...); int wscanf (const wchar_t*, ...); int swscanf (const wchar_t*, const wchar_t*, ...); @@ -350,6 +363,14 @@ int _wremove (const wchar_t*); void _wperror (const wchar_t*); FILE* _wpopen (const wchar_t*, const wchar_t*); #endif /* __MSVCRT__ */ + +#ifndef __NO_ISOCEXT /* externs in libmingwex.a */ +int snwprintf(wchar_t* s, size_t n, const wchar_t* format, ...); +extern __inline__ int +vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, __VALIST arg) + { return _vsnwprintf ( s, n, format, arg);} +#endif + #define _WSTDIO_DEFINED #endif /* _WSTDIO_DEFINED */ diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h index 153e648..bc58842 100644 --- a/winsup/mingw/include/stdlib.h +++ b/winsup/mingw/include/stdlib.h @@ -101,10 +101,10 @@ extern wchar_t*** __p___wargv(void); #ifndef __DECLSPEC_SUPPORTED -extern int* __imp___argc_dll; -extern char*** __imp___argv_dll; -#define __argc (*__imp___argc_dll) -#define __argv (*__imp___argv_dll) +extern int* _imp____argc_dll; +extern char*** _imp____argv_dll; +#define __argc (*_imp____argc_dll) +#define __argv (*_imp____argv_dll) #else /* __DECLSPEC_SUPPORTED */ @@ -121,16 +121,27 @@ __MINGW_IMPORT char** __argv_dll; * Also defined in ctype.h. */ +/* Also defined in stdlib.h */ #ifndef MB_CUR_MAX +#ifdef __DECLSPEC_SUPPORTED # ifdef __MSVCRT__ # define MB_CUR_MAX __mb_cur_max __MINGW_IMPORT int __mb_cur_max; -# else /* not __MSVCRT */ +# 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 */ +# endif /* not __MSVCRT */ +#else /* ! __DECLSPEC_SUPPORTED */ +# ifdef __MSVCRT__ + extern int* _imp____mbcur_max +# define MB_CUR_MAX (*_imp____mb_cur_max) +# else /* not __MSVCRT */ + extern int* _imp____mbcur_max_dll +# define MB_CUR_MAX (*_imp____mb_cur_max_dll) +# endif /* not __MSVCRT */ +#endif /* __DECLSPEC_SUPPORTED */ +#endif /* MB_CUR_MAX */ /* * MS likes to declare errno in stdlib.h as well. */ @@ -156,8 +167,8 @@ int* __doserrno(void); # define _wenviron (*__p__wenviron()) #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED - extern char *** __imp__environ_dll; -# define _environ (*__imp__environ_dll) + extern char *** _imp___environ_dll; +# define _environ (*_imp___environ_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char ** _environ_dll; # define _environ _environ_dll @@ -170,8 +181,8 @@ int* __doserrno(void); /* One of the MSVCRTxx libraries */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr; -# define sys_nerr (*__imp__sys_nerr) + extern int* _imp___sys_nerr; +# define sys_nerr (*_imp___sys_nerr) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT int _sys_nerr; # ifndef _UWIN @@ -184,8 +195,8 @@ int* __doserrno(void); /* CRTDLL run time library */ #ifndef __DECLSPEC_SUPPORTED - extern int* __imp__sys_nerr_dll; -# define sys_nerr (*__imp__sys_nerr_dll) + 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 @@ -194,8 +205,8 @@ int* __doserrno(void); #endif /* ! __MSVCRT__ */ #ifndef __DECLSPEC_SUPPORTED -extern char*** __imp__sys_errlist; -#define sys_errlist (*__imp__sys_errlist) +extern char*** _imp__sys_errlist; +#define sys_errlist (*_imp___sys_errlist) #else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _sys_errlist[]; #ifndef _UWIN @@ -262,7 +273,7 @@ wchar_t** __p__wpgmptr(void); #else /* ! __MSVCRT__ */ # ifndef __DECLSPEC_SUPPORTED extern char** __imp__pgmptr_dll; -# define _pgmptr (*__imp__pgmptr_dll) +# define _pgmptr (*_imp___pgmptr_dll) # else /* __DECLSPEC_SUPPORTED */ __MINGW_IMPORT char* _pgmptr_dll; # define _pgmptr _pgmptr_dll @@ -285,12 +296,26 @@ int _wtoi (const wchar_t *); long _wtol (const wchar_t *); 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); +#if !defined __NO_ISOCEXT /* extern stubs in static libmingwex.a */ +extern __inline__ float strtof (const char *nptr, char **endptr) + { return (strtod (nptr, endptr));} +#endif /* __NO_ISOCEXT */ +long strtol (const char*, char**, int); unsigned long strtoul (const char*, char**, int); + +#ifndef _WSTDLIB_DEFINED +/* also declared in wchar.h */ +double wcstod (const wchar_t*, wchar_t**); +#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ +extern __inline__ float wcstof( const wchar_t *nptr, wchar_t **endptr) +{ return (wcstod(nptr, endptr)); } +#endif /* __NO_ISOCEXT */ + +long wcstol (const wchar_t*, wchar_t**, int); unsigned long wcstoul (const wchar_t*, wchar_t**, int); +#define _WSTDLIB_DEFINED +#endif size_t wcstombs (char*, const wchar_t*, size_t); int wctomb (char*, wchar_t); @@ -336,7 +361,6 @@ typedef struct { long quot, rem; } ldiv_t; div_t div (int, int); ldiv_t ldiv (long, long); - #ifndef __STRICT_ANSI__ /* @@ -348,7 +372,12 @@ void _seterrormode (int); void _sleep (unsigned long); void _exit (int) _ATTRIB_NORETURN; - +#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ +/* C99 function name */ +void _Exit(int) _ATTRIB_NORETURN; /* Declare to get noreturn attribute. */ +extern __inline__ void _Exit(int status) + { _exit(status); } +#endif /* _onexit is MS extension. Use atexit for portability. */ typedef int (* _onexit_t)(void); _onexit_t _onexit( _onexit_t ); @@ -406,6 +435,49 @@ char* gcvt (double, int, char*); #endif /* Not __STRICT_ANSI__ */ +/* C99 names */ + +#if !defined __NO_ISOCEXT /* externs in static libmingwex.a */ + +typedef struct { long long quot, rem; } lldiv_t; + +lldiv_t lldiv (long long, long long); + +extern __inline__ long long llabs(long long _j) + {return (_j >= 0 ? _j : -_j);} + +long long strtoll (const char* __restrict__, char** __restrict, int); +unsigned long long strtoull (const char* __restrict__, char** __restrict__, int); + +#if defined (__MSVCRT__) /* these are stubs for MS _i64 versions */ +long long atoll (const char *); + +#if !defined (__STRICT_ANSI__) +long long wtoll(const wchar_t *); +char* lltoa(long long, char *, int); +char* ulltoa(unsigned long long , char *, int); +wchar_t* lltow(long long, wchar_t *, int); +wchar_t* ulltow(unsigned long long, wchar_t *, int); + + /* inline using non-ansi functions */ +extern __inline__ long long atoll (const char * _c) + { return _atoi64 (_c); } +extern __inline__ char* lltoa(long long _n, char * _c, int _i) + { return _i64toa (_n, _c, _i); } +extern __inline__ char* ulltoa(unsigned long long _n, char * _c, int _i) + { return _ui64toa (_n, _c, _i); } +extern __inline__ long long wtoll(const wchar_t * _w) + { return _wtoi64 (_w); } +extern __inline__ wchar_t* lltow(long long _n, wchar_t * _w, int _i) + { return _i64tow (_n, _w, _i); } +extern __inline__ wchar_t* ulltow(unsigned long long _n, wchar_t * _w, int _i) + { return _ui64tow (_n, _w, _i); } +#endif /* (__STRICT_ANSI__) */ + +#endif /* __MSVCRT__ */ + +#endif /* !__NO_ISOCEXT */ + /* * Undefine the no return attribute used in some function definitions */ diff --git a/winsup/mingw/include/tchar.h b/winsup/mingw/include/tchar.h index 2b19c16..bc6f28f 100644 --- a/winsup/mingw/include/tchar.h +++ b/winsup/mingw/include/tchar.h @@ -207,6 +207,15 @@ typedef wchar_t _TCHAR; #define _tfinddatai64_t _wfinddatai64_t #endif /* __MSVCRT__ */ +/* dirent structures and functions */ +#define _tdirent _wdirent +#define _TDIR _WDIR +#define _topendir _wopendir +#define _tclosedir _wclosedir +#define _treaddir _wreaddir +#define _trewinddir _wrewinddir +#define _ttelldir _wtelldir +#define _tseekdir _wseekdir #else /* Not _UNICODE */ /* @@ -364,6 +373,16 @@ typedef char _TCHAR; #define _tfinddatai64_t _finddatai64_t #endif /* __MSVCRT__ */ +/* dirent structures and functions */ +#define _tdirent dirent +#define _TDIR DIR +#define _topendir opendir +#define _tclosedir closedir +#define _treaddir readdir +#define _trewinddir rewinddir +#define _ttelldir telldir +#define _tseekdir seekdir + #endif /* Not _UNICODE */ /* diff --git a/winsup/mingw/include/time.h b/winsup/mingw/include/time.h index 6e9d1e4..f2f7b50 100644 --- a/winsup/mingw/include/time.h +++ b/winsup/mingw/include/time.h @@ -151,13 +151,13 @@ __MINGW_IMPORT char *_tzname[2]; #ifndef __DECLSPEC_SUPPORTED -extern int* __imp__daylight_dll; -extern long* __imp__timezone_dll; -extern char** __imp__tzname; +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) +#define _daylight (*_imp___daylight_dll) +#define _timezone (*_imp___timezone_dll) +#define _tzname (*_imp___tzname) #else /* __DECLSPEC_SUPPORTED */ diff --git a/winsup/mingw/include/varargs.h b/winsup/mingw/include/varargs.h index f81c864..c1197e9 100644 --- a/winsup/mingw/include/varargs.h +++ b/winsup/mingw/include/varargs.h @@ -1,102 +1,7 @@ /* - * 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 <colin@bird.fu.is.saga-u.ac.jp> - * - * 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 - * DISCLAIMED. This includes but is not limited to warranties of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * - * $Revision$ - * $Author$ - * $Date$ - * + * This is just an RC_INVOKED guard for the real varargs.h + * fixincluded in gcc system dir. One day we will delete this file. */ - -#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 -#if defined __GNUC__ && __GNUC__ >= 3 -typedef __builtin_va_list va_list; -#else -typedef char* va_list; -#endif +#include_next<varargs.h> #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 index 69cd3ba..61408e9 100644 --- a/winsup/mingw/include/wchar.h +++ b/winsup/mingw/include/wchar.h @@ -117,6 +117,13 @@ wint_t fgetwc (FILE*); wint_t fputwc (wchar_t, FILE*); wint_t ungetwc (wchar_t, FILE*); +#ifndef __NO_ISOCEXT /* externs in libmingwex.a */ +int snwprintf(wchar_t* s, size_t n, const wchar_t* format, ...); +extern __inline__ int vsnwprintf (wchar_t* s, size_t n, const wchar_t* format, + va_list arg) + { return _vsnwprintf ( s, n, format, arg); } +#endif + #ifdef __MSVCRT__ wchar_t* fgetws (wchar_t*, int, FILE*); int fputws (const wchar_t*, FILE*); @@ -236,6 +243,17 @@ wchar_t* _wsetlocale (int, const wchar_t*); #define _WLOCALE_DEFINED #endif +#ifndef _WSTDLIB_DEFINED /* also declared in stdlib.h */ +long wcstol (const wchar_t*, wchar_t**, int); +unsigned long wcstoul (const wchar_t*, wchar_t**, int); +double wcstod (const wchar_t*, wchar_t**); +#if !defined __NO_ISOCEXT /* extern stub in static libmingwex.a */ +extern __inline__ float wcstof( const wchar_t *nptr, wchar_t **endptr) +{ return (wcstod(nptr, endptr)); } +#endif /* __NO_ISOCEXT */ +#define _WSTDLIB_DEFINED +#endif + #ifndef _NO_OLDNAMES @@ -273,6 +291,23 @@ size_t wcrtomb(char *, wchar_t, mbstate_t *); size_t wcsrtombs(char *, const wchar_t **, size_t, mbstate_t *); int wctob(wint_t); +#ifndef __NO_ISOCEXT /* these need static lib libmingwex.a */ +extern __inline__ int fwide(FILE* stream, int mode) {return -1;} /* limited to byte orientation */ +extern __inline__ int mbsinit(const mbstate_t* ps) {return 1;} +wchar_t* wmemset(wchar_t* s, wchar_t c, size_t n); +wchar_t* wmemchr(const wchar_t* s, wchar_t c, size_t n); +int wmemcmp(const wchar_t* s1, const wchar_t * s2, size_t n); +wchar_t* wmemcpy(wchar_t* __restrict__ s1, const wchar_t* __restrict__ s2, + size_t n); +wchar_t* wmemmove(wchar_t* s1, const wchar_t* s2, size_t n); +long long wcstoll(const wchar_t* __restrict__ nptr, + wchar_t** __restrict__ endptr, int base); +unsigned long long wcstoull(const wchar_t* __restrict__ nptr, + wchar_t ** __restrict__ endptr, int base); + +#endif /* __NO_ISOCEXT */ + + #ifdef __cplusplus } /* end of extern "C" */ #endif diff --git a/winsup/mingw/include/wctype.h b/winsup/mingw/include/wctype.h index 1fb00fb..f39ef64 100644 --- a/winsup/mingw/include/wctype.h +++ b/winsup/mingw/include/wctype.h @@ -86,29 +86,43 @@ int isleadbyte (int); /* Also in ctype.h */ +#ifdef __DECLSPEC_SUPPORTED __MINGW_IMPORT unsigned short _ctype[]; -#ifdef __MSVCRT__ -__MINGW_IMPORT unsigned short* _pctype; -#else -__MINGW_IMPORT unsigned short* _pctype_dll; -#define _pctype _pctype_dll -#endif +# ifdef __MSVCRT__ + __MINGW_IMPORT unsigned short* _pctype; +# else /* CRTDLL */ + __MINGW_IMPORT unsigned short* _pctype_dll; +# define _pctype _pctype_dll +# endif + +#else /* ! __DECLSPEC_SUPPORTED */ +extern unsigned short** _imp___ctype; +#define _ctype (*_imp___ctype) +# ifdef __MSVCRT__ + extern unsigned short** _imp___pctype; +# define _pctype (*_imp___pctype) +# else /* CRTDLL */ + extern unsigned short** _imp___pctype_dll; +# define _pctype (*_imp___pctype_dll) +# endif /* CRTDLL */ +#endif /* __DECLSPEC_SUPPORTED */ + #if !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) #define __WCTYPE_INLINES_DEFINED -extern inline int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} -extern inline int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} -extern inline int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} -extern inline int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} -extern inline int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} -extern inline int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} -extern inline int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} -extern inline int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} -extern inline int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} -extern inline int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} -extern inline int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} -extern inline int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} -extern inline int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} +extern __inline__ int iswalnum(wint_t wc) {return (iswctype(wc,_ALPHA|_DIGIT));} +extern __inline__ int iswalpha(wint_t wc) {return (iswctype(wc,_ALPHA));} +extern __inline__ int iswascii(wint_t wc) {return (((unsigned)wc & 0x7F) ==0);} +extern __inline__ int iswcntrl(wint_t wc) {return (iswctype(wc,_CONTROL));} +extern __inline__ int iswdigit(wint_t wc) {return (iswctype(wc,_DIGIT));} +extern __inline__ int iswgraph(wint_t wc) {return (iswctype(wc,_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int iswlower(wint_t wc) {return (iswctype(wc,_LOWER));} +extern __inline__ int iswprint(wint_t wc) {return (iswctype(wc,_BLANK|_PUNCT|_ALPHA|_DIGIT));} +extern __inline__ int iswpunct(wint_t wc) {return (iswctype(wc,_PUNCT));} +extern __inline__ int iswspace(wint_t wc) {return (iswctype(wc,_SPACE));} +extern __inline__ int iswupper(wint_t wc) {return (iswctype(wc,_UPPER));} +extern __inline__ int iswxdigit(wint_t wc) {return (iswctype(wc,_HEX));} +extern __inline__ int isleadbyte(int c) {return (_pctype[(unsigned char)(c)] & _LEADBYTE);} #endif /* !(defined(__NO_CTYPE_INLINES) || defined(__WCTYPE_INLINES_DEFINED)) */ diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in new file mode 100644 index 0000000..59f8e40 --- /dev/null +++ b/winsup/mingw/mingwex/Makefile.in @@ -0,0 +1,236 @@ +# +# mingw/mingwex/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 +DISTFILES = Makefile.in configure configure.in \ + mingw-fseek.c \ + _Exit.c \ + atoll.c \ + copysignl.S \ + dirent.c \ + fdim.c \ + fdimf.c \ + fdiml.c \ + feclearexcept.c \ + fegetenv.c \ + fegetexceptflag.c \ + fegetround.c \ + feholdexcept.c \ + feraiseexcept.c \ + fesetenv.c \ + fesetround.c \ + fetestexcept.c \ + fesetexceptflag.c \ + feupdateenv.c \ + fma.S \ + fmaf.S \ + fmal.c \ + fmax.c \ + fmaxf.c \ + fmaxl.c \ + fmin.c \ + fminf.c \ + fminl.c \ + fp_consts.c \ + fpclassify.c \ + fpclassifyf.c \ + fpclassifyl.c \ + fucom.c \ + fwide.c \ + imaxabs.c \ + imaxdiv.c \ + isnan.c \ + isnanf.c \ + isnanl.c \ + lltoa.c \ + lltow.c \ + log2.c \ + log2f.c \ + log2l.c \ + math_stubs.c \ + mbsinit.c \ + rint.c \ + rintf.c \ + rintl.c \ + round.c \ + roundf.c \ + roundl.c \ + signbit.c \ + signbitf.c \ + signbitl.c \ + sitest.c \ + snprintf.c \ + snwprintf.c \ + strtof.c \ + strtoimax.c \ + strtoumax.c \ + testwmem.c \ + trunc.c \ + truncf.c \ + truncl.c \ + ulltoa.c \ + ulltow.c \ + vsnprintf.c \ + vsnwprintf.c \ + wcstof.c \ + wcstoimax.c \ + wcstoumax.c \ + wdirent.c \ + wmemchr.c \ + wmemcmp.c \ + wmemcpy.c \ + wmemmove.c \ + wmemset.c \ + wtoll.c + +CC = @CC@ +# FIXME: Which is it, CC or CC_FOR_TARGET? +CC_FOR_TARGET = $(CC) +AS_FOR_TARGET = $(AS) +CFLAGS = @CFLAGS@ -Wall +CXXFLAGS = @CXXFLAGS@ +OPTFLAGS= -fomit-frame-pointer + +# compiling with Cygwin? +MNO_CYGWIN = @MNO_CYGWIN@ + + +INCLUDES = -I$(srcdir) -I$(srcdir)/../include \ + -I$(srcdir)/../../w32api/include \ + -nostdinc -nostdinc++ \ + -iwithprefixbefore include +ALL_CFLAGS = $(CFLAGS) $(OPTFLAGS) $(INCLUDES) $(MNO_CYGWIN) +ALL_CXXFLAGS = $(CXXFLAGS) $(OPTFLAGS) $(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) + +LIBMINGWEX_A = libmingwex.a + +Q8_OBJS = \ + fwide.o imaxabs.o imaxdiv.o mbsinit.o \ + strtoimax.o strtoumax.o wcstoimax.o wcstoumax.o \ + wmemchr.o wmemcmp.o wmemcpy.o wmemmove.o wmemset.o +STDLIB_STUB_OBJS = \ + lltoa.o ulltoa.o \ + lltow.o ulltow.o \ + atoll.o wtoll.o \ + strtof.o wcstof.o \ + _Exit.o +STDIO_STUB_OBJS = \ + snprintf.o vsnprintf.o snwprintf.o vsnwprintf.o +MATH_OBJS = \ + fpclassify.o fpclassifyf.o fpclassifyl.o \ + fucom.o \ + round.o roundf.o roundl.o \ + rint.o rintf.o rintl.o \ + signbit.o signbitf.o signbitl.o \ + trunc.o truncf.o truncl.o \ + isnan.o isnanf.o isnanl.o \ + fp_consts.o \ + fdim.o fdimf.o fdiml.o \ + fmax.o fmaxf.o fmaxl.o \ + fmin.o fminf.o fminl.o \ + fma.o fmaf.o fmal.o \ + log2.o log2f.o log2l.o \ + copysignl.o +MATH_STUB_OBJS = \ + math_stubs.o +FENV_OBJS = fesetround.o fegetround.o \ + fegetenv.o fesetenv.o feupdateenv.o \ + feclearexcept.o feholdexcept.o fegetexceptflag.o \ + feraiseexcept.o fetestexcept.o fesetexceptflag.o +POSIX_OBJS = \ + dirent.o wdirent.o +REPLACE_OBJS = \ + mingw-fseek.o + +LIB_OBJS = $(Q8_OBJS) $(STDLIB_STUB_OBJS) $(STDIO_STUB_OBJS) \ + $(MATH_OBJS) $(MATH_STUB_OBJS) $(FENV_OBJS) $(POSIX_OBJS) \ + $(REPLACE_OBJS) + +LIBS = $(LIBMINGWEX_A) +DLLS = + +all: $(LIBMINGWEX_A) + +$(LIBMINGWEX_A): $(LIB_OBJS) + $(AR) $(ARFLAGS) $@ $(LIB_OBJS) + $(RANLIB) $@ + + +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) $(inst_libdir) + for i in $(LIBS); do \ + $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \ + done + +clean: + -rm -f $(LIB_OBJS) $(LIBMINGWEX_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_CFLAGS) $< -o $@ +.S.o: + $(CC) -c $< -o $@ +.s.o: + $(CC) -c $< -o $@ + + +# +# Dependancies +# +wdirent.o: $(srcdir)/dirent.c $(srcdir)/wdirent.c + + +dist: + mkdir $(distdir)/mingwex + chmod 755 $(distdir)/mingwex + @for i in $(DISTFILES); do\ + cp -p $(srcdir)/$$i $(distdir)/mingwex/$$i ; \ + done diff --git a/winsup/mingw/mingwex/_Exit.c b/winsup/mingw/mingwex/_Exit.c new file mode 100644 index 0000000..38f7e18 --- /dev/null +++ b/winsup/mingw/mingwex/_Exit.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +void _Exit(int status) + { _exit(status); } diff --git a/winsup/mingw/mingwex/atoll.c b/winsup/mingw/mingwex/atoll.c new file mode 100644 index 0000000..97920b4 --- /dev/null +++ b/winsup/mingw/mingwex/atoll.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +long long atoll (const char * _c) + { return _atoi64 (_c); } diff --git a/winsup/mingw/mingwex/configure b/winsup/mingw/mingwex/configure new file mode 100755 index 0000000..746c6fe --- /dev/null +++ b/winsup/mingw/mingwex/configure @@ -0,0 +1,1007 @@ +#! /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=imaxabs.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 +*cygwin*) + MNO_CYGWIN=-mno-cygwin + ;; +*) + # Build it for MSVCRT by default. + MNO_CYGWIN= + ;; +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:673: 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 <<EOF +#! /bin/sh +# Generated automatically by configure. +# Run this file to recreate the current configuration. +# This directory was configured as follows, +# on host `(hostname || uname -n) 2>/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 <<EOF + +# Protect against being on the right side of a sed subst in config.status. +sed 's/%@/@@/; s/@%/@@/; s/%g\$/@g/; /@g\$/s/[\\\\&%]/\\\\&/g; + s/@@/%@/; s/@@/@%/; s/@g\$/%g/' > 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%@MNO_CYGWIN@%$MNO_CYGWIN%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 <<EOF + +CONFIG_FILES=\${CONFIG_FILES-"Makefile"} +EOF +cat >> $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 <<EOF + +EOF +cat >> $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/mingwex/configure.in b/winsup/mingw/mingwex/configure.in new file mode 100644 index 0000000..4c0ed42 --- /dev/null +++ b/winsup/mingw/mingwex/configure.in @@ -0,0 +1,52 @@ +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.13) +AC_INIT(imaxabs.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 +*cygwin*) + MNO_CYGWIN=-mno-cygwin + ;; +*) + # Build it for MSVCRT by default. + MNO_CYGWIN= + ;; +esac + +AC_SUBST(MNO_CYGWIN) + +AC_PROG_INSTALL +AC_OUTPUT(Makefile) + diff --git a/winsup/mingw/mingwex/copysignl.S b/winsup/mingw/mingwex/copysignl.S new file mode 100644 index 0000000..500607e --- /dev/null +++ b/winsup/mingw/mingwex/copysignl.S @@ -0,0 +1,21 @@ +/* + * Written by J.T. Conklin <jtc@netbsd.org>. + * Changes for long double by Ulrich Drepper <drepper@cygnus.com> + * Public domain. + */ + + .file "copysignl.S" + .text + .align 2 + .p2align 4,,15 +.globl _copysignl + .def _copysignl; .scl 2; .type 32; .endef +_copysignl: + movl 24(%esp),%edx + movl 12(%esp),%eax + andl $0x8000,%edx + andl $0x7fff,%eax + orl %edx,%eax + movl %eax,12(%esp) + fldt 4(%esp) + ret diff --git a/winsup/mingw/dirent.c b/winsup/mingw/mingwex/dirent.c index 9eb1a50..91c1706 100644 --- a/winsup/mingw/dirent.c +++ b/winsup/mingw/mingwex/dirent.c @@ -20,14 +20,14 @@ #include <string.h> #include <io.h> #include <direct.h> - #include <dirent.h> #define WIN32_LEAN_AND_MEAN #include <windows.h> /* for GetFileAttributes */ -#define SUFFIX "*" -#define SLASH "\\" +#include <tchar.h> +#define SUFFIX _T("*") +#define SLASH _T("\\") /* * opendir @@ -35,25 +35,25 @@ * Returns a pointer to a DIR structure appropriately filled in to begin * searching a directory. */ -DIR * -opendir (const char *szPath) +_TDIR * +_topendir (const _TCHAR *szPath) { - DIR *nd; + _TDIR *nd; unsigned int rc; - char szFullPath[MAX_PATH]; + _TCHAR szFullPath[MAX_PATH]; errno = 0; if (!szPath) { errno = EFAULT; - return (DIR *) 0; + return (_TDIR *) 0; } - if (szPath[0] == '\0') + if (szPath[0] == _T('\0')) { errno = ENOTDIR; - return (DIR *) 0; + return (_TDIR *) 0; } /* Attempt to determine if the given path really is a directory. */ @@ -62,43 +62,43 @@ opendir (const char *szPath) { /* call GetLastError for more error info */ errno = ENOENT; - return (DIR *) 0; + return (_TDIR *) 0; } if (!(rc & FILE_ATTRIBUTE_DIRECTORY)) { /* Error, entry exists but not a directory. */ errno = ENOTDIR; - return (DIR *) 0; + return (_TDIR *) 0; } /* Make an absolute pathname. */ - _fullpath (szFullPath, szPath, MAX_PATH); + _tfullpath (szFullPath, szPath, MAX_PATH); /* Allocate enough space to store DIR structure and the complete * directory path given. */ - nd = (DIR *) malloc (sizeof (DIR) + strlen (szFullPath) + strlen (SLASH) + - strlen (SUFFIX)); + nd = (_TDIR *) malloc (sizeof (_TDIR) + _tcslen (szFullPath) + _tcslen (SLASH) + + _tcslen (SUFFIX)); if (!nd) { /* Error, out of memory. */ errno = ENOMEM; - return (DIR *) 0; + return (_TDIR *) 0; } /* Create the search expression. */ - strcpy (nd->dd_name, szFullPath); + _tcscpy (nd->dd_name, szFullPath); /* Add on a slash if the path does not end with one. */ - if (nd->dd_name[0] != '\0' && - nd->dd_name[strlen (nd->dd_name) - 1] != '/' && - nd->dd_name[strlen (nd->dd_name) - 1] != '\\') + if (nd->dd_name[0] != _T('\0') && + nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('/') && + nd->dd_name[_tcslen (nd->dd_name) - 1] != _T('\\')) { - strcat (nd->dd_name, SLASH); + _tcscat (nd->dd_name, SLASH); } /* Add on the search pattern */ - strcat (nd->dd_name, SUFFIX); + _tcscat (nd->dd_name, SUFFIX); /* Initialize handle to -1 so that a premature closedir doesn't try * to call _findclose on it. */ @@ -125,8 +125,8 @@ opendir (const char *szPath) * Return a pointer to a dirent structure filled with the information on the * next entry in the directory. */ -struct dirent * -readdir (DIR * dirp) +struct _tdirent * +_treaddir (_TDIR * dirp) { errno = 0; @@ -134,27 +134,27 @@ readdir (DIR * dirp) if (!dirp) { errno = EFAULT; - return (struct dirent *) 0; + return (struct _tdirent *) 0; } if (dirp->dd_dir.d_name != dirp->dd_dta.name) { /* The structure does not seem to be set up correctly. */ errno = EINVAL; - return (struct dirent *) 0; + return (struct _tdirent *) 0; } if (dirp->dd_stat < 0) { /* We have already returned all files in the directory * (or the structure has an invalid dd_stat). */ - return (struct dirent *) 0; + return (struct _tdirent *) 0; } else if (dirp->dd_stat == 0) { /* We haven't started the search yet. */ /* Start the search */ - dirp->dd_handle = _findfirst (dirp->dd_name, &(dirp->dd_dta)); + dirp->dd_handle = _tfindfirst (dirp->dd_name, &(dirp->dd_dta)); if (dirp->dd_handle == -1) { @@ -170,7 +170,7 @@ readdir (DIR * dirp) else { /* Get the next search entry. */ - if (_findnext (dirp->dd_handle, &(dirp->dd_dta))) + if (_tfindnext (dirp->dd_handle, &(dirp->dd_dta))) { /* We are off the end or otherwise error. */ _findclose (dirp->dd_handle); @@ -190,11 +190,11 @@ readdir (DIR * dirp) /* Successfully got an entry. Everything about the file is * already appropriately filled in except the length of the * file name. */ - dirp->dd_dir.d_namlen = strlen (dirp->dd_dir.d_name); + dirp->dd_dir.d_namlen = _tcslen (dirp->dd_dir.d_name); return &dirp->dd_dir; } - return (struct dirent *) 0; + return (struct _tdirent *) 0; } @@ -204,7 +204,7 @@ readdir (DIR * dirp) * Frees up resources allocated by opendir. */ int -closedir (DIR * dirp) +_tclosedir (_TDIR * dirp) { int rc; @@ -235,7 +235,7 @@ closedir (DIR * dirp) * and then reset things like an opendir. */ void -rewinddir (DIR * dirp) +_trewinddir (_TDIR * dirp) { errno = 0; @@ -261,7 +261,7 @@ rewinddir (DIR * dirp) * seekdir to go back to an old entry. We simply return the value in stat. */ long -telldir (DIR * dirp) +_ttelldir (_TDIR * dirp) { errno = 0; @@ -283,7 +283,7 @@ telldir (DIR * dirp) * any such system. */ void -seekdir (DIR * dirp, long lPos) +_tseekdir (_TDIR * dirp, long lPos) { errno = 0; @@ -312,9 +312,9 @@ seekdir (DIR * dirp, long lPos) else { /* Rewind and read forward to the appropriate index. */ - rewinddir (dirp); + _trewinddir (dirp); - while ((dirp->dd_stat < lPos) && readdir (dirp)) + while ((dirp->dd_stat < lPos) && _treaddir (dirp)) ; } } diff --git a/winsup/mingw/mingwex/fdim.c b/winsup/mingw/mingwex/fdim.c new file mode 100644 index 0000000..330b092 --- /dev/null +++ b/winsup/mingw/mingwex/fdim.c @@ -0,0 +1,7 @@ +#include <math.h> + +double +fdim (double x, double y) +{ + return (isgreater(x, y) ? (x - y) : 0.0); +} diff --git a/winsup/mingw/mingwex/fdimf.c b/winsup/mingw/mingwex/fdimf.c new file mode 100644 index 0000000..02bfc6e --- /dev/null +++ b/winsup/mingw/mingwex/fdimf.c @@ -0,0 +1,7 @@ +#include <math.h> + +float +fdimf (float x, float y) +{ + return (isgreater(x, y) ? (x - y) : 0.0F); +} diff --git a/winsup/mingw/mingwex/fdiml.c b/winsup/mingw/mingwex/fdiml.c new file mode 100644 index 0000000..1c3d0aa --- /dev/null +++ b/winsup/mingw/mingwex/fdiml.c @@ -0,0 +1,7 @@ +#include <math.h> + +long double +fdiml (long double x, long double y) +{ + return (isgreater(x, y) ? (x - y) : 0.0L); +} diff --git a/winsup/mingw/mingwex/feclearexcept.c b/winsup/mingw/mingwex/feclearexcept.c new file mode 100644 index 0000000..e6017fc --- /dev/null +++ b/winsup/mingw/mingwex/feclearexcept.c @@ -0,0 +1,14 @@ +#include <fenv.h> + +/* 7.6.2.1 + The feclearexcept function clears the supported exceptions + represented by its argument. */ + +int feclearexcept (int excepts) +{ + fenv_t _env; + __asm__ volatile ("fnstenv %0;" : "=m" (_env)); /* get the env */ + _env.__status_word &= ~(excepts & FE_ALL_EXCEPT); /* clear the except */ + __asm__ volatile ("fldenv %0;" :: "m" (_env)); /*set the env */ + return 0; +} diff --git a/winsup/mingw/mingwex/fegetenv.c b/winsup/mingw/mingwex/fegetenv.c new file mode 100644 index 0000000..8af5103 --- /dev/null +++ b/winsup/mingw/mingwex/fegetenv.c @@ -0,0 +1,12 @@ +#include <fenv.h>
+
+/* 7.6.4.1
+ The fegetenv function stores the current floating-point environment
+ in the object pointed to by envp. */
+
+int fegetenv (fenv_t * envp)
+{
+ __asm__ ("fnstenv %0;": "=m" (*envp));
+ return 0;
+}
+
diff --git a/winsup/mingw/mingwex/fegetexceptflag.c b/winsup/mingw/mingwex/fegetexceptflag.c new file mode 100644 index 0000000..353e90d --- /dev/null +++ b/winsup/mingw/mingwex/fegetexceptflag.c @@ -0,0 +1,15 @@ +#include <fenv.h> + + +/* 7.6.2.2 + The fegetexceptflag function stores an implementation-defined + representation of the exception flags indicated by the argument + excepts in the object pointed to by the argument flagp. */ + +int fegetexceptflag (fexcept_t * flagp, int excepts) +{ + unsigned short _sw; + __asm__ ("fnstsw %%ax;": "=a" (_sw)); + *flagp = _sw & excepts & FE_ALL_EXCEPT; + return 0; +} diff --git a/winsup/mingw/mingwex/fegetround.c b/winsup/mingw/mingwex/fegetround.c new file mode 100644 index 0000000..076b106 --- /dev/null +++ b/winsup/mingw/mingwex/fegetround.c @@ -0,0 +1,14 @@ +#include <fenv.h> + +/* 7.6.3.1 + The fegetround function returns the value of the rounding direction + macro representing the current rounding direction. */ + +int +fegetround (void) +{ + unsigned short _cw; + __asm__ ("fnstcw %0;" : "=m" (_cw)); + return _cw + & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); +} diff --git a/winsup/mingw/mingwex/feholdexcept.c b/winsup/mingw/mingwex/feholdexcept.c new file mode 100644 index 0000000..df486af --- /dev/null +++ b/winsup/mingw/mingwex/feholdexcept.c @@ -0,0 +1,18 @@ +#include <fenv.h> + +/* 7.6.4.2 + The feholdexcept function saves the current floating-point + environment in the object pointed to by envp, clears the exception + flags, and then installs a non-stop (continue on exceptions) mode, + if available, for all exceptions. */ + +int feholdexcept (fenv_t * envp) +{ + fenv_t tmp_env; + __asm__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */ + tmp_env = * envp; + tmp_env.__status_word &= ~FE_ALL_EXCEPT; /* clear exception flags */ + tmp_env.__control_word |= FE_ALL_EXCEPT; /* set cw to non-stop */ + __asm__ volatile ("fldenv %0;" : : "m" (tmp_env)); /* install the copy */ + return 0; +} diff --git a/winsup/mingw/mingwex/feraiseexcept.c b/winsup/mingw/mingwex/feraiseexcept.c new file mode 100644 index 0000000..b1ba870 --- /dev/null +++ b/winsup/mingw/mingwex/feraiseexcept.c @@ -0,0 +1,19 @@ +#include <fenv.h> + +/* 7.6.2.3 + The feraiseexcept function raises the supported exceptions + represented by its argument The order in which these exceptions + are raised is unspecified, except as stated in F.7.6. + Whether the feraiseexcept function additionally raises + the inexact exception whenever it raises the overflow + or underflow exception is implementation-defined. */ + +int feraiseexcept (int excepts) +{ + fenv_t _env; + __asm__ volatile ("fnstenv %0;" : "=m" (_env)); + _env.__status_word |= excepts & FE_ALL_EXCEPT; + __asm__ volatile ("fldenv %0;" + "fwait;" : : "m" (_env)); + return 0; +} diff --git a/winsup/mingw/mingwex/fesetenv.c b/winsup/mingw/mingwex/fesetenv.c new file mode 100644 index 0000000..b3d5c5f --- /dev/null +++ b/winsup/mingw/mingwex/fesetenv.c @@ -0,0 +1,41 @@ +#include <fenv.h> + +/* 7.6.4.3 + The fesetenv function establishes the floating-point environment + represented by the object pointed to by envp. The argument envp + points to an object set by a call to fegetenv or feholdexcept, or + equal the macro FE_DFL_ENV or an implementation-defined environment + macro. Note that fesetenv merely installs the state of the exception + flags represented through its argument, and does not raise these + exceptions. + */ + +extern void (*_imp___fpreset)( void ) ; + +int fesetenv (const fenv_t * envp) +{ + if (envp == FE_PC64_ENV) + /* + * fninit initializes the control register to 0x37f, + * the status register to zero and the tag word to 0FFFFh. + * The other registers are unaffected. + */ + __asm__ ("fninit"); + + else if (envp == FE_PC53_ENV) + /* + * MS _fpreset() does same *except* it sets control word + * to 0x27f (53-bit precison). + * We force calling _fpreset in msvcrt.dll + */ + + (*_imp___fpreset)(); + + else if (envp == FE_DFL_ENV) + /* Use the choice made at app startup */ + _fpreset(); + + else + __asm__ ("fldenv %0;" : : "m" (*envp)); + return 0; +} diff --git a/winsup/mingw/mingwex/fesetexceptflag.c b/winsup/mingw/mingwex/fesetexceptflag.c new file mode 100644 index 0000000..7f4b8e5 --- /dev/null +++ b/winsup/mingw/mingwex/fesetexceptflag.c @@ -0,0 +1,22 @@ +#include <fenv.h> + +/* 7.6.2.4 + The fesetexceptflag function sets the complete status for those + exception flags indicated by the argument excepts, according to the + representation in the object pointed to by flagp. The value of + *flagp shall have been set by a previous call to fegetexceptflag + whose second argument represented at least those exceptions + represented by the argument excepts. This function does not raise + exceptions, but only sets the state of the flags. */ + +int fesetexceptflag (const fexcept_t * flagp, int excepts) +{ + fenv_t _env; + + excepts &= FE_ALL_EXCEPT; + __asm__ volatile ("fnstenv %0;" : "=m" (_env)); + _env.__status_word &= ~excepts; + _env.__status_word |= (*flagp & excepts); + __asm__ volatile ("fldenv %0;" : : "m" (_env)); + return 0; +} diff --git a/winsup/mingw/mingwex/fesetround.c b/winsup/mingw/mingwex/fesetround.c new file mode 100644 index 0000000..a8cef86 --- /dev/null +++ b/winsup/mingw/mingwex/fesetround.c @@ -0,0 +1,19 @@ +#include <fenv.h> + /* 7.6.3.2 + The fesetround function establishes the rounding direction + represented by its argument round. If the argument is not equal + to the value of a rounding direction macro, the rounding direction + is not changed. */ + +int fesetround (int mode) +{ + unsigned short _cw; + if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) + != 0) + return -1; + __asm__ volatile ("fnstcw %0;": "=m" (_cw)); + _cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); + _cw |= mode; + __asm__ volatile ("fldcw %0;" : : "m" (_cw)); + return 0; +} diff --git a/winsup/mingw/mingwex/fetestexcept.c b/winsup/mingw/mingwex/fetestexcept.c new file mode 100644 index 0000000..6934ed9 --- /dev/null +++ b/winsup/mingw/mingwex/fetestexcept.c @@ -0,0 +1,15 @@ +#include <fenv.h> +/* 7.6.2.5 + The fetestexcept function determines which of a specified subset of + the exception flags are currently set. The excepts argument + specifies the exception flags to be queried. + The fetestexcept function returns the value of the bitwise OR of the + exception macros corresponding to the currently set exceptions + included in excepts. */ + +int fetestexcept (int excepts) +{ + unsigned short _sw; + __asm__ ("fnstsw %%ax" : "=a" (_sw)); + return _sw & excepts & FE_ALL_EXCEPT; +} diff --git a/winsup/mingw/mingwex/feupdateenv.c b/winsup/mingw/mingwex/feupdateenv.c new file mode 100644 index 0000000..f414837 --- /dev/null +++ b/winsup/mingw/mingwex/feupdateenv.c @@ -0,0 +1,20 @@ +#include <fenv.h> + +/* 7.6.4.4 + The feupdateenv function saves the currently raised exceptions in + its automatic storage, installs the floating-point environment + represented by the object pointed to by envp, and then raises the + saved exceptions. The argument envp shall point to an object + set by a call to feholdexcept or fegetenv, or equal the macro + FE_DFL_ENV or an implementation-defined environment macro. */ + +/* FIXME: this works but surely there must be a better way. */ + +int feupdateenv (const fenv_t * envp) +{ + unsigned int _fexcept = fetestexcept (FE_ALL_EXCEPT); /*save excepts */ + fesetenv (envp); /* install the env */ + feraiseexcept (_fexcept); /* raise the execept */ + return 0; +} + diff --git a/winsup/mingw/mingwex/fma.S b/winsup/mingw/mingwex/fma.S new file mode 100644 index 0000000..d622665 --- /dev/null +++ b/winsup/mingw/mingwex/fma.S @@ -0,0 +1,12 @@ + .file "fma.S" + .text + .align 2 + .p2align 4,,15 +.globl _fma + .def _fma; .scl 2; .type 32; .endef +_fma: + fldl 4(%esp) + fmull 12(%esp) + fldl 20(%esp) + faddp + ret diff --git a/winsup/mingw/mingwex/fmaf.S b/winsup/mingw/mingwex/fmaf.S new file mode 100644 index 0000000..0d64ac2 --- /dev/null +++ b/winsup/mingw/mingwex/fmaf.S @@ -0,0 +1,12 @@ + .file "fmaf.S" + .text + .align 2 + .p2align 4,,15 +.globl _fmaf + .def _fmaf; .scl 2; .type 32; .endef +_fmaf: + flds 4(%esp) + fmuls 8(%esp) + flds 12(%esp) + faddp + ret diff --git a/winsup/mingw/mingwex/fmal.c b/winsup/mingw/mingwex/fmal.c new file mode 100644 index 0000000..b827875 --- /dev/null +++ b/winsup/mingw/mingwex/fmal.c @@ -0,0 +1,4 @@ +long double +fmal ( long double _x, long double _y, long double _z){ +return ((_x * _y) + _z); +} diff --git a/winsup/mingw/mingwex/fmax.c b/winsup/mingw/mingwex/fmax.c new file mode 100644 index 0000000..35c1f45 --- /dev/null +++ b/winsup/mingw/mingwex/fmax.c @@ -0,0 +1,7 @@ +#include <math.h> + +double +fmax (double _x, double _y) +{ + return ( isgreaterequal (_x, _y)|| __isnan (_y) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fmaxf.c b/winsup/mingw/mingwex/fmaxf.c new file mode 100644 index 0000000..079a7e7 --- /dev/null +++ b/winsup/mingw/mingwex/fmaxf.c @@ -0,0 +1,7 @@ +#include <math.h> + +float +fmaxf (float _x, float _y) +{ + return (( isgreaterequal(_x, _y) || __isnanf (_y)) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fmaxl.c b/winsup/mingw/mingwex/fmaxl.c new file mode 100644 index 0000000..4e38da4 --- /dev/null +++ b/winsup/mingw/mingwex/fmaxl.c @@ -0,0 +1,7 @@ +#include <math.h> + +long double +fmaxl (long double _x, long double _y) +{ + return (( isgreaterequal(_x, _y) || __isnanl (_y)) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fmin.c b/winsup/mingw/mingwex/fmin.c new file mode 100644 index 0000000..96a6ed1 --- /dev/null +++ b/winsup/mingw/mingwex/fmin.c @@ -0,0 +1,7 @@ +#include <math.h> + +double +fmin (double _x, double _y) +{ + return ((islessequal(_x, _y) || __isnan (_y)) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fminf.c b/winsup/mingw/mingwex/fminf.c new file mode 100644 index 0000000..f3d7148 --- /dev/null +++ b/winsup/mingw/mingwex/fminf.c @@ -0,0 +1,7 @@ +#include <math.h> + +float +fminf (float _x, float _y) +{ + return ((islessequal(_x, _y) || _isnan (_y)) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fminl.c b/winsup/mingw/mingwex/fminl.c new file mode 100644 index 0000000..d8a3fea --- /dev/null +++ b/winsup/mingw/mingwex/fminl.c @@ -0,0 +1,7 @@ +#include <math.h> + +long double +fminl (long double _x, long double _y) +{ + return ((islessequal(_x, _y) || __isnanl (_y)) ? _x : _y ); +} diff --git a/winsup/mingw/mingwex/fp_consts.c b/winsup/mingw/mingwex/fp_consts.c new file mode 100644 index 0000000..9293eed --- /dev/null +++ b/winsup/mingw/mingwex/fp_consts.c @@ -0,0 +1,81 @@ +/* Floating point consts needed by STL class mumeric_limits<float> + and numeric_limits<double>. Also used as return values by nan, inf */ + +#include <math.h> +/* +According to IEEE 754 a QNaN has exponent bits of all 1 values and +initial significand bit of 1. A SNaN has has an exponent of all 1 +values and initial significand bit of 0 (with one or more other +significand bits of 1). An Inf has significand of 0 and +exponent of all 1 values. A denormal value has all exponent bits of 0. + +The following does _not_ follow those rules, but uses values +equal to those exported from MS C++ runtime lib, msvcprt.dll +for float and double. MSVC however, does not have long doubles. +*/ + + +#define __DOUBLE_INF_REP { 0, 0, 0, 0x7ff0 } +#define __DOUBLE_QNAN_REP { 0, 0, 0, 0xfff8 } /* { 0, 0, 0, 0x7ff8 } */ +#define __DOUBLE_SNAN_REP { 0, 0, 0, 0xfff0 } /* { 1, 0, 0, 0x7ff0 } */ +#define __DOUBLE_DENORM_REP {1, 0, 0, 0} +#define D_NAN_MASK 0x7ff0000000000000LL /* this will mask NaN's and Inf's */ + +#define __FLOAT_INF_REP { 0, 0x7f80 } +#define __FLOAT_QNAN_REP { 0, 0xffc0 } /* { 0, 0x7fc0 } */ +#define __FLOAT_SNAN_REP { 0, 0xff80 } /* { 1, 0x7f80 } */ +#define __FLOAT_DENORM_REP {1,0} +#define F_NAN_MASK 0x7f800000 + +/* This assumes no implicit (hidden) bit in extended mode */ +#define __LONG_DOUBLE_INF_REP { 0, 0, 0, 0x8000, 0x7fff } +#define __LONG_DOUBLE_QNAN_REP { 0, 0, 0, 0xc000, 0xffff } +#define __LONG_DOUBLE_SNAN_REP { 0, 0, 0, 0x8000, 0xffff } +#define __LONG_DOUBLE_DENORM_REP {1, 0, 0, 0, 0} + +union _ieee_rep +{ + unsigned short rep[5]; + float float_val; + double double_val; + long double ldouble_val; +} ; + +const union _ieee_rep __QNAN = { __DOUBLE_QNAN_REP }; +/* +const union _ieee_rep __SNAN = { __DOUBLE_SNAN_REP }; +const union _ieee_rep __INF = { __DOUBLE_INF_REP }; +const union _ieee_rep __DENORM = { __DOUBLE_DENORM_REP }; +*/ +/* ISO C99 */ + +#undef nan +/* FIXME */ +double nan (const char * tagp __attribute__((unused)) ) + { return __QNAN.double_val; } + + +const union _ieee_rep __QNANF = { __FLOAT_QNAN_REP }; +/* +const union _ieee_rep __SNANF = { __FLOAT_SNAN_REP }; +const union _ieee_rep __INFF = { __FLOAT_INF_REP }; +const union _ieee_rep __DENORMF = { __FLOAT_DENORM_REP }; +*/ + +#undef nanf +/* FIXME */ +float nanf(const char * tagp __attribute__((unused)) ) + { return __QNANF.float_val;} + + +const union _ieee_rep __QNANL = { __LONG_DOUBLE_QNAN_REP }; +/* +const union _ieee_rep __SNANL = { __LONG_DOUBLE_SNAN_REP }; +const union _ieee_rep __INFL = { __LONG_DOUBLE_INF_REP }; +const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP }; +*/ + +#undef nanl +/* FIXME */ +long double nanl (const char * tagp __attribute__((unused)) ) + { return __QNANL.ldouble_val;} diff --git a/winsup/mingw/mingwex/fpclassify.c b/winsup/mingw/mingwex/fpclassify.c new file mode 100644 index 0000000..f8cd8cb --- /dev/null +++ b/winsup/mingw/mingwex/fpclassify.c @@ -0,0 +1,20 @@ +#include <math.h> + +/* 'fxam' sets FPU flags C3,C2,C0 'fstsw' stores: + FP_NAN 001 0x0100 + FP_NORMAL 010 0x0400 + FP_INFINITE 011 0x0500 + FP_ZERO 100 0x4000 + FP_SUBNORMAL 110 0x4400 + +and sets C1 flag (signbit) if neg */ + +int __fpclassify (double _x){ + unsigned short sw; + __asm__ ( + "fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (_x) + ); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} diff --git a/winsup/mingw/mingwex/fpclassifyf.c b/winsup/mingw/mingwex/fpclassifyf.c new file mode 100644 index 0000000..aca4e59 --- /dev/null +++ b/winsup/mingw/mingwex/fpclassifyf.c @@ -0,0 +1,10 @@ +#include <math.h> +int __fpclassifyf (float _x){ + unsigned short sw; + __asm__ ( + "fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (_x) + ); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} diff --git a/winsup/mingw/mingwex/fpclassifyl.c b/winsup/mingw/mingwex/fpclassifyl.c new file mode 100644 index 0000000..9979d62 --- /dev/null +++ b/winsup/mingw/mingwex/fpclassifyl.c @@ -0,0 +1,10 @@ +#include <math.h> +int __fpclassifyl (long double _x){ + unsigned short sw; + __asm__ ( + "fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (_x) + ); + return sw & (FP_NAN | FP_NORMAL | FP_ZERO ); +} diff --git a/winsup/mingw/mingwex/fucom.c b/winsup/mingw/mingwex/fucom.c new file mode 100644 index 0000000..80c9372 --- /dev/null +++ b/winsup/mingw/mingwex/fucom.c @@ -0,0 +1,11 @@ +int +__fp_unordered_compare (long double x, long double y){ + unsigned short retval; + __asm__ ( + "fucom %%st(1);" + "fnstsw;" + : "=a" (retval) + : "t" (x), "u" (y) + ); + return retval; +} diff --git a/winsup/mingw/mingwex/fwide.c b/winsup/mingw/mingwex/fwide.c new file mode 100644 index 0000000..fc8bf5b --- /dev/null +++ b/winsup/mingw/mingwex/fwide.c @@ -0,0 +1,25 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + This is a minimal implementation for environments where + internationalization is not considered important. + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + +int +fwide(stream, mode) + FILE *stream; + int mode; + { + return -1; /* limited to byte orientation */ + } + diff --git a/winsup/mingw/mingwex/imaxabs.c b/winsup/mingw/mingwex/imaxabs.c new file mode 100644 index 0000000..b643cea --- /dev/null +++ b/winsup/mingw/mingwex/imaxabs.c @@ -0,0 +1,17 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + + This particular implementation requires the matching <inttypes.h>. +*/ + +#include <inttypes.h> + +intmax_t +imaxabs (intmax_t _j) + { return _j >= 0 ? _j : -_j; } + +long long __attribute__ ((alias ("imaxabs"))) llabs (long long); diff --git a/winsup/mingw/mingwex/imaxdiv.c b/winsup/mingw/mingwex/imaxdiv.c new file mode 100644 index 0000000..6acfcf6 --- /dev/null +++ b/winsup/mingw/mingwex/imaxdiv.c @@ -0,0 +1,25 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + +*/ + +#include <inttypes.h> + +imaxdiv_t +imaxdiv(intmax_t numer, intmax_t denom) +{ + imaxdiv_t result; + result.quot = numer / denom; + result.rem = numer % denom; + return result; +} + +long long __attribute__ ((alias ("imaxdiv"))) +lldiv (long long, long long); diff --git a/winsup/mingw/mingwex/isnan.c b/winsup/mingw/mingwex/isnan.c new file mode 100644 index 0000000..b38bc29 --- /dev/null +++ b/winsup/mingw/mingwex/isnan.c @@ -0,0 +1,14 @@ +#include <math.h> + +int +__isnan (double _x) +{ + unsigned short _sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (_sw) : "t" (_x)); + return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +#undef isnan +int __attribute__ ((alias ("__isnan"))) isnan (double); diff --git a/winsup/mingw/mingwex/isnanf.c b/winsup/mingw/mingwex/isnanf.c new file mode 100644 index 0000000..73fe0eb --- /dev/null +++ b/winsup/mingw/mingwex/isnanf.c @@ -0,0 +1,12 @@ +#include <math.h> +int +__isnanf (float _x) +{ + unsigned short _sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (_sw) : "t" (_x) ); + return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +int __attribute__ ((alias ("__isnanf"))) isnanf (float); diff --git a/winsup/mingw/mingwex/isnanl.c b/winsup/mingw/mingwex/isnanl.c new file mode 100644 index 0000000..86d0088 --- /dev/null +++ b/winsup/mingw/mingwex/isnanl.c @@ -0,0 +1,13 @@ +#include <math.h> + +int +__isnanl (long double _x) +{ + unsigned short _sw; + __asm__ ("fxam;" + "fstsw %%ax": "=a" (_sw) : "t" (_x)); + return (_sw & (FP_NAN | FP_NORMAL | FP_INFINITE | FP_ZERO | FP_SUBNORMAL)) + == FP_NAN; +} + +int __attribute__ ((alias ("__isnanl"))) isnanl (long double); diff --git a/winsup/mingw/mingwex/lltoa.c b/winsup/mingw/mingwex/lltoa.c new file mode 100644 index 0000000..28248a8 --- /dev/null +++ b/winsup/mingw/mingwex/lltoa.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +char* lltoa(long long _n, char * _c, int _i) + { return _i64toa (_n, _c, _i); } diff --git a/winsup/mingw/mingwex/lltow.c b/winsup/mingw/mingwex/lltow.c new file mode 100644 index 0000000..cdf45b7 --- /dev/null +++ b/winsup/mingw/mingwex/lltow.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +wchar_t* lltow(long long _n, wchar_t * _w, int _i) + { return _i64tow (_n, _w, _i); } diff --git a/winsup/mingw/mingwex/log2.c b/winsup/mingw/mingwex/log2.c new file mode 100644 index 0000000..4f14f26 --- /dev/null +++ b/winsup/mingw/mingwex/log2.c @@ -0,0 +1,8 @@ +#include <math.h> +double +log2 (double _x) +{ + double retval; + __asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)"); + return retval; +} diff --git a/winsup/mingw/mingwex/log2f.c b/winsup/mingw/mingwex/log2f.c new file mode 100644 index 0000000..576396c --- /dev/null +++ b/winsup/mingw/mingwex/log2f.c @@ -0,0 +1,8 @@ +#include <math.h> +float +log2f (float _x) +{ + float retval; + __asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)"); + return retval; +} diff --git a/winsup/mingw/mingwex/log2l.c b/winsup/mingw/mingwex/log2l.c new file mode 100644 index 0000000..c67d770 --- /dev/null +++ b/winsup/mingw/mingwex/log2l.c @@ -0,0 +1,8 @@ +#include <math.h> +long double +log2l (long double _x) +{ + long double retval; + __asm__ ("fyl2x;" : "=t" (retval) : "0" (_x), "u" (1.0L) : "st(1)"); + return retval; +} diff --git a/winsup/mingw/mingwex/math_stubs.c b/winsup/mingw/mingwex/math_stubs.c new file mode 100644 index 0000000..2254398 --- /dev/null +++ b/winsup/mingw/mingwex/math_stubs.c @@ -0,0 +1,12 @@ +
+#include <math.h>
+
+double copysign (double x, double y) {return _copysign(x, y);}
+float copysignf (float x, float y) {return _copysign(x, y);}
+double logb (double x) {return _logb(x);}
+float logbf (float x) {return _logb( x );}
+double nextafter(double x, double y) {return _nextafter(x, y);}
+float nextafterf(float x, float y) {return _nextafter(x, y);}
+double scalb (double x, long i) {return _scalb (x, i);}
+float scalbf (float x, long i) {return _scalb(x, i);}
+
diff --git a/winsup/mingw/mingwex/mbsinit.c b/winsup/mingw/mingwex/mbsinit.c new file mode 100644 index 0000000..c130afe --- /dev/null +++ b/winsup/mingw/mingwex/mbsinit.c @@ -0,0 +1,21 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + +int +mbsinit(ps) + const mbstate_t *ps; + { + return 1; /* don't have shift states */ + } + diff --git a/winsup/mingw/mingwex/mingw-fseek.c b/winsup/mingw/mingwex/mingw-fseek.c new file mode 100644 index 0000000..6a3b661 --- /dev/null +++ b/winsup/mingw/mingwex/mingw-fseek.c @@ -0,0 +1,119 @@ +/* + * Workaround for limitations on win9x where a file contents are + * not zero'd out if you seek past the end and then write. + * Copied from ming local-patch to binutils/bfd/libbfd.c written by + * Mumit Khan <khan@xraylith.wisc.edu> + */ + +#include <windows.h> +#include <stdio.h> +#include <io.h> + +#ifdef __GNUC__ +# define INLINE __inline__ +#elif defined _MSC_VER +# define INLINE __inline +#else +# define INLINE +#endif + +#define ZEROBLOCKSIZE 512 +static int __mingw_fseek_called; + +/* FIXME: put this in startup code and make os_platform_id global? + Or just get _osver from msvcrt.dll and bitest (_osver & 0x8000)? */ + +INLINE +static +int +__mingw_is_win9x (void) +{ + static DWORD os_platform_id = -1 ; + + if (os_platform_id == -1) + { + OSVERSIONINFO os_version_info; + memset (&os_version_info, 0, sizeof (OSVERSIONINFO)); + os_version_info.dwOSVersionInfoSize = sizeof (OSVERSIONINFO); + GetVersionEx (&os_version_info); + + os_platform_id = os_version_info.dwPlatformId; + } + + /* Don't even bother to check for Win32s. */ + return os_platform_id == VER_PLATFORM_WIN32_WINDOWS; +} + +/* The fseek in Win9x runtime does not zero out the file if seeking past + the end; if you don't want random stuff from your disk included in your + output DLL/executable, use this version instead. On WinNT/Win2k, it + just calls runtime fseek(). + + CHECK/FIXME: Does this work for both text and binary modes?? */ + + +int +__mingw_fseek (FILE *fp, long offset, int whence) +{ +# undef fseek + __mingw_fseek_called = 1; + return fseek (fp, offset, whence); +} + +int +__mingw_fwrite (const void *buffer, size_t size, size_t count, FILE *fp) +{ +# undef fwrite + if ( __mingw_is_win9x () && __mingw_fseek_called) + { + DWORD actual_length, current_position; + __mingw_fseek_called = 0; + fflush (fp); + actual_length = GetFileSize ((HANDLE) _get_osfhandle (fileno (fp)), + NULL); + current_position = SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), + 0, 0, FILE_CURRENT); +#ifdef DEBUG + printf ("__mingw_fwrite: current %ld, actual %ld\n", + current_position, actual_length); +#endif /* DEBUG */ + if (current_position > actual_length) + { + static char __mingw_zeros[ZEROBLOCKSIZE]; + long numleft; + + SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), + 0, 0, FILE_END); + numleft = current_position - actual_length; + +#ifdef DEBUG + printf ("__mingw_fwrite: Seeking %ld bytes past end\n", numleft); +#endif /* DEBUG */ + while (numleft > 0) + { + DWORD nzeros = (numleft > ZEROBLOCKSIZE) + ? ZEROBLOCKSIZE : numleft; + DWORD written; + if (! WriteFile ((HANDLE) _get_osfhandle (fileno (fp)), + __mingw_zeros, nzeros, &written, NULL)) + { + /* Best we can hope for, or at least DJ says so. */ + SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), + 0, 0, FILE_BEGIN); + return -1; + } + if (written < nzeros) + { + /* Likewise. */ + SetFilePointer ((HANDLE) _get_osfhandle (fileno (fp)), + 0, 0, FILE_BEGIN); + return -1; + } + + numleft -= written; + } + FlushFileBuffers ((HANDLE) _get_osfhandle (fileno (fp))); + } + } + return fwrite (buffer, size, count, fp); +} diff --git a/winsup/mingw/mingwex/rint.c b/winsup/mingw/mingwex/rint.c new file mode 100644 index 0000000..3198f4b --- /dev/null +++ b/winsup/mingw/mingwex/rint.c @@ -0,0 +1,6 @@ +#include <math.h> +double rint (double x){ + double retval; + __asm__ ("frndint;" : "=t" (retval) : "0" (x)); + return retval; +} diff --git a/winsup/mingw/mingwex/rintf.c b/winsup/mingw/mingwex/rintf.c new file mode 100644 index 0000000..0b05e8f --- /dev/null +++ b/winsup/mingw/mingwex/rintf.c @@ -0,0 +1,7 @@ +#include <math.h> + +float rintf (float x){ + float retval; + __asm__ ("frndint;": "=t" (retval) : "0" (x)); + return retval; +} diff --git a/winsup/mingw/mingwex/rintl.c b/winsup/mingw/mingwex/rintl.c new file mode 100644 index 0000000..ffc9d11 --- /dev/null +++ b/winsup/mingw/mingwex/rintl.c @@ -0,0 +1,7 @@ +#include <math.h> + +long double rintl (long double x){ + long double retval; + __asm__ ("frndint;": "=t" (retval) : "0" (x)); + return retval; +} diff --git a/winsup/mingw/mingwex/round.c b/winsup/mingw/mingwex/round.c new file mode 100644 index 0000000..9d8e949 --- /dev/null +++ b/winsup/mingw/mingwex/round.c @@ -0,0 +1,29 @@ +#include <fenv.h> + +double +round (double x) { + double retval; + unsigned short saved_cw, _cw; + __asm__ ( + "fnstcw %0;" + : "=m" (saved_cw) + ); /* save control word */ + _cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) + | (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */ + __asm__ ( + "fldcw %0;" + : + : "m" (_cw) + ); /* load the rounding control */ + __asm__ ( + "frndint;" + : "=t" (retval) + : "0" (x) + ); /* do the rounding */ + __asm__ ( + "fldcw %0;" + : + : "m" (saved_cw) + ); /* restore control word */ + return retval; +} diff --git a/winsup/mingw/mingwex/roundf.c b/winsup/mingw/mingwex/roundf.c new file mode 100644 index 0000000..6ae81bd --- /dev/null +++ b/winsup/mingw/mingwex/roundf.c @@ -0,0 +1,29 @@ +#include <fenv.h> + +float +roundf (float x) { + double retval; + unsigned short saved_cw, _cw; + __asm__ ( + "fnstcw %0;" + : "=m" (saved_cw) + ); /* save control word */ + _cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) + | (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */ + __asm__ ( + "fldcw %0;" + : + : "m" (_cw) + ); /* load the rounding control */ + __asm__ ( + "frndint;" + : "=t" (retval) + : "0" (x) + ); /* do the rounding */ + __asm__ ( + "fldcw %0;" + : + : "m" (saved_cw) + ); /* restore control word */ + return retval; +} diff --git a/winsup/mingw/mingwex/roundl.c b/winsup/mingw/mingwex/roundl.c new file mode 100644 index 0000000..de3334a --- /dev/null +++ b/winsup/mingw/mingwex/roundl.c @@ -0,0 +1,30 @@ +#include <fenv.h> + +long double +roundl (long double x) { + long double retval; + unsigned short saved_cw, _cw; + __asm__ ( + "fnstcw %0;" + : "=m" (saved_cw) + ); /* save control word */ + _cw = ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) + | (x > 0.0 ? FE_UPWARD : FE_DOWNWARD); /* round away from zero */ + __asm__ ( + "fldcw %0;" + : + : "m" (_cw) + ); /* load the rounding control */ + __asm__ ( + "frndint;" + : "=t" (retval) + : "0" (x) + ); /* do the rounding */ + __asm__ ( + "fldcw %0;" + : + : "m" (saved_cw) + ); /* restore control word */ + return retval; +} + diff --git a/winsup/mingw/mingwex/signbit.c b/winsup/mingw/mingwex/signbit.c new file mode 100644 index 0000000..7f86c86 --- /dev/null +++ b/winsup/mingw/mingwex/signbit.c @@ -0,0 +1,13 @@ +#define __FP_SIGNBIT 0x0200 + +int __signbit (double x) { + unsigned short sw; + __asm__ ("fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (x) ); + return sw & __FP_SIGNBIT; +} + +#undef signbit +int __attribute__ ((alias ("__signbit"))) signbit (double); + diff --git a/winsup/mingw/mingwex/signbitf.c b/winsup/mingw/mingwex/signbitf.c new file mode 100644 index 0000000..5bbf675 --- /dev/null +++ b/winsup/mingw/mingwex/signbitf.c @@ -0,0 +1,10 @@ +#define __FP_SIGNBIT 0x0200 + +int __signbitf (float x) { + unsigned short sw; + __asm__ ("fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (x) ); + return sw & __FP_SIGNBIT; +} +int __attribute__ ((alias ("__signbitf"))) signbitf (float); diff --git a/winsup/mingw/mingwex/signbitl.c b/winsup/mingw/mingwex/signbitl.c new file mode 100644 index 0000000..78f9903 --- /dev/null +++ b/winsup/mingw/mingwex/signbitl.c @@ -0,0 +1,11 @@ +#define __FP_SIGNBIT 0x0200 + +int __signbitl (long double x) { + unsigned short sw; + __asm__ ("fxam; fstsw %%ax;" + : "=a" (sw) + : "t" (x) ); + return sw & __FP_SIGNBIT; +} + +int __attribute__ ((alias ("__signbitl"))) signbitl (long double); diff --git a/winsup/mingw/mingwex/sitest.c b/winsup/mingw/mingwex/sitest.c new file mode 100644 index 0000000..9e06bf1 --- /dev/null +++ b/winsup/mingw/mingwex/sitest.c @@ -0,0 +1,1527 @@ +/* + sitest -- exercise features of C99 <stdint.h> and <inttypes.h> + + This source code has been placed into the PUBLIC DOMAIN by its author. + + last edit: 1999/11/05 gwyn@arl.mil + + Tries to accommodate pre-C99 versions of <inttypes.h>. + + Takes advantage of __Q8_* symbols defined by a particular + implementation of <stdint.h>, but doesn't require them. + + NOTE: This is not a thorough validation test of the facilities. +*/ + +#include <errno.h> +#include <limits.h> /* for CHAR_BIT */ +#include <stdio.h> +#include <stddef.h> /* for ptrdiff_t */ +#include <stdlib.h> +#include <string.h> + +#include <inttypes.h> /* embeds <stdint.h> */ +#include <signal.h> /* for sig_atomic_t */ +#if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */ +#include <wchar.h> +#endif + +#include <inttypes.h> /* test idempotency */ + +#if 1 /* __STDC_VERSION__ >= 199901 */ +#ifndef __Q8_QT +#define __Q8_QT long long +#endif +#endif + +#ifdef PRIdMAX +#define HAVE_PRIdMAX +#ifndef __Q8_MT +#define __Q8_MT intmax_t +#endif +#else +#ifdef PRIdLEAST64 +#ifndef __Q8_MT +#define __Q8_MT int_least64_t +#endif +#define PRIdMAX PRIdLEAST64 +#else +#ifndef __Q8_MT +#define __Q8_MT long +#endif +#define PRIdMAX "ld" +#endif +#endif + +#ifdef PRIuMAX +#define HAVE_PRIuMAX +#define U__Q8_MT uintmax_t +#else +#ifdef PRIuLEAST64 +#define U__Q8_MT uint_least64_t +#define PRIuMAX PRIuLEAST64 +#else +#define U__Q8_MT unsigned long +#define PRIuMAX "lu" +#endif +#endif + +#define STR_SUB(s) #s +#define STRINGIZE(s) STR_SUB(s) /* extra level to expand argument */ + +#if defined(SCNo32) || defined(PRIo32) +static int32_t int32; +#endif +static int_least16_t intl16; +static uint_least16_t uintl16; +static uint_fast16_t uintf16; +static intmax_t intmax; +static uintmax_t uintmax; + +int +main() { + int status = 0; /* exit status to be returned */ + + /* <stdint.h> features: */ + + printf("CHAR_BIT=%u\n", (unsigned)CHAR_BIT ); + printf("sizeof(char)=%u\n", (unsigned)sizeof(char)); /* s.b. 1 */ + printf("sizeof(short)=%u\n", (unsigned)sizeof(short)); + printf("sizeof(int)=%u\n", (unsigned)sizeof(int)); + printf("sizeof(long)=%u\n", (unsigned)sizeof(long)); +#ifdef __Q8_QT + printf("sizeof(long long)=%u\n", (unsigned)sizeof(__Q8_QT)); +#endif + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(ptrdiff_t)=%u\n", (unsigned)sizeof(ptrdiff_t)); + printf("sizeof(size_t)=%u\n", (unsigned)sizeof(size_t)); + printf("sizeof(sig_atomic_t)=%u\n", (unsigned)sizeof(sig_atomic_t)); + printf("sizeof(wchar_t)=%u\n", (unsigned)sizeof(wchar_t)); +#if defined(WINT_MAX) || __STDC_VERSION__ >= 199901 + printf("sizeof(wint_t)=%u\n", (unsigned)sizeof(wint_t)); +#else + printf("*** wint_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INT8_MAX + printf("sizeof(int8_t)=%u\n", (unsigned)sizeof(int8_t)); + printf("sizeof(uint8_t)=%u\n", (unsigned)sizeof(uint8_t)); +#endif +#ifdef INT9_MAX + printf("sizeof(int9_t)=%u\n", (unsigned)sizeof(int9_t)); + printf("sizeof(uint9_t)=%u\n", (unsigned)sizeof(uint9_t)); +#endif +#ifdef INT12_MAX + printf("sizeof(int12_t)=%u\n", (unsigned)sizeof(int12_t)); + printf("sizeof(uint12_t)=%u\n", (unsigned)sizeof(uint12_t)); +#endif +#ifdef INT16_MAX + printf("sizeof(int16_t)=%u\n", (unsigned)sizeof(int16_t)); + printf("sizeof(uint16_t)=%u\n", (unsigned)sizeof(uint16_t)); +#endif +#ifdef INT18_MAX + printf("sizeof(int18_t)=%u\n", (unsigned)sizeof(int18_t)); + printf("sizeof(uint18_t)=%u\n", (unsigned)sizeof(uint18_t)); +#endif +#ifdef INT24_MAX + printf("sizeof(int24_t)=%u\n", (unsigned)sizeof(int24_t)); + printf("sizeof(uint24_t)=%u\n", (unsigned)sizeof(uint24_t)); +#endif +#ifdef INT32_MAX + printf("sizeof(int32_t)=%u\n", (unsigned)sizeof(int32_t)); + printf("sizeof(uint32_t)=%u\n", (unsigned)sizeof(uint32_t)); +#endif +#ifdef INT36_MAX + printf("sizeof(int36_t)=%u\n", (unsigned)sizeof(int36_t)); + printf("sizeof(uint36_t)=%u\n", (unsigned)sizeof(uint36_t)); +#endif +#ifdef INT40_MAX + printf("sizeof(int40_t)=%u\n", (unsigned)sizeof(int40_t)); + printf("sizeof(uint40_t)=%u\n", (unsigned)sizeof(uint40_t)); +#endif +#ifdef INT48_MAX + printf("sizeof(int48_t)=%u\n", (unsigned)sizeof(int48_t)); + printf("sizeof(uint48_t)=%u\n", (unsigned)sizeof(uint48_t)); +#endif +#ifdef INT60_MAX + printf("sizeof(int60_t)=%u\n", (unsigned)sizeof(int60_t)); + printf("sizeof(uint60_t)=%u\n", (unsigned)sizeof(uint60_t)); +#endif +#ifdef INT64_MAX + printf("sizeof(int64_t)=%u\n", (unsigned)sizeof(int64_t)); + printf("sizeof(uint64_t)=%u\n", (unsigned)sizeof(uint64_t)); +#endif +#ifdef INT72_MAX + printf("sizeof(int72_t)=%u\n", (unsigned)sizeof(int72_t)); + printf("sizeof(uint72_t)=%u\n", (unsigned)sizeof(uint72_t)); +#endif +#ifdef INT128_MAX + printf("sizeof(int128_t)=%u\n", (unsigned)sizeof(int128_t)); + printf("sizeof(uint128_t)=%u\n", (unsigned)sizeof(uint128_t)); +#endif + printf("sizeof(int_least8_t)=%u\n", (unsigned)sizeof(int_least8_t)); + printf("sizeof(uint_least8_t)=%u\n", (unsigned)sizeof(uint_least8_t)); + printf("sizeof(int_least16_t)=%u\n", (unsigned)sizeof(int_least16_t)); + printf("sizeof(uint_least16_t)=%u\n", (unsigned)sizeof(uint_least16_t)); + printf("sizeof(int_least32_t)=%u\n", (unsigned)sizeof(int_least32_t)); + printf("sizeof(uint_least32_t)=%u\n", (unsigned)sizeof(uint_least32_t)); +#ifdef INT_LEAST64_MAX + printf("sizeof(int_least64_t)=%u\n", (unsigned)sizeof(int_least64_t)); + printf("sizeof(uint_least64_t)=%u\n", (unsigned)sizeof(uint_least64_t)); +#else + printf("*** uint_least64_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INT_LEAST128_MAX + printf("sizeof(int_least128_t)=%u\n", (unsigned)sizeof(int_least128_t)); + printf("sizeof(uint_least128_t)=%u\n", + (unsigned)sizeof(uint_least128_t)); +#endif + printf("sizeof(int_fast8_t)=%u\n", (unsigned)sizeof(int_fast8_t)); + printf("sizeof(uint_fast8_t)=%u\n", (unsigned)sizeof(uint_fast8_t)); + printf("sizeof(int_fast16_t)=%u\n", (unsigned)sizeof(int_fast16_t)); + printf("sizeof(uint_fast16_t)=%u\n", (unsigned)sizeof(uint_fast16_t)); + printf("sizeof(int_fast32_t)=%u\n", (unsigned)sizeof(int_fast32_t)); + printf("sizeof(uint_fast32_t)=%u\n", (unsigned)sizeof(uint_fast32_t)); +#ifdef INT_FAST64_MAX + printf("sizeof(int_fast64_t)=%u\n", (unsigned)sizeof(int_fast64_t)); + printf("sizeof(uint_fast64_t)=%u\n", (unsigned)sizeof(uint_fast64_t)); +#else + printf("*** int_fast64_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INT_FAST128_MAX + printf("sizeof(int_fast128_t)=%u\n", (unsigned)sizeof(int_fast128_t)); + printf("sizeof(uint_fast128_t)=%u\n", (unsigned)sizeof(uint_fast128_t)); +#endif +#if defined(INTPTR_MAX) + printf("sizeof(intptr_t)=%u\n", (unsigned)sizeof(intptr_t)); +#if defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); +#else + printf("*** intptr_t is defined but uintptr_t isn't ***\n"); + status = EXIT_FAILURE; +#endif +#elif defined(UINTPTR_MAX) + printf("sizeof(uintptr_t)=%u\n", (unsigned)sizeof(uintptr_t)); + printf("*** uintptr_t is defined but intptr_t isn't ***\n"); + status = EXIT_FAILURE; +#else + printf("*** neither intptr_t nor uintptr_t is defined ***\n"); + status = EXIT_FAILURE; +#endif +#ifdef INTMAX_MAX + printf("sizeof(intmax_t)=%u\n", (unsigned)sizeof(intmax_t)); + printf("sizeof(uintmax_t)=%u\n", (unsigned)sizeof(uintmax_t)); +#else + printf("*** intmax_t isn't defined ***\n"); + status = EXIT_FAILURE; +#endif + +#ifdef INT8_MAX + printf("INT8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT8_MIN); + printf("INT8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT8_MAX); + printf("UINT8_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT8_MAX); +#endif +#ifdef INT9_MAX + printf("INT9_MIN=%"PRIdMAX"\n", (__Q8_MT)INT9_MIN); + printf("INT9_MAX=%"PRIdMAX"\n", (__Q8_MT)INT9_MAX); + printf("UINT9_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT9_MAX); +#endif +#ifdef INT12_MAX + printf("INT12_MIN=%"PRIdMAX"\n", (__Q8_MT)INT12_MIN); + printf("INT12_MAX=%"PRIdMAX"\n", (__Q8_MT)INT12_MAX); + printf("UINT12_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT12_MAX); +#endif +#ifdef INT16_MAX + printf("INT16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT16_MIN); + printf("INT16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT16_MAX); + printf("UINT16_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT16_MAX); +#endif +#ifdef INT18_MAX + printf("INT18_MIN=%"PRIdMAX"\n", (__Q8_MT)INT18_MIN); + printf("INT18_MAX=%"PRIdMAX"\n", (__Q8_MT)INT18_MAX); + printf("UINT18_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT18_MAX); +#endif +#ifdef INT24_MAX + printf("INT24_MIN=%"PRIdMAX"\n", (__Q8_MT)INT24_MIN); + printf("INT24_MAX=%"PRIdMAX"\n", (__Q8_MT)INT24_MAX); + printf("UINT24_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT24_MAX); +#endif +#ifdef INT32_MAX + printf("INT32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT32_MIN); + printf("INT32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT32_MAX); + printf("UINT32_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT32_MAX); +#endif +#ifdef INT36_MAX + printf("INT36_MIN=%"PRIdMAX"\n", (__Q8_MT)INT36_MIN); + printf("INT36_MAX=%"PRIdMAX"\n", (__Q8_MT)INT36_MAX); + printf("UINT36_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT36_MAX); +#endif +#ifdef INT40_MAX + printf("INT40_MIN=%"PRIdMAX"\n", (__Q8_MT)INT40_MIN); + printf("INT40_MAX=%"PRIdMAX"\n", (__Q8_MT)INT40_MAX); + printf("UINT40_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT40_MAX); +#endif +#ifdef INT48_MAX + printf("INT48_MIN=%"PRIdMAX"\n", (__Q8_MT)INT48_MIN); + printf("INT48_MAX=%"PRIdMAX"\n", (__Q8_MT)INT48_MAX); + printf("UINT48_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT48_MAX); +#endif +#ifdef INT60_MAX + printf("INT60_MIN=%"PRIdMAX"\n", (__Q8_MT)INT60_MIN); + printf("INT60_MAX=%"PRIdMAX"\n", (__Q8_MT)INT60_MAX); + printf("UINT60_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT60_MAX); +#endif +#ifdef INT64_MAX + printf("INT64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT64_MIN); + printf("INT64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT64_MAX); + printf("UINT64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT64_MAX); +#endif +#ifdef INT72_MAX + printf("INT72_MIN=%"PRIdMAX"\n", (__Q8_MT)INT72_MIN); + printf("INT72_MAX=%"PRIdMAX"\n", (__Q8_MT)INT72_MAX); + printf("UINT72_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT72_MAX); +#endif +#ifdef INT128_MAX + printf("INT128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT128_MIN); + printf("INT128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT128_MAX); + printf("UINT128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT128_MAX); +#endif + printf("INT_LEAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MIN); + printf("INT_LEAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST8_MAX); + printf("UINT_LEAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST8_MAX); + printf("INT_LEAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MIN); + printf("INT_LEAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST16_MAX); + printf("UINT_LEAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST16_MAX); + printf("INT_LEAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MIN); + printf("INT_LEAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST32_MAX); + printf("UINT_LEAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_LEAST32_MAX); +#ifdef INT_LEAST64_MAX + printf("INT_LEAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MIN); + printf("INT_LEAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST64_MAX); + printf("UINT_LEAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST64_MAX); +#endif +#ifdef INT_LEAST128_MAX + printf("INT_LEAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MIN); + printf("INT_LEAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_LEAST128_MAX); + printf("UINT_LEAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_LEAST128_MAX); +#endif + printf("INT_FAST8_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MIN); + printf("INT_FAST8_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST8_MAX); + printf("UINT_FAST8_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST8_MAX); + printf("INT_FAST16_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MIN); + printf("INT_FAST16_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST16_MAX); + printf("UINT_FAST16_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST16_MAX); + printf("INT_FAST32_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MIN); + printf("INT_FAST32_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST32_MAX); + printf("UINT_FAST32_MAX=%"PRIuMAX"\n", + (U__Q8_MT)UINT_FAST32_MAX); +#ifdef INT_FAST64_MAX + printf("INT_FAST64_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MIN); + printf("INT_FAST64_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST64_MAX); + printf("UINT_FAST64_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST64_MAX); +#endif +#ifdef INT_FAST128_MAX + printf("INT_FAST128_MIN=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MIN); + printf("INT_FAST128_MAX=%"PRIdMAX"\n", (__Q8_MT)INT_FAST128_MAX); + printf("UINT_FAST128_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINT_FAST128_MAX); +#endif +#ifdef INTPTR_MAX + printf("INTPTR_MIN=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MIN); + printf("INTPTR_MAX=%"PRIdMAX"\n", (__Q8_MT)INTPTR_MAX); +#endif +#ifdef UINTPTR_MAX + printf("UINTPTR_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTPTR_MAX); +#endif +#ifdef INTMAX_MAX + printf("INTMAX_MIN=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MIN); + printf("INTMAX_MAX=%"PRIdMAX"\n", (__Q8_MT)INTMAX_MAX); + printf("UINTMAX_MAX=%"PRIuMAX"\n", (U__Q8_MT)UINTMAX_MAX); +#endif +#ifdef PTRDIFF_MAX + printf("PTRDIFF_MIN=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MIN); + printf("PTRDIFF_MAX=%"PRIdMAX"\n", (__Q8_MT)PTRDIFF_MAX); +#endif +#ifdef SIG_ATOMIC_MAX +#if SIG_ATOMIC_MIN < 0 + printf("SIG_ATOMIC_MIN=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIdMAX"\n", (__Q8_MT)SIG_ATOMIC_MAX); +#else + printf("SIG_ATOMIC_MIN=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MIN); + printf("SIG_ATOMIC_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIG_ATOMIC_MAX); +#endif +#endif +#ifdef SIZE_MAX + printf("SIZE_MAX=%"PRIuMAX"\n", (U__Q8_MT)SIZE_MAX); +#endif + +#ifdef WCHAR_MAX +#if WCHAR_MIN < 0 + printf("WCHAR_MIN=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIdMAX"\n", (__Q8_MT)WCHAR_MAX); +#else + printf("WCHAR_MIN=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MIN); + printf("WCHAR_MAX=%"PRIuMAX"\n", (U__Q8_MT)WCHAR_MAX); +#endif +#endif +#ifdef WINT_MAX +#if WINT_MIN < 0 + printf("WINT_MIN=%"PRIdMAX"\n", (__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIdMAX"\n", (__Q8_MT)WINT_MAX); +#else + printf("WINT_MIN=%"PRIuMAX"\n", (U__Q8_MT)WINT_MIN); + printf("WINT_MAX=%"PRIuMAX"\n", (U__Q8_MT)WINT_MAX); +#endif +#endif + + /* + 7.18.4 Macros for integer constants + */ + + /* INTn_C for n=8 and 16 were at one point unimplementable + on most platforms, so they're treated as "optional": */ +#ifdef INT8_C + if ( INT8_C(-123) != -123 ) + printf("*** INT8_C(-123) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT8_C(-123) + ); + if ( UINT8_C(123) != 123 ) + printf("*** UINT8_C(123) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT8_C(123) + ); +#endif +#ifdef INT16_C + if ( INT16_C(-12345) != -12345 ) + printf("*** INT16_C(-12345) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT16_C(-12345) + ); + if ( UINT16_C(12345) != 12345 ) + printf("*** UINT16_C(12345) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT16_C(12345) + ); +#endif + if ( INT32_C(-123456789) != -123456789 ) + printf("*** INT32_C(-123456789) produced %"PRIdMAX" ***\n", + (__Q8_MT)INT32_C(-123456789) + ); + if ( UINT32_C(123456789) != 123456789 ) + printf("*** UINT32_C(123456789) produced %"PRIuMAX" ***\n", + (U__Q8_MT)UINT32_C(123456789) + ); +#ifdef INT_LEAST64_MAX + if ( INT64_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INT64_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INT64_C(-1234567890123456789) + ); + if ( UINT64_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINT64_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINT64_C(1234567890123456789) + ); +#endif +#ifdef INTMAX_MAX + if ( INTMAX_C(-1234567890123456789) != -1234567890123456789 ) + printf("*** INTMAX_C(-1234567890123456789) produced %"PRIdMAX + " ***\n", + (__Q8_MT)INTMAX_C(-1234567890123456789) + ); + if ( UINTMAX_C(1234567890123456789) != 1234567890123456789 ) + printf("*** UINTMAX_C(1234567890123456789) produced %"PRIuMAX + " ***\n", + (U__Q8_MT)UINTMAX_C(1234567890123456789) + ); +#endif + + /* <inttypes.h> features: */ + +#if __STDC_VERSION__ >= 199901 + printf("sizeof(imaxdiv_t)=%u\n", (unsigned)sizeof(imaxdiv_t)); +#endif + + /* + 7.8.1 Macros for format specifiers + */ + + { + /* scanf these strings */ + static const char in_dn[] = "Z119bZ"; + static const char in_dmo[] = "Z-0119bZ"; + static const char in_dspx[] = "Z \t\n +0X119bZ"; + static const char in_dsmx[] = "Z \t\n -0x119bZ"; + static const char in_dsn[] = "Z \t\n 119bZ"; + static const char in_dp[] = "Z+119bZ"; + static const char in_dpx[] = "Z+0X119bz"; + + /* sprintf into this */ + static char buffer[1024]; + +#define SCAN(buf,fs,var,exp) if ( sscanf(buf, "Z%" fs, &var) != 1 ) \ + { \ + printf("*** " #fs "=" STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( var != (exp) ) \ + { \ + printf("*** " #fs "=" STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %" fs " ***\n", var \ + ); \ + status = EXIT_FAILURE; \ + } \ + else + +#define PRINT(fs,var,exp) if ( sprintf(buffer, "%" fs, var ) <= 0 ) \ + { \ + printf("*** " #fs "=" STR_SUB(fs) \ + " failed ***\n" \ + ); \ + status = EXIT_FAILURE; \ + } \ + else if ( strcmp(buffer, STR_SUB(exp)) != 0 ) \ + { \ + printf("*** " #fs "=" STR_SUB(fs) \ + " should be: " STR_SUB(exp) \ + ", was: %s ***\n", buffer \ + ); \ + status = EXIT_FAILURE; \ + } \ + else + +#ifdef SCNo32 + SCAN(in_dn, SCNo32, int32, 9); +#endif +#ifdef PRIo32 + PRINT(PRIo32, int32, 11); +#endif + SCAN(in_dmo, SCNiLEAST16, intl16, -9); + SCAN(in_dspx, SCNdLEAST16, intl16, 0); + SCAN(in_dsmx, SCNiLEAST16, intl16, -4507); + PRINT(PRIdLEAST16, intl16, -4507); + PRINT(PRIiLEAST16, intl16, -4507); + SCAN(in_dsn, SCNxLEAST16, uintl16, 4507); + PRINT(PRIoLEAST16, uintl16, 10633); + PRINT(PRIuLEAST16, uintl16, 4507); + PRINT(PRIxLEAST16, uintl16, 119b); + PRINT(PRIXLEAST16, uintl16, 119B); + SCAN(in_dp, SCNxFAST16, uintf16, 4507); + PRINT(PRIxFAST16, uintf16, 119b); +#ifdef SCNdMAX + SCAN(in_dp, SCNdMAX, intmax, 119); +#endif +#ifdef PRIiMAX + PRINT(PRIiMAX, intmax, 119); +#endif +#ifdef SCNoMAX + SCAN(in_dpx, SCNoMAX, uintmax, 0); +#endif +#ifdef PRIxMAX + PRINT(PRIxMAX, uintmax, 0); +#endif + /* Obviously there should be a much larger battery of such tests. */ + } + +#if defined(INTMAX_MAX) /* <inttypes.h> has C99 features */ + /* + 7.8.2 Functions for greatest-width integer types + */ + + { + static struct + { + intmax_t input; + intmax_t expect; + } abs_data[] = + { +#ifdef INT8_MAX + {INT8_MAX, INT8_MAX}, + {-INT8_MAX, INT8_MAX}, + {UINT8_MAX, UINT8_MAX}, +#endif + +#ifdef INT16_MAX + { INT16_MAX, INT16_MAX}, + { -INT16_MAX, INT16_MAX}, + { UINT16_MAX, UINT16_MAX}, +#endif +#ifdef INT32_MAX + { INT32_MAX, INT32_MAX}, + { -INT32_MAX, INT32_MAX}, +#ifdef INT_LEAST64_MAX + { UINT32_MAX, UINT32_MAX}, +#endif +#endif +#ifdef INT64_MAX + { INT64_MAX, INT64_MAX}, + { -INT64_MAX, INT64_MAX}, +#endif + { INT_LEAST8_MAX, INT_LEAST8_MAX}, + { -INT_LEAST8_MAX, INT_LEAST8_MAX}, + { UINT_LEAST8_MAX, UINT_LEAST8_MAX}, + { INT_LEAST16_MAX, INT_LEAST16_MAX}, + { -INT_LEAST16_MAX, INT_LEAST16_MAX}, + { UINT_LEAST16_MAX, UINT_LEAST16_MAX}, + { INT_LEAST32_MAX, INT_LEAST32_MAX}, + { -INT_LEAST32_MAX, INT_LEAST32_MAX}, +#ifdef INT_LEAST64_MAX + { UINT_LEAST32_MAX, UINT_LEAST32_MAX}, + { INT_LEAST64_MAX, INT_LEAST64_MAX}, + { -INT_LEAST64_MAX, INT_LEAST64_MAX}, +#endif + { INT_FAST8_MAX, INT_FAST8_MAX}, + { -INT_FAST8_MAX, INT_FAST8_MAX}, + { UINT_FAST8_MAX, UINT_FAST8_MAX}, + { INT_FAST16_MAX, INT_FAST16_MAX}, + { -INT_FAST16_MAX, INT_FAST16_MAX}, + { UINT_FAST16_MAX, UINT_FAST16_MAX}, + { INT_FAST32_MAX, INT_FAST32_MAX}, + { -INT_FAST32_MAX, INT_FAST32_MAX}, +#ifdef INT_FAST64_MAX + { UINT_FAST32_MAX, UINT_FAST32_MAX}, + { INT_FAST64_MAX, INT_FAST64_MAX}, + { -INT_FAST64_MAX, INT_FAST64_MAX}, +#endif +#ifdef INTPTR_MAX + { INTPTR_MAX, INTPTR_MAX}, + { -INTPTR_MAX, INTPTR_MAX}, +#endif +#ifdef UINTPTR_MAX + { UINTPTR_MAX, UINTPTR_MAX}, +#endif + { INTMAX_MAX, INTMAX_MAX}, +#ifdef PTRDIFF_MAX + { PTRDIFF_MAX, PTRDIFF_MAX}, +#endif +#ifdef SIG_ATOMIC_MAX + { SIG_ATOMIC_MAX, SIG_ATOMIC_MAX}, +#if SIG_ATOMIC_MIN < 0 + { -SIG_ATOMIC_MAX, SIG_ATOMIC_MAX}, +#endif +#endif +#ifdef SIZE_MAX + { SIZE_MAX, SIZE_MAX}, +#endif +#ifdef WCHAR_MAX + { WCHAR_MAX, WCHAR_MAX}, +#if WCHAR_MIN < 0 + { -WCHAR_MAX, WCHAR_MAX}, +#endif +#endif +#ifdef WINT_MAX + { WINT_MAX, WINT_MAX}, +#if WINT_MIN < 0 + { -WINT_MAX, WINT_MAX}, +#endif +#endif + { 127, 127}, + { -127, 127}, + { 128, 128}, + { -127-1, 128}, + { 255, 255}, + { -256+1, 255}, + { 256, 256}, + { -256, 256}, + { 32767, 32767}, + { -32767, 32767}, + { 32768, 32768}, + { -32767-1, 32768}, + { 65535, 65535}, + { -65536+1, 65535}, + { 65536, 65536}, + { -65536, 65536}, + { 2147483647, 2147483647}, + { -2147483647, 2147483647}, + { 2147483648LL, 2147483648LL}, + { -2147483647LL-1, 2147483648LL}, +#ifdef INT_LEAST64_MAX + { 4294967295LL, 4294967295LL}, + { -4294967296LL+1, 4294967295LL}, + { 4294967296LL, 4294967296LL}, + { -4294967296LL, 4294967296LL}, + { 9223372036854775807LL, 9223372036854775807LL}, + { -9223372036854775807LL, 9223372036854775807LL}, + { 1234567890123456789LL, 1234567890123456789LL}, + { -1234567890123456789LL, 1234567890123456789LL}, +#endif + { 1, 1}, + { -1, 1}, + { 2, 2}, + { -2, 2}, + { 10, 10}, + { -10, 10}, + { 16, 16}, + { -16, 16}, + /* Other test cases can be added here. */ + {0, 0} /* terminates the list */ + }, *adp=abs_data; + int count=0; + do{ + intmax = imaxabs(adp->input); + count++; + if (intmax != adp->expect ) + { + + printf("*** imaxabs(%"PRIdMAX") failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", + adp->input, adp->expect, intmax + ); + status = EXIT_FAILURE; + } + } + while ( adp++->input != 0 ); + } + + { + imaxdiv_t result; + static struct + { + intmax_t numer; + intmax_t denom; + intmax_t exp_quot; + intmax_t exp_rem; + } div_data[] = + { + { 0, 1, 0, 0}, + { 0, -1, 0, 0}, + { 0, 2, 0, 0}, + { 0, -2, 0, 0}, + { 0, 5, 0, 0}, + { 0, -5, 0, 0}, + { 1, 1, 1, 0}, + { 1, -1, -1, 0}, + { 1, 2, 0, 1}, + { 1, -2, 0, 1}, + { 1, 5, 0, 1}, + { 1, -5, 0, 1}, + { -1, 1, -1, 0}, + { -1, -1, 1, 0}, + { -1, 2, 0, -1}, + { -1, -2, 0, -1}, + { -1, 5, 0, -1}, + { -1, -5, 0, -1}, + { 2, 1, 2, 0}, + { 2, -1, -2, 0}, + { 2, 2, 1, 0}, + { 2, -2, -1, 0}, + { 2, 5, 0, 2}, + { 2, -5, 0, 2}, + { -2, 1, -2, 0}, + { -2, -1, 2, 0}, + { -2, 2, -1, 0}, + { -2, -2, 1, 0}, + { -2, 5, 0, -2}, + { -2, -5, 0, -2}, + { 17, 5, 3, 2}, + { -17, -5, 3, -2}, + { 17, -5, -3, 2}, + { -17, 5, -3, -2}, + { 2147483647, 1, 2147483647, 0}, + { -2147483647LL, 1, -2147483647LL, 0}, + { 2147483648LL, 1LL, 2147483648LL, 0LL}, + { -2147483647-1LL, 1LL, -2147483647-1LL, 0LL}, + { 2147483647LL, 2LL, 1073741823LL, 1LL}, + { -2147483647LL, 2LL, -1073741823LL, -1LL}, + { 2147483648LL, 2LL, 1073741824LL, 0LL}, + { -2147483647-1LL, 2LL, -1073741824LL, 0LL}, +#ifdef INT_LEAST64_MAX /* else might support only 32 bits */ + { 4294967295LL, 1LL, 4294967295LL, 0LL}, + { -4294967296LL+1LL, 1LL, -4294967296LL+1, 0}, + { 4294967296LL, 1, 4294967296LL, 0}, + { -4294967296LL, 1LL, -4294967296LL, 0LL}, + { 4294967295LL, -1LL, -4294967296+1LL, 0LL}, + { -4294967296+1LL, -1LL, 4294967295LL, 0LL}, + { 4294967296LL, -1LL, -4294967296LL, 0LL}, + { -4294967296LL, -1LL, 4294967296LL, 0LL}, + { 4294967295LL, 2LL, 2147483647LL, 1LL}, + { -4294967296+1LL, 2LL, -2147483647LL, -1LL}, + { 4294967296LL, 2LL, 2147483648LL, 0LL}, + { -4294967296LL, 2LL, -2147483647-1LL, 0LL}, + { 4294967295LL, 2147483647LL, 2LL, 1LL}, + { -4294967296+1LL, 2147483647LL, -2LL, -1LL}, + { 4294967296LL, 2147483647LL, 2LL, 2LL}, + { -4294967296LL, 2147483647LL, -2LL, -2LL}, + { 4294967295LL, -2147483647LL, -2LL, 1LL}, + { -4294967296+1LL, -2147483647LL, 2LL, -1LL}, + { 4294967296LL, -2147483647LL, -2LL, 2LL}, + { -4294967296LL, -2147483647LL, 2LL, -2LL}, + { 4294967295LL, 2147483648LL, 1LL, 2147483647LL}, + { -4294967296+1LL, 2147483648LL, -1LL, -2147483647LL}, + { 4294967296LL, 2147483648LL, 2LL, 0LL}, + { -4294967296LL, 2147483648LL, -2LL, 0LL}, + { 4294967295LL, -2147483647-1LL, -1LL, 2147483647LL}, + { -4294967296+1LL, -2147483647-1LL, 1LL, -2147483647LL}, + { 4294967296LL, -2147483647-1LL, -2LL, 0LL}, + { -4294967296LL, -2147483647-1LL, 2LL, 0LL}, + { 9223372036854775807LL, 1LL, 9223372036854775807LL, 0LL}, + { -9223372036854775807LL, 1LL, -9223372036854775807LL, 0LL}, + { 9223372036854775807LL, 2LL, 4611686018427387903LL, 1LL}, + { -9223372036854775807LL, 2LL, -4611686018427387903LL, -1LL}, +#endif + /* There should be a much larger battery of such tests. */ + { 0, 0, 0, 0} /* 0 denom terminates the list */ + }, *ddp; + + for ( ddp = div_data; ddp->denom != 0; ++ddp ) + if ( (result = imaxdiv(ddp->numer, ddp->denom)).quot + != ddp->exp_quot || result.rem != ddp->exp_rem + ) { + printf("*** imaxdiv(%"PRIdMAX",%"PRIdMAX + ") failed; should be: (%"PRIdMAX",%"PRIdMAX + "), was: (%"PRIdMAX",%"PRIdMAX") ***\n", + ddp->numer, ddp->denom, ddp->exp_quot, + ddp->exp_rem, result.quot, result.rem + ); + status = EXIT_FAILURE; + } + } + + { + char *endptr; + wchar_t *wendptr; + static char saved[64]; /* holds copy of input string */ + static wchar_t wnptr[64]; /* holds wide copy of test string */ + static int warned; /* "warned for null endptr" flag */ + register int i; + static struct + { + char * nptr; + int base; + intmax_t exp_val; + int exp_len; + } str_data[] = + { + { "", 0, 0, 0}, + { "", 2, 0, 0}, + { "", 8, 0, 0}, + { "", 9, 0, 0}, + { "", 10, 0, 0}, + { "", 16, 0, 0}, + { "", 36, 0, 0}, + { "0", 0, 0, 1}, + { "0", 2, 0, 1}, + { "0", 8, 0, 1}, + { "0", 9, 0, 1}, + { "0", 10, 0, 1}, + { "0", 16, 0, 1}, + { "0", 36, 0, 1}, + { "+0", 0, 0, 2}, + { "+0", 2, 0, 2}, + { "+0", 8, 0, 2}, + { "+0", 9, 0, 2}, + { "+0", 10, 0, 2}, + { "+0", 16, 0, 2}, + { "+0", 36, 0, 2}, + { "-0", 0, 0, 2}, + { "-0", 2, 0, 2}, + { "-0", 8, 0, 2}, + { "-0", 9, 0, 2}, + { "-0", 10, 0, 2}, + { "-0", 16, 0, 2}, + { "-0", 36, 0, 2}, + { "Inf", 0, 0, 0}, + { "Inf", 2, 0, 0}, + { "Inf", 8, 0, 0}, + { "Inf", 9, 0, 0}, + { "Inf", 10, 0, 0}, + { "Inf", 16, 0, 0}, + { "Inf", 36, 24171, 3}, + { "+Inf", 0, 0, 0}, + { "+Inf", 2, 0, 0}, + { "+Inf", 8, 0, 0}, + { "+Inf", 9, 0, 0}, + { "+Inf", 10, 0, 0}, + { "+Inf", 16, 0, 0}, + { "+Inf", 36, 24171, 4}, + { "-Inf", 0, 0, 0}, + { "-Inf", 2, 0, 0}, + { "-Inf", 8, 0, 0}, + { "-Inf", 9, 0, 0}, + { "-Inf", 10, 0, 0}, + { "-Inf", 16, 0, 0}, + { "-Inf", 36, -24171, 4}, + { "inf", 0, 0, 0}, + { "inf", 2, 0, 0}, + { "inf", 8, 0, 0}, + { "inf", 9, 0, 0}, + { "inf", 10, 0, 0}, + { "inf", 16, 0, 0}, + { "inf", 36, 24171, 3}, + { "+inf", 0, 0, 0}, + { "+inf", 2, 0, 0}, + { "+inf", 8, 0, 0}, + { "+inf", 9, 0, 0}, + { "+inf", 10, 0, 0}, + { "+inf", 16, 0, 0}, + { "+inf", 36, 24171, 4}, + { "-inf", 0, 0, 0}, + { "-inf", 2, 0, 0}, + { "-inf", 8, 0, 0}, + { "-inf", 9, 0, 0}, + { "-inf", 10, 0, 0}, + { "-inf", 16, 0, 0}, + { "-inf", 36, -24171, 4}, + { "119b8Z", 0, 119, 3}, + { "119bZ", 0, 119, 3}, + { "-0119bZ", 0, -9, 4}, + { " \t\n 0X119bZ", 0, 4507, 10}, + { " \t\n +0X119bZ", 0, 4507, 11}, + { " \t\n -0x119bZ", 0, -4507, 11}, + { " \t\n 119bZ", 0, 119, 7}, + { "+119bZ", 0, 119, 4}, + { "+0X119bz", 0, 4507, 7}, + { "119b8Z", 2, 3, 2}, + { "119bZ", 2, 3, 2}, + { "-0119bZ", 2, -3, 4}, + { " \t\n 0X119bZ", 2, 0, 5}, + { " \t\n +0X119bZ", 2, 0, 6}, + { " \t\n -0x119bZ", 2, 0, 6}, + { " \t\n 119bZ", 2, 3, 6}, + { "+119bZ", 2, 3, 3}, + { "+0X119bz", 2, 0, 2}, + { "119b8Z", 8, 9, 2}, + { "119bZ", 8, 9, 2}, + { "-0119bZ", 8, -9, 4}, + { " \t\n 0X119bZ", 8, 0, 5}, + { " \t\n +0X119bZ", 8, 0, 6}, + { " \t\n -0x119bZ", 8, 0, 6}, + { " \t\n 119bZ", 8, 9, 6}, + { "+119bZ", 8, 9, 3}, + { "+0X119bz", 8, 0, 2}, + { "119b8Z", 9, 10, 2}, + { "119bZ", 9, 10, 2}, + { "-0119bZ", 9, -10, 4}, + { " \t\n 0X119bZ", 9, 0, 5}, + { " \t\n +0X119bZ", 9, 0, 6}, + { " \t\n -0x119bZ", 9, 0, 6}, + { " \t\n 119bZ", 9, 10, 6}, + { "+119bZ", 9, 10, 3}, + { "+0X119bz", 9, 0, 2}, + { "119b8Z", 10, 119, 3}, + { "119bZ", 10, 119, 3}, + { "-0119bZ", 10, -119, 5}, + { " \t\n 0X119bZ", 10, 0, 5}, + { " \t\n +0X119bZ", 10, 0, 6}, + { " \t\n -0x119bZ", 10, 0, 6}, + { " \t\n 119bZ", 10, 119, 7}, + { "+119bZ", 10, 119, 4}, + { "+0X119bz", 10, 0, 2}, + { "119b8Z", 16, 72120, 5}, + { "119bZ", 16, 4507, 4}, + { "-0119bZ", 16, -4507, 6}, + { " \t\n 0X119bZ", 16, 4507, 10}, + { " \t\n +0X119bZ", 16, 4507, 11}, + { " \t\n -0x119bZ", 16, -4507, 11}, + { " \t\n 119bZ", 16, 4507,8}, + { "+119bZ", 16, 4507, 5}, + { "+0X119bz", 16, 4507, 7}, + { "119b8Z", 36, 62580275, 6}, + { "119bZ", 36, 1738367, 5}, + { "-0119bZ", 36, -1738367, 7}, + { " \t\n 0X119bZ", 36, 1997122175, 11}, + { " \t\n +0X119bZ", 36, 1997122175, 12}, + { " \t\n -0x119bZ", 36, -1997122175, 12}, + { " \t\n 119bZ", 36, 1738367, 9}, + { "+119bZ", 36, 1738367, 6}, + { "+0X119bz", 36, 1997122175, 8}, + /* There should be a much larger battery of such tests. */ + { "127", 0, 127, 3}, + { "-127", 0, -127, 4}, + { "128", 0, 128, 3}, + { "-128", 0, -127-1, 4}, + { "255", 0, 255, 3}, + { "-255", 0, -255, 4}, + { "256", 0, 256, 3}, + { "-256", 0, -255-1, 4}, + { "32767", 0, 32767, 5}, + { "-32767", 0, -32767, 6}, + { "32768", 0, 32768, 5}, + { "-32768", 0, -32767-1, 6}, + { "65535", 0, 65535, 5}, + { "-65535", 0, -65536+1, 6}, + { "65536", 0, 65536, 5}, + { "-65536", 0, -65536, 6}, + { "2147483647", 0, 2147483647, 10}, + { "-2147483647", 0, -2147483647, 11}, + { "2147483648", 0, 2147483648LL, 10}, + { "-2147483648", 0, -2147483647LL-1, 11}, + { "4294967295", 0, 4294967295LL, 10}, + { "-4294967295", 0, -4294967296LL+1, 11}, + { "4294967296", 0, 4294967296LL, 10}, + { "-4294967296", 0, -4294967296L, 11}, + { "9223372036854775807", 0, 9223372036854775807LL, 19}, + { "-9223372036854775807", 0, -9223372036854775807LL, 20}, + { "1234567890123456789", 0, 1234567890123456789LL, 19}, + { "-1234567890123456789", 0, -1234567890123456789LL, 20}, + { "1", 0, 1, 1}, + { "-1", 0, -1, 2}, + { "2", 0, 2, 1}, + { "-2", 0, -2, 2}, + { "10", 0, 10, 2}, + { "-10", 0, -10, 3}, + { "16", 0, 16, 2}, + { "-16", 0, -16, 3}, + /* Other test cases can be added here. */ + { NULL, 0, 0, 0 } /* terminates the list */ + }, *sdp; + + for ( sdp = str_data; sdp->nptr != NULL ; ++sdp ) + { + /* + 7.8.2.3 The strtoimax and strtoumax functions + */ + + strcpy(saved, sdp->nptr); + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, &endptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, &endptr, sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** strtoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( endptr != sdp->nptr + sdp->exp_len ) + { + int save = errno; + + printf("*** strtoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* tests for null endptr */ + +#define WARN() if (!warned) warned = 1, printf("*** Using null endptr: ***\n") + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = strtoimax(sdp->nptr, (char **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoimax(%s,NULL,%d) failed; " + "should be: %"PRIdMAX", was: %"PRIdMAX" ***\n", + sdp->nptr, sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoimax modified its input ***\n"); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = strtoumax(sdp->nptr, (char **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** strtoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** strtoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + if ( strcmp(sdp->nptr, saved) != 0 ) + { + WARN(); + printf("*** strtoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + strcpy(saved, sdp->nptr); + } + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions + */ + + for ( i = 0; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, &wendptr, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoimax(%s,,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoimax(%s,,%d) returned wrong endptr" + " ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) == '\0' ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, &wendptr, sdp->base) + ) != sdp->exp_val + ) { + int save = errno; + + printf("*** wcstoumax(%s,,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + else if ( wendptr != wnptr + sdp->exp_len ) + { + int save = errno; + + printf("*** wcstoumax(%s,,%d) returned wrong " + "endptr ***\n", sdp->nptr, sdp->base + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + + /* tests for null endptr */ + + warned = 0; + errno = 0; /* shouldn't be changed */ + + if ( (intmax = wcstoimax(wnptr, (wchar_t **)NULL, sdp->base)) + != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoimax(%s,NULL,%d) failed; should be: %" + PRIdMAX", was: %"PRIdMAX" ***\n", sdp->nptr, + sdp->base, sdp->exp_val, intmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoimax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoimax modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + + if ( sdp->exp_val >= 0 ) /* else some sign extension */ + { + errno = 0; /* shouldn't be changed */ + + if ( (uintmax = wcstoumax(wnptr, (wchar_t **)NULL, + sdp->base + ) + ) != sdp->exp_val + ) { + int save = errno; + + WARN(); + printf("*** wcstoumax(%s,NULL,%d) failed; " + "should be: %"PRIuMAX", was: %"PRIuMAX + " ***\n", sdp->nptr, sdp->base, + sdp->exp_val, uintmax + ); + status = EXIT_FAILURE; + errno = save; + } + + if ( errno != 0 ) + { + WARN(); + printf("*** wcstoumax modified errno ***\n"); + status = EXIT_FAILURE; + } + + for ( i = 0; i < 64; ++i ) + if ( wnptr[i] != sdp->nptr[i] ) + { + WARN(); + printf("*** wcstoumax" + " modified its input ***\n" + ); + status = EXIT_FAILURE; + + for ( ; i < 64; ++i ) + if ( (wnptr[i] = sdp->nptr[i]) + == '\0' + ) + break; + + break; + } + else if ( wnptr[i] == '\0' ) + break; + } + } + + /* + 7.8.2.3 The strtoimax and strtoumax functions (continued) + */ + + if ( (intmax = strtoimax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = strtoimax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** strtoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("+1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = strtoumax("-1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890" + "1234567890123456789012345678901234567890", + &endptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** strtoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + /* + 7.8.2.4 The wcstoimax and wcstoumax functions (continued) + */ + + if ( (intmax = wcstoimax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = wcstoimax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoimax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (intmax = wcstoimax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != INTMAX_MIN || errno != ERANGE + ) { + printf("*** wcstoimax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"+1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed +overflow test ***\n"); + status = EXIT_FAILURE; + } + + if ( (uintmax = wcstoumax(L"-1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890" + L"1234567890123456789012345678901234567890", + &wendptr, 0 + ) + ) != UINTMAX_MAX || errno != ERANGE + ) { + printf("*** wcstoumax failed -overflow test ***\n"); + status = EXIT_FAILURE; + } + } +#endif /* defined(INTMAX_MAX) */ + + if ( status != 0 ) + fprintf(stderr, "sitest failed; see stdout for details\n"); + + return status; + } diff --git a/winsup/mingw/mingwex/snprintf.c b/winsup/mingw/mingwex/snprintf.c new file mode 100644 index 0000000..c8d2a7b --- /dev/null +++ b/winsup/mingw/mingwex/snprintf.c @@ -0,0 +1,13 @@ +#include <stdarg.h> +#include <stdio.h> + +int snprintf(char* buffer, size_t n, const char* format, ...) +{ + int retval; + va_list argptr; + + va_start( argptr, format ); + retval = _vsnprintf( buffer, n, format, argptr ); + va_end( argptr ); + return retval; +} diff --git a/winsup/mingw/mingwex/snwprintf.c b/winsup/mingw/mingwex/snwprintf.c new file mode 100644 index 0000000..42b05b2 --- /dev/null +++ b/winsup/mingw/mingwex/snwprintf.c @@ -0,0 +1,13 @@ +#include <stdarg.h> +#include <wchar.h> + +int snwprintf(wchar_t* buffer, size_t n, const wchar_t* format, ...) +{ + int retval; + va_list argptr; + + va_start( argptr, format ); + retval = _vsnwprintf( buffer, n, format, argptr ); + va_end( argptr ); + return retval; +} diff --git a/winsup/mingw/mingwex/strtof.c b/winsup/mingw/mingwex/strtof.c new file mode 100644 index 0000000..62907cb --- /dev/null +++ b/winsup/mingw/mingwex/strtof.c @@ -0,0 +1,6 @@ +#include <stdlib.h> + +float strtof( const char *nptr, char **endptr) +{ + return (strtod(nptr, endptr)); +} diff --git a/winsup/mingw/mingwex/strtoimax.c b/winsup/mingw/mingwex/strtoimax.c new file mode 100644 index 0000000..0cf2c01 --- /dev/null +++ b/winsup/mingw/mingwex/strtoimax.c @@ -0,0 +1,112 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + + This particular implementation requires the matching <inttypes.h>. + It also assumes that character codes for A..Z and a..z are in + contiguous ascending order; this is true for ASCII but not EBCDIC. +*/ +#include <stdlib.h> +#include <errno.h> +#include <ctype.h> +#include <inttypes.h> + +/* Helper macros */ + +/* convert digit character to number, in any base */ +#define ToNumber(c) (isdigit(c) ? (c) - '0' : \ + isupper(c) ? (c) - 'A' + 10 : \ + islower(c) ? (c) - 'a' + 10 : \ + -1 /* "invalid" flag */ \ + ) +/* validate converted digit character for specific base */ +#define valid(n, b) ((n) >= 0 && (n) < (b)) + +intmax_t +strtoimax(nptr, endptr, base) + register const char * __restrict__ nptr; + char ** __restrict__ endptr; + register int base; + { + register uintmax_t accum; /* accumulates converted value */ + register int n; /* numeral from digit character */ + int minus; /* set iff minus sign seen */ + int toobig; /* set iff value overflows */ + + if ( endptr != NULL ) + *endptr = (char *)nptr; /* in case no conversion's performed */ + + if ( base < 0 || base == 1 || base > 36 ) + { + errno = EDOM; + return 0; /* unspecified behavior */ + } + + /* skip initial, possibly empty sequence of white-space characters */ + + while ( isspace(*nptr) ) + ++nptr; + + /* process subject sequence: */ + + /* optional sign */ + if ( (minus = *nptr == '-') || *nptr == '+' ) + ++nptr; + + if ( base == 0 ) { + if ( *nptr == '0' ) { + if ( nptr[1] == 'X' || nptr[1] == 'x' ) + base = 16; + else + base = 8; + } + else + base = 10; + } + /* optional "0x" or "0X" for base 16 */ + + if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') ) + nptr += 2; /* skip past this prefix */ + + /* check whether there is at least one valid digit */ + + n = ToNumber(*nptr); + ++nptr; + + if ( !valid(n, base) ) + return 0; /* subject seq. not of expected form */ + + accum = n; + + for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr ) + if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */ + toobig = 1; /* but keep scanning */ + else + accum = base * accum + n; + + if ( endptr != NULL ) + *endptr = (char *)nptr; /* points to first not-valid-digit */ + + if ( minus ) + { + if ( accum > (uintmax_t)INTMAX_MAX + 1 ) + toobig = 1; + } + else + if ( accum > (uintmax_t)INTMAX_MAX ) + toobig = 1; + + if ( toobig ) + { + errno = ERANGE; + return minus ? INTMAX_MIN : INTMAX_MAX; + } + else + return (intmax_t)(minus ? -accum : accum); + } + +long long __attribute__ ((alias ("strtoimax"))) +strtoll (const char* __restrict__ nptr, char ** __restrict__ endptr, int base); diff --git a/winsup/mingw/mingwex/strtoumax.c b/winsup/mingw/mingwex/strtoumax.c new file mode 100644 index 0000000..2c052ac --- /dev/null +++ b/winsup/mingw/mingwex/strtoumax.c @@ -0,0 +1,110 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + + This particular implementation requires the matching <inttypes.h>. + It also assumes that character codes for A..Z and a..z are in + contiguous ascending order; this is true for ASCII but not EBCDIC. +*/ +#include <stdlib.h> +#include <errno.h> +#include <ctype.h> +#include <inttypes.h> + +/* Helper macros */ + +/* convert digit character to number, in any base */ +#define ToNumber(c) (isdigit(c) ? (c) - '0' : \ + isupper(c) ? (c) - 'A' + 10 : \ + islower(c) ? (c) - 'a' + 10 : \ + -1 /* "invalid" flag */ \ + ) +/* validate converted digit character for specific base */ +#define valid(n, b) ((n) >= 0 && (n) < (b)) + +uintmax_t +strtoumax(nptr, endptr, base) + register const char * __restrict__ nptr; + char ** __restrict__ endptr; + register int base; + { + register uintmax_t accum; /* accumulates converted value */ + register uintmax_t next; /* for computing next value of accum */ + register int n; /* numeral from digit character */ + int minus; /* set iff minus sign seen (yes!) */ + int toobig; /* set iff value overflows */ + + if ( endptr != NULL ) + *endptr = (char *)nptr; /* in case no conversion's performed */ + + if ( base < 0 || base == 1 || base > 36 ) + { + errno = EDOM; + return 0; /* unspecified behavior */ + } + + /* skip initial, possibly empty sequence of white-space characters */ + + while ( isspace(*nptr) ) + ++nptr; + + /* process subject sequence: */ + + /* optional sign (yes!) */ + + if ( (minus = *nptr == '-') || *nptr == '+' ) + ++nptr; + + if ( base == 0 ) + { + if ( *nptr == '0' ) + { + if ( nptr[1] == 'X' || nptr[1] == 'x' ) + base = 16; + else + base = 8; + } + else + base = 10; + } + + /* optional "0x" or "0X" for base 16 */ + + if ( base == 16 && *nptr == '0' && (nptr[1] == 'X' || nptr[1] == 'x') ) + nptr += 2; /* skip past this prefix */ + + /* check whether there is at least one valid digit */ + + n = ToNumber(*nptr); + ++nptr; + + if ( !valid(n, base) ) + return 0; /* subject seq. not of expected form */ + + accum = n; + + for ( toobig = 0; n = ToNumber(*nptr), valid(n, base); ++nptr ) + if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */ + || (next = base * accum + n) < accum /* minor wrap-around */ + ) + toobig = 1; /* but keep scanning */ + else + accum = next; + + if ( endptr != NULL ) + *endptr = (char *)nptr; /* points to first not-valid-digit */ + + if ( toobig ) + { + errno = ERANGE; + return UINTMAX_MAX; + } + else + return minus ? -accum : accum; /* (yes!) */ + } + +unsigned long long __attribute__ ((alias ("strtoumax"))) +strtoull (const char* __restrict__ nptr, char ** __restrict__ endptr, int base); diff --git a/winsup/mingw/mingwex/testwmem.c b/winsup/mingw/mingwex/testwmem.c new file mode 100644 index 0000000..1310718 --- /dev/null +++ b/winsup/mingw/mingwex/testwmem.c @@ -0,0 +1,104 @@ +#include <memory.h> +#include <wchar.h> +#include <stdio.h> + +wchar_t fmt1[] = L" 1 2 3 4 5"; +wchar_t fmt2[] = L"12345678901234567890123456789012345678901234567890"; + +void test_wmemchr( void ) +{ + wchar_t* dest; + wint_t result; + wint_t ch = L'r'; + wchar_t str[] = L"lazy"; + wchar_t string1[60] = L"The quick brown dog jumps over the lazy fox"; + + wprintf( L"Wmemchr\n" ); + wprintf( L"String to be searched:\n\t\t%s\n", string1 ); + wprintf( L"\t\t%s\n\t\t%s\n\n", fmt1, fmt2 ); + + wprintf( L"Search char:\t%c\n", ch ); + dest = wmemchr( string1, ch, sizeof( string1 ) ); + result = dest - string1 + 1; + if( dest != NULL ) + wprintf( L"Result:\t\t%c found at position %d\n\n", ch, result ); + else + wprintf( L"Result:\t\t%c not found\n\n" ); +return; +} +void test_wmemset( void ) +{/* 1 2 + 0123456789012345678901234567890 */ + wchar_t buffer[] = L"This is a test of the wmemset function"; + wprintf( L"Before: %s\n", buffer ); + wmemset( buffer+22, L'*', 7 ); + wprintf( L"After: %s\n\n", buffer ); +return; +} + +void test_wmemmove( void ) +{ + wchar_t string1[60] = L"The quick brown dog jumps over the lazy fox"; + wchar_t string2[60] = L"The quick brown fox jumps over the lazy dog"; + + wprintf( L"Wmemcpy without overlap\n" ); + wprintf( L"Source:\t\t%s\n", string1 + 40 ); + wprintf( L"Destination:\t%s\n", string1 + 16 ); + wmemcpy( string1 + 16, string1 + 40, 3 ); + wprintf( L"Result:\t\t%s\n", string1 ); + wprintf( L"Length:\t\t%d characters\n\n", wcslen( string1 ) ); + wmemcpy( string1 + 16, string2 + 40, 3 ); + + wprintf( L"Wmemmove with overlap\n" ); + wprintf( L"Source:\t\t%s\n", string2 + 4 ); + wprintf( L"Destination:\t%s\n", string2 + 10 ); + wmemmove( string2 + 10, string2 + 4, 40 ); + wprintf( L"Result:\t\t%s\n", string2 ); + wprintf( L"Length:\t\t%d characters\n\n", wcslen( string2 ) ); + + wprintf( L"Wmemcpy with overlap\n" ); + wprintf( L"Source:\t\t%s\n", string1 + 4 ); + wprintf( L"Destination:\t%s\n", string1 + 10 ); + wmemcpy( string1 + 10, string1 + 4, 40 ); + wprintf( L"Result:\t\t%s\n", string1 ); + wprintf( L"Length:\t\t%d characters\n\n", wcslen( string1 ) ); +} + + +void test_wmemcmp( void ) +{ + wchar_t first[] = L"12345678901234567890"; + wchar_t second[] = L"12345678901234567891"; + wint_t result; + wprintf(L"Wmemcmp\n"); + wprintf( L"Compare '%.19s' to '%.19s':\n", first, second ); + result = wmemcmp( first, second, 19 ); + if( result < 0 ) + wprintf( L"First is less than second.\n" ); + else if( result == 0 ) + wprintf( L"First is equal to second.\n" ); + else if( result > 0 ) + wprintf( L"First is greater than second.\n" ); + wprintf( L"\nCompare '%.20s' to '%.20s':\n", first, second ); + result = wmemcmp( first, second, 20 ); + if( result < 0 ) + wprintf( L"First is less than second.\n\n" ); + else if( result == 0 ) + wprintf( L"First is equal to second.\n\n" ); + else if( result > 0 ) + wprintf( L"First is greater than second.\n\n" ); +} + + + +int main(){ +test_wmemset(); +test_wmemmove(); +test_wmemchr(); +test_wmemcmp(); +return 0; +} + + + + diff --git a/winsup/mingw/mingwex/trunc.c b/winsup/mingw/mingwex/trunc.c new file mode 100644 index 0000000..2b99312 --- /dev/null +++ b/winsup/mingw/mingwex/trunc.c @@ -0,0 +1,17 @@ +#include <fenv.h> +#include <math.h> + +double +trunc (double _x){ + double retval; + unsigned short saved_cw; + __asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */ + __asm__ ("fldcw %0;" + : + : "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD + | FE_TOWARDZERO)) | FE_TOWARDZERO) + ); + __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ + __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ + return retval; +} diff --git a/winsup/mingw/mingwex/truncf.c b/winsup/mingw/mingwex/truncf.c new file mode 100644 index 0000000..53fccb1 --- /dev/null +++ b/winsup/mingw/mingwex/truncf.c @@ -0,0 +1,17 @@ +#include <fenv.h> +#include <math.h> + +float +truncf (float _x){ + float retval; + unsigned short saved_cw; + __asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */ + __asm__ ("fldcw %0;" + : + : "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD + | FE_TOWARDZERO)) | FE_TOWARDZERO) + ); + __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ + __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ + return retval; +} diff --git a/winsup/mingw/mingwex/truncl.c b/winsup/mingw/mingwex/truncl.c new file mode 100644 index 0000000..908197a --- /dev/null +++ b/winsup/mingw/mingwex/truncl.c @@ -0,0 +1,17 @@ +#include <fenv.h> +#include <math.h> + +long double +truncl (long double _x){ + long double retval; + unsigned short saved_cw; + __asm__ ("fnstcw %0;": "=m" (saved_cw)); /* save FPU control word */ + __asm__ ("fldcw %0;" + : + : "m" ((saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD + | FE_TOWARDZERO)) | FE_TOWARDZERO) + ); + __asm__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ + __asm__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ + return retval; +} diff --git a/winsup/mingw/mingwex/ulltoa.c b/winsup/mingw/mingwex/ulltoa.c new file mode 100644 index 0000000..8e90de7 --- /dev/null +++ b/winsup/mingw/mingwex/ulltoa.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +char* ulltoa(unsigned long long _n, char * _c, int _i) + { return _ui64toa (_n, _c, _i); } diff --git a/winsup/mingw/mingwex/ulltow.c b/winsup/mingw/mingwex/ulltow.c new file mode 100644 index 0000000..8e4f228 --- /dev/null +++ b/winsup/mingw/mingwex/ulltow.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +wchar_t* ulltow(unsigned long long _n, wchar_t * _w, int _i) + { return _ui64tow (_n, _w, _i); } diff --git a/winsup/mingw/mingwex/vsnprintf.c b/winsup/mingw/mingwex/vsnprintf.c new file mode 100644 index 0000000..466e064 --- /dev/null +++ b/winsup/mingw/mingwex/vsnprintf.c @@ -0,0 +1,5 @@ +#include <stdarg.h>
+#include <stdio.h>
+
+int vsnprintf (char* s, size_t n, const char* format, va_list arg)
+ { return _vsnprintf ( s, n, format, arg); }
diff --git a/winsup/mingw/mingwex/vsnwprintf.c b/winsup/mingw/mingwex/vsnwprintf.c new file mode 100644 index 0000000..05a1ec9 --- /dev/null +++ b/winsup/mingw/mingwex/vsnwprintf.c @@ -0,0 +1,5 @@ +#include <stdarg.h>
+#include <wchar.h>
+
+int vsnwprintf(wchar_t *buffer, size_t n, const wchar_t * format, va_list argptr)
+ { return _vsnwprintf( buffer, n, format, argptr );}
diff --git a/winsup/mingw/mingwex/wcstof.c b/winsup/mingw/mingwex/wcstof.c new file mode 100644 index 0000000..830f794 --- /dev/null +++ b/winsup/mingw/mingwex/wcstof.c @@ -0,0 +1,6 @@ +#include <wchar.h> + +float wcstof( const wchar_t *nptr, wchar_t **endptr) +{ + return (wcstod(nptr, endptr)); +} diff --git a/winsup/mingw/mingwex/wcstoimax.c b/winsup/mingw/mingwex/wcstoimax.c new file mode 100644 index 0000000..4b82b14 --- /dev/null +++ b/winsup/mingw/mingwex/wcstoimax.c @@ -0,0 +1,119 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + + This particular implementation requires the matching <inttypes.h>. + It also assumes that character codes for A..Z and a..z are in + contiguous ascending order; this is true for ASCII but not EBCDIC. +*/ + +#include <wchar.h> +#include <errno.h> +#include <ctype.h> +#include <inttypes.h> + +/* convert digit wide character to number, in any base */ + +#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \ + iswupper(c) ? (c) - L'A' + 10 : \ + iswlower(c) ? (c) - L'a' + 10 : \ + -1 /* "invalid" flag */ \ + ) + +/* validate converted digit character for specific base */ +#define valid(n, b) ((n) >= 0 && (n) < (b)) + +intmax_t +wcstoimax(nptr, endptr, base) + register const wchar_t * __restrict__ nptr; + wchar_t ** __restrict__ endptr; + register int base; + { + register uintmax_t accum; /* accumulates converted value */ + register int n; /* numeral from digit character */ + int minus; /* set iff minus sign seen */ + int toobig; /* set iff value overflows */ + + if ( endptr != NULL ) + *endptr = (wchar_t *)nptr; /* in case no conv performed */ + + if ( base < 0 || base == 1 || base > 36 ) + { + errno = EDOM; + return 0; /* unspecified behavior */ + } + + /* skip initial, possibly empty sequence of white-space w.characters */ + + while ( iswspace(*nptr) ) + ++nptr; + + /* process subject sequence: */ + + /* optional sign */ + + if ( (minus = *nptr == L'-') || *nptr == L'+' ) + ++nptr; + + if ( base == 0 ) + { + if ( *nptr == L'0' ) + { + if ( nptr[1] == L'X' || nptr[1] == L'x' ) + base = 16; + else + base = 8; + } + else + base = 10; + } + /* optional "0x" or "0X" for base 16 */ + + if ( base == 16 && *nptr == L'0' + && (nptr[1] == L'X' || nptr[1] == L'x') + ) + nptr += 2; /* skip past this prefix */ + + /* check whether there is at least one valid digit */ + + n = ToWNumber(*nptr); + ++nptr; + + if ( !valid(n, base) ) + return 0; /* subject seq. not of expected form */ + + accum = n; + + for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr ) + if ( accum > INTMAX_MAX / base + 2 ) /* major wrap-around */ + toobig = 1; /* but keep scanning */ + else + accum = base * accum + n; + + if ( endptr != NULL ) + *endptr = (wchar_t *)nptr; /* -> first not-valid-digit */ + + if ( minus ) + { + if ( accum > (uintmax_t)INTMAX_MAX + 1 ) + toobig = 1; + } + else + if ( accum > (uintmax_t)INTMAX_MAX ) + toobig = 1; + + if ( toobig ) + { + errno = ERANGE; + return minus ? INTMAX_MIN : INTMAX_MAX; + } + else + return (intmax_t)(minus ? -accum : accum); + } + +long long __attribute__ ((alias ("wcstoimax"))) +wcstoll (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, int base); diff --git a/winsup/mingw/mingwex/wcstoumax.c b/winsup/mingw/mingwex/wcstoumax.c new file mode 100644 index 0000000..9bd6cd7 --- /dev/null +++ b/winsup/mingw/mingwex/wcstoumax.c @@ -0,0 +1,113 @@ +/* + This source code was extracted from the Q8 package created and + placed in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.8.2 of ISO/IEC 9899:1999 (E). + + This particular implementation requires the matching <inttypes.h>. + It also assumes that character codes for A..Z and a..z are in + contiguous ascending order; this is true for ASCII but not EBCDIC. +*/ + +#include <wchar.h> +#include <errno.h> +#include <ctype.h> +#include <inttypes.h> + +/* convert digit wide character to number, in any base */ + +#define ToWNumber(c) (iswdigit(c) ? (c) - L'0' : \ + iswupper(c) ? (c) - L'A' + 10 : \ + iswlower(c) ? (c) - L'a' + 10 : \ + -1 /* "invalid" flag */ \ + ) + +/* validate converted digit character for specific base */ +#define valid(n, b) ((n) >= 0 && (n) < (b)) + +uintmax_t +wcstoumax(nptr, endptr, base) + register const wchar_t * __restrict__ nptr; + wchar_t ** __restrict__ endptr; + register int base; + { + register uintmax_t accum; /* accumulates converted value */ + register uintmax_t next; /* for computing next value of accum */ + register int n; /* numeral from digit character */ + int minus; /* set iff minus sign seen (yes!) */ + int toobig; /* set iff value overflows */ + + if ( endptr != NULL ) + *endptr = (wchar_t *)nptr; /* in case no conv performed */ + + if ( base < 0 || base == 1 || base > 36 ) + { + errno = EDOM; + return 0; /* unspecified behavior */ + } + + /* skip initial, possibly empty sequence of white-space w.characters */ + + while ( iswspace(*nptr) ) + ++nptr; + + /* process subject sequence: */ + + /* optional sign */ + + if ( (minus = *nptr == L'-') || *nptr == L'+' ) + ++nptr; + + if ( base == 0 ) + { + if ( *nptr == L'0' ) + { + if ( nptr[1] == L'X' || nptr[1] == L'x' ) + base = 16; + else + base = 8; + } + else + base = 10; + } + /* optional "0x" or "0X" for base 16 */ + + if ( base == 16 && *nptr == L'0' + && (nptr[1] == L'X' || nptr[1] == L'x') + ) + nptr += 2; /* skip past this prefix */ + + /* check whether there is at least one valid digit */ + + n = ToWNumber(*nptr); + ++nptr; + + if ( !valid(n, base) ) + return 0; /* subject seq. not of expected form */ + + accum = n; + + for ( toobig = 0; n = ToWNumber(*nptr), valid(n, base); ++nptr ) + if ( accum > UINTMAX_MAX / base + 1 /* major wrap-around */ + || (next = base * accum + n) < accum /* minor wrap-around */ + ) + toobig = 1; /* but keep scanning */ + else + accum = next; + + if ( endptr != NULL ) + *endptr = (wchar_t *)nptr; /* -> first not-valid-digit */ + + if ( toobig ) + { + errno = ERANGE; + return UINTMAX_MAX; + } + else + return minus ? -accum : accum; /* (yes!) */ + } + +unsigned long long __attribute__ ((alias ("wcstoumax"))) +wcstoull (const wchar_t* __restrict__ nptr, wchar_t ** __restrict__ endptr, int base); diff --git a/winsup/mingw/mingwex/wdirent.c b/winsup/mingw/mingwex/wdirent.c new file mode 100644 index 0000000..4b8cc50 --- /dev/null +++ b/winsup/mingw/mingwex/wdirent.c @@ -0,0 +1,3 @@ +#define _UNICODE 1 +#define UNICODE 1 +#include "dirent.c" diff --git a/winsup/mingw/mingwex/wmemchr.c b/winsup/mingw/mingwex/wmemchr.c new file mode 100644 index 0000000..dc5cedd --- /dev/null +++ b/winsup/mingw/mingwex/wmemchr.c @@ -0,0 +1,28 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + +wchar_t* +wmemchr(s, c, n) + register const wchar_t *s; + register wchar_t c; + register size_t n; + { + if ( s != NULL ) + for ( ; n > 0; ++s, --n ) + if ( *s == c ) + return (wchar_t *)s; + + return NULL; + } + diff --git a/winsup/mingw/mingwex/wmemcmp.c b/winsup/mingw/mingwex/wmemcmp.c new file mode 100644 index 0000000..e1e034c --- /dev/null +++ b/winsup/mingw/mingwex/wmemcmp.c @@ -0,0 +1,32 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + +int +wmemcmp(s1, s2, n) + register const wchar_t *s1; + register const wchar_t *s2; + size_t n; + { + if ( n == 0 || s1 == s2 ) + return 0; /* even for NULL pointers */ + + if ( (s1 != NULL) != (s2 != NULL) ) + return s2 == NULL ? 1 : -1; /* robust */ + + for ( ; n > 0; ++s1, ++s2, --n ) + if ( *s1 != *s2 ) + return *s1 - *s2; + + return 0; + } diff --git a/winsup/mingw/mingwex/wmemcpy.c b/winsup/mingw/mingwex/wmemcpy.c new file mode 100644 index 0000000..d7e7b4c --- /dev/null +++ b/winsup/mingw/mingwex/wmemcpy.c @@ -0,0 +1,32 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + + +wchar_t * +wmemcpy(s1, s2, n) + register wchar_t * __restrict__ s1; + register const wchar_t * __restrict__ s2; + register size_t n; + { + wchar_t *orig_s1 = s1; + + if ( s1 == NULL || s2 == NULL || n == 0 ) + return orig_s1; /* robust */ + + for ( ; n > 0; --n ) + *s1++ = *s2++; + + return orig_s1; + } + diff --git a/winsup/mingw/mingwex/wmemmove.c b/winsup/mingw/mingwex/wmemmove.c new file mode 100644 index 0000000..3c545ac --- /dev/null +++ b/winsup/mingw/mingwex/wmemmove.c @@ -0,0 +1,43 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <errno.h> +#include <stdio.h> +#include <stdlib.h> +#include <wchar.h> + +wchar_t * +wmemmove(s1, s2, n) + register wchar_t *s1; + register const wchar_t *s2; + register size_t n; + { + wchar_t *orig_s1 = s1; + + if ( s1 == NULL || s2 == NULL || n == 0 ) + return orig_s1; /* robust */ + + /* XXX -- The following test works only within a flat address space! */ + if ( s2 >= s1 ) + for ( ; n > 0; --n ) + *s1++ = *s2++; + else { + s1 += n; + s2 += n; + + for ( ; n > 0; --n ) + *--s1 = *--s2; + } + + return orig_s1; + } + diff --git a/winsup/mingw/mingwex/wmemset.c b/winsup/mingw/mingwex/wmemset.c new file mode 100644 index 0000000..dadd9fb --- /dev/null +++ b/winsup/mingw/mingwex/wmemset.c @@ -0,0 +1,30 @@ +/* This source code was extracted from the Q8 package created and placed + in the PUBLIC DOMAIN by Doug Gwyn <gwyn@arl.mil> + last edit: 1999/11/05 gwyn@arl.mil + + Implements subclause 7.24 of ISO/IEC 9899:1999 (E). + + It supports an encoding where all char codes are mapped + to the *same* code values within a wchar_t or wint_t, + so long as no other wchar_t codes are used by the program. + +*/ + +#include <wchar.h> + + +wchar_t * +wmemset(s, c, n) + register wchar_t *s; + register wchar_t c; + register size_t n; + { + wchar_t *orig_s = s; + + if ( s != NULL ) + for ( ; n > 0; --n ) + *s++ = c; + + return orig_s; + } + diff --git a/winsup/mingw/mingwex/wtoll.c b/winsup/mingw/mingwex/wtoll.c new file mode 100644 index 0000000..48f8562 --- /dev/null +++ b/winsup/mingw/mingwex/wtoll.c @@ -0,0 +1,3 @@ +#include <stdlib.h> +long long wtoll(const wchar_t * _w) + { return _wtoi64 (_w); }; diff --git a/winsup/mingw/moldname-crtdll.def b/winsup/mingw/moldname-crtdll.def index f27fa15..aded521 100644 --- a/winsup/mingw/moldname-crtdll.def +++ b/winsup/mingw/moldname-crtdll.def @@ -1,142 +1,143 @@ -; -; 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 <colin@bird.fu.is.saga-u.ac.jp> -; Maintained by Mumit Khan <khan@xraylith.wisc.edu> -; -; 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 <time.h> -tzname DATA -tzset -umask -ungetch -unlink -utime -wcsdup -wcsicmp -wcsicoll -wcslwr -wcsnicmp -wcsnset -wcsrev -wcsset -wcsupr - - - -write -y0 -y1 -yn +;
+; 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 <colin@bird.fu.is.saga-u.ac.jp>
+; Maintained by Mumit Khan <khan@xraylith.wisc.edu>
+;
+; 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
+; Alias fpreset is set in CRT_fp10,c and CRT_fp8.c.
+; 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 <time.h>
+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 index f6e9075..a209007 100644 --- a/winsup/mingw/moldname-msvcrt.def +++ b/winsup/mingw/moldname-msvcrt.def @@ -1,142 +1,143 @@ -; -; 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 <colin@bird.fu.is.saga-u.ac.jp> -; Maintained by Mumit Khan <khan@xraylith.wisc.edu> -; -; 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 <time.h> -tzname DATA -tzset -umask -ungetch -unlink -utime -wcsdup -wcsicmp -wcsicoll -wcslwr -wcsnicmp -wcsnset -wcsrev -wcsset -wcsupr - -wpopen - -write -y0 -y1 -yn +;
+; 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 <colin@bird.fu.is.saga-u.ac.jp>
+; Maintained by Mumit Khan <khan@xraylith.wisc.edu>
+;
+; 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
+; Alias fpreset is set in CRT_fp10,c and CRT_fp8.c.
+; 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 <time.h>
+tzname DATA
+tzset
+umask
+ungetch
+unlink
+utime
+wcsdup
+wcsicmp
+wcsicoll
+wcslwr
+wcsnicmp
+wcsnset
+wcsrev
+wcsset
+wcsupr
+
+wpopen
+
+write
+y0
+y1
+yn
diff --git a/winsup/mingw/moldname.def.in b/winsup/mingw/moldname.def.in index c0032af..1c88b0a 100644 --- a/winsup/mingw/moldname.def.in +++ b/winsup/mingw/moldname.def.in @@ -54,7 +54,8 @@ fgetchar fgetwchar filelength fileno -fpreset +; Alias fpreset is set in CRT_fp10,c and CRT_fp8.c. +; fpreset fputchar fputwchar fstat diff --git a/winsup/mingw/msvcrt.def b/winsup/mingw/msvcrt.def index 8a1b872..0b85e9e 100644 --- a/winsup/mingw/msvcrt.def +++ b/winsup/mingw/msvcrt.def @@ -210,7 +210,7 @@ _flushall _fmode DATA _fpclass _fpieee_flt -_fpreset +_fpreset DATA _fputchar _fputwchar _fsopen @@ -365,7 +365,7 @@ _mkdir _mktemp _msize _nextafter -_onexit +_onexit DATA _open _open_osfhandle _osver DATA @@ -546,7 +546,7 @@ asctime asin atan atan2 -atexit +atexit DATA atof atoi atol diff --git a/winsup/mingw/msvcrt20.def b/winsup/mingw/msvcrt20.def index 2f27ea0..9ceb075 100644 --- a/winsup/mingw/msvcrt20.def +++ b/winsup/mingw/msvcrt20.def @@ -181,7 +181,7 @@ _flushall _fmode _fpclass _fpieee_flt -_fpreset +_fpreset DATA _fputchar _fputwchar _fsopen @@ -329,7 +329,7 @@ _msize _mtlock _mtunlock _nextafter -_onexit +_onexit DATA _open _open_osfhandle _osver @@ -528,7 +528,7 @@ asctime asin atan atan2 -atexit +atexit DATA atof atoi atol diff --git a/winsup/mingw/msvcrt40.def b/winsup/mingw/msvcrt40.def index 7b1d2e8..e4b09f9 100644 --- a/winsup/mingw/msvcrt40.def +++ b/winsup/mingw/msvcrt40.def @@ -163,7 +163,7 @@ _flushall _fmode _fpclass _fpieee_flt -_fpreset +_fpreset DATA _fputchar _fputwchar _fsopen @@ -312,7 +312,7 @@ _msize _mtlock _mtunlock _nextafter -_onexit +_onexit DATA _open _open_osfhandle _osver @@ -485,7 +485,7 @@ asctime asin atan atan2 -atexit +atexit DATA atof atoi atol diff --git a/winsup/mingw/profile/Makefile.in b/winsup/mingw/profile/Makefile.in index d882526..c7f3a0c 100644 --- a/winsup/mingw/profile/Makefile.in +++ b/winsup/mingw/profile/Makefile.in @@ -49,7 +49,8 @@ THREAD_DLL_NAME = $(THREAD_DLL)$(THREAD_DLL_VERSION).dll INCLUDES = -I$(srcdir) -I$(srcdir)/../include \ -I$(srcdir)/../../w32api/include \ - -nostdinc -nostdinc++ + -nostdinc -nostdinc++ \ + -iwithprefixbefore include ALL_CFLAGS = $(CFLAGS) $(INCLUDES) $(MNO_CYGWIN) ALL_CXXFLAGS = $(CXXFLAGS) $(INCLUDES) $(MNO_CYGWIN) @@ -65,7 +66,8 @@ DLLTOOL_FLAGS = --as $(AS_FOR_TARGET) LIBGMON_A = @LIBGMON_A@ LIBGMON_OBJS = gmon.o mcount.o profil.o -CRT0S = gcrt1.o gcrt2.o +CRT0S = @CRT0S@ +ALL_CRT0S = gcrt0.o gcrt1.o gcrt2.o LIBS = $(LIBGMON_A) DLLS = @@ -76,6 +78,11 @@ $(LIBGMON_A): $(LIBGMON_OBJS) $(CRT0S) $(AR) $(ARFLAGS) $@ $(LIBGMON_OBJS) $(RANLIB) $@ +# FIXME: These are really the same, but gcc specs want different names. +# The only CRT dependency is atexit. +gcrt0.o: gcrt0.c + $(CC) -c -o $@ $(CPPFLAGS) $(CFLAGS) $? + gcrt1.o: gcrt0.c $(CC) -U__MSVCRT__ -c -o $@ $(CPPFLAGS) $(CFLAGS) $? @@ -95,22 +102,22 @@ info-html: install-info: info install: all - $(mkinstalldirs) $(tooldir)/lib + $(mkinstalldirs) $(inst_libdir) for i in $(LIBS); do \ - $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \ done for i in $(CRT0S); do \ - $(INSTALL_DATA) $$i $(tooldir)/lib/$$i ; \ + $(INSTALL_DATA) $$i $(inst_libdir)/$$i ; \ done for sub in . ; do \ - $(mkinstalldirs) $(tooldir)/include/$$sub ; \ + $(mkinstalldirs) $(inst_includedir)/$$sub ; \ for i in $(srcdir)/$$sub/*.h ; do \ - $(INSTALL_DATA) $$i $(tooldir)/include/$$sub/`basename $$i` ; \ + $(INSTALL_DATA) $$i $(inst_includedir)/$$sub/`basename $$i` ; \ done ; \ done clean: - -rm -f $(LIBGMON_OBJS) $(CRT0S) $(LIBGMON_A) + -rm -f $(LIBGMON_OBJS) $(ALL_CRT0S) $(LIBGMON_A) distclean: -rm -f *.o *.a *~ core a.out diff --git a/winsup/mingw/profile/configure b/winsup/mingw/profile/configure index cc3dcfe..f9c64e0 100755 --- a/winsup/mingw/profile/configure +++ b/winsup/mingw/profile/configure @@ -645,33 +645,29 @@ test "$host_alias" != "$target_alias" && program_prefix=${target_alias}- +LIBGMON_A=libgmon.a + case "$target_os" in *mingw32crt*) CRT_ID=1 MNO_CYGWIN= RUNTIME=crtdll - THREAD_DLL=mingwc - LIBM_A=libm.a - LIBGMON_A=libgmon.a + CRT0S="gcrt1.o gcrt2.o" ;; *cygwin*) CRT_ID=2 MNO_CYGWIN=-mno-cygwin RUNTIME=msvcrt - THREAD_DLL=mingwc + CRT0S=gcrt0.o # 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 MSVCRT by default. CRT_ID=2 MNO_CYGWIN= RUNTIME=msvcrt - THREAD_DLL=mingwm - LIBM_A=libm.a - LIBGMON_A=libgmon.a + CRT0S="gcrt1.o gcrt2.o" ;; esac @@ -681,7 +677,6 @@ 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: @@ -694,7 +689,7 @@ esac # 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 +echo "configure:693: 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 @@ -916,9 +911,8 @@ 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%@CRT0S@%$CRT0S%g s%@INSTALL_PROGRAM@%$INSTALL_PROGRAM%g s%@INSTALL_SCRIPT@%$INSTALL_SCRIPT%g s%@INSTALL_DATA@%$INSTALL_DATA%g diff --git a/winsup/mingw/profile/configure.in b/winsup/mingw/profile/configure.in index 4f41536..e688a67 100644 --- a/winsup/mingw/profile/configure.in +++ b/winsup/mingw/profile/configure.in @@ -35,42 +35,37 @@ DLLWRAP=${DLLWRAP-dllwrap} AC_SUBST(DLLWRAP) AC_CANONICAL_SYSTEM +LIBGMON_A=libgmon.a + case "$target_os" in *mingw32crt*) CRT_ID=1 MNO_CYGWIN= RUNTIME=crtdll - THREAD_DLL=mingwc - LIBM_A=libm.a - LIBGMON_A=libgmon.a + CRT0S="gcrt1.o gcrt2.o" ;; *cygwin*) CRT_ID=2 MNO_CYGWIN=-mno-cygwin RUNTIME=msvcrt - THREAD_DLL=mingwc + CRT0S=gcrt0.o # 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 MSVCRT by default. CRT_ID=2 MNO_CYGWIN= RUNTIME=msvcrt - THREAD_DLL=mingwm - LIBM_A=libm.a - LIBGMON_A=libgmon.a + CRT0S="gcrt1.o gcrt2.o" ;; 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_SUBST(CRT0S) AC_PROG_INSTALL AC_OUTPUT(Makefile) diff --git a/winsup/mingw/samples/dirent/wtest.c b/winsup/mingw/samples/dirent/wtest.c new file mode 100644 index 0000000..7985443 --- /dev/null +++ b/winsup/mingw/samples/dirent/wtest.c @@ -0,0 +1,98 @@ +/* + * A test which demonstrates the use of _wopendir and related + * wide char functions declared in dirent.h. + * + * TODO: Make this _UNICODE neutral using tchar.h mappings. + */ + +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include <errno.h> +#include <dirent.h> + +int +main (int argc, char* argv[]) +{ + int i; + struct _wdirent* de; + _WDIR* dir; + long lPos; + + if (argc == 2) + { + size_t len = strlen(argv[1]) + 1; + wchar_t* wpath = (wchar_t*) malloc(len *sizeof(wchar_t)); + mbstowcs(wpath, argv[1], len); + wprintf (L"Opening directory \"%s\"\n", wpath); + dir = _wopendir(wpath); + free (wpath); + } + else + { + wprintf (L"Opening \".\"\n"); + dir = _wopendir(L"."); + } + + if (!dir) + { + wprintf (L"Directory open failed!\n"); + if (errno) + { + wprintf (L"Error : %S\n", strerror(errno)); + } + return 1; + } + + i = 0; + lPos = -1; + + while ((de = _wreaddir (dir))) + { + i++; + wprintf (L"%d : \"%s\" (tell %ld)\n", i, de->d_name, + _wtelldir(dir)); + + if (i == 3) + { + wprintf (L"We will seek here later.\n"); + lPos = _wtelldir (dir); + } + } + + printf ("Rewind directory.\n"); + _wrewinddir (dir); + + if ((de = _wreaddir (dir))) + { + wprintf (L"First entry : \"%s\"\n", de->d_name); + } + else + { + wprintf (L"Empty directory.\n"); + } + + if (lPos != -1) + { + wprintf (L"Seeking to fourth entry.\n"); + _wseekdir (dir, lPos); + + if ((de = _wreaddir (dir))) + { + wprintf (L"Fourth entry : \"%s\"\n", de->d_name); + } + else + { + wprintf (L"No fourth entry.\n"); + } + } + else + { + wprintf (L"Seek position is past end of directory.\n"); + } + + wprintf (L"Closing directory.\n"); + _wclosedir (dir); +return 0; +} + |