summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorMike Hommey <mh@glandium.org>2012-04-30 10:38:31 (GMT)
committerJason Evans <je@fb.com>2012-05-01 18:32:11 (GMT)
commitfd97b1dfc76647c3f90f28dc63cc987041fe20df (patch)
tree97ed1b2b8de5dfd5bddc4f32da1cecd0af4c5da8 /src
parentb45c57ecaf2bf7ff8abe013b856be90fb4e365f3 (diff)
downloadjemalloc-fd97b1dfc76647c3f90f28dc63cc987041fe20df.zip
jemalloc-fd97b1dfc76647c3f90f28dc63cc987041fe20df.tar.gz
jemalloc-fd97b1dfc76647c3f90f28dc63cc987041fe20df.tar.bz2
Add support for MSVC
Tested with MSVC 8 32 and 64 bits.
Diffstat (limited to 'src')
-rw-r--r--src/jemalloc.c11
-rw-r--r--src/tsd.c8
2 files changed, 17 insertions, 2 deletions
diff --git a/src/jemalloc.c b/src/jemalloc.c
index 2f858c3..d42e91d 100644
--- a/src/jemalloc.c
+++ b/src/jemalloc.c
@@ -56,12 +56,19 @@ static bool malloc_initializer = NO_INITIALIZER;
static malloc_mutex_t init_lock;
JEMALLOC_ATTR(constructor)
-static void
-init_init_lock()
+static void WINAPI
+_init_init_lock(void)
{
malloc_mutex_init(&init_lock);
}
+
+#ifdef _MSC_VER
+# pragma section(".CRT$XCU", read)
+JEMALLOC_SECTION(".CRT$XCU") JEMALLOC_ATTR(used)
+static const void (WINAPI *init_init_lock)(void) = _init_init_lock;
+#endif
+
#else
static malloc_mutex_t init_lock = MALLOC_MUTEX_INITIALIZER;
#endif
diff --git a/src/tsd.c b/src/tsd.c
index 0506c8a..00d7b45 100644
--- a/src/tsd.c
+++ b/src/tsd.c
@@ -93,6 +93,14 @@ _tls_callback(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
return (true);
}
+#ifdef _MSC_VER
+# ifdef _M_IX86
+# pragma comment(linker, "/INCLUDE:__tls_used")
+# else
+# pragma comment(linker, "/INCLUDE:_tls_used")
+# endif
+# pragma section(".CRT$XLY",long,read)
+#endif
JEMALLOC_SECTION(".CRT$XLY") JEMALLOC_ATTR(used)
static const BOOL (WINAPI *tls_callback)(HINSTANCE hinstDLL,
DWORD fdwReason, LPVOID lpvReserved) = _tls_callback;