Add macro for dynamic library plugin initializer definition.
PiperOrigin-RevId: 478544478 Change-Id: Idc899eef25261f2cb0b8317a84989cea2d8c2243
This commit is contained in:
committed by
Copybara-Service
parent
7072b61cc5
commit
f9b4593d11
@@ -58,4 +58,31 @@ struct mjpPlugin_ {
|
|||||||
};
|
};
|
||||||
typedef struct mjpPlugin_ mjpPlugin;
|
typedef struct mjpPlugin_ mjpPlugin;
|
||||||
|
|
||||||
|
#if defined(__has_attribute)
|
||||||
|
|
||||||
|
#if __has_attribute(constructor)
|
||||||
|
#define mjPLUGIN_DYNAMIC_LIBRARY_INIT \
|
||||||
|
__attribute__((constructor)) static void _mjplugin_init(void)
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#elif defined(_MSC_VER)
|
||||||
|
|
||||||
|
#ifndef mjDLLMAIN
|
||||||
|
#define mjDLLMAIN DllMain
|
||||||
|
#endif
|
||||||
|
|
||||||
|
// NOLINTBEGIN(runtime/int)
|
||||||
|
#define mjPLUGIN_DYNAMIC_LIBRARY_INIT \
|
||||||
|
static void _mjplugin_dllmain(void); \
|
||||||
|
static int __stdcall mjDLLMAIN(void* hinst, unsigned long reason, void* reserved) { \
|
||||||
|
if (reason == 1) { \
|
||||||
|
_mjplugin_dllmain(); \
|
||||||
|
} \
|
||||||
|
return 1; \
|
||||||
|
} \
|
||||||
|
static void _mjplugin_dllmain(void)
|
||||||
|
// NOLINTEND(runtime/int)
|
||||||
|
|
||||||
|
#endif // defined(_MSC_VER)
|
||||||
|
|
||||||
#endif // MUJOCO_INCLUDE_MJPLUGIN_H_
|
#endif // MUJOCO_INCLUDE_MJPLUGIN_H_
|
||||||
|
|||||||
Reference in New Issue
Block a user