mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 16:51:18 +00:00
[CRT] Format source a bit.
This is horrendous.
This commit is contained in:
parent
f234cb6e59
commit
26863538a4
1 changed files with 108 additions and 108 deletions
|
@ -62,95 +62,95 @@ static int
|
||||||
__cdecl
|
__cdecl
|
||||||
pre_c_init (void)
|
pre_c_init (void)
|
||||||
{
|
{
|
||||||
_PVFV *onexitbegin;
|
_PVFV *onexitbegin;
|
||||||
|
|
||||||
onexitbegin = (_PVFV *) malloc (32 * sizeof (_PVFV));
|
onexitbegin = (_PVFV *) malloc (32 * sizeof (_PVFV));
|
||||||
__onexitend = __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin);
|
__onexitend = __onexitbegin = (_PVFV *) _encode_pointer (onexitbegin);
|
||||||
|
|
||||||
if (onexitbegin == NULL)
|
if (onexitbegin == NULL)
|
||||||
return 1;
|
return 1;
|
||||||
*onexitbegin = (_PVFV) NULL;
|
*onexitbegin = (_PVFV) NULL;
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
WINBOOL WINAPI _CRT_INIT (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||||
{
|
{
|
||||||
if (dwReason == DLL_PROCESS_DETACH)
|
if (dwReason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
if (__proc_attached > 0)
|
if (__proc_attached > 0)
|
||||||
__proc_attached--;
|
__proc_attached--;
|
||||||
else
|
else
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
void *lock_free = NULL;
|
void *lock_free = NULL;
|
||||||
void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase;
|
void *fiberid = ((PNT_TIB)NtCurrentTeb ())->StackBase;
|
||||||
int nested = FALSE;
|
int nested = FALSE;
|
||||||
|
|
||||||
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,
|
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,
|
||||||
fiberid, 0)) != 0)
|
fiberid, 0)) != 0)
|
||||||
{
|
{
|
||||||
if (lock_free == fiberid)
|
if (lock_free == fiberid)
|
||||||
{
|
{
|
||||||
nested = TRUE;
|
nested = TRUE;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
}
|
}
|
||||||
if (__native_startup_state == __initializing)
|
if (__native_startup_state == __initializing)
|
||||||
{
|
{
|
||||||
_amsg_exit (31);
|
_amsg_exit (31);
|
||||||
}
|
}
|
||||||
else if (__native_startup_state == __uninitialized)
|
else if (__native_startup_state == __uninitialized)
|
||||||
{
|
{
|
||||||
__native_startup_state = __initializing;
|
__native_startup_state = __initializing;
|
||||||
|
|
||||||
_initterm ((_PVFV *) (void *) __xi_a, (_PVFV *) (void *) __xi_z);
|
_initterm ((_PVFV *) (void *) __xi_a, (_PVFV *) (void *) __xi_z);
|
||||||
}
|
}
|
||||||
if (__native_startup_state == __initializing)
|
if (__native_startup_state == __initializing)
|
||||||
{
|
{
|
||||||
_initterm (__xc_a, __xc_z);
|
_initterm (__xc_a, __xc_z);
|
||||||
__native_startup_state = __initialized;
|
__native_startup_state = __initialized;
|
||||||
}
|
}
|
||||||
if (! nested)
|
if (! nested)
|
||||||
{
|
{
|
||||||
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
||||||
}
|
}
|
||||||
if (__dyn_tls_init_callback != NULL)
|
if (__dyn_tls_init_callback != NULL)
|
||||||
{
|
{
|
||||||
__dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved);
|
__dyn_tls_init_callback (hDllHandle, DLL_THREAD_ATTACH, lpreserved);
|
||||||
}
|
}
|
||||||
__proc_attached++;
|
__proc_attached++;
|
||||||
}
|
}
|
||||||
else if (dwReason == DLL_PROCESS_DETACH)
|
else if (dwReason == DLL_PROCESS_DETACH)
|
||||||
{
|
{
|
||||||
void *lock_free = NULL;
|
void *lock_free = NULL;
|
||||||
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,(PVOID) 1, 0)) != 0)
|
while ((lock_free = InterlockedCompareExchangePointer ((volatile PVOID *) &__native_startup_lock,(PVOID) 1, 0)) != 0)
|
||||||
{
|
{
|
||||||
Sleep(1000);
|
Sleep(1000);
|
||||||
}
|
}
|
||||||
if (__native_startup_state != __initialized)
|
if (__native_startup_state != __initialized)
|
||||||
{
|
{
|
||||||
_amsg_exit (31);
|
_amsg_exit (31);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
_PVFV * onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
|
_PVFV * onexitbegin = (_PVFV *) _decode_pointer (__onexitbegin);
|
||||||
if (onexitbegin)
|
if (onexitbegin)
|
||||||
{
|
{
|
||||||
_PVFV *onexitend = (_PVFV *) _decode_pointer (__onexitend);
|
_PVFV *onexitend = (_PVFV *) _decode_pointer (__onexitend);
|
||||||
while (--onexitend >= onexitbegin)
|
while (--onexitend >= onexitbegin)
|
||||||
if (*onexitend != NULL)
|
if (*onexitend != NULL)
|
||||||
(**onexitend) ();
|
(**onexitend) ();
|
||||||
free (onexitbegin);
|
free (onexitbegin);
|
||||||
__onexitbegin = __onexitend = (_PVFV *) NULL;
|
__onexitbegin = __onexitend = (_PVFV *) NULL;
|
||||||
}
|
}
|
||||||
__native_startup_state = __uninitialized;
|
__native_startup_state = __uninitialized;
|
||||||
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
(void) InterlockedExchangePointer ((volatile PVOID *) &__native_startup_lock, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
|
static WINBOOL __DllMainCRTStartup (HANDLE, DWORD, LPVOID);
|
||||||
|
@ -161,59 +161,59 @@ int __mingw_init_ehandler (void);
|
||||||
WINBOOL WINAPI
|
WINBOOL WINAPI
|
||||||
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||||
{
|
{
|
||||||
mingw_app_type = 0;
|
mingw_app_type = 0;
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
{
|
{
|
||||||
__security_init_cookie ();
|
__security_init_cookie ();
|
||||||
#ifdef _WIN64
|
#ifdef _WIN64
|
||||||
__mingw_init_ehandler ();
|
__mingw_init_ehandler ();
|
||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
|
return __DllMainCRTStartup (hDllHandle, dwReason, lpreserved);
|
||||||
}
|
}
|
||||||
|
|
||||||
__declspec(noinline) WINBOOL
|
__declspec(noinline) WINBOOL
|
||||||
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
__DllMainCRTStartup (HANDLE hDllHandle, DWORD dwReason, LPVOID lpreserved)
|
||||||
{
|
{
|
||||||
WINBOOL retcode = TRUE;
|
WINBOOL retcode = TRUE;
|
||||||
|
|
||||||
__native_dllmain_reason = dwReason;
|
__native_dllmain_reason = dwReason;
|
||||||
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)
|
if (dwReason == DLL_PROCESS_DETACH && __proc_attached == 0)
|
||||||
{
|
{
|
||||||
retcode = FALSE;
|
retcode = FALSE;
|
||||||
goto i__leave;
|
goto i__leave;
|
||||||
}
|
}
|
||||||
_pei386_runtime_relocator ();
|
_pei386_runtime_relocator ();
|
||||||
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH || dwReason == DLL_THREAD_ATTACH)
|
||||||
{
|
{
|
||||||
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
retcode = _CRT_INIT (hDllHandle, dwReason, lpreserved);
|
||||||
if (!retcode)
|
if (!retcode)
|
||||||
goto i__leave;
|
goto i__leave;
|
||||||
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
||||||
if (! retcode)
|
if (! retcode)
|
||||||
{
|
{
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||||
goto i__leave;
|
goto i__leave;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (dwReason == DLL_PROCESS_ATTACH)
|
if (dwReason == DLL_PROCESS_ATTACH)
|
||||||
__main ();
|
__main ();
|
||||||
retcode = DllMain(hDllHandle,dwReason,lpreserved);
|
retcode = DllMain(hDllHandle,dwReason,lpreserved);
|
||||||
if (dwReason == DLL_PROCESS_ATTACH && ! retcode)
|
if (dwReason == DLL_PROCESS_ATTACH && ! retcode)
|
||||||
{
|
{
|
||||||
DllMain (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
DllMain (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||||
DllEntryPoint (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
DllEntryPoint (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||||
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
_CRT_INIT (hDllHandle, DLL_PROCESS_DETACH, lpreserved);
|
||||||
}
|
}
|
||||||
if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH)
|
if (dwReason == DLL_PROCESS_DETACH || dwReason == DLL_THREAD_DETACH)
|
||||||
{
|
{
|
||||||
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
retcode = DllEntryPoint (hDllHandle, dwReason, lpreserved);
|
||||||
if (_CRT_INIT (hDllHandle, dwReason, lpreserved) == FALSE)
|
if (_CRT_INIT (hDllHandle, dwReason, lpreserved) == FALSE)
|
||||||
retcode = FALSE;
|
retcode = FALSE;
|
||||||
}
|
}
|
||||||
i__leave:
|
i__leave:
|
||||||
__native_dllmain_reason = UINT_MAX;
|
__native_dllmain_reason = UINT_MAX;
|
||||||
return retcode ;
|
return retcode ;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue