Skip to content

Commit 8afe928

Browse files
committed
mingw: Update MinGW-w64 sources to 3839e21b08807479a31d5a9764666f82ae2f0356.
1 parent ed10a5d commit 8afe928

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

66 files changed

+2070
-2832
lines changed

lib/libc/mingw/crt/cinitexe.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
#include <stdio.h>
22
#include <sect_attribs.h>
3+
#include <corecrt_startup.h>
34

45
#ifdef _MSC_VER
56
#pragma comment(linker, "/merge:.CRT=.rdata")
67
#endif
78

8-
typedef void (__cdecl *_PVFV)(void);
9-
10-
_CRTALLOC(".CRT$XIA") _PVFV __xi_a[] = { NULL };
11-
_CRTALLOC(".CRT$XIZ") _PVFV __xi_z[] = { NULL };
9+
_CRTALLOC(".CRT$XIA") _PIFV __xi_a[] = { NULL };
10+
_CRTALLOC(".CRT$XIZ") _PIFV __xi_z[] = { NULL };
1211
_CRTALLOC(".CRT$XCA") _PVFV __xc_a[] = { NULL };
1312
_CRTALLOC(".CRT$XCZ") _PVFV __xc_z[] = { NULL };

lib/libc/mingw/crt/crt_handler.c

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -51,10 +51,6 @@ __mingw_init_ehandler (void)
5151
if (_FindPESectionByName (".pdata") != NULL)
5252
return 1;
5353

54-
/* Allocate # of e tables and entries. */
55-
memset (emu_pdata, 0, sizeof (RUNTIME_FUNCTION) * MAX_PDATA_ENTRIES);
56-
memset (emu_xdata, 0, sizeof (UNWIND_INFO) * MAX_PDATA_ENTRIES);
57-
5854
e = 0;
5955
/* Fill tables and entries. */
6056
while (e < MAX_PDATA_ENTRIES && (pSec = _FindPESectionExec (e)) != NULL)

lib/libc/mingw/crt/crtdll.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,8 @@ WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
9797
{
9898
__native_startup_state = __initializing;
9999

100-
_initterm ((_PVFV *) (void *) __xi_a, (_PVFV *) (void *) __xi_z);
100+
if (_initterm_e (__xi_a, __xi_z) != 0)
101+
return FALSE;
101102
}
102103
if (__native_startup_state == __initializing)
103104
{
@@ -147,15 +148,15 @@ WINBOOL WINAPI
147148
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
148149
{
149150
__mingw_app_type = 0;
150-
if (dwReason == DLL_PROCESS_ATTACH)
151-
{
152-
#if defined(__x86_64__) && !defined(__SEH__)
153-
__mingw_init_ehandler ();
154-
#endif
155-
}
156151
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
157152
}
158153

154+
static
155+
#if defined(__i386__) || defined(_X86_)
156+
/* 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. */
158+
__attribute__((force_align_arg_pointer))
159+
#endif
159160
__declspec(noinline) WINBOOL
160161
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
161162
{
@@ -168,6 +169,12 @@ __DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
168169
goto i__leave;
169170
}
170171
_pei386_runtime_relocator ();
172+
173+
#if defined(__x86_64__) && !defined(__SEH__)
174+
if (dwReason == DLL_PROCESS_ATTACH)
175+
__mingw_init_ehandler ();
176+
#endif
177+
171178
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
172179
{
173180
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);

lib/libc/mingw/crt/crtexe.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,9 @@ extern void __main(void);
5858
static _TCHAR **argv;
5959
static _TCHAR **envp;
6060

61-
static int argret;
6261
static int mainret=0;
6362
static int managedapp;
6463
static int has_cctor = 0;
65-
static _startupinfo startinfo;
6664
extern LPTOP_LEVEL_EXCEPTION_FILTER __mingw_oldexcpt_handler;
6765

6866
extern void _pei386_runtime_relocator (void);
@@ -97,6 +95,7 @@ __mingw_invalidParameterHandler (const wchar_t * __UNUSED_PARAM_1(expression),
9795
static int __cdecl
9896
pre_c_init (void)
9997
{
98+
int ret;
10099
managedapp = check_managed_app ();
101100
if (__mingw_app_type)
102101
__set_app_type(_GUI_APP);
@@ -107,10 +106,12 @@ pre_c_init (void)
107106
* __p__commode() = _commode;
108107

109108
#ifdef _UNICODE
110-
_wsetargv();
109+
ret = _wsetargv();
111110
#else
112-
_setargv();
111+
ret = _setargv();
113112
#endif
113+
if (ret < 0)
114+
_amsg_exit(8); /* _RT_SPACEARG */
114115
if (_MINGW_INSTALL_DEBUG_MATHERR == 1)
115116
{
116117
__setusermatherr (_matherr);
@@ -125,13 +126,18 @@ pre_c_init (void)
125126
static void __cdecl
126127
pre_cpp_init (void)
127128
{
129+
_startupinfo startinfo;
130+
int argret;
131+
128132
startinfo.newmode = _newmode;
129133

130134
#ifdef _UNICODE
131135
argret = __wgetmainargs(&argc,&argv,&envp,_dowildcard,&startinfo);
132136
#else
133137
argret = __getmainargs(&argc,&argv,&envp,_dowildcard,&startinfo);
134138
#endif
139+
if (argret < 0)
140+
_amsg_exit(8); /* _RT_SPACEARG */
135141
}
136142

137143
static int __tmainCRTStartup (void);
@@ -197,7 +203,7 @@ int mainCRTStartup (void)
197203
static
198204
#if defined(__i386__) || defined(_X86_)
199205
/* We need to make sure that we align the stack to 16 bytes for the sake of SSE
200-
opts in main or in functions called main. */
206+
opts in main or in functions called from main. */
201207
__attribute__((force_align_arg_pointer))
202208
#endif
203209
__declspec(noinline) int
@@ -223,7 +229,8 @@ __tmainCRTStartup (void)
223229
else if (__native_startup_state == __uninitialized)
224230
{
225231
__native_startup_state = __initializing;
226-
_initterm ((_PVFV *)(void *)__xi_a, (_PVFV *)(void *) __xi_z);
232+
if (_initterm_e (__xi_a, __xi_z) != 0)
233+
return 255;
227234
}
228235
else
229236
has_cctor = 1;

lib/libc/mingw/crt/tlssup.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ typedef struct TlsDtorNode {
3232
_PVFV funcs[FUNCS_PER_NODE];
3333
} TlsDtorNode;
3434

35+
__attribute__((used))
3536
ULONG _tls_index = 0;
3637

3738
/* TLS raw template data start and end.

lib/libc/mingw/def-include/crt-aliases.def.in

Lines changed: 14 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -231,6 +231,12 @@ ADD_UNDERSCORE(y1)
231231
ADD_UNDERSCORE(yn)
232232

233233
; This is list of symbol aliases for C95 functions
234+
#ifdef WITH_GET_PUT_WCHAR_ALIASES
235+
getwc == fgetwc
236+
getwchar == _fgetwchar
237+
putwc == fputwc
238+
putwchar == _fputwchar
239+
#endif
234240
#ifdef USE_WCSTOK_S_FOR_WCSTOK
235241
wcstok == wcstok_s
236242
#endif
@@ -531,24 +537,22 @@ __ms_printf == printf
531537
__ms_scanf == scanf
532538
__ms_sprintf == sprintf
533539
__ms_sscanf == sscanf
534-
#ifdef PRE_C95_SWPRINTF
535-
__ms_swprintf == swprintf
536-
#else
537-
__ms_swprintf == _swprintf
538-
#endif
539540
__ms_swscanf == swscanf
540541
__ms_vfprintf == vfprintf
541542
__ms_vfwprintf == vfwprintf
542543
__ms_vprintf == vprintf
543544
__ms_vsprintf == vsprintf
544-
#ifdef PRE_C95_SWPRINTF
545-
__ms_vswprintf == vswprintf
546-
#else
547-
__ms_vswprintf == _vswprintf
548-
#endif
549545
__ms_vwprintf == vwprintf
550546
__ms_wprintf == wprintf
551547
__ms_wscanf == wscanf
548+
#ifdef WITH_MS_VSCANF_ALIASES
549+
__ms_vfscanf == vfscanf
550+
__ms_vfwscanf == vfwscanf
551+
__ms_vscanf == vscanf
552+
__ms_vsscanf == vsscanf
553+
__ms_vswscanf == vswscanf
554+
__ms_vwscanf == vwscanf
555+
#endif
552556
#endif
553557

554558
; This is list of additional symbol aliases not available in any library as neither native symbols nor aliases

lib/libc/mingw/include/msvcrt.h

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
1-
#include <winbase.h>
2-
31
#ifndef __LIBMSVCRT_OS__
42
#error "This file should only be used in libmsvcrt-os.a"
53
#endif
64

7-
static inline HANDLE __mingw_get_msvcrt_handle(void)
5+
#ifndef MSVCRT_H
6+
#define MSVCRT_H
7+
8+
#include <winbase.h>
9+
10+
static inline HMODULE __mingw_get_msvcrt_handle(void)
811
{
9-
return GetModuleHandleW(L"msvcrt.dll");
12+
return GetModuleHandleA("msvcrt.dll");
1013
}
14+
15+
#endif

lib/libc/mingw/lib-common/kernel32.def.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ AddVectoredContinueHandler
2525
AddVectoredExceptionHandler
2626
AdjustCalendarDate
2727
AllocConsole
28+
AllocConsoleWithOptions
2829
AllocateUserPhysicalPages
2930
AllocateUserPhysicalPagesNuma
3031
AppPolicyGetClrCompat
@@ -447,6 +448,7 @@ FindVolumeMountPointClose
447448
FlsAlloc
448449
FlsFree
449450
FlsGetValue
451+
FlsGetValue2
450452
FlsSetValue
451453
FlushConsoleInputBuffer
452454
FlushFileBuffers
@@ -626,6 +628,7 @@ GetFileAttributesW
626628
GetFileBandwidthReservation
627629
GetFileInformationByHandle
628630
GetFileInformationByHandleEx
631+
GetFileInformationByName
629632
GetFileMUIInfo
630633
GetFileMUIPath
631634
GetFileSize
@@ -1282,6 +1285,7 @@ ReleaseActCtxWorker
12821285
ReleaseMutex
12831286
ReleaseMutexWhenCallbackReturns
12841287
ReleasePackageVirtualizationContext
1288+
ReleasePseudoConsole
12851289
ReleaseSRWLockExclusive
12861290
ReleaseSRWLockShared
12871291
ReleaseSemaphore
@@ -1543,6 +1547,7 @@ Thread32Next
15431547
TlsAlloc
15441548
TlsFree
15451549
TlsGetValue
1550+
TlsGetValue2
15461551
TlsSetValue
15471552
Toolhelp32ReadProcessMemory
15481553
TransactNamedPipe
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
_CreateFrameInfo
2+
F_I386(_CxxThrowException@8)
3+
F_NON_I386(_CxxThrowException)
4+
F_I386(_EH_prolog)
5+
_FindAndUnlinkFrame
6+
_IsExceptionObjectToBeDestroyed
7+
F_I386(_NLG_Dispatch2@4)
8+
F_I386(_NLG_Return@12)
9+
F_I386(_NLG_Return2)
10+
_SetWinRTOutOfMemoryExceptionCallback
11+
__AdjustPointer
12+
__BuildCatchObject
13+
__BuildCatchObjectHelper
14+
F_NON_I386(__C_specific_handler)
15+
F_NON_I386(__C_specific_handler_noexcept)
16+
__CxxDetectRethrow
17+
__CxxExceptionFilter
18+
__CxxFrameHandler
19+
__CxxFrameHandler2
20+
__CxxFrameHandler3
21+
F_I386(__CxxLongjmpUnwind@4)
22+
__CxxQueryExceptionSize
23+
__CxxRegisterExceptionObject
24+
__CxxUnregisterExceptionObject
25+
__DestructExceptionObject
26+
__FrameUnwindFilter
27+
__GetPlatformExceptionInfo
28+
F_NON_I386(__NLG_Dispatch2)
29+
F_NON_I386(__NLG_Return2)
30+
__RTCastToVoid
31+
__RTDynamicCast
32+
__RTtypeid
33+
__TypeMatch
34+
__current_exception
35+
__current_exception_context
36+
F_NON_ARM64(__intrinsic_setjmp)
37+
F_NON_I386(__intrinsic_setjmpex)
38+
F_ARM32(__jump_unwind)
39+
__processing_throw
40+
__report_gsfailure
41+
__std_exception_copy
42+
__std_exception_destroy
43+
__std_terminate
44+
__std_type_info_compare
45+
__std_type_info_destroy_list
46+
__std_type_info_hash
47+
__std_type_info_name
48+
__telemetry_main_invoke_trigger
49+
__telemetry_main_return_trigger
50+
__unDName
51+
__unDNameEx
52+
__uncaught_exception
53+
__uncaught_exceptions
54+
__vcrt_GetModuleFileNameW
55+
__vcrt_GetModuleHandleW
56+
__vcrt_InitializeCriticalSectionEx
57+
__vcrt_LoadLibraryExW
58+
F_I386(_chkesp)
59+
F_I386(_except_handler2)
60+
F_I386(_except_handler3)
61+
F_I386(_except_handler4_common)
62+
_get_purecall_handler
63+
_get_unexpected
64+
F_I386(_global_unwind2)
65+
_is_exception_typeof
66+
F64(_local_unwind)
67+
F_I386(_local_unwind2)
68+
F_I386(_local_unwind4)
69+
F_I386(_longjmpex)
70+
_purecall
71+
F_I386(_seh_longjmp_unwind4@4)
72+
F_I386(_seh_longjmp_unwind@4)
73+
_set_purecall_handler
74+
_set_se_translator
75+
F_I386(_setjmp3)
76+
longjmp
77+
memchr
78+
memcmp
79+
memcpy
80+
memmove
81+
memset
82+
set_unexpected
83+
strchr
84+
strrchr
85+
strstr
86+
unexpected
87+
wcschr
88+
wcsrchr
89+
wcsstr

0 commit comments

Comments
 (0)