aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2011-04-27 16:33:44 -0700
committerChris Robinson <[email protected]>2011-04-27 16:33:44 -0700
commitc031b4d5d07703e179f258e74fdfbd8e6b66e9ef (patch)
tree4b83fc4f484e517aa4e1ca5cbb47be7564a3000f
parentd91b3464a4cc2e6c01d8f1e72a9cccf96db9291b (diff)
Allow MSVC to build a static lib
Based on a patch by Michał Cichoń <[email protected]>
-rw-r--r--Alc/ALc.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/Alc/ALc.c b/Alc/ALc.c
index 330a177c..078b168a 100644
--- a/Alc/ALc.c
+++ b/Alc/ALc.c
@@ -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