aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormwturvey <michael.w.turvey@intel.com>2017-03-16 10:32:18 -0700
committermwturvey <michael.w.turvey@intel.com>2017-03-16 10:32:18 -0700
commit27c9edd889c746e818dc3aa55971d9cd6d8595a7 (patch)
tree7b38a03436bf11dfab7b0c3145ca9f1560374115
parentfa0f4825937ed93163bb2cd165c001d7444d8928 (diff)
downloadlibsurvive-27c9edd889c746e818dc3aa55971d9cd6d8595a7.tar.gz
libsurvive-27c9edd889c746e818dc3aa55971d9cd6d8595a7.tar.bz2
Manual registration on Windows
-rw-r--r--include/libsurvive/survive.h46
-rwxr-xr-xsrc/survive.c22
2 files changed, 15 insertions, 53 deletions
diff --git a/include/libsurvive/survive.h b/include/libsurvive/survive.h
index deb91c4..3bc3b33 100644
--- a/include/libsurvive/survive.h
+++ b/include/libsurvive/survive.h
@@ -136,50 +136,12 @@ void survive_default_angle_process( SurviveObject * so, int sensor_id, int acode
////////////////////// Survive Drivers ////////////////////////////
-// The following macros were taken from StackOverflow here:
-// http://stackoverflow.com/questions/1113409/attribute-constructor-equivalent-in-vc
-// The author, Joe Lowe explicitly released this code into the public domain as part of his post.
-#ifdef __cplusplus
-#define INITIALIZER(f) \
- static void f(void); \
- struct f##_t_ { f##_t_(void) { f(); } }; static f##_t_ f##_; \
- static void f(void)
-#elif defined(_MSC_VER)
-#pragma section(".CRT$XCU",read)
-#define INITIALIZER2_(f,p) \
- __declspec(dllexport) void f(void); \
- __declspec(allocate(".CRT$XCU")) void (*f##_)(void) = f; \
- volatile static void * LTRegistrationPinnerFor##f = &##f; \
- __pragma(comment(linker,"/include:" p #f "_")) \
- void f(void)
-#ifdef _WIN64
-#define INITIALIZER(f) INITIALIZER2_(f,"")
-#else
-#define INITIALIZER(f) INITIALIZER2_(f,"_")
-#endif
+#ifdef _WIN32
+#define REGISTER_LINKTIME( func )
#else
-#define INITIALIZER(f) \
- static void f(void) __attribute__((constructor)); \
- static void f(void)
-#endif
-// End macros from StackOverflow.
-
-//static void foo(void)
-//{
-// int a=0;
-//}
-//
-//INITIALIZER(foo);
-
-
-void RegisterDriver( const char * name, void * data );
-
#define REGISTER_LINKTIME( func ) \
- __declspec(dllexport) void LTRegister##func() { RegisterDriver( #func, &func ); } \
- INITIALIZER(LTRegister##func)
-
-
- //void __attribute__((constructor)) LTRegister##func() { RegisterDriver(#func, &func); }
+ void __attribute__((constructor)) LTRegister##func() { RegisterDriver(#func, &func); }
+#endif
diff --git a/src/survive.c b/src/survive.c
index c2b2940..d7aa691 100755
--- a/src/survive.c
+++ b/src/survive.c
@@ -47,17 +47,17 @@ SurviveContext * survive_init( int headless )
did_runtime_symnum = 1;
}
#endif
-//#ifdef MANUAL_REGISTRATION
-// // note: this manual registration is currently only in use on builds using Visual Studio.
-//
-//#define MANUAL_DRIVER_REGISTRATION(func) int func( SurviveObject * so, PoserData * pd ); RegisterDriver( #func, &func);
-//
-// MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow)
-// MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho)
-// MANUAL_DRIVER_REGISTRATION(PoserDummy)
-// MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive)
-//
-//#endif
+#ifdef MANUAL_REGISTRATION
+ // note: this manual registration is currently only in use on builds using Visual Studio.
+
+#define MANUAL_DRIVER_REGISTRATION(func) int func( SurviveObject * so, PoserData * pd ); RegisterDriver( #func, &func);
+
+ MANUAL_DRIVER_REGISTRATION(PoserCharlesSlow)
+ MANUAL_DRIVER_REGISTRATION(PoserDaveOrtho)
+ MANUAL_DRIVER_REGISTRATION(PoserDummy)
+ MANUAL_DRIVER_REGISTRATION(DriverRegHTCVive)
+
+#endif
int r = 0;
int i = 0;