From dc8971488e7c174ab4084cbdb0a8f12c39b738d7 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Thu, 13 Jun 2002 10:20:48 +0000 Subject: * include/_mingw.h: Increment version to 2.0. * Makefile.in: Ditto. Merge in mingwex branch. --- winsup/mingw/include/_mingw.h | 10 +- winsup/mingw/include/ctype.h | 41 ++++- winsup/mingw/include/dirent.h | 55 +++++- winsup/mingw/include/dos.h | 26 +-- winsup/mingw/include/fcntl.h | 8 +- winsup/mingw/include/fenv.h | 91 ++++++++++ winsup/mingw/include/float.h | 96 +++-------- winsup/mingw/include/inttypes.h | 275 +++++++++++++++++++++++++++++ winsup/mingw/include/math.h | 280 +++++++++++++++++++++++++++++- winsup/mingw/include/stdarg.h | 111 +----------- winsup/mingw/include/stddef.h | 372 +--------------------------------------- winsup/mingw/include/stdint.h | 10 +- winsup/mingw/include/stdio.h | 67 +++++--- winsup/mingw/include/stdlib.h | 114 +++++++++--- winsup/mingw/include/tchar.h | 19 ++ winsup/mingw/include/time.h | 12 +- winsup/mingw/include/varargs.h | 101 +---------- winsup/mingw/include/wchar.h | 35 ++++ winsup/mingw/include/wctype.h | 52 ++++-- 19 files changed, 1012 insertions(+), 763 deletions(-) create mode 100644 winsup/mingw/include/fenv.h create mode 100644 winsup/mingw/include/inttypes.h (limited to 'winsup/mingw/include') diff --git a/winsup/mingw/include/_mingw.h b/winsup/mingw/include/_mingw.h index 274428d7f..f8b126142 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 bc7c60db1..35a577b4c 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 92ec6b587..4df6bd997 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 d0d7892af..5374a7a52 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 61ed94604..bcc7bca47 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 000000000..e27095ff8 --- /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 709f3699e..dbd044155 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 /* * 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 000000000..70efb5f59 --- /dev/null +++ b/winsup/mingw/include/inttypes.h @@ -0,0 +1,275 @@ +/* 7.8 Format conversion of integer types */ + +#ifndef _INTTYPES_H_ +#define _INTTYPES_H_ + +#include +#define __need_wchar_t +#include + +#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 d94a7066c..c87b6163b 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 20169a1fc..90a2d95a0 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 - * - * 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 #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 7bdc2cfd0..ef9d5ffe4 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 - * - * 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 -#endif - -/* In 4.3bsd-net2, machine/ansi.h defines these symbols, which are - defined if the corresponding type is *not* defined. - FreeBSD-2.1 defines _MACHINE_ANSI_H_ instead of _ANSI_H_ */ -#if defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) -#if !defined(_SIZE_T_) && !defined(_BSD_SIZE_T_) -#define _SIZE_T -#endif -#if !defined(_PTRDIFF_T_) && !defined(_BSD_PTRDIFF_T_) -#define _PTRDIFF_T -#endif -/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ - instead of _WCHAR_T_. */ -#if !defined(_WCHAR_T_) && !defined(_BSD_WCHAR_T_) -#ifndef _BSD_WCHAR_T_ -#define _WCHAR_T -#endif -#endif -/* Undef _FOO_T_ if we are supposed to define foo_t. */ -#if defined (__need_ptrdiff_t) || defined (_STDDEF_H_) -#undef _PTRDIFF_T_ -#undef _BSD_PTRDIFF_T_ -#endif -#if defined (__need_size_t) || defined (_STDDEF_H_) -#undef _SIZE_T_ -#undef _BSD_SIZE_T_ -#endif -#if defined (__need_wchar_t) || defined (_STDDEF_H_) -#undef _WCHAR_T_ -#undef _BSD_WCHAR_T_ -#endif -#endif /* defined(_ANSI_H_) || defined(_MACHINE_ANSI_H_) */ - -/* Sequent's header files use _PTRDIFF_T_ in some conflicting way. - Just ignore it. */ -#if defined (__sequent__) && defined (_PTRDIFF_T_) -#undef _PTRDIFF_T_ -#endif - -/* On VxWorks, may have defined macros like - _TYPE_size_t which will typedef size_t. fixincludes patched the - vxTypesBase.h so that this macro is only defined if _GCC_SIZE_T is - not defined, and so that defining this macro defines _GCC_SIZE_T. - If we find that the macros are still defined at this point, we must - invoke them so that the type is defined as expected. */ -#if defined (_TYPE_ptrdiff_t) && (defined (__need_ptrdiff_t) || defined (_STDDEF_H_)) -_TYPE_ptrdiff_t; -#undef _TYPE_ptrdiff_t -#endif -#if defined (_TYPE_size_t) && (defined (__need_size_t) || defined (_STDDEF_H_)) -_TYPE_size_t; -#undef _TYPE_size_t -#endif -#if defined (_TYPE_wchar_t) && (defined (__need_wchar_t) || defined (_STDDEF_H_)) -_TYPE_wchar_t; -#undef _TYPE_wchar_t -#endif - -/* In case nobody has defined these types, but we aren't running under - GCC 2.00, make sure that __PTRDIFF_TYPE__, __SIZE__TYPE__, and - __WCHAR_TYPE__ have reasonable values. This can happen if the - parts of GCC is compiled by an older compiler, that actually - include gstddef.h, such as collect2. */ - -/* Signed type of difference of two pointers. */ - -/* Define this type if we are doing the whole job, - or if we want this type in particular. */ -#if defined (_STDDEF_H) || defined (__need_ptrdiff_t) -#ifndef _PTRDIFF_T /* in case has defined it. */ -#ifndef _T_PTRDIFF_ -#ifndef _T_PTRDIFF -#ifndef __PTRDIFF_T -#ifndef _PTRDIFF_T_ -#ifndef _BSD_PTRDIFF_T_ -#ifndef ___int_ptrdiff_t_h -#ifndef _GCC_PTRDIFF_T -#define _PTRDIFF_T -#define _T_PTRDIFF_ -#define _T_PTRDIFF -#define __PTRDIFF_T -#define _PTRDIFF_T_ -#define _BSD_PTRDIFF_T_ -#define ___int_ptrdiff_t_h -#define _GCC_PTRDIFF_T -#ifndef __PTRDIFF_TYPE__ -#define __PTRDIFF_TYPE__ long int -#endif -typedef __PTRDIFF_TYPE__ ptrdiff_t; -#endif /* _GCC_PTRDIFF_T */ -#endif /* ___int_ptrdiff_t_h */ -#endif /* _BSD_PTRDIFF_T_ */ -#endif /* _PTRDIFF_T_ */ -#endif /* __PTRDIFF_T */ -#endif /* _T_PTRDIFF */ -#endif /* _T_PTRDIFF_ */ -#endif /* _PTRDIFF_T */ - -/* If this symbol has done its job, get rid of it. */ -#undef __need_ptrdiff_t - -#endif /* _STDDEF_H or __need_ptrdiff_t. */ - -/* Unsigned type of `sizeof' something. */ - -/* Define this type if we are doing the whole job, - or if we want this type in particular. */ -#if defined (_STDDEF_H) || defined (__need_size_t) -#ifndef __size_t__ /* BeOS */ -#ifndef _SIZE_T /* in case has defined it. */ -#ifndef _SYS_SIZE_T_H -#ifndef _T_SIZE_ -#ifndef _T_SIZE -#ifndef __SIZE_T -#ifndef _SIZE_T_ -#ifndef _BSD_SIZE_T_ -#ifndef _SIZE_T_DEFINED_ -#ifndef _SIZE_T_DEFINED -#ifndef ___int_size_t_h -#ifndef _GCC_SIZE_T -#ifndef _SIZET_ -#ifndef __size_t -#define __size_t__ /* BeOS */ -#define _SIZE_T -#define _SYS_SIZE_T_H -#define _T_SIZE_ -#define _T_SIZE -#define __SIZE_T -#define _SIZE_T_ -#define _BSD_SIZE_T_ -#define _SIZE_T_DEFINED_ -#define _SIZE_T_DEFINED -#define ___int_size_t_h -#define _GCC_SIZE_T -#define _SIZET_ -#define __size_t -#ifndef __SIZE_TYPE__ -#define __SIZE_TYPE__ long unsigned int -#endif -#if !(defined (__GNUG__) && defined (size_t)) -typedef __SIZE_TYPE__ size_t; -#ifdef __BEOS__ -typedef long ssize_t; -#endif /* __BEOS__ */ -#endif /* !(defined (__GNUG__) && defined (size_t)) */ -#endif /* __size_t */ -#endif /* _SIZET_ */ -#endif /* _GCC_SIZE_T */ -#endif /* ___int_size_t_h */ -#endif /* _SIZE_T_DEFINED */ -#endif /* _SIZE_T_DEFINED_ */ -#endif /* _BSD_SIZE_T_ */ -#endif /* _SIZE_T_ */ -#endif /* __SIZE_T */ -#endif /* _T_SIZE */ -#endif /* _T_SIZE_ */ -#endif /* _SYS_SIZE_T_H */ -#endif /* _SIZE_T */ -#endif /* __size_t__ */ -#undef __need_size_t -#endif /* _STDDEF_H or __need_size_t. */ - -/* Wide character type. - Locale-writers should change this as necessary to - be big enough to hold unique values not between 0 and 127, - and not (wchar_t) -1, for each defined multibyte character. */ - -/* Define this type if we are doing the whole job, - or if we want this type in particular. */ -#if defined (_STDDEF_H) || defined (__need_wchar_t) -#ifndef __wchar_t__ /* BeOS */ -#ifndef _WCHAR_T -#ifndef _T_WCHAR_ -#ifndef _T_WCHAR -#ifndef __WCHAR_T -#ifndef _WCHAR_T_ -#ifndef _BSD_WCHAR_T_ -#ifndef _WCHAR_T_DEFINED_ -#ifndef _WCHAR_T_DEFINED -#ifndef _WCHAR_T_H -#ifndef ___int_wchar_t_h -#ifndef __INT_WCHAR_T_H -#ifndef _GCC_WCHAR_T -#define __wchar_t__ /* BeOS */ -#define _WCHAR_T -#define _T_WCHAR_ -#define _T_WCHAR -#define __WCHAR_T -#define _WCHAR_T_ -#define _BSD_WCHAR_T_ -#define _WCHAR_T_DEFINED_ -#define _WCHAR_T_DEFINED -#define _WCHAR_T_H -#define ___int_wchar_t_h -#define __INT_WCHAR_T_H -#define _GCC_WCHAR_T - -/* On BSD/386 1.1, at least, machine/ansi.h defines _BSD_WCHAR_T_ - instead of _WCHAR_T_, and _BSD_RUNE_T_ (which, unlike the other - symbols in the _FOO_T_ family, stays defined even after its - corresponding type is defined). If we define wchar_t, then we - must undef _WCHAR_T_; for BSD/386 1.1 (and perhaps others), if - we undef _WCHAR_T_, then we must also define rune_t, since - headers like runetype.h assume that if machine/ansi.h is included, - and _BSD_WCHAR_T_ is not defined, then rune_t is available. - machine/ansi.h says, "Note that _WCHAR_T_ and _RUNE_T_ must be of - the same type." */ -#ifdef _BSD_WCHAR_T_ -#undef _BSD_WCHAR_T_ -#ifdef _BSD_RUNE_T_ -#if !defined (_ANSI_SOURCE) && !defined (_POSIX_SOURCE) -typedef _BSD_RUNE_T_ rune_t; -#endif -#endif -#endif - -#ifndef __WCHAR_TYPE__ -#ifdef __BEOS__ -#define __WCHAR_TYPE__ unsigned char -#else -#define __WCHAR_TYPE__ int -#endif -#endif -#ifndef __cplusplus -typedef __WCHAR_TYPE__ wchar_t; -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif -#endif /* __wchar_t__ */ -#undef __need_wchar_t -#endif /* _STDDEF_H or __need_wchar_t. */ - -#if defined (_STDDEF_H) || defined (__need_wint_t) -#ifndef _WINT_T -#define _WINT_T - -#ifndef __WINT_TYPE__ -#define __WINT_TYPE__ unsigned int -#endif -typedef __WINT_TYPE__ wint_t; -#endif -#undef __need_wint_t -#endif - -/* In 4.3bsd-net2, leave these undefined to indicate that size_t, etc. - are already defined. */ -/* BSD/OS 3.1 requires the MACHINE_ANSI_H check here. FreeBSD 2.x apparently - does not, even though there is a check for MACHINE_ANSI_H above. */ -#if defined(_ANSI_H_) || (defined(__bsdi__) && defined(_MACHINE_ANSI_H_)) -/* The references to _GCC_PTRDIFF_T_, _GCC_SIZE_T_, and _GCC_WCHAR_T_ - are probably typos and should be removed before 2.8 is released. */ -#ifdef _GCC_PTRDIFF_T_ -#undef _PTRDIFF_T_ -#undef _BSD_PTRDIFF_T_ -#endif -#ifdef _GCC_SIZE_T_ -#undef _SIZE_T_ -#undef _BSD_SIZE_T_ -#endif -#ifdef _GCC_WCHAR_T_ -#undef _WCHAR_T_ -#undef _BSD_WCHAR_T_ -#endif -/* The following ones are the real ones. */ -#ifdef _GCC_PTRDIFF_T -#undef _PTRDIFF_T_ -#undef _BSD_PTRDIFF_T_ -#endif -#ifdef _GCC_SIZE_T -#undef _SIZE_T_ -#undef _BSD_SIZE_T_ -#endif -#ifdef _GCC_WCHAR_T -#undef _WCHAR_T_ -#undef _BSD_WCHAR_T_ +#include_next #endif -#endif /* _ANSI_H_ || ( __bsdi__ && _MACHINE_ANSI_H_ ) */ - -#endif /* __sys_stdtypes_h */ - -#endif /* RC_INVOKED */ - -/* A null pointer constant. */ - -#if defined (_STDDEF_H) || defined (__need_NULL) -#undef NULL /* in case has defined it. */ -#ifdef __GNUG__ -#define NULL __null -#else /* G++ */ -#define NULL ((void *)0) -#endif /* G++ */ -#endif /* NULL not defined and or need NULL. */ -#undef __need_NULL - -#ifdef _STDDEF_H - -/* Offset of member MEMBER in a struct of type TYPE. */ - -#define offsetof(TYPE, MEMBER) ((size_t) &((TYPE *)0)->MEMBER) - -#endif /* _STDDEF_H was defined this time */ - -#endif /* !_STDDEF_H && !_STDDEF_H_ && !_ANSI_STDDEF_H && !__STDDEF_H__ - || __need_XXX was not defined before */ diff --git a/winsup/mingw/include/stdint.h b/winsup/mingw/include/stdint.h index c3a79c5bb..ec1566db2 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 /* 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 b978abf44..fd5827ad0 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 +#define __need___va_list +#include #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 153e6483c..bc5884278 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 2b19c16a7..bc6f28f5c 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 6e9d1e4a0..f2f7b5024 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 f81c864bc..c1197e97e 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 - * - * 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 #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 69cd3bacc..61408e98e 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 1fb00fb3c..f39ef6496 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)) */ -- cgit v1.2.3