Port the library_init() constructor to MSVC.

macos/v1.5.9
Chun-wei Fan 10 years ago committed by Eric Anholt
parent d88c639e63
commit 95ecc2d1a1
  1. 23
      src/dispatch_common.c

@ -120,6 +120,26 @@
#define GLES2_LIB "libGLESv2.so.2" #define GLES2_LIB "libGLESv2.so.2"
#endif #endif
#ifdef __GNUC__
#define CONSTRUCT(_func) static void _func (void) __attribute__((constructor));
#define DESTRUCT(_func) static void _func (void) __attribute__((destructor));
#elif defined (_MSC_VER) && (_MSC_VER >= 1500)
#define CONSTRUCT(_func) \
static void _func(void); \
static int _func ## _wrapper(void) { _func(); return 0; } \
__pragma(section(".CRT$XCU",read)) \
__declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _wrapper;
#define DESTRUCT(_func) \
static void _func(void); \
static int _func ## _constructor(void) { atexit (_func); return 0; } \
__pragma(section(".CRT$XCU",read)) \
__declspec(allocate(".CRT$XCU")) static int (* _array ## _func)(void) = _func ## _constructor;
#else
#error "You will need constructor support for your compiler"
#endif
struct api { struct api {
#ifndef _WIN32 #ifndef _WIN32
/** /**
@ -175,8 +195,7 @@ static EGLenum
epoxy_egl_get_current_gl_context_api(void); epoxy_egl_get_current_gl_context_api(void);
#endif #endif
static void CONSTRUCT (library_init)
library_init(void) __attribute__((constructor));
static void static void
library_init(void) library_init(void)

Loading…
Cancel
Save