| author | |
| committer | |
| log | 879bc2e5cb614bdb1b7a2426c9746989089bccd3 |
| tree | 9ce260ac4bb0f6658356e84432cea0627a2d76af |
| parent | 0979e56bd284adf161e1765200785a376fd7bb53 |
| signature |
145 files changed, 1820 insertions(+), 1511 deletions(-)
lib/libc/mingw/cfguard/mingw_cfguard_support.c-8| ... | @@ -17,14 +17,6 @@ | ... | @@ -17,14 +17,6 @@ |
| 17 | // really matter here because this is a no-op anyway. | 17 | // really matter here because this is a no-op anyway. |
| 18 | static void __guard_check_icall_dummy(void) {} | 18 | static void __guard_check_icall_dummy(void) {} |
| 19 | 19 | ||
| 20 | // When CFGuard is not active, directly tail-call the target address, which | ||
| 21 | // is passed via %rax. | ||
| 22 | __asm__( | ||
| 23 | ".globl __guard_dispatch_icall_dummy\n" | ||
| 24 | "__guard_dispatch_icall_dummy:\n" | ||
| 25 | " jmp *%rax\n" | ||
| 26 | ); | ||
| 27 | |||
| 28 | // This is intentionally declared as _not_ a function pointer, so that the | 20 | // This is intentionally declared as _not_ a function pointer, so that the |
| 29 | // jmp instruction is not included as a valid call target for CFGuard. | 21 | // jmp instruction is not included as a valid call target for CFGuard. |
| 30 | extern void *__guard_dispatch_icall_dummy; | 22 | extern void *__guard_dispatch_icall_dummy; |
lib/libc/mingw/crt/CRT_fp10.c-8| ... | @@ -8,19 +8,11 @@ void _fpreset (void); | ... | @@ -8,19 +8,11 @@ void _fpreset (void); |
| 8 | 8 | ||
| 9 | void _fpreset (void) | 9 | void _fpreset (void) |
| 10 | { | 10 | { |
| 11 | #if defined(_ARM_) || defined(__arm__) | ||
| 12 | __asm__ __volatile__ ( | ||
| 13 | "vmsr	fpscr, %0\n\t" : : "r"(0 /* INITIAL_FPSCR */)); | ||
| 14 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 15 | __asm__ __volatile__ ( | ||
| 16 | "msr	fpcr, %0\n\t" : : "r"(0LL /* INITIAL_FPSCR */)); | ||
| 17 | #else | ||
| 18 | #ifdef __GNUC__ | 11 | #ifdef __GNUC__ |
| 19 | __asm__ ("fninit"); | 12 | __asm__ ("fninit"); |
| 20 | #else /* msvc: */ | 13 | #else /* msvc: */ |
| 21 | __asm fninit; | 14 | __asm fninit; |
| 22 | #endif | 15 | #endif |
| 23 | #endif | ||
| 24 | } | 16 | } |
| 25 | 17 | ||
| 26 | #ifdef __GNUC__ | 18 | #ifdef __GNUC__ |
lib/libc/mingw/crt/crtdll.c+47-80| ... | @@ -4,12 +4,6 @@ | ... | @@ -4,12 +4,6 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifdef CRTDLL | ||
| 8 | #undef CRTDLL | ||
| 9 | #ifndef _DLL | ||
| 10 | #define _DLL | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include <oscalls.h> | 7 | #include <oscalls.h> |
| 14 | #include <internal.h> | 8 | #include <internal.h> |
| 15 | #include <stdlib.h> | 9 | #include <stdlib.h> |
| ... | @@ -19,20 +13,14 @@ | ... | @@ -19,20 +13,14 @@ |
| 19 | #include <crtdbg.h> | 13 | #include <crtdbg.h> |
| 20 | 14 | ||
| 21 | #ifndef _CRTIMP | 15 | #ifndef _CRTIMP |
| 22 | #ifdef CRTDLL | ||
| 23 | #define _CRTIMP __declspec(dllexport) | ||
| 24 | #else | ||
| 25 | #ifdef _DLL | ||
| 26 | #define _CRTIMP __declspec(dllimport) | 16 | #define _CRTIMP __declspec(dllimport) |
| 27 | #else | ||
| 28 | #define _CRTIMP | ||
| 29 | #endif | ||
| 30 | #endif | ||
| 31 | #endif | 17 | #endif |
| 32 | #include <sect_attribs.h> | 18 | #include <sect_attribs.h> |
| 33 | #include <locale.h> | 19 | #include <locale.h> |
| 34 | 20 | ||
| 35 | extern void __cdecl _initterm(_PVFV *,_PVFV *); | 21 | #if defined(__x86_64__) && !defined(__SEH__) |
| 22 | extern int __mingw_init_ehandler (void); | ||
| 23 | #endif | ||
| 36 | extern void __main (); | 24 | extern void __main (); |
| 37 | extern void _pei386_runtime_relocator (void); | 25 | extern void _pei386_runtime_relocator (void); |
| 38 | extern _PIFV __xi_a[]; | 26 | extern _PIFV __xi_a[]; |
| ... | @@ -50,20 +38,6 @@ static _onexit_table_t atexit_table; | ... | @@ -50,20 +38,6 @@ static _onexit_table_t atexit_table; |
| 50 | 38 | ||
| 51 | extern int __mingw_app_type; | 39 | extern int __mingw_app_type; |
| 52 | 40 | ||
| 53 | extern WINBOOL WINAPI DllMain (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved); | ||
| 54 | |||
| 55 | extern WINBOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID); | ||
| 56 | |||
| 57 | static int pre_c_init (void); | ||
| 58 | |||
| 59 | _CRTALLOC(".CRT$XIAA") _PIFV pcinit = pre_c_init; | ||
| 60 | |||
| 61 | static int | ||
| 62 | pre_c_init (void) | ||
| 63 | { | ||
| 64 | return _initialize_onexit_table(&atexit_table); | ||
| 65 | } | ||
| 66 | |||
| 67 | WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | 41 | WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) |
| 68 | { | 42 | { |
| 69 | if (dwReason == DLL_PROCESS_DETACH) | 43 | if (dwReason == DLL_PROCESS_DETACH) |
| ... | @@ -77,10 +51,11 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ... | @@ -77,10 +51,11 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) |
| 77 | { | 51 | { |
| 78 | void *lock_free = NULL; | 52 | void *lock_free = NULL; |
| 79 | void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; | 53 | void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; |
| 80 | int nested = FALSE; | 54 | BOOL nested = FALSE; |
| 55 | int ret = 0; | ||
| 81 | 56 | ||
| 82 | while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock, | 57 | while ((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock, |
| 83 | 							 fiberid, 0)) != 0) | 58 | 							 fiberid, NULL)) != 0) |
| 84 | 	{ | 59 | 	{ |
| 85 | 	 if (lock_free == fiberid) | 60 | 	 if (lock_free == fiberid) |
| 86 | 	 { | 61 | 	 { |
| ... | @@ -89,25 +64,37 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ... | @@ -89,25 +64,37 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) |
| 89 | 	 } | 64 | 	 } |
| 90 | 	 Sleep(1000); | 65 | 	 Sleep(1000); |
| 91 | 	} | 66 | 	} |
| 92 | if (__native_startup_state == __initializing) | 67 | if (__native_startup_state != __uninitialized) |
| 93 | 	{ | 68 | 	{ |
| 94 | 	 _amsg_exit (31); | 69 | 	 _amsg_exit (31); |
| 95 | 	} | 70 | 	} |
| 96 | else if (__native_startup_state == __uninitialized) | 71 | else |
| 97 | 	{ | 72 | 	{ |
| 98 | 	 __native_startup_state = __initializing; | 73 | 	 __native_startup_state = __initializing; |
| 99 | 	 | 74 | 	 |
| 100 | 	 if (_initterm_e (__xi_a, __xi_z) != 0) | 75 | 	 _pei386_runtime_relocator (); |
| 101 | 	 return FALSE; | 76 | #if defined(__x86_64__) && !defined(__SEH__) |
| 102 | 	} | 77 | 	 __mingw_init_ehandler (); |
| 103 | if (__native_startup_state == __initializing) | 78 | #endif |
| 104 | 	{ | 79 | 	 ret = _initialize_onexit_table (&atexit_table); |
| 80 | 	 if (ret != 0) | ||
| 81 | 	 goto i__leave; | ||
| 82 | 	 ret = _initterm_e (__xi_a, __xi_z); | ||
| 83 | 	 if (ret != 0) | ||
| 84 | 	 goto i__leave; | ||
| 105 | 	 _initterm (__xc_a, __xc_z); | 85 | 	 _initterm (__xc_a, __xc_z); |
| 86 | 	 __main (); | ||
| 87 | |||
| 106 | 	 __native_startup_state = __initialized; | 88 | 	 __native_startup_state = __initialized; |
| 107 | 	} | 89 | 	} |
| 90 | i__leave: | ||
| 108 | if (! nested) | 91 | if (! nested) |
| 109 | 	{ | 92 | 	{ |
| 110 | 	 (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); | 93 | 	 (void) InterlockedExchangePointer (&__native_startup_lock, NULL); |
| 94 | 	} | ||
| 95 | if (ret != 0) | ||
| 96 | 	{ | ||
| 97 | 	 return FALSE; | ||
| 111 | 	} | 98 | 	} |
| 112 | if (__dyn_tls_init_callback != NULL) | 99 | if (__dyn_tls_init_callback != NULL) |
| 113 | 	{ | 100 | 	{ |
| ... | @@ -118,8 +105,16 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ... | @@ -118,8 +105,16 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) |
| 118 | else if (dwReason == DLL_PROCESS_DETACH) | 105 | else if (dwReason == DLL_PROCESS_DETACH) |
| 119 | { | 106 | { |
| 120 | void *lock_free = NULL; | 107 | void *lock_free = NULL; |
| 121 | while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,(PVOID) 1, 0)) != 0) | 108 | void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase; |
| 109 | BOOL nested = FALSE; | ||
| 110 | |||
| 111 | while ((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock, fiberid, NULL)) != 0) | ||
| 122 | 	{ | 112 | 	{ |
| 113 | 	 if (lock_free == fiberid) | ||
| 114 | 	 { | ||
| 115 | 	 nested = TRUE; | ||
| 116 | 	 break; | ||
| 117 | 	 } | ||
| 123 | 	 Sleep(1000); | 118 | 	 Sleep(1000); |
| 124 | 	} | 119 | 	} |
| 125 | if (__native_startup_state != __initialized) | 120 | if (__native_startup_state != __initialized) |
| ... | @@ -130,84 +125,56 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ... | @@ -130,84 +125,56 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) |
| 130 | 	{ | 125 | 	{ |
| 131 | _execute_onexit_table(&atexit_table); | 126 | _execute_onexit_table(&atexit_table); |
| 132 | 	 __native_startup_state = __uninitialized; | 127 | 	 __native_startup_state = __uninitialized; |
| 133 | 	 (void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); | 128 | 	} |
| 129 | if (! nested) | ||
| 130 | 	{ | ||
| 131 | 	 (void) InterlockedExchangePointer (&__native_startup_lock, NULL); | ||
| 134 | 	} | 132 | 	} |
| 135 | } | 133 | } |
| 136 | return TRUE; | 134 | return TRUE; |
| 137 | } | 135 | } |
| 138 | 136 | ||
| 139 | static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID); | ||
| 140 | |||
| 141 | WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID); | 137 | WINBOOL WINAPI DllMainCRTStartup (HANDLE, DWORD, LPVOID); |
| 142 | #if defined(__x86_64__) && !defined(__SEH__) | ||
| 143 | int __mingw_init_ehandler (void); | ||
| 144 | #endif | ||
| 145 | 138 | ||
| 146 | __attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ | ||
| 147 | WINBOOL WINAPI | ||
| 148 | DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ||
| 149 | { | ||
| 150 | __mingw_app_type = 0; | ||
| 151 | return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved); | ||
| 152 | } | ||
| 153 | |||
| 154 | static | ||
| 155 | #if defined(__i386__) || defined(_X86_) | 139 | #if defined(__i386__) || defined(_X86_) |
| 156 | /* We need to make sure that we align the stack to 16 bytes for the sake of SSE | 140 | /* We need to make sure that we align the stack to 16 bytes for the sake of SSE |
| 157 | opts in DllMain/DllEntryPoint or in functions called from DllMain/DllEntryPoint. */ | 141 | opts in DllMain or in functions called from DllMain. */ |
| 158 | __attribute__((force_align_arg_pointer)) | 142 | __attribute__((force_align_arg_pointer)) |
| 159 | #endif | 143 | #endif |
| 160 | __declspec(noinline) WINBOOL | 144 | __attribute__((used)) /* required due to GNU LD bug: https://sourceware.org/bugzilla/show_bug.cgi?id=30300 */ |
| 161 | __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | 145 | WINBOOL WINAPI |
| 146 | DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved) | ||
| 162 | { | 147 | { |
| 163 | WINBOOL retcode = TRUE; | 148 | WINBOOL retcode = TRUE; |
| 164 | 149 | ||
| 150 | __mingw_app_type = 0; | ||
| 165 | __native_dllmain_reason = dwReason; | 151 | __native_dllmain_reason = dwReason; |
| 166 | if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0) | 152 | if (dwReason == DLL_PROCESS_DETACH && __proc_attached <= 0) |
| 167 | { | 153 | { |
| 168 | 	retcode = FALSE; | 154 | 	retcode = FALSE; |
| 169 | 	goto i__leave; | 155 | 	goto i__leave; |
| 170 | } | 156 | } |
| 171 | _pei386_runtime_relocator (); | ||
| 172 | |||
| 173 | #if defined(__x86_64__) && !defined(__SEH__) | ||
| 174 | if (dwReason == DLL_PROCESS_ATTACH) | ||
| 175 | __mingw_init_ehandler (); | ||
| 176 | #endif | ||
| 177 | 157 | ||
| 178 | if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH) | 158 | if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH) |
| 179 | { | 159 | { |
| 180 | retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved); | 160 | retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved); |
| 181 | if (!retcode) | 161 | if (!retcode) |
| 182 | goto i__leave; | 162 | goto i__leave; |
| 183 | retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved); | ||
| 184 | 	if (! retcode) | ||
| 185 | 	 { | ||
| 186 | 	 if (dwReason == DLL_PROCESS_ATTACH) | ||
| 187 | 	 _CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved); | ||
| 188 | 	 goto i__leave; | ||
| 189 | 	 } | ||
| 190 | } | 163 | } |
| 191 | if (dwReason == DLL_PROCESS_ATTACH) | ||
| 192 | __main (); | ||
| 193 | retcode = DllMain(hDllHandle,dwReason,lpreserved); | 164 | retcode = DllMain(hDllHandle,dwReason,lpreserved); |
| 194 | if (dwReason == DLL_PROCESS_ATTACH && ! retcode) | 165 | if (dwReason == DLL_PROCESS_ATTACH && ! retcode) |
| 195 | { | 166 | { |
| 196 | 	DllMain (hDllHandle, DLL_PROCESS_DETACH, lpreserved); | 167 | 	DllMain (hDllHandle, DLL_PROCESS_DETACH, lpreserved); |
| 197 | 	DllEntryPoint (hDllHandle, DLL_PROCESS_DETACH, lpreserved); | ||
| 198 | 	_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved); | 168 | 	_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved); |
| 199 | } | 169 | } |
| 200 | if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH) | 170 | if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH) |
| 201 | { | 171 | { |
| 202 | retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved); | 172 | 	retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved); |
| 203 | 	if (_CRT_INIT (hDllHandle, dwReason, lpreserved) == FALSE) | ||
| 204 | 	 retcode = FALSE; | ||
| 205 | } | 173 | } |
| 206 | i__leave: | 174 | i__leave: |
| 207 | __native_dllmain_reason = UINT_MAX; | 175 | __native_dllmain_reason = UINT_MAX; |
| 208 | return retcode ; | 176 | return retcode ; |
| 209 | } | 177 | } |
| 210 | #endif | ||
| 211 | 178 | ||
| 212 | int __cdecl atexit (_PVFV func) | 179 | int __cdecl atexit (_PVFV func) |
| 213 | { | 180 | { |
lib/libc/mingw/crt/crtexe.c+4-11| ... | @@ -4,13 +4,6 @@ | ... | @@ -4,13 +4,6 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #undef CRTDLL | ||
| 8 | #ifndef _DLL | ||
| 9 | #define _DLL | ||
| 10 | #endif | ||
| 11 | |||
| 12 | #define SPECIAL_CRTEXE | ||
| 13 | |||
| 14 | #include <oscalls.h> | 7 | #include <oscalls.h> |
| 15 | #include <internal.h> | 8 | #include <internal.h> |
| 16 | #include <process.h> | 9 | #include <process.h> |
| ... | @@ -211,9 +204,9 @@ __tmainCRTStartup (void) | ... | @@ -211,9 +204,9 @@ __tmainCRTStartup (void) |
| 211 | { | 204 | { |
| 212 | void *lock_free = NULL; | 205 | void *lock_free = NULL; |
| 213 | void *fiberid = ((PNT_TIB)NtCurrentTeb())->StackBase; | 206 | void *fiberid = ((PNT_TIB)NtCurrentTeb())->StackBase; |
| 214 | int nested = FALSE; | 207 | BOOL nested = FALSE; |
| 215 | while((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock, | 208 | while((lock_free = InterlockedCompareExchangePointer (&__native_startup_lock, |
| 216 | 							 fiberid, 0)) != 0) | 209 | 							 fiberid, NULL)) != 0) |
| 217 | { | 210 | { |
| 218 | 	if (lock_free == fiberid) | 211 | 	if (lock_free == fiberid) |
| 219 | 	 { | 212 | 	 { |
| ... | @@ -242,7 +235,7 @@ __tmainCRTStartup (void) | ... | @@ -242,7 +235,7 @@ __tmainCRTStartup (void) |
| 242 | } | 235 | } |
| 243 | _ASSERTE(__native_startup_state == __initialized); | 236 | _ASSERTE(__native_startup_state == __initialized); |
| 244 | if (! nested) | 237 | if (! nested) |
| 245 | (VOID)InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0); | 238 | (VOID)InterlockedExchangePointer (&__native_startup_lock, NULL); |
| 246 | 239 | ||
| 247 | if (__dyn_tls_init_callback != NULL) | 240 | if (__dyn_tls_init_callback != NULL) |
| 248 | __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL); | 241 | __dyn_tls_init_callback (NULL, DLL_THREAD_ATTACH, NULL); |
lib/libc/mingw/crt/crtexewin.c-1| ... | @@ -56,7 +56,6 @@ int _tmain (int __UNUSED_PARAM(argc), | ... | @@ -56,7 +56,6 @@ int _tmain (int __UNUSED_PARAM(argc), |
| 56 | 56 | ||
| 57 | { | 57 | { |
| 58 | STARTUPINFO StartupInfo; | 58 | STARTUPINFO StartupInfo; |
| 59 | memset (&StartupInfo, 0, sizeof (STARTUPINFO)); | ||
| 60 | GetStartupInfo (&StartupInfo); | 59 | GetStartupInfo (&StartupInfo); |
| 61 | if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW) | 60 | if (StartupInfo.dwFlags & STARTF_USESHOWWINDOW) |
| 62 | nShowCmd = StartupInfo.wShowWindow; | 61 | nShowCmd = StartupInfo.wShowWindow; |
lib/libc/mingw/crt/dll_argv.c-4| ... | @@ -4,10 +4,6 @@ | ... | @@ -4,10 +4,6 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifdef CRTDLL | ||
| 8 | #undef CRTDLL | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #include <internal.h> | 7 | #include <internal.h> |
| 12 | 8 | ||
| 13 | extern int _dowildcard; | 9 | extern int _dowildcard; |
lib/libc/mingw/crt/dllargv.c-4| ... | @@ -4,10 +4,6 @@ | ... | @@ -4,10 +4,6 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifdef CRTDLL | ||
| 8 | #undef CRTDLL | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #include <internal.h> | 7 | #include <internal.h> |
| 12 | 8 | ||
| 13 | int __CRTDECL | 9 | int __CRTDECL |
lib/libc/mingw/crt/natstart.c+2-2| ... | @@ -10,5 +10,5 @@ | ... | @@ -10,5 +10,5 @@ |
| 10 | _PGLOBAL | 10 | _PGLOBAL |
| 11 | volatile unsigned int __native_dllmain_reason = UINT_MAX; | 11 | volatile unsigned int __native_dllmain_reason = UINT_MAX; |
| 12 | volatile unsigned int __native_vcclrit_reason = UINT_MAX; | 12 | volatile unsigned int __native_vcclrit_reason = UINT_MAX; |
| 13 | volatile __enative_startup_state __native_startup_state; | 13 | volatile __enative_startup_state __native_startup_state = __uninitialized; |
| 14 | volatile void *__native_startup_lock; | 14 | void *volatile __native_startup_lock = NULL; |
lib/libc/mingw/crt/tlssup.c-4| ... | @@ -6,10 +6,6 @@ | ... | @@ -6,10 +6,6 @@ |
| 6 | * Written by Kai Tietz <kai.tietz@onevision.com> | 6 | * Written by Kai Tietz <kai.tietz@onevision.com> |
| 7 | */ | 7 | */ |
| 8 | 8 | ||
| 9 | #ifdef CRTDLL | ||
| 10 | #undef CRTDLL | ||
| 11 | #endif | ||
| 12 | |||
| 13 | #include <sect_attribs.h> | 9 | #include <sect_attribs.h> |
| 14 | 10 | ||
| 15 | #ifndef WIN32_LEAN_AND_MEAN | 11 | #ifndef WIN32_LEAN_AND_MEAN |
lib/libc/mingw/gdtoa/strtodnrp.c+1-2| ... | @@ -85,8 +85,7 @@ double __cdecl | ... | @@ -85,8 +85,7 @@ double __cdecl |
| 85 | __mingw_strtod (const char * __restrict__ src, char ** __restrict__ endptr) | 85 | __mingw_strtod (const char * __restrict__ src, char ** __restrict__ endptr) |
| 86 | __attribute__((alias("__strtod"))); | 86 | __attribute__((alias("__strtod"))); |
| 87 | 87 | ||
| 88 | #if !(defined(_AMD64_) || defined(__x86_64__) || \ | 88 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 89 | defined(_X86_) || defined(__i386__)) | ||
| 90 | /* For systems other than x86, where long double == double, provide the | 89 | /* For systems other than x86, where long double == double, provide the |
| 91 | * long double functions as aliases to __strtod. */ | 90 | * long double functions as aliases to __strtod. */ |
| 92 | 91 |
lib/libc/mingw/gdtoa/strtopx.c+12-11| ... | @@ -53,8 +53,19 @@ THIS SOFTWARE. | ... | @@ -53,8 +53,19 @@ THIS SOFTWARE. |
| 53 | #define _4 0 | 53 | #define _4 0 |
| 54 | #endif | 54 | #endif |
| 55 | 55 | ||
| 56 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ | ||
| 57 | /* For ARM, where long double == double, provide the long double function as | ||
| 58 | * an alias for __strtod. Do this in a separate object file from other | ||
| 59 | * functions, to avoid linker conflicts if object files import both 'strtold' | ||
| 60 | * from libucrt*.a and the object file providing '__strtod'. */ | ||
| 61 | long double __cdecl | ||
| 62 | strtold (const char * __restrict__ src, char ** __restrict__ endptr) | ||
| 63 | { | ||
| 64 | return __mingw_strtod(src, endptr); | ||
| 65 | } | ||
| 66 | |||
| 56 | /* This is specific to the x86 80 bit long doubles. */ | 67 | /* This is specific to the x86 80 bit long doubles. */ |
| 57 | #if defined(_AMD64_) || defined(__x86_64__) || \ | 68 | #elif defined(_AMD64_) || defined(__x86_64__) || \ |
| 58 | defined(_X86_) || defined(__i386__) | 69 | defined(_X86_) || defined(__i386__) |
| 59 | 70 | ||
| 60 | typedef union lD { | 71 | typedef union lD { |
| ... | @@ -133,14 +144,4 @@ long double __cdecl | ... | @@ -133,14 +144,4 @@ long double __cdecl |
| 133 | strtold (const char * __restrict__ src, char ** __restrict__ endptr) | 144 | strtold (const char * __restrict__ src, char ** __restrict__ endptr) |
| 134 | __attribute__((alias("__strtold"))); | 145 | __attribute__((alias("__strtold"))); |
| 135 | 146 | ||
| 136 | #elif defined(__arm__) || defined(__aarch64__) || defined(_ARM_) || defined(_ARM64_) | ||
| 137 | /* For ARM, where long double == double, provide the long double function as | ||
| 138 | * an alias for __strtod. Do this in a separate object file from other | ||
| 139 | * functions, to avoid linker conflicts if object files import both 'strtold' | ||
| 140 | * from libucrt*.a and the object file providing '__strtod'. */ | ||
| 141 | long double __cdecl | ||
| 142 | strtold (const char * __restrict__ src, char ** __restrict__ endptr) | ||
| 143 | { | ||
| 144 | return __mingw_strtod(src, endptr); | ||
| 145 | } | ||
| 146 | #endif | 147 | #endif |
lib/libc/mingw/include/internal.h+155-1| ... | @@ -14,6 +14,7 @@ extern "C" { | ... | @@ -14,6 +14,7 @@ extern "C" { |
| 14 | #endif | 14 | #endif |
| 15 | 15 | ||
| 16 | #include <limits.h> | 16 | #include <limits.h> |
| 17 | #include <fenv.h> | ||
| 17 | #include <windows.h> | 18 | #include <windows.h> |
| 18 | 19 | ||
| 19 | #pragma pack(push,_CRT_PACKING) | 20 | #pragma pack(push,_CRT_PACKING) |
| ... | @@ -130,7 +131,7 @@ extern "C" { | ... | @@ -130,7 +131,7 @@ extern "C" { |
| 130 | } __enative_startup_state; | 131 | } __enative_startup_state; |
| 131 | 132 | ||
| 132 | extern volatile __enative_startup_state __native_startup_state; | 133 | extern volatile __enative_startup_state __native_startup_state; |
| 133 | extern volatile void *__native_startup_lock; | 134 | extern void *volatile __native_startup_lock; |
| 134 | 135 | ||
| 135 | extern volatile unsigned int __native_dllmain_reason; | 136 | extern volatile unsigned int __native_dllmain_reason; |
| 136 | extern volatile unsigned int __native_vcclrit_reason; | 137 | extern volatile unsigned int __native_vcclrit_reason; |
| ... | @@ -154,6 +155,159 @@ extern "C" { | ... | @@ -154,6 +155,159 @@ extern "C" { |
| 154 | # define __mingw_has_sse() 0 | 155 | # define __mingw_has_sse() 0 |
| 155 | #endif | 156 | #endif |
| 156 | 157 | ||
| 158 | #if defined(__i386__) || defined(__x86_64__) | ||
| 159 | enum fenv_masks | ||
| 160 | { | ||
| 161 | /* x87 encoding constants */ | ||
| 162 | FENV_X_INVALID = 0x00100010, | ||
| 163 | FENV_X_DENORMAL = 0x00200020, | ||
| 164 | FENV_X_ZERODIVIDE = 0x00080008, | ||
| 165 | FENV_X_OVERFLOW = 0x00040004, | ||
| 166 | FENV_X_UNDERFLOW = 0x00020002, | ||
| 167 | FENV_X_INEXACT = 0x00010001, | ||
| 168 | FENV_X_AFFINE = 0x00004000, | ||
| 169 | FENV_X_UP = 0x00800200, | ||
| 170 | FENV_X_DOWN = 0x00400100, | ||
| 171 | FENV_X_24 = 0x00002000, | ||
| 172 | FENV_X_53 = 0x00001000, | ||
| 173 | /* SSE encoding constants: they share the same lower word as their x87 counterparts | ||
| 174 | * but differ in the upper word */ | ||
| 175 | FENV_Y_INVALID = 0x10000010, | ||
| 176 | FENV_Y_DENORMAL = 0x20000020, | ||
| 177 | FENV_Y_ZERODIVIDE = 0x08000008, | ||
| 178 | FENV_Y_OVERFLOW = 0x04000004, | ||
| 179 | FENV_Y_UNDERFLOW = 0x02000002, | ||
| 180 | FENV_Y_INEXACT = 0x01000001, | ||
| 181 | FENV_Y_UP = 0x80000200, | ||
| 182 | FENV_Y_DOWN = 0x40000100, | ||
| 183 | FENV_Y_FLUSH = 0x00000400, | ||
| 184 | FENV_Y_FLUSH_SAVE = 0x00000800 | ||
| 185 | }; | ||
| 186 | |||
| 187 | /* encodes the x87 (represented as x) or SSE (represented as y) control/status word in a ulong */ | ||
| 188 | static inline unsigned long fenv_encode(unsigned int x, unsigned int y) | ||
| 189 | { | ||
| 190 | unsigned long ret = 0; | ||
| 191 | |||
| 192 | if (x & _EM_INVALID) ret |= FENV_X_INVALID; | ||
| 193 | if (x & _EM_DENORMAL) ret |= FENV_X_DENORMAL; | ||
| 194 | if (x & _EM_ZERODIVIDE) ret |= FENV_X_ZERODIVIDE; | ||
| 195 | if (x & _EM_OVERFLOW) ret |= FENV_X_OVERFLOW; | ||
| 196 | if (x & _EM_UNDERFLOW) ret |= FENV_X_UNDERFLOW; | ||
| 197 | if (x & _EM_INEXACT) ret |= FENV_X_INEXACT; | ||
| 198 | if (x & _IC_AFFINE) ret |= FENV_X_AFFINE; | ||
| 199 | if (x & _RC_UP) ret |= FENV_X_UP; | ||
| 200 | if (x & _RC_DOWN) ret |= FENV_X_DOWN; | ||
| 201 | if (x & _PC_24) ret |= FENV_X_24; | ||
| 202 | if (x & _PC_53) ret |= FENV_X_53; | ||
| 203 | |||
| 204 | if (y & _EM_INVALID) ret |= FENV_Y_INVALID; | ||
| 205 | if (y & _EM_DENORMAL) ret |= FENV_Y_DENORMAL; | ||
| 206 | if (y & _EM_ZERODIVIDE) ret |= FENV_Y_ZERODIVIDE; | ||
| 207 | if (y & _EM_OVERFLOW) ret |= FENV_Y_OVERFLOW; | ||
| 208 | if (y & _EM_UNDERFLOW) ret |= FENV_Y_UNDERFLOW; | ||
| 209 | if (y & _EM_INEXACT) ret |= FENV_Y_INEXACT; | ||
| 210 | if (y & _RC_UP) ret |= FENV_Y_UP; | ||
| 211 | if (y & _RC_DOWN) ret |= FENV_Y_DOWN; | ||
| 212 | if (y & _DN_FLUSH) ret |= FENV_Y_FLUSH; | ||
| 213 | if (y & _DN_FLUSH_OPERANDS_SAVE_RESULTS) ret |= FENV_Y_FLUSH_SAVE; | ||
| 214 | |||
| 215 | return ret; | ||
| 216 | } | ||
| 217 | |||
| 218 | /* decodes the x87 (represented as x) or SSE (represented as y) control/status word in a ulong */ | ||
| 219 | static inline BOOL fenv_decode(unsigned long enc, unsigned int *x, unsigned int *y) | ||
| 220 | { | ||
| 221 | *x = *y = 0; | ||
| 222 | if ((enc & FENV_X_INVALID) == FENV_X_INVALID) *x |= _EM_INVALID; | ||
| 223 | if ((enc & FENV_X_DENORMAL) == FENV_X_DENORMAL) *x |= _EM_DENORMAL; | ||
| 224 | if ((enc & FENV_X_ZERODIVIDE) == FENV_X_ZERODIVIDE) *x |= _EM_ZERODIVIDE; | ||
| 225 | if ((enc & FENV_X_OVERFLOW) == FENV_X_OVERFLOW) *x |= _EM_OVERFLOW; | ||
| 226 | if ((enc & FENV_X_UNDERFLOW) == FENV_X_UNDERFLOW) *x |= _EM_UNDERFLOW; | ||
| 227 | if ((enc & FENV_X_INEXACT) == FENV_X_INEXACT) *x |= _EM_INEXACT; | ||
| 228 | if ((enc & FENV_X_AFFINE) == FENV_X_AFFINE) *x |= _IC_AFFINE; | ||
| 229 | if ((enc & FENV_X_UP) == FENV_X_UP) *x |= _RC_UP; | ||
| 230 | if ((enc & FENV_X_DOWN) == FENV_X_DOWN) *x |= _RC_DOWN; | ||
| 231 | if ((enc & FENV_X_24) == FENV_X_24) *x |= _PC_24; | ||
| 232 | if ((enc & FENV_X_53) == FENV_X_53) *x |= _PC_53; | ||
| 233 | |||
| 234 | if ((enc & FENV_Y_INVALID) == FENV_Y_INVALID) *y |= _EM_INVALID; | ||
| 235 | if ((enc & FENV_Y_DENORMAL) == FENV_Y_DENORMAL) *y |= _EM_DENORMAL; | ||
| 236 | if ((enc & FENV_Y_ZERODIVIDE) == FENV_Y_ZERODIVIDE) *y |= _EM_ZERODIVIDE; | ||
| 237 | if ((enc & FENV_Y_OVERFLOW) == FENV_Y_OVERFLOW) *y |= _EM_OVERFLOW; | ||
| 238 | if ((enc & FENV_Y_UNDERFLOW) == FENV_Y_UNDERFLOW) *y |= _EM_UNDERFLOW; | ||
| 239 | if ((enc & FENV_Y_INEXACT) == FENV_Y_INEXACT) *y |= _EM_INEXACT; | ||
| 240 | if ((enc & FENV_Y_UP) == FENV_Y_UP) *y |= _RC_UP; | ||
| 241 | if ((enc & FENV_Y_DOWN) == FENV_Y_DOWN) *y |= _RC_DOWN; | ||
| 242 | if ((enc & FENV_Y_FLUSH) == FENV_Y_FLUSH) *y |= _DN_FLUSH; | ||
| 243 | if ((enc & FENV_Y_FLUSH_SAVE) == FENV_Y_FLUSH_SAVE) *y |= _DN_FLUSH_OPERANDS_SAVE_RESULTS; | ||
| 244 | |||
| 245 | return fenv_encode(*x, *y) == enc; | ||
| 246 | } | ||
| 247 | #else | ||
| 248 | static inline unsigned long fenv_encode(unsigned int x, unsigned int y) | ||
| 249 | { | ||
| 250 | /* Encode _EM_DENORMAL as 0x20 for Windows compatibility. */ | ||
| 251 | if (y & _EM_DENORMAL) | ||
| 252 | y = (y & ~_EM_DENORMAL) | 0x20; | ||
| 253 | |||
| 254 | return x | y; | ||
| 255 | } | ||
| 256 | |||
| 257 | static inline BOOL fenv_decode(unsigned long enc, unsigned int *x, unsigned int *y) | ||
| 258 | { | ||
| 259 | /* Decode 0x20 as _EM_DENORMAL. */ | ||
| 260 | if (enc & 0x20) | ||
| 261 | enc = (enc & ~0x20) | _EM_DENORMAL; | ||
| 262 | |||
| 263 | *x = *y = enc; | ||
| 264 | return TRUE; | ||
| 265 | } | ||
| 266 | #endif | ||
| 267 | |||
| 268 | void __mingw_setfp( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask ); | ||
| 269 | void __mingw_setfp_sse( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask ); | ||
| 270 | unsigned int __mingw_controlfp(unsigned int newval, unsigned int mask); | ||
| 271 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) | ||
| 272 | int __mingw_control87_2(unsigned int, unsigned int, unsigned int *, unsigned int *); | ||
| 273 | #endif | ||
| 274 | |||
| 275 | static inline unsigned int __mingw_statusfp(void) | ||
| 276 | { | ||
| 277 | unsigned int flags = 0; | ||
| 278 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) | ||
| 279 | unsigned int x86_sw, sse2_sw = 0; | ||
| 280 | __mingw_setfp(NULL, 0, &x86_sw, 0); | ||
| 281 | if (__mingw_has_sse()) | ||
| 282 | __mingw_setfp_sse(NULL, 0, &sse2_sw, 0); | ||
| 283 | flags = x86_sw | sse2_sw; | ||
| 284 | #else | ||
| 285 | __mingw_setfp(NULL, 0, &flags, 0); | ||
| 286 | #endif | ||
| 287 | return flags; | ||
| 288 | } | ||
| 289 | |||
| 290 | /* Use naked functions only on Clang. GCC doesn’t support them on ARM targets and | ||
| 291 | * has broken behavior on x86_64 by emitting .seh_endprologue. */ | ||
| 292 | #ifndef __clang__ | ||
| 293 | |||
| 294 | #define __ASM_DEFINE_FUNC(rettype, name, args, code) \ | ||
| 295 | asm(".text\n\t" \ | ||
| 296 | ".p2align 2\n\t" \ | ||
| 297 | ".globl " __MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) "\n\t" \ | ||
| 298 | ".def " __MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) "; .scl 2; .type 32; .endef\n\t" \ | ||
| 299 | __MINGW64_STRINGIFY(__MINGW_USYMBOL(name)) ":\n\t" \ | ||
| 300 | code "\n\t"); | ||
| 301 | |||
| 302 | #else | ||
| 303 | |||
| 304 | #define __ASM_DEFINE_FUNC(rettype, name, args, code) \ | ||
| 305 | rettype __attribute__((naked)) name args { \ | ||
| 306 | asm(code "\n\t"); \ | ||
| 307 | } | ||
| 308 | |||
| 309 | #endif | ||
| 310 | |||
| 157 | #ifdef __cplusplus | 311 | #ifdef __cplusplus |
| 158 | } | 312 | } |
| 159 | #endif | 313 | #endif |
lib/libc/mingw/intrincs/RtlSecureZeroMemory.c+1-1| ... | @@ -4,7 +4,7 @@ | ... | @@ -4,7 +4,7 @@ |
| 4 | PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt) | 4 | PVOID WINAPI RtlSecureZeroMemory(PVOID ptr,SIZE_T cnt) |
| 5 | { | 5 | { |
| 6 | volatile char *vptr = (volatile char *)ptr; | 6 | volatile char *vptr = (volatile char *)ptr; |
| 7 | #ifdef __x86_64 | 7 | #if defined(__x86_64__) && !defined(__arm64ec__) |
| 8 | __stosb ((PBYTE)((DWORD64)vptr),0,cnt); | 8 | __stosb ((PBYTE)((DWORD64)vptr),0,cnt); |
| 9 | #else | 9 | #else |
| 10 | while (cnt != 0) | 10 | while (cnt != 0) |
lib/libc/mingw/libsrc/uuid.c+1| ... | @@ -15,6 +15,7 @@ | ... | @@ -15,6 +15,7 @@ |
| 15 | #include <basetyps.h> | 15 | #include <basetyps.h> |
| 16 | 16 | ||
| 17 | #include <credentialprovider.h> | 17 | #include <credentialprovider.h> |
| 18 | #include <httprequest.h> | ||
| 18 | #include <functiondiscoverykeys.h> | 19 | #include <functiondiscoverykeys.h> |
| 19 | #include <textstor.h> | 20 | #include <textstor.h> |
| 20 | #include <shobjidl.h> | 21 | #include <shobjidl.h> |
lib/libc/mingw/libsrc/ws2tcpip/in6_set_addr_loopback.c+1-1| ... | @@ -8,6 +8,6 @@ | ... | @@ -8,6 +8,6 @@ |
| 8 | 8 | ||
| 9 | void IN6_SET_ADDR_LOOPBACK(struct in6_addr *a) | 9 | void IN6_SET_ADDR_LOOPBACK(struct in6_addr *a) |
| 10 | { | 10 | { |
| 11 | 	memset(a->s6_bytes, 0, sizeof(struct in6_addr)); | 11 | 	*a = (struct in6_addr){0}; |
| 12 | 	a->s6_bytes[15] = 1; | 12 | 	a->s6_bytes[15] = 1; |
| 13 | } | 13 | } |
lib/libc/mingw/libsrc/ws2tcpip/in6_set_addr_unspecified.c+1-1| ... | @@ -8,5 +8,5 @@ | ... | @@ -8,5 +8,5 @@ |
| 8 | 8 | ||
| 9 | void IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *a) | 9 | void IN6_SET_ADDR_UNSPECIFIED(struct in6_addr *a) |
| 10 | { | 10 | { |
| 11 | 	memset(a->s6_bytes, 0, sizeof(struct in6_addr)); | 11 | 	*a = (struct in6_addr){0}; |
| 12 | } | 12 | } |
lib/libc/mingw/libsrc/ws2tcpip/in6addr_setany.c+1-4| ... | @@ -6,14 +6,11 @@ | ... | @@ -6,14 +6,11 @@ |
| 6 | #include <winsock2.h> | 6 | #include <winsock2.h> |
| 7 | #include <ws2tcpip.h> | 7 | #include <ws2tcpip.h> |
| 8 | 8 | ||
| 9 | #undef IN6_SET_ADDR_UNSPECIFIED | ||
| 10 | #define IN6_SET_ADDR_UNSPECIFIED(a)	memset((a)->s6_bytes,0,sizeof(struct in6_addr)) | ||
| 11 | |||
| 12 | void IN6ADDR_SETANY(struct sockaddr_in6 *a) | 9 | void IN6ADDR_SETANY(struct sockaddr_in6 *a) |
| 13 | { | 10 | { |
| 14 | 	a->sin6_family = AF_INET6; | 11 | 	a->sin6_family = AF_INET6; |
| 15 | 	a->sin6_port = 0; | 12 | 	a->sin6_port = 0; |
| 16 | 	a->sin6_flowinfo = 0; | 13 | 	a->sin6_flowinfo = 0; |
| 17 | 	IN6_SET_ADDR_UNSPECIFIED(&a->sin6_addr); | 14 | 	a->sin6_addr = (struct in6_addr){0}; |
| 18 | 	a->sin6_scope_id = 0; | 15 | 	a->sin6_scope_id = 0; |
| 19 | } | 16 | } |
lib/libc/mingw/libsrc/ws2tcpip/in6addr_setloopback.c-7| ... | @@ -6,13 +6,6 @@ | ... | @@ -6,13 +6,6 @@ |
| 6 | #include <winsock2.h> | 6 | #include <winsock2.h> |
| 7 | #include <ws2tcpip.h> | 7 | #include <ws2tcpip.h> |
| 8 | 8 | ||
| 9 | #undef IN6_SET_ADDR_LOOPBACK | ||
| 10 | #define IN6_SET_ADDR_LOOPBACK(a)				\ | ||
| 11 | 	do {							\ | ||
| 12 | 		memset((a)->s6_bytes,0,sizeof(struct in6_addr));\ | ||
| 13 | 		(a)->s6_bytes[15] = 1;				\ | ||
| 14 | 	} while (0) | ||
| 15 | |||
| 16 | void IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *a) | 9 | void IN6ADDR_SETLOOPBACK(struct sockaddr_in6 *a) |
| 17 | { | 10 | { |
| 18 | 	a->sin6_family = AF_INET6; | 11 | 	a->sin6_family = AF_INET6; |
lib/libc/mingw/math/arm-common/ldexpl.c-4| ... | @@ -8,9 +8,5 @@ | ... | @@ -8,9 +8,5 @@ |
| 8 | 8 | ||
| 9 | long double ldexpl(long double x, int n) | 9 | long double ldexpl(long double x, int n) |
| 10 | { | 10 | { |
| 11 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 12 | return ldexp(x, n); | 11 | return ldexp(x, n); |
| 13 | #else | ||
| 14 | #error Not supported on your platform yet | ||
| 15 | #endif | ||
| 16 | } | 12 | } |
lib/libc/mingw/math/arm-common/sincosl.c created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <math.h> | ||
| 8 | |||
| 9 | void sincosl(long double x, long double *s, long double *c) | ||
| 10 | { | ||
| 11 | *s = sinl(x); | ||
| 12 | *c = cosl(x); | ||
| 13 | } | ||
lib/libc/mingw/math/arm/_chgsignl.S deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <_mingw_mac.h> | ||
| 8 | |||
| 9 | 	.file	"_chgignl.S" | ||
| 10 | 	.text | ||
| 11 | 	.align 4 | ||
| 12 | 	.globl __MINGW_USYMBOL(_chgsignl) | ||
| 13 | 	.def	__MINGW_USYMBOL(_chgsignl);	.scl	2;	.type	32;	.endef | ||
| 14 | __MINGW_USYMBOL(_chgsignl): | ||
| 15 | 	vneg.f64	d0, d0 | ||
| 16 | 	bx	lr | ||
lib/libc/mingw/math/arm64/_chgsignl.S deleted-16| ... | @@ -1,16 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <_mingw_mac.h> | ||
| 8 | |||
| 9 | 	.file	"_chgignl.S" | ||
| 10 | 	.text | ||
| 11 | 	.align 2 | ||
| 12 | 	.globl __MINGW_USYMBOL(_chgsignl) | ||
| 13 | 	.def	__MINGW_USYMBOL(_chgsignl);	.scl	2;	.type	32;	.endef | ||
| 14 | __MINGW_USYMBOL(_chgsignl): | ||
| 15 | 	fneg	d0, d0 | ||
| 16 | 	ret | ||
lib/libc/mingw/math/cephes_mconf.h+2-2| ... | @@ -66,7 +66,7 @@ extern double __QNAN; | ... | @@ -66,7 +66,7 @@ extern double __QNAN; |
| 66 | #endif | 66 | #endif |
| 67 | 67 | ||
| 68 | /*long double*/ | 68 | /*long double*/ |
| 69 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 69 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 70 | #define MAXNUML	1.7976931348623158E308 | 70 | #define MAXNUML	1.7976931348623158E308 |
| 71 | #define MAXLOGL	7.09782712893383996843E2 | 71 | #define MAXLOGL	7.09782712893383996843E2 |
| 72 | #define MINLOGL	-7.08396418532264106224E2 | 72 | #define MINLOGL	-7.08396418532264106224E2 |
| ... | @@ -84,7 +84,7 @@ extern double __QNAN; | ... | @@ -84,7 +84,7 @@ extern double __QNAN; |
| 84 | #define PIL	3.1415926535897932384626L | 84 | #define PIL	3.1415926535897932384626L |
| 85 | #define PIO2L	1.5707963267948966192313L | 85 | #define PIO2L	1.5707963267948966192313L |
| 86 | #define PIO4L	7.8539816339744830961566E-1L | 86 | #define PIO4L	7.8539816339744830961566E-1L |
| 87 | #endif /* defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) */ | 87 | #endif /* __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ */ |
| 88 | 88 | ||
| 89 | #define isfinitel isfinite | 89 | #define isfinitel isfinite |
| 90 | #define isinfl isinf | 90 | #define isinfl isinf |
lib/libc/mingw/math/coshl.c+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | */ | 5 | */ |
| 6 | #include "cephes_mconf.h" | 6 | #include "cephes_mconf.h" |
| 7 | 7 | ||
| 8 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 8 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 9 | #include <math.h> | 9 | #include <math.h> |
| 10 | 10 | ||
| 11 | long double coshl(long double x) | 11 | long double coshl(long double x) |
lib/libc/mingw/math/erfl.c+1-1| ... | @@ -108,7 +108,7 @@ Copyright 1984, 1995 by Stephen L. Moshier | ... | @@ -108,7 +108,7 @@ Copyright 1984, 1995 by Stephen L. Moshier |
| 108 | 108 | ||
| 109 | long double erfl(long double x); | 109 | long double erfl(long double x); |
| 110 | 110 | ||
| 111 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 111 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 112 | long double erfcl(long double x) | 112 | long double erfcl(long double x) |
| 113 | { | 113 | { |
| 114 | 	return erfc(x); | 114 | 	return erfc(x); |
lib/libc/mingw/math/fmal.c+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | */ | 5 | */ |
| 6 | long double fmal(long double x, long double y, long double z); | 6 | long double fmal(long double x, long double y, long double z); |
| 7 | 7 | ||
| 8 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 8 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 9 | 9 | ||
| 10 | double fma(double x, double y, double z); | 10 | double fma(double x, double y, double z); |
| 11 | 11 |
lib/libc/mingw/math/fp_constsl.c+1-1| ... | @@ -16,7 +16,7 @@ const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP }; | ... | @@ -16,7 +16,7 @@ const union _ieee_rep __DENORML = { __LONG_DOUBLE_DENORM_REP }; |
| 16 | long double nanl (const char *); | 16 | long double nanl (const char *); |
| 17 | long double nanl (const char * tagp __attribute__((unused)) ) | 17 | long double nanl (const char * tagp __attribute__((unused)) ) |
| 18 | { | 18 | { |
| 19 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 19 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 20 | return nan(""); | 20 | return nan(""); |
| 21 | #else | 21 | #else |
| 22 | return __QNANL.ldouble_val; | 22 | return __QNANL.ldouble_val; |
lib/libc/mingw/math/fpclassifyl.c+3-3| ... | @@ -6,7 +6,9 @@ | ... | @@ -6,7 +6,9 @@ |
| 6 | #include <math.h> | 6 | #include <math.h> |
| 7 | 7 | ||
| 8 | int __fpclassifyl (long double _x){ | 8 | int __fpclassifyl (long double _x){ |
| 9 | #if defined(__x86_64__) || defined(_AMD64_) | 9 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 10 | return __fpclassify(_x); | ||
| 11 | #elif defined(_AMD64_) || defined(__x86_64__) | ||
| 10 | __mingw_ldbl_type_t hlp; | 12 | __mingw_ldbl_type_t hlp; |
| 11 | unsigned int e; | 13 | unsigned int e; |
| 12 | hlp.x = _x; | 14 | hlp.x = _x; |
| ... | @@ -23,8 +25,6 @@ int __fpclassifyl (long double _x){ | ... | @@ -23,8 +25,6 @@ int __fpclassifyl (long double _x){ |
| 23 | return (((hlp.lh.high & 0x7fffffff) | hlp.lh.low) == 0 ? | 25 | return (((hlp.lh.high & 0x7fffffff) | hlp.lh.low) == 0 ? |
| 24 | 	 FP_INFINITE : FP_NAN); | 26 | 	 FP_INFINITE : FP_NAN); |
| 25 | return FP_NORMAL; | 27 | return FP_NORMAL; |
| 26 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 27 | return __fpclassify(_x); | ||
| 28 | #elif defined(__i386__) || defined(_X86_) | 28 | #elif defined(__i386__) || defined(_X86_) |
| 29 | unsigned short sw; | 29 | unsigned short sw; |
| 30 | __asm__ __volatile__ ( | 30 | __asm__ __volatile__ ( |
lib/libc/mingw/math/frexpl.c+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | */ | 5 | */ |
| 6 | long double frexpl(long double value, int* exp); | 6 | long double frexpl(long double value, int* exp); |
| 7 | 7 | ||
| 8 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 8 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 9 | 9 | ||
| 10 | double frexp(double value, int* exp); | 10 | double frexp(double value, int* exp); |
| 11 | 11 |
lib/libc/mingw/math/isnanl.c+3-3| ... | @@ -8,7 +8,9 @@ | ... | @@ -8,7 +8,9 @@ |
| 8 | int | 8 | int |
| 9 | __isnanl (long double _x) | 9 | __isnanl (long double _x) |
| 10 | { | 10 | { |
| 11 | #if defined(__x86_64__) || defined(_AMD64_) | 11 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 12 | return __isnan(_x); | ||
| 13 | #elif defined(__x86_64__) || defined(_AMD64_) | ||
| 12 | __mingw_ldbl_type_t ld; | 14 | __mingw_ldbl_type_t ld; |
| 13 | int xx, signexp; | 15 | int xx, signexp; |
| 14 | 16 | ||
| ... | @@ -18,8 +20,6 @@ __isnanl (long double _x) | ... | @@ -18,8 +20,6 @@ __isnanl (long double _x) |
| 18 | signexp |= (unsigned int) (xx | (-xx)) >> 31; | 20 | signexp |= (unsigned int) (xx | (-xx)) >> 31; |
| 19 | signexp = 0xfffe - signexp; | 21 | signexp = 0xfffe - signexp; |
| 20 | return (int) ((unsigned int) signexp) >> 16; | 22 | return (int) ((unsigned int) signexp) >> 16; |
| 21 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 22 | return __isnan(_x); | ||
| 23 | #elif defined(__i386__) || defined(_X86_) | 23 | #elif defined(__i386__) || defined(_X86_) |
| 24 | unsigned short _sw; | 24 | unsigned short _sw; |
| 25 | __asm__ __volatile__ ("fxam;" | 25 | __asm__ __volatile__ ("fxam;" |
lib/libc/mingw/math/lgammal.c+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | */ | 5 | */ |
| 6 | #include "cephes_mconf.h" | 6 | #include "cephes_mconf.h" |
| 7 | 7 | ||
| 8 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 8 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 9 | double lgamma(double x); | 9 | double lgamma(double x); |
| 10 | 10 | ||
| 11 | long double lgammal(long double x) | 11 | long double lgammal(long double x) |
lib/libc/mingw/math/llrintl.c+2-1| ... | @@ -9,7 +9,8 @@ | ... | @@ -9,7 +9,8 @@ |
| 9 | long long llrintl (long double x) | 9 | long long llrintl (long double x) |
| 10 | { | 10 | { |
| 11 | long long retval = 0ll; | 11 | long long retval = 0ll; |
| 12 | #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | 12 | #if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__)) || \ |
| 13 | defined(_X86_) || defined(__i386__) | ||
| 13 | __asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); | 14 | __asm__ __volatile__ ("fistpll %0" : "=m" (retval) : "t" (x) : "st"); |
| 14 | #else | 15 | #else |
| 15 | int mode = fegetround(); | 16 | int mode = fegetround(); |
lib/libc/mingw/math/lrintl.c+3-3| ... | @@ -8,10 +8,10 @@ | ... | @@ -8,10 +8,10 @@ |
| 8 | long lrintl (long double x) | 8 | long lrintl (long double x) |
| 9 | { | 9 | { |
| 10 | long retval = 0l; | 10 | long retval = 0l; |
| 11 | #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | 11 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 12 | __asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); | ||
| 13 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 14 | retval = lrint(x); | 12 | retval = lrint(x); |
| 13 | #elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | ||
| 14 | __asm__ __volatile__ ("fistpl %0" : "=m" (retval) : "t" (x) : "st"); | ||
| 15 | #endif | 15 | #endif |
| 16 | return retval; | 16 | return retval; |
| 17 | } | 17 | } |
lib/libc/mingw/math/modff.c+1-1| ... | @@ -13,7 +13,7 @@ modff (float value, float* iptr) | ... | @@ -13,7 +13,7 @@ modff (float value, float* iptr) |
| 13 | float int_part = 0.0F; | 13 | float int_part = 0.0F; |
| 14 | /* truncate */ | 14 | /* truncate */ |
| 15 | /* truncate */ | 15 | /* truncate */ |
| 16 | #if defined(_AMD64_) || defined(__x86_64__) | 16 | #if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 17 | asm volatile ("subq $8, %%rsp\n" | 17 | asm volatile ("subq $8, %%rsp\n" |
| 18 | "fnstcw 4(%%rsp)\n" | 18 | "fnstcw 4(%%rsp)\n" |
| 19 | "movzwl 4(%%rsp), %%eax\n" | 19 | "movzwl 4(%%rsp), %%eax\n" |
lib/libc/mingw/math/modfl.c+1-1| ... | @@ -12,7 +12,7 @@ modfl (long double value, long double* iptr) | ... | @@ -12,7 +12,7 @@ modfl (long double value, long double* iptr) |
| 12 | { | 12 | { |
| 13 | long double int_part = 0.0L; | 13 | long double int_part = 0.0L; |
| 14 | /* truncate */ | 14 | /* truncate */ |
| 15 | #if defined(_AMD64_) || defined(__x86_64__) | 15 | #if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 16 | asm volatile ("subq $8, %%rsp\n" | 16 | asm volatile ("subq $8, %%rsp\n" |
| 17 | "fnstcw 4(%%rsp)\n" | 17 | "fnstcw 4(%%rsp)\n" |
| 18 | "movzwl 4(%%rsp), %%eax\n" | 18 | "movzwl 4(%%rsp), %%eax\n" |
lib/libc/mingw/math/rintl.c+3-3| ... | @@ -7,10 +7,10 @@ | ... | @@ -7,10 +7,10 @@ |
| 7 | 7 | ||
| 8 | long double rintl (long double x) { | 8 | long double rintl (long double x) { |
| 9 | long double retval = 0.0L; | 9 | long double retval = 0.0L; |
| 10 | #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | 10 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 11 | __asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x)); | ||
| 12 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | ||
| 13 | retval = rint(x); | 11 | retval = rint(x); |
| 12 | #elif defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | ||
| 13 | __asm__ __volatile__ ("frndint;": "=t" (retval) : "0" (x)); | ||
| 14 | #endif | 14 | #endif |
| 15 | return retval; | 15 | return retval; |
| 16 | } | 16 | } |
lib/libc/mingw/math/signbitl.c+2-2| ... | @@ -9,11 +9,11 @@ | ... | @@ -9,11 +9,11 @@ |
| 9 | 9 | ||
| 10 | 10 | ||
| 11 | int __signbitl (long double x) { | 11 | int __signbitl (long double x) { |
| 12 | #if defined(__x86_64__) || defined(_AMD64_) | 12 | #if (defined(_AMD64_) && !defined(_ARM64EC_)) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 13 | __mingw_ldbl_type_t ld; | 13 | __mingw_ldbl_type_t ld; |
| 14 | ld.x = x; | 14 | ld.x = x; |
| 15 | return ((ld.lh.sign_exponent & 0x8000) != 0); | 15 | return ((ld.lh.sign_exponent & 0x8000) != 0); |
| 16 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 16 | #elif defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) |
| 17 | return __signbit(x); | 17 | return __signbit(x); |
| 18 | #elif defined(__i386__) || defined(_X86_) | 18 | #elif defined(__i386__) || defined(_X86_) |
| 19 | unsigned short sw; | 19 | unsigned short sw; |
lib/libc/mingw/math/sinhl.c+1-1| ... | @@ -6,7 +6,7 @@ | ... | @@ -6,7 +6,7 @@ |
| 6 | #include "cephes_mconf.h" | 6 | #include "cephes_mconf.h" |
| 7 | #include <errno.h> | 7 | #include <errno.h> |
| 8 | 8 | ||
| 9 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 9 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 10 | #include <math.h> | 10 | #include <math.h> |
| 11 | 11 | ||
| 12 | long double sinhl(long double x) | 12 | long double sinhl(long double x) |
lib/libc/mingw/math/sqrt.def.h+1-1| ... | @@ -77,7 +77,7 @@ __FLT_ABI (sqrt) (__FLT_TYPE x) | ... | @@ -77,7 +77,7 @@ __FLT_ABI (sqrt) (__FLT_TYPE x) |
| 77 | #else | 77 | #else |
| 78 | asm volatile ("fsqrtd %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x)); | 78 | asm volatile ("fsqrtd %[dst], %[src];\n" : [dst] "=w" (res) : [src] "w" (x)); |
| 79 | #endif | 79 | #endif |
| 80 | #elif defined(__aarch64__) || defined(_ARM64_) | 80 | #elif defined(__aarch64__) || defined(_ARM64_) || defined(__arm64ec__) || defined(_ARM64EC_) |
| 81 | #if _NEW_COMPLEX_FLOAT | 81 | #if _NEW_COMPLEX_FLOAT |
| 82 | asm volatile ("fsqrt %s[dst], %s[src]\n" : [dst] "=w" (res) : [src] "w" (x)); | 82 | asm volatile ("fsqrt %s[dst], %s[src]\n" : [dst] "=w" (res) : [src] "w" (x)); |
| 83 | #else | 83 | #else |
lib/libc/mingw/math/tanhl.c+1-1| ... | @@ -8,7 +8,7 @@ | ... | @@ -8,7 +8,7 @@ |
| 8 | #define _SET_ERRNO(x) | 8 | #define _SET_ERRNO(x) |
| 9 | #endif | 9 | #endif |
| 10 | 10 | ||
| 11 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 11 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 12 | #include <math.h> | 12 | #include <math.h> |
| 13 | 13 | ||
| 14 | long double tanhl(long double x) | 14 | long double tanhl(long double x) |
lib/libc/mingw/math/tgammal.c+1-1| ... | @@ -5,7 +5,7 @@ | ... | @@ -5,7 +5,7 @@ |
| 5 | */ | 5 | */ |
| 6 | #include "cephes_mconf.h" | 6 | #include "cephes_mconf.h" |
| 7 | 7 | ||
| 8 | #if defined(__arm__) || defined(_ARM_) || defined(__aarch64__) || defined(_ARM64_) | 8 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 9 | double tgamma(double x); | 9 | double tgamma(double x); |
| 10 | 10 | ||
| 11 | long double tgammal(long double x) | 11 | long double tgammal(long double x) |
lib/libc/mingw/math/truncl.c+3-4| ... | @@ -3,21 +3,20 @@ | ... | @@ -3,21 +3,20 @@ |
| 3 | * This file is part of the mingw-w64 runtime package. | 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | #include <fenv.h> | 6 | |
| 7 | #include <math.h> | 7 | #include <math.h> |
| 8 | 8 | ||
| 9 | long double | 9 | long double |
| 10 | truncl (long double _x) | 10 | truncl (long double _x) |
| 11 | { | 11 | { |
| 12 | #if defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) | 12 | #if __SIZEOF_LONG_DOUBLE__ == __SIZEOF_DOUBLE__ |
| 13 | return trunc(_x); | 13 | return trunc(_x); |
| 14 | #else | 14 | #else |
| 15 | long double retval = 0.0L; | 15 | long double retval = 0.0L; |
| 16 | unsigned short saved_cw; | 16 | unsigned short saved_cw; |
| 17 | unsigned short tmp_cw; | 17 | unsigned short tmp_cw; |
| 18 | __asm__ __volatile__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */ | 18 | __asm__ __volatile__ ("fnstcw %0;" : "=m" (saved_cw)); /* save FPU control word */ |
| 19 | tmp_cw = (saved_cw & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) | 19 | tmp_cw = saved_cw | 0xc00; /* round towards zero */ |
| 20 | 	 | FE_TOWARDZERO; | ||
| 21 | __asm__ __volatile__ ("fldcw %0;" : : "m" (tmp_cw)); | 20 | __asm__ __volatile__ ("fldcw %0;" : : "m" (tmp_cw)); |
| 22 | __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ | 21 | __asm__ __volatile__ ("frndint;" : "=t" (retval) : "0" (_x)); /* round towards zero */ |
| 23 | __asm__ __volatile__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ | 22 | __asm__ __volatile__ ("fldcw %0;" : : "m" (saved_cw) ); /* restore saved control word */ |
lib/libc/mingw/math/x86/pow.def.h-3| ... | @@ -69,11 +69,8 @@ | ... | @@ -69,11 +69,8 @@ |
| 69 | #include "../complex/complex_internal.h" | 69 | #include "../complex/complex_internal.h" |
| 70 | #include <errno.h> | 70 | #include <errno.h> |
| 71 | #include <limits.h> | 71 | #include <limits.h> |
| 72 | #include <fenv.h> | ||
| 73 | #include <math.h> | 72 | #include <math.h> |
| 74 | #include <errno.h> | 73 | #include <errno.h> |
| 75 | #define FE_ROUNDING_MASK \ | ||
| 76 | (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO) | ||
| 77 | 74 | ||
| 78 | static __FLT_TYPE | 75 | static __FLT_TYPE |
| 79 | internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr) | 76 | internal_modf (__FLT_TYPE value, __FLT_TYPE *iptr) |
lib/libc/mingw/misc/dllentrypoint.c deleted-18| ... | @@ -1,18 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <oscalls.h> | ||
| 8 | #define _DECL_DLLMAIN | ||
| 9 | #include <process.h> | ||
| 10 | |||
| 11 | BOOL WINAPI DllEntryPoint (HANDLE, DWORD, LPVOID); | ||
| 12 | |||
| 13 | BOOL WINAPI DllEntryPoint (HANDLE __UNUSED_PARAM(hDllHandle), | ||
| 14 | 			 DWORD __UNUSED_PARAM(dwReason), | ||
| 15 | 			 LPVOID __UNUSED_PARAM(lpreserved)) | ||
| 16 | { | ||
| 17 | return TRUE; | ||
| 18 | } | ||
lib/libc/mingw/misc/feclearexcept.c+7-33| ... | @@ -4,44 +4,18 @@ | ... | @@ -4,44 +4,18 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <fenv.h> | ||
| 8 | #include <internal.h> | 7 | #include <internal.h> |
| 9 | 8 | ||
| 10 | /* 7.6.2.1 | 9 | /* 7.6.2.1 |
| 11 | The feclearexcept function clears the supported exceptions | 10 | The feclearexcept function clears the supported exceptions |
| 12 | represented by its argument. */ | 11 | represented by its argument. */ |
| 13 | 12 | ||
| 14 | int feclearexcept (int excepts) | 13 | int feclearexcept(int flags) |
| 15 | { | 14 | { |
| 16 | fenv_t _env; | 15 | fenv_t env; |
| 17 | #if defined(_ARM_) || defined(__arm__) | 16 | |
| 18 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | 17 | fegetenv(&env); |
| 19 | _env.__cw &= ~(excepts & FE_ALL_EXCEPT); | 18 | flags &= FE_ALL_EXCEPT; |
| 20 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); | 19 | env._Fe_stat &= ~fenv_encode(flags, flags); |
| 21 | #elif defined(_ARM64_) || defined(__aarch64__) | 20 | return fesetenv(&env); |
| 22 | unsigned __int64 fpcr; | ||
| 23 | (void) _env; | ||
| 24 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 25 | fpcr &= ~(excepts & FE_ALL_EXCEPT); | ||
| 26 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 27 | #else | ||
| 28 | int _mxcsr; | ||
| 29 | if (excepts == FE_ALL_EXCEPT) | ||
| 30 | { | ||
| 31 | __asm__ volatile ("fnclex"); | ||
| 32 | } | ||
| 33 | else | ||
| 34 | { | ||
| 35 | __asm__ volatile ("fnstenv %0" : "=m" (_env)); | ||
| 36 | _env.__status_word &= ~(excepts & FE_ALL_EXCEPT); | ||
| 37 | __asm__ volatile ("fldenv %0" : : "m" (_env)); | ||
| 38 | } | ||
| 39 | if (__mingw_has_sse ()) | ||
| 40 | { | ||
| 41 | __asm__ volatile ("stmxcsr %0" : "=m" (_mxcsr)); | ||
| 42 | _mxcsr &= ~(((excepts & FE_ALL_EXCEPT))); | ||
| 43 | __asm__ volatile ("ldmxcsr %0" : : "m" (_mxcsr)); | ||
| 44 | } | ||
| 45 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 46 | return (0); | ||
| 47 | } | 21 | } |
lib/libc/mingw/misc/fegetenv.c+11-20| ... | @@ -4,34 +4,25 @@ | ... | @@ -4,34 +4,25 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <fenv.h> | ||
| 8 | #include <internal.h> | 7 | #include <internal.h> |
| 9 | 8 | ||
| 10 | /* 7.6.4.1 | 9 | /* 7.6.4.1 |
| 11 | The fegetenv function stores the current floating-point environment | 10 | The fegetenv function stores the current floating-point environment |
| 12 | in the object pointed to by envp. */ | 11 | in the object pointed to by envp. */ |
| 13 | 12 | ||
| 14 | int fegetenv (fenv_t * envp) | 13 | int fegetenv(fenv_t *env) |
| 15 | { | 14 | { |
| 16 | #if defined(_ARM_) || defined(__arm__) | 15 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 17 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (*envp)); | 16 | unsigned int x87, sse; |
| 18 | #elif defined(_ARM64_) || defined(__aarch64__) | 17 | __mingw_control87_2(0, 0, &x87, &sse); |
| 19 | unsigned __int64 fpcr; | 18 | env->_Fe_ctl = fenv_encode(x87, sse); |
| 20 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | 19 | __mingw_setfp(NULL, 0, &x87, 0); |
| 21 | envp->__cw = fpcr; | 20 | __mingw_setfp_sse(NULL, 0, &sse, 0); |
| 21 | env->_Fe_stat = fenv_encode(x87, sse); | ||
| 22 | #else | 22 | #else |
| 23 | __asm__ __volatile__ ("fnstenv %0;": "=m" (*envp)); | 23 | env->_Fe_ctl = fenv_encode(0, __mingw_controlfp(0, 0)); |
| 24 | /* fnstenv sets control word to non-stop for all exceptions, so we | 24 | env->_Fe_stat = fenv_encode(0, __mingw_statusfp()); |
| 25 | need to reload our env to restore the original mask. */ | 25 | #endif |
| 26 | __asm__ __volatile__ ("fldenv %0" : : "m" (*envp)); | ||
| 27 | if (__mingw_has_sse ()) | ||
| 28 | { | ||
| 29 | int _mxcsr; | ||
| 30 | __asm__ __volatile__ ("stmxcsr %0" : "=m" (_mxcsr)); | ||
| 31 | envp->__unused0 = (((unsigned int) _mxcsr) >> 16); | ||
| 32 | envp->__unused1 = (((unsigned int) _mxcsr) & 0xffff); | ||
| 33 | } | ||
| 34 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 35 | return 0; | 26 | return 0; |
| 36 | } | 27 | } |
| 37 | 28 |
lib/libc/mingw/misc/fegetexceptflag.c+9-20| ... | @@ -12,26 +12,15 @@ | ... | @@ -12,26 +12,15 @@ |
| 12 | representation of the exception flags indicated by the argument | 12 | representation of the exception flags indicated by the argument |
| 13 | excepts in the object pointed to by the argument flagp. */ | 13 | excepts in the object pointed to by the argument flagp. */ |
| 14 | 14 | ||
| 15 | int fegetexceptflag (fexcept_t * flagp, int excepts) | 15 | int fegetexceptflag(fexcept_t *status, int excepts) |
| 16 | { | 16 | { |
| 17 | #if defined(_ARM_) || defined(__arm__) | 17 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 18 | fenv_t _env; | 18 | unsigned int x87, sse; |
| 19 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | 19 | __mingw_setfp(NULL, 0, &x87, 0); |
| 20 | *flagp = _env.__cw & excepts & FE_ALL_EXCEPT; | 20 | __mingw_setfp_sse(NULL, 0, &sse, 0); |
| 21 | #elif defined(_ARM64_) || defined(__aarch64__) | 21 | *status = fenv_encode(x87 & excepts, sse & excepts); |
| 22 | unsigned __int64 fpcr; | ||
| 23 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 24 | *flagp = fpcr & excepts & FE_ALL_EXCEPT; | ||
| 25 | #else | 22 | #else |
| 26 | int _mxcsr; | 23 | *status = fenv_encode(0, __mingw_statusfp() & excepts); |
| 27 | unsigned short _status; | 24 | #endif |
| 28 | 25 | return 0; | |
| 29 | __asm__ volatile ("fnstsw %0" : "=am" (_status)); | ||
| 30 | _mxcsr = 0; | ||
| 31 | if (__mingw_has_sse ()) | ||
| 32 | __asm__ volatile ("stmxcsr %0" : "=m" (_mxcsr)); | ||
| 33 | |||
| 34 | *flagp = (_mxcsr | _status) & excepts & FE_ALL_EXCEPT; | ||
| 35 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 36 | return 0; | ||
| 37 | } | 26 | } |
lib/libc/mingw/misc/fegetround.c+3-16| ... | @@ -3,26 +3,13 @@ | ... | @@ -3,26 +3,13 @@ |
| 3 | * This file is part of the mingw-w64 runtime package. | 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | #include <fenv.h> | 6 | #include <internal.h> |
| 7 | 7 | ||
| 8 | /* 7.6.3.1 | 8 | /* 7.6.3.1 |
| 9 | The fegetround function returns the value of the rounding direction | 9 | The fegetround function returns the value of the rounding direction |
| 10 | macro representing the current rounding direction. */ | 10 | macro representing the current rounding direction. */ |
| 11 | 11 | ||
| 12 | int | 12 | int fegetround(void) |
| 13 | fegetround (void) | ||
| 14 | { | 13 | { |
| 15 | #if defined(_ARM_) || defined(__arm__) | 14 | return __mingw_controlfp(0, 0) & _MCW_RC; |
| 16 | fenv_t _env; | ||
| 17 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | ||
| 18 | return (_env.__cw & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)); | ||
| 19 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 20 | unsigned __int64 fpcr; | ||
| 21 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 22 | return (fpcr & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)); | ||
| 23 | #else | ||
| 24 | int _control; | ||
| 25 | __asm__ volatile ("fnstcw %0" : "=m" (*&_control)); | ||
| 26 | return (_control & (FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)); | ||
| 27 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 28 | } | 15 | } |
lib/libc/mingw/misc/feholdexcept.c+3-20| ... | @@ -11,25 +11,8 @@ | ... | @@ -11,25 +11,8 @@ |
| 11 | flags, and then installs a non-stop (continue on exceptions) mode, | 11 | flags, and then installs a non-stop (continue on exceptions) mode, |
| 12 | if available, for all exceptions. */ | 12 | if available, for all exceptions. */ |
| 13 | 13 | ||
| 14 | int feholdexcept (fenv_t * envp) | 14 | int feholdexcept(fenv_t *env) |
| 15 | { | 15 | { |
| 16 | #if defined(_ARM_) || defined(__arm__) | 16 | fegetenv(env); |
| 17 | fenv_t _env; | 17 | return feclearexcept(FE_ALL_EXCEPT); |
| 18 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | ||
| 19 | envp->__cw = _env.__cw; | ||
| 20 | _env.__cw &= ~(FE_ALL_EXCEPT); | ||
| 21 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); | ||
| 22 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 23 | unsigned __int64 fpcr; | ||
| 24 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 25 | envp->__cw = fpcr; | ||
| 26 | fpcr &= ~(FE_ALL_EXCEPT); | ||
| 27 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 28 | #else | ||
| 29 | __asm__ __volatile__ ("fnstenv %0;" : "=m" (* envp)); /* save current into envp */ | ||
| 30 | /* fnstenv sets control word to non-stop for all exceptions, so all we | ||
| 31 | need to do is clear the exception flags. */ | ||
| 32 | __asm__ __volatile__ ("fnclex"); | ||
| 33 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 34 | return 0; | ||
| 35 | } | 18 | } |
lib/libc/mingw/misc/feraiseexcept.c+12-20| ... | @@ -3,7 +3,7 @@ | ... | @@ -3,7 +3,7 @@ |
| 3 | * This file is part of the mingw-w64 runtime package. | 3 | * This file is part of the mingw-w64 runtime package. |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | #include <fenv.h> | 6 | #include <internal.h> |
| 7 | 7 | ||
| 8 | /* 7.6.2.3 | 8 | /* 7.6.2.3 |
| 9 | The feraiseexcept function raises the supported exceptions | 9 | The feraiseexcept function raises the supported exceptions |
| ... | @@ -13,24 +13,16 @@ | ... | @@ -13,24 +13,16 @@ |
| 13 | the inexact exception whenever it raises the overflow | 13 | the inexact exception whenever it raises the overflow |
| 14 | or underflow exception is implementation-defined. */ | 14 | or underflow exception is implementation-defined. */ |
| 15 | 15 | ||
| 16 | int feraiseexcept (int excepts) | 16 | int feraiseexcept(int flags) |
| 17 | { | 17 | { |
| 18 | fenv_t _env; | 18 | fenv_t env; |
| 19 | #if defined(_ARM_) || defined(__arm__) | 19 | |
| 20 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | 20 | flags &= FE_ALL_EXCEPT; |
| 21 | _env.__cw |= excepts & FE_ALL_EXCEPT; | 21 | fegetenv(&env); |
| 22 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); | 22 | env._Fe_stat |= fenv_encode(flags, flags); |
| 23 | #elif defined(_ARM64_) || defined(__aarch64__) | 23 | fesetenv(&env); |
| 24 | unsigned __int64 fpcr; | 24 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) |
| 25 | (void) _env; | 25 | __asm__ volatile ("fwait\n\t"); |
| 26 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | 26 | #endif |
| 27 | fpcr |= excepts & FE_ALL_EXCEPT; | 27 | return 0; |
| 28 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 29 | #else | ||
| 30 | __asm__ volatile ("fnstenv %0;" : "=m" (_env)); | ||
| 31 | _env.__status_word |= excepts & FE_ALL_EXCEPT; | ||
| 32 | __asm__ volatile ("fldenv %0;" | ||
| 33 | 		 "fwait;" : : "m" (_env)); | ||
| 34 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 35 | return 0; | ||
| 36 | } | 28 | } |
lib/libc/mingw/misc/fesetenv.c+35-56| ... | @@ -4,11 +4,24 @@ | ... | @@ -4,11 +4,24 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <_mingw.h> | ||
| 8 | #include <fenv.h> | ||
| 9 | #include <float.h> | ||
| 10 | #include <internal.h> | 7 | #include <internal.h> |
| 11 | 8 | ||
| 9 | /* The FE_DFL_ENV macro is required by standard. | ||
| 10 | fesetenv will use the environment set at app startup.*/ | ||
| 11 | const fenv_t __mingw_fe_dfl_env = { 0, 0 }; | ||
| 12 | |||
| 13 | /* The C99 standard (7.6.9) allows us to define implementation-specific macros for | ||
| 14 | different fp environments */ | ||
| 15 | #if defined(__i386__) || defined(__x86_64__) | ||
| 16 | |||
| 17 | /* The default Intel x87 floating point environment (64-bit mantissa) */ | ||
| 18 | const fenv_t __mingw_fe_pc64_env = { 0x3f3f003f, 0 }; | ||
| 19 | |||
| 20 | /* The floating point environment set by MSVCRT _fpreset (53-bit mantissa) */ | ||
| 21 | const fenv_t __mingw_fe_pc53_env = { 0x3f3f103f, 0 }; | ||
| 22 | |||
| 23 | #endif | ||
| 24 | |||
| 12 | /* 7.6.4.3 | 25 | /* 7.6.4.3 |
| 13 | The fesetenv function establishes the floating-point environment | 26 | The fesetenv function establishes the floating-point environment |
| 14 | represented by the object pointed to by envp. The argument envp | 27 | represented by the object pointed to by envp. The argument envp |
| ... | @@ -22,61 +35,27 @@ | ... | @@ -22,61 +35,27 @@ |
| 22 | extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void); | 35 | extern void (* __MINGW_IMP_SYMBOL(_fpreset))(void); |
| 23 | extern void _fpreset(void); | 36 | extern void _fpreset(void); |
| 24 | 37 | ||
| 25 | int fesetenv (const fenv_t * envp) | 38 | int fesetenv(const fenv_t *env) |
| 26 | { | 39 | { |
| 27 | #if defined(_ARM_) || defined(__arm__) | 40 | unsigned int x87_cw, cw, x87_stat, stat; |
| 28 | if (envp == FE_DFL_ENV) | 41 | unsigned int mask = ~0u; |
| 29 | /* Use the choice made at app startup */ | ||
| 30 | _fpreset(); | ||
| 31 | else | ||
| 32 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (*envp)); | ||
| 33 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 34 | if (envp == FE_DFL_ENV) { | ||
| 35 | /* Use the choice made at app startup */ | ||
| 36 | _fpreset(); | ||
| 37 | } else { | ||
| 38 | unsigned __int64 fpcr = envp->__cw; | ||
| 39 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 40 | } | ||
| 41 | #else | ||
| 42 | if (envp == FE_PC64_ENV) | ||
| 43 | /* | ||
| 44 | * fninit initializes the control register to 0x37f, | ||
| 45 | * the status register to zero and the tag word to 0FFFFh. | ||
| 46 | * The other registers are unaffected. | ||
| 47 | */ | ||
| 48 | __asm__ __volatile__ ("fninit"); | ||
| 49 | 42 | ||
| 50 | else if (envp == FE_PC53_ENV) | 43 | if (!env->_Fe_ctl && !env->_Fe_stat) { |
| 51 | /* | 44 | _fpreset(); |
| 52 | * MS _fpreset() does same *except* it sets control word | 45 | return 0; |
| 53 | * to 0x27f (53-bit precision). | ||
| 54 | * We force calling _fpreset in msvcrt.dll | ||
| 55 | */ | ||
| 56 | |||
| 57 | (* __MINGW_IMP_SYMBOL(_fpreset))(); | ||
| 58 | |||
| 59 | else if (envp == FE_DFL_ENV) | ||
| 60 | /* Use the choice made at app startup */ | ||
| 61 | _fpreset(); | ||
| 62 | |||
| 63 | else | ||
| 64 | { | ||
| 65 | fenv_t env = *envp; | ||
| 66 | int has_sse = __mingw_has_sse (); | ||
| 67 | int _mxcsr; | ||
| 68 | /*_mxcsr = ((int)envp->__unused0 << 16) | (int)envp->__unused1; *//* mxcsr low and high */ | ||
| 69 | if (has_sse) | ||
| 70 | __asm__ ("stmxcsr %0" : "=m" (*&_mxcsr)); | ||
| 71 | env.__unused0 = 0xffff; | ||
| 72 | env.__unused1 = 0xffff; | ||
| 73 | __asm__ volatile ("fldenv %0" : : "m" (env) | ||
| 74 | 			: "st", "st(1)", "st(2)", "st(3)", "st(4)", | ||
| 75 | 			"st(5)", "st(6)", "st(7)"); | ||
| 76 | if (has_sse) | ||
| 77 | __asm__ volatile ("ldmxcsr %0" : : "m" (*&_mxcsr)); | ||
| 78 | } | 46 | } |
| 79 | 47 | ||
| 80 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | 48 | if (!fenv_decode(env->_Fe_ctl, &x87_cw, &cw)) |
| 81 | return 0; | 49 | return 1; |
| 50 | if (!fenv_decode(env->_Fe_stat, &x87_stat, &stat)) | ||
| 51 | return 1; | ||
| 52 | |||
| 53 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) | ||
| 54 | __mingw_setfp(&x87_cw, mask, &x87_stat, ~0); | ||
| 55 | if (__mingw_has_sse()) | ||
| 56 | __mingw_setfp_sse(&cw, mask, &stat, ~0); | ||
| 57 | #else | ||
| 58 | __mingw_setfp(&cw, mask, &stat, ~0); | ||
| 59 | #endif | ||
| 60 | return 0; | ||
| 82 | } | 61 | } |
lib/libc/mingw/misc/fesetexceptflag.c+9-33| ... | @@ -4,7 +4,6 @@ | ... | @@ -4,7 +4,6 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #include <fenv.h> | ||
| 8 | #include <internal.h> | 7 | #include <internal.h> |
| 9 | 8 | ||
| 10 | /* 7.6.2.4 | 9 | /* 7.6.2.4 |
| ... | @@ -16,39 +15,16 @@ | ... | @@ -16,39 +15,16 @@ |
| 16 | represented by the argument excepts. This function does not raise | 15 | represented by the argument excepts. This function does not raise |
| 17 | exceptions, but only sets the state of the flags. */ | 16 | exceptions, but only sets the state of the flags. */ |
| 18 | 17 | ||
| 19 | int fesetexceptflag (const fexcept_t * flagp, int excepts) | 18 | int fesetexceptflag(const fexcept_t *status, int excepts) |
| 20 | { | 19 | { |
| 21 | fenv_t _env; | 20 | fenv_t env; |
| 22 | 21 | ||
| 23 | excepts &= FE_ALL_EXCEPT; | 22 | excepts &= FE_ALL_EXCEPT; |
| 23 | if(!excepts) | ||
| 24 | return 0; | ||
| 24 | 25 | ||
| 25 | #if defined(_ARM_) || defined(__arm__) | 26 | fegetenv(&env); |
| 26 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | 27 | env._Fe_stat &= ~fenv_encode(excepts, excepts); |
| 27 | _env.__cw &= ~excepts; | 28 | env._Fe_stat |= *status & fenv_encode(excepts, excepts); |
| 28 | _env.__cw |= (*flagp & excepts); | 29 | return fesetenv(&env); |
| 29 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); | ||
| 30 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 31 | unsigned __int64 fpcr; | ||
| 32 | (void) _env; | ||
| 33 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 34 | fpcr &= ~excepts; | ||
| 35 | fpcr |= (*flagp & excepts); | ||
| 36 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 37 | #else | ||
| 38 | __asm__ volatile ("fnstenv %0;" : "=m" (_env)); | ||
| 39 | _env.__status_word &= ~excepts; | ||
| 40 | _env.__status_word |= (*flagp & excepts); | ||
| 41 | __asm__ volatile ("fldenv %0;" : : "m" (_env)); | ||
| 42 | |||
| 43 | if (__mingw_has_sse ()) | ||
| 44 | { | ||
| 45 | int sse_cw; | ||
| 46 | __asm__ volatile ("stmxcsr %0;" : "=m" (sse_cw)); | ||
| 47 | sse_cw &= ~(excepts << 7); | ||
| 48 | sse_cw |= ((*flagp & excepts) << 7); | ||
| 49 | __asm__ volatile ("ldmxcsr %0" : : "m" (sse_cw)); | ||
| 50 | } | ||
| 51 | |||
| 52 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 53 | return 0; | ||
| 54 | } | 30 | } |
lib/libc/mingw/misc/fesetround.c+5-38| ... | @@ -13,43 +13,10 @@ | ... | @@ -13,43 +13,10 @@ |
| 13 | to the value of a rounding direction macro, the rounding direction | 13 | to the value of a rounding direction macro, the rounding direction |
| 14 | is not changed. */ | 14 | is not changed. */ |
| 15 | 15 | ||
| 16 | int fesetround (int mode) | 16 | int fesetround(int round_mode) |
| 17 | { | 17 | { |
| 18 | #if defined(_ARM_) || defined(__arm__) | 18 | if (round_mode & (~_MCW_RC)) |
| 19 | fenv_t _env; | 19 | return 1; |
| 20 | if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) != 0) | 20 | __mingw_controlfp(round_mode, _MCW_RC); |
| 21 | return -1; | 21 | return 0; |
| 22 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | ||
| 23 | _env.__cw &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); | ||
| 24 | _env.__cw |= mode; | ||
| 25 | __asm__ volatile ("fmxr FPSCR, %0" : : "r" (_env)); | ||
| 26 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 27 | unsigned __int64 fpcr; | ||
| 28 | if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) != 0) | ||
| 29 | return -1; | ||
| 30 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 31 | fpcr &= ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO); | ||
| 32 | fpcr |= mode; | ||
| 33 | __asm__ volatile ("msr fpcr, %0" : : "r" (fpcr)); | ||
| 34 | #else | ||
| 35 | unsigned short _cw; | ||
| 36 | if ((mode & ~(FE_TONEAREST | FE_DOWNWARD | FE_UPWARD | FE_TOWARDZERO)) | ||
| 37 | != 0) | ||
| 38 | return -1; | ||
| 39 | __asm__ volatile ("fnstcw %0;": "=m" (*&_cw)); | ||
| 40 | _cw &= ~0xc00; | ||
| 41 | _cw |= mode; | ||
| 42 | __asm__ volatile ("fldcw %0;" : : "m" (*&_cw)); | ||
| 43 | |||
| 44 | if (__mingw_has_sse ()) | ||
| 45 | { | ||
| 46 | int mxcsr; | ||
| 47 | |||
| 48 | __asm__ volatile ("stmxcsr %0" : "=m" (*&mxcsr)); | ||
| 49 | mxcsr &= ~0x6000; | ||
| 50 | mxcsr |= mode << 3; | ||
| 51 | __asm__ volatile ("ldmxcsr %0" : : "m" (*&mxcsr)); | ||
| 52 | } | ||
| 53 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 54 | return 0; | ||
| 55 | } | 22 | } |
lib/libc/mingw/misc/fetestexcept.c+2-21| ... | @@ -15,26 +15,7 @@ | ... | @@ -15,26 +15,7 @@ |
| 15 | exception macros corresponding to the currently set exceptions | 15 | exception macros corresponding to the currently set exceptions |
| 16 | included in excepts. */ | 16 | included in excepts. */ |
| 17 | 17 | ||
| 18 | int fetestexcept (int excepts) | 18 | int fetestexcept(int flags) |
| 19 | { | 19 | { |
| 20 | #if defined(_ARM_) || defined(__arm__) | 20 | return __mingw_statusfp() & flags; |
| 21 | fenv_t _env; | ||
| 22 | __asm__ volatile ("fmrx %0, FPSCR" : "=r" (_env)); | ||
| 23 | return _env.__cw & excepts & FE_ALL_EXCEPT; | ||
| 24 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 25 | unsigned __int64 fpcr; | ||
| 26 | __asm__ volatile ("mrs %0, fpcr" : "=r" (fpcr)); | ||
| 27 | return fpcr & excepts & FE_ALL_EXCEPT; | ||
| 28 | #else | ||
| 29 | unsigned short _sw; | ||
| 30 | __asm__ __volatile__ ("fnstsw %%ax" : "=a" (_sw)); | ||
| 31 | |||
| 32 | if (__mingw_has_sse ()) | ||
| 33 | { | ||
| 34 | int sse_sw; | ||
| 35 | __asm__ __volatile__ ("stmxcsr %0;" : "=m" (sse_sw)); | ||
| 36 | _sw |= sse_sw; | ||
| 37 | } | ||
| 38 | return _sw & excepts & FE_ALL_EXCEPT; | ||
| 39 | #endif /* defined(_ARM_) || defined(__arm__) || defined(_ARM64_) || defined(__aarch64__) */ | ||
| 40 | } | 21 | } |
lib/libc/mingw/misc/feupdateenv.c+3-7| ... | @@ -13,13 +13,9 @@ | ... | @@ -13,13 +13,9 @@ |
| 13 | set by a call to feholdexcept or fegetenv, or equal the macro | 13 | set by a call to feholdexcept or fegetenv, or equal the macro |
| 14 | FE_DFL_ENV or an implementation-defined environment macro. */ | 14 | FE_DFL_ENV or an implementation-defined environment macro. */ |
| 15 | 15 | ||
| 16 | /* FIXME: this works but surely there must be a better way. */ | 16 | int feupdateenv(const fenv_t *env) |
| 17 | |||
| 18 | int feupdateenv (const fenv_t * envp) | ||
| 19 | { | 17 | { |
| 20 | unsigned int _fexcept = fetestexcept (FE_ALL_EXCEPT); /*save excepts */ | 18 | int except = fetestexcept(FE_ALL_EXCEPT); |
| 21 | fesetenv (envp); /* install the env */ | 19 | return fesetenv(env) || feraiseexcept(except); |
| 22 | feraiseexcept (_fexcept); /* raise the except */ | ||
| 23 | return 0; | ||
| 24 | } | 20 | } |
| 25 | 21 |
lib/libc/mingw/misc/ftw.c+18-16| ... | @@ -15,11 +15,9 @@ | ... | @@ -15,11 +15,9 @@ |
| 15 | #include <dirent.h> | 15 | #include <dirent.h> |
| 16 | #include <ftw.h> | 16 | #include <ftw.h> |
| 17 | 17 | ||
| 18 | #ifdef IMPL_FTW64 | 18 | int __cdecl stat32(const char *_Filename, struct _stat32 *_Stat); |
| 19 | #define stat stat64 | 19 | int __cdecl stat32i64(const char *_Filename, struct _stat32i64 *_Stat); |
| 20 | #define nftw nftw64 | 20 | int __cdecl stat64i32(const char *_Filename, struct _stat64i32 *_Stat); |
| 21 | #define ftw ftw64 | ||
| 22 | #endif | ||
| 23 | 21 | ||
| 24 | typedef struct dir_data_t { | 22 | typedef struct dir_data_t { |
| 25 | DIR *h; | 23 | DIR *h; |
| ... | @@ -36,14 +34,14 @@ typedef struct ctx_t { | ... | @@ -36,14 +34,14 @@ typedef struct ctx_t { |
| 36 | dir_data_t **dirs; | 34 | dir_data_t **dirs; |
| 37 | char *buf; | 35 | char *buf; |
| 38 | struct FTW ftw; | 36 | struct FTW ftw; |
| 39 | int (*fcb) (const char *, const struct stat *, int , struct FTW *); | 37 | int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *); |
| 40 | size_t cur_dir, msz_dir, buf_sz; | 38 | size_t cur_dir, msz_dir, buf_sz; |
| 41 | int flags; | 39 | int flags; |
| 42 | dev_t dev; | 40 | dev_t dev; |
| 43 | } ctx_t; | 41 | } ctx_t; |
| 44 | 42 | ||
| 45 | static int add_object (ctx_t *); | 43 | static int add_object (ctx_t *); |
| 46 | static int do_dir (ctx_t *, struct stat *, dir_data_t *); | 44 | static int do_dir (ctx_t *, STRUCT_STAT *, dir_data_t *); |
| 47 | static int do_entity (ctx_t *, dir_data_t *, const char *, size_t); | 45 | static int do_entity (ctx_t *, dir_data_t *, const char *, size_t); |
| 48 | static int do_it (const char *, int, void *, int, int); | 46 | static int do_it (const char *, int, void *, int, int); |
| 49 | 47 | ||
| ... | @@ -225,7 +223,7 @@ open_directory (ctx_t *ctx, dir_data_t *dirp) | ... | @@ -225,7 +223,7 @@ open_directory (ctx_t *ctx, dir_data_t *dirp) |
| 225 | static int | 223 | static int |
| 226 | do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) | 224 | do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) |
| 227 | { | 225 | { |
| 228 | struct stat st; | 226 | STRUCT_STAT st; |
| 229 | char *h; | 227 | char *h; |
| 230 | size_t cnt_sz; | 228 | size_t cnt_sz; |
| 231 | int ret = 0, flag = 0; | 229 | int ret = 0, flag = 0; |
| ... | @@ -249,7 +247,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) | ... | @@ -249,7 +247,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) |
| 249 | 247 | ||
| 250 | name = ctx->buf; | 248 | name = ctx->buf; |
| 251 | 249 | ||
| 252 | if (stat (name, &st) < 0) | 250 | if (FUNC_STAT (name, &st) < 0) |
| 253 | { | 251 | { |
| 254 | if (errno != EACCES && errno != ENOENT) | 252 | if (errno != EACCES && errno != ENOENT) |
| 255 | 	ret = -1; | 253 | 	ret = -1; |
| ... | @@ -257,7 +255,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) | ... | @@ -257,7 +255,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) |
| 257 | 	flag = FTW_NS; | 255 | 	flag = FTW_NS; |
| 258 | 256 | ||
| 259 | if (!(ctx->flags & FTW_PHYS)) | 257 | if (!(ctx->flags & FTW_PHYS)) |
| 260 | 	stat (name, &st); | 258 | 	FUNC_STAT (name, &st); |
| 261 | } | 259 | } |
| 262 | else | 260 | else |
| 263 | flag = (S_ISDIR (st.st_mode) ? FTW_D : FTW_F); | 261 | 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) | ... | @@ -281,7 +279,7 @@ do_entity (ctx_t *ctx, dir_data_t *dir, const char *name, size_t namlen) |
| 281 | 279 | ||
| 282 | 280 | ||
| 283 | static int | 281 | static int |
| 284 | do_dir (ctx_t *ctx, struct stat *st, __UNUSED_PARAM(dir_data_t *old_dir)) | 282 | do_dir (ctx_t *ctx, STRUCT_STAT *st, __UNUSED_PARAM(dir_data_t *old_dir)) |
| 285 | { | 283 | { |
| 286 | dir_data_t dir; | 284 | dir_data_t dir; |
| 287 | struct dirent *d; | 285 | struct dirent *d; |
| ... | @@ -378,7 +376,7 @@ static int | ... | @@ -378,7 +376,7 @@ static int |
| 378 | do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, int flags) | 376 | do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, int flags) |
| 379 | { | 377 | { |
| 380 | struct ctx_t ctx; | 378 | struct ctx_t ctx; |
| 381 | struct stat st; | 379 | STRUCT_STAT st; |
| 382 | int ret = 0; | 380 | int ret = 0; |
| 383 | int sv_e; | 381 | int sv_e; |
| 384 | char *cp; | 382 | char *cp; |
| ... | @@ -417,12 +415,12 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, | ... | @@ -417,12 +415,12 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, |
| 417 | ctx.ftw.level = 0; | 415 | ctx.ftw.level = 0; |
| 418 | ctx.ftw.base = cp - ctx.buf; | 416 | ctx.ftw.base = cp - ctx.buf; |
| 419 | ctx.flags = flags; | 417 | ctx.flags = flags; |
| 420 | ctx.fcb = (int (*) (const char *, const struct stat *, int , struct FTW *)) fcb; | 418 | ctx.fcb = (int (*) (const char *, const STRUCT_STAT *, int , struct FTW *)) fcb; |
| 421 | ctx.objs = NULL; | 419 | ctx.objs = NULL; |
| 422 | 420 | ||
| 423 | if (!ret) | 421 | if (!ret) |
| 424 | { | 422 | { |
| 425 | if (stat (ctx.buf, &st) < 0) | 423 | if (FUNC_STAT (ctx.buf, &st) < 0) |
| 426 | 	ret = -1; | 424 | 	ret = -1; |
| 427 | else if (S_ISDIR (st.st_mode)) | 425 | else if (S_ISDIR (st.st_mode)) |
| 428 | 	{ | 426 | 	{ |
| ... | @@ -451,13 +449,17 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, | ... | @@ -451,13 +449,17 @@ do_it (const char *dir, __UNUSED_PARAM(int is_nftw), void *fcb, int descriptors, |
| 451 | } | 449 | } |
| 452 | 450 | ||
| 453 | int | 451 | int |
| 454 | ftw (const char *path, int (*fcb) (const char *, const struct stat *, int), int descriptors) | 452 | FUNC_FTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int), int descriptors); |
| 453 | int | ||
| 454 | FUNC_FTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int), int descriptors) | ||
| 455 | { | 455 | { |
| 456 | return do_it (path, 0, fcb, descriptors, 0); | 456 | return do_it (path, 0, fcb, descriptors, 0); |
| 457 | } | 457 | } |
| 458 | 458 | ||
| 459 | int | 459 | int |
| 460 | nftw (const char *path, int (*fcb) (const char *, const struct stat *, int , struct FTW *), int descriptors, int flags) | 460 | FUNC_NFTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *), int descriptors, int flags); |
| 461 | int | ||
| 462 | FUNC_NFTW (const char *path, int (*fcb) (const char *, const STRUCT_STAT *, int , struct FTW *), int descriptors, int flags) | ||
| 461 | { | 463 | { |
| 462 | return do_it (path, 1, fcb, descriptors, flags); | 464 | return do_it (path, 1, fcb, descriptors, flags); |
| 463 | } | 465 | } |
lib/libc/mingw/misc/ftw32.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | /** | ||
| 2 | * This file is part of the mingw-w64 runtime package. | ||
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define FUNC_FTW ftw32 | ||
| 7 | #define FUNC_NFTW nftw32 | ||
| 8 | #define FUNC_STAT stat32 | ||
| 9 | #define STRUCT_STAT struct _stat32 | ||
| 10 | #include "ftw.c" | ||
| 11 | |||
| 12 | /* On 32-bit systems is stat ABI compatible with stat32 */ | ||
| 13 | #ifndef _WIN64 | ||
| 14 | #undef nftw | ||
| 15 | #undef ftw | ||
| 16 | struct stat; | ||
| 17 | int __attribute__ ((alias ("nftw32"))) __cdecl nftw(const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int); | ||
| 18 | int __attribute__ ((alias ("ftw32"))) __cdecl ftw(const char *, int (*) (const char *, const struct stat *, int), int); | ||
| 19 | #endif | ||
lib/libc/mingw/misc/ftw32i64.c created+10| ... | @@ -0,0 +1,10 @@ | ||
| 1 | /** | ||
| 2 | * This file is part of the mingw-w64 runtime package. | ||
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define FUNC_FTW ftw32i64 | ||
| 7 | #define FUNC_NFTW nftw32i64 | ||
| 8 | #define FUNC_STAT stat32i64 | ||
| 9 | #define STRUCT_STAT struct _stat32i64 | ||
| 10 | #include "ftw.c" | ||
lib/libc/mingw/misc/ftw64.c+4-2| ... | @@ -3,6 +3,8 @@ | ... | @@ -3,6 +3,8 @@ |
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. | 3 | * No warranty is given; refer to the file DISCLAIMER within this package. |
| 4 | */ | 4 | */ |
| 5 | 5 | ||
| 6 | #define IMPL_FTW64 1 | 6 | #define FUNC_FTW ftw64 |
| 7 | 7 | #define FUNC_NFTW nftw64 | |
| 8 | #define FUNC_STAT stat64 | ||
| 9 | #define STRUCT_STAT struct stat64 | ||
| 8 | #include "ftw.c" | 10 | #include "ftw.c" |
lib/libc/mingw/misc/ftw64i32.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | /** | ||
| 2 | * This file is part of the mingw-w64 runtime package. | ||
| 3 | * No warranty is given; refer to the file DISCLAIMER within this package. | ||
| 4 | */ | ||
| 5 | |||
| 6 | #define FUNC_FTW ftw64i32 | ||
| 7 | #define FUNC_NFTW nftw64i32 | ||
| 8 | #define FUNC_STAT stat64i32 | ||
| 9 | #define STRUCT_STAT struct _stat64i32 | ||
| 10 | #include "ftw.c" | ||
| 11 | |||
| 12 | /* On 64-bit systems is stat ABI compatible with stat64i32 */ | ||
| 13 | #ifdef _WIN64 | ||
| 14 | #undef nftw | ||
| 15 | #undef ftw | ||
| 16 | struct stat; | ||
| 17 | int __attribute__ ((alias ("nftw64i32"))) __cdecl nftw(const char *, int (*) (const char *, const struct stat *, int, struct FTW *), int, int); | ||
| 18 | int __attribute__ ((alias ("ftw64i32"))) __cdecl ftw(const char *, int (*) (const char *, const struct stat *, int), int); | ||
| 19 | #endif | ||
lib/libc/mingw/misc/mingw-aligned-malloc.c+33-7| ... | @@ -18,16 +18,14 @@ | ... | @@ -18,16 +18,14 @@ |
| 18 | #include <stdint.h>		/* uintptr_t */ | 18 | #include <stdint.h>		/* uintptr_t */ |
| 19 | #include <string.h>		/* memmove */ | 19 | #include <string.h>		/* memmove */ |
| 20 | 20 | ||
| 21 | /* Forward declarations: */ | ||
| 22 | void *__mingw_aligned_offset_malloc (size_t, size_t, size_t); | ||
| 23 | |||
| 24 | #define NOT_POWER_OF_TWO(n) (((n) & ((n) - 1))) | 21 | #define NOT_POWER_OF_TWO(n) (((n) & ((n) - 1))) |
| 25 | #define UI(p) ((uintptr_t) (p)) | 22 | #define UI(p) ((uintptr_t) (p)) |
| 26 | #define CP(p) ((char *) p) | 23 | #define CP(p) ((char *) p) |
| 27 | 24 | ||
| 25 | #define GAP(offset) ((0 - offset) & (sizeof (void *) -1)) | ||
| 28 | #define PTR_ALIGN(p0, alignment, offset)				\ | 26 | #define PTR_ALIGN(p0, alignment, offset)				\ |
| 29 | ((void *) (((UI(p0) + (alignment + sizeof(void*)) + offset)	\ | 27 | ((void *) (((UI(p0) + (alignment + GAP(offset) + sizeof(void*)) + offset)	\ |
| 30 | 			& (~UI(alignment - 1)))				\ | 28 | 			& (~UI(alignment)))				\ |
| 31 | 		 - offset)) | 29 | 		 - offset)) |
| 32 | 30 | ||
| 33 | /* Pointer must sometimes be aligned; assume sizeof(void*) is a power of two. */ | 31 | /* 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) | ... | @@ -47,12 +45,13 @@ __mingw_aligned_offset_malloc (size_t size, size_t alignment, size_t offset) |
| 47 | return ((void *) 0); | 45 | return ((void *) 0); |
| 48 | if (alignment < sizeof (void *)) | 46 | if (alignment < sizeof (void *)) |
| 49 | alignment = sizeof (void *); | 47 | alignment = sizeof (void *); |
| 48 | alignment--; | ||
| 50 | 49 | ||
| 51 | /* Including the extra sizeof(void*) is overkill on a 32-bit | 50 | /* Including the extra sizeof(void*) is overkill on a 32-bit |
| 52 | machine, since malloc is already 8-byte aligned, as long | 51 | machine, since malloc is already 8-byte aligned, as long |
| 53 | as we enforce alignment >= 8 ...but oh well. */ | 52 | as we enforce alignment >= 8 ...but oh well. */ |
| 54 | 53 | ||
| 55 | p0 = malloc (size + (alignment + sizeof (void *))); | 54 | p0 = malloc (size + (alignment + GAP (offset) + sizeof (void *))); |
| 56 | if (!p0) | 55 | if (!p0) |
| 57 | return ((void *) 0); | 56 | return ((void *) 0); |
| 58 | p = PTR_ALIGN (p0, alignment, offset); | 57 | p = PTR_ALIGN (p0, alignment, offset); |
| ... | @@ -91,6 +90,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size, | ... | @@ -91,6 +90,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size, |
| 91 | } | 90 | } |
| 92 | if (alignment < sizeof (void *)) | 91 | if (alignment < sizeof (void *)) |
| 93 | alignment = sizeof (void *); | 92 | alignment = sizeof (void *); |
| 93 | alignment--; | ||
| 94 | 94 | ||
| 95 | p0 = ORIG_PTR (memblock); | 95 | p0 = ORIG_PTR (memblock); |
| 96 | /* It is an error for the alignment to change. */ | 96 | /* It is an error for the alignment to change. */ |
| ... | @@ -98,7 +98,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size, | ... | @@ -98,7 +98,7 @@ __mingw_aligned_offset_realloc (void *memblock, size_t size, |
| 98 | goto bad; | 98 | goto bad; |
| 99 | shift = CP (memblock) - CP (p0); | 99 | shift = CP (memblock) - CP (p0); |
| 100 | 100 | ||
| 101 | p0 = realloc (p0, size + (alignment + sizeof (void *))); | 101 | p0 = realloc (p0, size + (alignment + GAP (offset) + sizeof (void *))); |
| 102 | if (!p0) | 102 | if (!p0) |
| 103 | return ((void *) 0); | 103 | return ((void *) 0); |
| 104 | p = PTR_ALIGN (p0, alignment, offset); | 104 | p = PTR_ALIGN (p0, alignment, offset); |
| ... | @@ -121,3 +121,29 @@ __mingw_aligned_realloc (void *memblock, size_t size, size_t alignment) | ... | @@ -121,3 +121,29 @@ __mingw_aligned_realloc (void *memblock, size_t size, size_t alignment) |
| 121 | { | 121 | { |
| 122 | return __mingw_aligned_offset_realloc (memblock, size, alignment, 0); | 122 | return __mingw_aligned_offset_realloc (memblock, size, alignment, 0); |
| 123 | } | 123 | } |
| 124 | |||
| 125 | size_t | ||
| 126 | __mingw_aligned_msize (void *memblock, size_t alignment, size_t offset) | ||
| 127 | { | ||
| 128 | void *p0; | ||
| 129 | |||
| 130 | if (!memblock || NOT_POWER_OF_TWO (alignment)) | ||
| 131 | { | ||
| 132 | errno = EINVAL; | ||
| 133 | return (size_t)-1; | ||
| 134 | } | ||
| 135 | if (alignment < sizeof (void *)) | ||
| 136 | alignment = sizeof (void *); | ||
| 137 | alignment--; | ||
| 138 | |||
| 139 | p0 = ORIG_PTR (memblock); | ||
| 140 | |||
| 141 | /* It is an error if the alignment or offset does not match. */ | ||
| 142 | if (memblock != PTR_ALIGN (p0, alignment, offset)) | ||
| 143 | { | ||
| 144 | errno = EINVAL; | ||
| 145 | return (size_t)-1; | ||
| 146 | } | ||
| 147 | |||
| 148 | return _msize (p0) - (alignment + GAP (offset) + sizeof (void *)); | ||
| 149 | } |
lib/libc/mingw/misc/mingw_controlfp.c created+53| ... | @@ -0,0 +1,53 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include "internal.h" | ||
| 8 | |||
| 9 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) | ||
| 10 | /* Internal MinGW version of _control87_2 */ | ||
| 11 | int __mingw_control87_2( unsigned int newval, unsigned int mask, | ||
| 12 | unsigned int *x86_cw, unsigned int *sse2_cw ) | ||
| 13 | { | ||
| 14 | if (x86_cw) | ||
| 15 | { | ||
| 16 | *x86_cw = newval; | ||
| 17 | __mingw_setfp(x86_cw, mask, NULL, 0); | ||
| 18 | } | ||
| 19 | |||
| 20 | if (!sse2_cw) return 1; | ||
| 21 | |||
| 22 | if (__mingw_has_sse()) | ||
| 23 | { | ||
| 24 | *sse2_cw = newval; | ||
| 25 | __mingw_setfp_sse(sse2_cw, mask, NULL, 0); | ||
| 26 | } | ||
| 27 | else *sse2_cw = 0; | ||
| 28 | |||
| 29 | return 1; | ||
| 30 | } | ||
| 31 | #endif | ||
| 32 | |||
| 33 | /* Internal MinGW version of _control87 */ | ||
| 34 | unsigned int __mingw_controlfp(unsigned int newval, unsigned int mask) | ||
| 35 | { | ||
| 36 | unsigned int flags = 0; | ||
| 37 | #if defined(__i386__) || (defined(__x86_64__) && !defined(__arm64ec__)) | ||
| 38 | unsigned int sse2_cw; | ||
| 39 | |||
| 40 | __mingw_control87_2( newval, mask, &flags, &sse2_cw ); | ||
| 41 | |||
| 42 | if (__mingw_has_sse()) | ||
| 43 | { | ||
| 44 | if ((flags ^ sse2_cw) & (_MCW_EM | _MCW_RC)) flags |= _EM_AMBIGUOUS; | ||
| 45 | flags |= sse2_cw; | ||
| 46 | } | ||
| 47 | #else | ||
| 48 | flags = newval; | ||
| 49 | __mingw_setfp(&flags, mask, NULL, 0); | ||
| 50 | #endif | ||
| 51 | return flags; | ||
| 52 | } | ||
| 53 | |||
lib/libc/mingw/misc/mingw_getsp.S+4-4| ... | @@ -15,7 +15,10 @@ | ... | @@ -15,7 +15,10 @@ |
| 15 | 	.globl __MINGW_USYMBOL(mingw_getsp) | 15 | 	.globl __MINGW_USYMBOL(mingw_getsp) |
| 16 | 	.def	__MINGW_USYMBOL(mingw_getsp);	.scl	2;	.type	32;	.endef | 16 | 	.def	__MINGW_USYMBOL(mingw_getsp);	.scl	2;	.type	32;	.endef |
| 17 | __MINGW_USYMBOL(mingw_getsp): | 17 | __MINGW_USYMBOL(mingw_getsp): |
| 18 | #if defined(_AMD64_) || defined(__x86_64__) | 18 | #if defined(_ARM64_) || defined(__aarch64__) || defined(__arm64ec__) |
| 19 | 	mov	x0, sp | ||
| 20 | 	ret | ||
| 21 | #elif defined(_AMD64_) || defined(__x86_64__) | ||
| 19 | 	leaq 8(%rsp),%rax | 22 | 	leaq 8(%rsp),%rax |
| 20 | 	ret | 23 | 	ret |
| 21 | #elif defined(_X86_) || defined(__i386__) | 24 | #elif defined(_X86_) || defined(__i386__) |
| ... | @@ -24,7 +27,4 @@ __MINGW_USYMBOL(mingw_getsp): | ... | @@ -24,7 +27,4 @@ __MINGW_USYMBOL(mingw_getsp): |
| 24 | #elif defined(_ARM_) || defined(__arm__) | 27 | #elif defined(_ARM_) || defined(__arm__) |
| 25 | 	mov	r0, sp | 28 | 	mov	r0, sp |
| 26 | 	bx	lr | 29 | 	bx	lr |
| 27 | #elif defined(_ARM64_) || defined(__aarch64__) | ||
| 28 | 	mov	x0, sp | ||
| 29 | 	ret | ||
| 30 | #endif | 30 | #endif |
lib/libc/mingw/misc/mingw_setfp.c created+373| ... | @@ -0,0 +1,373 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include "internal.h" | ||
| 8 | |||
| 9 | #if defined(__i386__) || defined(__x86_64__) | ||
| 10 | |||
| 11 | static unsigned int get_mxcsr(void) | ||
| 12 | { | ||
| 13 | unsigned int ret; | ||
| 14 | #ifdef __arm64ec__ | ||
| 15 | extern NTSTATUS (*__os_arm64x_get_x64_information)(ULONG,void*,void*); | ||
| 16 | __os_arm64x_get_x64_information( 0, &ret, NULL ); | ||
| 17 | #else | ||
| 18 | __asm__ __volatile__( "stmxcsr %0" : "=m" (ret) ); | ||
| 19 | #endif | ||
| 20 | return ret; | ||
| 21 | } | ||
| 22 | |||
| 23 | static void set_mxcsr( unsigned int val ) | ||
| 24 | { | ||
| 25 | #ifdef __arm64ec__ | ||
| 26 | extern NTSTATUS (*__os_arm64x_set_x64_information)(ULONG,ULONG_PTR,void*); | ||
| 27 | __os_arm64x_set_x64_information( 0, val, NULL ); | ||
| 28 | #else | ||
| 29 | __asm__ __volatile__( "ldmxcsr %0" : : "m" (val) ); | ||
| 30 | #endif | ||
| 31 | } | ||
| 32 | |||
| 33 | void __mingw_setfp_sse( unsigned int *cw, unsigned int cw_mask, unsigned int *sw, unsigned int sw_mask ) | ||
| 34 | { | ||
| 35 | unsigned int old_fpword, fpword = get_mxcsr(); | ||
| 36 | unsigned int flags; | ||
| 37 | |||
| 38 | old_fpword = fpword; | ||
| 39 | |||
| 40 | cw_mask &= _MCW_EM | _MCW_RC | _MCW_DN; | ||
| 41 | sw_mask &= _MCW_EM; | ||
| 42 | |||
| 43 | if (sw) | ||
| 44 | { | ||
| 45 | flags = 0; | ||
| 46 | if (fpword & 0x1) flags |= _SW_INVALID; | ||
| 47 | if (fpword & 0x2) flags |= _SW_DENORMAL; | ||
| 48 | if (fpword & 0x4) flags |= _SW_ZERODIVIDE; | ||
| 49 | if (fpword & 0x8) flags |= _SW_OVERFLOW; | ||
| 50 | if (fpword & 0x10) flags |= _SW_UNDERFLOW; | ||
| 51 | if (fpword & 0x20) flags |= _SW_INEXACT; | ||
| 52 | |||
| 53 | *sw = (flags & ~sw_mask) | (*sw & sw_mask); | ||
| 54 | fpword &= ~0x3f; | ||
| 55 | if (*sw & _SW_INVALID) fpword |= 0x1; | ||
| 56 | if (*sw & _SW_DENORMAL) fpword |= 0x2; | ||
| 57 | if (*sw & _SW_ZERODIVIDE) fpword |= 0x4; | ||
| 58 | if (*sw & _SW_OVERFLOW) fpword |= 0x8; | ||
| 59 | if (*sw & _SW_UNDERFLOW) fpword |= 0x10; | ||
| 60 | if (*sw & _SW_INEXACT) fpword |= 0x20; | ||
| 61 | *sw = flags; | ||
| 62 | } | ||
| 63 | |||
| 64 | if (cw) | ||
| 65 | { | ||
| 66 | flags = 0; | ||
| 67 | if (fpword & 0x80) flags |= _EM_INVALID; | ||
| 68 | if (fpword & 0x100) flags |= _EM_DENORMAL; | ||
| 69 | if (fpword & 0x200) flags |= _EM_ZERODIVIDE; | ||
| 70 | if (fpword & 0x400) flags |= _EM_OVERFLOW; | ||
| 71 | if (fpword & 0x800) flags |= _EM_UNDERFLOW; | ||
| 72 | if (fpword & 0x1000) flags |= _EM_INEXACT; | ||
| 73 | switch (fpword & 0x6000) | ||
| 74 | { | ||
| 75 | case 0x6000: flags |= _RC_UP|_RC_DOWN; break; | ||
| 76 | case 0x4000: flags |= _RC_UP; break; | ||
| 77 | case 0x2000: flags |= _RC_DOWN; break; | ||
| 78 | } | ||
| 79 | switch (fpword & 0x8040) | ||
| 80 | { | ||
| 81 | case 0x0040: flags |= _DN_FLUSH_OPERANDS_SAVE_RESULTS; break; | ||
| 82 | case 0x8000: flags |= _DN_SAVE_OPERANDS_FLUSH_RESULTS; break; | ||
| 83 | case 0x8040: flags |= _DN_FLUSH; break; | ||
| 84 | } | ||
| 85 | |||
| 86 | *cw = (flags & ~cw_mask) | (*cw & cw_mask); | ||
| 87 | fpword &= ~0xffc0; | ||
| 88 | if (*cw & _EM_INVALID) fpword |= 0x80; | ||
| 89 | if (*cw & _EM_DENORMAL) fpword |= 0x100; | ||
| 90 | if (*cw & _EM_ZERODIVIDE) fpword |= 0x200; | ||
| 91 | if (*cw & _EM_OVERFLOW) fpword |= 0x400; | ||
| 92 | if (*cw & _EM_UNDERFLOW) fpword |= 0x800; | ||
| 93 | if (*cw & _EM_INEXACT) fpword |= 0x1000; | ||
| 94 | switch (*cw & _MCW_RC) | ||
| 95 | { | ||
| 96 | case _RC_UP|_RC_DOWN: fpword |= 0x6000; break; | ||
| 97 | case _RC_UP: fpword |= 0x4000; break; | ||
| 98 | case _RC_DOWN: fpword |= 0x2000; break; | ||
| 99 | } | ||
| 100 | switch (*cw & _MCW_DN) | ||
| 101 | { | ||
| 102 | case _DN_FLUSH_OPERANDS_SAVE_RESULTS: fpword |= 0x0040; break; | ||
| 103 | case _DN_SAVE_OPERANDS_FLUSH_RESULTS: fpword |= 0x8000; break; | ||
| 104 | case _DN_FLUSH: fpword |= 0x8040; break; | ||
| 105 | } | ||
| 106 | |||
| 107 | /* clear status word if anything changes */ | ||
| 108 | if (fpword != old_fpword && !sw) fpword &= ~0x3f; | ||
| 109 | } | ||
| 110 | |||
| 111 | if (fpword != old_fpword) set_mxcsr( fpword ); | ||
| 112 | } | ||
| 113 | #endif | ||
| 114 | |||
| 115 | void __mingw_setfp( unsigned int *cw, unsigned int cw_mask, | ||
| 116 | unsigned int *sw, unsigned int sw_mask ) | ||
| 117 | { | ||
| 118 | #if defined(__arm64ec__) | ||
| 119 | __mingw_setfp_sse(cw, cw_mask, sw, sw_mask); | ||
| 120 | #elif defined(__i386__) || defined(__x86_64__) | ||
| 121 | unsigned long oldcw = 0, newcw = 0; | ||
| 122 | unsigned long oldsw = 0, newsw = 0; | ||
| 123 | unsigned int flags; | ||
| 124 | |||
| 125 | cw_mask &= _MCW_EM | _MCW_IC | _MCW_RC | _MCW_PC; | ||
| 126 | sw_mask &= _MCW_EM; | ||
| 127 | |||
| 128 | if (sw) | ||
| 129 | { | ||
| 130 | __asm__ __volatile__( "fstsw %0" : "=m" (newsw) ); | ||
| 131 | oldsw = newsw; | ||
| 132 | |||
| 133 | flags = 0; | ||
| 134 | if (newsw & 0x1) flags |= _SW_INVALID; | ||
| 135 | if (newsw & 0x2) flags |= _SW_DENORMAL; | ||
| 136 | if (newsw & 0x4) flags |= _SW_ZERODIVIDE; | ||
| 137 | if (newsw & 0x8) flags |= _SW_OVERFLOW; | ||
| 138 | if (newsw & 0x10) flags |= _SW_UNDERFLOW; | ||
| 139 | if (newsw & 0x20) flags |= _SW_INEXACT; | ||
| 140 | |||
| 141 | *sw = (flags & ~sw_mask) | (*sw & sw_mask); | ||
| 142 | newsw &= ~0x3f; | ||
| 143 | if (*sw & _SW_INVALID) newsw |= 0x1; | ||
| 144 | if (*sw & _SW_DENORMAL) newsw |= 0x2; | ||
| 145 | if (*sw & _SW_ZERODIVIDE) newsw |= 0x4; | ||
| 146 | if (*sw & _SW_OVERFLOW) newsw |= 0x8; | ||
| 147 | if (*sw & _SW_UNDERFLOW) newsw |= 0x10; | ||
| 148 | if (*sw & _SW_INEXACT) newsw |= 0x20; | ||
| 149 | *sw = flags; | ||
| 150 | } | ||
| 151 | |||
| 152 | if (cw) | ||
| 153 | { | ||
| 154 | __asm__ __volatile__( "fstcw %0" : "=m" (newcw) ); | ||
| 155 | oldcw = newcw; | ||
| 156 | |||
| 157 | flags = 0; | ||
| 158 | if (newcw & 0x1) flags |= _EM_INVALID; | ||
| 159 | if (newcw & 0x2) flags |= _EM_DENORMAL; | ||
| 160 | if (newcw & 0x4) flags |= _EM_ZERODIVIDE; | ||
| 161 | if (newcw & 0x8) flags |= _EM_OVERFLOW; | ||
| 162 | if (newcw & 0x10) flags |= _EM_UNDERFLOW; | ||
| 163 | if (newcw & 0x20) flags |= _EM_INEXACT; | ||
| 164 | switch (newcw & 0xc00) | ||
| 165 | { | ||
| 166 | case 0xc00: flags |= _RC_UP|_RC_DOWN; break; | ||
| 167 | case 0x800: flags |= _RC_UP; break; | ||
| 168 | case 0x400: flags |= _RC_DOWN; break; | ||
| 169 | } | ||
| 170 | switch (newcw & 0x300) | ||
| 171 | { | ||
| 172 | case 0x0: flags |= _PC_24; break; | ||
| 173 | case 0x200: flags |= _PC_53; break; | ||
| 174 | case 0x300: flags |= _PC_64; break; | ||
| 175 | } | ||
| 176 | if (newcw & 0x1000) flags |= _IC_AFFINE; | ||
| 177 | |||
| 178 | *cw = (flags & ~cw_mask) | (*cw & cw_mask); | ||
| 179 | newcw &= ~0x1f3f; | ||
| 180 | if (*cw & _EM_INVALID) newcw |= 0x1; | ||
| 181 | if (*cw & _EM_DENORMAL) newcw |= 0x2; | ||
| 182 | if (*cw & _EM_ZERODIVIDE) newcw |= 0x4; | ||
| 183 | if (*cw & _EM_OVERFLOW) newcw |= 0x8; | ||
| 184 | if (*cw & _EM_UNDERFLOW) newcw |= 0x10; | ||
| 185 | if (*cw & _EM_INEXACT) newcw |= 0x20; | ||
| 186 | switch (*cw & _MCW_RC) | ||
| 187 | { | ||
| 188 | case _RC_UP|_RC_DOWN: newcw |= 0xc00; break; | ||
| 189 | case _RC_UP: newcw |= 0x800; break; | ||
| 190 | case _RC_DOWN: newcw |= 0x400; break; | ||
| 191 | } | ||
| 192 | switch (*cw & _MCW_PC) | ||
| 193 | { | ||
| 194 | case _PC_64: newcw |= 0x300; break; | ||
| 195 | case _PC_53: newcw |= 0x200; break; | ||
| 196 | case _PC_24: newcw |= 0x0; break; | ||
| 197 | } | ||
| 198 | if (*cw & _IC_AFFINE) newcw |= 0x1000; | ||
| 199 | } | ||
| 200 | |||
| 201 | if (oldsw != newsw && (newsw & 0x3f)) | ||
| 202 | { | ||
| 203 | struct { | ||
| 204 | WORD control_word; | ||
| 205 | WORD unused1; | ||
| 206 | WORD status_word; | ||
| 207 | WORD unused2; | ||
| 208 | WORD tag_word; | ||
| 209 | WORD unused3; | ||
| 210 | DWORD instruction_pointer; | ||
| 211 | WORD code_segment; | ||
| 212 | WORD unused4; | ||
| 213 | DWORD operand_addr; | ||
| 214 | WORD data_segment; | ||
| 215 | WORD unused5; | ||
| 216 | } fenv; | ||
| 217 | |||
| 218 | __asm__ __volatile__( "fnstenv %0" : "=m" (fenv) ); | ||
| 219 | fenv.control_word = newcw; | ||
| 220 | fenv.status_word = newsw; | ||
| 221 | __asm__ __volatile__( "fldenv %0" : : "m" (fenv) : "st", "st(1)", | ||
| 222 | "st(2)", "st(3)", "st(4)", "st(5)", "st(6)", "st(7)" ); | ||
| 223 | return; | ||
| 224 | } | ||
| 225 | |||
| 226 | if (oldsw != newsw) | ||
| 227 | __asm__ __volatile__( "fnclex" ); | ||
| 228 | if (oldcw != newcw) | ||
| 229 | __asm__ __volatile__( "fldcw %0" : : "m" (newcw) ); | ||
| 230 | #elif defined(__aarch64__) | ||
| 231 | ULONG_PTR old_fpsr = 0, fpsr = 0, old_fpcr = 0, fpcr = 0; | ||
| 232 | unsigned int flags; | ||
| 233 | |||
| 234 | cw_mask &= _MCW_EM | _MCW_RC; | ||
| 235 | sw_mask &= _MCW_EM; | ||
| 236 | |||
| 237 | if (sw) | ||
| 238 | { | ||
| 239 | __asm__ __volatile__( "mrs %0, fpsr" : "=r" (fpsr) ); | ||
| 240 | old_fpsr = fpsr; | ||
| 241 | |||
| 242 | flags = 0; | ||
| 243 | if (fpsr & 0x1) flags |= _SW_INVALID; | ||
| 244 | if (fpsr & 0x2) flags |= _SW_ZERODIVIDE; | ||
| 245 | if (fpsr & 0x4) flags |= _SW_OVERFLOW; | ||
| 246 | if (fpsr & 0x8) flags |= _SW_UNDERFLOW; | ||
| 247 | if (fpsr & 0x10) flags |= _SW_INEXACT; | ||
| 248 | if (fpsr & 0x80) flags |= _SW_DENORMAL; | ||
| 249 | |||
| 250 | *sw = (flags & ~sw_mask) | (*sw & sw_mask); | ||
| 251 | fpsr &= ~0x9f; | ||
| 252 | if (*sw & _SW_INVALID) fpsr |= 0x1; | ||
| 253 | if (*sw & _SW_ZERODIVIDE) fpsr |= 0x2; | ||
| 254 | if (*sw & _SW_OVERFLOW) fpsr |= 0x4; | ||
| 255 | if (*sw & _SW_UNDERFLOW) fpsr |= 0x8; | ||
| 256 | if (*sw & _SW_INEXACT) fpsr |= 0x10; | ||
| 257 | if (*sw & _SW_DENORMAL) fpsr |= 0x80; | ||
| 258 | *sw = flags; | ||
| 259 | } | ||
| 260 | |||
| 261 | if (cw) | ||
| 262 | { | ||
| 263 | __asm__ __volatile__( "mrs %0, fpcr" : "=r" (fpcr) ); | ||
| 264 | old_fpcr = fpcr; | ||
| 265 | |||
| 266 | flags = 0; | ||
| 267 | if (!(fpcr & 0x100)) flags |= _EM_INVALID; | ||
| 268 | if (!(fpcr & 0x200)) flags |= _EM_ZERODIVIDE; | ||
| 269 | if (!(fpcr & 0x400)) flags |= _EM_OVERFLOW; | ||
| 270 | if (!(fpcr & 0x800)) flags |= _EM_UNDERFLOW; | ||
| 271 | if (!(fpcr & 0x1000)) flags |= _EM_INEXACT; | ||
| 272 | if (!(fpcr & 0x8000)) flags |= _EM_DENORMAL; | ||
| 273 | switch (fpcr & 0xc00000) | ||
| 274 | { | ||
| 275 | case 0x400000: flags |= _RC_UP; break; | ||
| 276 | case 0x800000: flags |= _RC_DOWN; break; | ||
| 277 | case 0xc00000: flags |= _RC_CHOP; break; | ||
| 278 | } | ||
| 279 | |||
| 280 | *cw = (flags & ~cw_mask) | (*cw & cw_mask); | ||
| 281 | fpcr &= ~0xc09f00ul; | ||
| 282 | if (!(*cw & _EM_INVALID)) fpcr |= 0x100; | ||
| 283 | if (!(*cw & _EM_ZERODIVIDE)) fpcr |= 0x200; | ||
| 284 | if (!(*cw & _EM_OVERFLOW)) fpcr |= 0x400; | ||
| 285 | if (!(*cw & _EM_UNDERFLOW)) fpcr |= 0x800; | ||
| 286 | if (!(*cw & _EM_INEXACT)) fpcr |= 0x1000; | ||
| 287 | if (!(*cw & _EM_DENORMAL)) fpcr |= 0x8000; | ||
| 288 | switch (*cw & _MCW_RC) | ||
| 289 | { | ||
| 290 | case _RC_CHOP: fpcr |= 0xc00000; break; | ||
| 291 | case _RC_UP: fpcr |= 0x400000; break; | ||
| 292 | case _RC_DOWN: fpcr |= 0x800000; break; | ||
| 293 | } | ||
| 294 | } | ||
| 295 | |||
| 296 | /* mask exceptions if needed */ | ||
| 297 | if (old_fpcr != fpcr && ~(old_fpcr >> 8) & fpsr & 0x9f != fpsr & 0x9f) | ||
| 298 | { | ||
| 299 | ULONG_PTR mask = fpcr & ~0x9f00; | ||
| 300 | __asm__ __volatile__( "msr fpcr, %0" :: "r" (mask) ); | ||
| 301 | } | ||
| 302 | |||
| 303 | if (old_fpsr != fpsr) | ||
| 304 | __asm__ __volatile__( "msr fpsr, %0" :: "r" (fpsr) ); | ||
| 305 | if (old_fpcr != fpcr) | ||
| 306 | __asm__ __volatile__( "msr fpcr, %0" :: "r" (fpcr) ); | ||
| 307 | #elif defined(__arm__) | ||
| 308 | DWORD old_fpscr, fpscr; | ||
| 309 | unsigned int flags; | ||
| 310 | |||
| 311 | __asm__ __volatile__( "vmrs %0, fpscr" : "=r" (fpscr) ); | ||
| 312 | old_fpscr = fpscr; | ||
| 313 | |||
| 314 | cw_mask &= _MCW_EM | _MCW_RC; | ||
| 315 | sw_mask &= _MCW_EM; | ||
| 316 | |||
| 317 | if (sw) | ||
| 318 | { | ||
| 319 | flags = 0; | ||
| 320 | if (fpscr & 0x1) flags |= _SW_INVALID; | ||
| 321 | if (fpscr & 0x2) flags |= _SW_ZERODIVIDE; | ||
| 322 | if (fpscr & 0x4) flags |= _SW_OVERFLOW; | ||
| 323 | if (fpscr & 0x8) flags |= _SW_UNDERFLOW; | ||
| 324 | if (fpscr & 0x10) flags |= _SW_INEXACT; | ||
| 325 | if (fpscr & 0x80) flags |= _SW_DENORMAL; | ||
| 326 | |||
| 327 | *sw = (flags & ~sw_mask) | (*sw & sw_mask); | ||
| 328 | fpscr &= ~0x9f; | ||
| 329 | if (*sw & _SW_INVALID) fpscr |= 0x1; | ||
| 330 | if (*sw & _SW_ZERODIVIDE) fpscr |= 0x2; | ||
| 331 | if (*sw & _SW_OVERFLOW) fpscr |= 0x4; | ||
| 332 | if (*sw & _SW_UNDERFLOW) fpscr |= 0x8; | ||
| 333 | if (*sw & _SW_INEXACT) fpscr |= 0x10; | ||
| 334 | if (*sw & _SW_DENORMAL) fpscr |= 0x80; | ||
| 335 | *sw = flags; | ||
| 336 | } | ||
| 337 | |||
| 338 | if (cw) | ||
| 339 | { | ||
| 340 | flags = 0; | ||
| 341 | if (!(fpscr & 0x100)) flags |= _EM_INVALID; | ||
| 342 | if (!(fpscr & 0x200)) flags |= _EM_ZERODIVIDE; | ||
| 343 | if (!(fpscr & 0x400)) flags |= _EM_OVERFLOW; | ||
| 344 | if (!(fpscr & 0x800)) flags |= _EM_UNDERFLOW; | ||
| 345 | if (!(fpscr & 0x1000)) flags |= _EM_INEXACT; | ||
| 346 | if (!(fpscr & 0x8000)) flags |= _EM_DENORMAL; | ||
| 347 | switch (fpscr & 0xc00000) | ||
| 348 | { | ||
| 349 | case 0x400000: flags |= _RC_UP; break; | ||
| 350 | case 0x800000: flags |= _RC_DOWN; break; | ||
| 351 | case 0xc00000: flags |= _RC_CHOP; break; | ||
| 352 | } | ||
| 353 | |||
| 354 | *cw = (flags & ~cw_mask) | (*cw & cw_mask); | ||
| 355 | fpscr &= ~0xc09f00ul; | ||
| 356 | if (!(*cw & _EM_INVALID)) fpscr |= 0x100; | ||
| 357 | if (!(*cw & _EM_ZERODIVIDE)) fpscr |= 0x200; | ||
| 358 | if (!(*cw & _EM_OVERFLOW)) fpscr |= 0x400; | ||
| 359 | if (!(*cw & _EM_UNDERFLOW)) fpscr |= 0x800; | ||
| 360 | if (!(*cw & _EM_INEXACT)) fpscr |= 0x1000; | ||
| 361 | if (!(*cw & _EM_DENORMAL)) fpscr |= 0x8000; | ||
| 362 | switch (*cw & _MCW_RC) | ||
| 363 | { | ||
| 364 | case _RC_CHOP: fpscr |= 0xc00000; break; | ||
| 365 | case _RC_UP: fpscr |= 0x400000; break; | ||
| 366 | case _RC_DOWN: fpscr |= 0x800000; break; | ||
| 367 | } | ||
| 368 | } | ||
| 369 | |||
| 370 | if (old_fpscr != fpscr) | ||
| 371 | __asm__ __volatile__( "vmsr fpscr, %0" :: "r" (fpscr) ); | ||
| 372 | #endif | ||
| 373 | } | ||
lib/libc/mingw/misc/setjmp.S+2| ... | @@ -6,6 +6,7 @@ | ... | @@ -6,6 +6,7 @@ |
| 6 | 6 | ||
| 7 | #include <_mingw_mac.h> | 7 | #include <_mingw_mac.h> |
| 8 | 8 | ||
| 9 | #ifndef __arm64ec__ | ||
| 9 | .globl __MINGW_USYMBOL(__intrinsic_setjmp) | 10 | .globl __MINGW_USYMBOL(__intrinsic_setjmp) |
| 10 | .def __MINGW_USYMBOL(__intrinsic_setjmp); .scl 2; .type 32; .endef | 11 | .def __MINGW_USYMBOL(__intrinsic_setjmp); .scl 2; .type 32; .endef |
| 11 | 12 | ||
| ... | @@ -115,3 +116,4 @@ __MINGW_USYMBOL(__intrinsic_setjmpex): | ... | @@ -115,3 +116,4 @@ __MINGW_USYMBOL(__intrinsic_setjmpex): |
| 115 | mov x0, #0 | 116 | mov x0, #0 |
| 116 | ret | 117 | ret |
| 117 | #endif | 118 | #endif |
| 119 | #endif /* __arm64ec__ */ |
lib/libc/mingw/misc/ucrt_tzset.c-3| ... | @@ -40,6 +40,3 @@ void __cdecl tzset(void) | ... | @@ -40,6 +40,3 @@ void __cdecl tzset(void) |
| 40 | { | 40 | { |
| 41 | _tzset(); | 41 | _tzset(); |
| 42 | } | 42 | } |
| 43 | |||
| 44 | // Dummy/unused __imp_ wrappers, to make GNU ld not autoexport these symbols. | ||
| 45 | void __cdecl (*__MINGW_IMP_SYMBOL(tzset))(void) = tzset; |
lib/libc/mingw/misc/winbs_uint64.c+1-34| ... | @@ -2,38 +2,5 @@ unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64); | ... | @@ -2,38 +2,5 @@ unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64); |
| 2 | 2 | ||
| 3 | unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64) | 3 | unsigned long long __cdecl _byteswap_uint64(unsigned long long _Int64) |
| 4 | { | 4 | { |
| 5 | #if defined(_AMD64_) || defined(__x86_64__) | 5 | return __builtin_bswap64(_Int64); |
| 6 | unsigned long long retval; | ||
| 7 | __asm__ __volatile__ ("bswapq %[retval]" : [retval] "=rm" (retval) : "[retval]" (_Int64)); | ||
| 8 | return retval; | ||
| 9 | #elif defined(_X86_) || defined(__i386__) | ||
| 10 | union { | ||
| 11 | long long int64part; | ||
| 12 | struct { | ||
| 13 | unsigned long lowpart; | ||
| 14 | unsigned long hipart; | ||
| 15 | }; | ||
| 16 | } retval; | ||
| 17 | retval.int64part = _Int64; | ||
| 18 | __asm__ __volatile__ ("bswapl %[lowpart]\n" | ||
| 19 | "bswapl %[hipart]\n" | ||
| 20 | : [lowpart] "=rm" (retval.hipart), [hipart] "=rm" (retval.lowpart) : "[lowpart]" (retval.lowpart), "[hipart]" (retval.hipart)); | ||
| 21 | return retval.int64part; | ||
| 22 | #else | ||
| 23 | unsigned char *b = (void*)&_Int64; | ||
| 24 | unsigned char tmp; | ||
| 25 | tmp = b[0]; | ||
| 26 | b[0] = b[7]; | ||
| 27 | b[7] = tmp; | ||
| 28 | tmp = b[1]; | ||
| 29 | b[1] = b[6]; | ||
| 30 | b[6] = tmp; | ||
| 31 | tmp = b[2]; | ||
| 32 | b[2] = b[5]; | ||
| 33 | b[5] = tmp; | ||
| 34 | tmp = b[3]; | ||
| 35 | b[3] = b[4]; | ||
| 36 | b[4] = tmp; | ||
| 37 | return _Int64; | ||
| 38 | #endif | ||
| 39 | } | 6 | } |
lib/libc/mingw/misc/winbs_ulong.c+1-15| ... | @@ -2,19 +2,5 @@ unsigned long __cdecl _byteswap_ulong (unsigned long _Long); | ... | @@ -2,19 +2,5 @@ unsigned long __cdecl _byteswap_ulong (unsigned long _Long); |
| 2 | 2 | ||
| 3 | unsigned long __cdecl _byteswap_ulong (unsigned long _Long) | 3 | unsigned long __cdecl _byteswap_ulong (unsigned long _Long) |
| 4 | { | 4 | { |
| 5 | #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | 5 | return __builtin_bswap32(_Long); |
| 6 | unsigned long retval; | ||
| 7 | __asm__ __volatile__ ("bswapl %[retval]" : [retval] "=rm" (retval) : "[retval]" (_Long)); | ||
| 8 | return retval; | ||
| 9 | #else | ||
| 10 | unsigned char *b = (void*)&_Long; | ||
| 11 | unsigned char tmp; | ||
| 12 | tmp = b[0]; | ||
| 13 | b[0] = b[3]; | ||
| 14 | b[3] = tmp; | ||
| 15 | tmp = b[1]; | ||
| 16 | b[1] = b[2]; | ||
| 17 | b[2] = tmp; | ||
| 18 | return _Long; | ||
| 19 | #endif /* defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) */ | ||
| 20 | } | 6 | } |
lib/libc/mingw/misc/winbs_ushort.c+1-12| ... | @@ -2,16 +2,5 @@ unsigned short __cdecl _byteswap_ushort(unsigned short _Short); | ... | @@ -2,16 +2,5 @@ unsigned short __cdecl _byteswap_ushort(unsigned short _Short); |
| 2 | 2 | ||
| 3 | unsigned short __cdecl _byteswap_ushort(unsigned short _Short) | 3 | unsigned short __cdecl _byteswap_ushort(unsigned short _Short) |
| 4 | { | 4 | { |
| 5 | #if defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) | 5 | return __builtin_bswap16(_Short); |
| 6 | unsigned short retval; | ||
| 7 | __asm__ __volatile__ ("rorw $8, %w[retval]" : [retval] "=rm" (retval) : "[retval]" (_Short)); | ||
| 8 | return retval; | ||
| 9 | #else | ||
| 10 | unsigned char *b = (void*)&_Short; | ||
| 11 | unsigned char tmp; | ||
| 12 | tmp = b[0]; | ||
| 13 | b[0] = b[1]; | ||
| 14 | b[1] = tmp; | ||
| 15 | return _Short; | ||
| 16 | #endif /* defined(_AMD64_) || defined(__x86_64__) || defined(_X86_) || defined(__i386__) */ | ||
| 17 | } | 6 | } |
lib/libc/mingw/stdio/__mingw_fix_stat_path.c created+64| ... | @@ -0,0 +1,64 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <sys/stat.h> | ||
| 8 | #include <stdlib.h> | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Returns _path without trailing slash if any | ||
| 12 | * | ||
| 13 | * - if _path has no trailing slash, the function returns it | ||
| 14 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 15 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 16 | * without the trailing slash. It is then the responsibility of the caller | ||
| 17 | * to free it. | ||
| 18 | */ | ||
| 19 | |||
| 20 | char* __mingw_fix_stat_path (const char* _path); | ||
| 21 | char* __mingw_fix_stat_path (const char* _path) | ||
| 22 | { | ||
| 23 | int len; | ||
| 24 | char *p; | ||
| 25 | |||
| 26 | p = (char*)_path; | ||
| 27 | |||
| 28 | if (_path && *_path) { | ||
| 29 | len = strlen (_path); | ||
| 30 | |||
| 31 | /* Ignore X:\ */ | ||
| 32 | |||
| 33 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':')) | ||
| 34 | return p; | ||
| 35 | |||
| 36 | /* Check UNC \\abc\<name>\ */ | ||
| 37 | if ((_path[0] == '\\' || _path[0] == '/') | ||
| 38 | 	&& (_path[1] == '\\' || _path[1] == '/')) | ||
| 39 | { | ||
| 40 | 	const char *r = &_path[2]; | ||
| 41 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 42 | 	 ++r; | ||
| 43 | 	if (*r != 0) | ||
| 44 | 	 ++r; | ||
| 45 | 	if (*r == 0) | ||
| 46 | 	 return p; | ||
| 47 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 48 | 	 ++r; | ||
| 49 | 	if (*r != 0) | ||
| 50 | 	 ++r; | ||
| 51 | 	if (*r == 0) | ||
| 52 | 	 return p; | ||
| 53 | } | ||
| 54 | |||
| 55 | if (_path[len - 1] == '/' || _path[len - 1] == '\\') | ||
| 56 | { | ||
| 57 | 	p = (char*)malloc (len); | ||
| 58 | 	memcpy (p, _path, len - 1); | ||
| 59 | 	p[len - 1] = '\0'; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | return p; | ||
| 64 | } | ||
lib/libc/mingw/stdio/__mingw_fix_wstat_path.c created+64| ... | @@ -0,0 +1,64 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #include <sys/stat.h> | ||
| 8 | #include <stdlib.h> | ||
| 9 | |||
| 10 | /** | ||
| 11 | * Returns _path without trailing slash if any | ||
| 12 | * | ||
| 13 | * - if _path has no trailing slash, the function returns it | ||
| 14 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 15 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 16 | * without the trailing slash. It is then the responsibility of the caller | ||
| 17 | * to free it. | ||
| 18 | */ | ||
| 19 | |||
| 20 | wchar_t* __mingw_fix_wstat_path (const wchar_t* _path); | ||
| 21 | wchar_t* __mingw_fix_wstat_path (const wchar_t* _path) | ||
| 22 | { | ||
| 23 | int len; | ||
| 24 | wchar_t *p; | ||
| 25 | |||
| 26 | p = (wchar_t*)_path; | ||
| 27 | |||
| 28 | if (_path && *_path) { | ||
| 29 | len = wcslen (_path); | ||
| 30 | |||
| 31 | /* Ignore X:\ */ | ||
| 32 | |||
| 33 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':')) | ||
| 34 | return p; | ||
| 35 | |||
| 36 | /* Check UNC \\abc\<name>\ */ | ||
| 37 | if ((_path[0] == L'\\' || _path[0] == L'/') | ||
| 38 | 	&& (_path[1] == L'\\' || _path[1] == L'/')) | ||
| 39 | { | ||
| 40 | 	const wchar_t *r = &_path[2]; | ||
| 41 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 42 | 	 ++r; | ||
| 43 | 	if (*r != 0) | ||
| 44 | 	 ++r; | ||
| 45 | 	if (*r == 0) | ||
| 46 | 	 return p; | ||
| 47 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 48 | 	 ++r; | ||
| 49 | 	if (*r != 0) | ||
| 50 | 	 ++r; | ||
| 51 | 	if (*r == 0) | ||
| 52 | 	 return p; | ||
| 53 | } | ||
| 54 | |||
| 55 | if (_path[len - 1] == L'/' || _path[len - 1] == L'\\') | ||
| 56 | { | ||
| 57 | 	p = (wchar_t*)malloc (len * sizeof(wchar_t)); | ||
| 58 | 	memcpy (p, _path, (len - 1) * sizeof(wchar_t)); | ||
| 59 | 	p[len - 1] = L'\0'; | ||
| 60 | } | ||
| 61 | } | ||
| 62 | |||
| 63 | return p; | ||
| 64 | } | ||
lib/libc/mingw/stdio/_findfirst64i32.c+1-1| ... | @@ -7,7 +7,7 @@ intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t * | ... | @@ -7,7 +7,7 @@ intptr_t __cdecl _findfirst64i32(const char *_Filename,struct _finddata64i32_t * |
| 7 | struct __finddata64_t fd; | 7 | struct __finddata64_t fd; |
| 8 | intptr_t ret = _findfirst64(_Filename,&fd); | 8 | intptr_t ret = _findfirst64(_Filename,&fd); |
| 9 | if (ret == -1) { | 9 | if (ret == -1) { |
| 10 | memset(_FindData,0,sizeof(struct _finddata64i32_t)); | 10 | *_FindData = (struct _finddata64i32_t){0}; |
| 11 | return -1; | 11 | return -1; |
| 12 | } | 12 | } |
| 13 | _FindData->attrib=fd.attrib; | 13 | _FindData->attrib=fd.attrib; |
lib/libc/mingw/stdio/_findnext64i32.c+1-1| ... | @@ -7,7 +7,7 @@ int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindDa | ... | @@ -7,7 +7,7 @@ int __cdecl _findnext64i32(intptr_t _FindHandle,struct _finddata64i32_t *_FindDa |
| 7 | struct __finddata64_t fd; | 7 | struct __finddata64_t fd; |
| 8 | int ret = _findnext64(_FindHandle,&fd); | 8 | int ret = _findnext64(_FindHandle,&fd); |
| 9 | if (ret == -1) { | 9 | if (ret == -1) { |
| 10 | memset(_FindData,0,sizeof(struct _finddata64i32_t)); | 10 | *_FindData = (struct _finddata64i32_t){0}; |
| 11 | return -1; | 11 | return -1; |
| 12 | } | 12 | } |
| 13 | _FindData->attrib=fd.attrib; | 13 | _FindData->attrib=fd.attrib; |
lib/libc/mingw/stdio/_fstat64i32.c+20-8| ... | @@ -1,14 +1,26 @@ | ... | @@ -1,14 +1,26 @@ |
| 1 | #define __CRT__NO_INLINE | 1 | /** |
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 2 | #include <sys/stat.h> | 7 | #include <sys/stat.h> |
| 3 | 8 | ||
| 9 | /* When the file size does not fit into the st_size field: | ||
| 10 | * crtdll-msvcr90 msvcr100 msvcr110+ | ||
| 11 | * st_size truncate 0 0 | ||
| 12 | * errno no change no change EOVERFLOW | ||
| 13 | * returns 0 -1 -1 | ||
| 14 | * | ||
| 15 | * This file is used only for pre-msvcr80 builds, | ||
| 16 | * So use the pre-msvcr80 behavior - truncate without error. | ||
| 17 | */ | ||
| 4 | int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat) | 18 | int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat) |
| 5 | { | 19 | { |
| 6 | struct _stat64 st; | 20 | struct _stat64 st; |
| 7 | int ret=_fstat64(_FileDes,&st); | 21 | int ret=_fstat64(_FileDes,&st); |
| 8 | if (ret == -1) { | 22 | if (ret != 0) |
| 9 | memset(_Stat,0,sizeof(struct _stat64i32)); | 23 | return ret; |
| 10 | return -1; | ||
| 11 | } | ||
| 12 | _Stat->st_dev=st.st_dev; | 24 | _Stat->st_dev=st.st_dev; |
| 13 | _Stat->st_ino=st.st_ino; | 25 | _Stat->st_ino=st.st_ino; |
| 14 | _Stat->st_mode=st.st_mode; | 26 | _Stat->st_mode=st.st_mode; |
| ... | @@ -16,10 +28,10 @@ int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat) | ... | @@ -16,10 +28,10 @@ int __cdecl _fstat64i32(int _FileDes,struct _stat64i32 *_Stat) |
| 16 | _Stat->st_uid=st.st_uid; | 28 | _Stat->st_uid=st.st_uid; |
| 17 | _Stat->st_gid=st.st_gid; | 29 | _Stat->st_gid=st.st_gid; |
| 18 | _Stat->st_rdev=st.st_rdev; | 30 | _Stat->st_rdev=st.st_rdev; |
| 19 | _Stat->st_size=(_off_t) st.st_size; /* 32bit size */ | 31 | _Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */ |
| 20 | _Stat->st_atime=st.st_atime; | 32 | _Stat->st_atime=st.st_atime; |
| 21 | _Stat->st_mtime=st.st_mtime; | 33 | _Stat->st_mtime=st.st_mtime; |
| 22 | _Stat->st_ctime=st.st_ctime; | 34 | _Stat->st_ctime=st.st_ctime; |
| 23 | return ret; | 35 | return 0; |
| 24 | } | 36 | } |
| 25 | 37 | int (__cdecl *__MINGW_IMP_SYMBOL(_fstat64i32))(int, struct _stat64i32 *) = _fstat64i32; |
lib/libc/mingw/stdio/_stat.c deleted-120| ... | @@ -1,120 +0,0 @@ | ||
| 1 | #define __CRT__NO_INLINE | ||
| 2 | #include <sys/stat.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | |||
| 5 | /** | ||
| 6 | * Returns _path without trailing slash if any | ||
| 7 | * | ||
| 8 | * - if _path has no trailing slash, the function returns it | ||
| 9 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 10 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 11 | * without the trailing slash. It is then the responsibility of the caller | ||
| 12 | * to free it. | ||
| 13 | */ | ||
| 14 | |||
| 15 | static char* | ||
| 16 | _mingw_no_trailing_slash (const char* _path) | ||
| 17 | { | ||
| 18 | int len; | ||
| 19 | char *p; | ||
| 20 | |||
| 21 | p = (char*)_path; | ||
| 22 | |||
| 23 | if (_path && *_path) { | ||
| 24 | len = strlen (_path); | ||
| 25 | |||
| 26 | /* Ignore X:\ */ | ||
| 27 | |||
| 28 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':')) | ||
| 29 | return p; | ||
| 30 | |||
| 31 | /* Check UNC \\abc\<name>\ */ | ||
| 32 | if ((_path[0] == '\\' || _path[0] == '/') | ||
| 33 | 	&& (_path[1] == '\\' || _path[1] == '/')) | ||
| 34 | { | ||
| 35 | 	const char *r = &_path[2]; | ||
| 36 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 37 | 	 ++r; | ||
| 38 | 	if (*r != 0) | ||
| 39 | 	 ++r; | ||
| 40 | 	if (*r == 0) | ||
| 41 | 	 return p; | ||
| 42 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 43 | 	 ++r; | ||
| 44 | 	if (*r != 0) | ||
| 45 | 	 ++r; | ||
| 46 | 	if (*r == 0) | ||
| 47 | 	 return p; | ||
| 48 | } | ||
| 49 | |||
| 50 | if (_path[len - 1] == '/' || _path[len - 1] == '\\') | ||
| 51 | { | ||
| 52 | 	p = (char*)malloc (len); | ||
| 53 | 	memcpy (p, _path, len - 1); | ||
| 54 | 	p[len - 1] = '\0'; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | return p; | ||
| 59 | } | ||
| 60 | /* FIXME: Relying on _USE_32BIT_TIME_T, which is a user-macro, | ||
| 61 | during CRT compilation is plainly broken. Need an appropriate | ||
| 62 | implementation to provide users the ability of compiling the | ||
| 63 | CRT only with 32-bit time_t behavior. */ | ||
| 64 | #if defined(_USE_32BIT_TIME_T) | ||
| 65 | int __cdecl | ||
| 66 | stat(const char *_Filename,struct stat *_Stat) | ||
| 67 | { | ||
| 68 | struct _stat32 st; | ||
| 69 | char *_path = _mingw_no_trailing_slash(_Filename); | ||
| 70 | |||
| 71 | int ret=_stat32(_path,&st); | ||
| 72 | |||
| 73 | if (_path != _Filename) | ||
| 74 | free (_path); | ||
| 75 | |||
| 76 | if (ret == -1) { | ||
| 77 | memset(_Stat,0,sizeof(struct stat)); | ||
| 78 | return -1; | ||
| 79 | } | ||
| 80 | /* struct stat and struct _stat32 | ||
| 81 | are the same for this case. */ | ||
| 82 | memcpy(_Stat, &st, sizeof(struct _stat32)); | ||
| 83 | return ret; | ||
| 84 | } | ||
| 85 | #else | ||
| 86 | int __cdecl | ||
| 87 | stat(const char *_Filename,struct stat *_Stat) | ||
| 88 | { | ||
| 89 | struct _stat64 st; | ||
| 90 | char *_path = _mingw_no_trailing_slash(_Filename); | ||
| 91 | |||
| 92 | int ret=_stat64(_path,&st); | ||
| 93 | |||
| 94 | if (_path != _Filename) | ||
| 95 | free (_path); | ||
| 96 | |||
| 97 | if (ret == -1) { | ||
| 98 | memset(_Stat,0,sizeof(struct stat)); | ||
| 99 | return -1; | ||
| 100 | } | ||
| 101 | /* struct stat and struct _stat64i32 | ||
| 102 | are the same for this case. */ | ||
| 103 | _Stat->st_dev=st.st_dev; | ||
| 104 | _Stat->st_ino=st.st_ino; | ||
| 105 | _Stat->st_mode=st.st_mode; | ||
| 106 | _Stat->st_nlink=st.st_nlink; | ||
| 107 | _Stat->st_uid=st.st_uid; | ||
| 108 | _Stat->st_gid=st.st_gid; | ||
| 109 | _Stat->st_rdev=st.st_rdev; | ||
| 110 | _Stat->st_size=(_off_t) st.st_size; | ||
| 111 | _Stat->st_atime=st.st_atime; | ||
| 112 | _Stat->st_mtime=st.st_mtime; | ||
| 113 | _Stat->st_ctime=st.st_ctime; | ||
| 114 | return ret; | ||
| 115 | } | ||
| 116 | #endif | ||
| 117 | |||
| 118 | /* Add __imp__fstat and __imp__stat symbols. */ | ||
| 119 | int (*__MINGW_IMP_SYMBOL(stat))(const char *,struct stat *) = &stat; | ||
| 120 | |||
lib/libc/mingw/stdio/_stat64i32.c+19-70| ... | @@ -1,77 +1,26 @@ | ... | @@ -1,77 +1,26 @@ |
| 1 | #define __CRT__NO_INLINE | ||
| 2 | #include <sys/stat.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | |||
| 5 | /** | 1 | /** |
| 6 | * Returns _path without trailing slash if any | 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 7 | * | 3 | * This file is part of the mingw-w64 runtime package. |
| 8 | * - if _path has no trailing slash, the function returns it | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 9 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 10 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 11 | * without the trailing slash. It is then the responsibility of the caller | ||
| 12 | * to free it. | ||
| 13 | */ | 5 | */ |
| 14 | 6 | ||
| 15 | static char* | 7 | #include <sys/stat.h> |
| 16 | _mingw_no_trailing_slash (const char* _path) | ||
| 17 | { | ||
| 18 | int len; | ||
| 19 | char *p; | ||
| 20 | |||
| 21 | p = (char*)_path; | ||
| 22 | |||
| 23 | if (_path && *_path) { | ||
| 24 | len = strlen (_path); | ||
| 25 | |||
| 26 | /* Ignore X:\ */ | ||
| 27 | |||
| 28 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == ':')) | ||
| 29 | return p; | ||
| 30 | |||
| 31 | /* Check UNC \\abc\<name>\ */ | ||
| 32 | if ((_path[0] == '\\' || _path[0] == '/') | ||
| 33 | 	&& (_path[1] == '\\' || _path[1] == '/')) | ||
| 34 | { | ||
| 35 | 	const char *r = &_path[2]; | ||
| 36 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 37 | 	 ++r; | ||
| 38 | 	if (*r != 0) | ||
| 39 | 	 ++r; | ||
| 40 | 	if (*r == 0) | ||
| 41 | 	 return p; | ||
| 42 | 	while (*r != 0 && *r != '\\' && *r != '/') | ||
| 43 | 	 ++r; | ||
| 44 | 	if (*r != 0) | ||
| 45 | 	 ++r; | ||
| 46 | 	if (*r == 0) | ||
| 47 | 	 return p; | ||
| 48 | } | ||
| 49 | |||
| 50 | if (_path[len - 1] == '/' || _path[len - 1] == '\\') | ||
| 51 | { | ||
| 52 | 	p = (char*)malloc (len); | ||
| 53 | 	memcpy (p, _path, len - 1); | ||
| 54 | 	p[len - 1] = '\0'; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | return p; | ||
| 59 | } | ||
| 60 | 8 | ||
| 9 | /* When the file size does not fit into the st_size field: | ||
| 10 | * crtdll-msvcr90 msvcr100 msvcr110+ | ||
| 11 | * st_size truncate 0 0 | ||
| 12 | * errno no change no change EOVERFLOW | ||
| 13 | * returns 0 -1 -1 | ||
| 14 | * | ||
| 15 | * This file is used only for pre-msvcr80 builds, | ||
| 16 | * So use the pre-msvcr80 behavior - truncate without error. | ||
| 17 | */ | ||
| 61 | int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat) | 18 | int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat) |
| 62 | { | 19 | { |
| 63 | struct _stat64 st; | 20 | struct _stat64 st; |
| 64 | char *_path = _mingw_no_trailing_slash(_Name); | 21 | int ret=_stat64(_Name,&st); |
| 65 | 22 | if (ret != 0) | |
| 66 | int ret=_stat64(_path,&st); | 23 | return ret; |
| 67 | |||
| 68 | if (_path != _Name) | ||
| 69 | free(_path); | ||
| 70 | |||
| 71 | if (ret == -1) { | ||
| 72 | memset(_Stat,0,sizeof(struct _stat64i32)); | ||
| 73 | return -1; | ||
| 74 | } | ||
| 75 | _Stat->st_dev=st.st_dev; | 24 | _Stat->st_dev=st.st_dev; |
| 76 | _Stat->st_ino=st.st_ino; | 25 | _Stat->st_ino=st.st_ino; |
| 77 | _Stat->st_mode=st.st_mode; | 26 | _Stat->st_mode=st.st_mode; |
| ... | @@ -79,10 +28,10 @@ int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat) | ... | @@ -79,10 +28,10 @@ int __cdecl _stat64i32(const char *_Name,struct _stat64i32 *_Stat) |
| 79 | _Stat->st_uid=st.st_uid; | 28 | _Stat->st_uid=st.st_uid; |
| 80 | _Stat->st_gid=st.st_gid; | 29 | _Stat->st_gid=st.st_gid; |
| 81 | _Stat->st_rdev=st.st_rdev; | 30 | _Stat->st_rdev=st.st_rdev; |
| 82 | _Stat->st_size=(_off_t) st.st_size; | 31 | _Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */ |
| 83 | _Stat->st_atime=st.st_atime; | 32 | _Stat->st_atime=st.st_atime; |
| 84 | _Stat->st_mtime=st.st_mtime; | 33 | _Stat->st_mtime=st.st_mtime; |
| 85 | _Stat->st_ctime=st.st_ctime; | 34 | _Stat->st_ctime=st.st_ctime; |
| 86 | return ret; | 35 | return 0; |
| 87 | } | 36 | } |
| 88 | 37 | int (__cdecl *__MINGW_IMP_SYMBOL(_stat64i32))(const char *, struct _stat64i32 *) = _stat64i32; |
lib/libc/mingw/stdio/_wfindfirst64i32.c+1-1| ... | @@ -7,7 +7,7 @@ intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i3 | ... | @@ -7,7 +7,7 @@ intptr_t __cdecl _wfindfirst64i32(const wchar_t *_Filename,struct _wfinddata64i3 |
| 7 | struct _wfinddata64_t fd; | 7 | struct _wfinddata64_t fd; |
| 8 | intptr_t ret = _wfindfirst64(_Filename,&fd); | 8 | intptr_t ret = _wfindfirst64(_Filename,&fd); |
| 9 | if (ret == -1) { | 9 | if (ret == -1) { |
| 10 | memset(_FindData,0,sizeof(struct _wfinddata64i32_t)); | 10 | *_FindData = (struct _wfinddata64i32_t){0}; |
| 11 | return -1; | 11 | return -1; |
| 12 | } | 12 | } |
| 13 | _FindData->attrib=fd.attrib; | 13 | _FindData->attrib=fd.attrib; |
lib/libc/mingw/stdio/_wfindnext64i32.c+1-1| ... | @@ -7,7 +7,7 @@ int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_Find | ... | @@ -7,7 +7,7 @@ int __cdecl _wfindnext64i32(intptr_t _FindHandle,struct _wfinddata64i32_t *_Find |
| 7 | struct _wfinddata64_t fd; | 7 | struct _wfinddata64_t fd; |
| 8 | int ret = _wfindnext64(_FindHandle,&fd); | 8 | int ret = _wfindnext64(_FindHandle,&fd); |
| 9 | if (ret == -1) { | 9 | if (ret == -1) { |
| 10 | memset(_FindData,0,sizeof(struct _wfinddata64i32_t)); | 10 | *_FindData = (struct _wfinddata64i32_t){0}; |
| 11 | return -1; | 11 | return -1; |
| 12 | } | 12 | } |
| 13 | _FindData->attrib=fd.attrib; | 13 | _FindData->attrib=fd.attrib; |
lib/libc/mingw/stdio/_wstat.c deleted-119| ... | @@ -1,119 +0,0 @@ | ||
| 1 | #define __CRT__NO_INLINE | ||
| 2 | #include <sys/stat.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | #include <malloc.h> | ||
| 5 | |||
| 6 | /** | ||
| 7 | * Returns _path without trailing slash if any | ||
| 8 | * | ||
| 9 | * - if _path has no trailing slash, the function returns it | ||
| 10 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 11 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 12 | * without the trailing slash. It is then the responsibility of the caller | ||
| 13 | * to free it. | ||
| 14 | */ | ||
| 15 | |||
| 16 | static wchar_t* | ||
| 17 | _mingw_no_trailing_slash (const wchar_t* _path) | ||
| 18 | { | ||
| 19 | int len; | ||
| 20 | wchar_t *p; | ||
| 21 | |||
| 22 | p = (wchar_t*)_path; | ||
| 23 | |||
| 24 | if (_path && *_path) { | ||
| 25 | len = wcslen (_path); | ||
| 26 | |||
| 27 | /* Ignore X:\ */ | ||
| 28 | |||
| 29 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':')) | ||
| 30 | return p; | ||
| 31 | |||
| 32 | /* Check UNC \\abc\<name>\ */ | ||
| 33 | if ((_path[0] == L'\\' || _path[0] == L'/') | ||
| 34 | 	&& (_path[1] == L'\\' || _path[1] == L'/')) | ||
| 35 | { | ||
| 36 | 	const wchar_t *r = &_path[2]; | ||
| 37 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 38 | 	 ++r; | ||
| 39 | 	if (*r != 0) | ||
| 40 | 	 ++r; | ||
| 41 | 	if (*r == 0) | ||
| 42 | 	 return p; | ||
| 43 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 44 | 	 ++r; | ||
| 45 | 	if (*r != 0) | ||
| 46 | 	 ++r; | ||
| 47 | 	if (*r == 0) | ||
| 48 | 	 return p; | ||
| 49 | } | ||
| 50 | |||
| 51 | if (_path[len - 1] == L'/' || _path[len - 1] == L'\\') | ||
| 52 | { | ||
| 53 | 	p = (wchar_t*)malloc (len * sizeof(wchar_t)); | ||
| 54 | 	memcpy (p, _path, (len - 1) * sizeof(wchar_t)); | ||
| 55 | 	p[len - 1] = L'\0'; | ||
| 56 | } | ||
| 57 | } | ||
| 58 | |||
| 59 | return p; | ||
| 60 | } | ||
| 61 | |||
| 62 | /* FIXME: Relying on _USE_32BIT_TIME_T, which is a user-macro, | ||
| 63 | during CRT compilation is plainly broken. Need an appropriate | ||
| 64 | implementation to provide users the ability of compiling the | ||
| 65 | CRT only with 32-bit time_t behavior. */ | ||
| 66 | #if defined(_USE_32BIT_TIME_T) | ||
| 67 | int __cdecl | ||
| 68 | wstat(const wchar_t *_Filename,struct stat *_Stat) | ||
| 69 | { | ||
| 70 | struct _stat32 st; | ||
| 71 | wchar_t *_path = _mingw_no_trailing_slash(_Filename); | ||
| 72 | |||
| 73 | int ret=_wstat32(_path,&st); | ||
| 74 | |||
| 75 | if (_path != _Filename) | ||
| 76 | free (_path); | ||
| 77 | |||
| 78 | if (ret == -1) { | ||
| 79 | memset(_Stat,0,sizeof(struct stat)); | ||
| 80 | return -1; | ||
| 81 | } | ||
| 82 | /* struct stat and struct _stat32 | ||
| 83 | are the same for this case. */ | ||
| 84 | memcpy(_Stat, &st, sizeof(struct _stat32)); | ||
| 85 | return ret; | ||
| 86 | } | ||
| 87 | #else | ||
| 88 | int __cdecl | ||
| 89 | wstat(const wchar_t *_Filename,struct stat *_Stat) | ||
| 90 | { | ||
| 91 | struct _stat64 st; | ||
| 92 | wchar_t *_path = _mingw_no_trailing_slash(_Filename); | ||
| 93 | |||
| 94 | int ret=_wstat64(_path,&st); | ||
| 95 | |||
| 96 | if (_path != _Filename) | ||
| 97 | free (_path); | ||
| 98 | |||
| 99 | if (ret == -1) { | ||
| 100 | memset(_Stat,0,sizeof(struct stat)); | ||
| 101 | return -1; | ||
| 102 | } | ||
| 103 | /* struct stat and struct _stat64i32 | ||
| 104 | are the same for this case. */ | ||
| 105 | _Stat->st_dev=st.st_dev; | ||
| 106 | _Stat->st_ino=st.st_ino; | ||
| 107 | _Stat->st_mode=st.st_mode; | ||
| 108 | _Stat->st_nlink=st.st_nlink; | ||
| 109 | _Stat->st_uid=st.st_uid; | ||
| 110 | _Stat->st_gid=st.st_gid; | ||
| 111 | _Stat->st_rdev=st.st_rdev; | ||
| 112 | _Stat->st_size=(_off_t) st.st_size; | ||
| 113 | _Stat->st_atime=st.st_atime; | ||
| 114 | _Stat->st_mtime=st.st_mtime; | ||
| 115 | _Stat->st_ctime=st.st_ctime; | ||
| 116 | return ret; | ||
| 117 | } | ||
| 118 | #endif | ||
| 119 | |||
lib/libc/mingw/stdio/_wstat64i32.c+19-70| ... | @@ -1,77 +1,26 @@ | ... | @@ -1,77 +1,26 @@ |
| 1 | #define __CRT__NO_INLINE | ||
| 2 | #include <sys/stat.h> | ||
| 3 | #include <stdlib.h> | ||
| 4 | |||
| 5 | /** | 1 | /** |
| 6 | * Returns _path without trailing slash if any | 2 | * This file has no copyright assigned and is placed in the Public Domain. |
| 7 | * | 3 | * This file is part of the mingw-w64 runtime package. |
| 8 | * - if _path has no trailing slash, the function returns it | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 9 | * - if _path has a trailing slash, but is of the form C:/, then it returns it | ||
| 10 | * - otherwise, the function creates a new string, which is a copy of _path | ||
| 11 | * without the trailing slash. It is then the responsibility of the caller | ||
| 12 | * to free it. | ||
| 13 | */ | 5 | */ |
| 14 | 6 | ||
| 15 | static wchar_t* | 7 | #include <sys/stat.h> |
| 16 | _mingw_no_trailing_slash (const wchar_t* _path) | ||
| 17 | { | ||
| 18 | int len; | ||
| 19 | wchar_t *p; | ||
| 20 | |||
| 21 | p = (wchar_t*)_path; | ||
| 22 | |||
| 23 | if (_path && *_path) { | ||
| 24 | len = wcslen (_path); | ||
| 25 | |||
| 26 | /* Ignore X:\ */ | ||
| 27 | |||
| 28 | if (len <= 1 || ((len == 2 || len == 3) && _path[1] == L':')) | ||
| 29 | return p; | ||
| 30 | |||
| 31 | /* Check UNC \\abc\<name>\ */ | ||
| 32 | if ((_path[0] == L'\\' || _path[0] == L'/') | ||
| 33 | 	&& (_path[1] == L'\\' || _path[1] == L'/')) | ||
| 34 | { | ||
| 35 | 	const wchar_t *r = &_path[2]; | ||
| 36 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 37 | 	 ++r; | ||
| 38 | 	if (*r != 0) | ||
| 39 | 	 ++r; | ||
| 40 | 	if (*r == 0) | ||
| 41 | 	 return p; | ||
| 42 | 	while (*r != 0 && *r != L'\\' && *r != L'/') | ||
| 43 | 	 ++r; | ||
| 44 | 	if (*r != 0) | ||
| 45 | 	 ++r; | ||
| 46 | 	if (*r == 0) | ||
| 47 | 	 return p; | ||
| 48 | } | ||
| 49 | |||
| 50 | if (_path[len - 1] == L'/' || _path[len - 1] == L'\\') | ||
| 51 | { | ||
| 52 | 	p = (wchar_t*)malloc (len * sizeof(wchar_t)); | ||
| 53 | 	memcpy (p, _path, (len - 1) * sizeof(wchar_t)); | ||
| 54 | 	p[len - 1] = L'\0'; | ||
| 55 | } | ||
| 56 | } | ||
| 57 | |||
| 58 | return p; | ||
| 59 | } | ||
| 60 | 8 | ||
| 9 | /* When the file size does not fit into the st_size field: | ||
| 10 | * crtdll-msvcr90 msvcr100 msvcr110+ | ||
| 11 | * st_size truncate 0 0 | ||
| 12 | * errno no change no change EOVERFLOW | ||
| 13 | * returns 0 -1 -1 | ||
| 14 | * | ||
| 15 | * This file is used only for pre-msvcr80 builds, | ||
| 16 | * So use the pre-msvcr80 behavior - truncate without error. | ||
| 17 | */ | ||
| 61 | int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat) | 18 | int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat) |
| 62 | { | 19 | { |
| 63 | struct _stat64 st; | 20 | struct _stat64 st; |
| 64 | wchar_t *_path = _mingw_no_trailing_slash(_Name); | 21 | int ret=_wstat64(_Name,&st); |
| 65 | 22 | if (ret != 0) | |
| 66 | int ret=_wstat64(_path,&st); | 23 | return ret; |
| 67 | |||
| 68 | if (_path != _Name) | ||
| 69 | free(_path); | ||
| 70 | |||
| 71 | if (ret == -1) { | ||
| 72 | memset(_Stat,0,sizeof(struct _stat64i32)); | ||
| 73 | return -1; | ||
| 74 | } | ||
| 75 | _Stat->st_dev=st.st_dev; | 24 | _Stat->st_dev=st.st_dev; |
| 76 | _Stat->st_ino=st.st_ino; | 25 | _Stat->st_ino=st.st_ino; |
| 77 | _Stat->st_mode=st.st_mode; | 26 | _Stat->st_mode=st.st_mode; |
| ... | @@ -79,10 +28,10 @@ int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat) | ... | @@ -79,10 +28,10 @@ int __cdecl _wstat64i32(const wchar_t *_Name,struct _stat64i32 *_Stat) |
| 79 | _Stat->st_uid=st.st_uid; | 28 | _Stat->st_uid=st.st_uid; |
| 80 | _Stat->st_gid=st.st_gid; | 29 | _Stat->st_gid=st.st_gid; |
| 81 | _Stat->st_rdev=st.st_rdev; | 30 | _Stat->st_rdev=st.st_rdev; |
| 82 | _Stat->st_size=(_off_t) st.st_size; | 31 | _Stat->st_size=(_off_t) st.st_size; /* truncate 64-bit st_size to 32-bit */ |
| 83 | _Stat->st_atime=st.st_atime; | 32 | _Stat->st_atime=st.st_atime; |
| 84 | _Stat->st_mtime=st.st_mtime; | 33 | _Stat->st_mtime=st.st_mtime; |
| 85 | _Stat->st_ctime=st.st_ctime; | 34 | _Stat->st_ctime=st.st_ctime; |
| 86 | return ret; | 35 | return 0; |
| 87 | } | 36 | } |
| 88 | 37 | int (__cdecl *__MINGW_IMP_SYMBOL(_wstat64i32))(const wchar_t *, struct _stat64i32 *) = _wstat64i32; |
lib/libc/mingw/stdio/mingw_pformat.c+7-14| ... | @@ -512,8 +512,7 @@ void __pformat_putchars( const char *s, int count, __pformat_t *stream ) | ... | @@ -512,8 +512,7 @@ void __pformat_putchars( const char *s, int count, __pformat_t *stream ) |
| 512 | wchar_t w[12], *p; | 512 | wchar_t w[12], *p; |
| 513 | while( count > 0 ) | 513 | while( count > 0 ) |
| 514 | { | 514 | { |
| 515 | mbstate_t ps; | 515 | mbstate_t ps = {0}; |
| 516 | memset(&ps, 0, sizeof(ps) ); | ||
| 517 | --count; | 516 | --count; |
| 518 | p = &w[0]; | 517 | p = &w[0]; |
| 519 | l = mbrtowc (p, s, strlen (s), &ps); | 518 | l = mbrtowc (p, s, strlen (s), &ps); |
| ... | @@ -1175,11 +1174,8 @@ void __pformat_emit_radix_point( __pformat_t *stream ) | ... | @@ -1175,11 +1174,8 @@ void __pformat_emit_radix_point( __pformat_t *stream ) |
| 1175 | /* Radix point initialisation not yet completed; | 1174 | /* Radix point initialisation not yet completed; |
| 1176 | * establish a multibyte to `wchar_t' converter... | 1175 | * establish a multibyte to `wchar_t' converter... |
| 1177 | */ | 1176 | */ |
| 1178 | int len; wchar_t rpchr; mbstate_t state; | 1177 | int len; wchar_t rpchr; |
| 1179 | 1178 | mbstate_t state = {0}; | |
| 1180 | /* Initialise the conversion state... | ||
| 1181 | */ | ||
| 1182 | memset( &state, 0, sizeof( state ) ); | ||
| 1183 | 1179 | ||
| 1184 | /* Fetch and convert the localised radix point representation... | 1180 | /* Fetch and convert the localised radix point representation... |
| 1185 | */ | 1181 | */ |
| ... | @@ -1203,11 +1199,8 @@ void __pformat_emit_radix_point( __pformat_t *stream ) | ... | @@ -1203,11 +1199,8 @@ void __pformat_emit_radix_point( __pformat_t *stream ) |
| 1203 | #ifdef __BUILD_WIDEAPI | 1199 | #ifdef __BUILD_WIDEAPI |
| 1204 | __pformat_putc (stream->rpchr, stream); | 1200 | __pformat_putc (stream->rpchr, stream); |
| 1205 | #else | 1201 | #else |
| 1206 | int len; char buf[len = stream->rplen]; mbstate_t state; | 1202 | int len; char buf[len = stream->rplen]; |
| 1207 | 1203 | mbstate_t state = {0}; | |
| 1208 | /* Initialise the conversion state... | ||
| 1209 | */ | ||
| 1210 | memset( &state, 0, sizeof( state ) ); | ||
| 1211 | 1204 | ||
| 1212 | /* Convert the `wchar_t' representation to multibyte... | 1205 | /* Convert the `wchar_t' representation to multibyte... |
| 1213 | */ | 1206 | */ |
| ... | @@ -3123,8 +3116,8 @@ __pformat (int flags, void *dest, int max, const APICHAR *fmt, va_list argv) | ... | @@ -3123,8 +3116,8 @@ __pformat (int flags, void *dest, int max, const APICHAR *fmt, va_list argv) |
| 3123 | if (state == PFORMAT_INIT) | 3116 | if (state == PFORMAT_INIT) |
| 3124 | { | 3117 | { |
| 3125 | stream.flags |= PFORMAT_GROUPED; /* $$$$ */ | 3118 | stream.flags |= PFORMAT_GROUPED; /* $$$$ */ |
| 3126 | int len; wchar_t rpchr; mbstate_t cstate; | 3119 | int len; wchar_t rpchr; |
| 3127 | memset (&cstate, 0, sizeof(state)); | 3120 | mbstate_t cstate = {0}; |
| 3128 | if ((len = mbrtowc( &rpchr, localeconv()->thousands_sep, 16, &cstate)) > 0) | 3121 | if ((len = mbrtowc( &rpchr, localeconv()->thousands_sep, 16, &cstate)) > 0) |
| 3129 | stream.thousands_chr = rpchr; | 3122 | stream.thousands_chr = rpchr; |
| 3130 | stream.thousands_chr_len = len; | 3123 | stream.thousands_chr_len = len; |
lib/libc/mingw/stdio/mingw_sformat.c+4-6| ... | @@ -307,7 +307,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) | ... | @@ -307,7 +307,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) |
| 307 | char seen_dot, seen_exp, is_neg, not_in; | 307 | char seen_dot, seen_exp, is_neg, not_in; |
| 308 | char *tmp_wbuf_ptr, buf[MB_LEN_MAX]; | 308 | char *tmp_wbuf_ptr, buf[MB_LEN_MAX]; |
| 309 | const char *lc_decimal_point, *lc_thousands_sep; | 309 | const char *lc_decimal_point, *lc_thousands_sep; |
| 310 | mbstate_t state, cstate; | 310 | mbstate_t state = {0}, cstate; |
| 311 | union { | 311 | union { |
| 312 | unsigned long long ull; | 312 | unsigned long long ull; |
| 313 | unsigned long ul; | 313 | unsigned long ul; |
| ... | @@ -323,8 +323,6 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) | ... | @@ -323,8 +323,6 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) |
| 323 | return EOF; | 323 | return EOF; |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | memset (&state, 0, sizeof (state)); | ||
| 327 | |||
| 328 | lc_decimal_point = localeconv()->decimal_point; | 326 | lc_decimal_point = localeconv()->decimal_point; |
| 329 | lc_thousands_sep = localeconv()->thousands_sep; | 327 | lc_thousands_sep = localeconv()->thousands_sep; |
| 330 | if (lc_thousands_sep != NULL && *lc_thousands_sep == 0) | 328 | if (lc_thousands_sep != NULL && *lc_thousands_sep == 0) |
| ... | @@ -682,7 +680,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) | ... | @@ -682,7 +680,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) |
| 682 | 	 if ((c = in_ch (s, &read_in)) == EOF) | 680 | 	 if ((c = in_ch (s, &read_in)) == EOF) |
| 683 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 681 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 684 | 682 | ||
| 685 | 	 memset (&cstate, 0, sizeof (cstate)); | 683 | 	 cstate = (mbstate_t){0}; |
| 686 | 684 | ||
| 687 | 	 do | 685 | 	 do |
| 688 | 	 { | 686 | 	 { |
| ... | @@ -854,7 +852,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) | ... | @@ -854,7 +852,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) |
| 854 | 	 if ((c = in_ch (s, &read_in)) == EOF) | 852 | 	 if ((c = in_ch (s, &read_in)) == EOF) |
| 855 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 853 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 856 | 854 | ||
| 857 | 	 memset (&cstate, 0, sizeof (cstate)); | 855 | 	 cstate = (mbstate_t){0}; |
| 858 | 856 | ||
| 859 | 	 do | 857 | 	 do |
| 860 | 	 { | 858 | 	 { |
| ... | @@ -1459,7 +1457,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) | ... | @@ -1459,7 +1457,7 @@ __mingw_sformat (_IFP *s, const char *format, va_list argp) |
| 1459 | 	 if ((c = in_ch (s, &read_in)) == EOF) | 1457 | 	 if ((c = in_ch (s, &read_in)) == EOF) |
| 1460 | 		return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 1458 | 		return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 1461 | 1459 | ||
| 1462 | 	 memset (&cstate, 0, sizeof (cstate)); | 1460 | cstate = (mbstate_t){0}; |
| 1463 | 1461 | ||
| 1464 | 	 do | 1462 | 	 do |
| 1465 | 		{ | 1463 | 		{ |
lib/libc/mingw/stdio/mingw_swformat.c+5-5| ... | @@ -332,10 +332,10 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) | ... | @@ -332,10 +332,10 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) |
| 332 | return EOF; | 332 | return EOF; |
| 333 | } | 333 | } |
| 334 | 334 | ||
| 335 | memset (&state, 0, sizeof(state)); | 335 | state = (mbstate_t){0}; |
| 336 | clen = mbrtowc( &wc, localeconv()->decimal_point, 16, &state); | 336 | clen = mbrtowc( &wc, localeconv()->decimal_point, 16, &state); |
| 337 | lc_decimal_point = (clen > 0 ? wc : '.'); | 337 | lc_decimal_point = (clen > 0 ? wc : '.'); |
| 338 | memset( &state, 0, sizeof( state ) ); | 338 | state = (mbstate_t){0}; |
| 339 | clen = mbrtowc( &wc, localeconv()->thousands_sep, 16, &state); | 339 | clen = mbrtowc( &wc, localeconv()->thousands_sep, 16, &state); |
| 340 | lc_thousands_sep = (clen > 0 ? wc : 0); | 340 | lc_thousands_sep = (clen > 0 ? wc : 0); |
| 341 | 341 | ||
| ... | @@ -596,7 +596,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) | ... | @@ -596,7 +596,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) |
| 596 | 	 if ((c = in_ch (s, &read_in)) == WEOF) | 596 | 	 if ((c = in_ch (s, &read_in)) == WEOF) |
| 597 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 597 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 598 | 598 | ||
| 599 | 	 memset (&state, 0, sizeof (state)); | 599 | state = (mbstate_t){0}; |
| 600 | 600 | ||
| 601 | 	 do | 601 | 	 do |
| 602 | 	 { | 602 | 	 { |
| ... | @@ -744,7 +744,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) | ... | @@ -744,7 +744,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) |
| 744 | 	 if ((c = in_ch (s, &read_in)) == WEOF) | 744 | 	 if ((c = in_ch (s, &read_in)) == WEOF) |
| 745 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 745 | 	 return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 746 | 746 | ||
| 747 | 	 memset (&state, 0, sizeof (state)); | 747 | state = (mbstate_t){0}; |
| 748 | 748 | ||
| 749 | 	 do | 749 | 	 do |
| 750 | 	 { | 750 | 	 { |
| ... | @@ -1459,7 +1459,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) | ... | @@ -1459,7 +1459,7 @@ __mingw_swformat (_IFPW *s, const wchar_t *format, va_list argp) |
| 1459 | 	 if ((c = in_ch (s, &read_in)) == WEOF) | 1459 | 	 if ((c = in_ch (s, &read_in)) == WEOF) |
| 1460 | 		return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); | 1460 | 		return cleanup_return ((!rval ? EOF : rval), &gcollect, pstr, &wbuf); |
| 1461 | 1461 | ||
| 1462 | 	 memset (&state, 0, sizeof (state)); | 1462 | state = (mbstate_t){0}; |
| 1463 | 1463 | ||
| 1464 | 	 do | 1464 | 	 do |
| 1465 | 		{ | 1465 | 		{ |
lib/libc/mingw/stdio/mingw_vfscanf.c+1-3| ... | @@ -7,8 +7,6 @@ | ... | @@ -7,8 +7,6 @@ |
| 7 | int | 7 | int |
| 8 | __mingw_vfscanf (FILE *s, const char *format, va_list argp) | 8 | __mingw_vfscanf (FILE *s, const char *format, va_list argp) |
| 9 | { | 9 | { |
| 10 | _IFP ifp; | 10 | _IFP ifp = { .fp = s }; |
| 11 | memset (&ifp, 0, sizeof (_IFP)); | ||
| 12 | ifp.fp = s; | ||
| 13 | return __mingw_sformat (&ifp, format, argp); | 11 | return __mingw_sformat (&ifp, format, argp); |
| 14 | } | 12 | } |
lib/libc/mingw/stdio/mingw_vfwscanf.c+1-3| ... | @@ -7,8 +7,6 @@ | ... | @@ -7,8 +7,6 @@ |
| 7 | int | 7 | int |
| 8 | __mingw_vfwscanf (FILE *s, const wchar_t *format, va_list argp) | 8 | __mingw_vfwscanf (FILE *s, const wchar_t *format, va_list argp) |
| 9 | { | 9 | { |
| 10 | _IFPW ifp; | 10 | _IFPW ifp = { .fp = s }; |
| 11 | memset (&ifp, 0, sizeof (_IFPW)); | ||
| 12 | ifp.fp = s; | ||
| 13 | return __mingw_swformat (&ifp, format, argp); | 11 | return __mingw_swformat (&ifp, format, argp); |
| 14 | } | 12 | } |
lib/libc/mingw/stdio/mingw_vsscanf.c+1-4| ... | @@ -7,9 +7,6 @@ | ... | @@ -7,9 +7,6 @@ |
| 7 | int | 7 | int |
| 8 | __mingw_vsscanf (const char *s, const char *format, va_list argp) | 8 | __mingw_vsscanf (const char *s, const char *format, va_list argp) |
| 9 | { | 9 | { |
| 10 | _IFP ifp; | 10 | _IFP ifp = { .str = s, .is_string = 1 }; |
| 11 | memset (&ifp, 0, sizeof (_IFP)); | ||
| 12 | ifp.str = s; | ||
| 13 | ifp.is_string = 1; | ||
| 14 | return __mingw_sformat (&ifp, format, argp); | 11 | return __mingw_sformat (&ifp, format, argp); |
| 15 | } | 12 | } |
lib/libc/mingw/stdio/mingw_vswscanf.c+1-4| ... | @@ -7,9 +7,6 @@ | ... | @@ -7,9 +7,6 @@ |
| 7 | int | 7 | int |
| 8 | __mingw_vswscanf (const wchar_t *s, const wchar_t *format, va_list argp) | 8 | __mingw_vswscanf (const wchar_t *s, const wchar_t *format, va_list argp) |
| 9 | { | 9 | { |
| 10 | _IFPW ifp; | 10 | _IFPW ifp = { .str = s, .is_string = 1 }; |
| 11 | memset (&ifp, 0, sizeof (_IFPW)); | ||
| 12 | ifp.str = s; | ||
| 13 | ifp.is_string = 1; | ||
| 14 | return __mingw_swformat (&ifp, format, argp); | 11 | return __mingw_swformat (&ifp, format, argp); |
| 15 | } | 12 | } |
lib/libc/mingw/stdio/ucrt___local_stdio_printf_options.c created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <corecrt_stdio_config.h> | ||
| 10 | |||
| 11 | static unsigned __int64 options = _CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS | _CRT_INTERNAL_PRINTF_STANDARD_ROUNDING; | ||
| 12 | |||
| 13 | unsigned __int64* __local_stdio_printf_options(void) { | ||
| 14 | return &options; | ||
| 15 | } | ||
lib/libc/mingw/stdio/ucrt___local_stdio_scanf_options.c created+15| ... | @@ -0,0 +1,15 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <corecrt_stdio_config.h> | ||
| 10 | |||
| 11 | static unsigned __int64 options = _CRT_INTERNAL_SCANF_LEGACY_WIDE_SPECIFIERS; | ||
| 12 | |||
| 13 | unsigned __int64* __local_stdio_scanf_options(void) { | ||
| 14 | return &options; | ||
| 15 | } | ||
lib/libc/mingw/stdio/ucrt__scprintf.c-1| ... | @@ -18,4 +18,3 @@ int __cdecl _scprintf(const char * __restrict__ _Format, ...) | ... | @@ -18,4 +18,3 @@ int __cdecl _scprintf(const char * __restrict__ _Format, ...) |
| 18 | va_end(_ArgList); | 18 | va_end(_ArgList); |
| 19 | return ret; | 19 | return ret; |
| 20 | } | 20 | } |
| 21 | int __cdecl (*__MINGW_IMP_SYMBOL(_scprintf))(const char *__restrict__, ...) = _scprintf; |
lib/libc/mingw/stdio/ucrt__snprintf.c-1| ... | @@ -18,4 +18,3 @@ int __cdecl _snprintf(char * __restrict__ _Dest, size_t _Count, const char * __r | ... | @@ -18,4 +18,3 @@ int __cdecl _snprintf(char * __restrict__ _Dest, size_t _Count, const char * __r |
| 18 | va_end(_Args); | 18 | va_end(_Args); |
| 19 | return ret; | 19 | return ret; |
| 20 | } | 20 | } |
| 21 | int __cdecl (*__MINGW_IMP_SYMBOL(_snprintf))(char *__restrict__, size_t, const char *__restrict__, ...) = _snprintf; |
lib/libc/mingw/stdio/ucrt__snscanf.c+1-2| ... | @@ -14,8 +14,7 @@ int __cdecl _snscanf(const char * __restrict__ _Src, size_t _MaxCount, const cha | ... | @@ -14,8 +14,7 @@ int __cdecl _snscanf(const char * __restrict__ _Src, size_t _MaxCount, const cha |
| 14 | int ret; | 14 | int ret; |
| 15 | va_list _ArgList; | 15 | va_list _ArgList; |
| 16 | va_start(_ArgList, _Format); | 16 | va_start(_ArgList, _Format); |
| 17 | ret = __stdio_common_vsscanf(0, _Src, _MaxCount, _Format, NULL, _ArgList); | 17 | ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Src, _MaxCount, _Format, NULL, _ArgList); |
| 18 | va_end(_ArgList); | 18 | va_end(_ArgList); |
| 19 | return ret; | 19 | return ret; |
| 20 | } | 20 | } |
| 21 | int __cdecl (*__MINGW_IMP_SYMBOL(_snscanf))(const char *__restrict__, size_t, const char * __restrict__, ...) = _snscanf; |
lib/libc/mingw/stdio/ucrt__snwprintf.c-18| ... | @@ -4,25 +4,12 @@ | ... | @@ -4,25 +4,12 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | // For ucrt, this function normally is an inline function in stdio.h. | ||
| 8 | // libmingwex doesn't use the ucrt version of headers, and wassert.c can | ||
| 9 | // end up requiring a concrete version of it. | ||
| 10 | |||
| 11 | #ifdef __GNUC__ | ||
| 12 | #pragma GCC diagnostic push | ||
| 13 | #pragma GCC diagnostic ignored "-Winline" | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #undef __MSVCRT_VERSION__ | 7 | #undef __MSVCRT_VERSION__ |
| 17 | #define _UCRT | 8 | #define _UCRT |
| 18 | 9 | ||
| 19 | #define _snwprintf real__snwprintf | ||
| 20 | |||
| 21 | #include <stdarg.h> | 10 | #include <stdarg.h> |
| 22 | #include <stdio.h> | 11 | #include <stdio.h> |
| 23 | 12 | ||
| 24 | #undef _snwprintf | ||
| 25 | |||
| 26 | int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * restrict _Format, ...); | 13 | int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * restrict _Format, ...); |
| 27 | 14 | ||
| 28 | int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * restrict _Format, ...) | 15 | 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 * | ... | @@ -34,8 +21,3 @@ int __cdecl _snwprintf(wchar_t * restrict _Dest, size_t _Count, const wchar_t * |
| 34 | va_end(ap); | 21 | va_end(ap); |
| 35 | return ret; | 22 | return ret; |
| 36 | } | 23 | } |
| 37 | |||
| 38 | int __cdecl (*__MINGW_IMP_SYMBOL(_snwprintf))(wchar_t *restrict, size_t, const wchar_t *restrict, ...) = _snwprintf; | ||
| 39 | #ifdef __GNUC__ | ||
| 40 | #pragma GCC diagnostic pop | ||
| 41 | #endif |
lib/libc/mingw/stdio/ucrt__vsnprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __re | ... | @@ -12,4 +12,3 @@ int __cdecl _vsnprintf(char * __restrict__ _Dest,size_t _Count,const char * __re |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args); | 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(_vsnprintf))(char *__restrict__, size_t, const char *__restrict__, va_list) = _vsnprintf; |
lib/libc/mingw/stdio/ucrt__vsnwprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t | ... | @@ -12,4 +12,3 @@ int __cdecl _vsnwprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args); | 13 | return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_LEGACY_VSPRINTF_NULL_TERMINATION, _Dest, _Count, _Format, NULL, _Args); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(_vsnwprintf))(wchar_t *__restrict__, size_t, const wchar_t *__restrict__, va_list) = _vsnwprintf; |
lib/libc/mingw/stdio/ucrt_fprintf.c-1| ... | @@ -17,4 +17,3 @@ int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format, | ... | @@ -17,4 +17,3 @@ int __cdecl fprintf(FILE * __restrict__ _File,const char * __restrict__ _Format, |
| 17 | __builtin_va_end(ap); | 17 | __builtin_va_end(ap); |
| 18 | return ret; | 18 | return ret; |
| 19 | } | 19 | } |
| 20 | int __cdecl (*__MINGW_IMP_SYMBOL(fprintf))(FILE *__restrict__, const char *__restrict__, ...) = fprintf; |
lib/libc/mingw/stdio/ucrt_fscanf.c+1-2| ... | @@ -12,8 +12,7 @@ int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,. | ... | @@ -12,8 +12,7 @@ int __cdecl fscanf(FILE * __restrict__ _File,const char * __restrict__ _Format,. |
| 12 | __builtin_va_list __ap; | 12 | __builtin_va_list __ap; |
| 13 | int __ret; | 13 | int __ret; |
| 14 | __builtin_va_start(__ap, _Format); | 14 | __builtin_va_start(__ap, _Format); |
| 15 | __ret = __stdio_common_vfscanf(0, _File, _Format, NULL, __ap); | 15 | __ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _File, _Format, NULL, __ap); |
| 16 | __builtin_va_end(__ap); | 16 | __builtin_va_end(__ap); |
| 17 | return __ret; | 17 | return __ret; |
| 18 | } | 18 | } |
| 19 | int __cdecl (*__MINGW_IMP_SYMBOL(fscanf))(FILE *__restrict__, const char *__restrict__, ...) = fscanf; |
lib/libc/mingw/stdio/ucrt_fwprintf.c+1-19| ... | @@ -4,25 +4,12 @@ | ... | @@ -4,25 +4,12 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | // For ucrt, this function normally is an inline function in stdio.h. | ||
| 8 | // libmingwex doesn't use the ucrt version of headers, and wassert.c can | ||
| 9 | // end up requiring a concrete version of it. | ||
| 10 | |||
| 11 | #ifdef __GNUC__ | ||
| 12 | #pragma GCC diagnostic push | ||
| 13 | #pragma GCC diagnostic ignored "-Winline" | ||
| 14 | #endif | ||
| 15 | |||
| 16 | #undef __MSVCRT_VERSION__ | 7 | #undef __MSVCRT_VERSION__ |
| 17 | #define _UCRT | 8 | #define _UCRT |
| 18 | 9 | ||
| 19 | #define fwprintf real_fwprintf | ||
| 20 | |||
| 21 | #include <stdarg.h> | 10 | #include <stdarg.h> |
| 22 | #include <stdio.h> | 11 | #include <stdio.h> |
| 23 | 12 | ||
| 24 | #undef fwprintf | ||
| 25 | |||
| 26 | int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...); | 13 | int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...); |
| 27 | 14 | ||
| 28 | int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...) | 15 | int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...) |
| ... | @@ -30,12 +17,7 @@ int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...) | ... | @@ -30,12 +17,7 @@ int __cdecl fwprintf(FILE *ptr, const wchar_t *fmt, ...) |
| 30 | va_list ap; | 17 | va_list ap; |
| 31 | int ret; | 18 | int ret; |
| 32 | va_start(ap, fmt); | 19 | va_start(ap, fmt); |
| 33 | ret = vfwprintf(ptr, fmt, ap); | 20 | ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, ptr, fmt, NULL, ap); |
| 34 | va_end(ap); | 21 | va_end(ap); |
| 35 | return ret; | 22 | return ret; |
| 36 | } | 23 | } |
| 37 | |||
| 38 | int __cdecl (*__MINGW_IMP_SYMBOL(fwprintf))(FILE *, const wchar_t *, ...) = fwprintf; | ||
| 39 | #ifdef __GNUC__ | ||
| 40 | #pragma GCC diagnostic pop | ||
| 41 | #endif |
lib/libc/mingw/stdio/ucrt_fwscanf.c created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl fwscanf(FILE * __restrict__ _File,const wchar_t * __restrict__ _Format,...) { | ||
| 12 | __builtin_va_list __ap; | ||
| 13 | int __ret; | ||
| 14 | __builtin_va_start(__ap, _Format); | ||
| 15 | __ret = __stdio_common_vfwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _File, _Format, NULL, __ap); | ||
| 16 | __builtin_va_end(__ap); | ||
| 17 | return __ret; | ||
| 18 | } | ||
lib/libc/mingw/stdio/ucrt_ms_fprintf.c deleted-22| ... | @@ -1,22 +0,0 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | |||
| 10 | #include <stdio.h> | ||
| 11 | #include <stdarg.h> | ||
| 12 | |||
| 13 | int __cdecl __ms_fprintf(FILE * restrict file, const char * restrict format, ...) | ||
| 14 | { | ||
| 15 | va_list ap; | ||
| 16 | int ret; | ||
| 17 | va_start(ap, format); | ||
| 18 | ret = __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, format, NULL, ap); | ||
| 19 | va_end(ap); | ||
| 20 | return ret; | ||
| 21 | } | ||
| 22 | int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fprintf))(FILE * restrict, const char * restrict, ...) = __ms_fprintf; | ||
lib/libc/mingw/stdio/ucrt_ms_fwprintf.c+1-2| ... | @@ -17,8 +17,7 @@ int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...) | ... | @@ -17,8 +17,7 @@ int __cdecl __ms_fwprintf(FILE *file, const wchar_t *fmt, ...) |
| 17 | va_list ap; | 17 | va_list ap; |
| 18 | int ret; | 18 | int ret; |
| 19 | va_start(ap, fmt); | 19 | va_start(ap, fmt); |
| 20 | ret = __stdio_common_vfwprintf(_CRT_INTERNAL_PRINTF_LEGACY_WIDE_SPECIFIERS, file, fmt, NULL, ap); | 20 | ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, file, fmt, NULL, ap); |
| 21 | va_end(ap); | 21 | va_end(ap); |
| 22 | return ret; | 22 | return ret; |
| 23 | } | 23 | } |
| 24 | int __cdecl (*__MINGW_IMP_SYMBOL(__ms_fwprintf))(FILE *, const wchar_t *, ...) = __ms_fwprintf; |
lib/libc/mingw/stdio/ucrt_printf.c-1| ... | @@ -17,4 +17,3 @@ int __cdecl printf(const char * __restrict__ _Format,...) | ... | @@ -17,4 +17,3 @@ int __cdecl printf(const char * __restrict__ _Format,...) |
| 17 | __builtin_va_end(ap); | 17 | __builtin_va_end(ap); |
| 18 | return ret; | 18 | return ret; |
| 19 | } | 19 | } |
| 20 | int __cdecl (*__MINGW_IMP_SYMBOL(printf))(const char *__restrict__, ...) = printf; |
lib/libc/mingw/stdio/ucrt_scanf.c+1-2| ... | @@ -12,8 +12,7 @@ int __cdecl scanf(const char * __restrict__ _Format,...) { | ... | @@ -12,8 +12,7 @@ int __cdecl scanf(const char * __restrict__ _Format,...) { |
| 12 | __builtin_va_list __ap; | 12 | __builtin_va_list __ap; |
| 13 | int __ret; | 13 | int __ret; |
| 14 | __builtin_va_start(__ap, _Format); | 14 | __builtin_va_start(__ap, _Format); |
| 15 | __ret = __stdio_common_vfscanf(0, stdin, _Format, NULL, __ap); | 15 | __ret = __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, _Format, NULL, __ap); |
| 16 | __builtin_va_end(__ap); | 16 | __builtin_va_end(__ap); |
| 17 | return __ret; | 17 | return __ret; |
| 18 | } | 18 | } |
| 19 | int __cdecl (*__MINGW_IMP_SYMBOL(scanf))(const char *__restrict__, ...) = scanf; |
lib/libc/mingw/stdio/ucrt_snprintf.c-1| ... | @@ -17,4 +17,3 @@ int __cdecl snprintf (char * __restrict__ __stream, size_t __n, const char * __r | ... | @@ -17,4 +17,3 @@ int __cdecl snprintf (char * __restrict__ __stream, size_t __n, const char * __r |
| 17 | __builtin_va_end(ap); | 17 | __builtin_va_end(ap); |
| 18 | return ret; | 18 | return ret; |
| 19 | } | 19 | } |
| 20 | int __cdecl (*__MINGW_IMP_SYMBOL(snprintf))(char *__restrict__, size_t, const char *__restrict__, ...) = snprintf; |
lib/libc/mingw/stdio/ucrt_snwprintf.c created+19| ... | @@ -0,0 +1,19 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl snwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, ...) | ||
| 12 | { | ||
| 13 | __builtin_va_list __ap; | ||
| 14 | int __ret; | ||
| 15 | __builtin_va_start(__ap, format); | ||
| 16 | __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, __ap); | ||
| 17 | __builtin_va_end(__ap); | ||
| 18 | return __ret; | ||
| 19 | } | ||
lib/libc/mingw/stdio/ucrt_sprintf.c-1| ... | @@ -17,4 +17,3 @@ int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format, | ... | @@ -17,4 +17,3 @@ int __cdecl sprintf(char * __restrict__ _Dest,const char * __restrict__ _Format, |
| 17 | __builtin_va_end(ap); | 17 | __builtin_va_end(ap); |
| 18 | return ret; | 18 | return ret; |
| 19 | } | 19 | } |
| 20 | int __cdecl (*__MINGW_IMP_SYMBOL(sprintf))(char *__restrict__, const char *__restrict__, ...) = sprintf; |
lib/libc/mingw/stdio/ucrt_sscanf.c+1-3| ... | @@ -12,9 +12,7 @@ int __cdecl sscanf(const char * __restrict__ _Src,const char * __restrict__ _For | ... | @@ -12,9 +12,7 @@ int __cdecl sscanf(const char * __restrict__ _Src,const char * __restrict__ _For |
| 12 | __builtin_va_list __ap; | 12 | __builtin_va_list __ap; |
| 13 | int __ret; | 13 | int __ret; |
| 14 | __builtin_va_start(__ap, _Format); | 14 | __builtin_va_start(__ap, _Format); |
| 15 | __ret = __stdio_common_vsscanf(0, _Src, (size_t)-1, _Format, NULL, __ap); | 15 | __ret = __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Src, (size_t)-1, _Format, NULL, __ap); |
| 16 | __builtin_va_end(__ap); | 16 | __builtin_va_end(__ap); |
| 17 | return __ret; | 17 | return __ret; |
| 18 | } | 18 | } |
| 19 | |||
| 20 | int __cdecl (*__MINGW_IMP_SYMBOL(sscanf))(const char *__restrict__, const char *__restrict__, ...) = sscanf; |
lib/libc/mingw/stdio/ucrt_swprintf.c created+29| ... | @@ -0,0 +1,29 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl swprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,...) | ||
| 12 | { | ||
| 13 | __builtin_va_list __ap; | ||
| 14 | int __ret; | ||
| 15 | /* | ||
| 16 | * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and | ||
| 17 | * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is | ||
| 18 | * executed in "standard snprintf behavior" and returns number of (wide) | ||
| 19 | * chars required to allocate. For all other cases it is executed in a way | ||
| 20 | * that returns negative value on error. But C95+ compliant swprintf() for | ||
| 21 | * case _Count == 0 returns negative value, so handle this case specially. | ||
| 22 | */ | ||
| 23 | if (_Dest == NULL && _Count == 0) | ||
| 24 | return -1; | ||
| 25 | __builtin_va_start(__ap, _Format); | ||
| 26 | __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, __ap); | ||
| 27 | __builtin_va_end(__ap); | ||
| 28 | return __ret < 0 ? -1 : __ret; | ||
| 29 | } | ||
lib/libc/mingw/stdio/ucrt_swscanf.c created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl swscanf(const wchar_t * __restrict__ _Src,const wchar_t * __restrict__ _Format,...) { | ||
| 12 | __builtin_va_list __ap; | ||
| 13 | int __ret; | ||
| 14 | __builtin_va_start(__ap, _Format); | ||
| 15 | __ret = __stdio_common_vswscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, _Src, (size_t)-1, _Format, NULL, __ap); | ||
| 16 | __builtin_va_end(__ap); | ||
| 17 | return __ret; | ||
| 18 | } | ||
lib/libc/mingw/stdio/ucrt_vfprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format | ... | @@ -12,4 +12,3 @@ int __cdecl vfprintf(FILE * __restrict__ _File,const char * __restrict__ _Format |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); | 13 | return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(vfprintf))(FILE *__restrict__, const char *__restrict__, va_list) = vfprintf; |
lib/libc/mingw/stdio/ucrt_vfscanf.c+1-2| ... | @@ -9,6 +9,5 @@ | ... | @@ -9,6 +9,5 @@ |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | 10 | ||
| 11 | int __cdecl vfscanf (FILE *__stream, const char *__format, __builtin_va_list __local_argv) { | 11 | int __cdecl vfscanf (FILE *__stream, const char *__format, __builtin_va_list __local_argv) { |
| 12 | return __stdio_common_vfscanf(0, __stream, __format, NULL, __local_argv); | 12 | return __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, __stream, __format, NULL, __local_argv); |
| 13 | } | 13 | } |
| 14 | int __cdecl (*__MINGW_IMP_SYMBOL(vfscanf))(FILE *, const char *, __builtin_va_list) = vfscanf; |
lib/libc/mingw/stdio/ucrt_vfwprintf.c created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vfwprintf(FILE * __restrict__ _File, const wchar_t * __restrict__ _Format, va_list _ArgList) | ||
| 12 | { | ||
| 13 | return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _File, _Format, NULL, _ArgList); | ||
| 14 | } | ||
lib/libc/mingw/stdio/ucrt_vfwscanf.c created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vfwscanf (FILE *__stream, const wchar_t *__format, __builtin_va_list __local_argv) { | ||
| 12 | return __stdio_common_vfwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, __stream, __format, NULL, __local_argv); | ||
| 13 | } | ||
lib/libc/mingw/stdio/ucrt_vprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList) | ... | @@ -12,4 +12,3 @@ int __cdecl vprintf(const char * __restrict__ _Format,va_list _ArgList) |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); | 13 | return __stdio_common_vfprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(vprintf))(const char *__restrict__, va_list) = vprintf; |
lib/libc/mingw/stdio/ucrt_vscanf.c+1-2| ... | @@ -9,6 +9,5 @@ | ... | @@ -9,6 +9,5 @@ |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | 10 | ||
| 11 | int __cdecl vscanf(const char *__format, __builtin_va_list __local_argv) { | 11 | int __cdecl vscanf(const char *__format, __builtin_va_list __local_argv) { |
| 12 | return __stdio_common_vfscanf(0, stdin, __format, NULL, __local_argv); | 12 | return __stdio_common_vfscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, __format, NULL, __local_argv); |
| 13 | } | 13 | } |
| 14 | int __cdecl (*__MINGW_IMP_SYMBOL(vscanf))(const char *, __builtin_va_list) = vscanf; |
lib/libc/mingw/stdio/ucrt_vsnprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl vsnprintf (char * __restrict__ __stream, size_t __n, const char * __ | ... | @@ -12,4 +12,3 @@ int __cdecl vsnprintf (char * __restrict__ __stream, size_t __n, const char * __ |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, __stream, __n, __format, NULL, __local_argv); | 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, __stream, __n, __format, NULL, __local_argv); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(vsnprintf))(char *__restrict__, size_t, const char *__restrict__, va_list) = vsnprintf; |
lib/libc/mingw/stdio/ucrt_vsnwprintf.c created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vsnwprintf (wchar_t * __restrict__ s, size_t n, const wchar_t * __restrict__ format, va_list arg) | ||
| 12 | { | ||
| 13 | return __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, s, n, format, NULL, arg); | ||
| 14 | } | ||
lib/libc/mingw/stdio/ucrt_vsprintf.c-1| ... | @@ -12,4 +12,3 @@ int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format | ... | @@ -12,4 +12,3 @@ int __cdecl vsprintf(char * __restrict__ _Dest,const char * __restrict__ _Format |
| 12 | { | 12 | { |
| 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, _Dest, (size_t)-1, _Format, NULL, _Args); | 13 | return __stdio_common_vsprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS | _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR, _Dest, (size_t)-1, _Format, NULL, _Args); |
| 14 | } | 14 | } |
| 15 | int __cdecl (*__MINGW_IMP_SYMBOL(vsprintf))(char *__restrict__, const char *__restrict__, va_list) = vsprintf; |
lib/libc/mingw/stdio/ucrt_vsscanf.c+1-2| ... | @@ -9,6 +9,5 @@ | ... | @@ -9,6 +9,5 @@ |
| 9 | #include <stdio.h> | 9 | #include <stdio.h> |
| 10 | 10 | ||
| 11 | int __cdecl vsscanf (const char * __restrict__ __source, const char * __restrict__ __format, __builtin_va_list __local_argv) { | 11 | int __cdecl vsscanf (const char * __restrict__ __source, const char * __restrict__ __format, __builtin_va_list __local_argv) { |
| 12 | return __stdio_common_vsscanf(0, __source, (size_t)-1, __format, NULL, __local_argv); | 12 | return __stdio_common_vsscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, __source, (size_t)-1, __format, NULL, __local_argv); |
| 13 | } | 13 | } |
| 14 | int __cdecl (*__MINGW_IMP_SYMBOL(vsscanf))(const char *__restrict, const char *__restrict__, __builtin_va_list) = vsscanf; |
lib/libc/mingw/stdio/ucrt_vswprintf.c created+26| ... | @@ -0,0 +1,26 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vswprintf(wchar_t * __restrict__ _Dest,size_t _Count,const wchar_t * __restrict__ _Format,va_list _Args) | ||
| 12 | { | ||
| 13 | int __ret; | ||
| 14 | /* | ||
| 15 | * __stdio_common_vswprintf() for case _Dest == NULL and _Count == 0 and | ||
| 16 | * without _CRT_INTERNAL_PRINTF_STANDARD_SNPRINTF_BEHAVIOR option, is | ||
| 17 | * executed in "standard snprintf behavior" and returns number of (wide) | ||
| 18 | * chars required to allocate. For all other cases it is executed in a way | ||
| 19 | * that returns negative value on error. But C95+ compliant vswprintf() for | ||
| 20 | * case _Count == 0 returns negative value, so handle this case specially. | ||
| 21 | */ | ||
| 22 | if (_Dest == NULL && _Count == 0) | ||
| 23 | return -1; | ||
| 24 | __ret = __stdio_common_vswprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, _Dest, _Count, _Format, NULL, _Args); | ||
| 25 | return __ret < 0 ? -1 : __ret; | ||
| 26 | } | ||
lib/libc/mingw/stdio/ucrt_vwprintf.c created+14| ... | @@ -0,0 +1,14 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vwprintf(const wchar_t * __restrict__ _Format, va_list _ArgList) | ||
| 12 | { | ||
| 13 | return __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, _Format, NULL, _ArgList); | ||
| 14 | } | ||
lib/libc/mingw/stdio/ucrt_vwscanf.c created+13| ... | @@ -0,0 +1,13 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl vwscanf(const wchar_t *__format, __builtin_va_list __local_argv) { | ||
| 12 | return __stdio_common_vfwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, __format, NULL, __local_argv); | ||
| 13 | } | ||
lib/libc/mingw/stdio/ucrt_wprintf.c created+23| ... | @@ -0,0 +1,23 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | |||
| 10 | #include <stdarg.h> | ||
| 11 | #include <stdio.h> | ||
| 12 | |||
| 13 | int __cdecl wprintf(const wchar_t *fmt, ...); | ||
| 14 | |||
| 15 | int __cdecl wprintf(const wchar_t *fmt, ...) | ||
| 16 | { | ||
| 17 | va_list ap; | ||
| 18 | int ret; | ||
| 19 | va_start(ap, fmt); | ||
| 20 | ret = __stdio_common_vfwprintf(_CRT_INTERNAL_LOCAL_PRINTF_OPTIONS, stdout, fmt, NULL, ap); | ||
| 21 | va_end(ap); | ||
| 22 | return ret; | ||
| 23 | } | ||
lib/libc/mingw/stdio/ucrt_wscanf.c created+18| ... | @@ -0,0 +1,18 @@ | ||
| 1 | /** | ||
| 2 | * This file has no copyright assigned and is placed in the Public Domain. | ||
| 3 | * This file is part of the mingw-w64 runtime package. | ||
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | ||
| 5 | */ | ||
| 6 | |||
| 7 | #undef __MSVCRT_VERSION__ | ||
| 8 | #define _UCRT | ||
| 9 | #include <stdio.h> | ||
| 10 | |||
| 11 | int __cdecl wscanf(const wchar_t * __restrict__ _Format,...) { | ||
| 12 | __builtin_va_list __ap; | ||
| 13 | int __ret; | ||
| 14 | __builtin_va_start(__ap, _Format); | ||
| 15 | __ret = __stdio_common_vfwscanf(_CRT_INTERNAL_LOCAL_SCANF_OPTIONS, stdin, _Format, NULL, __ap); | ||
| 16 | __builtin_va_end(__ap); | ||
| 17 | return __ret; | ||
| 18 | } | ||
lib/libc/mingw/winpthreads/barrier.c+17-9| ... | @@ -20,12 +20,22 @@ | ... | @@ -20,12 +20,22 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <windows.h> | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <stdio.h> | 24 | #include "config.h" |
| 25 | #endif | ||
| 26 | |||
| 27 | #include <assert.h> | ||
| 25 | #include <malloc.h> | 28 | #include <malloc.h> |
| 29 | #include <stdio.h> | ||
| 30 | |||
| 31 | #define WIN32_LEAN_AND_MEAN | ||
| 32 | #include <windows.h> | ||
| 33 | |||
| 34 | /* public header files */ | ||
| 26 | #include "pthread.h" | 35 | #include "pthread.h" |
| 36 | #include "semaphore.h" | ||
| 37 | /* internal header files */ | ||
| 27 | #include "barrier.h" | 38 | #include "barrier.h" |
| 28 | #include "ref.h" | ||
| 29 | #include "misc.h" | 39 | #include "misc.h" |
| 30 | 40 | ||
| 31 | static pthread_spinlock_t barrier_global = PTHREAD_SPINLOCK_INITIALIZER; | 41 | static pthread_spinlock_t barrier_global = PTHREAD_SPINLOCK_INITIALIZER; |
| ... | @@ -34,9 +44,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int | ... | @@ -34,9 +44,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int |
| 34 | barrier_unref(volatile pthread_barrier_t *barrier, int res) | 44 | barrier_unref(volatile pthread_barrier_t *barrier, int res) |
| 35 | { | 45 | { |
| 36 | pthread_spin_lock(&barrier_global); | 46 | pthread_spin_lock(&barrier_global); |
| 37 | #ifdef WINPTHREAD_DBG | ||
| 38 | assert((((barrier_t *)*barrier)->valid == LIFE_BARRIER) && (((barrier_t *)*barrier)->busy > 0)); | 47 | assert((((barrier_t *)*barrier)->valid == LIFE_BARRIER) && (((barrier_t *)*barrier)->busy > 0)); |
| 39 | #endif | ||
| 40 | ((barrier_t *)*barrier)->busy -= 1; | 48 | ((barrier_t *)*barrier)->busy -= 1; |
| 41 | pthread_spin_unlock(&barrier_global); | 49 | pthread_spin_unlock(&barrier_global); |
| 42 | return res; | 50 | return res; |
| ... | @@ -64,7 +72,7 @@ barrier_ref_destroy(volatile pthread_barrier_t *barrier, pthread_barrier_t *bDes | ... | @@ -64,7 +72,7 @@ barrier_ref_destroy(volatile pthread_barrier_t *barrier, pthread_barrier_t *bDes |
| 64 | 72 | ||
| 65 | *bDestroy = NULL; | 73 | *bDestroy = NULL; |
| 66 | pthread_spin_lock(&barrier_global); | 74 | pthread_spin_lock(&barrier_global); |
| 67 | 75 | ||
| 68 | if (!barrier || !*barrier || ((barrier_t *)*barrier)->valid != LIFE_BARRIER) r = EINVAL; | 76 | if (!barrier || !*barrier || ((barrier_t *)*barrier)->valid != LIFE_BARRIER) r = EINVAL; |
| 69 | else { | 77 | else { |
| 70 | barrier_t *b_ = (barrier_t *)*barrier; | 78 | barrier_t *b_ = (barrier_t *)*barrier; |
| ... | @@ -92,15 +100,15 @@ int pthread_barrier_destroy(pthread_barrier_t *b_) | ... | @@ -92,15 +100,15 @@ int pthread_barrier_destroy(pthread_barrier_t *b_) |
| 92 | pthread_barrier_t bDestroy; | 100 | pthread_barrier_t bDestroy; |
| 93 | barrier_t *b; | 101 | barrier_t *b; |
| 94 | int r; | 102 | int r; |
| 95 | 103 | ||
| 96 | while ((r = barrier_ref_destroy(b_,&bDestroy)) == EBUSY) | 104 | while ((r = barrier_ref_destroy(b_,&bDestroy)) == EBUSY) |
| 97 | Sleep(0); | 105 | Sleep(0); |
| 98 | 106 | ||
| 99 | if (r) | 107 | if (r) |
| 100 | return r; | 108 | return r; |
| 101 | 109 | ||
| 102 | b = (barrier_t *)bDestroy; | 110 | b = (barrier_t *)bDestroy; |
| 103 | 111 | ||
| 104 | pthread_mutex_lock(&b->m); | 112 | pthread_mutex_lock(&b->m); |
| 105 | 113 | ||
| 106 | if (sem_destroy(&b->sems[0]) != 0) | 114 | if (sem_destroy(&b->sems[0]) != 0) |
lib/libc/mingw/winpthreads/barrier.h-2| ... | @@ -34,8 +34,6 @@ | ... | @@ -34,8 +34,6 @@ |
| 34 | return EINVAL; \ | 34 | return EINVAL; \ |
| 35 | } while (0) | 35 | } while (0) |
| 36 | 36 | ||
| 37 | #include "semaphore.h" | ||
| 38 | |||
| 39 | typedef struct barrier_t barrier_t; | 37 | typedef struct barrier_t barrier_t; |
| 40 | struct barrier_t | 38 | struct barrier_t |
| 41 | { | 39 | { |
lib/libc/mingw/winpthreads/clock.c+112-15| ... | @@ -4,15 +4,23 @@ | ... | @@ -4,15 +4,23 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifdef HAVE_CONFIG_H | ||
| 8 | #include "config.h" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #include <assert.h> | ||
| 7 | #include <errno.h> | 12 | #include <errno.h> |
| 8 | #include <stdint.h> | 13 | #include <stdint.h> |
| 9 | #include <time.h> | 14 | #include <time.h> |
| 15 | |||
| 16 | #define WIN32_LEAN_AND_MEAN | ||
| 10 | #include <windows.h> | 17 | #include <windows.h> |
| 11 | #ifndef IN_WINPTHREAD | 18 | |
| 12 | #define IN_WINPTHREAD 1 | 19 | #define WINPTHREAD_CLOCK_DECL WINPTHREAD_API |
| 13 | #endif | 20 | |
| 14 | #include "pthread.h" | 21 | /* public header files */ |
| 15 | #include "pthread_time.h" | 22 | #include "pthread_time.h" |
| 23 | /* internal header files */ | ||
| 16 | #include "misc.h" | 24 | #include "misc.h" |
| 17 | 25 | ||
| 18 | #define POW10_7 10000000 | 26 | #define POW10_7 10000000 |
| ... | @@ -51,7 +59,7 @@ static WINPTHREADS_INLINE int lc_set_errno(int result) | ... | @@ -51,7 +59,7 @@ static WINPTHREADS_INLINE int lc_set_errno(int result) |
| 51 | * If the function fails, the return value is -1, | 59 | * If the function fails, the return value is -1, |
| 52 | * with errno set to indicate the error. | 60 | * with errno set to indicate the error. |
| 53 | */ | 61 | */ |
| 54 | int clock_getres(clockid_t clock_id, struct timespec *res) | 62 | static int __clock_getres(clockid_t clock_id, struct _timespec64 *res) |
| 55 | { | 63 | { |
| 56 | clockid_t id = clock_id; | 64 | clockid_t id = clock_id; |
| 57 | 65 | ||
| ... | @@ -113,7 +121,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res) | ... | @@ -113,7 +121,7 @@ int clock_getres(clockid_t clock_id, struct timespec *res) |
| 113 | * If the function fails, the return value is -1, | 121 | * If the function fails, the return value is -1, |
| 114 | * with errno set to indicate the error. | 122 | * with errno set to indicate the error. |
| 115 | */ | 123 | */ |
| 116 | int clock_gettime(clockid_t clock_id, struct timespec *tp) | 124 | static int __clock_gettime(clockid_t clock_id, struct _timespec64 *tp) |
| 117 | { | 125 | { |
| 118 | unsigned __int64 t; | 126 | unsigned __int64 t; |
| 119 | LARGE_INTEGER pf, pc; | 127 | LARGE_INTEGER pf, pc; |
| ... | @@ -172,7 +180,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) | ... | @@ -172,7 +180,7 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) |
| 172 | return 0; | 180 | return 0; |
| 173 | } | 181 | } |
| 174 | 182 | ||
| 175 | case CLOCK_THREAD_CPUTIME_ID: | 183 | case CLOCK_THREAD_CPUTIME_ID: |
| 176 | { | 184 | { |
| 177 | if(0 == GetThreadTimes(GetCurrentThread(), &ct.ft, &et.ft, &kt.ft, &ut.ft)) | 185 | if(0 == GetThreadTimes(GetCurrentThread(), &ct.ft, &et.ft, &kt.ft, &ut.ft)) |
| 178 | return lc_set_errno(EINVAL); | 186 | return lc_set_errno(EINVAL); |
| ... | @@ -201,20 +209,20 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) | ... | @@ -201,20 +209,20 @@ int clock_gettime(clockid_t clock_id, struct timespec *tp) |
| 201 | * If the function fails, the return value is -1, | 209 | * If the function fails, the return value is -1, |
| 202 | * with errno set to indicate the error. | 210 | * with errno set to indicate the error. |
| 203 | */ | 211 | */ |
| 204 | int clock_nanosleep(clockid_t clock_id, int flags, | 212 | static int __clock_nanosleep(clockid_t clock_id, int flags, |
| 205 | const struct timespec *request, | 213 | const struct _timespec64 *request, |
| 206 | struct timespec *remain) | 214 | struct _timespec64 *remain) |
| 207 | { | 215 | { |
| 208 | struct timespec tp; | 216 | struct _timespec64 tp; |
| 209 | 217 | ||
| 210 | if (clock_id != CLOCK_REALTIME) | 218 | if (clock_id != CLOCK_REALTIME) |
| 211 | return lc_set_errno(EINVAL); | 219 | return lc_set_errno(EINVAL); |
| 212 | 220 | ||
| 213 | if (flags == 0) | 221 | if (flags == 0) |
| 214 | return nanosleep(request, remain); | 222 | return nanosleep64(request, remain); |
| 215 | 223 | ||
| 216 | /* TIMER_ABSTIME = 1 */ | 224 | /* TIMER_ABSTIME = 1 */ |
| 217 | clock_gettime(CLOCK_REALTIME, &tp); | 225 | __clock_gettime(CLOCK_REALTIME, &tp); |
| 218 | 226 | ||
| 219 | tp.tv_sec = request->tv_sec - tp.tv_sec; | 227 | tp.tv_sec = request->tv_sec - tp.tv_sec; |
| 220 | tp.tv_nsec = request->tv_nsec - tp.tv_nsec; | 228 | tp.tv_nsec = request->tv_nsec - tp.tv_nsec; |
| ... | @@ -223,7 +231,7 @@ int clock_nanosleep(clockid_t clock_id, int flags, | ... | @@ -223,7 +231,7 @@ int clock_nanosleep(clockid_t clock_id, int flags, |
| 223 | tp.tv_sec --; | 231 | tp.tv_sec --; |
| 224 | } | 232 | } |
| 225 | 233 | ||
| 226 | return nanosleep(&tp, remain); | 234 | return nanosleep64(&tp, remain); |
| 227 | } | 235 | } |
| 228 | 236 | ||
| 229 | /** | 237 | /** |
| ... | @@ -234,7 +242,7 @@ int clock_nanosleep(clockid_t clock_id, int flags, | ... | @@ -234,7 +242,7 @@ int clock_nanosleep(clockid_t clock_id, int flags, |
| 234 | * If the function fails, the return value is -1, | 242 | * If the function fails, the return value is -1, |
| 235 | * with errno set to indicate the error. | 243 | * with errno set to indicate the error. |
| 236 | */ | 244 | */ |
| 237 | int clock_settime(clockid_t clock_id, const struct timespec *tp) | 245 | static int __clock_settime(clockid_t clock_id, const struct _timespec64 *tp) |
| 238 | { | 246 | { |
| 239 | SYSTEMTIME st; | 247 | SYSTEMTIME st; |
| 240 | 248 | ||
| ... | @@ -255,3 +263,92 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) | ... | @@ -255,3 +263,92 @@ int clock_settime(clockid_t clock_id, const struct timespec *tp) |
| 255 | 263 | ||
| 256 | return 0; | 264 | return 0; |
| 257 | } | 265 | } |
| 266 | |||
| 267 | /** | ||
| 268 | * Versions to use with 64-bit time_t (struct _timespec64) | ||
| 269 | */ | ||
| 270 | |||
| 271 | int clock_getres64 (clockid_t clock_id, struct _timespec64 *tp) | ||
| 272 | { | ||
| 273 | return __clock_getres (clock_id, tp); | ||
| 274 | } | ||
| 275 | |||
| 276 | int clock_gettime64 (clockid_t clock_id, struct _timespec64 *tp) | ||
| 277 | { | ||
| 278 | return __clock_gettime (clock_id, tp); | ||
| 279 | } | ||
| 280 | |||
| 281 | int clock_settime64 (clockid_t clock_id, const struct _timespec64 *tp) | ||
| 282 | { | ||
| 283 | return __clock_settime (clock_id, tp); | ||
| 284 | } | ||
| 285 | |||
| 286 | int clock_nanosleep64 (clockid_t clock_id, int flags, | ||
| 287 | const struct _timespec64 *request, struct _timespec64 *remain) | ||
| 288 | { | ||
| 289 | return __clock_nanosleep (clock_id, flags, request, remain); | ||
| 290 | } | ||
| 291 | |||
| 292 | /** | ||
| 293 | * Versions to use with 32-bit time_t (struct _timespec32) | ||
| 294 | */ | ||
| 295 | |||
| 296 | int clock_getres32 (clockid_t clock_id, struct _timespec32 *tp) | ||
| 297 | { | ||
| 298 | struct _timespec64 tp64 = {0}; | ||
| 299 | |||
| 300 | if (__clock_getres (clock_id, &tp64) == -1) | ||
| 301 | return -1; | ||
| 302 | |||
| 303 | tp->tv_sec = (__time32_t) tp64.tv_sec; | ||
| 304 | tp->tv_nsec = tp64.tv_nsec; | ||
| 305 | |||
| 306 | return 0; | ||
| 307 | } | ||
| 308 | |||
| 309 | int clock_gettime32 (clockid_t clock_id, struct _timespec32 *tp) | ||
| 310 | { | ||
| 311 | struct _timespec64 tp64 = {0}; | ||
| 312 | |||
| 313 | if (__clock_gettime (clock_id, &tp64) == -1) | ||
| 314 | return -1; | ||
| 315 | |||
| 316 | if (tp64.tv_sec > INT_MAX) | ||
| 317 | { | ||
| 318 | _set_errno (EOVERFLOW); | ||
| 319 | return -1; | ||
| 320 | } | ||
| 321 | |||
| 322 | tp->tv_sec = (__time32_t) tp64.tv_sec; | ||
| 323 | tp->tv_nsec = tp64.tv_nsec; | ||
| 324 | |||
| 325 | return 0; | ||
| 326 | } | ||
| 327 | |||
| 328 | int clock_settime32 (clockid_t clock_id, const struct _timespec32 *tp) | ||
| 329 | { | ||
| 330 | struct _timespec64 tp64 = {.tv_sec = tp->tv_sec, .tv_nsec = tp->tv_nsec}; | ||
| 331 | return __clock_settime (clock_id, &tp64); | ||
| 332 | } | ||
| 333 | |||
| 334 | int clock_nanosleep32 (clockid_t clock_id, int flags, | ||
| 335 | const struct _timespec32 *request, struct _timespec32 *remain) | ||
| 336 | { | ||
| 337 | struct _timespec64 request64 = { | ||
| 338 | .tv_sec = request->tv_sec, | ||
| 339 | .tv_nsec = request->tv_nsec | ||
| 340 | }; | ||
| 341 | struct _timespec64 remain64 = {0}; | ||
| 342 | |||
| 343 | if (__clock_nanosleep (clock_id, flags, &request64, &remain64) == -1) | ||
| 344 | return -1; | ||
| 345 | |||
| 346 | assert (remain64.tv_sec <= INT_MAX); | ||
| 347 | |||
| 348 | if (remain != NULL) { | ||
| 349 | remain->tv_sec = (__time32_t)remain64.tv_sec; | ||
| 350 | remain->tv_nsec = remain64.tv_nsec; | ||
| 351 | } | ||
| 352 | |||
| 353 | return 0; | ||
| 354 | } |
lib/libc/mingw/winpthreads/cond.c+36-74| ... | @@ -24,17 +24,27 @@ | ... | @@ -24,17 +24,27 @@ |
| 24 | * Posix Condition Variables for Microsoft Windows. | 24 | * Posix Condition Variables for Microsoft Windows. |
| 25 | * 22-9-2010 Partly based on the ACE framework implementation. | 25 | * 22-9-2010 Partly based on the ACE framework implementation. |
| 26 | */ | 26 | */ |
| 27 | #include <windows.h> | 27 | |
| 28 | #include <stdio.h> | 28 | #ifdef HAVE_CONFIG_H |
| 29 | #include "config.h" | ||
| 30 | #endif | ||
| 31 | |||
| 29 | #include <malloc.h> | 32 | #include <malloc.h> |
| 33 | #include <stdio.h> | ||
| 30 | #include <time.h> | 34 | #include <time.h> |
| 35 | |||
| 36 | #define WIN32_LEAN_AND_MEAN | ||
| 37 | #include <windows.h> | ||
| 38 | |||
| 39 | #define WINPTHREAD_COND_DECL WINPTHREAD_API | ||
| 40 | |||
| 41 | /* public header files */ | ||
| 31 | #include "pthread.h" | 42 | #include "pthread.h" |
| 32 | #include "pthread_time.h" | 43 | #include "pthread_time.h" |
| 33 | #include "ref.h" | 44 | /* internal header files */ |
| 34 | #include "cond.h" | 45 | #include "cond.h" |
| 35 | #include "thread.h" | ||
| 36 | #include "misc.h" | 46 | #include "misc.h" |
| 37 | #include "winpthread_internal.h" | 47 | #include "thread.h" |
| 38 | 48 | ||
| 39 | #include "pthread_compat.h" | 49 | #include "pthread_compat.h" |
| 40 | 50 | ||
| ... | @@ -52,41 +62,13 @@ typedef struct sCondWaitHelper { | ... | @@ -52,41 +62,13 @@ typedef struct sCondWaitHelper { |
| 52 | 62 | ||
| 53 | int do_sema_b_wait_intern (HANDLE sema, int nointerrupt, DWORD timeout); | 63 | int do_sema_b_wait_intern (HANDLE sema, int nointerrupt, DWORD timeout); |
| 54 | 64 | ||
| 55 | #ifdef WINPTHREAD_DBG | ||
| 56 | static int print_state = 0; | ||
| 57 | static FILE *fo; | ||
| 58 | void cond_print_set(int state, FILE *f) | ||
| 59 | { | ||
| 60 | if (f) fo = f; | ||
| 61 | if (!fo) fo = stdout; | ||
| 62 | print_state = state; | ||
| 63 | } | ||
| 64 | |||
| 65 | void cond_print(volatile pthread_cond_t *c, char *txt) | ||
| 66 | { | ||
| 67 | if (!print_state) return; | ||
| 68 | cond_t *c_ = (cond_t *)*c; | ||
| 69 | if (c_ == NULL) { | ||
| 70 | fprintf(fo,"C%p %lu %s\n",(void *)*c,GetCurrentThreadId(),txt); | ||
| 71 | } else { | ||
| 72 | fprintf(fo,"C%p %lu V=%0X w=%ld %s\n", | ||
| 73 | (void *)*c, | ||
| 74 | GetCurrentThreadId(), | ||
| 75 | (int)c_->valid, | ||
| 76 | c_->waiters_count_, | ||
| 77 | txt | ||
| 78 | ); | ||
| 79 | } | ||
| 80 | } | ||
| 81 | #endif | ||
| 82 | |||
| 83 | static pthread_spinlock_t cond_locked = PTHREAD_SPINLOCK_INITIALIZER; | 65 | static pthread_spinlock_t cond_locked = PTHREAD_SPINLOCK_INITIALIZER; |
| 84 | 66 | ||
| 85 | static int | 67 | static int |
| 86 | cond_static_init (pthread_cond_t *c) | 68 | cond_static_init (pthread_cond_t *c) |
| 87 | { | 69 | { |
| 88 | int r = 0; | 70 | int r = 0; |
| 89 | 71 | ||
| 90 | pthread_spin_lock (&cond_locked); | 72 | pthread_spin_lock (&cond_locked); |
| 91 | if (c == NULL) | 73 | if (c == NULL) |
| 92 | r = EINVAL; | 74 | r = EINVAL; |
| ... | @@ -143,40 +125,6 @@ pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clock_id) | ... | @@ -143,40 +125,6 @@ pthread_condattr_setclock(pthread_condattr_t *a, clockid_t clock_id) |
| 143 | return 0; | 125 | return 0; |
| 144 | } | 126 | } |
| 145 | 127 | ||
| 146 | int | ||
| 147 | __pthread_clock_nanosleep (clockid_t clock_id, int flags, const struct timespec *rqtp, | ||
| 148 | 			 struct timespec *rmtp) | ||
| 149 | { | ||
| 150 | unsigned long long tick, tick2; | ||
| 151 | unsigned long long delay; | ||
| 152 | DWORD dw; | ||
| 153 | |||
| 154 | if (clock_id != CLOCK_REALTIME | ||
| 155 | && clock_id != CLOCK_MONOTONIC | ||
| 156 | && clock_id != CLOCK_PROCESS_CPUTIME_ID) | ||
| 157 | return EINVAL; | ||
| 158 | if ((flags & TIMER_ABSTIME) != 0) | ||
| 159 | delay = _pthread_rel_time_in_ms (rqtp); | ||
| 160 | else | ||
| 161 | delay = _pthread_time_in_ms_from_timespec (rqtp); | ||
| 162 | do | ||
| 163 | { | ||
| 164 | dw = (DWORD) (delay >= 99999ULL ? 99999ULL : delay); | ||
| 165 | tick = _pthread_time_in_ms (); | ||
| 166 | pthread_delay_np_ms (dw); | ||
| 167 | tick2 = _pthread_time_in_ms (); | ||
| 168 | tick2 -= tick; | ||
| 169 | if (tick2 >= delay) | ||
| 170 | delay = 0; | ||
| 171 | else | ||
| 172 | delay -= tick2; | ||
| 173 | } | ||
| 174 | while (delay != 0ULL); | ||
| 175 | if (rmtp) | ||
| 176 | memset (rmtp, 0, sizeof (*rmtp)); | ||
| 177 | return 0; | ||
| 178 | } | ||
| 179 | |||
| 180 | int | 128 | int |
| 181 | pthread_condattr_setpshared (pthread_condattr_t *a, int s) | 129 | pthread_condattr_setpshared (pthread_condattr_t *a, int s) |
| 182 | { | 130 | { |
| ... | @@ -218,7 +166,7 @@ pthread_cond_init (pthread_cond_t *c, const pthread_condattr_t *a) | ... | @@ -218,7 +166,7 @@ pthread_cond_init (pthread_cond_t *c, const pthread_condattr_t *a) |
| 218 | _c->sema_b = CreateSemaphore (NULL, /* no security */ | 166 | _c->sema_b = CreateSemaphore (NULL, /* no security */ |
| 219 | 0, /* initially 0 */ | 167 | 0, /* initially 0 */ |
| 220 | 0x7fffffff, /* max count */ | 168 | 0x7fffffff, /* max count */ |
| 221 | NULL); | 169 | NULL); |
| 222 | if (_c->sema_q == NULL || _c->sema_b == NULL) { | 170 | if (_c->sema_q == NULL || _c->sema_b == NULL) { |
| 223 | if (_c->sema_q != NULL) | 171 | if (_c->sema_q != NULL) |
| 224 | 	CloseHandle (_c->sema_q); | 172 | 	CloseHandle (_c->sema_q); |
| ... | @@ -356,7 +304,7 @@ pthread_cond_broadcast (pthread_cond_t *c) | ... | @@ -356,7 +304,7 @@ pthread_cond_broadcast (pthread_cond_t *c) |
| 356 | { | 304 | { |
| 357 | cond_t *_c; | 305 | cond_t *_c; |
| 358 | int r; | 306 | int r; |
| 359 | int relCnt = 0; | 307 | int relCnt = 0; |
| 360 | 308 | ||
| 361 | if (!c || !*c) | 309 | if (!c || !*c) |
| 362 | return EINVAL; | 310 | return EINVAL; |
| ... | @@ -465,7 +413,7 @@ tryagain: | ... | @@ -465,7 +413,7 @@ tryagain: |
| 465 | } | 413 | } |
| 466 | 414 | ||
| 467 | static int | 415 | static int |
| 468 | pthread_cond_timedwait_impl (pthread_cond_t *c, pthread_mutex_t *external_mutex, const struct timespec *t, int rel) | 416 | pthread_cond_timedwait_impl (pthread_cond_t *c, pthread_mutex_t *external_mutex, const struct _timespec64 *t, int rel) |
| 469 | { | 417 | { |
| 470 | sCondWaitHelper ch; | 418 | sCondWaitHelper ch; |
| 471 | DWORD dwr; | 419 | DWORD dwr; |
| ... | @@ -531,17 +479,31 @@ tryagain: | ... | @@ -531,17 +479,31 @@ tryagain: |
| 531 | } | 479 | } |
| 532 | 480 | ||
| 533 | int | 481 | int |
| 534 | pthread_cond_timedwait(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *t) | 482 | pthread_cond_timedwait64(pthread_cond_t *c, pthread_mutex_t *m, const struct _timespec64 *t) |
| 535 | { | 483 | { |
| 536 | return pthread_cond_timedwait_impl(c, m, t, 0); | 484 | return pthread_cond_timedwait_impl(c, m, t, 0); |
| 537 | } | 485 | } |
| 538 | 486 | ||
| 539 | int | 487 | int |
| 540 | pthread_cond_timedwait_relative_np(pthread_cond_t *c, pthread_mutex_t *m, const struct timespec *t) | 488 | pthread_cond_timedwait32(pthread_cond_t *c, pthread_mutex_t *m, const struct _timespec32 *t) |
| 489 | { | ||
| 490 | struct _timespec64 t64 = {.tv_sec = t->tv_sec, .tv_nsec = t->tv_nsec}; | ||
| 491 | return pthread_cond_timedwait_impl(c, m, &t64, 0); | ||
| 492 | } | ||
| 493 | |||
| 494 | int | ||
| 495 | pthread_cond_timedwait64_relative_np(pthread_cond_t *c, pthread_mutex_t *m, const struct _timespec64 *t) | ||
| 541 | { | 496 | { |
| 542 | return pthread_cond_timedwait_impl(c, m, t, 1); | 497 | return pthread_cond_timedwait_impl(c, m, t, 1); |
| 543 | } | 498 | } |
| 544 | 499 | ||
| 500 | int | ||
| 501 | pthread_cond_timedwait32_relative_np(pthread_cond_t *c, pthread_mutex_t *m, const struct _timespec32 *t) | ||
| 502 | { | ||
| 503 | struct _timespec64 t64 = {.tv_sec = t->tv_sec, .tv_nsec = t->tv_nsec}; | ||
| 504 | return pthread_cond_timedwait_impl(c, m, &t64, 1); | ||
| 505 | } | ||
| 506 | |||
| 545 | static void | 507 | static void |
| 546 | cleanup_wait (void *arg) | 508 | cleanup_wait (void *arg) |
| 547 | { | 509 | { |
| ... | @@ -751,5 +713,5 @@ do_sema_b_release(HANDLE sema, LONG count,CRITICAL_SECTION *cs, LONG *val) | ... | @@ -751,5 +713,5 @@ do_sema_b_release(HANDLE sema, LONG count,CRITICAL_SECTION *cs, LONG *val) |
| 751 | } | 713 | } |
| 752 | InterlockedExchangeAdd(val, -count); | 714 | InterlockedExchangeAdd(val, -count); |
| 753 | LeaveCriticalSection(cs); | 715 | LeaveCriticalSection(cs); |
| 754 | return EINVAL; | 716 | return EINVAL; |
| 755 | } | 717 | } |
lib/libc/mingw/winpthreads/cond.h+1-7| ... | @@ -23,8 +23,6 @@ | ... | @@ -23,8 +23,6 @@ |
| 23 | #ifndef WIN_PTHREADS_COND_H | 23 | #ifndef WIN_PTHREADS_COND_H |
| 24 | #define WIN_PTHREADS_COND_H | 24 | #define WIN_PTHREADS_COND_H |
| 25 | 25 | ||
| 26 | #include <windows.h> | ||
| 27 | |||
| 28 | #define CHECK_COND(c) \ | 26 | #define CHECK_COND(c) \ |
| 29 | do { \ | 27 | do { \ |
| 30 | if (!(c) || !*c || (*c == PTHREAD_COND_INITIALIZER) \ | 28 | if (!(c) || !*c || (*c == PTHREAD_COND_INITIALIZER) \ |
| ... | @@ -40,7 +38,7 @@ | ... | @@ -40,7 +38,7 @@ |
| 40 | typedef struct cond_t cond_t; | 38 | typedef struct cond_t cond_t; |
| 41 | struct cond_t | 39 | struct cond_t |
| 42 | { | 40 | { |
| 43 | unsigned int valid; | 41 | unsigned int valid; |
| 44 | int busy; | 42 | int busy; |
| 45 | LONG waiters_count_; /* Number of waiting threads. */ | 43 | LONG waiters_count_; /* Number of waiting threads. */ |
| 46 | LONG waiters_count_unblock_; /* Number of waiting threads whitch can be unblocked. */ | 44 | LONG waiters_count_unblock_; /* Number of waiting threads whitch can be unblocked. */ |
| ... | @@ -56,8 +54,4 @@ struct cond_t | ... | @@ -56,8 +54,4 @@ struct cond_t |
| 56 | became signaled. */ | 54 | became signaled. */ |
| 57 | }; | 55 | }; |
| 58 | 56 | ||
| 59 | void cond_print_set(int state, FILE *f); | ||
| 60 | |||
| 61 | void cond_print(volatile pthread_cond_t *c, char *txt); | ||
| 62 | |||
| 63 | #endif | 57 | #endif |
lib/libc/mingw/winpthreads/misc.c+15-2| ... | @@ -20,8 +20,16 @@ | ... | @@ -20,8 +20,16 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #ifdef HAVE_CONFIG_H | ||
| 24 | #include "config.h" | ||
| 25 | #endif | ||
| 26 | |||
| 27 | #define WIN32_LEAN_AND_MEAN | ||
| 23 | #include <windows.h> | 28 | #include <windows.h> |
| 29 | |||
| 30 | /* public header files */ | ||
| 24 | #include "pthread.h" | 31 | #include "pthread.h" |
| 32 | /* internal header files */ | ||
| 25 | #include "misc.h" | 33 | #include "misc.h" |
| 26 | 34 | ||
| 27 | void (WINAPI *_pthread_get_system_time_best_as_file_time) (LPFILETIME) = NULL; | 35 | void (WINAPI *_pthread_get_system_time_best_as_file_time) (LPFILETIME) = NULL; |
| ... | @@ -29,6 +37,8 @@ static ULONGLONG (WINAPI *_pthread_get_tick_count_64) (VOID); | ... | @@ -29,6 +37,8 @@ static ULONGLONG (WINAPI *_pthread_get_tick_count_64) (VOID); |
| 29 | HRESULT (WINAPI *_pthread_set_thread_description) (HANDLE, PCWSTR) = NULL; | 37 | HRESULT (WINAPI *_pthread_set_thread_description) (HANDLE, PCWSTR) = NULL; |
| 30 | 38 | ||
| 31 | #if defined(__GNUC__) || defined(__clang__) | 39 | #if defined(__GNUC__) || defined(__clang__) |
| 40 | #pragma GCC diagnostic push | ||
| 41 | #pragma GCC diagnostic ignored "-Wprio-ctor-dtor" | ||
| 32 | __attribute__((constructor(0))) | 42 | __attribute__((constructor(0))) |
| 33 | #endif | 43 | #endif |
| 34 | static void winpthreads_init(void) | 44 | static void winpthreads_init(void) |
| ... | @@ -55,6 +65,9 @@ static void winpthreads_init(void) | ... | @@ -55,6 +65,9 @@ static void winpthreads_init(void) |
| 55 | (HRESULT (WINAPI *)(HANDLE, PCWSTR))(void*) GetProcAddress(mod, "SetThreadDescription"); | 65 | (HRESULT (WINAPI *)(HANDLE, PCWSTR))(void*) GetProcAddress(mod, "SetThreadDescription"); |
| 56 | } | 66 | } |
| 57 | } | 67 | } |
| 68 | #if defined(__GNUC__) || defined(__clang__) | ||
| 69 | #pragma GCC diagnostic pop | ||
| 70 | #endif | ||
| 58 | 71 | ||
| 59 | #if defined(_MSC_VER) && !defined(__clang__) | 72 | #if defined(_MSC_VER) && !defined(__clang__) |
| 60 | /* Force a reference to __xc_t to prevent whole program optimization | 73 | /* Force a reference to __xc_t to prevent whole program optimization |
| ... | @@ -82,7 +95,7 @@ unsigned long long _pthread_time_in_ms(void) | ... | @@ -82,7 +95,7 @@ unsigned long long _pthread_time_in_ms(void) |
| 82 | - 0x19DB1DED53E8000ULL) / 10000ULL; | 95 | - 0x19DB1DED53E8000ULL) / 10000ULL; |
| 83 | } | 96 | } |
| 84 | 97 | ||
| 85 | unsigned long long _pthread_time_in_ms_from_timespec(const struct timespec *ts) | 98 | unsigned long long _pthread_time_in_ms_from_timespec(const struct _timespec64 *ts) |
| 86 | { | 99 | { |
| 87 | unsigned long long t = (unsigned long long) ts->tv_sec * 1000LL; | 100 | unsigned long long t = (unsigned long long) ts->tv_sec * 1000LL; |
| 88 | /* The +999999 is here to ensure that the division always rounds up */ | 101 | /* The +999999 is here to ensure that the division always rounds up */ |
| ... | @@ -91,7 +104,7 @@ unsigned long long _pthread_time_in_ms_from_timespec(const struct timespec *ts) | ... | @@ -91,7 +104,7 @@ unsigned long long _pthread_time_in_ms_from_timespec(const struct timespec *ts) |
| 91 | return t; | 104 | return t; |
| 92 | } | 105 | } |
| 93 | 106 | ||
| 94 | unsigned long long _pthread_rel_time_in_ms(const struct timespec *ts) | 107 | unsigned long long _pthread_rel_time_in_ms(const struct _timespec64 *ts) |
| 95 | { | 108 | { |
| 96 | unsigned long long t1 = _pthread_time_in_ms_from_timespec(ts); | 109 | unsigned long long t1 = _pthread_time_in_ms_from_timespec(ts); |
| 97 | unsigned long long t2 = _pthread_time_in_ms(); | 110 | unsigned long long t2 = _pthread_time_in_ms(); |
lib/libc/mingw/winpthreads/misc.h+4-31| ... | @@ -23,37 +23,10 @@ | ... | @@ -23,37 +23,10 @@ |
| 23 | #ifndef WIN_PTHREADS_MISC_H | 23 | #ifndef WIN_PTHREADS_MISC_H |
| 24 | #define WIN_PTHREADS_MISC_H | 24 | #define WIN_PTHREADS_MISC_H |
| 25 | 25 | ||
| 26 | #include <limits.h> | ||
| 27 | /* public header files */ | ||
| 26 | #include "pthread_compat.h" | 28 | #include "pthread_compat.h" |
| 27 | 29 | ||
| 28 | #ifndef assert | ||
| 29 | |||
| 30 | #ifndef ASSERT_TRACE | ||
| 31 | # define ASSERT_TRACE 0 | ||
| 32 | #else | ||
| 33 | # undef ASSERT_TRACE | ||
| 34 | # define ASSERT_TRACE 0 | ||
| 35 | #endif | ||
| 36 | |||
| 37 | # define assert(e) \ | ||
| 38 | ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ | ||
| 39 | "Assertion succeeded: (%s), file %s, line %d\n", \ | ||
| 40 | #e, __FILE__, (int) __LINE__), \ | ||
| 41 | fflush(stderr) : \ | ||
| 42 | 0) : \ | ||
| 43 | (fprintf(stderr, "Assertion failed: (%s), file %s, line %d\n", \ | ||
| 44 | #e, __FILE__, (int) __LINE__), exit(1), 0)) | ||
| 45 | |||
| 46 | # define fixme(e) \ | ||
| 47 | ((e) ? ((ASSERT_TRACE) ? fprintf(stderr, \ | ||
| 48 | "Assertion succeeded: (%s), file %s, line %d\n", \ | ||
| 49 | #e, __FILE__, (int) __LINE__), \ | ||
| 50 | fflush(stderr) : \ | ||
| 51 | 0) : \ | ||
| 52 | (fprintf(stderr, "FIXME: (%s), file %s, line %d\n", \ | ||
| 53 | #e, __FILE__, (int) __LINE__), 0, 0)) | ||
| 54 | |||
| 55 | #endif | ||
| 56 | |||
| 57 | #define PTR2INT(x)	((int)(uintptr_t)(x)) | 30 | #define PTR2INT(x)	((int)(uintptr_t)(x)) |
| 58 | 31 | ||
| 59 | #if SIZE_MAX>UINT_MAX | 32 | #if SIZE_MAX>UINT_MAX |
| ... | @@ -102,8 +75,8 @@ static WINPTHREADS_INLINE unsigned long dwMilliSecs(unsigned long long ms) | ... | @@ -102,8 +75,8 @@ static WINPTHREADS_INLINE unsigned long dwMilliSecs(unsigned long long ms) |
| 102 | } | 75 | } |
| 103 | 76 | ||
| 104 | unsigned long long _pthread_time_in_ms(void); | 77 | unsigned long long _pthread_time_in_ms(void); |
| 105 | unsigned long long _pthread_time_in_ms_from_timespec(const struct timespec *ts); | 78 | unsigned long long _pthread_time_in_ms_from_timespec(const struct _timespec64 *ts); |
| 106 | unsigned long long _pthread_rel_time_in_ms(const struct timespec *ts); | 79 | unsigned long long _pthread_rel_time_in_ms(const struct _timespec64 *ts); |
| 107 | unsigned long _pthread_wait_for_single_object (void *handle, unsigned long timeout); | 80 | unsigned long _pthread_wait_for_single_object (void *handle, unsigned long timeout); |
| 108 | unsigned long _pthread_wait_for_multiple_objects (unsigned long count, void **handles, unsigned int all, unsigned long timeout); | 81 | unsigned long _pthread_wait_for_multiple_objects (unsigned long count, void **handles, unsigned int all, unsigned long timeout); |
| 109 | 82 |
lib/libc/mingw/winpthreads/mutex.c+29-6| ... | @@ -21,11 +21,22 @@ | ... | @@ -21,11 +21,22 @@ |
| 21 | DEALINGS IN THE SOFTWARE. | 21 | DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #include <windows.h> | 24 | #ifdef HAVE_CONFIG_H |
| 25 | #include <stdio.h> | 25 | #include "config.h" |
| 26 | #endif | ||
| 27 | |||
| 26 | #include <malloc.h> | 28 | #include <malloc.h> |
| 27 | #include <stdbool.h> | 29 | #include <stdbool.h> |
| 30 | #include <stdio.h> | ||
| 31 | |||
| 32 | #define WIN32_LEAN_AND_MEAN | ||
| 33 | #include <windows.h> | ||
| 34 | |||
| 35 | #define WINPTHREAD_MUTEX_DECL WINPTHREAD_API | ||
| 36 | |||
| 37 | /* public header files */ | ||
| 28 | #include "pthread.h" | 38 | #include "pthread.h" |
| 39 | /* internal header files */ | ||
| 29 | #include "misc.h" | 40 | #include "misc.h" |
| 30 | 41 | ||
| 31 | typedef enum { | 42 | typedef enum { |
| ... | @@ -184,7 +195,8 @@ pthread_mutex_lock (pthread_mutex_t *m) | ... | @@ -184,7 +195,8 @@ pthread_mutex_lock (pthread_mutex_t *m) |
| 184 | return pthread_mutex_lock_intern (m, INFINITE); | 195 | return pthread_mutex_lock_intern (m, INFINITE); |
| 185 | } | 196 | } |
| 186 | 197 | ||
| 187 | int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts) | 198 | /* Internal version which always uses `struct _timespec64`. */ |
| 199 | static int __pthread_mutex_timedlock(pthread_mutex_t *m, const struct _timespec64 *ts) | ||
| 188 | { | 200 | { |
| 189 | unsigned long long patience; | 201 | unsigned long long patience; |
| 190 | if (ts != NULL) { | 202 | if (ts != NULL) { |
| ... | @@ -199,8 +211,19 @@ int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts) | ... | @@ -199,8 +211,19 @@ int pthread_mutex_timedlock(pthread_mutex_t *m, const struct timespec *ts) |
| 199 | return pthread_mutex_lock_intern(m, patience); | 211 | return pthread_mutex_lock_intern(m, patience); |
| 200 | } | 212 | } |
| 201 | 213 | ||
| 214 | int pthread_mutex_timedlock64(pthread_mutex_t *m, const struct _timespec64 *ts) | ||
| 215 | { | ||
| 216 | return __pthread_mutex_timedlock (m, ts); | ||
| 217 | } | ||
| 218 | |||
| 219 | int pthread_mutex_timedlock32(pthread_mutex_t *m, const struct _timespec32 *ts) | ||
| 220 | { | ||
| 221 | struct _timespec64 ts64 = {.tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec}; | ||
| 222 | return __pthread_mutex_timedlock (m, &ts64); | ||
| 223 | } | ||
| 224 | |||
| 202 | int pthread_mutex_unlock(pthread_mutex_t *m) | 225 | int pthread_mutex_unlock(pthread_mutex_t *m) |
| 203 | { | 226 | { |
| 204 | /* Here m might an initialiser of an error-checking or recursive mutex, in | 227 | /* Here m might an initialiser of an error-checking or recursive mutex, in |
| 205 | which case the behaviour is well-defined, so we can't skip this check. */ | 228 | which case the behaviour is well-defined, so we can't skip this check. */ |
| 206 | mutex_impl_t *mi = mutex_impl(m); | 229 | mutex_impl_t *mi = mutex_impl(m); |
| ... | @@ -305,9 +328,9 @@ int pthread_mutexattr_gettype(const pthread_mutexattr_t *a, int *type) | ... | @@ -305,9 +328,9 @@ int pthread_mutexattr_gettype(const pthread_mutexattr_t *a, int *type) |
| 305 | { | 328 | { |
| 306 | if (!a || !type) | 329 | if (!a || !type) |
| 307 | return EINVAL; | 330 | return EINVAL; |
| 308 | 	 | 331 | |
| 309 | *type = *a & 3; | 332 | *type = *a & 3; |
| 310 | 333 | ||
| 311 | return 0; | 334 | return 0; |
| 312 | } | 335 | } |
| 313 | 336 |
lib/libc/mingw/winpthreads/nanosleep.c+41-3| ... | @@ -4,12 +4,24 @@ | ... | @@ -4,12 +4,24 @@ |
| 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. | 4 | * No warranty is given; refer to the file DISCLAIMER.PD within this package. |
| 5 | */ | 5 | */ |
| 6 | 6 | ||
| 7 | #ifdef HAVE_CONFIG_H | ||
| 8 | #include "config.h" | ||
| 9 | #endif | ||
| 10 | |||
| 11 | #include <assert.h> | ||
| 7 | #include <errno.h> | 12 | #include <errno.h> |
| 8 | #include <time.h> | 13 | #include <time.h> |
| 14 | |||
| 15 | #define WIN32_LEAN_AND_MEAN | ||
| 9 | #include <windows.h> | 16 | #include <windows.h> |
| 17 | |||
| 18 | #define WINPTHREAD_NANOSLEEP_DECL WINPTHREAD_API | ||
| 19 | |||
| 20 | /* public header files */ | ||
| 10 | #include "pthread.h" | 21 | #include "pthread.h" |
| 11 | #include "pthread_time.h" | 22 | #include "pthread_time.h" |
| 12 | #include "winpthread_internal.h" | 23 | /* internal header files */ |
| 24 | #include "thread.h" | ||
| 13 | 25 | ||
| 14 | #define POW10_3 1000 | 26 | #define POW10_3 1000 |
| 15 | #define POW10_4 10000 | 27 | #define POW10_4 10000 |
| ... | @@ -25,7 +37,7 @@ | ... | @@ -25,7 +37,7 @@ |
| 25 | * If the function fails, the return value is -1, | 37 | * If the function fails, the return value is -1, |
| 26 | * with errno set to indicate the error. | 38 | * with errno set to indicate the error. |
| 27 | */ | 39 | */ |
| 28 | int nanosleep(const struct timespec *request, struct timespec *remain) | 40 | static int __nanosleep(const struct _timespec64 *request, struct _timespec64 *remain) |
| 29 | { | 41 | { |
| 30 | unsigned long ms, rc = 0; | 42 | unsigned long ms, rc = 0; |
| 31 | unsigned __int64 u64, want, real; | 43 | unsigned __int64 u64, want, real; |
| ... | @@ -48,7 +60,7 @@ int nanosleep(const struct timespec *request, struct timespec *remain) | ... | @@ -48,7 +60,7 @@ int nanosleep(const struct timespec *request, struct timespec *remain) |
| 48 | else ms = (unsigned long) u64; | 60 | else ms = (unsigned long) u64; |
| 49 | 61 | ||
| 50 | u64 -= ms; | 62 | u64 -= ms; |
| 51 | rc = pthread_delay_np_ms(ms); | 63 | rc = _pthread_delay_np_ms(ms); |
| 52 | } | 64 | } |
| 53 | 65 | ||
| 54 | if (rc != 0) { /* WAIT_IO_COMPLETION (192) */ | 66 | if (rc != 0) { /* WAIT_IO_COMPLETION (192) */ |
| ... | @@ -69,3 +81,29 @@ int nanosleep(const struct timespec *request, struct timespec *remain) | ... | @@ -69,3 +81,29 @@ int nanosleep(const struct timespec *request, struct timespec *remain) |
| 69 | 81 | ||
| 70 | return 0; | 82 | return 0; |
| 71 | } | 83 | } |
| 84 | |||
| 85 | int nanosleep64(const struct _timespec64 *request, struct _timespec64 *remain) | ||
| 86 | { | ||
| 87 | return __nanosleep (request, remain); | ||
| 88 | } | ||
| 89 | |||
| 90 | int nanosleep32(const struct _timespec32 *request, struct _timespec32 *remain) | ||
| 91 | { | ||
| 92 | struct _timespec64 request64 = { | ||
| 93 | .tv_sec = request->tv_sec, | ||
| 94 | .tv_nsec = request->tv_nsec | ||
| 95 | }; | ||
| 96 | struct _timespec64 remain64 = {0}; | ||
| 97 | |||
| 98 | if (__nanosleep (&request64, &remain64) == -1) | ||
| 99 | return -1; | ||
| 100 | |||
| 101 | assert (remain64.tv_sec <= INT_MAX); | ||
| 102 | |||
| 103 | if (remain != NULL) { | ||
| 104 | remain->tv_sec = (__time32_t)remain64.tv_sec; | ||
| 105 | remain->tv_nsec = remain64.tv_nsec; | ||
| 106 | } | ||
| 107 | |||
| 108 | return 0; | ||
| 109 | } |
lib/libc/mingw/winpthreads/ref.c deleted-34| ... | @@ -1,34 +0,0 @@ | ||
| 1 | /* | ||
| 2 | Copyright (c) 2011-2016 mingw-w64 project | ||
| 3 | |||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | copy of this software and associated documentation files (the "Software"), | ||
| 6 | to deal in the Software without restriction, including without limitation | ||
| 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | Software is furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in | ||
| 12 | all copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 20 | DEALINGS IN THE SOFTWARE. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #include <windows.h> | ||
| 24 | #include <winternl.h> | ||
| 25 | #include <stdio.h> | ||
| 26 | #include "pthread.h" | ||
| 27 | #include "semaphore.h" | ||
| 28 | #include "rwlock.h" | ||
| 29 | #include "cond.h" | ||
| 30 | #include "barrier.h" | ||
| 31 | #include "sem.h" | ||
| 32 | #include "ref.h" | ||
| 33 | #include "misc.h" | ||
| 34 | |||
lib/libc/mingw/winpthreads/ref.h deleted-29| ... | @@ -1,29 +0,0 @@ | ||
| 1 | /* | ||
| 2 | Copyright (c) 2011-2016 mingw-w64 project | ||
| 3 | |||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | copy of this software and associated documentation files (the "Software"), | ||
| 6 | to deal in the Software without restriction, including without limitation | ||
| 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | Software is furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in | ||
| 12 | all copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 20 | DEALINGS IN THE SOFTWARE. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef WIN_PTHREADS_REF_H | ||
| 24 | #define WIN_PTHREADS_REF_H | ||
| 25 | #include "pthread.h" | ||
| 26 | #include "semaphore.h" | ||
| 27 | |||
| 28 | #endif | ||
| 29 | |||
lib/libc/mingw/winpthreads/rwlock.c+57-48| ... | @@ -20,14 +20,25 @@ | ... | @@ -20,14 +20,25 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <windows.h> | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <stdio.h> | 24 | #include "config.h" |
| 25 | #endif | ||
| 26 | |||
| 27 | #include <assert.h> | ||
| 25 | #include <malloc.h> | 28 | #include <malloc.h> |
| 29 | #include <stdio.h> | ||
| 30 | |||
| 31 | #define WIN32_LEAN_AND_MEAN | ||
| 32 | #include <windows.h> | ||
| 33 | |||
| 34 | #define WINPTHREAD_RWLOCK_DECL WINPTHREAD_API | ||
| 35 | |||
| 36 | /* public header files */ | ||
| 26 | #include "pthread.h" | 37 | #include "pthread.h" |
| 27 | #include "thread.h" | 38 | /* internal header files */ |
| 28 | #include "ref.h" | ||
| 29 | #include "rwlock.h" | ||
| 30 | #include "misc.h" | 39 | #include "misc.h" |
| 40 | #include "rwlock.h" | ||
| 41 | #include "thread.h" | ||
| 31 | 42 | ||
| 32 | static pthread_spinlock_t rwl_global = PTHREAD_SPINLOCK_INITIALIZER; | 43 | static pthread_spinlock_t rwl_global = PTHREAD_SPINLOCK_INITIALIZER; |
| 33 | 44 | ||
| ... | @@ -36,9 +47,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t | ... | @@ -36,9 +47,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t |
| 36 | static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_unref(volatile pthread_rwlock_t *rwl, int res) | 47 | static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_unref(volatile pthread_rwlock_t *rwl, int res) |
| 37 | { | 48 | { |
| 38 | pthread_spin_lock(&rwl_global); | 49 | pthread_spin_lock(&rwl_global); |
| 39 | #ifdef WINPTHREAD_DBG | ||
| 40 | assert((((rwlock_t *)*rwl)->valid == LIFE_RWLOCK) && (((rwlock_t *)*rwl)->busy > 0)); | 50 | assert((((rwlock_t *)*rwl)->valid == LIFE_RWLOCK) && (((rwlock_t *)*rwl)->busy > 0)); |
| 41 | #endif | ||
| 42 | ((rwlock_t *)*rwl)->busy--; | 51 | ((rwlock_t *)*rwl)->busy--; |
| 43 | pthread_spin_unlock(&rwl_global); | 52 | pthread_spin_unlock(&rwl_global); |
| 44 | return res; | 53 | return res; |
| ... | @@ -87,7 +96,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_ref_destroy(pthread_rwlock_t *r | ... | @@ -87,7 +96,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwl_ref_destroy(pthread_rwlock_t *r |
| 87 | 96 | ||
| 88 | *rDestroy = (pthread_rwlock_t)NULL; | 97 | *rDestroy = (pthread_rwlock_t)NULL; |
| 89 | pthread_spin_lock(&rwl_global); | 98 | pthread_spin_lock(&rwl_global); |
| 90 | 99 | ||
| 91 | if (!rwl || !*rwl) r = EINVAL; | 100 | if (!rwl || !*rwl) r = EINVAL; |
| 92 | else { | 101 | else { |
| 93 | rwlock_t *r_ = (rwlock_t *)*rwl; | 102 | rwlock_t *r_ = (rwlock_t *)*rwl; |
| ... | @@ -128,30 +137,6 @@ static int rwlock_free_both_locks(rwlock_t *rwlock, int last_fail) | ... | @@ -128,30 +137,6 @@ static int rwlock_free_both_locks(rwlock_t *rwlock, int last_fail) |
| 128 | return ret; | 137 | return ret; |
| 129 | } | 138 | } |
| 130 | 139 | ||
| 131 | #ifdef WINPTHREAD_DBG | ||
| 132 | static int print_state = 0; | ||
| 133 | void rwl_print_set(int state) | ||
| 134 | { | ||
| 135 | print_state = state; | ||
| 136 | } | ||
| 137 | |||
| 138 | void rwl_print(volatile pthread_rwlock_t *rwl, char *txt) | ||
| 139 | { | ||
| 140 | if (!print_state) return; | ||
| 141 | rwlock_t *r = (rwlock_t *)*rwl; | ||
| 142 | if (r == NULL) { | ||
| 143 | printf("RWL%p %lu %s\n",(void *)*rwl,GetCurrentThreadId(),txt); | ||
| 144 | } else { | ||
| 145 | printf("RWL%p %lu V=%0X B=%d r=%ld w=%ld L=%p %s\n", | ||
| 146 | (void *)*rwl, | ||
| 147 | GetCurrentThreadId(), | ||
| 148 | (int)r->valid, | ||
| 149 | (int)r->busy, | ||
| 150 | 0L,0L,NULL,txt); | ||
| 151 | } | ||
| 152 | } | ||
| 153 | #endif | ||
| 154 | |||
| 155 | static pthread_spinlock_t cond_locked = PTHREAD_SPINLOCK_INITIALIZER; | 140 | static pthread_spinlock_t cond_locked = PTHREAD_SPINLOCK_INITIALIZER; |
| 156 | 141 | ||
| 157 | static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t *rw) | 142 | static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t *rw) |
| ... | @@ -165,7 +150,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t | ... | @@ -165,7 +150,7 @@ static WINPTHREADS_ATTRIBUTE((noinline)) int rwlock_static_init(pthread_rwlock_t |
| 165 | } | 150 | } |
| 166 | r = pthread_rwlock_init (rw, NULL); | 151 | r = pthread_rwlock_init (rw, NULL); |
| 167 | pthread_spin_unlock(&cond_locked); | 152 | pthread_spin_unlock(&cond_locked); |
| 168 | 153 | ||
| 169 | return r; | 154 | return r; |
| 170 | } | 155 | } |
| 171 | 156 | ||
| ... | @@ -178,7 +163,7 @@ int pthread_rwlock_init (pthread_rwlock_t *rwlock_, const pthread_rwlockattr_t * | ... | @@ -178,7 +163,7 @@ int pthread_rwlock_init (pthread_rwlock_t *rwlock_, const pthread_rwlockattr_t * |
| 178 | return EINVAL; | 163 | return EINVAL; |
| 179 | *rwlock_ = (pthread_rwlock_t)NULL; | 164 | *rwlock_ = (pthread_rwlock_t)NULL; |
| 180 | if ((rwlock = calloc(1, sizeof(*rwlock))) == NULL) | 165 | if ((rwlock = calloc(1, sizeof(*rwlock))) == NULL) |
| 181 | return ENOMEM; | 166 | return ENOMEM; |
| 182 | rwlock->valid = DEAD_RWLOCK; | 167 | rwlock->valid = DEAD_RWLOCK; |
| 183 | 168 | ||
| 184 | rwlock->nex_count = rwlock->nsh_count = rwlock->ncomplete = 0; | 169 | rwlock->nex_count = rwlock->nsh_count = rwlock->ncomplete = 0; |
| ... | @@ -203,18 +188,18 @@ int pthread_rwlock_init (pthread_rwlock_t *rwlock_, const pthread_rwlockattr_t * | ... | @@ -203,18 +188,18 @@ int pthread_rwlock_init (pthread_rwlock_t *rwlock_, const pthread_rwlockattr_t * |
| 203 | rwlock->valid = LIFE_RWLOCK; | 188 | rwlock->valid = LIFE_RWLOCK; |
| 204 | *rwlock_ = (pthread_rwlock_t)rwlock; | 189 | *rwlock_ = (pthread_rwlock_t)rwlock; |
| 205 | return r; | 190 | return r; |
| 206 | } | 191 | } |
| 207 | 192 | ||
| 208 | int pthread_rwlock_destroy (pthread_rwlock_t *rwlock_) | 193 | int pthread_rwlock_destroy (pthread_rwlock_t *rwlock_) |
| 209 | { | 194 | { |
| 210 | rwlock_t *rwlock; | 195 | rwlock_t *rwlock; |
| 211 | pthread_rwlock_t rDestroy; | 196 | pthread_rwlock_t rDestroy; |
| 212 | int r, r2; | 197 | int r, r2; |
| 213 | 198 | ||
| 214 | pthread_spin_lock(&cond_locked); | 199 | pthread_spin_lock(&cond_locked); |
| 215 | r = rwl_ref_destroy(rwlock_,&rDestroy); | 200 | r = rwl_ref_destroy(rwlock_,&rDestroy); |
| 216 | pthread_spin_unlock(&cond_locked); | 201 | pthread_spin_unlock(&cond_locked); |
| 217 | 202 | ||
| 218 | if(r) return r; | 203 | if(r) return r; |
| 219 | if(!rDestroy) return 0; /* destroyed a (still) static initialized rwl */ | 204 | if(!rDestroy) return 0; /* destroyed a (still) static initialized rwl */ |
| 220 | 205 | ||
| ... | @@ -245,7 +230,7 @@ int pthread_rwlock_destroy (pthread_rwlock_t *rwlock_) | ... | @@ -245,7 +230,7 @@ int pthread_rwlock_destroy (pthread_rwlock_t *rwlock_) |
| 245 | rwlock->valid = DEAD_RWLOCK; | 230 | rwlock->valid = DEAD_RWLOCK; |
| 246 | free((void *)rDestroy); | 231 | free((void *)rDestroy); |
| 247 | return 0; | 232 | return 0; |
| 248 | } | 233 | } |
| 249 | 234 | ||
| 250 | int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock_) | 235 | int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock_) |
| 251 | { | 236 | { |
| ... | @@ -279,7 +264,8 @@ int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock_) | ... | @@ -279,7 +264,8 @@ int pthread_rwlock_rdlock (pthread_rwlock_t *rwlock_) |
| 279 | return rwl_unref(rwlock_, ret); | 264 | return rwl_unref(rwlock_, ret); |
| 280 | } | 265 | } |
| 281 | 266 | ||
| 282 | int pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct timespec *ts) | 267 | /* Internal version which always uses `struct _timespec64`. */ |
| 268 | static int __pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct _timespec64 *ts) | ||
| 283 | { | 269 | { |
| 284 | rwlock_t *rwlock; | 270 | rwlock_t *rwlock; |
| 285 | int ret; | 271 | int ret; |
| ... | @@ -290,12 +276,12 @@ int pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct timespec | ... | @@ -290,12 +276,12 @@ int pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct timespec |
| 290 | if(ret != 0) return ret; | 276 | if(ret != 0) return ret; |
| 291 | 277 | ||
| 292 | rwlock = (rwlock_t *)*rwlock_; | 278 | rwlock = (rwlock_t *)*rwlock_; |
| 293 | if ((ret = pthread_mutex_timedlock (&rwlock->mex, ts)) != 0) | 279 | if ((ret = pthread_mutex_timedlock64 (&rwlock->mex, ts)) != 0) |
| 294 | return rwl_unref(rwlock_, ret); | 280 | return rwl_unref(rwlock_, ret); |
| 295 | InterlockedIncrement(&rwlock->nsh_count); | 281 | InterlockedIncrement(&rwlock->nsh_count); |
| 296 | if (rwlock->nsh_count == INT_MAX) | 282 | if (rwlock->nsh_count == INT_MAX) |
| 297 | { | 283 | { |
| 298 | ret = pthread_mutex_timedlock(&rwlock->mcomplete, ts); | 284 | ret = pthread_mutex_timedlock64(&rwlock->mcomplete, ts); |
| 299 | if (ret != 0) | 285 | if (ret != 0) |
| 300 | { | 286 | { |
| 301 | if (ret == ETIMEDOUT) | 287 | if (ret == ETIMEDOUT) |
| ... | @@ -312,6 +298,17 @@ int pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct timespec | ... | @@ -312,6 +298,17 @@ int pthread_rwlock_timedrdlock (pthread_rwlock_t *rwlock_, const struct timespec |
| 312 | return rwl_unref(rwlock_, ret); | 298 | return rwl_unref(rwlock_, ret); |
| 313 | } | 299 | } |
| 314 | 300 | ||
| 301 | int pthread_rwlock_timedrdlock64(pthread_rwlock_t *l, const struct _timespec64 *ts) | ||
| 302 | { | ||
| 303 | return __pthread_rwlock_timedrdlock (l, ts); | ||
| 304 | } | ||
| 305 | |||
| 306 | int pthread_rwlock_timedrdlock32(pthread_rwlock_t *l, const struct _timespec32 *ts) | ||
| 307 | { | ||
| 308 | struct _timespec64 ts64 = {.tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec}; | ||
| 309 | return __pthread_rwlock_timedrdlock (l, &ts64); | ||
| 310 | } | ||
| 311 | |||
| 315 | int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock_) | 312 | int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock_) |
| 316 | { | 313 | { |
| 317 | rwlock_t *rwlock; | 314 | rwlock_t *rwlock; |
| ... | @@ -340,7 +337,7 @@ int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock_) | ... | @@ -340,7 +337,7 @@ int pthread_rwlock_tryrdlock (pthread_rwlock_t *rwlock_) |
| 340 | } | 337 | } |
| 341 | ret = pthread_mutex_unlock(&rwlock->mex); | 338 | ret = pthread_mutex_unlock(&rwlock->mex); |
| 342 | return rwl_unref(rwlock_,ret); | 339 | return rwl_unref(rwlock_,ret); |
| 343 | } | 340 | } |
| 344 | 341 | ||
| 345 | int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock_) | 342 | int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock_) |
| 346 | { | 343 | { |
| ... | @@ -378,7 +375,7 @@ int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock_) | ... | @@ -378,7 +375,7 @@ int pthread_rwlock_trywrlock (pthread_rwlock_t *rwlock_) |
| 378 | } | 375 | } |
| 379 | rwlock->nex_count = 1; | 376 | rwlock->nex_count = 1; |
| 380 | return rwl_unref(rwlock_, 0); | 377 | return rwl_unref(rwlock_, 0); |
| 381 | } | 378 | } |
| 382 | 379 | ||
| 383 | int pthread_rwlock_unlock (pthread_rwlock_t *rwlock_) | 380 | int pthread_rwlock_unlock (pthread_rwlock_t *rwlock_) |
| 384 | { | 381 | { |
| ... | @@ -409,7 +406,7 @@ int pthread_rwlock_unlock (pthread_rwlock_t *rwlock_) | ... | @@ -409,7 +406,7 @@ int pthread_rwlock_unlock (pthread_rwlock_t *rwlock_) |
| 409 | ret = rwlock_free_both_locks(rwlock, 0); | 406 | ret = rwlock_free_both_locks(rwlock, 0); |
| 410 | } | 407 | } |
| 411 | return rwl_unref(rwlock_, ret); | 408 | return rwl_unref(rwlock_, ret); |
| 412 | } | 409 | } |
| 413 | 410 | ||
| 414 | static void st_cancelwrite (void *arg) | 411 | static void st_cancelwrite (void *arg) |
| 415 | { | 412 | { |
| ... | @@ -459,7 +456,8 @@ int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock_) | ... | @@ -459,7 +456,8 @@ int pthread_rwlock_wrlock (pthread_rwlock_t *rwlock_) |
| 459 | return rwl_unref(rwlock_,ret); | 456 | return rwl_unref(rwlock_,ret); |
| 460 | } | 457 | } |
| 461 | 458 | ||
| 462 | int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec *ts) | 459 | /* Internal version which always uses `struct _timespec64`. */ |
| 460 | static int __pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct _timespec64 *ts) | ||
| 463 | { | 461 | { |
| 464 | int ret; | 462 | int ret; |
| 465 | rwlock_t *rwlock; | 463 | rwlock_t *rwlock; |
| ... | @@ -471,10 +469,10 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec | ... | @@ -471,10 +469,10 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec |
| 471 | return ret; | 469 | return ret; |
| 472 | rwlock = (rwlock_t *)*rwlock_; | 470 | rwlock = (rwlock_t *)*rwlock_; |
| 473 | 471 | ||
| 474 | ret = pthread_mutex_timedlock(&rwlock->mex, ts); | 472 | ret = pthread_mutex_timedlock64(&rwlock->mex, ts); |
| 475 | if (ret != 0) | 473 | if (ret != 0) |
| 476 | return rwl_unref(rwlock_,ret); | 474 | return rwl_unref(rwlock_,ret); |
| 477 | ret = pthread_mutex_timedlock (&rwlock->mcomplete, ts); | 475 | ret = pthread_mutex_timedlock64(&rwlock->mcomplete, ts); |
| 478 | if (ret != 0) | 476 | if (ret != 0) |
| 479 | { | 477 | { |
| 480 | pthread_mutex_unlock(&rwlock->mex); | 478 | pthread_mutex_unlock(&rwlock->mex); |
| ... | @@ -492,7 +490,7 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec | ... | @@ -492,7 +490,7 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec |
| 492 | rwlock->ncomplete = -rwlock->nsh_count; | 490 | rwlock->ncomplete = -rwlock->nsh_count; |
| 493 | pthread_cleanup_push(st_cancelwrite, (void *) rwlock); | 491 | pthread_cleanup_push(st_cancelwrite, (void *) rwlock); |
| 494 | do { | 492 | do { |
| 495 | 	ret = pthread_cond_timedwait(&rwlock->ccomplete, &rwlock->mcomplete, ts); | 493 | 	ret = pthread_cond_timedwait64(&rwlock->ccomplete, &rwlock->mcomplete, ts); |
| 496 | } while (rwlock->ncomplete < 0 && !ret); | 494 | } while (rwlock->ncomplete < 0 && !ret); |
| 497 | pthread_cleanup_pop(!ret ? 0 : 1); | 495 | pthread_cleanup_pop(!ret ? 0 : 1); |
| 498 | 496 | ||
| ... | @@ -505,6 +503,17 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec | ... | @@ -505,6 +503,17 @@ int pthread_rwlock_timedwrlock (pthread_rwlock_t *rwlock_, const struct timespec |
| 505 | return rwl_unref(rwlock_,ret); | 503 | return rwl_unref(rwlock_,ret); |
| 506 | } | 504 | } |
| 507 | 505 | ||
| 506 | int pthread_rwlock_timedwrlock64(pthread_rwlock_t *rwlock, const struct _timespec64 *ts) | ||
| 507 | { | ||
| 508 | return __pthread_rwlock_timedwrlock (rwlock, ts); | ||
| 509 | } | ||
| 510 | |||
| 511 | int pthread_rwlock_timedwrlock32(pthread_rwlock_t *rwlock, const struct _timespec32 *ts) | ||
| 512 | { | ||
| 513 | struct _timespec64 ts64 = {.tv_sec = ts->tv_sec, .tv_nsec = ts->tv_nsec}; | ||
| 514 | return __pthread_rwlock_timedwrlock (rwlock, &ts64); | ||
| 515 | } | ||
| 516 | |||
| 508 | int pthread_rwlockattr_destroy(pthread_rwlockattr_t *a) | 517 | int pthread_rwlockattr_destroy(pthread_rwlockattr_t *a) |
| 509 | { | 518 | { |
| 510 | if (!a) | 519 | if (!a) |
lib/libc/mingw/winpthreads/rwlock.h-3| ... | @@ -43,7 +43,4 @@ struct rwlock_t { | ... | @@ -43,7 +43,4 @@ struct rwlock_t { |
| 43 | #define RWL_SET	0x01 | 43 | #define RWL_SET	0x01 |
| 44 | #define RWL_TRY	0x02 | 44 | #define RWL_TRY	0x02 |
| 45 | 45 | ||
| 46 | void rwl_print(volatile pthread_rwlock_t *rwl, char *txt); | ||
| 47 | void rwl_print_set(int state); | ||
| 48 | |||
| 49 | #endif | 46 | #endif |
lib/libc/mingw/winpthreads/sched.c+11-3| ... | @@ -20,12 +20,20 @@ | ... | @@ -20,12 +20,20 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <windows.h> | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include "config.h" | ||
| 25 | #endif | ||
| 26 | |||
| 24 | #include <stdio.h> | 27 | #include <stdio.h> |
| 25 | #include "pthread.h" | ||
| 26 | #include "thread.h" | ||
| 27 | 28 | ||
| 29 | #define WIN32_LEAN_AND_MEAN | ||
| 30 | #include <windows.h> | ||
| 31 | |||
| 32 | /* public header files */ | ||
| 33 | #include "pthread.h" | ||
| 34 | /* internal header files */ | ||
| 28 | #include "misc.h" | 35 | #include "misc.h" |
| 36 | #include "thread.h" | ||
| 29 | 37 | ||
| 30 | int sched_get_priority_min(int pol) | 38 | int sched_get_priority_min(int pol) |
| 31 | { | 39 | { |
lib/libc/mingw/winpthreads/sem.c+28-8| ... | @@ -20,15 +20,23 @@ | ... | @@ -20,15 +20,23 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <windows.h> | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <stdio.h> | 24 | #include "config.h" |
| 25 | #endif | ||
| 26 | |||
| 25 | #include <malloc.h> | 27 | #include <malloc.h> |
| 28 | #include <stdio.h> | ||
| 29 | |||
| 30 | #define WIN32_LEAN_AND_MEAN | ||
| 31 | #include <windows.h> | ||
| 32 | |||
| 33 | /* public header files */ | ||
| 26 | #include "pthread.h" | 34 | #include "pthread.h" |
| 27 | #include "thread.h" | ||
| 28 | #include "misc.h" | ||
| 29 | #include "semaphore.h" | 35 | #include "semaphore.h" |
| 36 | /* internal header files */ | ||
| 37 | #include "misc.h" | ||
| 30 | #include "sem.h" | 38 | #include "sem.h" |
| 31 | #include "ref.h" | 39 | #include "thread.h" |
| 32 | 40 | ||
| 33 | int do_sema_b_wait_intern (HANDLE sema, int nointerrupt, DWORD timeout); | 41 | int do_sema_b_wait_intern (HANDLE sema, int nointerrupt, DWORD timeout); |
| 34 | 42 | ||
| ... | @@ -212,8 +220,9 @@ sem_wait (sem_t *sem) | ... | @@ -212,8 +220,9 @@ sem_wait (sem_t *sem) |
| 212 | return sem_result (ret); | 220 | return sem_result (ret); |
| 213 | } | 221 | } |
| 214 | 222 | ||
| 215 | int | 223 | /* Internal version which always uses `struct _timespec64`. */ |
| 216 | sem_timedwait (sem_t *sem, const struct timespec *t) | 224 | static int |
| 225 | __sem_timedwait (sem_t *sem, const struct _timespec64 *t) | ||
| 217 | { | 226 | { |
| 218 | int cur_v, ret = 0; | 227 | int cur_v, ret = 0; |
| 219 | DWORD dwr; | 228 | DWORD dwr; |
| ... | @@ -251,6 +260,17 @@ sem_timedwait (sem_t *sem, const struct timespec *t) | ... | @@ -251,6 +260,17 @@ sem_timedwait (sem_t *sem, const struct timespec *t) |
| 251 | return sem_result (ret); | 260 | return sem_result (ret); |
| 252 | } | 261 | } |
| 253 | 262 | ||
| 263 | int sem_timedwait64(sem_t *sem, const struct _timespec64 *t) | ||
| 264 | { | ||
| 265 | return __sem_timedwait (sem, t); | ||
| 266 | } | ||
| 267 | |||
| 268 | int sem_timedwait32(sem_t *sem, const struct _timespec32 *t) | ||
| 269 | { | ||
| 270 | struct _timespec64 t64 = {.tv_sec = t->tv_sec, .tv_nsec = t->tv_nsec}; | ||
| 271 | return __sem_timedwait (sem, &t64); | ||
| 272 | } | ||
| 273 | |||
| 254 | int | 274 | int |
| 255 | sem_post (sem_t *sem) | 275 | sem_post (sem_t *sem) |
| 256 | { | 276 | { |
| ... | @@ -350,5 +370,5 @@ sem_getvalue (sem_t *sem, int *sval) | ... | @@ -350,5 +370,5 @@ sem_getvalue (sem_t *sem, int *sval) |
| 350 | 370 | ||
| 351 | *sval = (int) sv->value; | 371 | *sval = (int) sv->value; |
| 352 | pthread_mutex_unlock (&sv->vlock); | 372 | pthread_mutex_unlock (&sv->vlock); |
| 353 | return 0; | 373 | return 0; |
| 354 | } | 374 | } |
lib/libc/mingw/winpthreads/sem.h-2| ... | @@ -23,8 +23,6 @@ | ... | @@ -23,8 +23,6 @@ |
| 23 | #ifndef WIN_SEM | 23 | #ifndef WIN_SEM |
| 24 | #define WIN_SEM | 24 | #define WIN_SEM |
| 25 | 25 | ||
| 26 | #include <windows.h> | ||
| 27 | |||
| 28 | #define LIFE_SEM 0xBAB1F00D | 26 | #define LIFE_SEM 0xBAB1F00D |
| 29 | #define DEAD_SEM 0xDEADBEEF | 27 | #define DEAD_SEM 0xDEADBEEF |
| 30 | 28 |
lib/libc/mingw/winpthreads/spinlock.c+9-1| ... | @@ -21,8 +21,16 @@ | ... | @@ -21,8 +21,16 @@ |
| 21 | DEALINGS IN THE SOFTWARE. | 21 | DEALINGS IN THE SOFTWARE. |
| 22 | */ | 22 | */ |
| 23 | 23 | ||
| 24 | #ifdef HAVE_CONFIG_H | ||
| 25 | #include "config.h" | ||
| 26 | #endif | ||
| 27 | |||
| 28 | #define WIN32_LEAN_AND_MEAN | ||
| 24 | #include <windows.h> | 29 | #include <windows.h> |
| 30 | |||
| 31 | /* public header files */ | ||
| 25 | #include "pthread.h" | 32 | #include "pthread.h" |
| 33 | /* internal header files */ | ||
| 26 | #include "misc.h" | 34 | #include "misc.h" |
| 27 | 35 | ||
| 28 | /* We use the pthread_spinlock_t itself as a lock: | 36 | /* We use the pthread_spinlock_t itself as a lock: |
| ... | @@ -56,7 +64,7 @@ pthread_spin_lock (pthread_spinlock_t *lock) | ... | @@ -56,7 +64,7 @@ pthread_spin_lock (pthread_spinlock_t *lock) |
| 56 | } while (*lk == 0); | 64 | } while (*lk == 0); |
| 57 | return 0; | 65 | return 0; |
| 58 | } | 66 | } |
| 59 | 67 | ||
| 60 | int | 68 | int |
| 61 | pthread_spin_trylock (pthread_spinlock_t *lock) | 69 | pthread_spin_trylock (pthread_spinlock_t *lock) |
| 62 | { | 70 | { |
lib/libc/mingw/winpthreads/thread.c+55-57| ... | @@ -20,16 +20,27 @@ | ... | @@ -20,16 +20,27 @@ |
| 20 | DEALINGS IN THE SOFTWARE. | 20 | DEALINGS IN THE SOFTWARE. |
| 21 | */ | 21 | */ |
| 22 | 22 | ||
| 23 | #include <windows.h> | 23 | #ifdef HAVE_CONFIG_H |
| 24 | #include <strsafe.h> | 24 | #include "config.h" |
| 25 | #include <stdio.h> | 25 | #endif |
| 26 | #include <stdlib.h> | 26 | |
| 27 | #include <malloc.h> | 27 | #include <malloc.h> |
| 28 | #include <signal.h> | 28 | #include <signal.h> |
| 29 | #include <stdio.h> | ||
| 30 | #include <stdlib.h> | ||
| 31 | #include <wchar.h> | ||
| 32 | |||
| 33 | #define WIN32_LEAN_AND_MEAN | ||
| 34 | #include <windows.h> | ||
| 35 | #include <strsafe.h> | ||
| 36 | |||
| 37 | #define WINPTHREAD_THREAD_DECL WINPTHREAD_API | ||
| 38 | |||
| 39 | /* public header files */ | ||
| 29 | #include "pthread.h" | 40 | #include "pthread.h" |
| 30 | #include "thread.h" | 41 | /* internal header files */ |
| 31 | #include "misc.h" | 42 | #include "misc.h" |
| 32 | #include "winpthread_internal.h" | 43 | #include "thread.h" |
| 33 | 44 | ||
| 34 | static _pthread_v *__pthread_self_lite (void); | 45 | static _pthread_v *__pthread_self_lite (void); |
| 35 | 46 | ||
| ... | @@ -537,34 +548,6 @@ WINPTHREADS_ATTRIBUTE((WINPTHREADS_SECTION(".CRT$XLF"))) | ... | @@ -537,34 +548,6 @@ WINPTHREADS_ATTRIBUTE((WINPTHREADS_SECTION(".CRT$XLF"))) |
| 537 | extern const PIMAGE_TLS_CALLBACK __xl_f; | 548 | extern const PIMAGE_TLS_CALLBACK __xl_f; |
| 538 | const PIMAGE_TLS_CALLBACK __xl_f = __dyn_tls_pthread; | 549 | const PIMAGE_TLS_CALLBACK __xl_f = __dyn_tls_pthread; |
| 539 | 550 | ||
| 540 | |||
| 541 | #ifdef WINPTHREAD_DBG | ||
| 542 | static int print_state = 0; | ||
| 543 | void thread_print_set (int state) | ||
| 544 | { | ||
| 545 | print_state = state; | ||
| 546 | } | ||
| 547 | |||
| 548 | void | ||
| 549 | thread_print (volatile pthread_t t, char *txt) | ||
| 550 | { | ||
| 551 | if (!print_state) | ||
| 552 | return; | ||
| 553 | if (!t) | ||
| 554 | printf("T%p %lu %s\n",NULL,GetCurrentThreadId(),txt); | ||
| 555 | else | ||
| 556 | { | ||
| 557 | 	printf("T%p %lu V=%0X H=%p %s\n", | ||
| 558 | 	 (void *) __pth_gpointer_locked (t), | ||
| 559 | 	 GetCurrentThreadId(), | ||
| 560 | 	 (__pth_gpointer_locked (t))->valid, | ||
| 561 | 	 (__pth_gpointer_locked (t))->h, | ||
| 562 | 	 txt | ||
| 563 | 	 ); | ||
| 564 | } | ||
| 565 | } | ||
| 566 | #endif | ||
| 567 | |||
| 568 | /* Internal collect-once structure. */ | 551 | /* Internal collect-once structure. */ |
| 569 | typedef struct collect_once_t { | 552 | typedef struct collect_once_t { |
| 570 | pthread_once_t *o; | 553 | pthread_once_t *o; |
| ... | @@ -677,8 +660,8 @@ pthread_timechange_handler_np(void *dummy) | ... | @@ -677,8 +660,8 @@ pthread_timechange_handler_np(void *dummy) |
| 677 | 660 | ||
| 678 | /* Compatibility routine for pthread-win32. It waits for ellapse of | 661 | /* Compatibility routine for pthread-win32. It waits for ellapse of |
| 679 | interval and additionally checks for possible thread-cancelation. */ | 662 | interval and additionally checks for possible thread-cancelation. */ |
| 680 | int | 663 | static int |
| 681 | pthread_delay_np (const struct timespec *interval) | 664 | __pthread_delay_np (const struct _timespec64 *interval) |
| 682 | { | 665 | { |
| 683 | DWORD to = (!interval ? 0 : dwMilliSecs (_pthread_time_in_ms_from_timespec (interval))); | 666 | DWORD to = (!interval ? 0 : dwMilliSecs (_pthread_time_in_ms_from_timespec (interval))); |
| 684 | struct _pthread_v *s = __pthread_self_lite (); | 667 | struct _pthread_v *s = __pthread_self_lite (); |
| ... | @@ -699,10 +682,21 @@ pthread_delay_np (const struct timespec *interval) | ... | @@ -699,10 +682,21 @@ pthread_delay_np (const struct timespec *interval) |
| 699 | return 0; | 682 | return 0; |
| 700 | } | 683 | } |
| 701 | 684 | ||
| 702 | int pthread_delay_np_ms (DWORD to); | 685 | int |
| 686 | pthread_delay64_np (const struct _timespec64 *interval) | ||
| 687 | { | ||
| 688 | return __pthread_delay_np(interval); | ||
| 689 | } | ||
| 690 | |||
| 691 | int | ||
| 692 | pthread_delay32_np (const struct _timespec32 *interval) | ||
| 693 | { | ||
| 694 | struct _timespec64 interval64 = {.tv_sec = interval->tv_sec, .tv_nsec = interval->tv_nsec}; | ||
| 695 | return __pthread_delay_np(&interval64); | ||
| 696 | } | ||
| 703 | 697 | ||
| 704 | int | 698 | int |
| 705 | pthread_delay_np_ms (DWORD to) | 699 | _pthread_delay_np_ms (DWORD to) |
| 706 | { | 700 | { |
| 707 | struct _pthread_v *s = __pthread_self_lite (); | 701 | struct _pthread_v *s = __pthread_self_lite (); |
| 708 | 702 | ||
| ... | @@ -725,7 +719,7 @@ pthread_delay_np_ms (DWORD to) | ... | @@ -725,7 +719,7 @@ pthread_delay_np_ms (DWORD to) |
| 725 | /* Compatibility routine for pthread-win32. It returns the | 719 | /* Compatibility routine for pthread-win32. It returns the |
| 726 | amount of available CPUs on system. */ | 720 | amount of available CPUs on system. */ |
| 727 | int | 721 | int |
| 728 | pthread_num_processors_np(void) | 722 | pthread_num_processors_np(void) |
| 729 | { | 723 | { |
| 730 | int r = 0; | 724 | int r = 0; |
| 731 | DWORD_PTR ProcessAffinityMask, SystemAffinityMask; | 725 | DWORD_PTR ProcessAffinityMask, SystemAffinityMask; |
| ... | @@ -742,10 +736,10 @@ pthread_num_processors_np(void) | ... | @@ -742,10 +736,10 @@ pthread_num_processors_np(void) |
| 742 | /* Compatiblity routine for pthread-win32. Allows to set amount of used | 736 | /* Compatiblity routine for pthread-win32. Allows to set amount of used |
| 743 | CPUs for process. */ | 737 | CPUs for process. */ |
| 744 | int | 738 | int |
| 745 | pthread_set_num_processors_np(int n) | 739 | pthread_set_num_processors_np(int n) |
| 746 | { | 740 | { |
| 747 | DWORD_PTR ProcessAffinityMask, ProcessNewAffinityMask = 0, SystemAffinityMask; | 741 | DWORD_PTR ProcessAffinityMask, ProcessNewAffinityMask = 0, SystemAffinityMask; |
| 748 | int r = 0; | 742 | int r = 0; |
| 749 | /* need at least 1 */ | 743 | /* need at least 1 */ |
| 750 | n = n ? n : 1; | 744 | n = n ? n : 1; |
| 751 | if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) | 745 | if (GetProcessAffinityMask (GetCurrentProcess (), &ProcessAffinityMask, &SystemAffinityMask)) |
| ... | @@ -878,7 +872,7 @@ pthread_key_delete (pthread_key_t key) | ... | @@ -878,7 +872,7 @@ pthread_key_delete (pthread_key_t key) |
| 878 | return EINVAL; | 872 | return EINVAL; |
| 879 | 873 | ||
| 880 | pthread_rwlock_wrlock (&_pthread_key_lock); | 874 | pthread_rwlock_wrlock (&_pthread_key_lock); |
| 881 | 875 | ||
| 882 | _pthread_key_dest[key] = NULL; | 876 | _pthread_key_dest[key] = NULL; |
| 883 | 877 | ||
| 884 | /* Start next search from our location */ | 878 | /* Start next search from our location */ |
| ... | @@ -910,7 +904,7 @@ pthread_setspecific (pthread_key_t key, const void *value) | ... | @@ -910,7 +904,7 @@ pthread_setspecific (pthread_key_t key, const void *value) |
| 910 | { | 904 | { |
| 911 | DWORD lasterr = GetLastError (); | 905 | DWORD lasterr = GetLastError (); |
| 912 | _pthread_v *t = __pthread_self_lite (); | 906 | _pthread_v *t = __pthread_self_lite (); |
| 913 | 907 | ||
| 914 | pthread_spin_lock (&t->spin_keys); | 908 | pthread_spin_lock (&t->spin_keys); |
| 915 | 909 | ||
| 916 | if (key >= t->keymax) | 910 | if (key >= t->keymax) |
| ... | @@ -1522,7 +1516,7 @@ void _fpreset (void); | ... | @@ -1522,7 +1516,7 @@ void _fpreset (void); |
| 1522 | 1516 | ||
| 1523 | #if defined(__i386__) | 1517 | #if defined(__i386__) |
| 1524 | /* Align ESP on 16-byte boundaries. */ | 1518 | /* Align ESP on 16-byte boundaries. */ |
| 1525 | # if __GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2) | 1519 | # if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 2)) |
| 1526 | __attribute__((force_align_arg_pointer)) | 1520 | __attribute__((force_align_arg_pointer)) |
| 1527 | # endif | 1521 | # endif |
| 1528 | #endif | 1522 | #endif |
| ... | @@ -1553,17 +1547,7 @@ pthread_create_wrapper (void *args) | ... | @@ -1553,17 +1547,7 @@ pthread_create_wrapper (void *args) |
| 1553 | if (tv->func) | 1547 | if (tv->func) |
| 1554 | trslt = (intptr_t) tv->func(tv->ret_arg); | 1548 | trslt = (intptr_t) tv->func(tv->ret_arg); |
| 1555 | #ifdef __SEH__ | 1549 | #ifdef __SEH__ |
| 1556 | 	asm ("\tnop\n\t.tl_end: nop\n" | 1550 | asm ("\tnop\n\t.tl_end: nop\n"); |
| 1557 | #ifdef __arm__ | ||
| 1558 | 	 "\t.seh_handler __C_specific_handler, %except\n" | ||
| 1559 | #else | ||
| 1560 | 	 "\t.seh_handler __C_specific_handler, @except\n" | ||
| 1561 | #endif | ||
| 1562 | 	 "\t.seh_handlerdata\n" | ||
| 1563 | 	 "\t.long 1\n" | ||
| 1564 | 	 "\t.rva .tl_start, .tl_end, _gnu_exception_handler ,.tl_end\n" | ||
| 1565 | 	 "\t.text" | ||
| 1566 | 	 ); | ||
| 1567 | #endif | 1551 | #endif |
| 1568 | pthread_mutex_lock (&mtx_pthr_locked); | 1552 | pthread_mutex_lock (&mtx_pthr_locked); |
| 1569 | tv->ret_arg = (void*) trslt; | 1553 | tv->ret_arg = (void*) trslt; |
| ... | @@ -1601,6 +1585,19 @@ pthread_create_wrapper (void *args) | ... | @@ -1601,6 +1585,19 @@ pthread_create_wrapper (void *args) |
| 1601 | Sleep (0); | 1585 | Sleep (0); |
| 1602 | _endthreadex (rslt); | 1586 | _endthreadex (rslt); |
| 1603 | return rslt; | 1587 | return rslt; |
| 1588 | |||
| 1589 | #if defined(__SEH__) | ||
| 1590 | asm( | ||
| 1591 | #ifdef __arm__ | ||
| 1592 | "\t.seh_handler __C_specific_handler, %except\n" | ||
| 1593 | #else | ||
| 1594 | "\t.seh_handler __C_specific_handler, @except\n" | ||
| 1595 | #endif | ||
| 1596 | "\t.seh_handlerdata\n" | ||
| 1597 | "\t.long 1\n" | ||
| 1598 | "\t.rva .tl_start, .tl_end, _gnu_exception_handler ,.tl_end\n" | ||
| 1599 | "\t.text\n"); | ||
| 1600 | #endif | ||
| 1604 | } | 1601 | } |
| 1605 | 1602 | ||
| 1606 | int | 1603 | int |
| ... | @@ -1881,13 +1878,14 @@ pthread_setname_np (pthread_t thread, const char *name) | ... | @@ -1881,13 +1878,14 @@ pthread_setname_np (pthread_t thread, const char *name) |
| 1881 | 1878 | ||
| 1882 | if (_pthread_set_thread_description != NULL) | 1879 | if (_pthread_set_thread_description != NULL) |
| 1883 | { | 1880 | { |
| 1884 | size_t required_size = mbstowcs(NULL, name, 0); | 1881 | mbstate_t mbs = {0}; |
| 1882 | size_t required_size = mbsrtowcs(NULL, &name, 0, &mbs); | ||
| 1885 | if (required_size != (size_t)-1) | 1883 | if (required_size != (size_t)-1) |
| 1886 | { | 1884 | { |
| 1887 | wchar_t *wname = malloc((required_size + 1) * sizeof(wchar_t)); | 1885 | wchar_t *wname = malloc((required_size + 1) * sizeof(wchar_t)); |
| 1888 | if (wname != NULL) | 1886 | if (wname != NULL) |
| 1889 | { | 1887 | { |
| 1890 | mbstowcs(wname, name, required_size + 1); | 1888 | mbsrtowcs(wname, &name, required_size + 1, &mbs); |
| 1891 | _pthread_set_thread_description(tv->h, wname); | 1889 | _pthread_set_thread_description(tv->h, wname); |
| 1892 | free(wname); | 1890 | free(wname); |
| 1893 | } | 1891 | } |
lib/libc/mingw/winpthreads/thread.h+2-5| ... | @@ -23,8 +23,8 @@ | ... | @@ -23,8 +23,8 @@ |
| 23 | #ifndef WIN_PTHREAD_H | 23 | #ifndef WIN_PTHREAD_H |
| 24 | #define WIN_PTHREAD_H | 24 | #define WIN_PTHREAD_H |
| 25 | 25 | ||
| 26 | #include <windows.h> | ||
| 27 | #include <setjmp.h> | 26 | #include <setjmp.h> |
| 27 | /* internal header files */ | ||
| 28 | #include "rwlock.h" | 28 | #include "rwlock.h" |
| 29 | 29 | ||
| 30 | #define LIFE_THREAD 0xBAB1F00D | 30 | #define LIFE_THREAD 0xBAB1F00D |
| ... | @@ -69,11 +69,8 @@ typedef struct __pthread_idlist { | ... | @@ -69,11 +69,8 @@ typedef struct __pthread_idlist { |
| 69 | 69 | ||
| 70 | int _pthread_tryjoin(pthread_t t, void **res); | 70 | int _pthread_tryjoin(pthread_t t, void **res); |
| 71 | void _pthread_setnobreak(int); | 71 | void _pthread_setnobreak(int); |
| 72 | #ifdef WINPTHREAD_DBG | ||
| 73 | void thread_print_set(int state); | ||
| 74 | void thread_print(volatile pthread_t t, char *txt); | ||
| 75 | #endif | ||
| 76 | int __pthread_shallcancel(void); | 72 | int __pthread_shallcancel(void); |
| 77 | WINPTHREAD_API struct _pthread_v * __pth_gpointer_locked (pthread_t id); | 73 | WINPTHREAD_API struct _pthread_v * __pth_gpointer_locked (pthread_t id); |
| 74 | int _pthread_delay_np_ms (DWORD to); | ||
| 78 | 75 | ||
| 79 | #endif | 76 | #endif |
lib/libc/mingw/winpthreads/winpthread_internal.h deleted-27| ... | @@ -1,27 +0,0 @@ | ||
| 1 | /* | ||
| 2 | Copyright (c) 2011-2016 mingw-w64 project | ||
| 3 | |||
| 4 | Permission is hereby granted, free of charge, to any person obtaining a | ||
| 5 | copy of this software and associated documentation files (the "Software"), | ||
| 6 | to deal in the Software without restriction, including without limitation | ||
| 7 | the rights to use, copy, modify, merge, publish, distribute, sublicense, | ||
| 8 | and/or sell copies of the Software, and to permit persons to whom the | ||
| 9 | Software is furnished to do so, subject to the following conditions: | ||
| 10 | |||
| 11 | The above copyright notice and this permission notice shall be included in | ||
| 12 | all copies or substantial portions of the Software. | ||
| 13 | |||
| 14 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
| 15 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
| 16 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
| 17 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
| 18 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING | ||
| 19 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER | ||
| 20 | DEALINGS IN THE SOFTWARE. | ||
| 21 | */ | ||
| 22 | |||
| 23 | #ifndef WINPTHREAD_INTERNAL_H | ||
| 24 | #define WINPTHREAD_INTERNAL_H | ||
| 25 | WINPTHREAD_API struct _pthread_v * __pth_gpointer_locked (pthread_t id); | ||
| 26 | int pthread_delay_np_ms (DWORD to); | ||
| 27 | #endif /*WINPTHREAD_INTERNAL_H*/ | ||
src/libs/mingw.zig+26-10| ... | @@ -154,7 +154,8 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre | ... | @@ -154,7 +154,8 @@ pub fn buildCrtFile(comp: *Compilation, crt_file: CrtFile, prog_node: std.Progre |
| 154 | try addCcArgs(comp, arena, &winpthreads_args); | 154 | try addCcArgs(comp, arena, &winpthreads_args); |
| 155 | try winpthreads_args.appendSlice(&[_][]const u8{ | 155 | try winpthreads_args.appendSlice(&[_][]const u8{ |
| 156 | "-DIN_WINPTHREAD", | 156 | "-DIN_WINPTHREAD", |
| 157 | "-DWIN32_LEAN_AND_MEAN", | 157 | // winpthreads incorrectly assumes that Clang has `-Wprio-ctor-dtor`. |
| 158 | "-Wno-unknown-warning-option", | ||
| 158 | }); | 159 | }); |
| 159 | 160 | ||
| 160 | switch (comp.compilerRtOptMode()) { | 161 | switch (comp.compilerRtOptMode()) { |
| ... | @@ -485,7 +486,6 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -485,7 +486,6 @@ const mingw32_generic_src = [_][]const u8{ |
| 485 | "crt" ++ path.sep_str ++ "pesect.c", | 486 | "crt" ++ path.sep_str ++ "pesect.c", |
| 486 | "crt" ++ path.sep_str ++ "udllargc.c", | 487 | "crt" ++ path.sep_str ++ "udllargc.c", |
| 487 | "crt" ++ path.sep_str ++ "xthdloc.c", | 488 | "crt" ++ path.sep_str ++ "xthdloc.c", |
| 488 | "crt" ++ path.sep_str ++ "CRT_fp10.c", | ||
| 489 | "crt" ++ path.sep_str ++ "mingw_helpers.c", | 489 | "crt" ++ path.sep_str ++ "mingw_helpers.c", |
| 490 | "crt" ++ path.sep_str ++ "pseudo-reloc.c", | 490 | "crt" ++ path.sep_str ++ "pseudo-reloc.c", |
| 491 | "crt" ++ path.sep_str ++ "udll_argv.c", | 491 | "crt" ++ path.sep_str ++ "udll_argv.c", |
| ... | @@ -609,7 +609,6 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -609,7 +609,6 @@ const mingw32_generic_src = [_][]const u8{ |
| 609 | "misc" ++ path.sep_str ++ "delayimp.c", | 609 | "misc" ++ path.sep_str ++ "delayimp.c", |
| 610 | "misc" ++ path.sep_str ++ "dirent.c", | 610 | "misc" ++ path.sep_str ++ "dirent.c", |
| 611 | "misc" ++ path.sep_str ++ "dirname.c", | 611 | "misc" ++ path.sep_str ++ "dirname.c", |
| 612 | "misc" ++ path.sep_str ++ "dllentrypoint.c", | ||
| 613 | "misc" ++ path.sep_str ++ "dllmain.c", | 612 | "misc" ++ path.sep_str ++ "dllmain.c", |
| 614 | "misc" ++ path.sep_str ++ "feclearexcept.c", | 613 | "misc" ++ path.sep_str ++ "feclearexcept.c", |
| 615 | "misc" ++ path.sep_str ++ "fegetenv.c", | 614 | "misc" ++ path.sep_str ++ "fegetenv.c", |
| ... | @@ -621,10 +620,14 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -621,10 +620,14 @@ const mingw32_generic_src = [_][]const u8{ |
| 621 | "misc" ++ path.sep_str ++ "fesetexceptflag.c", | 620 | "misc" ++ path.sep_str ++ "fesetexceptflag.c", |
| 622 | "misc" ++ path.sep_str ++ "fesetround.c", | 621 | "misc" ++ path.sep_str ++ "fesetround.c", |
| 623 | "misc" ++ path.sep_str ++ "fetestexcept.c", | 622 | "misc" ++ path.sep_str ++ "fetestexcept.c", |
| 623 | "misc" ++ path.sep_str ++ "mingw_controlfp.c", | ||
| 624 | "misc" ++ path.sep_str ++ "mingw_setfp.c", | ||
| 624 | "misc" ++ path.sep_str ++ "feupdateenv.c", | 625 | "misc" ++ path.sep_str ++ "feupdateenv.c", |
| 625 | "misc" ++ path.sep_str ++ "ftruncate.c", | 626 | "misc" ++ path.sep_str ++ "ftruncate.c", |
| 626 | "misc" ++ path.sep_str ++ "ftw.c", | 627 | "misc" ++ path.sep_str ++ "ftw32.c", |
| 628 | "misc" ++ path.sep_str ++ "ftw32i64.c", | ||
| 627 | "misc" ++ path.sep_str ++ "ftw64.c", | 629 | "misc" ++ path.sep_str ++ "ftw64.c", |
| 630 | "misc" ++ path.sep_str ++ "ftw64i32.c", | ||
| 628 | "misc" ++ path.sep_str ++ "fwide.c", | 631 | "misc" ++ path.sep_str ++ "fwide.c", |
| 629 | "misc" ++ path.sep_str ++ "getlogin.c", | 632 | "misc" ++ path.sep_str ++ "getlogin.c", |
| 630 | "misc" ++ path.sep_str ++ "getopt.c", | 633 | "misc" ++ path.sep_str ++ "getopt.c", |
| ... | @@ -669,12 +672,12 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -669,12 +672,12 @@ const mingw32_generic_src = [_][]const u8{ |
| 669 | "stdio" ++ path.sep_str ++ "_findfirst64i32.c", | 672 | "stdio" ++ path.sep_str ++ "_findfirst64i32.c", |
| 670 | "stdio" ++ path.sep_str ++ "_findnext64i32.c", | 673 | "stdio" ++ path.sep_str ++ "_findnext64i32.c", |
| 671 | "stdio" ++ path.sep_str ++ "_fstat64i32.c", | 674 | "stdio" ++ path.sep_str ++ "_fstat64i32.c", |
| 672 | "stdio" ++ path.sep_str ++ "_stat.c", | ||
| 673 | "stdio" ++ path.sep_str ++ "_stat64i32.c", | 675 | "stdio" ++ path.sep_str ++ "_stat64i32.c", |
| 674 | "stdio" ++ path.sep_str ++ "_wfindfirst64i32.c", | 676 | "stdio" ++ path.sep_str ++ "_wfindfirst64i32.c", |
| 675 | "stdio" ++ path.sep_str ++ "_wfindnext64i32.c", | 677 | "stdio" ++ path.sep_str ++ "_wfindnext64i32.c", |
| 676 | "stdio" ++ path.sep_str ++ "_wstat.c", | ||
| 677 | "stdio" ++ path.sep_str ++ "_wstat64i32.c", | 678 | "stdio" ++ path.sep_str ++ "_wstat64i32.c", |
| 679 | "stdio" ++ path.sep_str ++ "__mingw_fix_stat_path.c", | ||
| 680 | "stdio" ++ path.sep_str ++ "__mingw_fix_wstat_path.c", | ||
| 678 | "stdio" ++ path.sep_str ++ "asprintf.c", | 681 | "stdio" ++ path.sep_str ++ "asprintf.c", |
| 679 | "stdio" ++ path.sep_str ++ "fopen64.c", | 682 | "stdio" ++ path.sep_str ++ "fopen64.c", |
| 680 | "stdio" ++ path.sep_str ++ "fseeko32.c", | 683 | "stdio" ++ path.sep_str ++ "fseeko32.c", |
| ... | @@ -749,23 +752,36 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -749,23 +752,36 @@ const mingw32_generic_src = [_][]const u8{ |
| 749 | "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c", | 752 | "stdio" ++ path.sep_str ++ "ucrt__vscprintf.c", |
| 750 | "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c", | 753 | "stdio" ++ path.sep_str ++ "ucrt__vsnprintf.c", |
| 751 | "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c", | 754 | "stdio" ++ path.sep_str ++ "ucrt__vsnwprintf.c", |
| 755 | "stdio" ++ path.sep_str ++ "ucrt___local_stdio_printf_options.c", | ||
| 756 | "stdio" ++ path.sep_str ++ "ucrt___local_stdio_scanf_options.c", | ||
| 752 | "stdio" ++ path.sep_str ++ "ucrt_fprintf.c", | 757 | "stdio" ++ path.sep_str ++ "ucrt_fprintf.c", |
| 753 | "stdio" ++ path.sep_str ++ "ucrt_fscanf.c", | 758 | "stdio" ++ path.sep_str ++ "ucrt_fscanf.c", |
| 754 | "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c", | 759 | "stdio" ++ path.sep_str ++ "ucrt_fwprintf.c", |
| 755 | "stdio" ++ path.sep_str ++ "ucrt_ms_fprintf.c", | 760 | "stdio" ++ path.sep_str ++ "ucrt_fwscanf.c", |
| 756 | "stdio" ++ path.sep_str ++ "ucrt_ms_fwprintf.c", | 761 | "stdio" ++ path.sep_str ++ "ucrt_ms_fwprintf.c", |
| 757 | "stdio" ++ path.sep_str ++ "ucrt_printf.c", | 762 | "stdio" ++ path.sep_str ++ "ucrt_printf.c", |
| 758 | "stdio" ++ path.sep_str ++ "ucrt_scanf.c", | 763 | "stdio" ++ path.sep_str ++ "ucrt_scanf.c", |
| 759 | "stdio" ++ path.sep_str ++ "ucrt_snprintf.c", | 764 | "stdio" ++ path.sep_str ++ "ucrt_snprintf.c", |
| 765 | "stdio" ++ path.sep_str ++ "ucrt_snwprintf.c", | ||
| 760 | "stdio" ++ path.sep_str ++ "ucrt_sprintf.c", | 766 | "stdio" ++ path.sep_str ++ "ucrt_sprintf.c", |
| 761 | "stdio" ++ path.sep_str ++ "ucrt_sscanf.c", | 767 | "stdio" ++ path.sep_str ++ "ucrt_sscanf.c", |
| 768 | "stdio" ++ path.sep_str ++ "ucrt_swscanf.c", | ||
| 769 | "stdio" ++ path.sep_str ++ "ucrt_swprintf.c", | ||
| 762 | "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c", | 770 | "stdio" ++ path.sep_str ++ "ucrt_vfprintf.c", |
| 763 | "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c", | 771 | "stdio" ++ path.sep_str ++ "ucrt_vfscanf.c", |
| 772 | "stdio" ++ path.sep_str ++ "ucrt_vfwscanf.c", | ||
| 773 | "stdio" ++ path.sep_str ++ "ucrt_vfwprintf.c", | ||
| 764 | "stdio" ++ path.sep_str ++ "ucrt_vprintf.c", | 774 | "stdio" ++ path.sep_str ++ "ucrt_vprintf.c", |
| 765 | "stdio" ++ path.sep_str ++ "ucrt_vscanf.c", | 775 | "stdio" ++ path.sep_str ++ "ucrt_vscanf.c", |
| 766 | "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c", | 776 | "stdio" ++ path.sep_str ++ "ucrt_vsnprintf.c", |
| 777 | "stdio" ++ path.sep_str ++ "ucrt_vsnwprintf.c", | ||
| 767 | "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c", | 778 | "stdio" ++ path.sep_str ++ "ucrt_vsprintf.c", |
| 779 | "stdio" ++ path.sep_str ++ "ucrt_vswprintf.c", | ||
| 768 | "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c", | 780 | "stdio" ++ path.sep_str ++ "ucrt_vsscanf.c", |
| 781 | "stdio" ++ path.sep_str ++ "ucrt_vwscanf.c", | ||
| 782 | "stdio" ++ path.sep_str ++ "ucrt_wscanf.c", | ||
| 783 | "stdio" ++ path.sep_str ++ "ucrt_vwprintf.c", | ||
| 784 | "stdio" ++ path.sep_str ++ "ucrt_wprintf.c", | ||
| 769 | "string" ++ path.sep_str ++ "ucrt__wcstok.c", | 785 | "string" ++ path.sep_str ++ "ucrt__wcstok.c", |
| 770 | // uuid | 786 | // uuid |
| 771 | "libsrc" ++ path.sep_str ++ "ativscp-uuid.c", | 787 | "libsrc" ++ path.sep_str ++ "ativscp-uuid.c", |
| ... | @@ -889,6 +905,8 @@ const mingw32_generic_src = [_][]const u8{ | ... | @@ -889,6 +905,8 @@ const mingw32_generic_src = [_][]const u8{ |
| 889 | }; | 905 | }; |
| 890 | 906 | ||
| 891 | const mingw32_x86_src = [_][]const u8{ | 907 | const mingw32_x86_src = [_][]const u8{ |
| 908 | // mingw32 | ||
| 909 | "crt" ++ path.sep_str ++ "CRT_fp10.c", | ||
| 892 | // mingwex | 910 | // mingwex |
| 893 | "math" ++ path.sep_str ++ "cbrtl.c", | 911 | "math" ++ path.sep_str ++ "cbrtl.c", |
| 894 | "math" ++ path.sep_str ++ "erfl.c", | 912 | "math" ++ path.sep_str ++ "erfl.c", |
| ... | @@ -971,11 +989,11 @@ const mingw32_x86_32_src = [_][]const u8{ | ... | @@ -971,11 +989,11 @@ const mingw32_x86_32_src = [_][]const u8{ |
| 971 | const mingw32_arm_src = [_][]const u8{ | 989 | const mingw32_arm_src = [_][]const u8{ |
| 972 | // mingwex | 990 | // mingwex |
| 973 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c", | 991 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "ldexpl.c", |
| 992 | "math" ++ path.sep_str ++ "arm-common" ++ path.sep_str ++ "sincosl.c", | ||
| 974 | }; | 993 | }; |
| 975 | 994 | ||
| 976 | const mingw32_arm32_src = [_][]const u8{ | 995 | const mingw32_arm32_src = [_][]const u8{ |
| 977 | // mingwex | 996 | // mingwex |
| 978 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "_chgsignl.S", | ||
| 979 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c", | 997 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rint.c", |
| 980 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c", | 998 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "s_rintf.c", |
| 981 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S", | 999 | "math" ++ path.sep_str ++ "arm" ++ path.sep_str ++ "sincos.S", |
| ... | @@ -983,7 +1001,6 @@ const mingw32_arm32_src = [_][]const u8{ | ... | @@ -983,7 +1001,6 @@ const mingw32_arm32_src = [_][]const u8{ |
| 983 | 1001 | ||
| 984 | const mingw32_arm64_src = [_][]const u8{ | 1002 | const mingw32_arm64_src = [_][]const u8{ |
| 985 | // mingwex | 1003 | // mingwex |
| 986 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "_chgsignl.S", | ||
| 987 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c", | 1004 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rint.c", |
| 988 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c", | 1005 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "rintf.c", |
| 989 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S", | 1006 | "math" ++ path.sep_str ++ "arm64" ++ path.sep_str ++ "sincos.S", |
| ... | @@ -997,7 +1014,6 @@ const mingw32_winpthreads_src = [_][]const u8{ | ... | @@ -997,7 +1014,6 @@ const mingw32_winpthreads_src = [_][]const u8{ |
| 997 | "winpthreads" ++ path.sep_str ++ "misc.c", | 1014 | "winpthreads" ++ path.sep_str ++ "misc.c", |
| 998 | "winpthreads" ++ path.sep_str ++ "mutex.c", | 1015 | "winpthreads" ++ path.sep_str ++ "mutex.c", |
| 999 | "winpthreads" ++ path.sep_str ++ "nanosleep.c", | 1016 | "winpthreads" ++ path.sep_str ++ "nanosleep.c", |
| 1000 | "winpthreads" ++ path.sep_str ++ "ref.c", | ||
| 1001 | "winpthreads" ++ path.sep_str ++ "rwlock.c", | 1017 | "winpthreads" ++ path.sep_str ++ "rwlock.c", |
| 1002 | "winpthreads" ++ path.sep_str ++ "sched.c", | 1018 | "winpthreads" ++ path.sep_str ++ "sched.c", |
| 1003 | "winpthreads" ++ path.sep_str ++ "sem.c", | 1019 | "winpthreads" ++ path.sep_str ++ "sem.c", |