mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 08:14:48 +00:00
mingw-w64: remove msvcrt sources
This commit is contained in:
parent
bbecbaab0a
commit
b126978555
1628
lib/libc/mingw/lib-common/msvcrt.def.in
vendored
1628
lib/libc/mingw/lib-common/msvcrt.def.in
vendored
File diff suppressed because it is too large
Load Diff
726
lib/libc/mingw/lib32/crtdll.def.in
vendored
726
lib/libc/mingw/lib32/crtdll.def.in
vendored
@ -1,726 +0,0 @@
|
||||
;
|
||||
;* crtdll.def
|
||||
;* This file has no copyright assigned and is placed in the Public Domain.
|
||||
;* This file is part of the mingw-runtime package.
|
||||
;* No warranty is given; refer to the file DISCLAIMER.PD within the package.
|
||||
;
|
||||
; Exports from crtdll.dll from Windows 95 SYSTEM directory. Hopefully this
|
||||
; should also work with the crtdll provided with Windows NT.
|
||||
;
|
||||
; NOTE: The crtdll is OBSOLETE and msvcrt should be used instead. The msvcrt
|
||||
; is available for free download from Microsoft Corporation and will work on
|
||||
; Windows 95. Support for the crtdll is deprecated and this file may be
|
||||
; deleted in future versions.
|
||||
;
|
||||
; These three functions appear to be name mangled in some way, so GCC is
|
||||
; probably not going to be able to use them in any case.
|
||||
;
|
||||
; ??2@YAPAXI@Z
|
||||
; ??3@YAXPAX@Z
|
||||
; ?_set_new_handler@@YAP6AHI@ZP6AHI@Z@Z
|
||||
;
|
||||
; These are functions for which I have not yet written prototypes or
|
||||
; otherwise set up (they are still included below though unlike those
|
||||
; first three).
|
||||
;
|
||||
; _CIacos
|
||||
; _CIasin
|
||||
; _CIatan
|
||||
; _CIatan2
|
||||
; _CIcos
|
||||
; _CIcosh
|
||||
; _CIexp
|
||||
; _CIfmod
|
||||
; _CIlog
|
||||
; _CIlog10
|
||||
; _CIpow
|
||||
; _CIsin
|
||||
; _CIsinh
|
||||
; _CIsqrt
|
||||
; _CItan
|
||||
; _CItanh
|
||||
; __dllonexit
|
||||
; __mb_cur_max_dll
|
||||
; __threadhandle
|
||||
; __threadid
|
||||
; _abnormal_termination
|
||||
; _acmdln_dll
|
||||
; _aexit_rtn_dll
|
||||
; _amsg_exit
|
||||
; _commit
|
||||
; _commode_dll
|
||||
; _cpumode_dll
|
||||
; _ctype
|
||||
; _expand
|
||||
; _fcloseall
|
||||
; _filbuf
|
||||
; _fileinfo_dll
|
||||
; _flsbuf
|
||||
; _flushall
|
||||
; _fmode_dll
|
||||
; _fpieee_flt
|
||||
; _fsopen
|
||||
; _ftol
|
||||
; _getdiskfree
|
||||
; _getdllprocaddr
|
||||
; _getdrive
|
||||
; _getdrives
|
||||
; _getsystime
|
||||
; _initterm
|
||||
; _ismbbalnum
|
||||
; _ismbbalpha
|
||||
; _ismbbgraph
|
||||
; _ismbbkalnum
|
||||
; _ismbbkana
|
||||
; _ismbbkpunct
|
||||
; _ismbblead
|
||||
; _ismbbprint
|
||||
; _ismbbpunct
|
||||
; _ismbbtrail
|
||||
; _ismbcalpha
|
||||
; _ismbcdigit
|
||||
; _ismbchira
|
||||
; _ismbckata
|
||||
; _ismbcl0
|
||||
; _ismbcl1
|
||||
; _ismbcl2
|
||||
; _ismbclegal
|
||||
; _ismbclower
|
||||
; _ismbcprint
|
||||
; _ismbcspace
|
||||
; _ismbcsymbol
|
||||
; _ismbcupper
|
||||
; _ismbslead
|
||||
; _ismbstrail
|
||||
; _lfind
|
||||
; _loaddll
|
||||
; _lrotl
|
||||
; _lrotr
|
||||
; _lsearch
|
||||
; _makepath
|
||||
; _matherr
|
||||
; _mbbtombc
|
||||
; _mbbtype
|
||||
; _mbccpy
|
||||
; _mbcjistojms
|
||||
; _mbcjmstojis
|
||||
; _mbclen
|
||||
; _mbctohira
|
||||
; _mbctokata
|
||||
; _mbctolower
|
||||
; _mbctombb
|
||||
; _mbctoupper
|
||||
; _mbctype
|
||||
; _mbsbtype
|
||||
; _mbscat
|
||||
; _mbscmp
|
||||
; _mbscpy
|
||||
; _mbscspn
|
||||
; _mbsdec
|
||||
; _mbsdup
|
||||
; _mbsicmp
|
||||
; _mbsinc
|
||||
; _mbslen
|
||||
; _mbslwr
|
||||
; _mbsnbcat
|
||||
; _mbsnbcmp
|
||||
; _mbsnbcnt
|
||||
; _mbsnbcpy
|
||||
; _mbsnbicmp
|
||||
; _mbsnbset
|
||||
; _mbsnccnt
|
||||
; _mbsncmp
|
||||
; _mbsncpy
|
||||
; _mbsnextc
|
||||
; _mbsnicmp
|
||||
; _mbsninc
|
||||
; _mbsnset
|
||||
; _mbspbrk
|
||||
; _mbsrchr
|
||||
; _mbsrev
|
||||
; _mbsset
|
||||
; _mbsspn
|
||||
; _mbsspnp
|
||||
; _mbsstr
|
||||
; _mbstrlen
|
||||
; _mbsupr
|
||||
; _onexit
|
||||
; _osversion_dll
|
||||
; _pctype_dll
|
||||
; _purecall
|
||||
; _pwctype_dll
|
||||
; _rmtmp
|
||||
; _rotl
|
||||
; _rotr
|
||||
; _setsystime
|
||||
; _snprintf
|
||||
; _snwprintf
|
||||
; _splitpath
|
||||
; _strdate
|
||||
; _strdec
|
||||
; _strinc
|
||||
; _strncnt
|
||||
; _strnextc
|
||||
; _strninc
|
||||
; _strspnp
|
||||
; _strtime
|
||||
; _tempnam
|
||||
; _ultoa
|
||||
; _unloaddll
|
||||
; _vsnprintf
|
||||
; _vsnwprintf
|
||||
; _wtoi
|
||||
; _wtol
|
||||
;
|
||||
LIBRARY "crtdll.dll"
|
||||
EXPORTS
|
||||
|
||||
#include "msvcrt-common.def.in"
|
||||
|
||||
_CIacos
|
||||
_CIasin
|
||||
_CIatan
|
||||
_CIatan2
|
||||
_CIcos
|
||||
_CIcosh
|
||||
_CIexp
|
||||
_CIfmod
|
||||
_CIlog
|
||||
_CIlog10
|
||||
_CIpow
|
||||
_CIsin
|
||||
_CIsinh
|
||||
_CIsqrt
|
||||
_CItan
|
||||
_CItanh
|
||||
_HUGE_dll DATA
|
||||
_HUGE DATA == _HUGE_dll
|
||||
_XcptFilter
|
||||
__GetMainArgs
|
||||
__argc_dll DATA
|
||||
__argc DATA == __argc_dll
|
||||
__argv_dll DATA
|
||||
__argv DATA == __argv_dll
|
||||
__dllonexit
|
||||
__doserrno
|
||||
__fpecode
|
||||
__isascii
|
||||
__iscsym
|
||||
__iscsymf
|
||||
__mb_cur_max_dll DATA
|
||||
__mb_cur_max DATA == __mb_cur_max_dll
|
||||
__pxcptinfoptrs
|
||||
__threadhandle
|
||||
__threadid
|
||||
__toascii
|
||||
_abnormal_termination
|
||||
_access
|
||||
_acmdln_dll DATA
|
||||
_acmdln DATA == _acmdln_dll
|
||||
_aexit_rtn_dll DATA
|
||||
_aexit_rtn DATA == _aexit_rtn_dll
|
||||
_amsg_exit
|
||||
_assert
|
||||
_basemajor_dll DATA
|
||||
_baseminor_dll DATA
|
||||
_baseversion_dll DATA
|
||||
_beep
|
||||
_beginthread
|
||||
_c_exit
|
||||
_cabs DATA
|
||||
_cexit
|
||||
_cgets
|
||||
_chdir
|
||||
_chdrive
|
||||
_chgsign
|
||||
_chmod
|
||||
_chsize
|
||||
_clearfp
|
||||
_close
|
||||
_commit
|
||||
_commode_dll DATA
|
||||
_commode DATA == _commode_dll
|
||||
_control87
|
||||
_controlfp
|
||||
_copysign
|
||||
_cprintf
|
||||
_cpumode_dll DATA
|
||||
_cputs
|
||||
_creat
|
||||
_cscanf
|
||||
_ctype DATA
|
||||
_cwait
|
||||
_daylight_dll DATA
|
||||
_daylight DATA == _daylight_dll
|
||||
_dup
|
||||
_dup2
|
||||
_ecvt
|
||||
_endthread
|
||||
_environ_dll DATA
|
||||
_environ DATA == _environ_dll
|
||||
_eof
|
||||
_errno
|
||||
_except_handler2
|
||||
_execl
|
||||
_execle
|
||||
_execlp
|
||||
_execlpe
|
||||
_execv
|
||||
_execve
|
||||
_execvp
|
||||
_execvpe
|
||||
_exit
|
||||
_expand
|
||||
_fcloseall
|
||||
_fcvt
|
||||
_fdopen
|
||||
_fgetchar
|
||||
_fgetwchar
|
||||
_filbuf
|
||||
_fileinfo_dll DATA
|
||||
_fileinfo DATA == _fileinfo_dll
|
||||
_filelength
|
||||
_fileno
|
||||
_findclose
|
||||
_findfirst
|
||||
_findnext
|
||||
_finite
|
||||
_flsbuf
|
||||
_flushall
|
||||
_fmode_dll DATA
|
||||
_fmode DATA == _fmode_dll
|
||||
_fpclass
|
||||
_fpieee_flt
|
||||
_fpreset DATA
|
||||
_fputchar
|
||||
_fputwchar
|
||||
_fsopen
|
||||
_fstat
|
||||
_ftime
|
||||
_ftol
|
||||
_fullpath
|
||||
_futime
|
||||
_gcvt
|
||||
_get_osfhandle
|
||||
_getch
|
||||
_getche
|
||||
_getcwd
|
||||
_getdcwd
|
||||
_getdiskfree
|
||||
_getdllprocaddr
|
||||
_getdrive
|
||||
_getdrives
|
||||
_getpid
|
||||
_getsystime
|
||||
_getw
|
||||
_global_unwind2
|
||||
_heapchk
|
||||
_heapmin
|
||||
_heapset
|
||||
_heapwalk
|
||||
_hypot
|
||||
_initterm
|
||||
_iob DATA
|
||||
_isatty
|
||||
_isctype
|
||||
_ismbbalnum
|
||||
_ismbbalpha
|
||||
_ismbbgraph
|
||||
_ismbbkalnum
|
||||
_ismbbkana
|
||||
_ismbbkpunct
|
||||
_ismbblead
|
||||
_ismbbprint
|
||||
_ismbbpunct
|
||||
_ismbbtrail
|
||||
_ismbcalpha
|
||||
_ismbcdigit
|
||||
_ismbchira
|
||||
_ismbckata
|
||||
_ismbcl0
|
||||
_ismbcl1
|
||||
_ismbcl2
|
||||
_ismbclegal
|
||||
_ismbclower
|
||||
_ismbcprint
|
||||
_ismbcspace
|
||||
_ismbcsymbol
|
||||
_ismbcupper
|
||||
_ismbslead
|
||||
_ismbstrail
|
||||
_isnan
|
||||
_itoa
|
||||
_j0
|
||||
_j1
|
||||
_jn
|
||||
_kbhit
|
||||
_lfind
|
||||
_loaddll
|
||||
_local_unwind2
|
||||
_locking
|
||||
_logb
|
||||
_lrotl
|
||||
_lrotr
|
||||
_lsearch
|
||||
_lseek
|
||||
_ltoa
|
||||
_makepath
|
||||
_matherr
|
||||
_mbbtombc
|
||||
_mbbtype
|
||||
_mbccpy
|
||||
_mbcjistojms
|
||||
_mbcjmstojis
|
||||
_mbclen
|
||||
_mbctohira
|
||||
_mbctokata
|
||||
_mbctolower
|
||||
_mbctombb
|
||||
_mbctoupper
|
||||
_mbctype DATA
|
||||
_mbsbtype
|
||||
_mbscat
|
||||
_mbschr
|
||||
_mbscmp
|
||||
_mbscpy
|
||||
_mbscspn
|
||||
_mbsdec
|
||||
_mbsdup
|
||||
_mbsicmp
|
||||
_mbsinc
|
||||
_mbslen
|
||||
_mbslwr
|
||||
_mbsnbcat
|
||||
_mbsnbcmp
|
||||
_mbsnbcnt
|
||||
_mbsnbcpy
|
||||
_mbsnbicmp
|
||||
_mbsnbset
|
||||
_mbsncat
|
||||
_mbsnccnt
|
||||
_mbsncmp
|
||||
_mbsncpy
|
||||
_mbsnextc
|
||||
_mbsnicmp
|
||||
_mbsninc
|
||||
_mbsnset
|
||||
_mbspbrk
|
||||
_mbsrchr
|
||||
_mbsrev
|
||||
_mbsset
|
||||
_mbsspn
|
||||
_mbsspnp
|
||||
_mbsstr
|
||||
_mbstok
|
||||
_mbstrlen
|
||||
_mbsupr
|
||||
_memccpy
|
||||
_memicmp
|
||||
_mkdir
|
||||
_mktemp
|
||||
_msize
|
||||
_nextafter
|
||||
_onexit
|
||||
_open
|
||||
_open_osfhandle
|
||||
_osmajor_dll DATA
|
||||
_osminor_dll DATA
|
||||
_osmode_dll DATA
|
||||
_osver_dll DATA
|
||||
_osver DATA == _osver_dll
|
||||
_osversion_dll DATA
|
||||
_pclose
|
||||
_pctype_dll DATA
|
||||
_pctype DATA == _pctype_dll
|
||||
_pgmptr_dll DATA
|
||||
_pgmptr DATA == _pgmptr_dll
|
||||
_pipe
|
||||
_popen
|
||||
_purecall
|
||||
_putch
|
||||
_putenv
|
||||
_putw
|
||||
_pwctype_dll DATA
|
||||
_pwctype DATA == _pwctype_dll
|
||||
_read
|
||||
_rmdir
|
||||
_rmtmp
|
||||
_rotl
|
||||
_rotr
|
||||
_scalb
|
||||
_searchenv
|
||||
_seterrormode
|
||||
_setjmp
|
||||
_setmode
|
||||
_setsystime
|
||||
_sleep
|
||||
_snprintf
|
||||
_snwprintf
|
||||
_sopen
|
||||
_spawnl
|
||||
_spawnle
|
||||
_spawnlp
|
||||
_spawnlpe
|
||||
_spawnv
|
||||
_spawnve
|
||||
_spawnvp
|
||||
_spawnvpe
|
||||
_splitpath
|
||||
_stat
|
||||
_statusfp
|
||||
_strcmpi
|
||||
_strdate
|
||||
_strdec
|
||||
_strdup
|
||||
_strerror
|
||||
_stricmp
|
||||
_stricoll
|
||||
_strinc
|
||||
_strlwr
|
||||
strlwr == _strlwr
|
||||
_strncnt
|
||||
_strnextc
|
||||
_strnicmp
|
||||
_strninc
|
||||
_strnset
|
||||
_strrev
|
||||
_strset
|
||||
_strspnp
|
||||
_strtime
|
||||
_strupr
|
||||
_swab
|
||||
_sys_errlist DATA
|
||||
_sys_nerr_dll DATA
|
||||
_sys_nerr DATA == _sys_nerr_dll
|
||||
_tell
|
||||
_tempnam
|
||||
_timezone_dll DATA
|
||||
_timezone DATA == _timezone_dll
|
||||
_tolower
|
||||
_toupper
|
||||
_tzname DATA
|
||||
_tzset
|
||||
_ultoa
|
||||
_umask
|
||||
_ungetch
|
||||
_unlink
|
||||
_unloaddll
|
||||
_utime
|
||||
_vsnprintf
|
||||
_vsnwprintf
|
||||
_wcsdup
|
||||
_wcsicmp
|
||||
_wcsicoll
|
||||
_wcslwr
|
||||
wcslwr == _wcslwr
|
||||
_wcsnicmp
|
||||
_wcsnset
|
||||
_wcsrev
|
||||
_wcsset
|
||||
_wcsupr
|
||||
_winmajor_dll DATA
|
||||
_winmajor DATA == _winmajor_dll
|
||||
_winminor_dll DATA
|
||||
_winminor DATA == _winminor_dll
|
||||
_winver_dll DATA
|
||||
_winver DATA == _winver_dll
|
||||
_write
|
||||
_wtoi
|
||||
_wtol
|
||||
_y0
|
||||
_y1
|
||||
_yn
|
||||
abort
|
||||
abs
|
||||
acos
|
||||
asctime
|
||||
asin DATA
|
||||
atan DATA
|
||||
atan2 DATA
|
||||
atexit DATA
|
||||
atof
|
||||
atoi
|
||||
atol
|
||||
bsearch
|
||||
calloc
|
||||
ceil
|
||||
clearerr
|
||||
clock
|
||||
cos DATA
|
||||
cosh
|
||||
ctime DATA
|
||||
;_ctime32 = ctime
|
||||
difftime
|
||||
div
|
||||
exit
|
||||
exp DATA
|
||||
fabs DATA
|
||||
fclose
|
||||
feof
|
||||
ferror
|
||||
fflush
|
||||
fgetc
|
||||
fgetpos
|
||||
fgets
|
||||
fgetwc
|
||||
floor
|
||||
fmod
|
||||
fopen
|
||||
fprintf
|
||||
fputc
|
||||
fputs
|
||||
fputwc
|
||||
fread
|
||||
free
|
||||
freopen
|
||||
frexp
|
||||
fscanf
|
||||
fseek
|
||||
fsetpos
|
||||
ftell
|
||||
fwprintf
|
||||
fwrite
|
||||
fwscanf
|
||||
getc
|
||||
getchar
|
||||
getenv
|
||||
gets
|
||||
gmtime DATA
|
||||
;_gmtime32 = gmtime
|
||||
is_wctype
|
||||
isalnum
|
||||
isalpha
|
||||
iscntrl
|
||||
isdigit
|
||||
isgraph
|
||||
isleadbyte
|
||||
islower
|
||||
isprint
|
||||
ispunct
|
||||
isspace
|
||||
isupper
|
||||
iswalnum
|
||||
iswalpha
|
||||
iswascii
|
||||
iswcntrl
|
||||
iswctype
|
||||
iswdigit
|
||||
iswgraph
|
||||
iswlower
|
||||
iswprint
|
||||
iswpunct
|
||||
iswspace
|
||||
iswupper
|
||||
iswxdigit
|
||||
isxdigit
|
||||
labs
|
||||
ldexp DATA
|
||||
ldiv
|
||||
localeconv
|
||||
localtime DATA
|
||||
;_localtime32 = localtime
|
||||
log
|
||||
log10
|
||||
longjmp
|
||||
malloc
|
||||
mblen
|
||||
mbstowcs
|
||||
mbtowc
|
||||
memchr
|
||||
memcmp
|
||||
memcpy
|
||||
memmove
|
||||
memset
|
||||
mktime DATA
|
||||
;_mktime32 = mktime
|
||||
modf
|
||||
perror
|
||||
pow
|
||||
printf
|
||||
putc
|
||||
putchar
|
||||
puts
|
||||
qsort
|
||||
raise
|
||||
rand
|
||||
realloc
|
||||
remove
|
||||
rename
|
||||
rewind
|
||||
scanf
|
||||
setbuf
|
||||
setlocale
|
||||
setvbuf
|
||||
signal
|
||||
sin
|
||||
sinh
|
||||
sprintf
|
||||
sqrt
|
||||
srand
|
||||
sscanf
|
||||
strcat
|
||||
strchr
|
||||
strcmp
|
||||
strcoll
|
||||
strcpy
|
||||
strcspn
|
||||
strerror
|
||||
strftime
|
||||
strlen
|
||||
strncat
|
||||
strncmp
|
||||
strncpy
|
||||
strpbrk
|
||||
strrchr
|
||||
strspn
|
||||
strstr
|
||||
strtod
|
||||
strtok
|
||||
strtol
|
||||
strtoul
|
||||
strxfrm
|
||||
swprintf
|
||||
swscanf
|
||||
system
|
||||
tan
|
||||
tanh
|
||||
time DATA
|
||||
;_time32 = time
|
||||
tmpfile
|
||||
tmpnam
|
||||
tolower
|
||||
toupper
|
||||
towlower
|
||||
towupper
|
||||
ungetc
|
||||
ungetwc
|
||||
vfprintf
|
||||
vfwprintf
|
||||
vprintf
|
||||
vsprintf
|
||||
vswprintf
|
||||
vwprintf
|
||||
wcscat
|
||||
wcschr
|
||||
wcscmp
|
||||
wcscoll
|
||||
wcscpy
|
||||
wcscspn
|
||||
wcsftime
|
||||
wcslen
|
||||
wcsncat
|
||||
wcsncmp
|
||||
wcsncpy
|
||||
wcspbrk
|
||||
wcsrchr
|
||||
wcsspn
|
||||
wcsstr
|
||||
wcstod
|
||||
wcstok
|
||||
wcstol
|
||||
wcstombs
|
||||
wcstoul
|
||||
wcsxfrm
|
||||
wctomb
|
||||
wprintf
|
||||
wscanf
|
||||
71
lib/libc/mingw/lib32/msvcp60.def
vendored
71
lib/libc/mingw/lib32/msvcp60.def
vendored
@ -1,71 +0,0 @@
|
||||
;Submitted by: Danny Smith <danny_r_smith_2001@yahoo.co.nz>
|
||||
;Only the C functions are listed. Most of these have been commented out since
|
||||
;I don't know what they are and can't test them. Some look like data exports
|
||||
;for C++ math functions (E.G.: _Xbig).
|
||||
LIBRARY MSVCP60.DLL
|
||||
EXPORTS
|
||||
;_Cosh
|
||||
;_Denorm
|
||||
;_Dnorm
|
||||
;_Dscale
|
||||
;_Dtest
|
||||
;_Eps
|
||||
;_Exp
|
||||
;_FCosh
|
||||
;_FDenorm
|
||||
;_FDnorm
|
||||
;_FDscale
|
||||
;_FDtest
|
||||
;_FEps
|
||||
;_FExp
|
||||
;_FInf
|
||||
;_FNan
|
||||
;_FRteps
|
||||
;_FSinh
|
||||
;_FSnan
|
||||
;_FXbig
|
||||
;_Getcoll
|
||||
;_Getctype
|
||||
;_Getcvt
|
||||
;_Hugeval
|
||||
;_Inf
|
||||
;_LCosh
|
||||
;_LDenorm
|
||||
;_LDscale
|
||||
;_LDtest
|
||||
;_LEps
|
||||
;_LExp
|
||||
;_LInf
|
||||
;_LNan
|
||||
;_LPoly
|
||||
;_LRteps
|
||||
;_LSinh
|
||||
;_LSnan
|
||||
;_LXbig
|
||||
;_Mbrtowc
|
||||
;_Nan
|
||||
;_Poly
|
||||
;_Rteps
|
||||
;_Sinh
|
||||
;_Snan
|
||||
;_Stod
|
||||
;_Stof
|
||||
;_Stold
|
||||
;_Strcoll
|
||||
;_Strxfrm
|
||||
;_Tolower
|
||||
;_Toupper
|
||||
;_Wcrtomb
|
||||
;__Wcrtomb_lk
|
||||
;_Xbig
|
||||
|
||||
btowc
|
||||
mbrlen
|
||||
mbrtowc
|
||||
mbsrtowcs
|
||||
towctrans
|
||||
wcrtomb
|
||||
wcsrtombs
|
||||
wctob
|
||||
wctrans
|
||||
wctype
|
||||
16
lib/libc/mingw/math/arm-common/acosh.c
vendored
16
lib/libc/mingw/math/arm-common/acosh.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double acosh(double x)
|
||||
{
|
||||
if (x < 1.0)
|
||||
return NAN;
|
||||
if (isinf(x*x))
|
||||
return log(2) + log(x);
|
||||
return log(x + sqrt(x*x - 1));
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/acoshf.c
vendored
16
lib/libc/mingw/math/arm-common/acoshf.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float acoshf(float x)
|
||||
{
|
||||
if (x < 1.0)
|
||||
return NAN;
|
||||
if (isinf(x*x))
|
||||
return logf(2) + logf(x);
|
||||
return logf(x + sqrtf(x*x - 1));
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/acoshl.c
vendored
16
lib/libc/mingw/math/arm-common/acoshl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double acoshl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return acosh(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
18
lib/libc/mingw/math/arm-common/asinh.c
vendored
18
lib/libc/mingw/math/arm-common/asinh.c
vendored
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double asinh(double x)
|
||||
{
|
||||
if (isinf(x*x + 1)) {
|
||||
if (x > 0)
|
||||
return log(2) + log(x);
|
||||
else
|
||||
return -log(2) - log(-x);
|
||||
}
|
||||
return log(x + sqrt(x*x + 1));
|
||||
}
|
||||
18
lib/libc/mingw/math/arm-common/asinhf.c
vendored
18
lib/libc/mingw/math/arm-common/asinhf.c
vendored
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float asinhf(float x)
|
||||
{
|
||||
if (isinf(x*x + 1)) {
|
||||
if (x > 0)
|
||||
return logf(2) + logf(x);
|
||||
else
|
||||
return -logf(2) - logf(-x);
|
||||
}
|
||||
return logf(x + sqrtf(x*x + 1));
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/asinhl.c
vendored
16
lib/libc/mingw/math/arm-common/asinhl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double asinhl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return asinh(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/atanh.c
vendored
17
lib/libc/mingw/math/arm-common/atanh.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double atanh(double x)
|
||||
{
|
||||
if (x > 1 || x < -1)
|
||||
return NAN;
|
||||
if (-1e-6 < x && x < 1e-6)
|
||||
return x + x*x*x/3;
|
||||
else
|
||||
return (log(1 + x) - log(1 - x)) / 2;
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/atanhf.c
vendored
17
lib/libc/mingw/math/arm-common/atanhf.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float atanhf(float x)
|
||||
{
|
||||
if (x > 1 || x < -1)
|
||||
return NAN;
|
||||
if (-1e-6 < x && x < 1e-6)
|
||||
return x + x*x*x/3;
|
||||
else
|
||||
return (logf(1 + x) - logf(1 - x)) / 2;
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/atanhl.c
vendored
16
lib/libc/mingw/math/arm-common/atanhl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double atanhl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return atanh(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
11
lib/libc/mingw/math/arm-common/copysignl.c
vendored
11
lib/libc/mingw/math/arm-common/copysignl.c
vendored
@ -1,11 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
long double copysignl(long double x, long double y)
|
||||
{
|
||||
return copysign(x, y);
|
||||
}
|
||||
12
lib/libc/mingw/math/arm-common/expm1.c
vendored
12
lib/libc/mingw/math/arm-common/expm1.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double expm1(double x)
|
||||
{
|
||||
return exp(x) - 1.0;
|
||||
}
|
||||
15
lib/libc/mingw/math/arm-common/expm1f.c
vendored
15
lib/libc/mingw/math/arm-common/expm1f.c
vendored
@ -1,15 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float expm1f(float x)
|
||||
{
|
||||
// Intentionally using double version of exp() here in the float version of
|
||||
// expm1, to preserve as much accuracy as possible in the intermediate
|
||||
// result.
|
||||
return exp(x) - 1.0;
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/expm1l.c
vendored
16
lib/libc/mingw/math/arm-common/expm1l.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double expm1l(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return expm1(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
19
lib/libc/mingw/math/arm-common/ilogb.c
vendored
19
lib/libc/mingw/math/arm-common/ilogb.c
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
int ilogb(double x)
|
||||
{
|
||||
if (x == 0.0)
|
||||
return FP_ILOGB0;
|
||||
if (isinf(x))
|
||||
return INT_MAX;
|
||||
if (isnan(x))
|
||||
return FP_ILOGBNAN;
|
||||
return (int) logb(x);
|
||||
}
|
||||
19
lib/libc/mingw/math/arm-common/ilogbf.c
vendored
19
lib/libc/mingw/math/arm-common/ilogbf.c
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
int ilogbf(float x)
|
||||
{
|
||||
if (x == 0.0)
|
||||
return FP_ILOGB0;
|
||||
if (isinf(x))
|
||||
return INT_MAX;
|
||||
if (isnan(x))
|
||||
return FP_ILOGBNAN;
|
||||
return (int) logbf(x);
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/ilogbl.c
vendored
16
lib/libc/mingw/math/arm-common/ilogbl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
int ilogbl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return ilogb(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
12
lib/libc/mingw/math/arm-common/log1p.c
vendored
12
lib/libc/mingw/math/arm-common/log1p.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double log1p(double x)
|
||||
{
|
||||
return log(x + 1.0);
|
||||
}
|
||||
15
lib/libc/mingw/math/arm-common/log1pf.c
vendored
15
lib/libc/mingw/math/arm-common/log1pf.c
vendored
@ -1,15 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
float log1pf(float x)
|
||||
{
|
||||
// Intentionally using double version of log() here in the float version of
|
||||
// log1p, to preserve as much accuracy as possible in the intermediate
|
||||
// parameter.
|
||||
return log(x + 1.0);
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/log1pl.c
vendored
16
lib/libc/mingw/math/arm-common/log1pl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double log1pl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return log1p(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
55
lib/libc/mingw/math/arm-common/log2.c
vendored
55
lib/libc/mingw/math/arm-common/log2.c
vendored
@ -1,55 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
typedef union ieee754_double_ {
|
||||
struct __attribute__((__packed__)) {
|
||||
uint64_t f52 : 52;
|
||||
uint64_t exp : 11;
|
||||
uint64_t sgn : 1;
|
||||
};
|
||||
double f;
|
||||
} ieee754_double;
|
||||
|
||||
typedef union ieee754_float_ {
|
||||
struct __attribute__((__packed__)) {
|
||||
uint32_t f23 : 23;
|
||||
uint32_t exp : 8;
|
||||
uint32_t sgn : 1;
|
||||
};
|
||||
float f;
|
||||
} ieee754_float;
|
||||
|
||||
double log2(double x)
|
||||
{
|
||||
ieee754_double u = { .f = x };
|
||||
if (u.sgn == 0 && u.f52 == 0 && u.exp > 0 && u.exp < 0x7ff) {
|
||||
// Handle exact powers of two exactly
|
||||
return (int)u.exp - 1023;
|
||||
}
|
||||
return log(x) / 0.69314718246459960938;
|
||||
}
|
||||
|
||||
float log2f(float x)
|
||||
{
|
||||
ieee754_float u = { .f = x };
|
||||
if (u.sgn == 0 && u.f23 == 0 && u.exp > 0 && u.exp < 0xff) {
|
||||
// Handle exact powers of two exactly
|
||||
return (int)u.exp - 127;
|
||||
}
|
||||
return logf(x) / 0.69314718246459960938f;
|
||||
}
|
||||
|
||||
long double log2l(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return log2(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/logb.c
vendored
17
lib/libc/mingw/math/arm-common/logb.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
extern double (* __MINGW_IMP_SYMBOL(_logb))(double);
|
||||
|
||||
double logb(double x)
|
||||
{
|
||||
if (isinf(x))
|
||||
return INFINITY;
|
||||
return __MINGW_IMP_SYMBOL(_logb)(x);
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/logbf.c
vendored
17
lib/libc/mingw/math/arm-common/logbf.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
extern float (* __MINGW_IMP_SYMBOL(_logbf))(float);
|
||||
|
||||
float logbf(float x)
|
||||
{
|
||||
if (isinf(x))
|
||||
return INFINITY;
|
||||
return __MINGW_IMP_SYMBOL(_logbf)(x);
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/logbl.c
vendored
16
lib/libc/mingw/math/arm-common/logbl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double logbl(long double x)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return logb(x);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
21
lib/libc/mingw/math/arm-common/powf.c
vendored
21
lib/libc/mingw/math/arm-common/powf.c
vendored
@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
|
||||
extern float (* __MINGW_IMP_SYMBOL(powf))(float, float);
|
||||
|
||||
float powf(float x, float y)
|
||||
{
|
||||
if (x == 1.0f)
|
||||
return 1.0f;
|
||||
if (y == 0.0f)
|
||||
return 1.0f;
|
||||
if (x == -1.0f && isinf(y))
|
||||
return 1.0f;
|
||||
return __MINGW_IMP_SYMBOL(powf)(x, y);
|
||||
}
|
||||
16
lib/libc/mingw/math/arm-common/powl.c
vendored
16
lib/libc/mingw/math/arm-common/powl.c
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
long double powl(long double x, long double y)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return pow(x, y);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
14
lib/libc/mingw/math/arm-common/remainder.c
vendored
14
lib/libc/mingw/math/arm-common/remainder.c
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
double remainder(double x, double y)
|
||||
{
|
||||
int iret;
|
||||
return remquo(x, y, &iret);
|
||||
}
|
||||
14
lib/libc/mingw/math/arm-common/remainderf.c
vendored
14
lib/libc/mingw/math/arm-common/remainderf.c
vendored
@ -1,14 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
float remainderf(float x, float y)
|
||||
{
|
||||
int iret;
|
||||
return remquof(x, y, &iret);
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/remainderl.c
vendored
17
lib/libc/mingw/math/arm-common/remainderl.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
long double remainderl(long double x, long double y)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return remainder(x, y);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
17
lib/libc/mingw/math/arm-common/remquol.c
vendored
17
lib/libc/mingw/math/arm-common/remquol.c
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
long double remquol(long double x, long double y, int *quo)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return remquo(x, y, quo);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
154
lib/libc/mingw/math/arm-common/s_remquo.c
vendored
154
lib/libc/mingw/math/arm-common/s_remquo.c
vendored
@ -1,154 +0,0 @@
|
||||
/* @(#)e_fmod.c 1.3 95/01/18 */
|
||||
/*-
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunSoft, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include <math.h>
|
||||
#include "../bsd_private_base.h"
|
||||
|
||||
static const double Zero[] = {0.0, -0.0,};
|
||||
|
||||
/*
|
||||
* Return the IEEE remainder and set *quo to the last n bits of the
|
||||
* quotient, rounded to the nearest integer. We choose n=31 because
|
||||
* we wind up computing all the integer bits of the quotient anyway as
|
||||
* a side-effect of computing the remainder by the shift and subtract
|
||||
* method. In practice, this is far more bits than are needed to use
|
||||
* remquo in reduction algorithms.
|
||||
*/
|
||||
double
|
||||
remquo(double x, double y, int *quo)
|
||||
{
|
||||
int32_t n,hx,hy,hz,ix,iy,sx,i;
|
||||
u_int32_t lx,ly,lz,q,sxy;
|
||||
|
||||
EXTRACT_WORDS(hx,lx,x);
|
||||
EXTRACT_WORDS(hy,ly,y);
|
||||
sxy = (hx ^ hy) & 0x80000000;
|
||||
sx = hx&0x80000000; /* sign of x */
|
||||
hx ^=sx; /* |x| */
|
||||
hy &= 0x7fffffff; /* |y| */
|
||||
|
||||
/* purge off exception values */
|
||||
if((hy|ly)==0||(hx>=0x7ff00000)|| /* y=0,or x not finite */
|
||||
((hy|((ly|-ly)>>31))>0x7ff00000)) /* or y is NaN */
|
||||
return nan_mix_op(x, y, *)/nan_mix_op(x, y, *);
|
||||
if(hx<=hy) {
|
||||
if((hx<hy)||(lx<ly)) {
|
||||
q = 0;
|
||||
goto fixup; /* |x|<|y| return x or x-y */
|
||||
}
|
||||
if(lx==ly) {
|
||||
*quo = (sxy ? -1 : 1);
|
||||
return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/
|
||||
}
|
||||
}
|
||||
|
||||
/* determine ix = ilogb(x) */
|
||||
if(hx<0x00100000) { /* subnormal x */
|
||||
if(hx==0) {
|
||||
for (ix = -1043, i=lx; i>0; i<<=1) ix -=1;
|
||||
} else {
|
||||
for (ix = -1022,i=(hx<<11); i>0; i<<=1) ix -=1;
|
||||
}
|
||||
} else ix = (hx>>20)-1023;
|
||||
|
||||
/* determine iy = ilogb(y) */
|
||||
if(hy<0x00100000) { /* subnormal y */
|
||||
if(hy==0) {
|
||||
for (iy = -1043, i=ly; i>0; i<<=1) iy -=1;
|
||||
} else {
|
||||
for (iy = -1022,i=(hy<<11); i>0; i<<=1) iy -=1;
|
||||
}
|
||||
} else iy = (hy>>20)-1023;
|
||||
|
||||
/* set up {hx,lx}, {hy,ly} and align y to x */
|
||||
if(ix >= -1022)
|
||||
hx = 0x00100000|(0x000fffff&hx);
|
||||
else { /* subnormal x, shift x to normal */
|
||||
n = -1022-ix;
|
||||
if(n<=31) {
|
||||
hx = (hx<<n)|(lx>>(32-n));
|
||||
lx <<= n;
|
||||
} else {
|
||||
hx = lx<<(n-32);
|
||||
lx = 0;
|
||||
}
|
||||
}
|
||||
if(iy >= -1022)
|
||||
hy = 0x00100000|(0x000fffff&hy);
|
||||
else { /* subnormal y, shift y to normal */
|
||||
n = -1022-iy;
|
||||
if(n<=31) {
|
||||
hy = (hy<<n)|(ly>>(32-n));
|
||||
ly <<= n;
|
||||
} else {
|
||||
hy = ly<<(n-32);
|
||||
ly = 0;
|
||||
}
|
||||
}
|
||||
|
||||
/* fix point fmod */
|
||||
n = ix - iy;
|
||||
q = 0;
|
||||
while(n--) {
|
||||
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
|
||||
if(hz<0){hx = hx+hx+(lx>>31); lx = lx+lx;}
|
||||
else {hx = hz+hz+(lz>>31); lx = lz+lz; q++;}
|
||||
q <<= 1;
|
||||
}
|
||||
hz=hx-hy;lz=lx-ly; if(lx<ly) hz -= 1;
|
||||
if(hz>=0) {hx=hz;lx=lz;q++;}
|
||||
|
||||
/* convert back to floating value and restore the sign */
|
||||
if((hx|lx)==0) { /* return sign(x)*0 */
|
||||
q &= 0x7fffffff;
|
||||
*quo = (sxy ? -q : q);
|
||||
return Zero[(u_int32_t)sx>>31];
|
||||
}
|
||||
while(hx<0x00100000) { /* normalize x */
|
||||
hx = hx+hx+(lx>>31); lx = lx+lx;
|
||||
iy -= 1;
|
||||
}
|
||||
if(iy>= -1022) { /* normalize output */
|
||||
hx = ((hx-0x00100000)|((iy+1023)<<20));
|
||||
} else { /* subnormal output */
|
||||
n = -1022 - iy;
|
||||
if(n<=20) {
|
||||
lx = (lx>>n)|((u_int32_t)hx<<(32-n));
|
||||
hx >>= n;
|
||||
} else if (n<=31) {
|
||||
lx = (hx<<(32-n))|(lx>>n); hx = 0;
|
||||
} else {
|
||||
lx = hx>>(n-32); hx = 0;
|
||||
}
|
||||
}
|
||||
fixup:
|
||||
INSERT_WORDS(x,hx,lx);
|
||||
y = fabs(y);
|
||||
if (y < 0x1p-1021) {
|
||||
if (x+x>y || (x+x==y && (q & 1))) {
|
||||
q++;
|
||||
x-=y;
|
||||
}
|
||||
} else if (x>0.5*y || (x==0.5*y && (q & 1))) {
|
||||
q++;
|
||||
x-=y;
|
||||
}
|
||||
GET_HIGH_WORD(hx,x);
|
||||
SET_HIGH_WORD(x,hx^sx);
|
||||
q &= 0x7fffffff;
|
||||
*quo = (sxy ? -q : q);
|
||||
return x;
|
||||
}
|
||||
121
lib/libc/mingw/math/arm-common/s_remquof.c
vendored
121
lib/libc/mingw/math/arm-common/s_remquof.c
vendored
@ -1,121 +0,0 @@
|
||||
/* @(#)e_fmod.c 1.3 95/01/18 */
|
||||
/*-
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunSoft, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
#include <math.h>
|
||||
#include "../bsd_private_base.h"
|
||||
|
||||
static const float Zero[] = {0.0, -0.0,};
|
||||
|
||||
/*
|
||||
* Return the IEEE remainder and set *quo to the last n bits of the
|
||||
* quotient, rounded to the nearest integer. We choose n=31 because
|
||||
* we wind up computing all the integer bits of the quotient anyway as
|
||||
* a side-effect of computing the remainder by the shift and subtract
|
||||
* method. In practice, this is far more bits than are needed to use
|
||||
* remquo in reduction algorithms.
|
||||
*/
|
||||
float
|
||||
remquof(float x, float y, int *quo)
|
||||
{
|
||||
int32_t n,hx,hy,hz,ix,iy,sx,i;
|
||||
u_int32_t q,sxy;
|
||||
|
||||
GET_FLOAT_WORD(hx,x);
|
||||
GET_FLOAT_WORD(hy,y);
|
||||
sxy = (hx ^ hy) & 0x80000000;
|
||||
sx = hx&0x80000000; /* sign of x */
|
||||
hx ^=sx; /* |x| */
|
||||
hy &= 0x7fffffff; /* |y| */
|
||||
|
||||
/* purge off exception values */
|
||||
if(hy==0||hx>=0x7f800000||hy>0x7f800000) /* y=0,NaN;or x not finite */
|
||||
return nan_mix_op(x, y, *)/nan_mix_op(x, y, *);
|
||||
if(hx<hy) {
|
||||
q = 0;
|
||||
goto fixup; /* |x|<|y| return x or x-y */
|
||||
} else if(hx==hy) {
|
||||
*quo = (sxy ? -1 : 1);
|
||||
return Zero[(u_int32_t)sx>>31]; /* |x|=|y| return x*0*/
|
||||
}
|
||||
|
||||
/* determine ix = ilogb(x) */
|
||||
if(hx<0x00800000) { /* subnormal x */
|
||||
for (ix = -126,i=(hx<<8); i>0; i<<=1) ix -=1;
|
||||
} else ix = (hx>>23)-127;
|
||||
|
||||
/* determine iy = ilogb(y) */
|
||||
if(hy<0x00800000) { /* subnormal y */
|
||||
for (iy = -126,i=(hy<<8); i>0; i<<=1) iy -=1;
|
||||
} else iy = (hy>>23)-127;
|
||||
|
||||
/* set up {hx,lx}, {hy,ly} and align y to x */
|
||||
if(ix >= -126)
|
||||
hx = 0x00800000|(0x007fffff&hx);
|
||||
else { /* subnormal x, shift x to normal */
|
||||
n = -126-ix;
|
||||
hx <<= n;
|
||||
}
|
||||
if(iy >= -126)
|
||||
hy = 0x00800000|(0x007fffff&hy);
|
||||
else { /* subnormal y, shift y to normal */
|
||||
n = -126-iy;
|
||||
hy <<= n;
|
||||
}
|
||||
|
||||
/* fix point fmod */
|
||||
n = ix - iy;
|
||||
q = 0;
|
||||
while(n--) {
|
||||
hz=hx-hy;
|
||||
if(hz<0) hx = hx << 1;
|
||||
else {hx = hz << 1; q++;}
|
||||
q <<= 1;
|
||||
}
|
||||
hz=hx-hy;
|
||||
if(hz>=0) {hx=hz;q++;}
|
||||
|
||||
/* convert back to floating value and restore the sign */
|
||||
if(hx==0) { /* return sign(x)*0 */
|
||||
q &= 0x7fffffff;
|
||||
*quo = (sxy ? -q : q);
|
||||
return Zero[(u_int32_t)sx>>31];
|
||||
}
|
||||
while(hx<0x00800000) { /* normalize x */
|
||||
hx <<= 1;
|
||||
iy -= 1;
|
||||
}
|
||||
if(iy>= -126) { /* normalize output */
|
||||
hx = ((hx-0x00800000)|((iy+127)<<23));
|
||||
} else { /* subnormal output */
|
||||
n = -126 - iy;
|
||||
hx >>= n;
|
||||
}
|
||||
fixup:
|
||||
SET_FLOAT_WORD(x,hx);
|
||||
y = fabsf(y);
|
||||
if (y < 0x1p-125f) {
|
||||
if (x+x>y || (x+x==y && (q & 1))) {
|
||||
q++;
|
||||
x-=y;
|
||||
}
|
||||
} else if (x>0.5f*y || (x==0.5f*y && (q & 1))) {
|
||||
q++;
|
||||
x-=y;
|
||||
}
|
||||
GET_FLOAT_WORD(hx,x);
|
||||
SET_FLOAT_WORD(x,hx^sx);
|
||||
q &= 0x7fffffff;
|
||||
*quo = (sxy ? -q : q);
|
||||
return x;
|
||||
}
|
||||
45
lib/libc/mingw/math/arm-common/scalbn.c
vendored
45
lib/libc/mingw/math/arm-common/scalbn.c
vendored
@ -1,45 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double scalbn(double x, int exp)
|
||||
{
|
||||
return x * exp2(exp);
|
||||
}
|
||||
|
||||
float scalbnf(float x, int exp)
|
||||
{
|
||||
return x * exp2f(exp);
|
||||
}
|
||||
|
||||
long double scalbnl(long double x, int exp)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return scalbn(x, exp);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
|
||||
double scalbln(double x, long exp)
|
||||
{
|
||||
return x * exp2(exp);
|
||||
}
|
||||
|
||||
float scalblnf(float x, long exp)
|
||||
{
|
||||
return x * exp2f(exp);
|
||||
}
|
||||
|
||||
long double scalblnl(long double x, long exp)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return scalbln(x, exp);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
19
lib/libc/mingw/math/arm/exp2.S
vendored
19
lib/libc/mingw/math/arm/exp2.S
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(exp2)
|
||||
.globl __MINGW_USYMBOL(exp2l)
|
||||
.def __MINGW_USYMBOL(exp2); .scl 2; .type 32; .endef
|
||||
.def __MINGW_USYMBOL(exp2l); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2):
|
||||
__MINGW_USYMBOL(exp2l):
|
||||
vmov.f64 d1, d0
|
||||
vmov.f64 d0, #2.0
|
||||
b pow
|
||||
16
lib/libc/mingw/math/arm/exp2f.S
vendored
16
lib/libc/mingw/math/arm/exp2f.S
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2f.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(exp2f)
|
||||
.def __MINGW_USYMBOL(exp2f); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2f):
|
||||
vmov s1, s0
|
||||
vmov.f32 s0, #2.0
|
||||
b powf
|
||||
18
lib/libc/mingw/math/arm/nearbyint.S
vendored
18
lib/libc/mingw/math/arm/nearbyint.S
vendored
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyint.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(nearbyint)
|
||||
.def __MINGW_USYMBOL(nearbyint); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyint):
|
||||
push {r4, lr}
|
||||
vmrs r4, fpscr
|
||||
bl rint
|
||||
vmsr fpscr, r4
|
||||
pop {r4, pc}
|
||||
18
lib/libc/mingw/math/arm/nearbyintf.S
vendored
18
lib/libc/mingw/math/arm/nearbyintf.S
vendored
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyintf.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(nearbyintf)
|
||||
.def __MINGW_USYMBOL(nearbyintf); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyintf):
|
||||
push {r4, lr}
|
||||
vmrs r4, fpscr
|
||||
bl rintf
|
||||
vmsr fpscr, r4
|
||||
pop {r4, pc}
|
||||
18
lib/libc/mingw/math/arm/nearbyintl.S
vendored
18
lib/libc/mingw/math/arm/nearbyintl.S
vendored
@ -1,18 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyintl.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(nearbyintl)
|
||||
.def __MINGW_USYMBOL(nearbyintl); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyintl):
|
||||
push {r4, lr}
|
||||
vmrs r4, fpscr
|
||||
bl rintl
|
||||
vmsr fpscr, r4
|
||||
pop {r4, pc}
|
||||
61
lib/libc/mingw/math/arm/s_trunc.c
vendored
61
lib/libc/mingw/math/arm/s_trunc.c
vendored
@ -1,61 +0,0 @@
|
||||
/* @(#)s_floor.c 5.1 93/09/24 */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
* trunc(x)
|
||||
* Return x rounded toward 0 to integral value
|
||||
* Method:
|
||||
* Bit twiddling.
|
||||
* Exception:
|
||||
* Inexact flag raised if x not equal to trunc(x).
|
||||
*/
|
||||
|
||||
#include <float.h>
|
||||
|
||||
#include "../bsd_private_base.h"
|
||||
|
||||
static const double huge = 1.0e300;
|
||||
|
||||
double
|
||||
trunc(double x)
|
||||
{
|
||||
int32_t i0,i1,j0;
|
||||
u_int32_t i;
|
||||
EXTRACT_WORDS(i0,i1,x);
|
||||
j0 = ((i0>>20)&0x7ff)-0x3ff;
|
||||
if(j0<20) {
|
||||
if(j0<0) { /* raise inexact if x != 0 */
|
||||
if(huge+x>0.0) {/* |x|<1, so return 0*sign(x) */
|
||||
i0 &= 0x80000000U;
|
||||
i1 = 0;
|
||||
}
|
||||
} else {
|
||||
i = (0x000fffff)>>j0;
|
||||
if(((i0&i)|i1)==0) return x; /* x is integral */
|
||||
if(huge+x>0.0) { /* raise inexact flag */
|
||||
i0 &= (~i); i1=0;
|
||||
}
|
||||
}
|
||||
} else if (j0>51) {
|
||||
if(j0==0x400) return x+x; /* inf or NaN */
|
||||
else return x; /* x is integral */
|
||||
} else {
|
||||
i = ((u_int32_t)(0xffffffff))>>(j0-20);
|
||||
if((i1&i)==0) return x; /* x is integral */
|
||||
if(huge+x>0.0) /* raise inexact flag */
|
||||
i1 &= (~i);
|
||||
}
|
||||
INSERT_WORDS(x,i0,i1);
|
||||
return x;
|
||||
}
|
||||
51
lib/libc/mingw/math/arm/s_truncf.c
vendored
51
lib/libc/mingw/math/arm/s_truncf.c
vendored
@ -1,51 +0,0 @@
|
||||
/* @(#)s_floor.c 5.1 93/09/24 */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
#include <sys/cdefs.h>
|
||||
|
||||
/*
|
||||
* truncf(x)
|
||||
* Return x rounded toward 0 to integral value
|
||||
* Method:
|
||||
* Bit twiddling.
|
||||
* Exception:
|
||||
* Inexact flag raised if x not equal to truncf(x).
|
||||
*/
|
||||
|
||||
#include "../bsd_private_base.h"
|
||||
|
||||
static const float huge = 1.0e30F;
|
||||
|
||||
float
|
||||
truncf(float x)
|
||||
{
|
||||
int32_t i0,j0;
|
||||
u_int32_t i;
|
||||
GET_FLOAT_WORD(i0,x);
|
||||
j0 = ((i0>>23)&0xff)-0x7f;
|
||||
if(j0<23) {
|
||||
if(j0<0) { /* raise inexact if x != 0 */
|
||||
if(huge+x>0.0F) /* |x|<1, so return 0*sign(x) */
|
||||
i0 &= 0x80000000;
|
||||
} else {
|
||||
i = (0x007fffff)>>j0;
|
||||
if((i0&i)==0) return x; /* x is integral */
|
||||
if(huge+x>0.0F) /* raise inexact flag */
|
||||
i0 &= (~i);
|
||||
}
|
||||
} else {
|
||||
if(j0==0x80) return x+x; /* inf or NaN */
|
||||
else return x; /* x is integral */
|
||||
}
|
||||
SET_FLOAT_WORD(x,i0);
|
||||
return x;
|
||||
}
|
||||
19
lib/libc/mingw/math/arm64/exp2.S
vendored
19
lib/libc/mingw/math/arm64/exp2.S
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(exp2)
|
||||
.globl __MINGW_USYMBOL(exp2l)
|
||||
.def __MINGW_USYMBOL(exp2); .scl 2; .type 32; .endef
|
||||
.def __MINGW_USYMBOL(exp2l); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2):
|
||||
__MINGW_USYMBOL(exp2l):
|
||||
fmov d1, d0
|
||||
fmov d0, #2.0
|
||||
b pow
|
||||
16
lib/libc/mingw/math/arm64/exp2f.S
vendored
16
lib/libc/mingw/math/arm64/exp2f.S
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2f.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(exp2f)
|
||||
.def __MINGW_USYMBOL(exp2f); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2f):
|
||||
fmov s1, s0
|
||||
fmov s0, #2.0
|
||||
b powf
|
||||
17
lib/libc/mingw/math/arm64/nearbyint.S
vendored
17
lib/libc/mingw/math/arm64/nearbyint.S
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyint.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(nearbyint)
|
||||
.def __MINGW_USYMBOL(nearbyint); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyint):
|
||||
mrs x1, fpcr
|
||||
frintx d0, d0
|
||||
msr fpcr, x1
|
||||
ret
|
||||
17
lib/libc/mingw/math/arm64/nearbyintf.S
vendored
17
lib/libc/mingw/math/arm64/nearbyintf.S
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyintf.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(nearbyintf)
|
||||
.def __MINGW_USYMBOL(nearbyintf); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyintf):
|
||||
mrs x1, fpcr
|
||||
frintx s0, s0
|
||||
msr fpcr, x1
|
||||
ret
|
||||
17
lib/libc/mingw/math/arm64/nearbyintl.S
vendored
17
lib/libc/mingw/math/arm64/nearbyintl.S
vendored
@ -1,17 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "nearbyintl.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(nearbyintl)
|
||||
.def __MINGW_USYMBOL(nearbyintl); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(nearbyintl):
|
||||
mrs x1, fpcr
|
||||
frintx d0, d0
|
||||
msr fpcr, x1
|
||||
ret
|
||||
16
lib/libc/mingw/math/arm64/trunc.S
vendored
16
lib/libc/mingw/math/arm64/trunc.S
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "trunc.S"
|
||||
.text
|
||||
.p2align 2
|
||||
.globl __MINGW_USYMBOL(trunc)
|
||||
.def __MINGW_USYMBOL(trunc); .scl 2; .type 32; .endef
|
||||
|
||||
__MINGW_USYMBOL(trunc):
|
||||
frintz d0, d0
|
||||
ret
|
||||
16
lib/libc/mingw/math/arm64/truncf.S
vendored
16
lib/libc/mingw/math/arm64/truncf.S
vendored
@ -1,16 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "truncf.S"
|
||||
.text
|
||||
.p2align 2
|
||||
.globl __MINGW_USYMBOL(truncf)
|
||||
.def __MINGW_USYMBOL(truncf); .scl 2; .type 32; .endef
|
||||
|
||||
__MINGW_USYMBOL(truncf):
|
||||
frintz s0, s0
|
||||
ret
|
||||
104
lib/libc/mingw/math/cbrt.c
vendored
104
lib/libc/mingw/math/cbrt.c
vendored
@ -1,104 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
static const double CBRT2 = 1.2599210498948731647672;
|
||||
static const double CBRT4 = 1.5874010519681994747517;
|
||||
static const double CBRT2I = 0.79370052598409973737585;
|
||||
static const double CBRT4I = 0.62996052494743658238361;
|
||||
|
||||
#ifndef __MINGW32__
|
||||
extern double frexp ( double, int * );
|
||||
extern double ldexp ( double, int );
|
||||
extern int isnan ( double );
|
||||
extern int isfinite ( double );
|
||||
#endif
|
||||
|
||||
double cbrt(double x)
|
||||
{
|
||||
int e, rem, sign;
|
||||
double z;
|
||||
|
||||
#ifdef __MINGW32__
|
||||
if (!isfinite (x) || x == 0)
|
||||
return x;
|
||||
#else
|
||||
#ifdef NANS
|
||||
if (isnan(x))
|
||||
return x;
|
||||
#endif
|
||||
#ifdef INFINITIES
|
||||
if (!isfinite(x))
|
||||
return x;
|
||||
#endif
|
||||
if (x == 0)
|
||||
return (x);
|
||||
#endif /* __MINGW32__ */
|
||||
|
||||
if (x > 0)
|
||||
sign = 1;
|
||||
else
|
||||
{
|
||||
sign = -1;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
z = x;
|
||||
/* extract power of 2, leaving
|
||||
* mantissa between 0.5 and 1
|
||||
*/
|
||||
x = frexp(x, &e);
|
||||
|
||||
/* Approximate cube root of number between .5 and 1,
|
||||
* peak relative error = 9.2e-6
|
||||
*/
|
||||
x = (((-1.3466110473359520655053e-1 * x
|
||||
+ 5.4664601366395524503440e-1) * x
|
||||
- 9.5438224771509446525043e-1) * x
|
||||
+ 1.1399983354717293273738e0 ) * x
|
||||
+ 4.0238979564544752126924e-1;
|
||||
|
||||
/* exponent divided by 3 */
|
||||
if (e >= 0)
|
||||
{
|
||||
rem = e;
|
||||
e /= 3;
|
||||
rem -= 3*e;
|
||||
if (rem == 1)
|
||||
x *= CBRT2;
|
||||
else if (rem == 2)
|
||||
x *= CBRT4;
|
||||
}
|
||||
/* argument less than 1 */
|
||||
else
|
||||
{
|
||||
e = -e;
|
||||
rem = e;
|
||||
e /= 3;
|
||||
rem -= 3*e;
|
||||
if (rem == 1)
|
||||
x *= CBRT2I;
|
||||
else if (rem == 2)
|
||||
x *= CBRT4I;
|
||||
e = -e;
|
||||
}
|
||||
|
||||
/* multiply by power of 2 */
|
||||
x = ldexp(x, e);
|
||||
|
||||
/* Newton iteration */
|
||||
x -= ( x - (z/(x*x)) )*0.33333333333333333333;
|
||||
#ifdef DEC
|
||||
x -= ( x - (z/(x*x)) )/3.0;
|
||||
#else
|
||||
x -= ( x - (z/(x*x)) )*0.33333333333333333333;
|
||||
#endif
|
||||
|
||||
if (sign < 0)
|
||||
x = -x;
|
||||
return (x);
|
||||
}
|
||||
75
lib/libc/mingw/math/cbrtf.c
vendored
75
lib/libc/mingw/math/cbrtf.c
vendored
@ -1,75 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
static const float CBRT2 = 1.25992104989487316477;
|
||||
static const float CBRT4 = 1.58740105196819947475;
|
||||
|
||||
float cbrtf (float x)
|
||||
{
|
||||
int e, rem, sign;
|
||||
float z;
|
||||
if (!isfinite (x) || x == 0.0F)
|
||||
return x;
|
||||
if (x > 0)
|
||||
sign = 1;
|
||||
else
|
||||
{
|
||||
sign = -1;
|
||||
x = -x;
|
||||
}
|
||||
|
||||
z = x;
|
||||
/* extract power of 2, leaving
|
||||
* mantissa between 0.5 and 1
|
||||
*/
|
||||
x = frexpf(x, &e);
|
||||
|
||||
/* Approximate cube root of number between .5 and 1,
|
||||
* peak relative error = 9.2e-6
|
||||
*/
|
||||
x = (((-0.13466110473359520655053 * x
|
||||
+ 0.54664601366395524503440 ) * x
|
||||
- 0.95438224771509446525043 ) * x
|
||||
+ 1.1399983354717293273738 ) * x
|
||||
+ 0.40238979564544752126924;
|
||||
|
||||
/* exponent divided by 3 */
|
||||
if (e >= 0)
|
||||
{
|
||||
rem = e;
|
||||
e /= 3;
|
||||
rem -= 3*e;
|
||||
if (rem == 1)
|
||||
x *= CBRT2;
|
||||
else if (rem == 2)
|
||||
x *= CBRT4;
|
||||
}
|
||||
/* argument less than 1 */
|
||||
else
|
||||
{
|
||||
e = -e;
|
||||
rem = e;
|
||||
e /= 3;
|
||||
rem -= 3*e;
|
||||
if (rem == 1)
|
||||
x /= CBRT2;
|
||||
else if (rem == 2)
|
||||
x /= CBRT4;
|
||||
e = -e;
|
||||
}
|
||||
|
||||
/* multiply by power of 2 */
|
||||
x = ldexpf(x, e);
|
||||
|
||||
/* Newton iteration */
|
||||
x -= ( x - (z/(x*x)) ) * 0.333333333333;
|
||||
|
||||
if (sign < 0)
|
||||
x = -x;
|
||||
return (x);
|
||||
}
|
||||
21
lib/libc/mingw/math/copysign.c
vendored
21
lib/libc/mingw/math/copysign.c
vendored
@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
typedef union U
|
||||
{
|
||||
unsigned int u[2];
|
||||
double d;
|
||||
} U;
|
||||
|
||||
double copysign(double x, double y)
|
||||
{
|
||||
U h,j;
|
||||
h.d = x;
|
||||
j.d = y;
|
||||
h.u[1] = (h.u[1] & 0x7fffffff) | (j.u[1] & 0x80000000);
|
||||
return h.d;
|
||||
}
|
||||
19
lib/libc/mingw/math/copysignf.c
vendored
19
lib/libc/mingw/math/copysignf.c
vendored
@ -1,19 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
typedef union ui_f {
|
||||
float f;
|
||||
unsigned int ui;
|
||||
} ui_f;
|
||||
|
||||
float copysignf(float aX, float aY)
|
||||
{
|
||||
ui_f x,y;
|
||||
x.f=aX; y.f=aY;
|
||||
x.ui= (x.ui & 0x7fffffff) | (y.ui & 0x80000000);
|
||||
return x.f;
|
||||
}
|
||||
20
lib/libc/mingw/math/fabs.c
vendored
20
lib/libc/mingw/math/fabs.c
vendored
@ -1,20 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#define __CRT__NO_INLINE
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fabs (double x)
|
||||
{
|
||||
#if defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return __builtin_fabs (x);
|
||||
#elif defined(__i386__) || defined(_X86_)
|
||||
double res = 0.0;
|
||||
|
||||
asm volatile ("fabs;" : "=t" (res) : "0" (x));
|
||||
return res;
|
||||
#endif /* defined(__x86_64__) || defined(_AMD64_) || defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */
|
||||
}
|
||||
24
lib/libc/mingw/math/fdim.c
vendored
24
lib/libc/mingw/math/fdim.c
vendored
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
double
|
||||
fdim (double x, double y)
|
||||
{
|
||||
int cx = fpclassify (x), cy = fpclassify (y);
|
||||
double r;
|
||||
|
||||
if (cx == FP_NAN || cy == FP_NAN
|
||||
|| (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
|
||||
return x - y; /* Take care invalid flag is raised. */
|
||||
if (x <= y)
|
||||
return 0.0;
|
||||
r = x - y;
|
||||
if (fpclassify (r) == FP_INFINITE)
|
||||
errno = ERANGE;
|
||||
return r;
|
||||
}
|
||||
24
lib/libc/mingw/math/fdimf.c
vendored
24
lib/libc/mingw/math/fdimf.c
vendored
@ -1,24 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fdimf (float x, float y)
|
||||
{
|
||||
int cx = fpclassify (x), cy = fpclassify (y);
|
||||
float r;
|
||||
|
||||
if (cx == FP_NAN || cy == FP_NAN
|
||||
|| (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
|
||||
return x - y; /* Take care invalid flag is raised. */
|
||||
if (x <= y)
|
||||
return 0.0f;
|
||||
r = x - y;
|
||||
if (fpclassify (r) == FP_INFINITE)
|
||||
errno = ERANGE;
|
||||
return r;
|
||||
}
|
||||
97
lib/libc/mingw/math/fma.c
vendored
97
lib/libc/mingw/math/fma.c
vendored
@ -1,97 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
double fma(double x, double y, double z);
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
|
||||
/* Use hardware FMA on ARM. */
|
||||
double fma(double x, double y, double z){
|
||||
__asm__ (
|
||||
"fmacd %0, %1, %2 \n"
|
||||
: "+w"(z)
|
||||
: "w"(x), "w"(y)
|
||||
);
|
||||
return z;
|
||||
}
|
||||
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
|
||||
/* Use hardware FMA on ARM64. */
|
||||
double fma(double x, double y, double z){
|
||||
__asm__ (
|
||||
"fmadd %d0, %d1, %d2, %d0 \n"
|
||||
: "+w"(z)
|
||||
: "w"(x), "w"(y)
|
||||
);
|
||||
return z;
|
||||
}
|
||||
|
||||
#elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* This is in accordance with the IEC 559 double-precision format.
|
||||
* Be advised that due to the hidden bit, the higher half actually has 26 bits.
|
||||
* Multiplying two 27-bit numbers will cause a 1-ULP error, which we cannot
|
||||
* avoid. It is kept in the very last position.
|
||||
*/
|
||||
typedef union iec559_double_ {
|
||||
struct __attribute__((__packed__)) {
|
||||
uint64_t mlo : 27;
|
||||
uint64_t mhi : 25;
|
||||
uint64_t exp : 11;
|
||||
uint64_t sgn : 1;
|
||||
};
|
||||
double f;
|
||||
} iec559_double;
|
||||
|
||||
static inline void break_down(iec559_double *restrict lo, iec559_double *restrict hi, double x) {
|
||||
hi->f = x;
|
||||
/* Erase low-order significant bits. `hi->f` now has only 26 significant bits. */
|
||||
hi->mlo = 0;
|
||||
/* Store the low-order half. It will be normalized by the hardware. */
|
||||
lo->f = x - hi->f;
|
||||
/* Preserve signness in case of zero. */
|
||||
lo->sgn = hi->sgn;
|
||||
}
|
||||
|
||||
double fma(double x, double y, double z) {
|
||||
/*
|
||||
POSIX-2013:
|
||||
1. If x or y are NaN, a NaN shall be returned.
|
||||
2. If x multiplied by y is an exact infinity and z is also an infinity
|
||||
but with the opposite sign, a domain error shall occur, and either a NaN
|
||||
(if supported), or an implementation-defined value shall be returned.
|
||||
3. If one of x and y is infinite, the other is zero, and z is not a NaN,
|
||||
a domain error shall occur, and either a NaN (if supported), or an
|
||||
implementation-defined value shall be returned.
|
||||
4. If one of x and y is infinite, the other is zero, and z is a NaN, a NaN
|
||||
shall be returned and a domain error may occur.
|
||||
5. If x* y is not 0*Inf nor Inf*0 and z is a NaN, a NaN shall be returned.
|
||||
*/
|
||||
/* Check whether the result is finite. */
|
||||
double ret = x * y + z;
|
||||
if(!isfinite(ret)) {
|
||||
return ret; /* If this naive check doesn't yield a finite value, the FMA isn't
|
||||
likely to return one either. Forward the value as is. */
|
||||
}
|
||||
iec559_double xlo, xhi, ylo, yhi;
|
||||
break_down(&xlo, &xhi, x);
|
||||
break_down(&ylo, &yhi, y);
|
||||
/* The order of these four statements is essential. Don't move them around. */
|
||||
ret = z;
|
||||
ret += xhi.f * yhi.f; /* The most significant item comes first. */
|
||||
ret += xhi.f * ylo.f + xlo.f * yhi.f; /* They are equally significant. */
|
||||
ret += xlo.f * ylo.f; /* The least significant item comes last. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error Please add FMA implementation for this platform.
|
||||
|
||||
#endif
|
||||
97
lib/libc/mingw/math/fmaf.c
vendored
97
lib/libc/mingw/math/fmaf.c
vendored
@ -1,97 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
float fmaf(float x, float y, float z);
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
|
||||
/* Use hardware FMA on ARM. */
|
||||
float fmaf(float x, float y, float z){
|
||||
__asm__ (
|
||||
"fmacs %0, %1, %2 \n"
|
||||
: "+t"(z)
|
||||
: "t"(x), "t"(y)
|
||||
);
|
||||
return z;
|
||||
}
|
||||
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
|
||||
/* Use hardware FMA on ARM64. */
|
||||
float fmaf(float x, float y, float z){
|
||||
__asm__ (
|
||||
"fmadd %s0, %s1, %s2, %s0 \n"
|
||||
: "+w"(z)
|
||||
: "w"(x), "w"(y)
|
||||
);
|
||||
return z;
|
||||
}
|
||||
|
||||
#elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
|
||||
/* This is in accordance with the IEC 559 single-precision format.
|
||||
* Be advised that due to the hidden bit, the higher half actually has 11 bits.
|
||||
* Multiplying two 13-bit numbers will cause a 1-ULP error, which we cannot
|
||||
* avoid. It is kept in the very last position.
|
||||
*/
|
||||
typedef union iec559_float_ {
|
||||
struct __attribute__((__packed__)) {
|
||||
uint32_t mlo : 13;
|
||||
uint32_t mhi : 10;
|
||||
uint32_t exp : 8;
|
||||
uint32_t sgn : 1;
|
||||
};
|
||||
float f;
|
||||
} iec559_float;
|
||||
|
||||
static inline void break_down(iec559_float *restrict lo, iec559_float *restrict hi, float x) {
|
||||
hi->f = x;
|
||||
/* Erase low-order significant bits. `hi->f` now has only 11 significant bits. */
|
||||
hi->mlo = 0;
|
||||
/* Store the low-order half. It will be normalized by the hardware. */
|
||||
lo->f = x - hi->f;
|
||||
/* Preserve signness in case of zero. */
|
||||
lo->sgn = hi->sgn;
|
||||
}
|
||||
|
||||
float fmaf(float x, float y, float z) {
|
||||
/*
|
||||
POSIX-2013:
|
||||
1. If x or y are NaN, a NaN shall be returned.
|
||||
2. If x multiplied by y is an exact infinity and z is also an infinity
|
||||
but with the opposite sign, a domain error shall occur, and either a NaN
|
||||
(if supported), or an implementation-defined value shall be returned.
|
||||
3. If one of x and y is infinite, the other is zero, and z is not a NaN,
|
||||
a domain error shall occur, and either a NaN (if supported), or an
|
||||
implementation-defined value shall be returned.
|
||||
4. If one of x and y is infinite, the other is zero, and z is a NaN, a NaN
|
||||
shall be returned and a domain error may occur.
|
||||
5. If x* y is not 0*Inf nor Inf*0 and z is a NaN, a NaN shall be returned.
|
||||
*/
|
||||
/* Check whether the result is finite. */
|
||||
float ret = x * y + z;
|
||||
if(!isfinite(ret)) {
|
||||
return ret; /* If this naive check doesn't yield a finite value, the FMA isn't
|
||||
likely to return one either. Forward the value as is. */
|
||||
}
|
||||
iec559_float xlo, xhi, ylo, yhi;
|
||||
break_down(&xlo, &xhi, x);
|
||||
break_down(&ylo, &yhi, y);
|
||||
/* The order of these four statements is essential. Don't move them around. */
|
||||
ret = z;
|
||||
ret += xhi.f * yhi.f; /* The most significant item comes first. */
|
||||
ret += xhi.f * ylo.f + xlo.f * yhi.f; /* They are equally significant. */
|
||||
ret += xlo.f * ylo.f; /* The least significant item comes last. */
|
||||
return ret;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error Please add FMA implementation for this platform.
|
||||
|
||||
#endif
|
||||
12
lib/libc/mingw/math/fmax.c
vendored
12
lib/libc/mingw/math/fmax.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fmax (double _x, double _y)
|
||||
{
|
||||
return ( isgreaterequal (_x, _y)|| __isnan (_y) ? _x : _y );
|
||||
}
|
||||
12
lib/libc/mingw/math/fmaxf.c
vendored
12
lib/libc/mingw/math/fmaxf.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fmaxf (float _x, float _y)
|
||||
{
|
||||
return (( isgreaterequal(_x, _y) || __isnanf (_y)) ? _x : _y );
|
||||
}
|
||||
12
lib/libc/mingw/math/fmin.c
vendored
12
lib/libc/mingw/math/fmin.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
fmin (double _x, double _y)
|
||||
{
|
||||
return ((islessequal(_x, _y) || __isnan (_y)) ? _x : _y );
|
||||
}
|
||||
12
lib/libc/mingw/math/fminf.c
vendored
12
lib/libc/mingw/math/fminf.c
vendored
@ -1,12 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
fminf (float _x, float _y)
|
||||
{
|
||||
return ((islessequal(_x, _y) || __isnanf (_y)) ? _x : _y );
|
||||
}
|
||||
64
lib/libc/mingw/math/frexp.c
vendored
64
lib/libc/mingw/math/frexp.c
vendored
@ -1,64 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
double frexp(double value, int* exp);
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) || \
|
||||
defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
/* It is assumed that `double` conforms to IEEE 754 and is little-endian.
|
||||
* This is true on x86 and ARM. */
|
||||
|
||||
typedef union ieee754_double_ {
|
||||
struct __attribute__((__packed__)) {
|
||||
uint64_t f52 : 52;
|
||||
uint64_t exp : 11;
|
||||
uint64_t sgn : 1;
|
||||
};
|
||||
double f;
|
||||
} ieee754_double;
|
||||
|
||||
double frexp(double value, int* exp)
|
||||
{
|
||||
int n;
|
||||
ieee754_double reg;
|
||||
reg.f = value;
|
||||
if(reg.exp == 0x7FF) {
|
||||
/* The value is an infinity or NaN.
|
||||
* Store zero in `*exp`. Return the value as is. */
|
||||
*exp = 0;
|
||||
return reg.f;
|
||||
}
|
||||
if(reg.exp != 0) {
|
||||
/* The value is normalized.
|
||||
* Extract and zero out the exponent. */
|
||||
*exp = reg.exp - 0x3FE;
|
||||
reg.exp = 0x3FE;
|
||||
return reg.f;
|
||||
}
|
||||
if(reg.f52 == 0) {
|
||||
/* The value is zero.
|
||||
* Store zero in `*exp`. Return the value as is.
|
||||
* Note the signness. */
|
||||
*exp = 0;
|
||||
return reg.f;
|
||||
}
|
||||
/* The value is denormalized.
|
||||
* Extract the exponent, normalize the value, then zero out
|
||||
* the exponent. Note that the hidden bit is removed. */
|
||||
n = __builtin_clzll(reg.f52) - 11;
|
||||
reg.f52 <<= n;
|
||||
*exp = 1 - 0x3FE - n;
|
||||
reg.exp = 0x3FE;
|
||||
return reg.f;
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#error Please add `frexp()` implementation for this platform.
|
||||
|
||||
#endif
|
||||
23
lib/libc/mingw/math/hypot.c
vendored
23
lib/libc/mingw/math/hypot.c
vendored
@ -1,23 +0,0 @@
|
||||
/**
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
|
||||
#include "../complex/complex_internal.h"
|
||||
#include <errno.h>
|
||||
#include <math.h>
|
||||
|
||||
double hypot (double x, double y)
|
||||
{
|
||||
int x_class = fpclassify (x);
|
||||
int y_class = fpclassify (y);
|
||||
|
||||
if (x_class == FP_INFINITE || y_class == FP_INFINITE)
|
||||
return __FLT_HUGE_VAL;
|
||||
else if (x_class == FP_NAN || y_class == FP_NAN)
|
||||
return __FLT_NAN;
|
||||
|
||||
return _hypot (x, y);
|
||||
}
|
||||
|
||||
42
lib/libc/mingw/math/llrint.c
vendored
42
lib/libc/mingw/math/llrint.c
vendored
@ -1,42 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <fenv.h>
|
||||
|
||||
long long llrint (double x)
|
||||
{
|
||||
long long retval = 0ll;
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#else
|
||||
int mode = fegetround();
|
||||
if (mode == FE_DOWNWARD)
|
||||
retval = (long long)floor(x);
|
||||
else if (mode == FE_UPWARD)
|
||||
retval = (long long)ceil(x);
|
||||
else if (mode == FE_TOWARDZERO)
|
||||
retval = x >= 0 ? (long long)floor(x) : (long long)ceil(x);
|
||||
else {
|
||||
// Break `x` into integral and fractional parts.
|
||||
double intg, frac;
|
||||
frac = modf(x, &intg);
|
||||
frac = fabs(frac);
|
||||
// Convert the truncated integral part to an integer.
|
||||
retval = intg;
|
||||
if (frac < 0.5) {
|
||||
// Round towards zero.
|
||||
} else if (frac > 0.5) {
|
||||
// Round towards infinities.
|
||||
retval += signbit(x) ? -1 : 1;
|
||||
} else {
|
||||
// Round to the nearest even number.
|
||||
retval += retval % 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
41
lib/libc/mingw/math/llrintf.c
vendored
41
lib/libc/mingw/math/llrintf.c
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <fenv.h>
|
||||
|
||||
long long llrintf (float x)
|
||||
{
|
||||
long long retval = 0ll;
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#else
|
||||
int mode = fegetround();
|
||||
if (mode == FE_DOWNWARD)
|
||||
retval = (long long)floorf(x);
|
||||
else if (mode == FE_UPWARD)
|
||||
retval = (long long)ceilf(x);
|
||||
else if (mode == FE_TOWARDZERO)
|
||||
retval = x >= 0 ? (long long)floorf(x) : (long long)ceilf(x);
|
||||
else {
|
||||
// Break `x` into integral and fractional parts.
|
||||
float intg, frac;
|
||||
frac = modff(x, &intg);
|
||||
frac = fabsf(frac);
|
||||
// Convert the truncated integral part to an integer.
|
||||
retval = intg;
|
||||
if (frac < 0.5) {
|
||||
// Round towards zero.
|
||||
} else if (frac > 0.5) {
|
||||
// Round towards infinities.
|
||||
retval += signbit(x) ? -1 : 1;
|
||||
} else {
|
||||
// Round to the nearest even number.
|
||||
retval += retval % 2;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
38
lib/libc/mingw/math/llround.c
vendored
38
lib/libc/mingw/math/llround.c
vendored
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
long long
|
||||
llround (double x)
|
||||
{
|
||||
double res;
|
||||
|
||||
if (x >= 0.0)
|
||||
{
|
||||
res = ceil (x);
|
||||
if (res - x > 0.5)
|
||||
res -= 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceil (-x);
|
||||
if (res + x > 0.5)
|
||||
res -= 1.0;
|
||||
res = -res;
|
||||
}
|
||||
if (!isfinite (res)
|
||||
|| res > (double) LONG_LONG_MAX
|
||||
|| res < (double) LONG_LONG_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
/* Undefined behaviour, so we could return anything. */
|
||||
/* return res > 0.0 ? LONG_LONG_MAX : LONG_LONG_MIN; */
|
||||
}
|
||||
return (long long) res;
|
||||
}
|
||||
|
||||
38
lib/libc/mingw/math/llroundf.c
vendored
38
lib/libc/mingw/math/llroundf.c
vendored
@ -1,38 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
long long
|
||||
llroundf (float x)
|
||||
{
|
||||
float res;
|
||||
|
||||
if (x >= 0.0F)
|
||||
{
|
||||
res = ceilf (x);
|
||||
if (res - x > 0.5F)
|
||||
res -= 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceilf (-x);
|
||||
if (res + x > 0.5F)
|
||||
res -= 1.0F;
|
||||
res = -res;
|
||||
}
|
||||
if (!isfinite (res)
|
||||
|| res > (float) LONG_LONG_MAX
|
||||
|| res < (float) LONG_LONG_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
/* Undefined behaviour, so we could return anything. */
|
||||
/* return res > 0.0F ? LONG_LONG_MAX : LONG_LONG_MIN; */
|
||||
}
|
||||
return (long long) res;
|
||||
}
|
||||
|
||||
32
lib/libc/mingw/math/lrint.c
vendored
32
lib/libc/mingw/math/lrint.c
vendored
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
long lrint (double x)
|
||||
{
|
||||
long retval = 0L;
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
retval = _mm_cvtsd_si32(_mm_load_sd(&x));
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#elif defined(__arm__) || defined(_ARM_)
|
||||
float temp;
|
||||
__asm__ __volatile__ (
|
||||
"vcvtr.s32.f64 %[tmp], %[src]\n\t"
|
||||
"fmrs %[dst], %[tmp]\n\t"
|
||||
: [dst] "=r" (retval), [tmp] "=t" (temp) : [src] "w" (x));
|
||||
#elif defined(__aarch64__) || defined(_ARM64_)
|
||||
__asm__ __volatile__ (
|
||||
"frintx %d1, %d1\n\t"
|
||||
"fcvtzs %w0, %d1\n\t"
|
||||
: "=r" (retval), "+w" (x));
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
31
lib/libc/mingw/math/lrintf.c
vendored
31
lib/libc/mingw/math/lrintf.c
vendored
@ -1,31 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
#include <xmmintrin.h>
|
||||
#endif
|
||||
|
||||
long lrintf (float x)
|
||||
{
|
||||
long retval = 0l;
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
retval = _mm_cvtss_si32(_mm_load_ss(&x));
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#elif defined(__arm__) || defined(_ARM_)
|
||||
__asm__ __volatile__ (
|
||||
"vcvtr.s32.f32 %[src], %[src]\n\t"
|
||||
"fmrs %[dst], %[src]\n\t"
|
||||
: [dst] "=r" (retval), [src] "+w" (x));
|
||||
#elif defined(__aarch64__) || defined(_ARM64_)
|
||||
__asm__ __volatile__ (
|
||||
"frintx %s1, %s1\n\t"
|
||||
"fcvtzs %w0, %s1\n\t"
|
||||
: "=r" (retval), "+w" (x));
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
37
lib/libc/mingw/math/lround.c
vendored
37
lib/libc/mingw/math/lround.c
vendored
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
long
|
||||
lround (double x)
|
||||
{
|
||||
double res;
|
||||
|
||||
if (x >= 0.0)
|
||||
{
|
||||
res = ceil (x);
|
||||
if (res - x > 0.5)
|
||||
res -= 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceil (-x);
|
||||
if (res + x > 0.5)
|
||||
res -= 1.0;
|
||||
res = -res;
|
||||
}
|
||||
if (!isfinite (res)
|
||||
|| res > (double) LONG_MAX
|
||||
|| res < (double) LONG_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
/* Undefined behaviour, so we could return anything. */
|
||||
/* return res > 0.0 ? LONG_MAX : LONG_MIN; */
|
||||
}
|
||||
return (long) res;
|
||||
}
|
||||
37
lib/libc/mingw/math/lroundf.c
vendored
37
lib/libc/mingw/math/lroundf.c
vendored
@ -1,37 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <limits.h>
|
||||
#include <errno.h>
|
||||
|
||||
long
|
||||
lroundf (float x)
|
||||
{
|
||||
float res;
|
||||
|
||||
if (x >= 0.0F)
|
||||
{
|
||||
res = ceilf (x);
|
||||
if (res - x > 0.5F)
|
||||
res -= 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceilf (-x);
|
||||
if (res + x > 0.5F)
|
||||
res -= 1.0F;
|
||||
res = -res;
|
||||
}
|
||||
if (!isfinite (res)
|
||||
|| res > (float) LONG_MAX
|
||||
|| res < (float) LONG_MIN)
|
||||
{
|
||||
errno = ERANGE;
|
||||
/* Undefined behaviour, so we could return anything. */
|
||||
/* return res > 0.0F ? LONG_MAX : LONG_MIN; */
|
||||
}
|
||||
return (long) res;
|
||||
}
|
||||
41
lib/libc/mingw/math/modf.c
vendored
41
lib/libc/mingw/math/modf.c
vendored
@ -1,41 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <fenv.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
|
||||
double
|
||||
modf (double value, double* iptr)
|
||||
{
|
||||
double int_part = 0.0;
|
||||
/* truncate */
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
asm volatile ("subq $8, %%rsp\n"
|
||||
"fnstcw 4(%%rsp)\n"
|
||||
"movzwl 4(%%rsp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
"movw %%ax, (%%rsp)\n"
|
||||
"fldcw (%%rsp)\n"
|
||||
"frndint\n"
|
||||
"fldcw 4(%%rsp)\n"
|
||||
"addq $8, %%rsp\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
asm volatile ("push %%eax\n\tsubl $8, %%esp\n"
|
||||
"fnstcw 4(%%esp)\n"
|
||||
"movzwl 4(%%esp), %%eax\n"
|
||||
"orb $12, %%ah\n"
|
||||
"movw %%ax, (%%esp)\n"
|
||||
"fldcw (%%esp)\n"
|
||||
"frndint\n"
|
||||
"fldcw 4(%%esp)\n"
|
||||
"addl $8, %%esp\n\tpop %%eax\n" : "=t" (int_part) : "0" (value) : "eax"); /* round */
|
||||
#else
|
||||
int_part = trunc(value);
|
||||
#endif
|
||||
if (iptr)
|
||||
*iptr = int_part;
|
||||
return (isinf (value) ? 0.0 : value - int_part);
|
||||
}
|
||||
32
lib/libc/mingw/math/nextafterf.c
vendored
32
lib/libc/mingw/math/nextafterf.c
vendored
@ -1,32 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
nextafterf (float x, float y)
|
||||
{
|
||||
union
|
||||
{
|
||||
float f;
|
||||
unsigned int i;
|
||||
} u;
|
||||
if (isnan (y) || isnan (x))
|
||||
return x + y;
|
||||
if (x == y )
|
||||
/* nextafter (0.0, -O.0) should return -0.0. */
|
||||
return y;
|
||||
u.f = x;
|
||||
if (x == 0.0F)
|
||||
{
|
||||
u.i = 1;
|
||||
return y > 0.0F ? u.f : -u.f;
|
||||
}
|
||||
if (((x > 0.0F) ^ (y > x)) == 0)
|
||||
u.i++;
|
||||
else
|
||||
u.i--;
|
||||
return u.f;
|
||||
}
|
||||
26
lib/libc/mingw/math/round.c
vendored
26
lib/libc/mingw/math/round.c
vendored
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
round (double x)
|
||||
{
|
||||
double res;
|
||||
if (x >= 0.0)
|
||||
{
|
||||
res = ceil (x);
|
||||
if (res - x > 0.5)
|
||||
res -= 1.0;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceil (-x);
|
||||
if (res + x > 0.5)
|
||||
res -= 1.0;
|
||||
res = -res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
26
lib/libc/mingw/math/roundf.c
vendored
26
lib/libc/mingw/math/roundf.c
vendored
@ -1,26 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
|
||||
float
|
||||
roundf (float x)
|
||||
{
|
||||
float res;
|
||||
if (x >= 0.0F)
|
||||
{
|
||||
res = ceilf (x);
|
||||
if (res - x > 0.5F)
|
||||
res -= 1.0F;
|
||||
}
|
||||
else
|
||||
{
|
||||
res = ceilf (-x);
|
||||
if (res + x > 0.5F)
|
||||
res -= 1.0F;
|
||||
res = -res;
|
||||
}
|
||||
return res;
|
||||
}
|
||||
347
lib/libc/mingw/math/s_erf.c
vendored
347
lib/libc/mingw/math/s_erf.c
vendored
@ -1,347 +0,0 @@
|
||||
/* @(#)s_erf.c 1.3 95/01/18 */
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunSoft, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/* double erf(double x)
|
||||
* double erfc(double x)
|
||||
* x
|
||||
* 2 |\
|
||||
* erf(x) = --------- | exp(-t*t)dt
|
||||
* sqrt(pi) \|
|
||||
* 0
|
||||
*
|
||||
* erfc(x) = 1-erf(x)
|
||||
* Note that
|
||||
* erf(-x) = -erf(x)
|
||||
* erfc(-x) = 2 - erfc(x)
|
||||
*
|
||||
* Method:
|
||||
* 1. For |x| in [0, 0.84375]
|
||||
* erf(x) = x + x*R(x^2)
|
||||
* erfc(x) = 1 - erf(x) if x in [-.84375,0.25]
|
||||
* = 0.5 + ((0.5-x)-x*R) if x in [0.25,0.84375]
|
||||
* where R = P/Q where P is an odd poly of degree 8 and
|
||||
* Q is an odd poly of degree 10.
|
||||
* -57.90
|
||||
* | R - (erf(x)-x)/x | <= 2
|
||||
*
|
||||
* Remark. The formula is derived by noting
|
||||
* erf(x) = (2/sqrt(pi))*(x - x^3/3 + x^5/10 - x^7/42 + ....)
|
||||
* and that
|
||||
* 2/sqrt(pi) = 1.128379167095512573896158903121545171688
|
||||
* is close to one. The interval is chosen because the fix
|
||||
* point of erf(x) is near 0.6174 (i.e., erf(x)=x when x is
|
||||
* near 0.6174), and by some experiment, 0.84375 is chosen to
|
||||
* guarantee the error is less than one ulp for erf.
|
||||
*
|
||||
* 2. For |x| in [0.84375,1.25], let s = |x| - 1, and
|
||||
* c = 0.84506291151 rounded to single (24 bits)
|
||||
* erf(x) = sign(x) * (c + P1(s)/Q1(s))
|
||||
* erfc(x) = (1-c) - P1(s)/Q1(s) if x > 0
|
||||
* 1+(c+P1(s)/Q1(s)) if x < 0
|
||||
* |P1/Q1 - (erf(|x|)-c)| <= 2**-59.06
|
||||
* Remark: here we use the taylor series expansion at x=1.
|
||||
* erf(1+s) = erf(1) + s*Poly(s)
|
||||
* = 0.845.. + P1(s)/Q1(s)
|
||||
* That is, we use rational approximation to approximate
|
||||
* erf(1+s) - (c = (single)0.84506291151)
|
||||
* Note that |P1/Q1|< 0.078 for x in [0.84375,1.25]
|
||||
* where
|
||||
* P1(s) = degree 6 poly in s
|
||||
* Q1(s) = degree 6 poly in s
|
||||
*
|
||||
* 3. For x in [1.25,1/0.35(~2.857143)],
|
||||
* erfc(x) = (1/x)*exp(-x*x-0.5625+R1/S1)
|
||||
* erf(x) = 1 - erfc(x)
|
||||
* where
|
||||
* R1(z) = degree 7 poly in z, (z=1/x^2)
|
||||
* S1(z) = degree 8 poly in z
|
||||
*
|
||||
* 4. For x in [1/0.35,28]
|
||||
* erfc(x) = (1/x)*exp(-x*x-0.5625+R2/S2) if x > 0
|
||||
* = 2.0 - (1/x)*exp(-x*x-0.5625+R2/S2) if -6<x<0
|
||||
* = 2.0 - tiny (if x <= -6)
|
||||
* erf(x) = sign(x)*(1.0 - erfc(x)) if x < 6, else
|
||||
* erf(x) = sign(x)*(1.0 - tiny)
|
||||
* where
|
||||
* R2(z) = degree 6 poly in z, (z=1/x^2)
|
||||
* S2(z) = degree 7 poly in z
|
||||
*
|
||||
* Note1:
|
||||
* To compute exp(-x*x-0.5625+R/S), let s be a single
|
||||
* precision number and s := x; then
|
||||
* -x*x = -s*s + (s-x)*(s+x)
|
||||
* exp(-x*x-0.5626+R/S) =
|
||||
* exp(-s*s-0.5625)*exp((s-x)*(s+x)+R/S);
|
||||
* Note2:
|
||||
* Here 4 and 5 make use of the asymptotic series
|
||||
* exp(-x*x)
|
||||
* erfc(x) ~ ---------- * ( 1 + Poly(1/x^2) )
|
||||
* x*sqrt(pi)
|
||||
* We use rational approximation to approximate
|
||||
* g(s)=f(1/x^2) = log(erfc(x)*x) - x*x + 0.5625
|
||||
* Here is the error bound for R1/S1 and R2/S2
|
||||
* |R1/S1 - f(x)| < 2**(-62.57)
|
||||
* |R2/S2 - f(x)| < 2**(-61.52)
|
||||
*
|
||||
* 5. For inf > x >= 28
|
||||
* erf(x) = sign(x) *(1 - tiny) (raise inexact)
|
||||
* erfc(x) = tiny*tiny (raise underflow) if x > 0
|
||||
* = 2 - tiny if x<0
|
||||
*
|
||||
* 7. Special case:
|
||||
* erf(0) = 0, erf(inf) = 1, erf(-inf) = -1,
|
||||
* erfc(0) = 1, erfc(inf) = 0, erfc(-inf) = 2,
|
||||
* erfc/erf(NaN) is NaN
|
||||
*/
|
||||
|
||||
|
||||
/* #include "fdlibm.h" */
|
||||
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define __ieee754_exp exp
|
||||
|
||||
typedef union
|
||||
{
|
||||
double value;
|
||||
struct
|
||||
{
|
||||
uint32_t lsw;
|
||||
uint32_t msw;
|
||||
} parts;
|
||||
} ieee_double_shape_type;
|
||||
|
||||
|
||||
static inline int __get_hi_word(const double x)
|
||||
{
|
||||
ieee_double_shape_type u;
|
||||
u.value = x;
|
||||
return u.parts.msw;
|
||||
}
|
||||
|
||||
static inline void __trunc_lo_word(double *x)
|
||||
{
|
||||
ieee_double_shape_type u;
|
||||
u.value = *x;
|
||||
u.parts.lsw = 0;
|
||||
*x = u.value;
|
||||
}
|
||||
|
||||
|
||||
static const double
|
||||
tiny= 1e-300,
|
||||
half= 5.00000000000000000000e-01, /* 0x3FE00000, 0x00000000 */
|
||||
one = 1.00000000000000000000e+00, /* 0x3FF00000, 0x00000000 */
|
||||
two = 2.00000000000000000000e+00, /* 0x40000000, 0x00000000 */
|
||||
/* c = (float)0.84506291151 */
|
||||
erx = 8.45062911510467529297e-01, /* 0x3FEB0AC1, 0x60000000 */
|
||||
/*
|
||||
* Coefficients for approximation to erf on [0,0.84375]
|
||||
*/
|
||||
efx = 1.28379167095512586316e-01, /* 0x3FC06EBA, 0x8214DB69 */
|
||||
efx8= 1.02703333676410069053e+00, /* 0x3FF06EBA, 0x8214DB69 */
|
||||
pp0 = 1.28379167095512558561e-01, /* 0x3FC06EBA, 0x8214DB68 */
|
||||
pp1 = -3.25042107247001499370e-01, /* 0xBFD4CD7D, 0x691CB913 */
|
||||
pp2 = -2.84817495755985104766e-02, /* 0xBF9D2A51, 0xDBD7194F */
|
||||
pp3 = -5.77027029648944159157e-03, /* 0xBF77A291, 0x236668E4 */
|
||||
pp4 = -2.37630166566501626084e-05, /* 0xBEF8EAD6, 0x120016AC */
|
||||
qq1 = 3.97917223959155352819e-01, /* 0x3FD97779, 0xCDDADC09 */
|
||||
qq2 = 6.50222499887672944485e-02, /* 0x3FB0A54C, 0x5536CEBA */
|
||||
qq3 = 5.08130628187576562776e-03, /* 0x3F74D022, 0xC4D36B0F */
|
||||
qq4 = 1.32494738004321644526e-04, /* 0x3F215DC9, 0x221C1A10 */
|
||||
qq5 = -3.96022827877536812320e-06, /* 0xBED09C43, 0x42A26120 */
|
||||
/*
|
||||
* Coefficients for approximation to erf in [0.84375,1.25]
|
||||
*/
|
||||
pa0 = -2.36211856075265944077e-03, /* 0xBF6359B8, 0xBEF77538 */
|
||||
pa1 = 4.14856118683748331666e-01, /* 0x3FDA8D00, 0xAD92B34D */
|
||||
pa2 = -3.72207876035701323847e-01, /* 0xBFD7D240, 0xFBB8C3F1 */
|
||||
pa3 = 3.18346619901161753674e-01, /* 0x3FD45FCA, 0x805120E4 */
|
||||
pa4 = -1.10894694282396677476e-01, /* 0xBFBC6398, 0x3D3E28EC */
|
||||
pa5 = 3.54783043256182359371e-02, /* 0x3FA22A36, 0x599795EB */
|
||||
pa6 = -2.16637559486879084300e-03, /* 0xBF61BF38, 0x0A96073F */
|
||||
qa1 = 1.06420880400844228286e-01, /* 0x3FBB3E66, 0x18EEE323 */
|
||||
qa2 = 5.40397917702171048937e-01, /* 0x3FE14AF0, 0x92EB6F33 */
|
||||
qa3 = 7.18286544141962662868e-02, /* 0x3FB2635C, 0xD99FE9A7 */
|
||||
qa4 = 1.26171219808761642112e-01, /* 0x3FC02660, 0xE763351F */
|
||||
qa5 = 1.36370839120290507362e-02, /* 0x3F8BEDC2, 0x6B51DD1C */
|
||||
qa6 = 1.19844998467991074170e-02, /* 0x3F888B54, 0x5735151D */
|
||||
/*
|
||||
* Coefficients for approximation to erfc in [1.25,1/0.35]
|
||||
*/
|
||||
ra0 = -9.86494403484714822705e-03, /* 0xBF843412, 0x600D6435 */
|
||||
ra1 = -6.93858572707181764372e-01, /* 0xBFE63416, 0xE4BA7360 */
|
||||
ra2 = -1.05586262253232909814e+01, /* 0xC0251E04, 0x41B0E726 */
|
||||
ra3 = -6.23753324503260060396e+01, /* 0xC04F300A, 0xE4CBA38D */
|
||||
ra4 = -1.62396669462573470355e+02, /* 0xC0644CB1, 0x84282266 */
|
||||
ra5 = -1.84605092906711035994e+02, /* 0xC067135C, 0xEBCCABB2 */
|
||||
ra6 = -8.12874355063065934246e+01, /* 0xC0545265, 0x57E4D2F2 */
|
||||
ra7 = -9.81432934416914548592e+00, /* 0xC023A0EF, 0xC69AC25C */
|
||||
sa1 = 1.96512716674392571292e+01, /* 0x4033A6B9, 0xBD707687 */
|
||||
sa2 = 1.37657754143519042600e+02, /* 0x4061350C, 0x526AE721 */
|
||||
sa3 = 4.34565877475229228821e+02, /* 0x407B290D, 0xD58A1A71 */
|
||||
sa4 = 6.45387271733267880336e+02, /* 0x40842B19, 0x21EC2868 */
|
||||
sa5 = 4.29008140027567833386e+02, /* 0x407AD021, 0x57700314 */
|
||||
sa6 = 1.08635005541779435134e+02, /* 0x405B28A3, 0xEE48AE2C */
|
||||
sa7 = 6.57024977031928170135e+00, /* 0x401A47EF, 0x8E484A93 */
|
||||
sa8 = -6.04244152148580987438e-02, /* 0xBFAEEFF2, 0xEE749A62 */
|
||||
/*
|
||||
* Coefficients for approximation to erfc in [1/.35,28]
|
||||
*/
|
||||
rb0 = -9.86494292470009928597e-03, /* 0xBF843412, 0x39E86F4A */
|
||||
rb1 = -7.99283237680523006574e-01, /* 0xBFE993BA, 0x70C285DE */
|
||||
rb2 = -1.77579549177547519889e+01, /* 0xC031C209, 0x555F995A */
|
||||
rb3 = -1.60636384855821916062e+02, /* 0xC064145D, 0x43C5ED98 */
|
||||
rb4 = -6.37566443368389627722e+02, /* 0xC083EC88, 0x1375F228 */
|
||||
rb5 = -1.02509513161107724954e+03, /* 0xC0900461, 0x6A2E5992 */
|
||||
rb6 = -4.83519191608651397019e+02, /* 0xC07E384E, 0x9BDC383F */
|
||||
sb1 = 3.03380607434824582924e+01, /* 0x403E568B, 0x261D5190 */
|
||||
sb2 = 3.25792512996573918826e+02, /* 0x40745CAE, 0x221B9F0A */
|
||||
sb3 = 1.53672958608443695994e+03, /* 0x409802EB, 0x189D5118 */
|
||||
sb4 = 3.19985821950859553908e+03, /* 0x40A8FFB7, 0x688C246A */
|
||||
sb5 = 2.55305040643316442583e+03, /* 0x40A3F219, 0xCEDF3BE6 */
|
||||
sb6 = 4.74528541206955367215e+02, /* 0x407DA874, 0xE79FE763 */
|
||||
sb7 = -2.24409524465858183362e+01; /* 0xC03670E2, 0x42712D62 */
|
||||
|
||||
|
||||
double erf(double x)
|
||||
{
|
||||
int hx, ix, i;
|
||||
double R, S, P, Q, s, y, z, r;
|
||||
hx = __get_hi_word(x);
|
||||
ix = hx & 0x7fffffff;
|
||||
if (ix >= 0x7ff00000) { /* erf(nan)=nan */
|
||||
i = ((unsigned)hx>>31)<<1;
|
||||
return (double)(1-i)+one/x; /* erf(+-inf)=+-1 */
|
||||
}
|
||||
|
||||
if (ix < 0x3feb0000) { /* |x|<0.84375 */
|
||||
if (ix < 0x3e300000) { /* |x|<2**-28 */
|
||||
if (ix < 0x00800000)
|
||||
return 0.125*(8.0*x+efx8*x); /*avoid underflow */
|
||||
return x + efx*x;
|
||||
}
|
||||
z = x*x;
|
||||
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
|
||||
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
|
||||
y = r/s;
|
||||
return x + x*y;
|
||||
}
|
||||
if (ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */
|
||||
s = fabs(x)-one;
|
||||
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
|
||||
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
|
||||
if (hx >= 0)
|
||||
return erx + P/Q;
|
||||
else
|
||||
return -erx - P/Q;
|
||||
}
|
||||
if (ix >= 0x40180000) { /* inf>|x|>=6 */
|
||||
if (hx >= 0)
|
||||
return one-tiny;
|
||||
else
|
||||
return tiny-one;
|
||||
}
|
||||
x = fabs(x);
|
||||
s = one/(x*x);
|
||||
if (ix < 0x4006DB6E) { /* |x| < 1/0.35 */
|
||||
R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
|
||||
ra5+s*(ra6+s*ra7))))));
|
||||
S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
|
||||
sa5+s*(sa6+s*(sa7+s*sa8)))))));
|
||||
} else { /* |x| >= 1/0.35 */
|
||||
R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
|
||||
rb5+s*rb6)))));
|
||||
S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
|
||||
sb5+s*(sb6+s*sb7))))));
|
||||
}
|
||||
z = x;
|
||||
__trunc_lo_word(&z);
|
||||
r = __ieee754_exp(-z*z-0.5625)*__ieee754_exp((z-x)*(z+x)+R/S);
|
||||
if (hx >= 0)
|
||||
return one-r/x;
|
||||
else
|
||||
return r/x-one;
|
||||
}
|
||||
|
||||
double erfc(double x)
|
||||
{
|
||||
int hx,ix;
|
||||
double R,S,P,Q,s,y,z,r;
|
||||
hx = __get_hi_word(x);
|
||||
ix = hx&0x7fffffff;
|
||||
if (ix >= 0x7ff00000) { /* erfc(nan)=nan */
|
||||
/* erfc(+-inf)=0,2 */
|
||||
return (double)(((unsigned)hx>>31)<<1)+one/x;
|
||||
}
|
||||
|
||||
if (ix < 0x3feb0000) { /* |x|<0.84375 */
|
||||
if (ix < 0x3c700000) /* |x|<2**-56 */
|
||||
return one-x;
|
||||
z = x*x;
|
||||
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
|
||||
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
|
||||
y = r/s;
|
||||
if (hx < 0x3fd00000) { /* x<1/4 */
|
||||
return one-(x+x*y);
|
||||
} else {
|
||||
r = x*y;
|
||||
r += (x-half);
|
||||
return half - r ;
|
||||
}
|
||||
}
|
||||
if (ix < 0x3ff40000) { /* 0.84375 <= |x| < 1.25 */
|
||||
s = fabs(x)-one;
|
||||
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
|
||||
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
|
||||
if (hx >= 0) {
|
||||
z = one-erx; return z - P/Q;
|
||||
} else {
|
||||
z = erx+P/Q; return one+z;
|
||||
}
|
||||
}
|
||||
if (ix < 0x403c0000) { /* |x|<28 */
|
||||
x = fabs(x);
|
||||
s = one/(x*x);
|
||||
if (ix < 0x4006DB6D) { /* |x| < 1/.35 ~ 2.857143*/
|
||||
R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
|
||||
ra5+s*(ra6+s*ra7))))));
|
||||
S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
|
||||
sa5+s*(sa6+s*(sa7+s*sa8)))))));
|
||||
} else { /* |x| >= 1/.35 ~ 2.857143 */
|
||||
if (hx < 0 && ix >= 0x40180000)
|
||||
return two-tiny; /* x < -6 */
|
||||
R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
|
||||
rb5+s*rb6)))));
|
||||
S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
|
||||
sb5+s*(sb6+s*sb7))))));
|
||||
}
|
||||
z = x;
|
||||
__trunc_lo_word(&z);
|
||||
r = __ieee754_exp(-z*z-0.5625)*
|
||||
__ieee754_exp((z-x)*(z+x)+R/S);
|
||||
if (hx > 0)
|
||||
return r/x;
|
||||
else
|
||||
return two-r/x;
|
||||
} else {
|
||||
/* set range error */
|
||||
errno = ERANGE;
|
||||
if (hx > 0)
|
||||
return tiny*tiny;
|
||||
else
|
||||
return two-tiny;
|
||||
}
|
||||
}
|
||||
|
||||
268
lib/libc/mingw/math/sf_erf.c
vendored
268
lib/libc/mingw/math/sf_erf.c
vendored
@ -1,268 +0,0 @@
|
||||
/* sf_erf.c -- float version of s_erf.c.
|
||||
* Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
|
||||
*/
|
||||
|
||||
/*
|
||||
* ====================================================
|
||||
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
|
||||
*
|
||||
* Developed at SunPro, a Sun Microsystems, Inc. business.
|
||||
* Permission to use, copy, modify, and distribute this
|
||||
* software is freely granted, provided that this notice
|
||||
* is preserved.
|
||||
* ====================================================
|
||||
*/
|
||||
|
||||
/*
|
||||
#include "fdlibm.h"
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <stdint.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define __ieee754_expf expf
|
||||
|
||||
typedef union
|
||||
{
|
||||
float value;
|
||||
uint32_t word;
|
||||
} ieee_float_shape_type;
|
||||
|
||||
/* Get a 32 bit int from a float. */
|
||||
|
||||
static inline int
|
||||
__get_float_word(float d)
|
||||
{
|
||||
ieee_float_shape_type u;
|
||||
u.value = d;
|
||||
return u.word;
|
||||
}
|
||||
|
||||
/* Set a float from a 32 bit int. */
|
||||
|
||||
#define SET_FLOAT_WORD(d,i) \
|
||||
do { \
|
||||
ieee_float_shape_type sf_u; \
|
||||
sf_u.word = (i); \
|
||||
(d) = sf_u.value; \
|
||||
} while (0)
|
||||
|
||||
static inline void __trunc_float_word(float * x)
|
||||
{
|
||||
ieee_float_shape_type u;
|
||||
u.value = * x;
|
||||
u.word &= 0xfffff000;
|
||||
}
|
||||
|
||||
#ifdef __v810__
|
||||
#define const
|
||||
#endif
|
||||
|
||||
static const float
|
||||
tiny= 1e-30,
|
||||
half= 5.0000000000e-01, /* 0x3F000000 */
|
||||
one = 1.0000000000e+00, /* 0x3F800000 */
|
||||
two = 2.0000000000e+00, /* 0x40000000 */
|
||||
/* c = (subfloat)0.84506291151 */
|
||||
erx = 8.4506291151e-01, /* 0x3f58560b */
|
||||
/*
|
||||
* Coefficients for approximation to erf on [0,0.84375]
|
||||
*/
|
||||
efx = 1.2837916613e-01, /* 0x3e0375d4 */
|
||||
efx8= 1.0270333290e+00, /* 0x3f8375d4 */
|
||||
pp0 = 1.2837916613e-01, /* 0x3e0375d4 */
|
||||
pp1 = -3.2504209876e-01, /* 0xbea66beb */
|
||||
pp2 = -2.8481749818e-02, /* 0xbce9528f */
|
||||
pp3 = -5.7702702470e-03, /* 0xbbbd1489 */
|
||||
pp4 = -2.3763017452e-05, /* 0xb7c756b1 */
|
||||
qq1 = 3.9791721106e-01, /* 0x3ecbbbce */
|
||||
qq2 = 6.5022252500e-02, /* 0x3d852a63 */
|
||||
qq3 = 5.0813062117e-03, /* 0x3ba68116 */
|
||||
qq4 = 1.3249473704e-04, /* 0x390aee49 */
|
||||
qq5 = -3.9602282413e-06, /* 0xb684e21a */
|
||||
/*
|
||||
* Coefficients for approximation to erf in [0.84375,1.25]
|
||||
*/
|
||||
pa0 = -2.3621185683e-03, /* 0xbb1acdc6 */
|
||||
pa1 = 4.1485610604e-01, /* 0x3ed46805 */
|
||||
pa2 = -3.7220788002e-01, /* 0xbebe9208 */
|
||||
pa3 = 3.1834661961e-01, /* 0x3ea2fe54 */
|
||||
pa4 = -1.1089469492e-01, /* 0xbde31cc2 */
|
||||
pa5 = 3.5478305072e-02, /* 0x3d1151b3 */
|
||||
pa6 = -2.1663755178e-03, /* 0xbb0df9c0 */
|
||||
qa1 = 1.0642088205e-01, /* 0x3dd9f331 */
|
||||
qa2 = 5.4039794207e-01, /* 0x3f0a5785 */
|
||||
qa3 = 7.1828655899e-02, /* 0x3d931ae7 */
|
||||
qa4 = 1.2617121637e-01, /* 0x3e013307 */
|
||||
qa5 = 1.3637083583e-02, /* 0x3c5f6e13 */
|
||||
qa6 = 1.1984500103e-02, /* 0x3c445aa3 */
|
||||
/*
|
||||
* Coefficients for approximation to erfc in [1.25,1/0.35]
|
||||
*/
|
||||
ra0 = -9.8649440333e-03, /* 0xbc21a093 */
|
||||
ra1 = -6.9385856390e-01, /* 0xbf31a0b7 */
|
||||
ra2 = -1.0558626175e+01, /* 0xc128f022 */
|
||||
ra3 = -6.2375331879e+01, /* 0xc2798057 */
|
||||
ra4 = -1.6239666748e+02, /* 0xc322658c */
|
||||
ra5 = -1.8460508728e+02, /* 0xc3389ae7 */
|
||||
ra6 = -8.1287437439e+01, /* 0xc2a2932b */
|
||||
ra7 = -9.8143291473e+00, /* 0xc11d077e */
|
||||
sa1 = 1.9651271820e+01, /* 0x419d35ce */
|
||||
sa2 = 1.3765776062e+02, /* 0x4309a863 */
|
||||
sa3 = 4.3456588745e+02, /* 0x43d9486f */
|
||||
sa4 = 6.4538726807e+02, /* 0x442158c9 */
|
||||
sa5 = 4.2900814819e+02, /* 0x43d6810b */
|
||||
sa6 = 1.0863500214e+02, /* 0x42d9451f */
|
||||
sa7 = 6.5702495575e+00, /* 0x40d23f7c */
|
||||
sa8 = -6.0424413532e-02, /* 0xbd777f97 */
|
||||
/*
|
||||
* Coefficients for approximation to erfc in [1/.35,28]
|
||||
*/
|
||||
rb0 = -9.8649431020e-03, /* 0xbc21a092 */
|
||||
rb1 = -7.9928326607e-01, /* 0xbf4c9dd4 */
|
||||
rb2 = -1.7757955551e+01, /* 0xc18e104b */
|
||||
rb3 = -1.6063638306e+02, /* 0xc320a2ea */
|
||||
rb4 = -6.3756646729e+02, /* 0xc41f6441 */
|
||||
rb5 = -1.0250950928e+03, /* 0xc480230b */
|
||||
rb6 = -4.8351919556e+02, /* 0xc3f1c275 */
|
||||
sb1 = 3.0338060379e+01, /* 0x41f2b459 */
|
||||
sb2 = 3.2579251099e+02, /* 0x43a2e571 */
|
||||
sb3 = 1.5367296143e+03, /* 0x44c01759 */
|
||||
sb4 = 3.1998581543e+03, /* 0x4547fdbb */
|
||||
sb5 = 2.5530502930e+03, /* 0x451f90ce */
|
||||
sb6 = 4.7452853394e+02, /* 0x43ed43a7 */
|
||||
sb7 = -2.2440952301e+01; /* 0xc1b38712 */
|
||||
|
||||
float erff(float x)
|
||||
{
|
||||
int32_t hx, ix, i;
|
||||
float R, S, P, Q, s, y, z, r;
|
||||
hx = __get_float_word(x);
|
||||
ix = hx & 0x7fffffff;
|
||||
if (!(ix<0x7f800000L)) { /* erf(nan)=nan */
|
||||
i = ((uint32_t)hx>>31)<<1;
|
||||
return (float)(1-i)+one/x; /* erf(+-inf)=+-1 */
|
||||
}
|
||||
|
||||
if (ix < 0x3f580000) { /* |x|<0.84375 */
|
||||
if (ix < 0x31800000) { /* |x|<2**-28 */
|
||||
if (ix < 0x04000000)
|
||||
/*avoid underflow */
|
||||
return (float)0.125*((float)8.0*x+efx8*x);
|
||||
return x + efx*x;
|
||||
}
|
||||
z = x*x;
|
||||
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
|
||||
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
|
||||
y = r/s;
|
||||
return x + x*y;
|
||||
}
|
||||
if (ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
|
||||
s = fabsf(x)-one;
|
||||
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
|
||||
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
|
||||
if (hx >= 0)
|
||||
return erx + P/Q;
|
||||
else
|
||||
return -erx - P/Q;
|
||||
}
|
||||
if (ix >= 0x40c00000) { /* inf>|x|>=6 */
|
||||
if (hx >= 0)
|
||||
return one-tiny;
|
||||
else
|
||||
return tiny-one;
|
||||
}
|
||||
x = fabsf(x);
|
||||
s = one/(x*x);
|
||||
if (ix< 0x4036DB6E) { /* |x| < 1/0.35 */
|
||||
R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
|
||||
ra5+s*(ra6+s*ra7))))));
|
||||
S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
|
||||
sa5+s*(sa6+s*(sa7+s*sa8)))))));
|
||||
} else { /* |x| >= 1/0.35 */
|
||||
R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
|
||||
rb5+s*rb6)))));
|
||||
S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
|
||||
sb5+s*(sb6+s*sb7))))));
|
||||
}
|
||||
|
||||
z = x;
|
||||
__trunc_float_word (&z);
|
||||
r = __ieee754_expf(-z*z-(float)0.5625)*__ieee754_expf((z-x)*(z+x)+R/S);
|
||||
if (hx >= 0)
|
||||
return one-r/x;
|
||||
else
|
||||
return r/x-one;
|
||||
}
|
||||
|
||||
float erfcf(float x)
|
||||
{
|
||||
int32_t hx, ix;
|
||||
float R, S, P, Q, s, y, z, r;
|
||||
hx = __get_float_word(x);
|
||||
ix = hx & 0x7fffffff;
|
||||
if (!(ix < 0x7f800000L)) { /* erfc(nan)=nan */
|
||||
/* erfc(+-inf)=0,2 */
|
||||
return (float)(((uint32_t)hx>>31)<<1)+one/x;
|
||||
}
|
||||
|
||||
if (ix < 0x3f580000) { /* |x|<0.84375 */
|
||||
if (ix < 0x23800000) /* |x|<2**-56 */
|
||||
return one-x;
|
||||
z = x*x;
|
||||
r = pp0+z*(pp1+z*(pp2+z*(pp3+z*pp4)));
|
||||
s = one+z*(qq1+z*(qq2+z*(qq3+z*(qq4+z*qq5))));
|
||||
y = r/s;
|
||||
if (hx < 0x3e800000) { /* x<1/4 */
|
||||
return one-(x+x*y);
|
||||
} else {
|
||||
r = x*y;
|
||||
r += (x-half);
|
||||
return half - r ;
|
||||
}
|
||||
}
|
||||
if (ix < 0x3fa00000) { /* 0.84375 <= |x| < 1.25 */
|
||||
s = fabsf(x)-one;
|
||||
P = pa0+s*(pa1+s*(pa2+s*(pa3+s*(pa4+s*(pa5+s*pa6)))));
|
||||
Q = one+s*(qa1+s*(qa2+s*(qa3+s*(qa4+s*(qa5+s*qa6)))));
|
||||
if (hx >= 0) {
|
||||
z = one-erx; return z - P/Q;
|
||||
} else {
|
||||
z = erx+P/Q; return one+z;
|
||||
}
|
||||
}
|
||||
|
||||
if (ix < 0x41e00000) { /* |x|<28 */
|
||||
x = fabsf(x);
|
||||
s = one/(x*x);
|
||||
if (ix< 0x4036DB6D) { /* |x| < 1/.35 ~ 2.857143*/
|
||||
R = ra0+s*(ra1+s*(ra2+s*(ra3+s*(ra4+s*(
|
||||
ra5+s*(ra6+s*ra7))))));
|
||||
S = one+s*(sa1+s*(sa2+s*(sa3+s*(sa4+s*(
|
||||
sa5+s*(sa6+s*(sa7+s*sa8)))))));
|
||||
} else { /* |x| >= 1/.35 ~ 2.857143 */
|
||||
if (hx < 0 && ix >= 0x40c00000)
|
||||
return two-tiny;/* x < -6 */
|
||||
R = rb0+s*(rb1+s*(rb2+s*(rb3+s*(rb4+s*(
|
||||
rb5+s*rb6)))));
|
||||
S = one+s*(sb1+s*(sb2+s*(sb3+s*(sb4+s*(
|
||||
sb5+s*(sb6+s*sb7))))));
|
||||
}
|
||||
|
||||
z = x;
|
||||
__trunc_float_word (&z);
|
||||
r = __ieee754_expf(-z*z-(float)0.5625)*
|
||||
__ieee754_expf((z-x)*(z+x)+R/S);
|
||||
if (hx > 0)
|
||||
return r/x;
|
||||
else
|
||||
return two-r/x;
|
||||
} else {
|
||||
/* set range error */
|
||||
errno = ERANGE;
|
||||
if (hx > 0)
|
||||
return tiny*tiny;
|
||||
else
|
||||
return two-tiny;
|
||||
}
|
||||
}
|
||||
47
lib/libc/mingw/math/sqrt.c
vendored
47
lib/libc/mingw/math/sqrt.c
vendored
@ -1,47 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
#define X64_ASM "sqrtsd"
|
||||
#include "sqrt.def.h"
|
||||
268
lib/libc/mingw/math/tgamma.c
vendored
268
lib/libc/mingw/math/tgamma.c
vendored
@ -1,268 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
#ifdef UNK
|
||||
static const uD P[7] = {
|
||||
{ { 1.60119522476751861407E-4 } },
|
||||
{ { 1.19135147006586384913E-3 } },
|
||||
{ { 1.04213797561761569935E-2 } },
|
||||
{ { 4.76367800457137231464E-2 } },
|
||||
{ { 2.07448227648435975150E-1 } },
|
||||
{ { 4.94214826801497100753E-1 } },
|
||||
{ { 9.99999999999999996796E-1 } }
|
||||
};
|
||||
static const uD Q[8] = {
|
||||
{ { -2.31581873324120129819E-5 } },
|
||||
{ { 5.39605580493303397842E-4 } },
|
||||
{ { -4.45641913851797240494E-3 } },
|
||||
{ { 1.18139785222060435552E-2 } },
|
||||
{ { 3.58236398605498653373E-2 } },
|
||||
{ { -2.34591795718243348568E-1 } },
|
||||
{ { 7.14304917030273074085E-2 } },
|
||||
{ { 1.00000000000000000320E0 } }
|
||||
};
|
||||
#define MAXGAM 171.624376956302725
|
||||
static const double LOGPI = 1.14472988584940017414;
|
||||
#endif
|
||||
|
||||
#ifdef IBMPC
|
||||
static const uD P[7] = {
|
||||
{ { 0x2153,0x3998,0xfcb8,0x3f24 } },
|
||||
{ { 0xbfab,0xe686,0x84e3,0x3f53 } },
|
||||
{ { 0x14b0,0xe9db,0x57cd,0x3f85 } },
|
||||
{ { 0x23d3,0x18c4,0x63d9,0x3fa8 } },
|
||||
{ { 0x7d31,0xdcae,0x8da9,0x3fca } },
|
||||
{ { 0xe312,0x3993,0xa137,0x3fdf } },
|
||||
{ { 0x0000,0x0000,0x0000,0x3ff0 } }
|
||||
};
|
||||
static const uD Q[8] = {
|
||||
{ { 0xd3af,0x8400,0x487a,0xbef8 } },
|
||||
{ { 0x2573,0x2915,0xae8a,0x3f41 } },
|
||||
{ { 0xb44a,0xe750,0x40e4,0xbf72 } },
|
||||
{ { 0xb117,0x5b1b,0x31ed,0x3f88 } },
|
||||
{ { 0xde67,0xe33f,0x5779,0x3fa2 } },
|
||||
{ { 0x87c2,0x9d42,0x071a,0xbfce } },
|
||||
{ { 0x3c51,0xc9cd,0x4944,0x3fb2 } },
|
||||
{ { 0x0000,0x0000,0x0000,0x3ff0 } }
|
||||
};
|
||||
#define MAXGAM 171.624376956302725
|
||||
#endif
|
||||
|
||||
#ifdef MIEEE
|
||||
static const uD P[7] = {
|
||||
{ { 0x3f24,0xfcb8,0x3998,0x2153 } },
|
||||
{ { 0x3f53,0x84e3,0xe686,0xbfab } },
|
||||
{ { 0x3f85,0x57cd,0xe9db,0x14b0 } },
|
||||
{ { 0x3fa8,0x63d9,0x18c4,0x23d3 } },
|
||||
{ { 0x3fca,0x8da9,0xdcae,0x7d31 } },
|
||||
{ { 0x3fdf,0xa137,0x3993,0xe312 } },
|
||||
{ { 0x3ff0,0x0000,0x0000,0x0000 } }
|
||||
};
|
||||
static const unsigned short Q[8] = {
|
||||
{ { 0xbef8,0x487a,0x8400,0xd3af } },
|
||||
{ { 0x3f41,0xae8a,0x2915,0x2573 } },
|
||||
{ { 0xbf72,0x40e4,0xe750,0xb44a } },
|
||||
{ { 0x3f88,0x31ed,0x5b1b,0xb117 } },
|
||||
{ { 0x3fa2,0x5779,0xe33f,0xde67 } },
|
||||
{ { 0xbfce,0x071a,0x9d42,0x87c2 } },
|
||||
{ { 0x3fb2,0x4944,0xc9cd,0x3c51 } },
|
||||
{ { 0x3ff0,0x0000,0x0000,0x0000 } }
|
||||
};
|
||||
#define MAXGAM 171.624376956302725
|
||||
#endif
|
||||
|
||||
/* Stirling's formula for the gamma function */
|
||||
#if UNK
|
||||
static const uD STIR[5] = {
|
||||
{ { 7.87311395793093628397E-4 } },
|
||||
{ { -2.29549961613378126380E-4 } },
|
||||
{ { -2.68132617805781232825E-3 } },
|
||||
{ { 3.47222221605458667310E-3 } },
|
||||
{ { 8.33333333333482257126E-2 } }
|
||||
};
|
||||
#define MAXSTIR 143.01608
|
||||
static const double SQTPI = 2.50662827463100050242E0;
|
||||
#endif
|
||||
#if IBMPC
|
||||
static const uD STIR[5] = {
|
||||
{ { 0x7293,0x592d,0xcc72,0x3f49 } },
|
||||
{ { 0x1d7c,0x27e6,0x166b,0xbf2e } },
|
||||
{ { 0x4fd7,0x07d4,0xf726,0xbf65 } },
|
||||
{ { 0xc5fd,0x1b98,0x71c7,0x3f6c } },
|
||||
{ { 0x5986,0x5555,0x5555,0x3fb5 } }
|
||||
};
|
||||
#define MAXSTIR 143.01608
|
||||
|
||||
static const union
|
||||
{
|
||||
unsigned short s[4];
|
||||
double d;
|
||||
} sqt = {{0x2706,0x1ff6,0x0d93,0x4004}};
|
||||
#define SQTPI (sqt.d)
|
||||
#endif
|
||||
#if MIEEE
|
||||
static const uD STIR[5] = {
|
||||
{ { 0x3f49,0xcc72,0x592d,0x7293 } },
|
||||
{ { 0xbf2e,0x166b,0x27e6,0x1d7c } },
|
||||
{ { 0xbf65,0xf726,0x07d4,0x4fd7 } },
|
||||
{ { 0x3f6c,0x71c7,0x1b98,0xc5fd } },
|
||||
{ { 0x3fb5,0x5555,0x5555,0x5986 } }
|
||||
};
|
||||
#define MAXSTIR 143.01608
|
||||
static const uD SQT = {
|
||||
{ { 0x4004,0x0d93,0x1ff6,0x2706 } }
|
||||
};
|
||||
#define SQTPI SQT.d
|
||||
#endif
|
||||
|
||||
static double stirf (double);
|
||||
|
||||
/* Gamma function computed by Stirling's formula.
|
||||
* The polynomial STIR is valid for 33 <= x <= 172.
|
||||
*/
|
||||
static double stirf(double x)
|
||||
{
|
||||
double y, w, v;
|
||||
|
||||
w = 1.0/x;
|
||||
w = 1.0 + w * polevl(w, STIR, 4);
|
||||
y = exp(x);
|
||||
if (x > MAXSTIR)
|
||||
{ /* Avoid overflow in pow() */
|
||||
v = pow(x, 0.5 * x - 0.25);
|
||||
y = v * (v / y);
|
||||
}
|
||||
else
|
||||
{
|
||||
y = pow(x, x - 0.5) / y;
|
||||
}
|
||||
y = SQTPI * y * w;
|
||||
return (y);
|
||||
}
|
||||
|
||||
|
||||
double __tgamma_r(double x, int *sgngam);
|
||||
|
||||
double __tgamma_r(double x, int *sgngam)
|
||||
{
|
||||
double p, q, z;
|
||||
int i;
|
||||
|
||||
*sgngam = 1;
|
||||
#ifdef NANS
|
||||
if (isnan(x))
|
||||
return (x);
|
||||
#endif
|
||||
#ifdef INFINITIES
|
||||
#ifdef NANS
|
||||
if (x == INFINITY)
|
||||
return (x);
|
||||
if (x == -INFINITY)
|
||||
return (NAN);
|
||||
#else
|
||||
if (!isfinite(x))
|
||||
return (x);
|
||||
#endif
|
||||
#endif
|
||||
if (x == 0.0)
|
||||
return copysign(HUGE_VAL, x);
|
||||
|
||||
q = fabs(x);
|
||||
|
||||
if (q > 33.0)
|
||||
{
|
||||
if (x < 0.0)
|
||||
{
|
||||
p = floor(q);
|
||||
if (p == q)
|
||||
{
|
||||
gsing:
|
||||
_SET_ERRNO(EDOM);
|
||||
mtherr("tgamma", SING);
|
||||
#ifdef NANS
|
||||
return (NAN);
|
||||
#else
|
||||
return (MAXNUM);
|
||||
#endif
|
||||
}
|
||||
i = p;
|
||||
if ((i & 1) == 0)
|
||||
*sgngam = -1;
|
||||
z = q - p;
|
||||
if (z > 0.5)
|
||||
{
|
||||
p += 1.0;
|
||||
z = q - p;
|
||||
}
|
||||
z = q * sin(PI * z);
|
||||
if (z == 0.0)
|
||||
{
|
||||
_SET_ERRNO(ERANGE);
|
||||
mtherr("tgamma", OVERFLOW);
|
||||
#ifdef INFINITIES
|
||||
return (*sgngam * INFINITY);
|
||||
#else
|
||||
return (*sgngam * MAXNUM);
|
||||
#endif
|
||||
}
|
||||
z = fabs(z);
|
||||
z = PI/(z * stirf(q));
|
||||
}
|
||||
else
|
||||
{
|
||||
z = stirf(x);
|
||||
}
|
||||
return (*sgngam * z);
|
||||
}
|
||||
|
||||
z = 1.0;
|
||||
while (x >= 3.0)
|
||||
{
|
||||
x -= 1.0;
|
||||
z *= x;
|
||||
}
|
||||
|
||||
while (x < 0.0)
|
||||
{
|
||||
if (x > -1.E-9)
|
||||
goto Small;
|
||||
z /= x;
|
||||
x += 1.0;
|
||||
}
|
||||
|
||||
while (x < 2.0)
|
||||
{
|
||||
if (x < 1.e-9)
|
||||
goto Small;
|
||||
z /= x;
|
||||
x += 1.0;
|
||||
}
|
||||
|
||||
if (x == 2.0)
|
||||
return (z);
|
||||
|
||||
x -= 2.0;
|
||||
p = polevl( x, P, 6 );
|
||||
q = polevl( x, Q, 7 );
|
||||
return (z * p / q);
|
||||
|
||||
Small:
|
||||
if (x == 0.0)
|
||||
{
|
||||
goto gsing;
|
||||
}
|
||||
else
|
||||
return (z/((1.0 + 0.5772156649015329 * x) * x));
|
||||
}
|
||||
|
||||
/* This is the C99 version */
|
||||
double tgamma(double x)
|
||||
{
|
||||
int local_sgngam = 0;
|
||||
return (__tgamma_r(x, &local_sgngam));
|
||||
}
|
||||
|
||||
196
lib/libc/mingw/math/tgammaf.c
vendored
196
lib/libc/mingw/math/tgammaf.c
vendored
@ -1,196 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
/* define MAXGAM 34.84425627277176174 */
|
||||
|
||||
/* Stirling's formula for the gamma function
|
||||
* gamma(x) = sqrt(2 pi) x^(x-.5) exp(-x) ( 1 + 1/x P(1/x) )
|
||||
* .028 < 1/x < .1
|
||||
* relative error < 1.9e-11
|
||||
*/
|
||||
static const float STIR[] = {
|
||||
-2.705194986674176E-003,
|
||||
3.473255786154910E-003,
|
||||
8.333331788340907E-002,
|
||||
};
|
||||
static const float MAXSTIR = 26.77;
|
||||
static const float SQTPIF = 2.50662827463100050242; /* sqrt( 2 pi ) */
|
||||
|
||||
static float stirf(float);
|
||||
|
||||
/* Gamma function computed by Stirling's formula,
|
||||
* sqrt(2 pi) x^(x-.5) exp(-x) (1 + 1/x P(1/x))
|
||||
* The polynomial STIR is valid for 33 <= x <= 172.
|
||||
*/
|
||||
static float stirf( float x )
|
||||
{
|
||||
float y, w, v;
|
||||
|
||||
w = 1.0/x;
|
||||
w = 1.0 + w * polevlf(w, STIR, 2);
|
||||
y = expf(-x);
|
||||
if (x > MAXSTIR)
|
||||
{ /* Avoid overflow in pow() */
|
||||
v = powf(x, 0.5 * x - 0.25);
|
||||
y *= v;
|
||||
y *= v;
|
||||
}
|
||||
else
|
||||
{
|
||||
y = powf(x, x - 0.5) * y;
|
||||
}
|
||||
y = SQTPIF * y * w;
|
||||
return (y);
|
||||
}
|
||||
|
||||
|
||||
/* gamma(x+2), 0 < x < 1 */
|
||||
static const float P[] = {
|
||||
1.536830450601906E-003,
|
||||
5.397581592950993E-003,
|
||||
4.130370201859976E-003,
|
||||
7.232307985516519E-002,
|
||||
8.203960091619193E-002,
|
||||
4.117857447645796E-001,
|
||||
4.227867745131584E-001,
|
||||
9.999999822945073E-001,
|
||||
};
|
||||
|
||||
float __tgammaf_r( float x, int* sgngamf);
|
||||
|
||||
float __tgammaf_r( float x, int* sgngamf)
|
||||
{
|
||||
float p, q, z, nz;
|
||||
int i, direction, negative;
|
||||
|
||||
#ifdef NANS
|
||||
if (isnan(x))
|
||||
return (x);
|
||||
#endif
|
||||
#ifdef INFINITIES
|
||||
#ifdef NANS
|
||||
if (x == INFINITYF)
|
||||
return (x);
|
||||
if (x == -INFINITYF)
|
||||
return (NANF);
|
||||
#else
|
||||
if (!isfinite(x))
|
||||
return (x);
|
||||
#endif
|
||||
#endif
|
||||
if (x == 0.0)
|
||||
return copysignf(HUGE_VALF, x);
|
||||
|
||||
*sgngamf = 1;
|
||||
negative = 0;
|
||||
nz = 0.0;
|
||||
if (x < 0.0)
|
||||
{
|
||||
negative = 1;
|
||||
q = -x;
|
||||
p = floorf(q);
|
||||
if (p == q)
|
||||
{
|
||||
gsing:
|
||||
_SET_ERRNO(EDOM);
|
||||
mtherr("tgammaf", SING);
|
||||
#ifdef NANS
|
||||
return (NAN);
|
||||
#else
|
||||
return (MAXNUMF);
|
||||
#endif
|
||||
}
|
||||
i = p;
|
||||
if ((i & 1) == 0)
|
||||
*sgngamf = -1;
|
||||
nz = q - p;
|
||||
if (nz > 0.5)
|
||||
{
|
||||
p += 1.0;
|
||||
nz = q - p;
|
||||
}
|
||||
nz = q * sinf(PIF * nz);
|
||||
if (nz == 0.0)
|
||||
{
|
||||
_SET_ERRNO(ERANGE);
|
||||
mtherr("tgamma", OVERFLOW);
|
||||
#ifdef INFINITIES
|
||||
return(*sgngamf * INFINITYF);
|
||||
#else
|
||||
return(*sgngamf * MAXNUMF);
|
||||
#endif
|
||||
}
|
||||
if (nz < 0)
|
||||
nz = -nz;
|
||||
x = q;
|
||||
}
|
||||
if (x >= 10.0)
|
||||
{
|
||||
z = stirf(x);
|
||||
}
|
||||
if (x < 2.0)
|
||||
direction = 1;
|
||||
else
|
||||
direction = 0;
|
||||
z = 1.0;
|
||||
while (x >= 3.0)
|
||||
{
|
||||
x -= 1.0;
|
||||
z *= x;
|
||||
}
|
||||
/*
|
||||
while (x < 0.0)
|
||||
{
|
||||
if (x > -1.E-4)
|
||||
goto Small;
|
||||
z *=x;
|
||||
x += 1.0;
|
||||
}
|
||||
*/
|
||||
while (x < 2.0)
|
||||
{
|
||||
if (x < 1.e-4)
|
||||
goto Small;
|
||||
z *=x;
|
||||
x += 1.0;
|
||||
}
|
||||
|
||||
if (direction)
|
||||
z = 1.0/z;
|
||||
|
||||
if (x == 2.0)
|
||||
return (z);
|
||||
|
||||
x -= 2.0;
|
||||
p = z * polevlf(x, P, 7);
|
||||
|
||||
gdone:
|
||||
if (negative)
|
||||
{
|
||||
p = *sgngamf * PIF/(nz * p );
|
||||
}
|
||||
return (p);
|
||||
|
||||
Small:
|
||||
if (x == 0.0)
|
||||
{
|
||||
goto gsing;
|
||||
}
|
||||
else
|
||||
{
|
||||
p = z / ((1.0 + 0.5772156649015329 * x) * x);
|
||||
goto gdone;
|
||||
}
|
||||
}
|
||||
|
||||
/* This is the C99 version */
|
||||
float tgammaf(float x)
|
||||
{
|
||||
int local_sgngamf = 0;
|
||||
return (__tgammaf_r(x, &local_sgngamf));
|
||||
}
|
||||
|
||||
46
lib/libc/mingw/math/x86/acosh.c
vendored
46
lib/libc/mingw/math/x86/acosh.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
#include "acosh.def.h"
|
||||
46
lib/libc/mingw/math/x86/acoshf.c
vendored
46
lib/libc/mingw/math/x86/acoshf.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_FLOAT 1
|
||||
#include "acosh.def.h"
|
||||
74
lib/libc/mingw/math/x86/asinh.c
vendored
74
lib/libc/mingw/math/x86/asinh.c
vendored
@ -1,74 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <float.h>
|
||||
#include "fastmath.h"
|
||||
|
||||
/* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */
|
||||
double asinh(double x)
|
||||
{
|
||||
double z;
|
||||
if (!isfinite (x))
|
||||
return x;
|
||||
z = fabs (x);
|
||||
|
||||
/* Avoid setting FPU underflow exception flag in x * x. */
|
||||
#if 0
|
||||
if ( z < 0x1p-32)
|
||||
return x;
|
||||
#endif
|
||||
|
||||
/* NB the previous formula
|
||||
z = __fast_log1p (z + z * z / (__fast_sqrt (z * z + 1.0) + 1.0));
|
||||
was defective in two ways:
|
||||
1: It ommitted required brackets:
|
||||
z = __fast_log1p (z + z * (z / (__fast_sqrt (z * z + 1.0) + 1.0)));
|
||||
^ ^
|
||||
so would still overflow for large z.
|
||||
2: Even with the brackets, it still degraded quickly for large z
|
||||
(where z*z+1 == z*z).
|
||||
e.g. asinh (sinh 356.0)) gave 355.30685281944005
|
||||
*/
|
||||
|
||||
const double asinhCutover = pow(2,DBL_MAX_EXP/2); // 1.3407807929943e+154
|
||||
|
||||
if (z < asinhCutover)
|
||||
/* After excluding large values, the rearranged formula gives better results
|
||||
the original formula log(z + sqrt(z * z + 1.0)) for very small z.
|
||||
e.g. rearranged asinh(sinh 2e-301)) = 2e-301
|
||||
original asinh(sinh 2e-301)) = 0.
|
||||
asinh(z) = log (z + sqrt (z * z + 1.0))
|
||||
= log1p (z + sqrt (z * z + 1.0) - 1.0)
|
||||
= log1p (z + (sqrt (z * z + 1.0) - 1.0)
|
||||
* (sqrt (z * z + 1.0) + 1.0)
|
||||
/ (sqrt (z * z + 1.0) + 1.0))
|
||||
= log1p (z + ((z * z + 1.0) - 1.0)
|
||||
/ (sqrt (z * z + 1.0) + 1.0))
|
||||
= log1p (z + z * z / (sqrt (z * z + 1.0) + 1.0))
|
||||
*/
|
||||
z = __fast_log1p (z + z * (z / (__fast_sqrt (z * z + 1.0) + 1.0)));
|
||||
else
|
||||
/* above this, z*z+1 == z*z, so we can simplify
|
||||
(and avoid z*z being infinity).
|
||||
asinh(z) = log (z + sqrt (z * z + 1.0))
|
||||
= log (z + sqrt (z * z ))
|
||||
= log (2 * z)
|
||||
= log 2 + log z
|
||||
Choosing asinhCutover is a little tricky.
|
||||
We'd like something that's based on the nature of
|
||||
the numeric type (DBL_MAX_EXP, etc).
|
||||
If c = asinhCutover, then we need:
|
||||
(1) c*c == c*c + 1
|
||||
(2) log (2*c) = log 2 + log c.
|
||||
For float:
|
||||
9.490626562425156e7 is the smallest value that
|
||||
achieves (1), but it fails (2). (It only just fails,
|
||||
but enough to make the function erroneously non-monotonic).
|
||||
*/
|
||||
z = __fast_log(2) + __fast_log(z);
|
||||
return copysign(z, x); //ensure 0.0 -> 0.0 and -0.0 -> -0.0.
|
||||
}
|
||||
34
lib/libc/mingw/math/x86/asinhf.c
vendored
34
lib/libc/mingw/math/x86/asinhf.c
vendored
@ -1,34 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include <float.h>
|
||||
#include "fastmath.h"
|
||||
|
||||
/* asinh(x) = copysign(log(fabs(x) + sqrt(x * x + 1.0)), x) */
|
||||
float asinhf(float x)
|
||||
{
|
||||
float z;
|
||||
if (!isfinite (x))
|
||||
return x;
|
||||
z = fabsf (x);
|
||||
|
||||
/* Avoid setting FPU underflow exception flag in x * x. */
|
||||
#if 0
|
||||
if ( z < 0x1p-32)
|
||||
return x;
|
||||
#endif
|
||||
|
||||
/* See commentary in asinh */
|
||||
const float asinhCutover = pow(2,FLT_MAX_EXP/2);
|
||||
|
||||
if (z < asinhCutover)
|
||||
z = __fast_log1p (z + z * (z / (__fast_sqrt (z * z + 1.0) + 1.0)));
|
||||
//z = __fast_log(z + __fast_sqrt(z * z + 1.0));
|
||||
else
|
||||
z = __fast_log(2) + __fast_log(z);
|
||||
return copysignf(z, x); //ensure 0.0 -> 0.0 and -0.0 -> -0.0.
|
||||
}
|
||||
15
lib/libc/mingw/math/x86/atan2.c
vendored
15
lib/libc/mingw/math/x86/atan2.c
vendored
@ -1,15 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <math.h>
|
||||
|
||||
double
|
||||
atan2 (double y, double x)
|
||||
{
|
||||
double res = 0.0;
|
||||
asm volatile ("fpatan" : "=t" (res) : "u" (y), "0" (x) : "st(1)");
|
||||
return res;
|
||||
}
|
||||
36
lib/libc/mingw/math/x86/atanh.c
vendored
36
lib/libc/mingw/math/x86/atanh.c
vendored
@ -1,36 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include "fastmath.h"
|
||||
|
||||
/* atanh (x) = 0.5 * log ((1.0 + x)/(1.0 - x)) */
|
||||
|
||||
double atanh(double x)
|
||||
{
|
||||
double z;
|
||||
if (isnan (x))
|
||||
return x;
|
||||
z = fabs (x);
|
||||
if (z == 1.0)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return (x > 0 ? INFINITY : -INFINITY);
|
||||
}
|
||||
if (z > 1.0)
|
||||
{
|
||||
errno = EDOM;
|
||||
return nan("");
|
||||
}
|
||||
/* Rearrange formula to avoid precision loss for small x.
|
||||
|
||||
atanh(x) = 0.5 * log ((1.0 + x)/(1.0 - x))
|
||||
= 0.5 * log1p ((1.0 + x)/(1.0 - x) - 1.0)
|
||||
= 0.5 * log1p ((1.0 + x - 1.0 + x) /(1.0 - x))
|
||||
= 0.5 * log1p ((2.0 * x ) / (1.0 - x)) */
|
||||
z = 0.5 * __fast_log1p ((z + z) / (1.0 - z));
|
||||
return copysign(z, x); //ensure 0.0 -> 0.0 and -0.0 -> -0.0.
|
||||
}
|
||||
35
lib/libc/mingw/math/x86/atanhf.c
vendored
35
lib/libc/mingw/math/x86/atanhf.c
vendored
@ -1,35 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#include "fastmath.h"
|
||||
|
||||
/* atanh (x) = 0.5 * log ((1.0 + x)/(1.0 - x)) */
|
||||
float atanhf (float x)
|
||||
{
|
||||
float z;
|
||||
if (isnan (x))
|
||||
return x;
|
||||
z = fabsf (x);
|
||||
if (z == 1.0)
|
||||
{
|
||||
errno = ERANGE;
|
||||
return (x > 0 ? INFINITY : -INFINITY);
|
||||
}
|
||||
if ( z > 1.0)
|
||||
{
|
||||
errno = EDOM;
|
||||
return nanf("");
|
||||
}
|
||||
/* Rearrange formula to avoid precision loss for small x.
|
||||
|
||||
atanh(x) = 0.5 * log ((1.0 + x)/(1.0 - x))
|
||||
= 0.5 * log1p ((1.0 + x)/(1.0 - x) - 1.0)
|
||||
= 0.5 * log1p ((1.0 + x - 1.0 + x) /(1.0 - x))
|
||||
= 0.5 * log1p ((2.0 * x ) / (1.0 - x)) */
|
||||
z = 0.5 * __fast_log1p ((z + z) / (1.0 - z));
|
||||
return copysignf(z, x); //ensure 0.0 -> 0.0 and -0.0 -> -0.0.
|
||||
}
|
||||
115
lib/libc/mingw/math/x86/ceil.S
vendored
115
lib/libc/mingw/math/x86/ceil.S
vendored
@ -1,115 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "ceil.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(ceil)
|
||||
.def __MINGW_USYMBOL(ceil); .scl 2; .type 32; .endef
|
||||
#ifdef __x86_64__
|
||||
.seh_proc __MINGW_USYMBOL(ceil)
|
||||
#endif
|
||||
|
||||
__MINGW_USYMBOL(ceil):
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
.seh_endprologue
|
||||
movd %xmm0, %rax
|
||||
movq %rax, %rcx
|
||||
sarq $52, %rcx
|
||||
andl $2047, %ecx
|
||||
subl $1023, %ecx
|
||||
cmpl $51, %ecx
|
||||
jg .is_intnaninf
|
||||
/* Is x zero? */
|
||||
testq %rax, %rax
|
||||
je .ret_org
|
||||
/* Is x signed? */
|
||||
testl %ecx, %ecx
|
||||
js .signed_val
|
||||
/* Is x integral? */
|
||||
movabsq $4503599627370495, %rdx
|
||||
sarq %cl, %rdx
|
||||
testq %rax, %rdx
|
||||
je .ret_org
|
||||
addsd .huge(%rip), %xmm0
|
||||
ucomisd .zero(%rip), %xmm0
|
||||
jbe .doret
|
||||
testq %rax, %rax
|
||||
jle .l1
|
||||
/* inexact ... */
|
||||
movabsq $4503599627370496, %r8
|
||||
shrq %cl, %r8
|
||||
addq %r8, %rax
|
||||
.l1:
|
||||
notq %rdx
|
||||
andq %rdx, %rax
|
||||
.doret:
|
||||
movd %rax, %xmm0
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.signed_val:
|
||||
addsd .huge(%rip), %xmm0
|
||||
ucomisd .zero(%rip), %xmm0
|
||||
jbe .doret2
|
||||
testq %rax, %rax
|
||||
movabsq $4607182418800017408, %rdx
|
||||
movabsq $-9223372036854775808, %rax
|
||||
cmovns %rdx, %rax
|
||||
.p2align 4,,10
|
||||
.doret2:
|
||||
movd %rax, %xmm0
|
||||
ret
|
||||
|
||||
.p2align 4,,10
|
||||
.is_intnaninf:
|
||||
/* Is Nan or Inf? */
|
||||
cmpl $1024, %ecx
|
||||
je .ret_naninf
|
||||
.p2align 4,,10
|
||||
.ret_org:
|
||||
/* return x. */
|
||||
rep
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.ret_naninf:
|
||||
/* return x + x; */
|
||||
addsd %xmm0, %xmm0
|
||||
ret
|
||||
.seh_endproc
|
||||
|
||||
/* local data. */
|
||||
.section .rdata,"dr"
|
||||
.align 8
|
||||
.huge:
|
||||
.long -2013235812
|
||||
.long 2117592124
|
||||
.align 8
|
||||
.zero:
|
||||
.long 0
|
||||
.long 0
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
fldl 4(%esp)
|
||||
subl $8,%esp
|
||||
|
||||
fstcw 4(%esp) /* store fpu control word */
|
||||
|
||||
/* We use here %edx although only the low 1 bits are defined.
|
||||
But none of the operations should care and they are faster
|
||||
than the 16 bit operations. */
|
||||
movl $0x0800,%edx /* round towards +oo */
|
||||
orl 4(%esp),%edx
|
||||
andl $0xfbff,%edx
|
||||
movl %edx,(%esp)
|
||||
fldcw (%esp) /* load modified control word */
|
||||
|
||||
frndint /* round */
|
||||
|
||||
fldcw 4(%esp) /* restore original control word */
|
||||
|
||||
addl $8,%esp
|
||||
ret
|
||||
#endif
|
||||
46
lib/libc/mingw/math/x86/cos.c
vendored
46
lib/libc/mingw/math/x86/cos.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
#include "cos.def.h"
|
||||
46
lib/libc/mingw/math/x86/exp.c
vendored
46
lib/libc/mingw/math/x86/exp.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
#include "exp.def.h"
|
||||
94
lib/libc/mingw/math/x86/exp2.S
vendored
94
lib/libc/mingw/math/x86/exp2.S
vendored
@ -1,94 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2.S"
|
||||
.text
|
||||
#ifdef __x86_64__
|
||||
.align 8
|
||||
#else
|
||||
.align 4
|
||||
#endif
|
||||
.globl __MINGW_USYMBOL(exp2)
|
||||
.def __MINGW_USYMBOL(exp2); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2):
|
||||
#ifdef __x86_64__
|
||||
subq $24, %rsp
|
||||
movsd %xmm0,(%rsp)
|
||||
fldl (%rsp)
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
subq $8, %rsp /* int(x) */
|
||||
fnstcw 4(%rsp)
|
||||
movzwl 4(%rsp), %eax
|
||||
orb $12, %ah
|
||||
movw %ax, (%rsp)
|
||||
fldcw (%rsp)
|
||||
frndint
|
||||
fldcw 4(%rsp)
|
||||
addq $8, %rsp
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
fstpl (%rsp)
|
||||
movsd (%rsp),%xmm0
|
||||
addq $24, %rsp
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: fstpl (%rsp)
|
||||
movsd (%rsp),%xmm0
|
||||
addq $24,%rsp
|
||||
ret
|
||||
#else
|
||||
fldl 4(%esp)
|
||||
/* I added the following ugly construct because exp(+-Inf) resulted
|
||||
in NaN. The ugliness results from the bright minds at Intel.
|
||||
For the i686 the code can be written better.
|
||||
-- drepper@cygnus.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
subl $8, %esp /* int(x) */
|
||||
fnstcw 4(%esp)
|
||||
movzwl 4(%esp), %eax
|
||||
orb $12, %ah
|
||||
movw %ax, (%esp)
|
||||
fldcw (%esp)
|
||||
frndint
|
||||
fldcw 4(%esp)
|
||||
addl $8, %esp
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: ret
|
||||
#endif
|
||||
94
lib/libc/mingw/math/x86/exp2f.S
vendored
94
lib/libc/mingw/math/x86/exp2f.S
vendored
@ -1,94 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "exp2f.S"
|
||||
.text
|
||||
#ifdef __x86_64__
|
||||
.align 8
|
||||
#else
|
||||
.align 4
|
||||
#endif
|
||||
.globl __MINGW_USYMBOL(exp2f)
|
||||
.def __MINGW_USYMBOL(exp2f); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(exp2f):
|
||||
#ifdef __x86_64__
|
||||
subq $24, %rsp
|
||||
movss %xmm0,(%rsp)
|
||||
flds (%rsp)
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
subq $8, %rsp /* int(x) */
|
||||
fnstcw 4(%rsp)
|
||||
movzwl 4(%rsp), %eax
|
||||
orb $12, %ah
|
||||
movw %ax, (%rsp)
|
||||
fldcw (%rsp)
|
||||
frndint
|
||||
fldcw 4(%rsp)
|
||||
addq $8, %rsp
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
fstps (%rsp)
|
||||
movss (%rsp),%xmm0
|
||||
addq $24, %rsp
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: fstps (%rsp)
|
||||
movss (%rsp),%xmm0
|
||||
addq $24, %rsp
|
||||
ret
|
||||
#else
|
||||
flds 4(%esp)
|
||||
/* I added the following ugly construct because exp(+-Inf) resulted
|
||||
in NaN. The ugliness results from the bright minds at Intel.
|
||||
For the i686 the code can be written better.
|
||||
-- drepper@cygnus.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
fld %st
|
||||
subl $8, %esp /* int(x) */
|
||||
fnstcw 4(%esp)
|
||||
movzwl 4(%esp), %eax
|
||||
orb $12, %ah
|
||||
movw %ax, (%esp)
|
||||
fldcw (%esp)
|
||||
frndint
|
||||
fldcw 4(%esp)
|
||||
addl $8, %esp
|
||||
fsubr %st,%st(1) /* fract(x) */
|
||||
fxch
|
||||
f2xm1 /* 2^(fract(x)) - 1 */
|
||||
fld1
|
||||
faddp /* 2^(fract(x)) */
|
||||
fscale /* e^x */
|
||||
fstp %st(1)
|
||||
ret
|
||||
|
||||
1: testl $0x200, %eax /* Test sign. */
|
||||
jz 2f /* If positive, jump. */
|
||||
fstp %st
|
||||
fldz /* Set result to 0. */
|
||||
2: ret
|
||||
#endif
|
||||
46
lib/libc/mingw/math/x86/expm1.c
vendored
46
lib/libc/mingw/math/x86/expm1.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_DOUBLE 1
|
||||
#include "expm1.def.h"
|
||||
46
lib/libc/mingw/math/x86/expm1f.c
vendored
46
lib/libc/mingw/math/x86/expm1f.c
vendored
@ -1,46 +0,0 @@
|
||||
/*
|
||||
This Software is provided under the Zope Public License (ZPL) Version 2.1.
|
||||
|
||||
Copyright (c) 2009, 2010 by the mingw-w64 project
|
||||
|
||||
See the AUTHORS file for the list of contributors to the mingw-w64 project.
|
||||
|
||||
This license has been certified as open source. It has also been designated
|
||||
as GPL compatible by the Free Software Foundation (FSF).
|
||||
|
||||
Redistribution and use in source and binary forms, with or without
|
||||
modification, are permitted provided that the following conditions are met:
|
||||
|
||||
1. Redistributions in source code must retain the accompanying copyright
|
||||
notice, this list of conditions, and the following disclaimer.
|
||||
2. Redistributions in binary form must reproduce the accompanying
|
||||
copyright notice, this list of conditions, and the following disclaimer
|
||||
in the documentation and/or other materials provided with the
|
||||
distribution.
|
||||
3. Names of the copyright holders must not be used to endorse or promote
|
||||
products derived from this software without prior written permission
|
||||
from the copyright holders.
|
||||
4. The right to distribute this software or to use it for any purpose does
|
||||
not give you the right to use Servicemarks (sm) or Trademarks (tm) of
|
||||
the copyright holders. Use of them is covered by separate agreement
|
||||
with the copyright holders.
|
||||
5. If any files are modified, you must cause the modified files to carry
|
||||
prominent notices stating that you changed the files and the date of
|
||||
any change.
|
||||
|
||||
Disclaimer
|
||||
|
||||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY EXPRESSED
|
||||
OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
||||
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
||||
EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
|
||||
LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
|
||||
OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
||||
LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||
NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
|
||||
EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
|
||||
#define _NEW_COMPLEX_FLOAT 1
|
||||
#include "expm1.def.h"
|
||||
167
lib/libc/mingw/math/x86/floor.S
vendored
167
lib/libc/mingw/math/x86/floor.S
vendored
@ -1,167 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "floor.S"
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl __MINGW_USYMBOL(floor)
|
||||
.def __MINGW_USYMBOL(floor); .scl 2; .type 32; .endef
|
||||
#ifdef __x86_64__
|
||||
.seh_proc __MINGW_USYMBOL(floor)
|
||||
#endif
|
||||
__MINGW_USYMBOL(floor):
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
pushq %rbx
|
||||
.seh_pushreg %rbx
|
||||
subq $16, %rsp
|
||||
.seh_stackalloc 16
|
||||
.seh_endprologue
|
||||
movsd %xmm0, 8(%rsp)
|
||||
movq 8(%rsp), %r9
|
||||
movq %r9, %rdx
|
||||
movl %r9d, %r10d
|
||||
shrq $32, %rdx
|
||||
movl %edx, %eax
|
||||
movl %edx, %r11d
|
||||
sarl $20, %eax
|
||||
andl $2047, %eax
|
||||
leal -1023(%rax), %r8d
|
||||
cmpl $51, %r8d
|
||||
jle .L2
|
||||
cmpl $1024, %r8d
|
||||
je .L27
|
||||
.L3:
|
||||
addq $16, %rsp
|
||||
popq %rbx
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L2:
|
||||
cmpl $19, %r8d
|
||||
jg .L4
|
||||
testl %r8d, %r8d
|
||||
js .L28
|
||||
movl $1048575, %eax
|
||||
movl %r8d, %ecx
|
||||
shrl %cl, %eax
|
||||
testl %r9d, %r9d
|
||||
jne .L8
|
||||
testl %edx, %eax
|
||||
je .L3
|
||||
.L8:
|
||||
movsd .hugeval(%rip), %xmm1
|
||||
xorpd %xmm2, %xmm2
|
||||
addsd %xmm0, %xmm1
|
||||
ucomisd %xmm1, %xmm2
|
||||
jae .L3
|
||||
xorl %r9d, %r9d
|
||||
testl %edx, %edx
|
||||
jns .L9
|
||||
movl $1048576, %r9d
|
||||
movl %r8d, %ecx
|
||||
sarl %cl, %r9d
|
||||
.L9:
|
||||
addl %r9d, %edx
|
||||
notl %eax
|
||||
andl %edx, %eax
|
||||
salq $32, %rax
|
||||
movq %rax, 8(%rsp)
|
||||
movsd 8(%rsp), %xmm0
|
||||
addq $16, %rsp
|
||||
popq %rbx
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L4:
|
||||
leal -1043(%rax), %ecx
|
||||
movl $-1, %ebx
|
||||
shrl %cl, %ebx
|
||||
testl %r9d, %ebx
|
||||
je .L3
|
||||
movsd .hugeval(%rip), %xmm1
|
||||
xorpd %xmm2, %xmm2
|
||||
addsd %xmm0, %xmm1
|
||||
ucomisd %xmm1, %xmm2
|
||||
jae .L3
|
||||
testl %edx, %edx
|
||||
js .L29
|
||||
.L11:
|
||||
notl %ebx
|
||||
salq $32, %r11
|
||||
andl %ebx, %r10d
|
||||
orq %r10, %r11
|
||||
movq %r11, 8(%rsp)
|
||||
movsd 8(%rsp), %xmm0
|
||||
addq $16, %rsp
|
||||
popq %rbx
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L27:
|
||||
addsd %xmm0, %xmm0
|
||||
addq $16, %rsp
|
||||
popq %rbx
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L28:
|
||||
movsd .hugeval(%rip), %xmm2
|
||||
xorpd %xmm1, %xmm1
|
||||
addsd %xmm0, %xmm2
|
||||
ucomisd %xmm1, %xmm2
|
||||
jbe .L3
|
||||
testl %edx, %edx
|
||||
js .L7
|
||||
movapd %xmm1, %xmm0
|
||||
jmp .L3
|
||||
.p2align 4,,10
|
||||
.L7:
|
||||
andl $2147483647, %edx
|
||||
orl %r9d, %edx
|
||||
je .L3
|
||||
movabsq $-4616189618054758400, %rax
|
||||
movq %rax, 8(%rsp)
|
||||
movsd 8(%rsp), %xmm0
|
||||
jmp .L3
|
||||
.p2align 4,,10
|
||||
.L29:
|
||||
cmpl $20, %r8d
|
||||
je .L25
|
||||
movl $1075, %ecx
|
||||
movl $1, %r10d
|
||||
subl %eax, %ecx
|
||||
sall %cl, %r10d
|
||||
addl %r9d, %r10d
|
||||
jae .L11
|
||||
.L25:
|
||||
leal 1(%rdx), %r11d
|
||||
jmp .L11
|
||||
.seh_endproc
|
||||
|
||||
.section .rdata,"dr"
|
||||
.align 8
|
||||
.hugeval:
|
||||
.long -2013235812
|
||||
.long 2117592124
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
fldl 4(%esp)
|
||||
subl $8,%esp
|
||||
|
||||
fstcw 4(%esp) /* store fpu control word */
|
||||
|
||||
/* We use here %edx although only the low 1 bits are defined.
|
||||
But none of the operations should care and they are faster
|
||||
than the 16 bit operations. */
|
||||
movl $0x400,%edx /* round towards -oo */
|
||||
orl 4(%esp),%edx
|
||||
andl $0xf7ff,%edx
|
||||
movl %edx,(%esp)
|
||||
fldcw (%esp) /* load modified control word */
|
||||
|
||||
frndint /* round */
|
||||
|
||||
fldcw 4(%esp) /* restore original control word */
|
||||
|
||||
addl $8,%esp
|
||||
ret
|
||||
#endif
|
||||
21
lib/libc/mingw/math/x86/fmod.c
vendored
21
lib/libc/mingw/math/x86/fmod.c
vendored
@ -1,21 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
double fmod (double x, double y);
|
||||
|
||||
double
|
||||
fmod (double x, double y)
|
||||
{
|
||||
double res = 0.0;
|
||||
|
||||
asm volatile (
|
||||
"1:\tfprem\n\t"
|
||||
"fstsw %%ax\n\t"
|
||||
"sahf\n\t"
|
||||
"jp 1b\n\t"
|
||||
"fstp %%st(1)"
|
||||
: "=t" (res) : "0" (x), "u" (y) : "ax", "st(1)");
|
||||
return res;
|
||||
}
|
||||
137
lib/libc/mingw/math/x86/ilogb.S
vendored
137
lib/libc/mingw/math/x86/ilogb.S
vendored
@ -1,137 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "ilogb.S"
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl __MINGW_USYMBOL(ilogb)
|
||||
.def __MINGW_USYMBOL(ilogb); .scl 2; .type 32; .endef
|
||||
#ifdef __x86_64__
|
||||
.seh_proc __MINGW_USYMBOL(ilogb)
|
||||
#endif
|
||||
__MINGW_USYMBOL(ilogb):
|
||||
#ifdef __x86_64__
|
||||
/* Generated code by:
|
||||
int
|
||||
ilogb (double x)
|
||||
{
|
||||
__mingw_dbl_type_t hlp;
|
||||
int hx, lx, ix;
|
||||
|
||||
hlp.x = x;
|
||||
hx = hpl.lh.high & 0x7fffffff;
|
||||
if (hx < 0x100000)
|
||||
{
|
||||
lx = hlp.lh.low;
|
||||
if ((hx | lx) == 0)
|
||||
return 0x80000000; // ilogb(0) = FP_ILOGB0
|
||||
// subnormal x
|
||||
if (hx == 0)
|
||||
{
|
||||
for (ix = -1043; lx > 0; lx <<= 1)
|
||||
ix -=1;
|
||||
}
|
||||
else
|
||||
{
|
||||
for (ix = -1022,hx <<= 11; hx > 0; hx <<= 1)
|
||||
ix -=1;
|
||||
}
|
||||
return ix;
|
||||
}
|
||||
if (hx < 0x7ff00000)
|
||||
return (hx >> 20) - 1023;
|
||||
lx = hlp.lh.low;
|
||||
return 0x7fffffff;
|
||||
} */
|
||||
subq $24, %rsp
|
||||
.seh_stackalloc 24
|
||||
.seh_endprologue
|
||||
movsd %xmm0, 8(%rsp)
|
||||
movq 8(%rsp), %rdx
|
||||
shrq $32, %rdx
|
||||
andl $2147483647, %edx
|
||||
cmpl $1048575, %edx
|
||||
jg .L2
|
||||
movq 8(%rsp), %rcx
|
||||
movl %edx, %eax
|
||||
orl %ecx, %eax
|
||||
je .L8
|
||||
testl %edx, %edx
|
||||
jne .L4
|
||||
testl %ecx, %ecx
|
||||
movl %ecx, %edx
|
||||
movl $-1043, %eax
|
||||
jle .L3
|
||||
.p2align 4,,10
|
||||
.L5:
|
||||
addl %edx, %edx
|
||||
subl $1, %eax
|
||||
testl %edx, %edx
|
||||
jg .L5
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L2:
|
||||
cmpl $2146435071, %edx
|
||||
jle .L13
|
||||
movl $2147483647, %eax
|
||||
.L3:
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L4:
|
||||
sall $11, %edx
|
||||
movl $-1022, %eax
|
||||
testl %edx, %edx
|
||||
jle .L3
|
||||
.p2align 4,,10
|
||||
.L6:
|
||||
addl %edx, %edx
|
||||
subl $1, %eax
|
||||
testl %edx, %edx
|
||||
jg .L6
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L13:
|
||||
sarl $20, %edx
|
||||
leal -1023(%rdx), %eax
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.L8:
|
||||
movl $-2147483648, %eax
|
||||
jmp .L3
|
||||
.seh_endproc
|
||||
#else
|
||||
|
||||
fldl 4(%esp)
|
||||
/* I added the following ugly construct because ilogb(+-Inf) is
|
||||
required to return INT_MAX in ISO C99.
|
||||
-- jakub@redhat.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
cmpb $0x01, %dh
|
||||
je 1f /* Is NaN, jump. */
|
||||
|
||||
fxtract
|
||||
pushl %eax
|
||||
fstp %st
|
||||
|
||||
fistpl (%esp)
|
||||
fwait
|
||||
popl %eax
|
||||
|
||||
ret
|
||||
|
||||
1: fstp %st
|
||||
movl $0x7fffffff, %eax
|
||||
ret
|
||||
#endif
|
||||
106
lib/libc/mingw/math/x86/ilogbf.S
vendored
106
lib/libc/mingw/math/x86/ilogbf.S
vendored
@ -1,106 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "ilogbf.S"
|
||||
.text
|
||||
.p2align 4,,15
|
||||
.globl __MINGW_USYMBOL(ilogbf)
|
||||
.def __MINGW_USYMBOL(ilogbf); .scl 2; .type 32; .endef
|
||||
#ifdef __x86_64__
|
||||
.seh_proc __MINGW_USYMBOL(ilogbf)
|
||||
#endif
|
||||
__MINGW_USYMBOL(ilogbf):
|
||||
#ifdef __x86_64__
|
||||
/* generated code for:
|
||||
int
|
||||
ilogbf (float x)
|
||||
{
|
||||
__mingw_flt_type_t hlp;
|
||||
int hx, ix;
|
||||
|
||||
hlp.x = x;
|
||||
hx = (int) hlp.val & 0x7fffffff;
|
||||
if (hx < 0x800000)
|
||||
{
|
||||
if (hx == 0)
|
||||
return 0x80000000; // ilogb(0) = FP_ILOGB0
|
||||
for (ix = -126, hx <<= 8; hx > 0; hx <<= 1)
|
||||
ix -= 1;
|
||||
return ix;
|
||||
}
|
||||
if (hx < 0x7f800000)
|
||||
return (hx >> 23) - 127;
|
||||
return 0x7fffffff;
|
||||
} */
|
||||
subq $24, %rsp
|
||||
.seh_stackalloc 24
|
||||
.seh_endprologue
|
||||
movss %xmm0, 12(%rsp)
|
||||
movl 12(%rsp), %edx
|
||||
andl $2147483647, %edx
|
||||
cmpl $8388607, %edx
|
||||
jg .L2
|
||||
testl %edx, %edx
|
||||
je .L6
|
||||
sall $8, %edx
|
||||
movl $-126, %eax
|
||||
testl %edx, %edx
|
||||
jle .L3
|
||||
.p2align 4,,10
|
||||
.L4:
|
||||
addl %edx, %edx
|
||||
subl $1, %eax
|
||||
testl %edx, %edx
|
||||
jg .L4
|
||||
.L3:
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L2:
|
||||
cmpl $2139095039, %edx
|
||||
jle .L10
|
||||
movl $2147483647, %eax
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.p2align 4,,10
|
||||
.L10:
|
||||
sarl $23, %edx
|
||||
leal -127(%rdx), %eax
|
||||
addq $24, %rsp
|
||||
ret
|
||||
.L6:
|
||||
movl $-2147483648, %eax
|
||||
jmp .L3
|
||||
.seh_endproc
|
||||
#else
|
||||
flds 4(%esp)
|
||||
/* I added the following ugly construct because ilogb(+-Inf) is
|
||||
required to return INT_MAX in ISO C99.
|
||||
-- jakub@redhat.com. */
|
||||
fxam /* Is NaN or +-Inf? */
|
||||
fstsw %ax
|
||||
movb $0x45, %dh
|
||||
andb %ah, %dh
|
||||
cmpb $0x05, %dh
|
||||
je 1f /* Is +-Inf, jump. */
|
||||
cmpb $0x01, %dh
|
||||
je 1f /* Is Nan, jump. */
|
||||
|
||||
fxtract
|
||||
pushl %eax
|
||||
fstp %st
|
||||
|
||||
fistpl (%esp)
|
||||
fwait
|
||||
popl %eax
|
||||
|
||||
ret
|
||||
|
||||
1: fstp %st
|
||||
movl $0x7fffffff, %eax
|
||||
ret
|
||||
#endif
|
||||
85
lib/libc/mingw/math/x86/log1p.S
vendored
85
lib/libc/mingw/math/x86/log1p.S
vendored
@ -1,85 +0,0 @@
|
||||
/**
|
||||
* This file has no copyright assigned and is placed in the Public Domain.
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
.file "log1p.S"
|
||||
.text
|
||||
#ifdef __x86_64__
|
||||
.align 8
|
||||
#else
|
||||
.align 4
|
||||
#endif
|
||||
/* The fyl2xp1 can only be used for values in
|
||||
-1 + sqrt(2) / 2 <= x <= 1 - sqrt(2) / 2
|
||||
0.29 is a safe value.
|
||||
*/
|
||||
limit: .double 0.29
|
||||
one: .double 1.0
|
||||
/*
|
||||
* Use the fyl2xp1 function when the argument is in the range -0.29 to 0.29,
|
||||
* otherwise fyl2x with the needed extra computation.
|
||||
*/
|
||||
.globl __MINGW_USYMBOL(log1p)
|
||||
.def __MINGW_USYMBOL(log1p); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(log1p):
|
||||
#ifdef __x86_64__
|
||||
movsd %xmm0,-16(%rsp)
|
||||
fldln2
|
||||
fldl -16(%rsp)
|
||||
fxam
|
||||
fnstsw
|
||||
fld %st
|
||||
sahf
|
||||
jc 3f // in case x is NaN or ±Inf
|
||||
|
||||
4: fabs
|
||||
fcompl limit(%rip)
|
||||
fnstsw
|
||||
sahf
|
||||
jc 2f
|
||||
faddl one(%rip)
|
||||
fyl2x
|
||||
fstpl -16(%rsp)
|
||||
movsd -16(%rsp),%xmm0
|
||||
ret
|
||||
|
||||
2: fyl2xp1
|
||||
fstpl -16(%rsp)
|
||||
movsd -16(%rsp),%xmm0
|
||||
ret
|
||||
|
||||
3: jp 4b // in case x is ±Inf
|
||||
fstp %st(1)
|
||||
fstp %st(1)
|
||||
fstpl -16(%rsp)
|
||||
movsd -16(%rsp),%xmm0
|
||||
ret
|
||||
#else
|
||||
fldln2
|
||||
fldl 4(%esp)
|
||||
fxam
|
||||
fnstsw
|
||||
fld %st
|
||||
sahf
|
||||
jc 3f // in case x is NaN or ±Inf
|
||||
|
||||
4: fabs
|
||||
fcompl limit
|
||||
fnstsw
|
||||
sahf
|
||||
jc 2f
|
||||
faddl one
|
||||
fyl2x
|
||||
ret
|
||||
|
||||
2: fyl2xp1
|
||||
ret
|
||||
|
||||
3: jp 4b // in case x is ±Inf
|
||||
fstp %st(1)
|
||||
fstp %st(1)
|
||||
ret
|
||||
#endif
|
||||
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user