mirror of
https://github.com/ziglang/zig.git
synced 2026-02-20 16:24:51 +00:00
mingw: Update MinGW-w64 sources to 38c8142f660b6ba11e7c408f2de1e9f8bfaf839e.
This commit is contained in:
parent
0979e56bd2
commit
879bc2e5cb
@ -17,14 +17,6 @@
|
||||
// really matter here because this is a no-op anyway.
|
||||
static void __guard_check_icall_dummy(void) {}
|
||||
|
||||
// When CFGuard is not active, directly tail-call the target address, which
|
||||
// is passed via %rax.
|
||||
__asm__(
|
||||
".globl __guard_dispatch_icall_dummy\n"
|
||||
"__guard_dispatch_icall_dummy:\n"
|
||||
" jmp *%rax\n"
|
||||
);
|
||||
|
||||
// This is intentionally declared as _not_ a function pointer, so that the
|
||||
// jmp instruction is not included as a valid call target for CFGuard.
|
||||
extern void *__guard_dispatch_icall_dummy;
|
||||
|
||||
8
lib/libc/mingw/crt/CRT_fp10.c
vendored
8
lib/libc/mingw/crt/CRT_fp10.c
vendored
@ -8,19 +8,11 @@ void _fpreset (void);
|
||||
|
||||
void _fpreset (void)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
__asm__ __volatile__ (
|
||||
"vmsr fpscr, %0\n\t" : : "r"(0 /* INITIAL_FPSCR */));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
__asm__ __volatile__ (
|
||||
"msr fpcr, %0\n\t" : : "r"(0LL /* INITIAL_FPSCR */));
|
||||
#else
|
||||
#ifdef __GNUC__
|
||||
__asm__ ("fninit");
|
||||
#else /* msvc: */
|
||||
__asm fninit;
|
||||
#endif
|
||||
#endif
|
||||
}
|
||||
|
||||
#ifdef __GNUC__
|
||||
|
||||
129
lib/libc/mingw/crt/crtdll.c
vendored
129
lib/libc/mingw/crt/crtdll.c
vendored
@ -4,12 +4,6 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#ifndef _DLL
|
||||
#define _DLL
|
||||
#endif
|
||||
|
||||
#include <oscalls.h>
|
||||
#include <internal.h>
|
||||
#include <stdlib.h>
|
||||
@ -19,20 +13,14 @@
|
||||
#include <crtdbg.h>
|
||||
|
||||
#ifndef _CRTIMP
|
||||
#ifdef CRTDLL
|
||||
#define _CRTIMP __declspec(dllexport)
|
||||
#else
|
||||
#ifdef _DLL
|
||||
#define _CRTIMP __declspec(dllimport)
|
||||
#else
|
||||
#define _CRTIMP
|
||||
#endif
|
||||
#endif
|
||||
#endif
|
||||
#include <sect_attribs.h>
|
||||
#include <locale.h>
|
||||
|
||||
extern void __cdecl _initterm(_PVFV *,_PVFV *);
|
||||
#if defined(__x86_64__) && !defined(__SEH__)
|
||||
extern int __mingw_init_ehandler (void);
|
||||
#endif
|
||||
extern void __main ();
|
||||
extern void _pei386_runtime_relocator (void);
|
||||
extern _PIFV __xi_a[];
|
||||
@ -50,20 +38,6 @@ static _onexit_table_t atexit_table;
|
||||
|
||||
extern int __mingw_app_type;
|
||||
|
||||
extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved);
|
||||
|
||||
extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
|
||||
|
||||
static int pre_c_init (void);
|
||||
|
||||
_CRTALLOC(".CRT$XIAA") _PIFV pcinit = pre_c_init;
|
||||
|
||||
static int
|
||||
pre_c_init (void)
|
||||
{
|
||||
return _initialize_onexit_table(&atexit_table);
|
||||
}
|
||||
|
||||
WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_DETACH)
|
||||
@ -77,10 +51,11 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
void *lock_free = NULL;
|
||||
void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase;
|
||||
int nested = FALSE;
|
||||
BOOL nested = FALSE;
|
||||
int ret = 0;
|
||||
|
||||
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,
|
||||
fiberid, 0)) != 0)
|
||||
while ((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock,
|
||||
fiberid, NULL)) != 0)
|
||||
{
|
||||
if (lock_free == fiberid)
|
||||
{
|
||||
@ -89,25 +64,37 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
}
|
||||
Sleep(1000);
|
||||
}
|
||||
if (__native_startup_state == __initializing)
|
||||
if (__native_startup_state != __uninitialized)
|
||||
{
|
||||
_amsg_exit (31);
|
||||
}
|
||||
else if (__native_startup_state == __uninitialized)
|
||||
else
|
||||
{
|
||||
__native_startup_state = __initializing;
|
||||
|
||||
if (_initterm_e (__xi_a, __xi_z) != 0)
|
||||
return FALSE;
|
||||
}
|
||||
if (__native_startup_state == __initializing)
|
||||
{
|
||||
_pei386_runtime_relocator ();
|
||||
#if defined(__x86_64__) && !defined(__SEH__)
|
||||
__mingw_init_ehandler ();
|
||||
#endif
|
||||
ret = _initialize_onexit_table (&atexit_table);
|
||||
if (ret != 0)
|
||||
goto i__leave;
|
||||
ret = _initterm_e (__xi_a, __xi_z);
|
||||
if (ret != 0)
|
||||
goto i__leave;
|
||||
_initterm (__xc_a, __xc_z);
|
||||
__main ();
|
||||
|
||||
__native_startup_state = __initialized;
|
||||
}
|
||||
i__leave:
|
||||
if (! nested)
|
||||
{
|
||||
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
||||
(void) InterlockedExchangePointer (&__native_startup_lock, NULL);
|
||||
}
|
||||
if (ret != 0)
|
||||
{
|
||||
return FALSE;
|
||||
}
|
||||
if (__dyn_tls_init_callback != NULL)
|
||||
{
|
||||
@ -118,8 +105,16 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
else if (dwReason == DLL_PROCESS_DETACH)
|
||||
{
|
||||
void *lock_free = NULL;
|
||||
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,(PVOID) 1, 0)) != 0)
|
||||
void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase;
|
||||
BOOL nested = FALSE;
|
||||
|
||||
while ((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock, fiberid, NULL)) != 0)
|
||||
{
|
||||
if (lock_free == fiberid)
|
||||
{
|
||||
nested = TRUE;
|
||||
break;
|
||||
}
|
||||
Sleep(1000);
|
||||
}
|
||||
if (__native_startup_state != __initialized)
|
||||
@ -130,84 +125,56 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
_execute_onexit_table(&atexit_table);
|
||||
__native_startup_state = __uninitialized;
|
||||
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
||||
}
|
||||
if (! nested)
|
||||
{
|
||||
(void) InterlockedExchangePointer (&__native_startup_lock, NULL);
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
|
||||
|
||||
WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID);
|
||||
#if defined(__x86_64__) && !defined(__SEH__)
|
||||
int __mingw_init_ehandler (void);
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(_X86_)
|
||||
/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
|
||||
opts in DllMain or in functions called from DllMain. */
|
||||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
__attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */
|
||||
WINBOOL WINAPI
|
||||
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
__mingw_app_type = 0;
|
||||
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
|
||||
}
|
||||
|
||||
static
|
||||
#if defined(__i386__) || defined(_X86_)
|
||||
/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
|
||||
opts in DllMain/DllEntryPoint or in functions called from DllMain/DllEntryPoint. */
|
||||
__attribute__((force_align_arg_pointer))
|
||||
#endif
|
||||
__declspec(noinline) WINBOOL
|
||||
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||
{
|
||||
WINBOOL retcode = TRUE;
|
||||
|
||||
__mingw_app_type = 0;
|
||||
__native_dllmain_reason = dwReason;
|
||||
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)
|
||||
if (dwReason == DLL_PROCESS_DETACH && __proc_attached <= 0)
|
||||
{
|
||||
retcode = FALSE;
|
||||
goto i__leave;
|
||||
}
|
||||
_pei386_runtime_relocator ();
|
||||
|
||||
#if defined(__x86_64__) && !defined(__SEH__)
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
__mingw_init_ehandler ();
|
||||
#endif
|
||||
|
||||
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
|
||||
{
|
||||
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
||||
if (!retcode)
|
||||
goto i__leave;
|
||||
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
||||
if (! retcode)
|
||||
{
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||
goto i__leave;
|
||||
}
|
||||
}
|
||||
if (dwReason == DLL_PROCESS_ATTACH)
|
||||
__main ();
|
||||
retcode = DllMain(hDllHandle,dwReason,lpreserved);
|
||||
if (dwReason == DLL_PROCESS_ATTACH && ! retcode)
|
||||
{
|
||||
DllMain (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||
DllEntryPoint (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||
}
|
||||
if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH)
|
||||
{
|
||||
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
||||
if (_CRT_INIT (hDllHandle, dwReason, lpreserved) == FALSE)
|
||||
retcode = FALSE;
|
||||
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
||||
}
|
||||
i__leave:
|
||||
__native_dllmain_reason = UINT_MAX;
|
||||
return retcode ;
|
||||
}
|
||||
#endif
|
||||
|
||||
int __cdecl atexit (_PVFV func)
|
||||
{
|
||||
|
||||
15
lib/libc/mingw/crt/crtexe.c
vendored
15
lib/libc/mingw/crt/crtexe.c
vendored
@ -4,13 +4,6 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#undef CRTDLL
|
||||
#ifndef _DLL
|
||||
#define _DLL
|
||||
#endif
|
||||
|
||||
#define SPECIAL_CRTEXE
|
||||
|
||||
#include <oscalls.h>
|
||||
#include <internal.h>
|
||||
#include <process.h>
|
||||
@ -211,9 +204,9 @@ __tmainCRTStartup (void)
|
||||
{
|
||||
void *lock_free = NULL;
|
||||
void *fiberid = ((PNT_TIB)NtCurrentTeb())->StackBase;
|
||||
int nested = FALSE;
|
||||
while((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,
|
||||
fiberid, 0)) != 0)
|
||||
BOOL nested = FALSE;
|
||||
while((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock,
|
||||
fiberid, NULL)) != 0)
|
||||
{
|
||||
if (lock_free == fiberid)
|
||||
{
|
||||
@ -242,7 +235,7 @@ __tmainCRTStartup (void)
|
||||
}
|
||||
_ASSERTE(__native_startup_state == __initialized);
|
||||
if (! nested)
|
||||
(VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
||||
(VOID)InterlockedExchangePointer (&__native_startup_lock, NULL);
|
||||
|
||||
if (__dyn_tls_init_callback != NULL)
|
||||
__dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL);
|
||||
|
||||
1
lib/libc/mingw/crt/crtexewin.c
vendored
1
lib/libc/mingw/crt/crtexewin.c
vendored
@ -56,7 +56,6 @@ int _tmain (int __UNUSED_PARAM(argc),
|
||||
|
||||
{
|
||||
STARTUPINFO StartupInfo;
|
||||
memset (&StartupInfo, 0, sizeof (STARTUPINFO));
|
||||
GetStartupInfo (&StartupInfo);
|
||||
if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW)
|
||||
nShowCmd = StartupInfo.wShowWindow;
|
||||
|
||||
4
lib/libc/mingw/crt/dll_argv.c
vendored
4
lib/libc/mingw/crt/dll_argv.c
vendored
@ -4,10 +4,6 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#endif
|
||||
|
||||
#include <internal.h>
|
||||
|
||||
extern int _dowildcard;
|
||||
|
||||
4
lib/libc/mingw/crt/dllargv.c
vendored
4
lib/libc/mingw/crt/dllargv.c
vendored
@ -4,10 +4,6 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#endif
|
||||
|
||||
#include <internal.h>
|
||||
|
||||
int __CRTDECL
|
||||
|
||||
4
lib/libc/mingw/crt/natstart.c
vendored
4
lib/libc/mingw/crt/natstart.c
vendored
@ -10,5 +10,5 @@
|
||||
_PGLOBAL
|
||||
volatile unsigned int __native_dllmain_reason = UINT_MAX;
|
||||
volatile unsigned int __native_vcclrit_reason = UINT_MAX;
|
||||
volatile __enative_startup_state __native_startup_state;
|
||||
volatile void *__native_startup_lock;
|
||||
volatile __enative_startup_state __native_startup_state = __uninitialized;
|
||||
void *volatile __native_startup_lock = NULL;
|
||||
|
||||
4
lib/libc/mingw/crt/tlssup.c
vendored
4
lib/libc/mingw/crt/tlssup.c
vendored
@ -6,10 +6,6 @@
|
||||
* Written by Kai Tietz <kai.tietz@onevision.com>
|
||||
*/
|
||||
|
||||
#ifdef CRTDLL
|
||||
#undef CRTDLL
|
||||
#endif
|
||||
|
||||
#include <sect_attribs.h>
|
||||
|
||||
#ifndef WIN32_LEAN_AND_MEAN
|
||||
|
||||
3
lib/libc/mingw/gdtoa/strtodnrp.c
vendored
3
lib/libc/mingw/gdtoa/strtodnrp.c
vendored
@ -85,8 +85,7 @@ double __cdecl
|
||||
__mingw_strtod (const char * __restrict__ src, char ** __restrict__ endptr)
|
||||
__attribute__((alias("__strtod")));
|
||||
|
||||
#if !(defined(_AMD64_) || defined(__x86_64__) || \
|
||||
defined(_X86_) || defined(__i386__))
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
/* For systems other than x86, where long double == double, provide the
|
||||
* long double functions as aliases to __strtod. */
|
||||
|
||||
|
||||
23
lib/libc/mingw/gdtoa/strtopx.c
vendored
23
lib/libc/mingw/gdtoa/strtopx.c
vendored
@ -53,8 +53,19 @@ THIS SOFTWARE.
|
||||
#define _4 0
|
||||
#endif
|
||||
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
/* For ARM, where long double == double, provide the long double function as
|
||||
* an alias for __strtod. Do this in a separate object file from other
|
||||
* functions, to avoid linker conflicts if object files import both 'strtold'
|
||||
* from libucrt*.a and the object file providing '__strtod'. */
|
||||
long double __cdecl
|
||||
strtold (const char * __restrict__ src, char ** __restrict__ endptr)
|
||||
{
|
||||
return __mingw_strtod(src, endptr);
|
||||
}
|
||||
|
||||
/* This is specific to the x86 80 bit long doubles. */
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || \
|
||||
#elif defined(_AMD64_) || defined(__x86_64__) || \
|
||||
defined(_X86_) || defined(__i386__)
|
||||
|
||||
typedef union lD {
|
||||
@ -133,14 +144,4 @@ long double __cdecl
|
||||
strtold (const char * __restrict__ src, char ** __restrict__ endptr)
|
||||
__attribute__((alias("__strtold")));
|
||||
|
||||
#elif defined(__arm__) || defined(__aarch64__) || defined(_ARM_) || defined(_ARM64_)
|
||||
/* For ARM, where long double == double, provide the long double function as
|
||||
* an alias for __strtod. Do this in a separate object file from other
|
||||
* functions, to avoid linker conflicts if object files import both 'strtold'
|
||||
* from libucrt*.a and the object file providing '__strtod'. */
|
||||
long double __cdecl
|
||||
strtold (const char * __restrict__ src, char ** __restrict__ endptr)
|
||||
{
|
||||
return __mingw_strtod(src, endptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
156
lib/libc/mingw/include/internal.h
vendored
156
lib/libc/mingw/include/internal.h
vendored
@ -14,6 +14,7 @@ extern "C" {
|
||||
#endif
|
||||
|
||||
#include <limits.h>
|
||||
#include <fenv.h>
|
||||
#include <windows.h>
|
||||
|
||||
#pragma pack(push,_CRT_PACKING)
|
||||
@ -130,7 +131,7 @@ extern "C" {
|
||||
} __enative_startup_state;
|
||||
|
||||
extern volatile __enative_startup_state __native_startup_state;
|
||||
extern volatile void *__native_startup_lock;
|
||||
extern void *volatile __native_startup_lock;
|
||||
|
||||
extern volatile unsigned int __native_dllmain_reason;
|
||||
extern volatile unsigned int __native_vcclrit_reason;
|
||||
@ -154,6 +155,159 @@ extern "C" {
|
||||
# define __mingw_has_sse() 0
|
||||
#endif
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
enum fenv_masks
|
||||
{
|
||||
/* x87 encoding constants */
|
||||
FENV_X_INVALID = 0x00100010,
|
||||
FENV_X_DENORMAL = 0x00200020,
|
||||
FENV_X_ZERODIVIDE = 0x00080008,
|
||||
FENV_X_OVERFLOW = 0x00040004,
|
||||
FENV_X_UNDERFLOW = 0x00020002,
|
||||
FENV_X_INEXACT = 0x00010001,
|
||||
FENV_X_AFFINE = 0x00004000,
|
||||
FENV_X_UP = 0x00800200,
|
||||
FENV_X_DOWN = 0x00400100,
|
||||
FENV_X_24 = 0x00002000,
|
||||
FENV_X_53 = 0x00001000,
|
||||
/* SSE encoding constants: they share the same lower word as their x87 counterparts
|
||||
* but differ in the upper word */
|
||||
FENV_Y_INVALID = 0x10000010,
|
||||
FENV_Y_DENORMAL = 0x20000020,
|
||||
FENV_Y_ZERODIVIDE = 0x08000008,
|
||||
FENV_Y_OVERFLOW = 0x04000004,
|
||||
FENV_Y_UNDERFLOW = 0x02000002,
|
||||
FENV_Y_INEXACT = 0x01000001,
|
||||
FENV_Y_UP = 0x80000200,
|
||||
FENV_Y_DOWN = 0x40000100,
|
||||
FENV_Y_FLUSH = 0x00000400,
|
||||
FENV_Y_FLUSH_SAVE = 0x00000800
|
||||
};
|
||||
|
||||
/* encodes the x87 (represented as x) or SSE (represented as y) control/status word in a ulong */
|
||||
static inline unsigned long fenv_encode(unsigned int x, unsigned int y)
|
||||
{
|
||||
unsigned long ret = 0;
|
||||
|
||||
if (x & _EM_INVALID) ret |= FENV_X_INVALID;
|
||||
if (x & _EM_DENORMAL) ret |= FENV_X_DENORMAL;
|
||||
if (x & _EM_ZERODIVIDE) ret |= FENV_X_ZERODIVIDE;
|
||||
if (x & _EM_OVERFLOW) ret |= FENV_X_OVERFLOW;
|
||||
if (x & _EM_UNDERFLOW) ret |= FENV_X_UNDERFLOW;
|
||||
if (x & _EM_INEXACT) ret |= FENV_X_INEXACT;
|
||||
if (x & _IC_AFFINE) ret |= FENV_X_AFFINE;
|
||||
if (x & _RC_UP) ret |= FENV_X_UP;
|
||||
if (x & _RC_DOWN) ret |= FENV_X_DOWN;
|
||||
if (x & _PC_24) ret |= FENV_X_24;
|
||||
if (x & _PC_53) ret |= FENV_X_53;
|
||||
|
||||
if (y & _EM_INVALID) ret |= FENV_Y_INVALID;
|
||||
if (y & _EM_DENORMAL) ret |= FENV_Y_DENORMAL;
|
||||
if (y & _EM_ZERODIVIDE) ret |= FENV_Y_ZERODIVIDE;
|
||||
if (y & _EM_OVERFLOW) ret |= FENV_Y_OVERFLOW;
|
||||
if (y & _EM_UNDERFLOW) ret |= FENV_Y_UNDERFLOW;
|
||||
if (y & _EM_INEXACT) ret |= FENV_Y_INEXACT;
|
||||
if (y & _RC_UP) ret |= FENV_Y_UP;
|
||||
if (y & _RC_DOWN) ret |= FENV_Y_DOWN;
|
||||
if (y & _DN_FLUSH) ret |= FENV_Y_FLUSH;
|
||||
if (y & _DN_FLUSH_OPERANDS_SAVE_RESULTS) ret |= FENV_Y_FLUSH_SAVE;
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* decodes the x87 (represented as x) or SSE (represented as y) control/status word in a ulong */
|
||||
static inline BOOL fenv_decode(unsigned long enc, unsigned int *x, unsigned int *y)
|
||||
{
|
||||
*x = *y = 0;
|
||||
if ((enc & FENV_X_INVALID) == FENV_X_INVALID) *x |= _EM_INVALID;
|
||||
if ((enc & FENV_X_DENORMAL) == FENV_X_DENORMAL) *x |= _EM_DENORMAL;
|
||||
if ((enc & FENV_X_ZERODIVIDE) == FENV_X_ZERODIVIDE) *x |= _EM_ZERODIVIDE;
|
||||
if ((enc & FENV_X_OVERFLOW) == FENV_X_OVERFLOW) *x |= _EM_OVERFLOW;
|
||||
if ((enc & FENV_X_UNDERFLOW) == FENV_X_UNDERFLOW) *x |= _EM_UNDERFLOW;
|
||||
if ((enc & FENV_X_INEXACT) == FENV_X_INEXACT) *x |= _EM_INEXACT;
|
||||
if ((enc & FENV_X_AFFINE) == FENV_X_AFFINE) *x |= _IC_AFFINE;
|
||||
if ((enc & FENV_X_UP) == FENV_X_UP) *x |= _RC_UP;
|
||||
if ((enc & FENV_X_DOWN) == FENV_X_DOWN) *x |= _RC_DOWN;
|
||||
if ((enc & FENV_X_24) == FENV_X_24) *x |= _PC_24;
|
||||
if ((enc & FENV_X_53) == FENV_X_53) *x |= _PC_53;
|
||||
|
||||
if ((enc & FENV_Y_INVALID) == FENV_Y_INVALID) *y |= _EM_INVALID;
|
||||
if ((enc & FENV_Y_DENORMAL) == FENV_Y_DENORMAL) *y |= _EM_DENORMAL;
|
||||
if ((enc & FENV_Y_ZERODIVIDE) == FENV_Y_ZERODIVIDE) *y |= _EM_ZERODIVIDE;
|
||||
if ((enc & FENV_Y_OVERFLOW) == FENV_Y_OVERFLOW) *y |= _EM_OVERFLOW;
|
||||
if ((enc & FENV_Y_UNDERFLOW) == FENV_Y_UNDERFLOW) *y |= _EM_UNDERFLOW;
|
||||
if ((enc & FENV_Y_INEXACT) == FENV_Y_INEXACT) *y |= _EM_INEXACT;
|
||||
if ((enc & FENV_Y_UP) == FENV_Y_UP) *y |= _RC_UP;
|
||||
if ((enc & FENV_Y_DOWN) == FENV_Y_DOWN) *y |= _RC_DOWN;
|
||||
if ((enc & FENV_Y_FLUSH) == FENV_Y_FLUSH) *y |= _DN_FLUSH;
|
||||
if ((enc & FENV_Y_FLUSH_SAVE) == FENV_Y_FLUSH_SAVE) *y |= _DN_FLUSH_OPERANDS_SAVE_RESULTS;
|
||||
|
||||
return fenv_encode(*x, *y) == enc;
|
||||
}
|
||||
#else
|
||||
static inline unsigned long fenv_encode(unsigned int x, unsigned int y)
|
||||
{
|
||||
/* Encode _EM_DENORMAL as 0x20 for Windows compatibility. */
|
||||
if (y & _EM_DENORMAL)
|
||||
y = (y & ~_EM_DENORMAL) | 0x20;
|
||||
|
||||
return x | y;
|
||||
}
|
||||
|
||||
static inline BOOL fenv_decode(unsigned long enc, unsigned int *x, unsigned int *y)
|
||||
{
|
||||
/* Decode 0x20 as _EM_DENORMAL. */
|
||||
if (enc & 0x20)
|
||||
enc = (enc & ~0x20) | _EM_DENORMAL;
|
||||
|
||||
*x = *y = enc;
|
||||
return TRUE;
|
||||
}
|
||||
#endif
|
||||
|
||||
void __mingw_setfp( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask );
|
||||
void __mingw_setfp_sse( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask );
|
||||
unsigned int __mingw_controlfp(unsigned int newval, unsigned int mask);
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
int __mingw_control87_2(unsigned int, unsigned int, unsigned int *, unsigned int *);
|
||||
#endif
|
||||
|
||||
static inline unsigned int __mingw_statusfp(void)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
unsigned int x86_sw, sse2_sw = 0;
|
||||
__mingw_setfp(NULL, 0, &x86_sw, 0);
|
||||
if (__mingw_has_sse())
|
||||
__mingw_setfp_sse(NULL, 0, &sse2_sw, 0);
|
||||
flags = x86_sw | sse2_sw;
|
||||
#else
|
||||
__mingw_setfp(NULL, 0, &flags, 0);
|
||||
#endif
|
||||
return flags;
|
||||
}
|
||||
|
||||
/* Use naked functions only on Clang. GCC doesn’t support them on ARM targets and
|
||||
* has broken behavior on x86_64 by emitting .seh_endprologue. */
|
||||
#ifndef __clang__
|
||||
|
||||
#define __ASM_DEFINE_FUNC(rettype, name, args, code) \
|
||||
asm(".text\n\t" \
|
||||
".p2align 2\n\t" \
|
||||
".globl " __MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) "\n\t" \
|
||||
".def " __MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) "; .scl 2; .type 32; .endef\n\t" \
|
||||
__MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) ":\n\t" \
|
||||
code "\n\t");
|
||||
|
||||
#else
|
||||
|
||||
#define __ASM_DEFINE_FUNC(rettype, name, args, code) \
|
||||
rettype __attribute__((naked)) name args { \
|
||||
asm(code "\n\t"); \
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
@ -4,7 +4,7 @@
|
||||
PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt)
|
||||
{
|
||||
volatile char *vptr = (volatile char *)ptr;
|
||||
#ifdef __x86_64
|
||||
#if defined(__x86_64__) && !defined(__arm64ec__)
|
||||
__stosb ((PBYTE)((DWORD64)vptr),0,cnt);
|
||||
#else
|
||||
while (cnt != 0)
|
||||
|
||||
1
lib/libc/mingw/libsrc/uuid.c
vendored
1
lib/libc/mingw/libsrc/uuid.c
vendored
@ -15,6 +15,7 @@
|
||||
#include <basetyps.h>
|
||||
|
||||
#include <credentialprovider.h>
|
||||
#include <httprequest.h>
|
||||
#include <functiondiscoverykeys.h>
|
||||
#include <textstor.h>
|
||||
#include <shobjidl.h>
|
||||
|
||||
@ -8,6 +8,6 @@
|
||||
|
||||
void IN6_SET_ADDR_LOOPBACK(struct in6_addr *a)
|
||||
{
|
||||
memset(a->s6_bytes, 0, sizeof(struct in6_addr));
|
||||
*a = (struct in6_addr){0};
|
||||
a->s6_bytes[15] = 1;
|
||||
}
|
||||
|
||||
@ -8,5 +8,5 @@
|
||||
|
||||
void IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *a)
|
||||
{
|
||||
memset(a->s6_bytes, 0, sizeof(struct in6_addr));
|
||||
*a = (struct in6_addr){0};
|
||||
}
|
||||
|
||||
@ -6,14 +6,11 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#undef IN6_SET_ADDR_UNSPECIFIED
|
||||
#define IN6_SET_ADDR_UNSPECIFIED(a) memset((a)->s6_bytes,0,sizeof(struct in6_addr))
|
||||
|
||||
void IN6ADDR_SETANY(struct sockaddr_in6 *a)
|
||||
{
|
||||
a->sin6_family = AF_INET6;
|
||||
a->sin6_port = 0;
|
||||
a->sin6_flowinfo = 0;
|
||||
IN6_SET_ADDR_UNSPECIFIED(&a->sin6_addr);
|
||||
a->sin6_addr = (struct in6_addr){0};
|
||||
a->sin6_scope_id = 0;
|
||||
}
|
||||
|
||||
@ -6,13 +6,6 @@
|
||||
#include <winsock2.h>
|
||||
#include <ws2tcpip.h>
|
||||
|
||||
#undef IN6_SET_ADDR_LOOPBACK
|
||||
#define IN6_SET_ADDR_LOOPBACK(a) \
|
||||
do { \
|
||||
memset((a)->s6_bytes,0,sizeof(struct in6_addr));\
|
||||
(a)->s6_bytes[15] = 1; \
|
||||
} while (0)
|
||||
|
||||
void IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *a)
|
||||
{
|
||||
a->sin6_family = AF_INET6;
|
||||
|
||||
4
lib/libc/mingw/math/arm-common/ldexpl.c
vendored
4
lib/libc/mingw/math/arm-common/ldexpl.c
vendored
@ -8,9 +8,5 @@
|
||||
|
||||
long double ldexpl(long double x, int n)
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return ldexp(x, n);
|
||||
#else
|
||||
#error Not supported on your platform yet
|
||||
#endif
|
||||
}
|
||||
|
||||
@ -4,13 +4,10 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <_mingw_mac.h>
|
||||
#include <math.h>
|
||||
|
||||
.file "_chgignl.S"
|
||||
.text
|
||||
.align 2
|
||||
.globl __MINGW_USYMBOL(_chgsignl)
|
||||
.def __MINGW_USYMBOL(_chgsignl); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(_chgsignl):
|
||||
fneg d0, d0
|
||||
ret
|
||||
void sincosl(long double x, long double *s, long double *c)
|
||||
{
|
||||
*s = sinl(x);
|
||||
*c = cosl(x);
|
||||
}
|
||||
16
lib/libc/mingw/math/arm/_chgsignl.S
vendored
16
lib/libc/mingw/math/arm/_chgsignl.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 "_chgignl.S"
|
||||
.text
|
||||
.align 4
|
||||
.globl __MINGW_USYMBOL(_chgsignl)
|
||||
.def __MINGW_USYMBOL(_chgsignl); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(_chgsignl):
|
||||
vneg.f64 d0, d0
|
||||
bx lr
|
||||
4
lib/libc/mingw/math/cephes_mconf.h
vendored
4
lib/libc/mingw/math/cephes_mconf.h
vendored
@ -66,7 +66,7 @@ extern double __QNAN;
|
||||
#endif
|
||||
|
||||
/*long double*/
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
#define MAXNUML 1.7976931348623158E308
|
||||
#define MAXLOGL 7.09782712893383996843E2
|
||||
#define MINLOGL -7.08396418532264106224E2
|
||||
@ -84,7 +84,7 @@ extern double __QNAN;
|
||||
#define PIL 3.1415926535897932384626L
|
||||
#define PIO2L 1.5707963267948966192313L
|
||||
#define PIO4L 7.8539816339744830961566E-1L
|
||||
#endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */
|
||||
#endif /* __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ */
|
||||
|
||||
#define isfinitel isfinite
|
||||
#define isinfl isinf
|
||||
|
||||
2
lib/libc/mingw/math/coshl.c
vendored
2
lib/libc/mingw/math/coshl.c
vendored
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
#include <math.h>
|
||||
|
||||
long double coshl(long double x)
|
||||
|
||||
2
lib/libc/mingw/math/erfl.c
vendored
2
lib/libc/mingw/math/erfl.c
vendored
@ -108,7 +108,7 @@ Copyright 1984, 1995 by Stephen L. Moshier
|
||||
|
||||
long double erfl(long double x);
|
||||
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
long double erfcl(long double x)
|
||||
{
|
||||
return erfc(x);
|
||||
|
||||
2
lib/libc/mingw/math/fmal.c
vendored
2
lib/libc/mingw/math/fmal.c
vendored
@ -5,7 +5,7 @@
|
||||
*/
|
||||
long double fmal(long double x, long double y, long double z);
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
|
||||
double fma(double x, double y, double z);
|
||||
|
||||
|
||||
2
lib/libc/mingw/math/fp_constsl.c
vendored
2
lib/libc/mingw/math/fp_constsl.c
vendored
@ -16,7 +16,7 @@ const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP };
|
||||
long double nanl (const char *);
|
||||
long double nanl (const char * tagp __attribute__((unused)) )
|
||||
{
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
return nan("");
|
||||
#else
|
||||
return __QNANL.ldouble_val;
|
||||
|
||||
6
lib/libc/mingw/math/fpclassifyl.c
vendored
6
lib/libc/mingw/math/fpclassifyl.c
vendored
@ -6,7 +6,9 @@
|
||||
#include <math.h>
|
||||
|
||||
int __fpclassifyl (long double _x){
|
||||
#if defined(__x86_64__) || defined(_AMD64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
return __fpclassify(_x);
|
||||
#elif defined(_AMD64_) || defined(__x86_64__)
|
||||
__mingw_ldbl_type_t hlp;
|
||||
unsigned int e;
|
||||
hlp.x = _x;
|
||||
@ -23,8 +25,6 @@ int __fpclassifyl (long double _x){
|
||||
return (((hlp.lh.high & 0x7fffffff) | hlp.lh.low) == 0 ?
|
||||
FP_INFINITE : FP_NAN);
|
||||
return FP_NORMAL;
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return __fpclassify(_x);
|
||||
#elif defined(__i386__) || defined(_X86_)
|
||||
unsigned short sw;
|
||||
__asm__ __volatile__ (
|
||||
|
||||
2
lib/libc/mingw/math/frexpl.c
vendored
2
lib/libc/mingw/math/frexpl.c
vendored
@ -5,7 +5,7 @@
|
||||
*/
|
||||
long double frexpl(long double value, int* exp);
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
|
||||
double frexp(double value, int* exp);
|
||||
|
||||
|
||||
6
lib/libc/mingw/math/isnanl.c
vendored
6
lib/libc/mingw/math/isnanl.c
vendored
@ -8,7 +8,9 @@
|
||||
int
|
||||
__isnanl (long double _x)
|
||||
{
|
||||
#if defined(__x86_64__) || defined(_AMD64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
return __isnan(_x);
|
||||
#elif defined(__x86_64__) || defined(_AMD64_)
|
||||
__mingw_ldbl_type_t ld;
|
||||
int xx, signexp;
|
||||
|
||||
@ -18,8 +20,6 @@ __isnanl (long double _x)
|
||||
signexp |= (unsigned int) (xx | (-xx)) >> 31;
|
||||
signexp = 0xfffe - signexp;
|
||||
return (int) ((unsigned int) signexp) >> 16;
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
return __isnan(_x);
|
||||
#elif defined(__i386__) || defined(_X86_)
|
||||
unsigned short _sw;
|
||||
__asm__ __volatile__ ("fxam;"
|
||||
|
||||
2
lib/libc/mingw/math/lgammal.c
vendored
2
lib/libc/mingw/math/lgammal.c
vendored
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
double lgamma(double x);
|
||||
|
||||
long double lgammal(long double x)
|
||||
|
||||
3
lib/libc/mingw/math/llrintl.c
vendored
3
lib/libc/mingw/math/llrintl.c
vendored
@ -9,7 +9,8 @@
|
||||
long long llrintl (long double x)
|
||||
{
|
||||
long long retval = 0ll;
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
#if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__)) || \
|
||||
defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#else
|
||||
int mode = fegetround();
|
||||
|
||||
6
lib/libc/mingw/math/lrintl.c
vendored
6
lib/libc/mingw/math/lrintl.c
vendored
@ -8,10 +8,10 @@
|
||||
long lrintl (long double x)
|
||||
{
|
||||
long retval = 0l;
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
retval = lrint(x);
|
||||
#elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st");
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
2
lib/libc/mingw/math/modff.c
vendored
2
lib/libc/mingw/math/modff.c
vendored
@ -13,7 +13,7 @@ modff (float value, float* iptr)
|
||||
float int_part = 0.0F;
|
||||
/* truncate */
|
||||
/* truncate */
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
#if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
asm volatile ("subq $8, %%rsp\n"
|
||||
"fnstcw 4(%%rsp)\n"
|
||||
"movzwl 4(%%rsp), %%eax\n"
|
||||
|
||||
2
lib/libc/mingw/math/modfl.c
vendored
2
lib/libc/mingw/math/modfl.c
vendored
@ -12,7 +12,7 @@ modfl (long double value, long double* iptr)
|
||||
{
|
||||
long double int_part = 0.0L;
|
||||
/* truncate */
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
#if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
asm volatile ("subq $8, %%rsp\n"
|
||||
"fnstcw 4(%%rsp)\n"
|
||||
"movzwl 4(%%rsp), %%eax\n"
|
||||
|
||||
6
lib/libc/mingw/math/rintl.c
vendored
6
lib/libc/mingw/math/rintl.c
vendored
@ -7,10 +7,10 @@
|
||||
|
||||
long double rintl (long double x) {
|
||||
long double retval = 0.0L;
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x));
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
retval = rint(x);
|
||||
#elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
__asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x));
|
||||
#endif
|
||||
return retval;
|
||||
}
|
||||
|
||||
4
lib/libc/mingw/math/signbitl.c
vendored
4
lib/libc/mingw/math/signbitl.c
vendored
@ -9,11 +9,11 @@
|
||||
|
||||
|
||||
int __signbitl (long double x) {
|
||||
#if defined(__x86_64__) || defined(_AMD64_)
|
||||
#if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
__mingw_ldbl_type_t ld;
|
||||
ld.x = x;
|
||||
return ((ld.lh.sign_exponent & 0x8000) != 0);
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
|
||||
return __signbit(x);
|
||||
#elif defined(__i386__) || defined(_X86_)
|
||||
unsigned short sw;
|
||||
|
||||
2
lib/libc/mingw/math/sinhl.c
vendored
2
lib/libc/mingw/math/sinhl.c
vendored
@ -6,7 +6,7 @@
|
||||
#include "cephes_mconf.h"
|
||||
#include <errno.h>
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
#include <math.h>
|
||||
|
||||
long double sinhl(long double x)
|
||||
|
||||
2
lib/libc/mingw/math/sqrt.def.h
vendored
2
lib/libc/mingw/math/sqrt.def.h
vendored
@ -77,7 +77,7 @@ __FLT_ABI (sqrt) (__FLT_TYPE x)
|
||||
#else
|
||||
asm volatile ("fsqrtd %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x));
|
||||
#endif
|
||||
#elif defined(__aarch64__) || defined(_ARM64_)
|
||||
#elif defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_)
|
||||
#if _NEW_COMPLEX_FLOAT
|
||||
asm volatile ("fsqrt %s[dst], %s[src]\n" : [dst] "=w" (res) : [src] "w" (x));
|
||||
#else
|
||||
|
||||
2
lib/libc/mingw/math/tanhl.c
vendored
2
lib/libc/mingw/math/tanhl.c
vendored
@ -8,7 +8,7 @@
|
||||
#define _SET_ERRNO(x)
|
||||
#endif
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
#include <math.h>
|
||||
|
||||
long double tanhl(long double x)
|
||||
|
||||
2
lib/libc/mingw/math/tgammal.c
vendored
2
lib/libc/mingw/math/tgammal.c
vendored
@ -5,7 +5,7 @@
|
||||
*/
|
||||
#include "cephes_mconf.h"
|
||||
|
||||
#if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
double tgamma(double x);
|
||||
|
||||
long double tgammal(long double x)
|
||||
|
||||
7
lib/libc/mingw/math/truncl.c
vendored
7
lib/libc/mingw/math/truncl.c
vendored
@ -3,21 +3,20 @@
|
||||
* 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>
|
||||
|
||||
long double
|
||||
truncl (long double _x)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__)
|
||||
#if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__
|
||||
return trunc(_x);
|
||||
#else
|
||||
long double retval = 0.0L;
|
||||
unsigned short saved_cw;
|
||||
unsigned short tmp_cw;
|
||||
__asm__ __volatile__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */
|
||||
tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||
| FE_TOWARDZERO;
|
||||
tmp_cw = saved_cw | 0xc00; /* round towards zero */
|
||||
__asm__ __volatile__ ("fldcw %0;" : : "m" (tmp_cw));
|
||||
__asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */
|
||||
__asm__ __volatile__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */
|
||||
|
||||
3
lib/libc/mingw/math/x86/pow.def.h
vendored
3
lib/libc/mingw/math/x86/pow.def.h
vendored
@ -69,11 +69,8 @@
|
||||
#include "../complex/complex_internal.h"
|
||||
#include <errno.h>
|
||||
#include <limits.h>
|
||||
#include <fenv.h>
|
||||
#include <math.h>
|
||||
#include <errno.h>
|
||||
#define FE_ROUNDING_MASK \
|
||||
(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)
|
||||
|
||||
static __FLT_TYPE
|
||||
internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr)
|
||||
|
||||
18
lib/libc/mingw/misc/dllentrypoint.c
vendored
18
lib/libc/mingw/misc/dllentrypoint.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 <oscalls.h>
|
||||
#define _DECL_DLLMAIN
|
||||
#include <process.h>
|
||||
|
||||
BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID);
|
||||
|
||||
BOOL WINAPI DllEntryPoint (HANDLE __UNUSED_PARAM(hDllHandle),
|
||||
DWORD __UNUSED_PARAM(dwReason),
|
||||
LPVOID __UNUSED_PARAM(lpreserved))
|
||||
{
|
||||
return TRUE;
|
||||
}
|
||||
40
lib/libc/mingw/misc/feclearexcept.c
vendored
40
lib/libc/mingw/misc/feclearexcept.c
vendored
@ -4,44 +4,18 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <fenv.h>
|
||||
#include <internal.h>
|
||||
|
||||
/* 7.6.2.1
|
||||
The feclearexcept function clears the supported exceptions
|
||||
represented by its argument. */
|
||||
|
||||
int feclearexcept (int excepts)
|
||||
int feclearexcept(int flags)
|
||||
{
|
||||
fenv_t _env;
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
_env.__cw &= ~(excepts & FE_ALL_EXCEPT);
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
(void) _env;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
fpcr &= ~(excepts & FE_ALL_EXCEPT);
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
#else
|
||||
int _mxcsr;
|
||||
if (excepts == FE_ALL_EXCEPT)
|
||||
{
|
||||
__asm__ volatile ("fnclex");
|
||||
}
|
||||
else
|
||||
{
|
||||
__asm__ volatile ("fnstenv %0" : "=m" (_env));
|
||||
_env.__status_word &= ~(excepts & FE_ALL_EXCEPT);
|
||||
__asm__ volatile ("fldenv %0" : : "m" (_env));
|
||||
}
|
||||
if (__mingw_has_sse ())
|
||||
{
|
||||
__asm__ volatile ("stmxcsr %0" : "=m" (_mxcsr));
|
||||
_mxcsr &= ~(((excepts & FE_ALL_EXCEPT)));
|
||||
__asm__ volatile ("ldmxcsr %0" : : "m" (_mxcsr));
|
||||
}
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return (0);
|
||||
fenv_t env;
|
||||
|
||||
fegetenv(&env);
|
||||
flags &= FE_ALL_EXCEPT;
|
||||
env._Fe_stat &= ~fenv_encode(flags, flags);
|
||||
return fesetenv(&env);
|
||||
}
|
||||
|
||||
31
lib/libc/mingw/misc/fegetenv.c
vendored
31
lib/libc/mingw/misc/fegetenv.c
vendored
@ -4,34 +4,25 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <fenv.h>
|
||||
#include <internal.h>
|
||||
|
||||
/* 7.6.4.1
|
||||
The fegetenv function stores the current floating-point environment
|
||||
in the object pointed to by envp. */
|
||||
|
||||
int fegetenv (fenv_t * envp)
|
||||
int fegetenv(fenv_t *env)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (*envp));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
envp->__cw = fpcr;
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
unsigned int x87, sse;
|
||||
__mingw_control87_2(0, 0, &x87, &sse);
|
||||
env->_Fe_ctl = fenv_encode(x87, sse);
|
||||
__mingw_setfp(NULL, 0, &x87, 0);
|
||||
__mingw_setfp_sse(NULL, 0, &sse, 0);
|
||||
env->_Fe_stat = fenv_encode(x87, sse);
|
||||
#else
|
||||
__asm__ __volatile__ ("fnstenv %0;": "=m" (*envp));
|
||||
/* fnstenv sets control word to non-stop for all exceptions, so we
|
||||
need to reload our env to restore the original mask. */
|
||||
__asm__ __volatile__ ("fldenv %0" : : "m" (*envp));
|
||||
if (__mingw_has_sse ())
|
||||
{
|
||||
int _mxcsr;
|
||||
__asm__ __volatile__ ("stmxcsr %0" : "=m" (_mxcsr));
|
||||
envp->__unused0 = (((unsigned int) _mxcsr) >> 16);
|
||||
envp->__unused1 = (((unsigned int) _mxcsr) & 0xffff);
|
||||
}
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
env->_Fe_ctl = fenv_encode(0, __mingw_controlfp(0, 0));
|
||||
env->_Fe_stat = fenv_encode(0, __mingw_statusfp());
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
29
lib/libc/mingw/misc/fegetexceptflag.c
vendored
29
lib/libc/mingw/misc/fegetexceptflag.c
vendored
@ -12,26 +12,15 @@
|
||||
representation of the exception flags indicated by the argument
|
||||
excepts in the object pointed to by the argument flagp. */
|
||||
|
||||
int fegetexceptflag (fexcept_t * flagp, int excepts)
|
||||
int fegetexceptflag(fexcept_t *status, int excepts)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
*flagp = _env.__cw & excepts & FE_ALL_EXCEPT;
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
*flagp = fpcr & excepts & FE_ALL_EXCEPT;
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
unsigned int x87, sse;
|
||||
__mingw_setfp(NULL, 0, &x87, 0);
|
||||
__mingw_setfp_sse(NULL, 0, &sse, 0);
|
||||
*status = fenv_encode(x87 & excepts, sse & excepts);
|
||||
#else
|
||||
int _mxcsr;
|
||||
unsigned short _status;
|
||||
|
||||
__asm__ volatile ("fnstsw %0" : "=am" (_status));
|
||||
_mxcsr = 0;
|
||||
if (__mingw_has_sse ())
|
||||
__asm__ volatile ("stmxcsr %0" : "=m" (_mxcsr));
|
||||
|
||||
*flagp = (_mxcsr | _status) & excepts & FE_ALL_EXCEPT;
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
*status = fenv_encode(0, __mingw_statusfp() & excepts);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
19
lib/libc/mingw/misc/fegetround.c
vendored
19
lib/libc/mingw/misc/fegetround.c
vendored
@ -3,26 +3,13 @@
|
||||
* 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 <internal.h>
|
||||
|
||||
/* 7.6.3.1
|
||||
The fegetround function returns the value of the rounding direction
|
||||
macro representing the current rounding direction. */
|
||||
|
||||
int
|
||||
fegetround (void)
|
||||
int fegetround(void)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
return (_env.__cw & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
return (fpcr & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO));
|
||||
#else
|
||||
int _control;
|
||||
__asm__ volatile ("fnstcw %0" : "=m" (*&_control));
|
||||
return (_control & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO));
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return __mingw_controlfp(0, 0) & _MCW_RC;
|
||||
}
|
||||
|
||||
23
lib/libc/mingw/misc/feholdexcept.c
vendored
23
lib/libc/mingw/misc/feholdexcept.c
vendored
@ -11,25 +11,8 @@
|
||||
flags, and then installs a non-stop (continue on exceptions) mode,
|
||||
if available, for all exceptions. */
|
||||
|
||||
int feholdexcept (fenv_t * envp)
|
||||
int feholdexcept(fenv_t *env)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
envp->__cw = _env.__cw;
|
||||
_env.__cw &= ~(FE_ALL_EXCEPT);
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
envp->__cw = fpcr;
|
||||
fpcr &= ~(FE_ALL_EXCEPT);
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
#else
|
||||
__asm__ __volatile__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */
|
||||
/* fnstenv sets control word to non-stop for all exceptions, so all we
|
||||
need to do is clear the exception flags. */
|
||||
__asm__ __volatile__ ("fnclex");
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
fegetenv(env);
|
||||
return feclearexcept(FE_ALL_EXCEPT);
|
||||
}
|
||||
|
||||
32
lib/libc/mingw/misc/feraiseexcept.c
vendored
32
lib/libc/mingw/misc/feraiseexcept.c
vendored
@ -3,7 +3,7 @@
|
||||
* 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 <internal.h>
|
||||
|
||||
/* 7.6.2.3
|
||||
The feraiseexcept function raises the supported exceptions
|
||||
@ -13,24 +13,16 @@
|
||||
the inexact exception whenever it raises the overflow
|
||||
or underflow exception is implementation-defined. */
|
||||
|
||||
int feraiseexcept (int excepts)
|
||||
int feraiseexcept(int flags)
|
||||
{
|
||||
fenv_t _env;
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
_env.__cw |= excepts & FE_ALL_EXCEPT;
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
(void) _env;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
fpcr |= excepts & FE_ALL_EXCEPT;
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
#else
|
||||
__asm__ volatile ("fnstenv %0;" : "=m" (_env));
|
||||
_env.__status_word |= excepts & FE_ALL_EXCEPT;
|
||||
__asm__ volatile ("fldenv %0;"
|
||||
"fwait;" : : "m" (_env));
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
fenv_t env;
|
||||
|
||||
flags &= FE_ALL_EXCEPT;
|
||||
fegetenv(&env);
|
||||
env._Fe_stat |= fenv_encode(flags, flags);
|
||||
fesetenv(&env);
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
__asm__ volatile ("fwait\n\t");
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
91
lib/libc/mingw/misc/fesetenv.c
vendored
91
lib/libc/mingw/misc/fesetenv.c
vendored
@ -4,11 +4,24 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <_mingw.h>
|
||||
#include <fenv.h>
|
||||
#include <float.h>
|
||||
#include <internal.h>
|
||||
|
||||
/* The FE_DFL_ENV macro is required by standard.
|
||||
fesetenv will use the environment set at app startup.*/
|
||||
const fenv_t __mingw_fe_dfl_env = { 0, 0 };
|
||||
|
||||
/* The C99 standard (7.6.9) allows us to define implementation-specific macros for
|
||||
different fp environments */
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
/* The default Intel x87 floating point environment (64-bit mantissa) */
|
||||
const fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 };
|
||||
|
||||
/* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */
|
||||
const fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 };
|
||||
|
||||
#endif
|
||||
|
||||
/* 7.6.4.3
|
||||
The fesetenv function establishes the floating-point environment
|
||||
represented by the object pointed to by envp. The argument envp
|
||||
@ -22,61 +35,27 @@
|
||||
extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void);
|
||||
extern void _fpreset(void);
|
||||
|
||||
int fesetenv (const fenv_t * envp)
|
||||
int fesetenv(const fenv_t *env)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
if (envp == FE_DFL_ENV)
|
||||
/* Use the choice made at app startup */
|
||||
_fpreset();
|
||||
else
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (*envp));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
if (envp == FE_DFL_ENV) {
|
||||
/* Use the choice made at app startup */
|
||||
_fpreset();
|
||||
} else {
|
||||
unsigned __int64 fpcr = envp->__cw;
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
}
|
||||
#else
|
||||
if (envp == FE_PC64_ENV)
|
||||
/*
|
||||
* fninit initializes the control register to 0x37f,
|
||||
* the status register to zero and the tag word to 0FFFFh.
|
||||
* The other registers are unaffected.
|
||||
*/
|
||||
__asm__ __volatile__ ("fninit");
|
||||
unsigned int x87_cw, cw, x87_stat, stat;
|
||||
unsigned int mask = ~0u;
|
||||
|
||||
else if (envp == FE_PC53_ENV)
|
||||
/*
|
||||
* MS _fpreset() does same *except* it sets control word
|
||||
* to 0x27f (53-bit precision).
|
||||
* We force calling _fpreset in msvcrt.dll
|
||||
*/
|
||||
|
||||
(* __MINGW_IMP_SYMBOL(_fpreset))();
|
||||
|
||||
else if (envp == FE_DFL_ENV)
|
||||
/* Use the choice made at app startup */
|
||||
_fpreset();
|
||||
|
||||
else
|
||||
{
|
||||
fenv_t env = *envp;
|
||||
int has_sse = __mingw_has_sse ();
|
||||
int _mxcsr;
|
||||
/*_mxcsr = ((int)envp->__unused0 << 16) | (int)envp->__unused1; *//* mxcsr low and high */
|
||||
if (has_sse)
|
||||
__asm__ ("stmxcsr %0" : "=m" (*&_mxcsr));
|
||||
env.__unused0 = 0xffff;
|
||||
env.__unused1 = 0xffff;
|
||||
__asm__ volatile ("fldenv %0" : : "m" (env)
|
||||
: "st", "st(1)", "st(2)", "st(3)", "st(4)",
|
||||
"st(5)", "st(6)", "st(7)");
|
||||
if (has_sse)
|
||||
__asm__ volatile ("ldmxcsr %0" : : "m" (*&_mxcsr));
|
||||
if (!env->_Fe_ctl && !env->_Fe_stat) {
|
||||
_fpreset();
|
||||
return 0;
|
||||
}
|
||||
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
if (!fenv_decode(env->_Fe_ctl, &x87_cw, &cw))
|
||||
return 1;
|
||||
if (!fenv_decode(env->_Fe_stat, &x87_stat, &stat))
|
||||
return 1;
|
||||
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
__mingw_setfp(&x87_cw, mask, &x87_stat, ~0);
|
||||
if (__mingw_has_sse())
|
||||
__mingw_setfp_sse(&cw, mask, &stat, ~0);
|
||||
#else
|
||||
__mingw_setfp(&cw, mask, &stat, ~0);
|
||||
#endif
|
||||
return 0;
|
||||
}
|
||||
|
||||
42
lib/libc/mingw/misc/fesetexceptflag.c
vendored
42
lib/libc/mingw/misc/fesetexceptflag.c
vendored
@ -4,7 +4,6 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
#include <fenv.h>
|
||||
#include <internal.h>
|
||||
|
||||
/* 7.6.2.4
|
||||
@ -16,39 +15,16 @@
|
||||
represented by the argument excepts. This function does not raise
|
||||
exceptions, but only sets the state of the flags. */
|
||||
|
||||
int fesetexceptflag (const fexcept_t * flagp, int excepts)
|
||||
int fesetexceptflag(const fexcept_t *status, int excepts)
|
||||
{
|
||||
fenv_t _env;
|
||||
fenv_t env;
|
||||
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
excepts &= FE_ALL_EXCEPT;
|
||||
if(!excepts)
|
||||
return 0;
|
||||
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
_env.__cw &= ~excepts;
|
||||
_env.__cw |= (*flagp & excepts);
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
(void) _env;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
fpcr &= ~excepts;
|
||||
fpcr |= (*flagp & excepts);
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
#else
|
||||
__asm__ volatile ("fnstenv %0;" : "=m" (_env));
|
||||
_env.__status_word &= ~excepts;
|
||||
_env.__status_word |= (*flagp & excepts);
|
||||
__asm__ volatile ("fldenv %0;" : : "m" (_env));
|
||||
|
||||
if (__mingw_has_sse ())
|
||||
{
|
||||
int sse_cw;
|
||||
__asm__ volatile ("stmxcsr %0;" : "=m" (sse_cw));
|
||||
sse_cw &= ~(excepts << 7);
|
||||
sse_cw |= ((*flagp & excepts) << 7);
|
||||
__asm__ volatile ("ldmxcsr %0" : : "m" (sse_cw));
|
||||
}
|
||||
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
fegetenv(&env);
|
||||
env._Fe_stat &= ~fenv_encode(excepts, excepts);
|
||||
env._Fe_stat |= *status & fenv_encode(excepts, excepts);
|
||||
return fesetenv(&env);
|
||||
}
|
||||
|
||||
43
lib/libc/mingw/misc/fesetround.c
vendored
43
lib/libc/mingw/misc/fesetround.c
vendored
@ -13,43 +13,10 @@
|
||||
to the value of a rounding direction macro, the rounding direction
|
||||
is not changed. */
|
||||
|
||||
int fesetround (int mode)
|
||||
int fesetround(int round_mode)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
fenv_t _env;
|
||||
if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) != 0)
|
||||
return -1;
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
_env.__cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO);
|
||||
_env.__cw |= mode;
|
||||
__asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env));
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) != 0)
|
||||
return -1;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
fpcr &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO);
|
||||
fpcr |= mode;
|
||||
__asm__ volatile ("msr fpcr, %0" : : "r" (fpcr));
|
||||
#else
|
||||
unsigned short _cw;
|
||||
if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO))
|
||||
!= 0)
|
||||
return -1;
|
||||
__asm__ volatile ("fnstcw %0;": "=m" (*&_cw));
|
||||
_cw &= ~0xc00;
|
||||
_cw |= mode;
|
||||
__asm__ volatile ("fldcw %0;" : : "m" (*&_cw));
|
||||
|
||||
if (__mingw_has_sse ())
|
||||
{
|
||||
int mxcsr;
|
||||
|
||||
__asm__ volatile ("stmxcsr %0" : "=m" (*&mxcsr));
|
||||
mxcsr &= ~0x6000;
|
||||
mxcsr |= mode << 3;
|
||||
__asm__ volatile ("ldmxcsr %0" : : "m" (*&mxcsr));
|
||||
}
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return 0;
|
||||
if (round_mode & (~_MCW_RC))
|
||||
return 1;
|
||||
__mingw_controlfp(round_mode, _MCW_RC);
|
||||
return 0;
|
||||
}
|
||||
|
||||
23
lib/libc/mingw/misc/fetestexcept.c
vendored
23
lib/libc/mingw/misc/fetestexcept.c
vendored
@ -15,26 +15,7 @@
|
||||
exception macros corresponding to the currently set exceptions
|
||||
included in excepts. */
|
||||
|
||||
int fetestexcept (int excepts)
|
||||
int fetestexcept(int flags)
|
||||
{
|
||||
#if defined(_ARM_) || defined(__arm__)
|
||||
fenv_t _env;
|
||||
__asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env));
|
||||
return _env.__cw & excepts & FE_ALL_EXCEPT;
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
unsigned __int64 fpcr;
|
||||
__asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr));
|
||||
return fpcr & excepts & FE_ALL_EXCEPT;
|
||||
#else
|
||||
unsigned short _sw;
|
||||
__asm__ __volatile__ ("fnstsw %%ax" : "=a" (_sw));
|
||||
|
||||
if (__mingw_has_sse ())
|
||||
{
|
||||
int sse_sw;
|
||||
__asm__ __volatile__ ("stmxcsr %0;" : "=m" (sse_sw));
|
||||
_sw |= sse_sw;
|
||||
}
|
||||
return _sw & excepts & FE_ALL_EXCEPT;
|
||||
#endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */
|
||||
return __mingw_statusfp() & flags;
|
||||
}
|
||||
|
||||
10
lib/libc/mingw/misc/feupdateenv.c
vendored
10
lib/libc/mingw/misc/feupdateenv.c
vendored
@ -13,13 +13,9 @@
|
||||
set by a call to feholdexcept or fegetenv, or equal the macro
|
||||
FE_DFL_ENV or an implementation-defined environment macro. */
|
||||
|
||||
/* FIXME: this works but surely there must be a better way. */
|
||||
|
||||
int feupdateenv (const fenv_t * envp)
|
||||
int feupdateenv(const fenv_t *env)
|
||||
{
|
||||
unsigned int _fexcept = fetestexcept (FE_ALL_EXCEPT); /*save excepts */
|
||||
fesetenv (envp); /* install the env */
|
||||
feraiseexcept (_fexcept); /* raise the except */
|
||||
return 0;
|
||||
int except = fetestexcept(FE_ALL_EXCEPT);
|
||||
return fesetenv(env) || feraiseexcept(except);
|
||||
}
|
||||
|
||||
|
||||
34
lib/libc/mingw/misc/ftw.c
vendored
34
lib/libc/mingw/misc/ftw.c
vendored
@ -15,11 +15,9 @@
|
||||
#include <dirent.h>
|
||||
#include <ftw.h>
|
||||
|
||||
#ifdef IMPL_FTW64
|
||||
#define stat stat64
|
||||
#define nftw nftw64
|
||||
#define ftw ftw64
|
||||
#endif
|
||||
int __cdecl stat32(const char *_Filename, struct _stat32 *_Stat);
|
||||
int __cdecl stat32i64(const char *_Filename, struct _stat32i64 *_Stat);
|
||||
int __cdecl stat64i32(const char *_Filename, struct _stat64i32 *_Stat);
|
||||
|
||||
typedef struct dir_data_t {
|
||||
DIR *h;
|
||||
@ -36,14 +34,14 @@ typedef struct ctx_t {
|
||||
dir_data_t **dirs;
|
||||
char *buf;
|
||||
struct FTW ftw;
|
||||
int (*fcb) (const char *, const struct stat *, int , struct FTW *);
|
||||
int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *);
|
||||
size_t cur_dir, msz_dir, buf_sz;
|
||||
int flags;
|
||||
dev_t dev;
|
||||
} ctx_t;
|
||||
|
||||
static int add_object (ctx_t *);
|
||||
static int do_dir (ctx_t *, struct stat *, dir_data_t *);
|
||||
static int do_dir (ctx_t *, STRUCT_STAT *, dir_data_t *);
|
||||
static int do_entity (ctx_t *, dir_data_t *, const char *, size_t);
|
||||
static int do_it (const char *, int, void *, int, int);
|
||||
|
||||
@ -225,7 +223,7 @@ open_directory (ctx_t *ctx, dir_data_t *dirp)
|
||||
static int
|
||||
do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen)
|
||||
{
|
||||
struct stat st;
|
||||
STRUCT_STAT st;
|
||||
char *h;
|
||||
size_t cnt_sz;
|
||||
int ret = 0, flag = 0;
|
||||
@ -249,7 +247,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen)
|
||||
|
||||
name = ctx->buf;
|
||||
|
||||
if (stat (name, &st) < 0)
|
||||
if (FUNC_STAT (name, &st) < 0)
|
||||
{
|
||||
if (errno != EACCES && errno != ENOENT)
|
||||
ret = -1;
|
||||
@ -257,7 +255,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen)
|
||||
flag = FTW_NS;
|
||||
|
||||
if (!(ctx->flags & FTW_PHYS))
|
||||
stat (name, &st);
|
||||
FUNC_STAT (name, &st);
|
||||
}
|
||||
else
|
||||
flag = (S_ISDIR (st.st_mode) ? FTW_D : FTW_F);
|
||||
@ -281,7 +279,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen)
|
||||
|
||||
|
||||
static int
|
||||
do_dir (ctx_t *ctx, struct stat *st, __UNUSED_PARAM(dir_data_t *old_dir))
|
||||
do_dir (ctx_t *ctx, STRUCT_STAT *st, __UNUSED_PARAM(dir_data_t *old_dir))
|
||||
{
|
||||
dir_data_t dir;
|
||||
struct dirent *d;
|
||||
@ -378,7 +376,7 @@ static int
|
||||
do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, int flags)
|
||||
{
|
||||
struct ctx_t ctx;
|
||||
struct stat st;
|
||||
STRUCT_STAT st;
|
||||
int ret = 0;
|
||||
int sv_e;
|
||||
char *cp;
|
||||
@ -417,12 +415,12 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors,
|
||||
ctx.ftw.level = 0;
|
||||
ctx.ftw.base = cp - ctx.buf;
|
||||
ctx.flags = flags;
|
||||
ctx.fcb = (int (*) (const char *, const struct stat *, int , struct FTW *)) fcb;
|
||||
ctx.fcb = (int (*) (const char *, const STRUCT_STAT *, int , struct FTW *)) fcb;
|
||||
ctx.objs = NULL;
|
||||
|
||||
if (!ret)
|
||||
{
|
||||
if (stat (ctx.buf, &st) < 0)
|
||||
if (FUNC_STAT (ctx.buf, &st) < 0)
|
||||
ret = -1;
|
||||
else if (S_ISDIR (st.st_mode))
|
||||
{
|
||||
@ -451,13 +449,17 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors,
|
||||
}
|
||||
|
||||
int
|
||||
ftw (const char *path, int (*fcb) (const char *, const struct stat *, int), int descriptors)
|
||||
FUNC_FTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int), int descriptors);
|
||||
int
|
||||
FUNC_FTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int), int descriptors)
|
||||
{
|
||||
return do_it (path, 0, fcb, descriptors, 0);
|
||||
}
|
||||
|
||||
int
|
||||
nftw (const char *path, int (*fcb) (const char *, const struct stat *, int , struct FTW *), int descriptors, int flags)
|
||||
FUNC_NFTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *), int descriptors, int flags);
|
||||
int
|
||||
FUNC_NFTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *), int descriptors, int flags)
|
||||
{
|
||||
return do_it (path, 1, fcb, descriptors, flags);
|
||||
}
|
||||
|
||||
19
lib/libc/mingw/misc/ftw32.c
vendored
Normal file
19
lib/libc/mingw/misc/ftw32.c
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#define FUNC_FTW ftw32
|
||||
#define FUNC_NFTW nftw32
|
||||
#define FUNC_STAT stat32
|
||||
#define STRUCT_STAT struct _stat32
|
||||
#include "ftw.c"
|
||||
|
||||
/* On 32-bit systems is stat ABI compatible with stat32 */
|
||||
#ifndef _WIN64
|
||||
#undef nftw
|
||||
#undef ftw
|
||||
struct stat;
|
||||
int __attribute__ ((alias ("nftw32"))) __cdecl nftw(const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int);
|
||||
int __attribute__ ((alias ("ftw32"))) __cdecl ftw(const char *, int (*) (const char *, const struct stat *, int), int);
|
||||
#endif
|
||||
10
lib/libc/mingw/misc/ftw32i64.c
vendored
Normal file
10
lib/libc/mingw/misc/ftw32i64.c
vendored
Normal file
@ -0,0 +1,10 @@
|
||||
/**
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#define FUNC_FTW ftw32i64
|
||||
#define FUNC_NFTW nftw32i64
|
||||
#define FUNC_STAT stat32i64
|
||||
#define STRUCT_STAT struct _stat32i64
|
||||
#include "ftw.c"
|
||||
6
lib/libc/mingw/misc/ftw64.c
vendored
6
lib/libc/mingw/misc/ftw64.c
vendored
@ -3,6 +3,8 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#define IMPL_FTW64 1
|
||||
|
||||
#define FUNC_FTW ftw64
|
||||
#define FUNC_NFTW nftw64
|
||||
#define FUNC_STAT stat64
|
||||
#define STRUCT_STAT struct stat64
|
||||
#include "ftw.c"
|
||||
|
||||
19
lib/libc/mingw/misc/ftw64i32.c
vendored
Normal file
19
lib/libc/mingw/misc/ftw64i32.c
vendored
Normal file
@ -0,0 +1,19 @@
|
||||
/**
|
||||
* This file is part of the mingw-w64 runtime package.
|
||||
* No warranty is given; refer to the file DISCLAIMER within this package.
|
||||
*/
|
||||
|
||||
#define FUNC_FTW ftw64i32
|
||||
#define FUNC_NFTW nftw64i32
|
||||
#define FUNC_STAT stat64i32
|
||||
#define STRUCT_STAT struct _stat64i32
|
||||
#include "ftw.c"
|
||||
|
||||
/* On 64-bit systems is stat ABI compatible with stat64i32 */
|
||||
#ifdef _WIN64
|
||||
#undef nftw
|
||||
#undef ftw
|
||||
struct stat;
|
||||
int __attribute__ ((alias ("nftw64i32"))) __cdecl nftw(const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int);
|
||||
int __attribute__ ((alias ("ftw64i32"))) __cdecl ftw(const char *, int (*) (const char *, const struct stat *, int), int);
|
||||
#endif
|
||||
40
lib/libc/mingw/misc/mingw-aligned-malloc.c
vendored
40
lib/libc/mingw/misc/mingw-aligned-malloc.c
vendored
@ -18,16 +18,14 @@
|
||||
#include <stdint.h> /* uintptr_t */
|
||||
#include <string.h> /* memmove */
|
||||
|
||||
/* Forward declarations: */
|
||||
void *__mingw_aligned_offset_malloc (size_t, size_t, size_t);
|
||||
|
||||
#define NOT_POWER_OF_TWO(n) (((n) & ((n) - 1)))
|
||||
#define UI(p) ((uintptr_t) (p))
|
||||
#define CP(p) ((char *) p)
|
||||
|
||||
#define GAP(offset) ((0 - offset) & (sizeof (void *) -1))
|
||||
#define PTR_ALIGN(p0, alignment, offset) \
|
||||
((void *) (((UI(p0) + (alignment + sizeof(void*)) + offset) \
|
||||
& (~UI(alignment - 1))) \
|
||||
((void *) (((UI(p0) + (alignment + GAP(offset) + sizeof(void*)) + offset) \
|
||||
& (~UI(alignment))) \
|
||||
- offset))
|
||||
|
||||
/* Pointer must sometimes be aligned; assume sizeof(void*) is a power of two. */
|
||||
@ -47,12 +45,13 @@ __mingw_aligned_offset_malloc (size_t size, size_t alignment, size_t offset)
|
||||
return ((void *) 0);
|
||||
if (alignment < sizeof (void *))
|
||||
alignment = sizeof (void *);
|
||||
alignment--;
|
||||
|
||||
/* Including the extra sizeof(void*) is overkill on a 32-bit
|
||||
machine, since malloc is already 8-byte aligned, as long
|
||||
as we enforce alignment >= 8 ...but oh well. */
|
||||
|
||||
p0 = malloc (size + (alignment + sizeof (void *)));
|
||||
p0 = malloc (size + (alignment + GAP (offset) + sizeof (void *)));
|
||||
if (!p0)
|
||||
return ((void *) 0);
|
||||
p = PTR_ALIGN (p0, alignment, offset);
|
||||
@ -91,6 +90,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size,
|
||||
}
|
||||
if (alignment < sizeof (void *))
|
||||
alignment = sizeof (void *);
|
||||
alignment--;
|
||||
|
||||
p0 = ORIG_PTR (memblock);
|
||||
/* It is an error for the alignment to change. */
|
||||
@ -98,7 +98,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size,
|
||||
goto bad;
|
||||
shift = CP (memblock) - CP (p0);
|
||||
|
||||
p0 = realloc (p0, size + (alignment + sizeof (void *)));
|
||||
p0 = realloc (p0, size + (alignment + GAP (offset) + sizeof (void *)));
|
||||
if (!p0)
|
||||
return ((void *) 0);
|
||||
p = PTR_ALIGN (p0, alignment, offset);
|
||||
@ -121,3 +121,29 @@ __mingw_aligned_realloc (void *memblock, size_t size, size_t alignment)
|
||||
{
|
||||
return __mingw_aligned_offset_realloc (memblock, size, alignment, 0);
|
||||
}
|
||||
|
||||
size_t
|
||||
__mingw_aligned_msize (void *memblock, size_t alignment, size_t offset)
|
||||
{
|
||||
void *p0;
|
||||
|
||||
if (!memblock || NOT_POWER_OF_TWO (alignment))
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (size_t)-1;
|
||||
}
|
||||
if (alignment < sizeof (void *))
|
||||
alignment = sizeof (void *);
|
||||
alignment--;
|
||||
|
||||
p0 = ORIG_PTR (memblock);
|
||||
|
||||
/* It is an error if the alignment or offset does not match. */
|
||||
if (memblock != PTR_ALIGN (p0, alignment, offset))
|
||||
{
|
||||
errno = EINVAL;
|
||||
return (size_t)-1;
|
||||
}
|
||||
|
||||
return _msize (p0) - (alignment + GAP (offset) + sizeof (void *));
|
||||
}
|
||||
|
||||
53
lib/libc/mingw/misc/mingw_controlfp.c
vendored
Normal file
53
lib/libc/mingw/misc/mingw_controlfp.c
vendored
Normal file
@ -0,0 +1,53 @@
|
||||
/**
|
||||
* 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 "internal.h"
|
||||
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
/* Internal MinGW version of _control87_2 */
|
||||
int __mingw_control87_2( unsigned int newval, unsigned int mask,
|
||||
unsigned int *x86_cw, unsigned int *sse2_cw )
|
||||
{
|
||||
if (x86_cw)
|
||||
{
|
||||
*x86_cw = newval;
|
||||
__mingw_setfp(x86_cw, mask, NULL, 0);
|
||||
}
|
||||
|
||||
if (!sse2_cw) return 1;
|
||||
|
||||
if (__mingw_has_sse())
|
||||
{
|
||||
*sse2_cw = newval;
|
||||
__mingw_setfp_sse(sse2_cw, mask, NULL, 0);
|
||||
}
|
||||
else *sse2_cw = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Internal MinGW version of _control87 */
|
||||
unsigned int __mingw_controlfp(unsigned int newval, unsigned int mask)
|
||||
{
|
||||
unsigned int flags = 0;
|
||||
#if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__))
|
||||
unsigned int sse2_cw;
|
||||
|
||||
__mingw_control87_2( newval, mask, &flags, &sse2_cw );
|
||||
|
||||
if (__mingw_has_sse())
|
||||
{
|
||||
if ((flags ^ sse2_cw) & (_MCW_EM | _MCW_RC)) flags |= _EM_AMBIGUOUS;
|
||||
flags |= sse2_cw;
|
||||
}
|
||||
#else
|
||||
flags = newval;
|
||||
__mingw_setfp(&flags, mask, NULL, 0);
|
||||
#endif
|
||||
return flags;
|
||||
}
|
||||
|
||||
8
lib/libc/mingw/misc/mingw_getsp.S
vendored
8
lib/libc/mingw/misc/mingw_getsp.S
vendored
@ -15,7 +15,10 @@
|
||||
.globl __MINGW_USYMBOL(mingw_getsp)
|
||||
.def __MINGW_USYMBOL(mingw_getsp); .scl 2; .type 32; .endef
|
||||
__MINGW_USYMBOL(mingw_getsp):
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
#if defined(_ARM64_) || defined(__aarch64__) || defined(__arm64ec__)
|
||||
mov x0, sp
|
||||
ret
|
||||
#elif defined(_AMD64_) || defined(__x86_64__)
|
||||
leaq 8(%rsp),%rax
|
||||
ret
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
@ -24,7 +27,4 @@ __MINGW_USYMBOL(mingw_getsp):
|
||||
#elif defined(_ARM_) || defined(__arm__)
|
||||
mov r0, sp
|
||||
bx lr
|
||||
#elif defined(_ARM64_) || defined(__aarch64__)
|
||||
mov x0, sp
|
||||
ret
|
||||
#endif
|
||||
|
||||
373
lib/libc/mingw/misc/mingw_setfp.c
vendored
Normal file
373
lib/libc/mingw/misc/mingw_setfp.c
vendored
Normal file
@ -0,0 +1,373 @@
|
||||
/**
|
||||
* 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 "internal.h"
|
||||
|
||||
#if defined(__i386__) || defined(__x86_64__)
|
||||
|
||||
static unsigned int get_mxcsr(void)
|
||||
{
|
||||
unsigned int ret;
|
||||
#ifdef __arm64ec__
|
||||
extern NTSTATUS (*__os_arm64x_get_x64_information)(ULONG,void*,void*);
|
||||
__os_arm64x_get_x64_information( 0, &ret, NULL );
|
||||
#else
|
||||
__asm__ __volatile__( "stmxcsr %0" : "=m" (ret) );
|
||||
#endif
|
||||
return ret;
|
||||
}
|
||||
|
||||
static void set_mxcsr( unsigned int val )
|
||||
{
|
||||
#ifdef __arm64ec__
|
||||
extern NTSTATUS (*__os_arm64x_set_x64_information)(ULONG,ULONG_PTR,void*);
|
||||
__os_arm64x_set_x64_information( 0, val, NULL );
|
||||
#else
|
||||
__asm__ __volatile__( "ldmxcsr %0" : : "m" (val) );
|
||||
#endif
|
||||
}
|
||||
|
||||
void __mingw_setfp_sse( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask )
|
||||
{
|
||||
unsigned int old_fpword, fpword = get_mxcsr();
|
||||
unsigned int flags;
|
||||
|
||||
old_fpword = fpword;
|
||||
|
||||
cw_mask &= _MCW_EM | _MCW_RC | _MCW_DN;
|
||||
sw_mask &= _MCW_EM;
|
||||
|
||||
if (sw)
|
||||
{
|
||||
flags = 0;
|
||||
if (fpword & 0x1) flags |= _SW_INVALID;
|
||||
if (fpword & 0x2) flags |= _SW_DENORMAL;
|
||||
if (fpword & 0x4) flags |= _SW_ZERODIVIDE;
|
||||
if (fpword & 0x8) flags |= _SW_OVERFLOW;
|
||||
if (fpword & 0x10) flags |= _SW_UNDERFLOW;
|
||||
if (fpword & 0x20) flags |= _SW_INEXACT;
|
||||
|
||||
*sw = (flags & ~sw_mask) | (*sw & sw_mask);
|
||||
fpword &= ~0x3f;
|
||||
if (*sw & _SW_INVALID) fpword |= 0x1;
|
||||
if (*sw & _SW_DENORMAL) fpword |= 0x2;
|
||||
if (*sw & _SW_ZERODIVIDE) fpword |= 0x4;
|
||||
if (*sw & _SW_OVERFLOW) fpword |= 0x8;
|
||||
if (*sw & _SW_UNDERFLOW) fpword |= 0x10;
|
||||
if (*sw & _SW_INEXACT) fpword |= 0x20;
|
||||
*sw = flags;
|
||||
}
|
||||
|
||||
if (cw)
|
||||
{
|
||||
flags = 0;
|
||||
if (fpword & 0x80) flags |= _EM_INVALID;
|
||||
if (fpword & 0x100) flags |= _EM_DENORMAL;
|
||||
if (fpword & 0x200) flags |= _EM_ZERODIVIDE;
|
||||
if (fpword & 0x400) flags |= _EM_OVERFLOW;
|
||||
if (fpword & 0x800) flags |= _EM_UNDERFLOW;
|
||||
if (fpword & 0x1000) flags |= _EM_INEXACT;
|
||||
switch (fpword & 0x6000)
|
||||
{
|
||||
case 0x6000: flags |= _RC_UP|_RC_DOWN; break;
|
||||
case 0x4000: flags |= _RC_UP; break;
|
||||
case 0x2000: flags |= _RC_DOWN; break;
|
||||
}
|
||||
switch (fpword & 0x8040)
|
||||
{
|
||||
case 0x0040: flags |= _DN_FLUSH_OPERANDS_SAVE_RESULTS; break;
|
||||
case 0x8000: flags |= _DN_SAVE_OPERANDS_FLUSH_RESULTS; break;
|
||||
case 0x8040: flags |= _DN_FLUSH; break;
|
||||
}
|
||||
|
||||
*cw = (flags & ~cw_mask) | (*cw & cw_mask);
|
||||
fpword &= ~0xffc0;
|
||||
if (*cw & _EM_INVALID) fpword |= 0x80;
|
||||
if (*cw & _EM_DENORMAL) fpword |= 0x100;
|
||||
if (*cw & _EM_ZERODIVIDE) fpword |= 0x200;
|
||||
if (*cw & _EM_OVERFLOW) fpword |= 0x400;
|
||||
if (*cw & _EM_UNDERFLOW) fpword |= 0x800;
|
||||
if (*cw & _EM_INEXACT) fpword |= 0x1000;
|
||||
switch (*cw & _MCW_RC)
|
||||
{
|
||||
case _RC_UP|_RC_DOWN: fpword |= 0x6000; break;
|
||||
case _RC_UP: fpword |= 0x4000; break;
|
||||
case _RC_DOWN: fpword |= 0x2000; break;
|
||||
}
|
||||
switch (*cw & _MCW_DN)
|
||||
{
|
||||
case _DN_FLUSH_OPERANDS_SAVE_RESULTS: fpword |= 0x0040; break;
|
||||
case _DN_SAVE_OPERANDS_FLUSH_RESULTS: fpword |= 0x8000; break;
|
||||
case _DN_FLUSH: fpword |= 0x8040; break;
|
||||
}
|
||||
|
||||
/* clear status word if anything changes */
|
||||
if (fpword != old_fpword && !sw) fpword &= ~0x3f;
|
||||
}
|
||||
|
||||
if (fpword != old_fpword) set_mxcsr( fpword );
|
||||
}
|
||||
#endif
|
||||
|
||||
void __mingw_setfp( unsigned int *cw, unsigned int cw_mask,
|
||||
unsigned int *sw, unsigned int sw_mask )
|
||||
{
|
||||
#if defined(__arm64ec__)
|
||||
__mingw_setfp_sse(cw, cw_mask, sw, sw_mask);
|
||||
#elif defined(__i386__) || defined(__x86_64__)
|
||||
unsigned long oldcw = 0, newcw = 0;
|
||||
unsigned long oldsw = 0, newsw = 0;
|
||||
unsigned int flags;
|
||||
|
||||
cw_mask &= _MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC;
|
||||
sw_mask &= _MCW_EM;
|
||||
|
||||
if (sw)
|
||||
{
|
||||
__asm__ __volatile__( "fstsw %0" : "=m" (newsw) );
|
||||
oldsw = newsw;
|
||||
|
||||
flags = 0;
|
||||
if (newsw & 0x1) flags |= _SW_INVALID;
|
||||
if (newsw & 0x2) flags |= _SW_DENORMAL;
|
||||
if (newsw & 0x4) flags |= _SW_ZERODIVIDE;
|
||||
if (newsw & 0x8) flags |= _SW_OVERFLOW;
|
||||
if (newsw & 0x10) flags |= _SW_UNDERFLOW;
|
||||
if (newsw & 0x20) flags |= _SW_INEXACT;
|
||||
|
||||
*sw = (flags & ~sw_mask) | (*sw & sw_mask);
|
||||
newsw &= ~0x3f;
|
||||
if (*sw & _SW_INVALID) newsw |= 0x1;
|
||||
if (*sw & _SW_DENORMAL) newsw |= 0x2;
|
||||
if (*sw & _SW_ZERODIVIDE) newsw |= 0x4;
|
||||
if (*sw & _SW_OVERFLOW) newsw |= 0x8;
|
||||
if (*sw & _SW_UNDERFLOW) newsw |= 0x10;
|
||||
if (*sw & _SW_INEXACT) newsw |= 0x20;
|
||||
*sw = flags;
|
||||
}
|
||||
|
||||
if (cw)
|
||||
{
|
||||
__asm__ __volatile__( "fstcw %0" : "=m" (newcw) );
|
||||
oldcw = newcw;
|
||||
|
||||
flags = 0;
|
||||
if (newcw & 0x1) flags |= _EM_INVALID;
|
||||
if (newcw & 0x2) flags |= _EM_DENORMAL;
|
||||
if (newcw & 0x4) flags |= _EM_ZERODIVIDE;
|
||||
if (newcw & 0x8) flags |= _EM_OVERFLOW;
|
||||
if (newcw & 0x10) flags |= _EM_UNDERFLOW;
|
||||
if (newcw & 0x20) flags |= _EM_INEXACT;
|
||||
switch (newcw & 0xc00)
|
||||
{
|
||||
case 0xc00: flags |= _RC_UP|_RC_DOWN; break;
|
||||
case 0x800: flags |= _RC_UP; break;
|
||||
case 0x400: flags |= _RC_DOWN; break;
|
||||
}
|
||||
switch (newcw & 0x300)
|
||||
{
|
||||
case 0x0: flags |= _PC_24; break;
|
||||
case 0x200: flags |= _PC_53; break;
|
||||
case 0x300: flags |= _PC_64; break;
|
||||
}
|
||||
if (newcw & 0x1000) flags |= _IC_AFFINE;
|
||||
|
||||
*cw = (flags & ~cw_mask) | (*cw & cw_mask);
|
||||
newcw &= ~0x1f3f;
|
||||
if (*cw & _EM_INVALID) newcw |= 0x1;
|
||||
if (*cw & _EM_DENORMAL) newcw |= 0x2;
|
||||
if (*cw & _EM_ZERODIVIDE) newcw |= 0x4;
|
||||
if (*cw & _EM_OVERFLOW) newcw |= 0x8;
|
||||
if (*cw & _EM_UNDERFLOW) newcw |= 0x10;
|
||||
if (*cw & _EM_INEXACT) newcw |= 0x20;
|
||||
switch (*cw & _MCW_RC)
|
||||
{
|
||||
case _RC_UP|_RC_DOWN: newcw |= 0xc00; break;
|
||||
case _RC_UP: newcw |= 0x800; break;
|
||||
case _RC_DOWN: newcw |= 0x400; break;
|
||||
}
|
||||
switch (*cw & _MCW_PC)
|
||||
{
|
||||
case _PC_64: newcw |= 0x300; break;
|
||||
case _PC_53: newcw |= 0x200; break;
|
||||
case _PC_24: newcw |= 0x0; break;
|
||||
}
|
||||
if (*cw & _IC_AFFINE) newcw |= 0x1000;
|
||||
}
|
||||
|
||||
if (oldsw != newsw && (newsw & 0x3f))
|
||||
{
|
||||
struct {
|
||||
WORD control_word;
|
||||
WORD unused1;
|
||||
WORD status_word;
|
||||
WORD unused2;
|
||||
WORD tag_word;
|
||||
WORD unused3;
|
||||
DWORD instruction_pointer;
|
||||
WORD code_segment;
|
||||
WORD unused4;
|
||||
DWORD operand_addr;
|
||||
WORD data_segment;
|
||||
WORD unused5;
|
||||
} fenv;
|
||||
|
||||
__asm__ __volatile__( "fnstenv %0" : "=m" (fenv) );
|
||||
fenv.control_word = newcw;
|
||||
fenv.status_word = newsw;
|
||||
__asm__ __volatile__( "fldenv %0" : : "m" (fenv) : "st", "st(1)",
|
||||
"st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" );
|
||||
return;
|
||||
}
|
||||
|
||||
if (oldsw != newsw)
|
||||
__asm__ __volatile__( "fnclex" );
|
||||
if (oldcw != newcw)
|
||||
__asm__ __volatile__( "fldcw %0" : : "m" (newcw) );
|
||||
#elif defined(__aarch64__)
|
||||
ULONG_PTR old_fpsr = 0, fpsr = 0, old_fpcr = 0, fpcr = 0;
|
||||
unsigned int flags;
|
||||
|
||||
cw_mask &= _MCW_EM | _MCW_RC;
|
||||
sw_mask &= _MCW_EM;
|
||||
|
||||
if (sw)
|
||||
{
|
||||
__asm__ __volatile__( "mrs %0, fpsr" : "=r" (fpsr) );
|
||||
old_fpsr = fpsr;
|
||||
|
||||
flags = 0;
|
||||
if (fpsr & 0x1) flags |= _SW_INVALID;
|
||||
if (fpsr & 0x2) flags |= _SW_ZERODIVIDE;
|
||||
if (fpsr & 0x4) flags |= _SW_OVERFLOW;
|
||||
if (fpsr & 0x8) flags |= _SW_UNDERFLOW;
|
||||
if (fpsr & 0x10) flags |= _SW_INEXACT;
|
||||
if (fpsr & 0x80) flags |= _SW_DENORMAL;
|
||||
|
||||
*sw = (flags & ~sw_mask) | (*sw & sw_mask);
|
||||
fpsr &= ~0x9f;
|
||||
if (*sw & _SW_INVALID) fpsr |= 0x1;
|
||||
if (*sw & _SW_ZERODIVIDE) fpsr |= 0x2;
|
||||
if (*sw & _SW_OVERFLOW) fpsr |= 0x4;
|
||||
if (*sw & _SW_UNDERFLOW) fpsr |= 0x8;
|
||||
if (*sw & _SW_INEXACT) fpsr |= 0x10;
|
||||
if (*sw & _SW_DENORMAL) fpsr |= 0x80;
|
||||
*sw = flags;
|
||||
}
|
||||
|
||||
if (cw)
|
||||
{
|
||||
__asm__ __volatile__( "mrs %0, fpcr" : "=r" (fpcr) );
|
||||
old_fpcr = fpcr;
|
||||
|
||||
flags = 0;
|
||||
if (!(fpcr & 0x100)) flags |= _EM_INVALID;
|
||||
if (!(fpcr & 0x200)) flags |= _EM_ZERODIVIDE;
|
||||
if (!(fpcr & 0x400)) flags |= _EM_OVERFLOW;
|
||||
if (!(fpcr & 0x800)) flags |= _EM_UNDERFLOW;
|
||||
if (!(fpcr & 0x1000)) flags |= _EM_INEXACT;
|
||||
if (!(fpcr & 0x8000)) flags |= _EM_DENORMAL;
|
||||
switch (fpcr & 0xc00000)
|
||||
{
|
||||
case 0x400000: flags |= _RC_UP; break;
|
||||
case 0x800000: flags |= _RC_DOWN; break;
|
||||
case 0xc00000: flags |= _RC_CHOP; break;
|
||||
}
|
||||
|
||||
*cw = (flags & ~cw_mask) | (*cw & cw_mask);
|
||||
fpcr &= ~0xc09f00ul;
|
||||
if (!(*cw & _EM_INVALID)) fpcr |= 0x100;
|
||||
if (!(*cw & _EM_ZERODIVIDE)) fpcr |= 0x200;
|
||||
if (!(*cw & _EM_OVERFLOW)) fpcr |= 0x400;
|
||||
if (!(*cw & _EM_UNDERFLOW)) fpcr |= 0x800;
|
||||
if (!(*cw & _EM_INEXACT)) fpcr |= 0x1000;
|
||||
if (!(*cw & _EM_DENORMAL)) fpcr |= 0x8000;
|
||||
switch (*cw & _MCW_RC)
|
||||
{
|
||||
case _RC_CHOP: fpcr |= 0xc00000; break;
|
||||
case _RC_UP: fpcr |= 0x400000; break;
|
||||
case _RC_DOWN: fpcr |= 0x800000; break;
|
||||
}
|
||||
}
|
||||
|
||||
/* mask exceptions if needed */
|
||||
if (old_fpcr != fpcr && ~(old_fpcr >> 8) & fpsr & 0x9f != fpsr & 0x9f)
|
||||
{
|
||||
ULONG_PTR mask = fpcr & ~0x9f00;
|
||||
__asm__ __volatile__( "msr fpcr, %0" :: "r" (mask) );
|
||||
}
|
||||
|
||||
if (old_fpsr != fpsr)
|
||||
__asm__ __volatile__( "msr fpsr, %0" :: "r" (fpsr) );
|
||||
if (old_fpcr != fpcr)
|
||||
__asm__ __volatile__( "msr fpcr, %0" :: "r" (fpcr) );
|
||||
#elif defined(__arm__)
|
||||
DWORD old_fpscr, fpscr;
|
||||
unsigned int flags;
|
||||
|
||||
__asm__ __volatile__( "vmrs %0, fpscr" : "=r" (fpscr) );
|
||||
old_fpscr = fpscr;
|
||||
|
||||
cw_mask &= _MCW_EM | _MCW_RC;
|
||||
sw_mask &= _MCW_EM;
|
||||
|
||||
if (sw)
|
||||
{
|
||||
flags = 0;
|
||||
if (fpscr & 0x1) flags |= _SW_INVALID;
|
||||
if (fpscr & 0x2) flags |= _SW_ZERODIVIDE;
|
||||
if (fpscr & 0x4) flags |= _SW_OVERFLOW;
|
||||
if (fpscr & 0x8) flags |= _SW_UNDERFLOW;
|
||||
if (fpscr & 0x10) flags |= _SW_INEXACT;
|
||||
if (fpscr & 0x80) flags |= _SW_DENORMAL;
|
||||
|
||||
*sw = (flags & ~sw_mask) | (*sw & sw_mask);
|
||||
fpscr &= ~0x9f;
|
||||
if (*sw & _SW_INVALID) fpscr |= 0x1;
|
||||
if (*sw & _SW_ZERODIVIDE) fpscr |= 0x2;
|
||||
if (*sw & _SW_OVERFLOW) fpscr |= 0x4;
|
||||
if (*sw & _SW_UNDERFLOW) fpscr |= 0x8;
|
||||
if (*sw & _SW_INEXACT) fpscr |= 0x10;
|
||||
if (*sw & _SW_DENORMAL) fpscr |= 0x80;
|
||||
*sw = flags;
|
||||
}
|
||||
|
||||
if (cw)
|
||||
{
|
||||
flags = 0;
|
||||
if (!(fpscr & 0x100)) flags |= _EM_INVALID;
|
||||
if (!(fpscr & 0x200)) flags |= _EM_ZERODIVIDE;
|
||||
if (!(fpscr & 0x400)) flags |= _EM_OVERFLOW;
|
||||
if (!(fpscr & 0x800)) flags |= _EM_UNDERFLOW;
|
||||
if (!(fpscr & 0x1000)) flags |= _EM_INEXACT;
|
||||
if (!(fpscr & 0x8000)) flags |= _EM_DENORMAL;
|
||||
switch (fpscr & 0xc00000)
|
||||
{
|
||||
case 0x400000: flags |= _RC_UP; break;
|
||||
case 0x800000: flags |= _RC_DOWN; break;
|
||||
case 0xc00000: flags |= _RC_CHOP; break;
|
||||
}
|
||||
|
||||
*cw = (flags & ~cw_mask) | (*cw & cw_mask);
|
||||
fpscr &= ~0xc09f00ul;
|
||||
if (!(*cw & _EM_INVALID)) fpscr |= 0x100;
|
||||
if (!(*cw & _EM_ZERODIVIDE)) fpscr |= 0x200;
|
||||
if (!(*cw & _EM_OVERFLOW)) fpscr |= 0x400;
|
||||
if (!(*cw & _EM_UNDERFLOW)) fpscr |= 0x800;
|
||||
if (!(*cw & _EM_INEXACT)) fpscr |= 0x1000;
|
||||
if (!(*cw & _EM_DENORMAL)) fpscr |= 0x8000;
|
||||
switch (*cw & _MCW_RC)
|
||||
{
|
||||
case _RC_CHOP: fpscr |= 0xc00000; break;
|
||||
case _RC_UP: fpscr |= 0x400000; break;
|
||||
case _RC_DOWN: fpscr |= 0x800000; break;
|
||||
}
|
||||
}
|
||||
|
||||
if (old_fpscr != fpscr)
|
||||
__asm__ __volatile__( "vmsr fpscr, %0" :: "r" (fpscr) );
|
||||
#endif
|
||||
}
|
||||
2
lib/libc/mingw/misc/setjmp.S
vendored
2
lib/libc/mingw/misc/setjmp.S
vendored
@ -6,6 +6,7 @@
|
||||
|
||||
#include <_mingw_mac.h>
|
||||
|
||||
#ifndef __arm64ec__
|
||||
.globl __MINGW_USYMBOL(__intrinsic_setjmp)
|
||||
.def __MINGW_USYMBOL(__intrinsic_setjmp); .scl 2; .type 32; .endef
|
||||
|
||||
@ -115,3 +116,4 @@ __MINGW_USYMBOL(__intrinsic_setjmpex):
|
||||
mov x0, #0
|
||||
ret
|
||||
#endif
|
||||
#endif /* __arm64ec__ */
|
||||
|
||||
3
lib/libc/mingw/misc/ucrt_tzset.c
vendored
3
lib/libc/mingw/misc/ucrt_tzset.c
vendored
@ -40,6 +40,3 @@ void __cdecl tzset(void)
|
||||
{
|
||||
_tzset();
|
||||
}
|
||||
|
||||
// Dummy/unused __imp_ wrappers, to make GNU ld not autoexport these symbols.
|
||||
void __cdecl (*__MINGW_IMP_SYMBOL(tzset))(void) = tzset;
|
||||
|
||||
35
lib/libc/mingw/misc/winbs_uint64.c
vendored
35
lib/libc/mingw/misc/winbs_uint64.c
vendored
@ -2,38 +2,5 @@ unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64);
|
||||
|
||||
unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64)
|
||||
{
|
||||
#if defined(_AMD64_) || defined(__x86_64__)
|
||||
unsigned long long retval;
|
||||
__asm__ __volatile__ ("bswapq %[retval]" : [retval] "=rm" (retval) : "[retval]" (_Int64));
|
||||
return retval;
|
||||
#elif defined(_X86_) || defined(__i386__)
|
||||
union {
|
||||
long long int64part;
|
||||
struct {
|
||||
unsigned long lowpart;
|
||||
unsigned long hipart;
|
||||
};
|
||||
} retval;
|
||||
retval.int64part = _Int64;
|
||||
__asm__ __volatile__ ("bswapl %[lowpart]\n"
|
||||
"bswapl %[hipart]\n"
|
||||
: [lowpart] "=rm" (retval.hipart), [hipart] "=rm" (retval.lowpart) : "[lowpart]" (retval.lowpart), "[hipart]" (retval.hipart));
|
||||
return retval.int64part;
|
||||
#else
|
||||
unsigned char *b = (void*)&_Int64;
|
||||
unsigned char tmp;
|
||||
tmp = b[0];
|
||||
b[0] = b[7];
|
||||
b[7] = tmp;
|
||||
tmp = b[1];
|
||||
b[1] = b[6];
|
||||
b[6] = tmp;
|
||||
tmp = b[2];
|
||||
b[2] = b[5];
|
||||
b[5] = tmp;
|
||||
tmp = b[3];
|
||||
b[3] = b[4];
|
||||
b[4] = tmp;
|
||||
return _Int64;
|
||||
#endif
|
||||
return __builtin_bswap64(_Int64);
|
||||
}
|
||||
|
||||
16
lib/libc/mingw/misc/winbs_ulong.c
vendored
16
lib/libc/mingw/misc/winbs_ulong.c
vendored
@ -2,19 +2,5 @@ unsigned long __cdecl _byteswap_ulong (unsigned long _Long);
|
||||
|
||||
unsigned long __cdecl _byteswap_ulong (unsigned long _Long)
|
||||
{
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
unsigned long retval;
|
||||
__asm__ __volatile__ ("bswapl %[retval]" : [retval] "=rm" (retval) : "[retval]" (_Long));
|
||||
return retval;
|
||||
#else
|
||||
unsigned char *b = (void*)&_Long;
|
||||
unsigned char tmp;
|
||||
tmp = b[0];
|
||||
b[0] = b[3];
|
||||
b[3] = tmp;
|
||||
tmp = b[1];
|
||||
b[1] = b[2];
|
||||
b[2] = tmp;
|
||||
return _Long;
|
||||
#endif /* defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) */
|
||||
return __builtin_bswap32(_Long);
|
||||
}
|
||||
|
||||
13
lib/libc/mingw/misc/winbs_ushort.c
vendored
13
lib/libc/mingw/misc/winbs_ushort.c
vendored
@ -2,16 +2,5 @@ unsigned short __cdecl _byteswap_ushort(unsigned short _Short);
|
||||
|
||||
unsigned short __cdecl _byteswap_ushort(unsigned short _Short)
|
||||
{
|
||||
#if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__)
|
||||
unsigned short retval;
|
||||
__asm__ __volatile__ ("rorw $8, %w[retval]" : [retval] "=rm" (retval) : "[retval]" (_Short));
|
||||
return retval;
|
||||
#else
|
||||
unsigned char *b = (void*)&_Short;
|
||||
unsigned char tmp;
|
||||
tmp = b[0];
|
||||
b[0] = b[1];
|
||||
b[1] = tmp;
|
||||
return _Short;
|
||||
#endif /* defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) */
|
||||
return __builtin_bswap16(_Short);
|
||||
}
|
||||
|
||||
64
lib/libc/mingw/stdio/__mingw_fix_stat_path.c
vendored
Normal file
64
lib/libc/mingw/stdio/__mingw_fix_stat_path.c
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
*/
|
||||
|
||||
char* __mingw_fix_stat_path (const char* _path);
|
||||
char* __mingw_fix_stat_path (const char* _path)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
p = (char*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = strlen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == '\\' || _path[0] == '/')
|
||||
&& (_path[1] == '\\' || _path[1] == '/'))
|
||||
{
|
||||
const char *r = &_path[2];
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == '/' || _path[len - 1] == '\\')
|
||||
{
|
||||
p = (char*)malloc (len);
|
||||
memcpy (p, _path, len - 1);
|
||||
p[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
64
lib/libc/mingw/stdio/__mingw_fix_wstat_path.c
vendored
Normal file
64
lib/libc/mingw/stdio/__mingw_fix_wstat_path.c
vendored
Normal file
@ -0,0 +1,64 @@
|
||||
/**
|
||||
* 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 <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
*/
|
||||
|
||||
wchar_t* __mingw_fix_wstat_path (const wchar_t* _path);
|
||||
wchar_t* __mingw_fix_wstat_path (const wchar_t* _path)
|
||||
{
|
||||
int len;
|
||||
wchar_t *p;
|
||||
|
||||
p = (wchar_t*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = wcslen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == L'\\' || _path[0] == L'/')
|
||||
&& (_path[1] == L'\\' || _path[1] == L'/'))
|
||||
{
|
||||
const wchar_t *r = &_path[2];
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == L'/' || _path[len - 1] == L'\\')
|
||||
{
|
||||
p = (wchar_t*)malloc (len * sizeof(wchar_t));
|
||||
memcpy (p, _path, (len - 1) * sizeof(wchar_t));
|
||||
p[len - 1] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
2
lib/libc/mingw/stdio/_findfirst64i32.c
vendored
2
lib/libc/mingw/stdio/_findfirst64i32.c
vendored
@ -7,7 +7,7 @@ intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t *
|
||||
struct __finddata64_t fd;
|
||||
intptr_t ret = _findfirst64(_Filename,&fd);
|
||||
if (ret == -1) {
|
||||
memset(_FindData,0,sizeof(struct _finddata64i32_t));
|
||||
*_FindData = (struct _finddata64i32_t){0};
|
||||
return -1;
|
||||
}
|
||||
_FindData->attrib=fd.attrib;
|
||||
|
||||
2
lib/libc/mingw/stdio/_findnext64i32.c
vendored
2
lib/libc/mingw/stdio/_findnext64i32.c
vendored
@ -7,7 +7,7 @@ int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindDa
|
||||
struct __finddata64_t fd;
|
||||
int ret = _findnext64(_FindHandle,&fd);
|
||||
if (ret == -1) {
|
||||
memset(_FindData,0,sizeof(struct _finddata64i32_t));
|
||||
*_FindData = (struct _finddata64i32_t){0};
|
||||
return -1;
|
||||
}
|
||||
_FindData->attrib=fd.attrib;
|
||||
|
||||
28
lib/libc/mingw/stdio/_fstat64i32.c
vendored
28
lib/libc/mingw/stdio/_fstat64i32.c
vendored
@ -1,14 +1,26 @@
|
||||
#define __CRT__NO_INLINE
|
||||
/**
|
||||
* 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 <sys/stat.h>
|
||||
|
||||
/* When the file size does not fit into the st_size field:
|
||||
* crtdll-msvcr90 msvcr100 msvcr110+
|
||||
* st_size truncate 0 0
|
||||
* errno no change no change EOVERFLOW
|
||||
* returns 0 -1 -1
|
||||
*
|
||||
* This file is used only for pre-msvcr80 builds,
|
||||
* So use the pre-msvcr80 behavior - truncate without error.
|
||||
*/
|
||||
int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat)
|
||||
{
|
||||
struct _stat64 st;
|
||||
int ret=_fstat64(_FileDes,&st);
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct _stat64i32));
|
||||
return -1;
|
||||
}
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
_Stat->st_dev=st.st_dev;
|
||||
_Stat->st_ino=st.st_ino;
|
||||
_Stat->st_mode=st.st_mode;
|
||||
@ -16,10 +28,10 @@ int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat)
|
||||
_Stat->st_uid=st.st_uid;
|
||||
_Stat->st_gid=st.st_gid;
|
||||
_Stat->st_rdev=st.st_rdev;
|
||||
_Stat->st_size=(_off_t) st.st_size; /* 32bit size */
|
||||
_Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */
|
||||
_Stat->st_atime=st.st_atime;
|
||||
_Stat->st_mtime=st.st_mtime;
|
||||
_Stat->st_ctime=st.st_ctime;
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int (__cdecl *__MINGW_IMP_SYMBOL(_fstat64i32))(int, struct _stat64i32 *) = _fstat64i32;
|
||||
|
||||
120
lib/libc/mingw/stdio/_stat.c
vendored
120
lib/libc/mingw/stdio/_stat.c
vendored
@ -1,120 +0,0 @@
|
||||
#define __CRT__NO_INLINE
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
*/
|
||||
|
||||
static char*
|
||||
_mingw_no_trailing_slash (const char* _path)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
p = (char*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = strlen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == '\\' || _path[0] == '/')
|
||||
&& (_path[1] == '\\' || _path[1] == '/'))
|
||||
{
|
||||
const char *r = &_path[2];
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == '/' || _path[len - 1] == '\\')
|
||||
{
|
||||
p = (char*)malloc (len);
|
||||
memcpy (p, _path, len - 1);
|
||||
p[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
/* FIXME: Relying on _USE_32BIT_TIME_T, which is a user-macro,
|
||||
during CRT compilation is plainly broken. Need an appropriate
|
||||
implementation to provide users the ability of compiling the
|
||||
CRT only with 32-bit time_t behavior. */
|
||||
#if defined(_USE_32BIT_TIME_T)
|
||||
int __cdecl
|
||||
stat(const char *_Filename,struct stat *_Stat)
|
||||
{
|
||||
struct _stat32 st;
|
||||
char *_path = _mingw_no_trailing_slash(_Filename);
|
||||
|
||||
int ret=_stat32(_path,&st);
|
||||
|
||||
if (_path != _Filename)
|
||||
free (_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct stat));
|
||||
return -1;
|
||||
}
|
||||
/* struct stat and struct _stat32
|
||||
are the same for this case. */
|
||||
memcpy(_Stat, &st, sizeof(struct _stat32));
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int __cdecl
|
||||
stat(const char *_Filename,struct stat *_Stat)
|
||||
{
|
||||
struct _stat64 st;
|
||||
char *_path = _mingw_no_trailing_slash(_Filename);
|
||||
|
||||
int ret=_stat64(_path,&st);
|
||||
|
||||
if (_path != _Filename)
|
||||
free (_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct stat));
|
||||
return -1;
|
||||
}
|
||||
/* struct stat and struct _stat64i32
|
||||
are the same for this case. */
|
||||
_Stat->st_dev=st.st_dev;
|
||||
_Stat->st_ino=st.st_ino;
|
||||
_Stat->st_mode=st.st_mode;
|
||||
_Stat->st_nlink=st.st_nlink;
|
||||
_Stat->st_uid=st.st_uid;
|
||||
_Stat->st_gid=st.st_gid;
|
||||
_Stat->st_rdev=st.st_rdev;
|
||||
_Stat->st_size=(_off_t) st.st_size;
|
||||
_Stat->st_atime=st.st_atime;
|
||||
_Stat->st_mtime=st.st_mtime;
|
||||
_Stat->st_ctime=st.st_ctime;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
/* Add __imp__fstat and __imp__stat symbols. */
|
||||
int (*__MINGW_IMP_SYMBOL(stat))(const char *,struct stat *) = &stat;
|
||||
|
||||
89
lib/libc/mingw/stdio/_stat64i32.c
vendored
89
lib/libc/mingw/stdio/_stat64i32.c
vendored
@ -1,77 +1,26 @@
|
||||
#define __CRT__NO_INLINE
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
static char*
|
||||
_mingw_no_trailing_slash (const char* _path)
|
||||
{
|
||||
int len;
|
||||
char *p;
|
||||
|
||||
p = (char*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = strlen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == '\\' || _path[0] == '/')
|
||||
&& (_path[1] == '\\' || _path[1] == '/'))
|
||||
{
|
||||
const char *r = &_path[2];
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != '\\' && *r != '/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == '/' || _path[len - 1] == '\\')
|
||||
{
|
||||
p = (char*)malloc (len);
|
||||
memcpy (p, _path, len - 1);
|
||||
p[len - 1] = '\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* When the file size does not fit into the st_size field:
|
||||
* crtdll-msvcr90 msvcr100 msvcr110+
|
||||
* st_size truncate 0 0
|
||||
* errno no change no change EOVERFLOW
|
||||
* returns 0 -1 -1
|
||||
*
|
||||
* This file is used only for pre-msvcr80 builds,
|
||||
* So use the pre-msvcr80 behavior - truncate without error.
|
||||
*/
|
||||
int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
|
||||
{
|
||||
struct _stat64 st;
|
||||
char *_path = _mingw_no_trailing_slash(_Name);
|
||||
|
||||
int ret=_stat64(_path,&st);
|
||||
|
||||
if (_path != _Name)
|
||||
free(_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct _stat64i32));
|
||||
return -1;
|
||||
}
|
||||
int ret=_stat64(_Name,&st);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
_Stat->st_dev=st.st_dev;
|
||||
_Stat->st_ino=st.st_ino;
|
||||
_Stat->st_mode=st.st_mode;
|
||||
@ -79,10 +28,10 @@ int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat)
|
||||
_Stat->st_uid=st.st_uid;
|
||||
_Stat->st_gid=st.st_gid;
|
||||
_Stat->st_rdev=st.st_rdev;
|
||||
_Stat->st_size=(_off_t) st.st_size;
|
||||
_Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */
|
||||
_Stat->st_atime=st.st_atime;
|
||||
_Stat->st_mtime=st.st_mtime;
|
||||
_Stat->st_ctime=st.st_ctime;
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int (__cdecl *__MINGW_IMP_SYMBOL(_stat64i32))(const char *, struct _stat64i32 *) = _stat64i32;
|
||||
|
||||
2
lib/libc/mingw/stdio/_wfindfirst64i32.c
vendored
2
lib/libc/mingw/stdio/_wfindfirst64i32.c
vendored
@ -7,7 +7,7 @@ intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i3
|
||||
struct _wfinddata64_t fd;
|
||||
intptr_t ret = _wfindfirst64(_Filename,&fd);
|
||||
if (ret == -1) {
|
||||
memset(_FindData,0,sizeof(struct _wfinddata64i32_t));
|
||||
*_FindData = (struct _wfinddata64i32_t){0};
|
||||
return -1;
|
||||
}
|
||||
_FindData->attrib=fd.attrib;
|
||||
|
||||
2
lib/libc/mingw/stdio/_wfindnext64i32.c
vendored
2
lib/libc/mingw/stdio/_wfindnext64i32.c
vendored
@ -7,7 +7,7 @@ int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_Find
|
||||
struct _wfinddata64_t fd;
|
||||
int ret = _wfindnext64(_FindHandle,&fd);
|
||||
if (ret == -1) {
|
||||
memset(_FindData,0,sizeof(struct _wfinddata64i32_t));
|
||||
*_FindData = (struct _wfinddata64i32_t){0};
|
||||
return -1;
|
||||
}
|
||||
_FindData->attrib=fd.attrib;
|
||||
|
||||
119
lib/libc/mingw/stdio/_wstat.c
vendored
119
lib/libc/mingw/stdio/_wstat.c
vendored
@ -1,119 +0,0 @@
|
||||
#define __CRT__NO_INLINE
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <malloc.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
*/
|
||||
|
||||
static wchar_t*
|
||||
_mingw_no_trailing_slash (const wchar_t* _path)
|
||||
{
|
||||
int len;
|
||||
wchar_t *p;
|
||||
|
||||
p = (wchar_t*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = wcslen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == L'\\' || _path[0] == L'/')
|
||||
&& (_path[1] == L'\\' || _path[1] == L'/'))
|
||||
{
|
||||
const wchar_t *r = &_path[2];
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == L'/' || _path[len - 1] == L'\\')
|
||||
{
|
||||
p = (wchar_t*)malloc (len * sizeof(wchar_t));
|
||||
memcpy (p, _path, (len - 1) * sizeof(wchar_t));
|
||||
p[len - 1] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
/* FIXME: Relying on _USE_32BIT_TIME_T, which is a user-macro,
|
||||
during CRT compilation is plainly broken. Need an appropriate
|
||||
implementation to provide users the ability of compiling the
|
||||
CRT only with 32-bit time_t behavior. */
|
||||
#if defined(_USE_32BIT_TIME_T)
|
||||
int __cdecl
|
||||
wstat(const wchar_t *_Filename,struct stat *_Stat)
|
||||
{
|
||||
struct _stat32 st;
|
||||
wchar_t *_path = _mingw_no_trailing_slash(_Filename);
|
||||
|
||||
int ret=_wstat32(_path,&st);
|
||||
|
||||
if (_path != _Filename)
|
||||
free (_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct stat));
|
||||
return -1;
|
||||
}
|
||||
/* struct stat and struct _stat32
|
||||
are the same for this case. */
|
||||
memcpy(_Stat, &st, sizeof(struct _stat32));
|
||||
return ret;
|
||||
}
|
||||
#else
|
||||
int __cdecl
|
||||
wstat(const wchar_t *_Filename,struct stat *_Stat)
|
||||
{
|
||||
struct _stat64 st;
|
||||
wchar_t *_path = _mingw_no_trailing_slash(_Filename);
|
||||
|
||||
int ret=_wstat64(_path,&st);
|
||||
|
||||
if (_path != _Filename)
|
||||
free (_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct stat));
|
||||
return -1;
|
||||
}
|
||||
/* struct stat and struct _stat64i32
|
||||
are the same for this case. */
|
||||
_Stat->st_dev=st.st_dev;
|
||||
_Stat->st_ino=st.st_ino;
|
||||
_Stat->st_mode=st.st_mode;
|
||||
_Stat->st_nlink=st.st_nlink;
|
||||
_Stat->st_uid=st.st_uid;
|
||||
_Stat->st_gid=st.st_gid;
|
||||
_Stat->st_rdev=st.st_rdev;
|
||||
_Stat->st_size=(_off_t) st.st_size;
|
||||
_Stat->st_atime=st.st_atime;
|
||||
_Stat->st_mtime=st.st_mtime;
|
||||
_Stat->st_ctime=st.st_ctime;
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
||||
89
lib/libc/mingw/stdio/_wstat64i32.c
vendored
89
lib/libc/mingw/stdio/_wstat64i32.c
vendored
@ -1,77 +1,26 @@
|
||||
#define __CRT__NO_INLINE
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
/**
|
||||
* Returns _path without trailing slash if any
|
||||
*
|
||||
* - if _path has no trailing slash, the function returns it
|
||||
* - if _path has a trailing slash, but is of the form C:/, then it returns it
|
||||
* - otherwise, the function creates a new string, which is a copy of _path
|
||||
* without the trailing slash. It is then the responsibility of the caller
|
||||
* to free it.
|
||||
* 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.
|
||||
*/
|
||||
|
||||
static wchar_t*
|
||||
_mingw_no_trailing_slash (const wchar_t* _path)
|
||||
{
|
||||
int len;
|
||||
wchar_t *p;
|
||||
|
||||
p = (wchar_t*)_path;
|
||||
|
||||
if (_path && *_path) {
|
||||
len = wcslen (_path);
|
||||
|
||||
/* Ignore X:\ */
|
||||
|
||||
if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':'))
|
||||
return p;
|
||||
|
||||
/* Check UNC \\abc\<name>\ */
|
||||
if ((_path[0] == L'\\' || _path[0] == L'/')
|
||||
&& (_path[1] == L'\\' || _path[1] == L'/'))
|
||||
{
|
||||
const wchar_t *r = &_path[2];
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
while (*r != 0 && *r != L'\\' && *r != L'/')
|
||||
++r;
|
||||
if (*r != 0)
|
||||
++r;
|
||||
if (*r == 0)
|
||||
return p;
|
||||
}
|
||||
|
||||
if (_path[len - 1] == L'/' || _path[len - 1] == L'\\')
|
||||
{
|
||||
p = (wchar_t*)malloc (len * sizeof(wchar_t));
|
||||
memcpy (p, _path, (len - 1) * sizeof(wchar_t));
|
||||
p[len - 1] = L'\0';
|
||||
}
|
||||
}
|
||||
|
||||
return p;
|
||||
}
|
||||
#include <sys/stat.h>
|
||||
|
||||
/* When the file size does not fit into the st_size field:
|
||||
* crtdll-msvcr90 msvcr100 msvcr110+
|
||||
* st_size truncate 0 0
|
||||
* errno no change no change EOVERFLOW
|
||||
* returns 0 -1 -1
|
||||
*
|
||||
* This file is used only for pre-msvcr80 builds,
|
||||
* So use the pre-msvcr80 behavior - truncate without error.
|
||||
*/
|
||||
int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat)
|
||||
{
|
||||
struct _stat64 st;
|
||||
wchar_t *_path = _mingw_no_trailing_slash(_Name);
|
||||
|
||||
int ret=_wstat64(_path,&st);
|
||||
|
||||
if (_path != _Name)
|
||||
free(_path);
|
||||
|
||||
if (ret == -1) {
|
||||
memset(_Stat,0,sizeof(struct _stat64i32));
|
||||
return -1;
|
||||
}
|
||||
int ret=_wstat64(_Name,&st);
|
||||
if (ret != 0)
|
||||
return ret;
|
||||
_Stat->st_dev=st.st_dev;
|
||||
_Stat->st_ino=st.st_ino;
|
||||
_Stat->st_mode=st.st_mode;
|
||||
@ -79,10 +28,10 @@ int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat)
|
||||
_Stat->st_uid=st.st_uid;
|
||||
_Stat->st_gid=st.st_gid;
|
||||
_Stat->st_rdev=st.st_rdev;
|
||||
_Stat->st_size=(_off_t) st.st_size;
|
||||
_Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */
|
||||
_Stat->st_atime=st.st_atime;
|
||||
_Stat->st_mtime=st.st_mtime;
|
||||
_Stat->st_ctime=st.st_ctime;
|
||||
return ret;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int (__cdecl *__MINGW_IMP_SYMBOL(_wstat64i32))(const wchar_t *, struct _stat64i32 *) = _wstat64i32;
|
||||
|
||||
21
lib/libc/mingw/stdio/mingw_pformat.c
vendored
21
lib/libc/mingw/stdio/mingw_pformat.c
vendored
@ -512,8 +512,7 @@ void __pformat_putchars( const char *s, int count, __pformat_t *stream )
|
||||
wchar_t w[12], *p;
|
||||
while( count > 0 )
|
||||
{
|
||||
mbstate_t ps;
|
||||
memset(&ps, 0, sizeof(ps) );
|
||||
mbstate_t ps = {0};
|
||||
--count;
|
||||
p = &w[0];
|
||||
l = mbrtowc (p, s, strlen (s), &ps);
|
||||
@ -1175,11 +1174,8 @@ void __pformat_emit_radix_point( __pformat_t *stream )
|
||||
/* Radix point initialisation not yet completed;
|
||||
* establish a multibyte to `wchar_t' converter...
|
||||
*/
|
||||
int len; wchar_t rpchr; mbstate_t state;
|
||||
|
||||
/* Initialise the conversion state...
|
||||
*/
|
||||
memset( &state, 0, sizeof( state ) );
|
||||
int len; wchar_t rpchr;
|
||||
mbstate_t state = {0};
|
||||
|
||||
/* Fetch and convert the localised radix point representation...
|
||||
*/
|
||||
@ -1203,11 +1199,8 @@ void __pformat_emit_radix_point( __pformat_t *stream )
|
||||
#ifdef __BUILD_WIDEAPI
|
||||
__pformat_putc (stream->rpchr, stream);
|
||||
#else
|
||||
int len; char buf[len = stream->rplen]; mbstate_t state;
|
||||
|
||||
/* Initialise the conversion state...
|
||||
*/
|
||||
memset( &state, 0, sizeof( state ) );
|
||||
int len; char buf[len = stream->rplen];
|
||||
mbstate_t state = {0};
|
||||
|
||||
/* Convert the `wchar_t' representation to multibyte...
|
||||
*/
|
||||
@ -3123,8 +3116,8 @@ __pformat (int flags, void *dest, int max, const APICHAR *fmt, va_list argv)
|
||||
if (state == PFORMAT_INIT)
|
||||
{
|
||||
stream.flags |= PFORMAT_GROUPED; /* $$$$ */
|
||||
int len; wchar_t rpchr; mbstate_t cstate;
|
||||
memset (&cstate, 0, sizeof(state));
|
||||
int len; wchar_t rpchr;
|
||||
mbstate_t cstate = {0};
|
||||
if ((len = mbrtowc( &rpchr, localeconv()->thousands_sep, 16, &cstate)) > 0)
|
||||
stream.thousands_chr = rpchr;
|
||||
stream.thousands_chr_len = len;
|
||||
|
||||
10
lib/libc/mingw/stdio/mingw_sformat.c
vendored
10
lib/libc/mingw/stdio/mingw_sformat.c
vendored
@ -307,7 +307,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp)
|
||||
char seen_dot, seen_exp, is_neg, not_in;
|
||||
char *tmp_wbuf_ptr, buf[MB_LEN_MAX];
|
||||
const char *lc_decimal_point, *lc_thousands_sep;
|
||||
mbstate_t state, cstate;
|
||||
mbstate_t state = {0}, cstate;
|
||||
union {
|
||||
unsigned long long ull;
|
||||
unsigned long ul;
|
||||
@ -323,8 +323,6 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
memset (&state, 0, sizeof (state));
|
||||
|
||||
lc_decimal_point = localeconv()->decimal_point;
|
||||
lc_thousands_sep = localeconv()->thousands_sep;
|
||||
if (lc_thousands_sep != NULL && *lc_thousands_sep == 0)
|
||||
@ -682,7 +680,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == EOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&cstate, 0, sizeof (cstate));
|
||||
cstate = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
@ -854,7 +852,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == EOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&cstate, 0, sizeof (cstate));
|
||||
cstate = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
@ -1459,7 +1457,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == EOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&cstate, 0, sizeof (cstate));
|
||||
cstate = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
10
lib/libc/mingw/stdio/mingw_swformat.c
vendored
10
lib/libc/mingw/stdio/mingw_swformat.c
vendored
@ -332,10 +332,10 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp)
|
||||
return EOF;
|
||||
}
|
||||
|
||||
memset (&state, 0, sizeof(state));
|
||||
state = (mbstate_t){0};
|
||||
clen = mbrtowc( &wc, localeconv()->decimal_point, 16, &state);
|
||||
lc_decimal_point = (clen > 0 ? wc : '.');
|
||||
memset( &state, 0, sizeof( state ) );
|
||||
state = (mbstate_t){0};
|
||||
clen = mbrtowc( &wc, localeconv()->thousands_sep, 16, &state);
|
||||
lc_thousands_sep = (clen > 0 ? wc : 0);
|
||||
|
||||
@ -596,7 +596,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == WEOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&state, 0, sizeof (state));
|
||||
state = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
@ -744,7 +744,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == WEOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&state, 0, sizeof (state));
|
||||
state = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
@ -1459,7 +1459,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp)
|
||||
if ((c = in_ch (s, &read_in)) == WEOF)
|
||||
return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf);
|
||||
|
||||
memset (&state, 0, sizeof (state));
|
||||
state = (mbstate_t){0};
|
||||
|
||||
do
|
||||
{
|
||||
|
||||
4
lib/libc/mingw/stdio/mingw_vfscanf.c
vendored
4
lib/libc/mingw/stdio/mingw_vfscanf.c
vendored
@ -7,8 +7,6 @@
|
||||
int
|
||||
__mingw_vfscanf (FILE *s, const char *format, va_list argp)
|
||||
{
|
||||
_IFP ifp;
|
||||
memset (&ifp, 0, sizeof (_IFP));
|
||||
ifp.fp = s;
|
||||
_IFP ifp = { .fp = s };
|
||||
return __mingw_sformat (&ifp, format, argp);
|
||||
}
|
||||
|
||||
4
lib/libc/mingw/stdio/mingw_vfwscanf.c
vendored
4
lib/libc/mingw/stdio/mingw_vfwscanf.c
vendored
@ -7,8 +7,6 @@
|
||||
int
|
||||
__mingw_vfwscanf (FILE *s, const wchar_t *format, va_list argp)
|
||||
{
|
||||
_IFPW ifp;
|
||||
memset (&ifp, 0, sizeof (_IFPW));
|
||||
ifp.fp = s;
|
||||
_IFPW ifp = { .fp = s };
|
||||
return __mingw_swformat (&ifp, format, argp);
|
||||
}
|
||||
|
||||
5
lib/libc/mingw/stdio/mingw_vsscanf.c
vendored
5
lib/libc/mingw/stdio/mingw_vsscanf.c
vendored
@ -7,9 +7,6 @@
|
||||
int
|
||||
__mingw_vsscanf (const char *s, const char *format, va_list argp)
|
||||
{
|
||||
_IFP ifp;
|
||||
memset (&ifp, 0, sizeof (_IFP));
|
||||
ifp.str = s;
|
||||
ifp.is_string = 1;
|
||||
_IFP ifp = { .str = s, .is_string = 1 };
|
||||
return __mingw_sformat (&ifp, format, argp);
|
||||
}
|
||||
|
||||
5
lib/libc/mingw/stdio/mingw_vswscanf.c
vendored
5
lib/libc/mingw/stdio/mingw_vswscanf.c
vendored
@ -7,9 +7,6 @@
|
||||
int
|
||||
__mingw_vswscanf (const wchar_t *s, const wchar_t *format, va_list argp)
|
||||
{
|
||||
_IFPW ifp;
|
||||
memset (&ifp, 0, sizeof (_IFPW));
|
||||
ifp.str = s;
|
||||
ifp.is_string = 1;
|
||||
_IFPW ifp = { .str = s, .is_string = 1 };
|
||||
return __mingw_swformat (&ifp, format, argp);
|
||||
}
|
||||
|
||||
15
lib/libc/mingw/stdio/ucrt___local_stdio_printf_options.c
vendored
Normal file
15
lib/libc/mingw/stdio/ucrt___local_stdio_printf_options.c
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define _UCRT
|
||||
#include <corecrt_stdio_config.h>
|
||||
|
||||
static unsigned __int64 options = _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING;
|
||||
|
||||
unsigned __int64* __local_stdio_printf_options(void) {
|
||||
return &options;
|
||||
}
|
||||
15
lib/libc/mingw/stdio/ucrt___local_stdio_scanf_options.c
vendored
Normal file
15
lib/libc/mingw/stdio/ucrt___local_stdio_scanf_options.c
vendored
Normal file
@ -0,0 +1,15 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define _UCRT
|
||||
#include <corecrt_stdio_config.h>
|
||||
|
||||
static unsigned __int64 options = _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS;
|
||||
|
||||
unsigned __int64* __local_stdio_scanf_options(void) {
|
||||
return &options;
|
||||
}
|
||||
1
lib/libc/mingw/stdio/ucrt__scprintf.c
vendored
1
lib/libc/mingw/stdio/ucrt__scprintf.c
vendored
@ -18,4 +18,3 @@ int __cdecl _scprintf(const char * __restrict__ _Format, ...)
|
||||
va_end(_ArgList);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_scprintf))(const char *__restrict__, ...) = _scprintf;
|
||||
|
||||
1
lib/libc/mingw/stdio/ucrt__snprintf.c
vendored
1
lib/libc/mingw/stdio/ucrt__snprintf.c
vendored
@ -18,4 +18,3 @@ int __cdecl _snprintf(char * __restrict__ _Dest, size_t _Count, const char * __r
|
||||
va_end(_Args);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_snprintf))(char *__restrict__, size_t, const char *__restrict__, ...) = _snprintf;
|
||||
|
||||
3
lib/libc/mingw/stdio/ucrt__snscanf.c
vendored
3
lib/libc/mingw/stdio/ucrt__snscanf.c
vendored
@ -14,8 +14,7 @@ int __cdecl _snscanf(const char * __restrict__ _Src, size_t _MaxCount, const cha
|
||||
int ret;
|
||||
va_list _ArgList;
|
||||
va_start(_ArgList, _Format);
|
||||
ret = __stdio_common_vsscanf(0, _Src, _MaxCount, _Format, NULL, _ArgList);
|
||||
ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Src, _MaxCount, _Format, NULL, _ArgList);
|
||||
va_end(_ArgList);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_snscanf))(const char *__restrict__, size_t, const char * __restrict__, ...) = _snscanf;
|
||||
|
||||
18
lib/libc/mingw/stdio/ucrt__snwprintf.c
vendored
18
lib/libc/mingw/stdio/ucrt__snwprintf.c
vendored
@ -4,25 +4,12 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
// For ucrt, this function normally is an inline function in stdio.h.
|
||||
// libmingwex doesn't use the ucrt version of headers, and wassert.c can
|
||||
// end up requiring a concrete version of it.
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Winline"
|
||||
#endif
|
||||
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define _UCRT
|
||||
|
||||
#define _snwprintf real__snwprintf
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#undef _snwprintf
|
||||
|
||||
int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * restrict _Format, ...);
|
||||
|
||||
int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * restrict _Format, ...)
|
||||
@ -34,8 +21,3 @@ int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t *
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_snwprintf))(wchar_t *restrict, size_t, const wchar_t *restrict, ...) = _snwprintf;
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
1
lib/libc/mingw/stdio/ucrt__vsnprintf.c
vendored
1
lib/libc/mingw/stdio/ucrt__vsnprintf.c
vendored
@ -12,4 +12,3 @@ int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __re
|
||||
{
|
||||
return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args);
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_vsnprintf))(char *__restrict__, size_t, const char *__restrict__, va_list) = _vsnprintf;
|
||||
|
||||
1
lib/libc/mingw/stdio/ucrt__vsnwprintf.c
vendored
1
lib/libc/mingw/stdio/ucrt__vsnwprintf.c
vendored
@ -12,4 +12,3 @@ int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t
|
||||
{
|
||||
return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args);
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(_vsnwprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list) = _vsnwprintf;
|
||||
|
||||
1
lib/libc/mingw/stdio/ucrt_fprintf.c
vendored
1
lib/libc/mingw/stdio/ucrt_fprintf.c
vendored
@ -17,4 +17,3 @@ int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format,
|
||||
__builtin_va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(fprintf))(FILE *__restrict__, const char *__restrict__, ...) = fprintf;
|
||||
|
||||
3
lib/libc/mingw/stdio/ucrt_fscanf.c
vendored
3
lib/libc/mingw/stdio/ucrt_fscanf.c
vendored
@ -12,8 +12,7 @@ int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,.
|
||||
__builtin_va_list __ap;
|
||||
int __ret;
|
||||
__builtin_va_start(__ap, _Format);
|
||||
__ret = __stdio_common_vfscanf(0, _File, _Format, NULL, __ap);
|
||||
__ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _File, _Format, NULL, __ap);
|
||||
__builtin_va_end(__ap);
|
||||
return __ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(fscanf))(FILE *__restrict__, const char *__restrict__, ...) = fscanf;
|
||||
|
||||
20
lib/libc/mingw/stdio/ucrt_fwprintf.c
vendored
20
lib/libc/mingw/stdio/ucrt_fwprintf.c
vendored
@ -4,25 +4,12 @@
|
||||
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
||||
*/
|
||||
|
||||
// For ucrt, this function normally is an inline function in stdio.h.
|
||||
// libmingwex doesn't use the ucrt version of headers, and wassert.c can
|
||||
// end up requiring a concrete version of it.
|
||||
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic push
|
||||
#pragma GCC diagnostic ignored "-Winline"
|
||||
#endif
|
||||
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define _UCRT
|
||||
|
||||
#define fwprintf real_fwprintf
|
||||
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
|
||||
#undef fwprintf
|
||||
|
||||
int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...);
|
||||
|
||||
int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...)
|
||||
@ -30,12 +17,7 @@ int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...)
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start(ap, fmt);
|
||||
ret = vfwprintf(ptr, fmt, ap);
|
||||
ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, ptr, fmt, NULL, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(fwprintf))(FILE *, const wchar_t *, ...) = fwprintf;
|
||||
#ifdef __GNUC__
|
||||
#pragma GCC diagnostic pop
|
||||
#endif
|
||||
|
||||
18
lib/libc/mingw/stdio/ucrt_fwscanf.c
vendored
Normal file
18
lib/libc/mingw/stdio/ucrt_fwscanf.c
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
|
||||
#undef __MSVCRT_VERSION__
|
||||
#define _UCRT
|
||||
#include <stdio.h>
|
||||
|
||||
int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) {
|
||||
__builtin_va_list __ap;
|
||||
int __ret;
|
||||
__builtin_va_start(__ap, _Format);
|
||||
__ret = __stdio_common_vfwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _File, _Format, NULL, __ap);
|
||||
__builtin_va_end(__ap);
|
||||
return __ret;
|
||||
}
|
||||
3
lib/libc/mingw/stdio/ucrt_ms_fwprintf.c
vendored
3
lib/libc/mingw/stdio/ucrt_ms_fwprintf.c
vendored
@ -17,8 +17,7 @@ int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...)
|
||||
va_list ap;
|
||||
int ret;
|
||||
va_start(ap, fmt);
|
||||
ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap);
|
||||
ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, fmt, NULL, ap);
|
||||
va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf;
|
||||
|
||||
1
lib/libc/mingw/stdio/ucrt_printf.c
vendored
1
lib/libc/mingw/stdio/ucrt_printf.c
vendored
@ -17,4 +17,3 @@ int __cdecl printf(const char * __restrict__ _Format,...)
|
||||
__builtin_va_end(ap);
|
||||
return ret;
|
||||
}
|
||||
int __cdecl (*__MINGW_IMP_SYMBOL(printf))(const char *__restrict__, ...) = printf;
|
||||
|
||||
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