diff options
author | Chris Robinson <[email protected]> | 2011-04-27 16:33:44 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2011-04-27 16:33:44 -0700 |
commit | c031b4d5d07703e179f258e74fdfbd8e6b66e9ef (patch) | |
tree | 4b83fc4f484e517aa4e1ca5cbb47be7564a3000f /Alc/ALc.c | |
parent | d91b3464a4cc2e6c01d8f1e72a9cccf96db9291b (diff) |
Allow MSVC to build a static lib
Based on a patch by Michał Cichoń <[email protected]>
Diffstat (limited to 'Alc/ALc.c')
-rw-r--r-- | Alc/ALc.c | 18 |
1 files changed, 18 insertions, 0 deletions
@@ -408,6 +408,7 @@ static void alc_deinit(void) __attribute__((destructor)); static void alc_init(void); static void alc_deinit(void); +#ifndef AL_LIBTYPE_STATIC BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) { (void)lpReserved; @@ -426,6 +427,23 @@ BOOL APIENTRY DllMain(HANDLE hModule,DWORD ul_reason_for_call,LPVOID lpReserved) } return TRUE; } +#elif defined(_MSC_VER) +#pragma section(".CRT$XCU",read) +static void alc_constructor(void); +static void alc_destructor(void); +__declspec(allocate(".CRT$XCU")) void (__cdecl* alc_constructor_)(void) = alc_constructor; + +static void alc_constructor(void) +{ + atexit(alc_destructor); + alc_init(); +} + +static void alc_destructor(void) +{ + alc_deinit(); +} +#endif #endif #endif |