Skip to content

winapi: Run fls_init in startup thread, before regular constructors #497

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Jan 2, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 5 additions & 2 deletions lib/nxdk/automount_d.c
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,10 @@
#include <windows.h>
#include <xboxkrnl/xboxkrnl.h>

__attribute__((constructor)) void automount_d_drive (void)
__cdecl int automount_d_drive (void)
{
if (nxIsDriveMounted('D')) {
return;
return 0;
}

// D: doesn't exist yet, so we create it
Expand All @@ -31,4 +31,7 @@ __attribute__((constructor)) void automount_d_drive (void)
BOOL success;
success = nxMountDrive('D', targetPath);
assert(success);

return 0;
}
__attribute__((section(".CRT$XIT"))) int (__cdecl *const automount_d_drive_p)(void) = automount_d_drive;
3 changes: 2 additions & 1 deletion lib/winapi/fiber.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,12 @@ static uint32_t fls_bitmap[FLS_MAXIMUM_AVAILABLE / 32];
static PFLS_CALLBACK_FUNCTION fls_dtors[FLS_MAXIMUM_AVAILABLE];

// Gets run by the CRT on startup.
__attribute__((constructor)) static VOID fls_init (VOID)
static __cdecl VOID fls_init (VOID)
{
InitializeCriticalSection(&fls_lock);
InitializeListHead(&fls_nodes_list);
}
__attribute__((section(".CRT$XXT"))) void (__cdecl *const __fls_init_p)(void) = fls_init;

VOID fls_register_thread (VOID)
{
Expand Down