diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/libirecovery.c | 28 |
1 files changed, 18 insertions, 10 deletions
diff --git a/src/libirecovery.c b/src/libirecovery.c index 0e971a0..b0f6409 100644 --- a/src/libirecovery.c +++ b/src/libirecovery.c | |||
| @@ -442,7 +442,23 @@ static void _irecv_deinit(void) | |||
| 442 | static thread_once_t init_once = THREAD_ONCE_INIT; | 442 | static thread_once_t init_once = THREAD_ONCE_INIT; |
| 443 | static thread_once_t deinit_once = THREAD_ONCE_INIT; | 443 | static thread_once_t deinit_once = THREAD_ONCE_INIT; |
| 444 | 444 | ||
| 445 | #ifdef WIN32 | 445 | #ifndef HAVE_ATTRIBUTE_CONSTRUCTOR |
| 446 | #if defined(__llvm__) || defined(__GNUC__) | ||
| 447 | #define HAVE_ATTRIBUTE_CONSTRUCTOR | ||
| 448 | #endif | ||
| 449 | #endif | ||
| 450 | |||
| 451 | #ifdef HAVE_ATTRIBUTE_CONSTRUCTOR | ||
| 452 | static void __attribute__((constructor)) libirecovery_initialize(void) | ||
| 453 | { | ||
| 454 | thread_once(&init_once, _irecv_init); | ||
| 455 | } | ||
| 456 | |||
| 457 | static void __attribute__((destructor)) libirecovery_deinitialize(void) | ||
| 458 | { | ||
| 459 | thread_once(&deinit_once, _irecv_deinit); | ||
| 460 | } | ||
| 461 | #elif defined(WIN32) | ||
| 446 | BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) | 462 | BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) |
| 447 | { | 463 | { |
| 448 | switch (dwReason) { | 464 | switch (dwReason) { |
| @@ -458,15 +474,7 @@ BOOL WINAPI DllMain(HINSTANCE hModule, DWORD dwReason, LPVOID lpReserved) | |||
| 458 | return 1; | 474 | return 1; |
| 459 | } | 475 | } |
| 460 | #else | 476 | #else |
| 461 | static void __attribute__((constructor)) libirecovery_initialize(void) | 477 | #warning No compiler support for constructor/destructor attributes, some features might not be available. |
| 462 | { | ||
| 463 | thread_once(&init_once, _irecv_init); | ||
| 464 | } | ||
| 465 | |||
| 466 | static void __attribute__((destructor)) libirecovery_deinitialize(void) | ||
| 467 | { | ||
| 468 | thread_once(&deinit_once, _irecv_deinit); | ||
| 469 | } | ||
| 470 | #endif | 478 | #endif |
| 471 | 479 | ||
| 472 | #ifdef HAVE_IOKIT | 480 | #ifdef HAVE_IOKIT |
