From 5a199765f94638d8f0600b4a8212c590436ac060 Mon Sep 17 00:00:00 2001 From: Danny Smith Date: Tue, 19 Nov 2002 08:47:50 +0000 Subject: Merge from mingw trunk (changes since 2002-10-04). --- winsup/mingw/ChangeLog | 87 +++++++++++++++- winsup/mingw/Makefile.in | 6 +- winsup/mingw/binmode.c | 11 ++ winsup/mingw/crt1.c | 26 ++++- winsup/mingw/include/fcntl.h | 2 +- winsup/mingw/include/stdint.h | 10 +- winsup/mingw/include/stdio.h | 6 +- winsup/mingw/include/stdlib.h | 2 +- winsup/mingw/include/string.h | 14 ++- winsup/mingw/include/tchar.h | 12 +++ winsup/mingw/mingwex/Makefile.in | 10 +- winsup/mingw/mingwex/math/cephes_mconf.h | 173 ++++++++++++++++++++++++++++--- winsup/mingw/mingwex/math/powil.c | 14 +-- winsup/mingw/mingwex/math/powl.c | 45 +------- winsup/mingw/mingwex/math/sqrtf.c | 17 ++- winsup/mingw/mingwex/math/sqrtl.c | 18 +++- winsup/mingw/samples/fmode/jamfile | 2 + winsup/mingw/txtmode.c | 11 ++ 18 files changed, 374 insertions(+), 92 deletions(-) diff --git a/winsup/mingw/ChangeLog b/winsup/mingw/ChangeLog index 309182c3d..0482b380e 100644 --- a/winsup/mingw/ChangeLog +++ b/winsup/mingw/ChangeLog @@ -1,3 +1,86 @@ +2002-11-19 Danny Smith + + Merge from mingw trunk, . + + 2002-11-09 Danny Smith + + * include/math.h (sqrt): Remove inline definition. + (sqrtf): Replace inline definition with prototype. + (sqrtl): Likewise. + * mingwex/math/sqrtf.c (sqrtf): Set domain error if + argument less than zero. + * mingwex/math/sqrtf.c (sqrtl): Likewise. + + 2002-10-30 Guido Serassio + + * include/stdio.h (_getmaxstdio): Add prototype. + (_setmaxstdio): Likewise. + + 2002-10-19 Kang Li + + * include/fcntl.h (O_SEQUENTIAL): Correct typo. + + 2002-10-19 Danny Smith + + * crt1.c: Define new macro __IN_MINGW_RUNTIME before including + stdlib.h. + Define WIN32_MEAN_AND_LEAN before including windows.h + * include/stdlib.h (_fmode): Protect declaration as dllimported + variable with __IN_MINGW_RUNTIME. + + 2002-10-19 Igor Pechtchanski + + * crt1.c: Include stdlib.h. + + 2002-10-19 Danny Smith + + * Makefile.in (CRT0S): Add txtmode.o binmode.o. + (MINGW_OBJS): Add txtmode.o. + (SRCDIST_FILES): Add txtmode.c binmode.c. + crt1.c: Don't include fcntrl.h, stdlib.h. + (_fmode): Declare, without dllimport attribute. + (__p__fmode): Declare access function for dll's _fmode. + (_mingw32_init_fmode): Sync dll _fmode with staticly linked + _fmode for app. + * txtmode.c: New file. + * binmode.c: New file. + * samples/fmode/test2.c: New file. + * samples/fmode/jamfile: Add test2.exe target. + + 2002-10-11 Danny Smith + + * include/stdint.h (INT64_C, UINT64_C ): Append suffix to let + macros work with C89. + (INTMAX_C, UINTMAX_C): Likewise. + + 2002-10-11 Danny Smith + + * include/string.h (strcasecmp): Make extern __inline__. + (strncasecmp): Likewise. + (wcscmpi): Likewise. + + 2002-10-08 Heiko Gerdau + + * include/tchar.h (_tchdir. _tgetcwd, _tgetdcwd. + _tmkdir, _trmdir, _tstat): Add ASCII and UNICODE + mappings. + + 2002-10-07 Danny Smith + + * mingwex/math/powil.c: Rename powil to __powil. + * mingwex/math/powl.c: Adjust declaration and call + to __powil. Remove comment on powil. + * mingwex/math/powi.c: New file. + * mingwex/math/powif.c: New file. + * mingwex/math/pow.c: New file. + * mingwex/math/cephes_mconf.h. Add double and float + versions of constants. + (polevl): Add double precision function. + (p1evl): Likewise. + * mingwex/Makefile.in (MATH_DISTFILES): Add pow.c, + powi.c, powif.c. + (MATH_OBJS): Add pow.o, powi.o, powif.o. + 2002-10-16 Danny Smith * include/stdio.h: Qualify another size_t with __CSTD. @@ -56,7 +139,7 @@ 2002-10-02 Danny Smith - * include/cytpe.h: Prefix identifiers used as args of inlines + * include/ctype.h: Prefix identifiers used as args of inlines with '__', throughout. * include/inttypes.h: Likewise. * include/math.h: Likewise. @@ -80,7 +163,7 @@ 2002-09-28 Danny Smith - * include/io.h: #include stddef.h with __need_wchat_t. + * include/io.h: #include stddef.h with __need_wchar_t. * include/wchar.h (__VA_LIST): Define as __builtin_va_list or char*. diff --git a/winsup/mingw/Makefile.in b/winsup/mingw/Makefile.in index 332fb1784..f2e5d253d 100644 --- a/winsup/mingw/Makefile.in +++ b/winsup/mingw/Makefile.in @@ -148,9 +148,9 @@ FLAGS_TO_PASS:=\ TARFILEEXT="$(TARFILEEXT)" CRT0S = crt1.o dllcrt1.o crt2.o dllcrt2.o CRT_noglob.o crtmt.o crtst.o \ - CRT_fp8.o CRT_fp10.o + CRT_fp8.o CRT_fp10.o txtmode.o binmode.o MINGW_OBJS = CRTglob.o CRTfmode.o CRTinit.o dllmain.o gccmain.o \ - main.o crtst.o mthr_stub.o CRT_fp10.o + main.o crtst.o mthr_stub.o CRT_fp10.o txtmode.o MOLD_OBJS = ctype_old.o string_old.o LIBS = libcrtdll.a libmsvcrt.a libmsvcrt20.a libmsvcrt40.a libmingw32.a \ @@ -164,7 +164,7 @@ 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 \ -CRT_fp8.c CRT_fp10.c test_headers.c +CRT_fp8.c CRT_fp10.c test_headers.c txtmode.c binmode.c all_dlls_host = @all_dlls_host@ install_dlls_host = @install_dlls_host@ diff --git a/winsup/mingw/binmode.c b/winsup/mingw/binmode.c index 1cc3dedbf..a5c57cb10 100644 --- a/winsup/mingw/binmode.c +++ b/winsup/mingw/binmode.c @@ -1,3 +1,14 @@ +/* + * binmode.c + * + * Adding binmode.o as object file when building an app + * sets the default file mode for user files to binary. + * It does not affect stdin, stderr, or stdout which will + * still be opened in text mode by default. + * + * 2002-10-19 Danny Smith + */ + #include /* Set default file mode to binary */ diff --git a/winsup/mingw/crt1.c b/winsup/mingw/crt1.c index 07aa9c5d4..ef4623f51 100644 --- a/winsup/mingw/crt1.c +++ b/winsup/mingw/crt1.c @@ -26,12 +26,17 @@ * */ +/* Hide the declaration of _fmode with dllimport attribute in stdlib.h. + This is not necessary with Mumit Khan's patches to gcc's winnt.c, + but those patches are still unofficial. */ + +#define __IN_MINGW_RUNTIME #include #include #include -#include #include #include +#define WIN32_LEAN_AND_MEAN #include #include @@ -55,6 +60,13 @@ extern int main (int, char **, char **); __MINGW_IMPORT void __set_app_type(int); #endif /* __MSVCRT__ */ +/* Global _fmode for this .exe, not the one in msvcrt.dll, + The default is set in txtmode.o in libmingw32.a */ +/* Override the dllimport'd declarations in stdlib.h */ +#undef _fmode +extern int _fmode; +extern int* __p__fmode(void); /* To access the dll _fmode */ + /* * Setup the default file handles to have the _CRT_fmode mode, as well as * any new files created by the user. @@ -64,7 +76,7 @@ extern int _CRT_fmode; static void _mingw32_init_fmode () { - /* Don't set the file mode if the user hasn't set any value for it. */ + /* Don't set the std file mode if the user hasn't set any value for it. */ if (_CRT_fmode) { _fmode = _CRT_fmode; @@ -89,6 +101,10 @@ _mingw32_init_fmode () _setmode (_fileno (stderr), _CRT_fmode); } } + + /* Now sync the dll _fmode to the one for this .exe. */ + *__p__fmode() = _fmode; + } /* This function will be called when a trap occurs. Thanks to Jacob @@ -180,8 +196,9 @@ __mingw_CRTStartup () _mingw32_init_mainargs (); /* - * Sets the default file mode for stdin, stdout and stderr, as well - * as files later opened by the user, to _CRT_fmode. + * Sets the default file mode. + * If _CRT_fmode is set, also set mode for stdin, stdout + * and stderr, as well * NOTE: DLLs don't do this because that would be rude! */ _mingw32_init_fmode (); @@ -230,6 +247,7 @@ WinMainCRTStartup () __set_app_type (__GUI_APP); #endif __mingw_CRTStartup (); +return 0; } /* diff --git a/winsup/mingw/include/fcntl.h b/winsup/mingw/include/fcntl.h index add43ff0e..ce193295b 100644 --- a/winsup/mingw/include/fcntl.h +++ b/winsup/mingw/include/fcntl.h @@ -80,7 +80,7 @@ #define O_BINARY _O_BINARY #define O_TEMPORARY _O_TEMPORARY #define O_NOINHERIT _O_NOINHERIT -#define O_SEQENTIAL _O_SEQUENTIAL +#define O_SEQUENTIAL _O_SEQUENTIAL #define O_RANDOM _O_RANDOM #endif /* Not _NO_OLDNAMES */ diff --git a/winsup/mingw/include/stdint.h b/winsup/mingw/include/stdint.h index ec1566db2..258002e3b 100644 --- a/winsup/mingw/include/stdint.h +++ b/winsup/mingw/include/stdint.h @@ -170,16 +170,18 @@ typedef unsigned long long uintmax_t; #define INT8_C(val) (INT_LEAST8_MAX-INT_LEAST8_MAX+(val)) #define INT16_C(val) (INT_LEAST16_MAX-INT_LEAST16_MAX+(val)) #define INT32_C(val) (INT_LEAST32_MAX-INT_LEAST32_MAX+(val)) -#define INT64_C(val) (INT_LEAST64_MAX-INT_LEAST64_MAX+(val)) +/* The 'trick' doesn't work in C89 for long long because, without + suffix, (val) will be evaluated as int, not intmax_t */ +#define INT64_C(val) val##LL #define UINT8_C(val) (UINT_LEAST8_MAX-UINT_LEAST8_MAX+(val)) #define UINT16_C(val) (UINT_LEAST16_MAX-UINT_LEAST16_MAX+(val)) #define UINT32_C(val) (UINT_LEAST32_MAX-UINT_LEAST32_MAX+(val)) -#define UINT64_C(val) (UINT_LEAST64_MAX-UINT_LEAST64_MAX+(val)) +#define UINT64_C(val) val##ULL /* 7.18.4.2 Macros for greatest-width integer constants */ -#define INTMAX_C(val) (INTMAX_MAX-INTMAX_MAX+(val)) -#define UINTMAX_C(val) (UINTMAX_MAX-UINTMAX_MAX+(val)) +#define INTMAX_C(val) val##LL +#define UINTMAX_C(val) val##ULL #endif /* !defined ( __cplusplus) || defined __STDC_CONSTANT_MACROS */ diff --git a/winsup/mingw/include/stdio.h b/winsup/mingw/include/stdio.h index 5390d36c5..65c4a4b7a 100644 --- a/winsup/mingw/include/stdio.h +++ b/winsup/mingw/include/stdio.h @@ -316,7 +316,11 @@ int _fgetchar (void); int _fputchar (int); __CSTD FILE* _fdopen (int, const char*); int _fileno (__CSTD FILE*); -int _fcloseall(void); +int _fcloseall(void); +#ifdef __MSVCRT__ +int _getmaxstdio(void); +int _setmaxstdio(int); +#endif #ifndef _NO_OLDNAMES int fgetchar (void); diff --git a/winsup/mingw/include/stdlib.h b/winsup/mingw/include/stdlib.h index ae88e8375..6f0ee4e49 100644 --- a/winsup/mingw/include/stdlib.h +++ b/winsup/mingw/include/stdlib.h @@ -282,7 +282,7 @@ wchar_t** __p__wpgmptr(void); * This variable determines the default file mode. * TODO: Which flags work? */ -#ifndef __DECLSPEC_SUPPORTED +#if !defined (__DECLSPEC_SUPPORTED) || defined (__IN_MINGW_RUNTIME) #ifdef __MSVCRT__ extern int* _imp___fmode; diff --git a/winsup/mingw/include/string.h b/winsup/mingw/include/string.h index da51709b9..678d49918 100644 --- a/winsup/mingw/include/string.h +++ b/winsup/mingw/include/string.h @@ -109,11 +109,17 @@ int memicmp (const void*, const void*, __CSTD size_t); char* strdup (const char*); int strcmpi (const char*, const char*); int stricmp (const char*, const char*); -int strcasecmp (const char*, const char*); +extern __inline__ int +strcasecmp (const char * __sz1, const char * __sz2) + {return _stricmp (__sz1, __sz2);} int stricoll (const char*, const char*); char* strlwr (char*); int strnicmp (const char*, const char*, __CSTD size_t); -int strncasecmp (const char*, const char*, __CSTD size_t); +extern __inline__ int +strncasecmp (const char*, const char*, __CSTD size_t); +extern __inline__ int +strncasecmp (const char * __sz1, const char * __sz2, __CSTD size_t __sizeMaxCompare) + {return _strnicmp (__sz1, __sz2, __sizeMaxCompare);} char* strnset (char*, int, __CSTD size_t); char* strrev (char*); char* strset (char*, int); @@ -167,7 +173,9 @@ wchar_t* _wcsdup (const wchar_t*); int _wcsicmp (const wchar_t*, const wchar_t*); int _wcsicoll (const wchar_t*, const wchar_t*); wchar_t* _wcslwr (wchar_t*); -int _wcsnicmp (const wchar_t*, const wchar_t*, __CSTD size_t); +extern __inline__ int +wcscmpi (const wchar_t * __ws1, const wchar_t * __ws2) + {return _wcsicmp (__ws1, __ws2);} wchar_t* _wcsnset (wchar_t*, wchar_t, __CSTD size_t); wchar_t* _wcsrev (wchar_t*); wchar_t* _wcsset (wchar_t*, wchar_t); diff --git a/winsup/mingw/include/tchar.h b/winsup/mingw/include/tchar.h index 9a5c1a1ae..d0c96dbbe 100644 --- a/winsup/mingw/include/tchar.h +++ b/winsup/mingw/include/tchar.h @@ -206,6 +206,12 @@ typedef wchar_t _TCHAR; #define _tfindfirsti64 _wfindfirsti64 #define _tfindnexti64 _wfindnexti64 #define _tfinddatai64_t _wfinddatai64_t +#define _tchdir _wchdir +#define _tgetcwd _wgetcwd +#define _tgetdcwd _wgetdcwd +#define _tmkdir _wmkdir +#define _trmdir _wrmdir +#define _tstat _wstat #endif /* __MSVCRT__ */ /* dirent structures and functions */ @@ -359,6 +365,12 @@ typedef char _TCHAR; #define _tsetlocale setlocale #define _tunlink _unlink #define _tfinddata_t _finddata_t +#define _tchdir _chdir +#define _tgetcwd _getcwd +#define _tgetdcwd _getdcwd +#define _tmkdir _mkdir +#define _trmdir _rmdir +#define _tstat _stat #if 1 /* defined __MSVCRT__ */ /* Not in crtdll.dll. Define macros anyway? */ diff --git a/winsup/mingw/mingwex/Makefile.in b/winsup/mingw/mingwex/Makefile.in index 4c346d346..8ede9f9e9 100644 --- a/winsup/mingw/mingwex/Makefile.in +++ b/winsup/mingw/mingwex/Makefile.in @@ -50,8 +50,9 @@ MATH_DISTFILES = \ log10f.S log10l.S log1p.S log1pf.S log1pl.S log2.S log2f.S \ log2l.S logb.c logbf.c logbl.c logf.S logl.S lrint.c lrintf.c \ lrintl.c lround.c lroundf.c lroundl.c modff.c modfl.c \ - nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c powf.c powil.c \ - powl.c remainder.S remainderf.S remainderl.S remquo.S \ + nearbyint.S nearbyintf.S nearbyintl.S nextafterf.c \ + pow.c powf.c powi.c powif.c powil.c powl.c \ + remainder.S remainderf.S remainderl.S remquo.S \ remquof.S remquol.S rint.c rintf.c rintl.c round.c roundf.c \ roundl.c scalbn.S scalbnf.S scalbnl.S signbit.c signbitf.c \ signbitl.c sinf.S sinhf.c sinhl.c sinl.S sqrtf.c sqrtl.c \ @@ -115,8 +116,9 @@ MATH_OBJS = \ log10f.o log10l.o log1p.o log1pf.o log1pl.o log2.o log2f.o \ log2l.o logb.o logbf.o logbl.o logf.o logl.o lrint.o lrintf.o \ lrintl.o lround.o lroundf.o lroundl.o modff.o modfl.o \ - nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o powf.o powil.o \ - powl.o remainder.o remainderf.o remainderl.o remquo.o \ + nearbyint.o nearbyintf.o nearbyintl.o nextafterf.o \ + pow.o powf.o powi.o powif.o powil.o powl.o \ + remainder.o remainderf.o remainderl.o remquo.o \ remquof.o remquol.o rint.o rintf.o rintl.o round.o roundf.o \ roundl.o scalbn.o scalbnf.o scalbnl.o signbit.o signbitf.o \ signbitl.o sinf.o sinhf.o sinhl.o sinl.o sqrtf.o sqrtl.o \ diff --git a/winsup/mingw/mingwex/math/cephes_mconf.h b/winsup/mingw/mingwex/math/cephes_mconf.h index ba8400f34..1dda63d53 100644 --- a/winsup/mingw/mingwex/math/cephes_mconf.h +++ b/winsup/mingw/mingwex/math/cephes_mconf.h @@ -1,8 +1,45 @@ #include #include + +#define IBMPC 1 +#define ANSIPROT 1 +#define MINUSZERO 1 +#define INFINITIES 1 +#define NANS 1 +#define DENORMAL 1 +#define VOLATILE +#define mtherr(fname, code) +#define XPD 0, + +#ifdef _CEPHES_USE_ERRNO +#define _SET_ERRNO(x) errno = (x) +#else +#define _SET_ERRNO(x) +#endif + /* constants used by cephes functions */ +/* double */ +#define MAXNUM 1.7976931348623158E308 +#define MAXLOG 7.09782712893383996843E2 +#define MINLOG -7.08396418532264106224E2 +#define LOGE2 6.93147180559945309417E-1 +#define LOG2E 1.44269504088896340736 +#define PI 3.14159265358979323846 +#define PIO2 1.57079632679489661923 +#define PIO4 7.85398163397448309616E-1 + +#define NEGZERO (-0.0) +extern double __INF; +#undef INFINITY +#define INFINITY (__INF) +extern double __QNAN; +#undef NAN +#define NAN (__QNAN) + + +/*long double*/ #define MAXNUML 1.189731495357231765021263853E4932L #define MAXLOGL 1.1356523406294143949492E4L #define MINLOGL -1.13994985314888605586758E4L @@ -17,27 +54,133 @@ #define isnanl isnan #define signbitl signbit - -#define IBMPC 1 -#define ANSIPROT 1 -#define MINUSZERO 1 -#define INFINITIES 1 -#define NANS 1 -#define DENORMAL 1 #define NEGZEROL (-0.0L) extern long double __INFL; #define INFINITYL (__INFL) extern long double __QNANL; #define NANL (__QNANL) -#define VOLATILE -#define mtherr(fname, code) -#define XPD 0, -#ifdef _CEPHES_USE_ERRNO -#define _SET_ERRNO(x) errno = (x) -#else -#define _SET_ERRNO(x) -#endif +/* float */ + +#define MAXNUMF 3.4028234663852885981170418348451692544e38F +#define MAXLOGF 88.72283905206835F +#define MINLOGF -103.278929903431851103F /* log(2^-149) */ +#define LOG2EF 1.44269504088896341F +#define LOGE2F 0.693147180559945309F +#define PIF 3.141592653589793238F +#define PIO2F 1.5707963267948966192F +#define PIO4F 0.7853981633974483096F + +#define isfinitef isfinite +#define isinff isinf +#define isnanf isnan +#define signbitf signbit + +#define NEGZEROF (-0.0F) +extern float __INFF; +#define INFINITYF (__INFF) +extern float __QNANF; +#define NANF (__QNANF) + + +/* double */ + +/* +Cephes Math Library Release 2.2: July, 1992 +Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier +Direct inquiries to 30 Frost Street, Cambridge, MA 02140 +*/ + + +/* polevl.c + * p1evl.c + * + * Evaluate polynomial + * + * + * + * SYNOPSIS: + * + * int N; + * double x, y, coef[N+1], polevl[]; + * + * y = polevl( x, coef, N ); + * + * + * + * DESCRIPTION: + * + * Evaluates polynomial of degree N: + * + * 2 N + * y = C + C x + C x +...+ C x + * 0 1 2 N + * + * Coefficients are stored in reverse order: + * + * coef[0] = C , ..., coef[N] = C . + * N 0 + * + * The function p1evl() assumes that coef[N] = 1.0 and is + * omitted from the array. Its calling arguments are + * otherwise the same as polevl(). + * + * + * SPEED: + * + * In the interest of speed, there are no checks for out + * of bounds arithmetic. This routine is used by most of + * the functions in the library. Depending on available + * equipment features, the user may wish to rewrite the + * program in microcode or assembly language. + * + */ + +/* Polynomial evaluator: + * P[0] x^n + P[1] x^(n-1) + ... + P[n] + */ +static __inline__ double polevl( x, p, n ) +double x; +const void *p; +int n; +{ +register double y; +register double *P = (double *)p; + +y = *P++; +do + { + y = y * x + *P++; + } +while( --n ); +return(y); +} + + + +/* Polynomial evaluator: + * x^n + P[0] x^(n-1) + P[1] x^(n-2) + ... + P[n] + */ +static __inline__ double p1evl( x, p, n ) +double x; +const void *p; +int n; +{ +register double y; +register double *P = (double *)p; + +n -= 1; +y = x + *P++; +do + { + y = y * x + *P++; + } +while( --n ); +return( y ); +} + + +/* long double */ /* Cephes Math Library Release 2.2: July, 1992 Copyright 1984, 1987, 1988, 1992 by Stephen L. Moshier diff --git a/winsup/mingw/mingwex/math/powil.c b/winsup/mingw/mingwex/math/powil.c index e900dd881..ec7a2866b 100644 --- a/winsup/mingw/mingwex/math/powil.c +++ b/winsup/mingw/mingwex/math/powil.c @@ -1,4 +1,4 @@ -/* powil.c +/* __powil.c * * Real raised to integer power, long double precision * @@ -6,10 +6,10 @@ * * SYNOPSIS: * - * long double x, y, powil(); + * long double x, y, __powil(); * int n; * - * y = powil( x, n ); + * y = __powil( x, n ); * * * @@ -36,7 +36,7 @@ * */ -/* powil.c */ +/* __powil.c */ /* Cephes Math Library Release 2.2: December, 1990 @@ -66,7 +66,7 @@ long double frexpl(); #define _SET_ERRNO(x) #endif -long double powil( x, nn ) +long double __powil( x, nn ) long double x; int nn; { @@ -126,7 +126,7 @@ else if( s > MAXLOGL ) { - mtherr( "powil", OVERFLOW ); + mtherr( "__powil", OVERFLOW ); _SET_ERRNO(ERANGE); y = INFINITYL; goto done; @@ -134,7 +134,7 @@ if( s > MAXLOGL ) if( s < MINLOGL ) { - mtherr( "powil", UNDERFLOW ); + mtherr( "__powil", UNDERFLOW ); _SET_ERRNO(ERANGE); return(0.0L); } diff --git a/winsup/mingw/mingwex/math/powl.c b/winsup/mingw/mingwex/math/powl.c index a94ede965..f066eeaee 100644 --- a/winsup/mingw/mingwex/math/powl.c +++ b/winsup/mingw/mingwex/math/powl.c @@ -382,7 +382,7 @@ static long double w, W, Wa, Wb, ya, yb, u; #ifdef __MINGW32__ static __inline__ long double reducl( long double ); -extern long double powil ( long double, int ); +extern long double __powil ( long double, int ); extern long double powl ( long double x, long double y); #else #ifdef ANSIPROT @@ -392,14 +392,14 @@ extern long double frexpl ( long double, int * ); extern long double ldexpl ( long double, int ); extern long double polevll ( long double, void *, int ); extern long double p1evll ( long double, void *, int ); -extern long double powil ( long double, int ); +extern long double __powil ( long double, int ); extern int isnanl ( long double ); extern int isfinitel ( long double ); static long double reducl( long double ); extern int signbitl ( long double ); #else long double floorl(), fabsl(), frexpl(), ldexpl(); -long double polevll(), p1evll(), powil(); +long double polevll(), p1evll(), __powil(); static long double reducl(); int isnanl(), isfinitel(), signbitl(); #endif @@ -603,7 +603,7 @@ if( iyflg ) w = floorl(x); if( (w == x) && (fabsl(y) < 32768.0) ) { - w = powil( x, (int) y ); + w = __powil( x, (int) y ); return( w ); } } @@ -764,40 +764,3 @@ t = ldexpl( t, -LNXT ); return(t); } -/* powil.c - * - * Real raised to integer power, long double precision - * - * - * - * SYNOPSIS: - * - * long double x, y, powil(); - * int n; - * - * y = powil( x, n ); - * - * - * - * DESCRIPTION: - * - * Returns argument x raised to the nth power. - * The routine efficiently decomposes n as a sum of powers of - * two. The desired power is a product of two-to-the-kth - * powers of x. Thus to compute the 32767 power of x requires - * 28 multiplications instead of 32767 multiplications. - * - * - * - * ACCURACY: - * - * - * Relative error: - * arithmetic x domain n domain # trials peak rms - * IEEE .001,1000 -1022,1023 50000 4.3e-17 7.8e-18 - * IEEE 1,2 -1022,1023 20000 3.9e-17 7.6e-18 - * IEEE .99,1.01 0,8700 10000 3.6e-16 7.2e-17 - * - * Returns INFINITY on overflow, zero on underflow. - * - */ diff --git a/winsup/mingw/mingwex/math/sqrtf.c b/winsup/mingw/mingwex/math/sqrtf.c index 55ca39dbe..b1029cad8 100644 --- a/winsup/mingw/mingwex/math/sqrtf.c +++ b/winsup/mingw/mingwex/math/sqrtf.c @@ -1,9 +1,20 @@ #include +#include + +extern float __QNANF; float sqrtf (float x) { - float res; - asm ("fsqrt" : "=t" (res) : "0" (x)); - return res; + if (x < 0.0F ) + { + errno = EDOM; + return __QNANF; + } + else + { + float res; + asm ("fsqrt" : "=t" (res) : "0" (x)); + return res; + } } diff --git a/winsup/mingw/mingwex/math/sqrtl.c b/winsup/mingw/mingwex/math/sqrtl.c index 0bd301390..dba68d878 100644 --- a/winsup/mingw/mingwex/math/sqrtl.c +++ b/winsup/mingw/mingwex/math/sqrtl.c @@ -1,8 +1,20 @@ #include +#include + +extern long double __QNANL; + long double sqrtl (long double x) { - long double res; - asm ("fsqrt" : "=t" (res) : "0" (x)); - return res; + if (x < 0.0L ) + { + errno = EDOM; + return __QNANL; + } + else + { + long double res; + asm ("fsqrt" : "=t" (res) : "0" (x)); + return res; + } } diff --git a/winsup/mingw/samples/fmode/jamfile b/winsup/mingw/samples/fmode/jamfile index 33455ec59..5b7a1cb06 100644 --- a/winsup/mingw/samples/fmode/jamfile +++ b/winsup/mingw/samples/fmode/jamfile @@ -1,5 +1,7 @@ Main test.exe : test.c ; +Main test2.exe : test2.c ; + Main all.exe : all.c ; diff --git a/winsup/mingw/txtmode.c b/winsup/mingw/txtmode.c index 077174697..a200bed17 100644 --- a/winsup/mingw/txtmode.c +++ b/winsup/mingw/txtmode.c @@ -1,3 +1,14 @@ +/* + * txtmode.c + * + * txtmode.o is included in libmingwex.a and sets default + * file mode to text. The value of this statically linked + * _fmode is used to set the dll version (using __p__fmode()), + * in crt1.c. + * + * 2002-10-19 Danny Smith + */ + #include /* Set default file mode to text */ -- cgit v1.2.3