-
Notifications
You must be signed in to change notification settings - Fork 102
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move from lazy_static to a weak static in C lib
Sadly, a C library is necessary for this, as `#[linkage="weak"]` is still unstable in Rust. Sadly, much like with the lazy-static mutex implementation, it is a wide-hitting hammer and will also hit platforms which aren’t affected by this (by virtue of using thread-local dlerrors). This will require a "major" version bump. Fixes #32
- Loading branch information
Showing
5 changed files
with
53 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,20 @@ | ||
#include <pthread.h> | ||
#include <stdlib.h> | ||
|
||
pthread_mutex_t __attribute__((weak)) rust_libloading_dlerror_mutex = PTHREAD_MUTEX_INITIALIZER; | ||
|
||
void __attribute__((weak)) | ||
rust_libloading_dlerror_mutex_lock(void) | ||
{ | ||
if (pthread_mutex_lock(&rust_libloading_dlerror_mutex) != 0) { | ||
abort(); | ||
} | ||
} | ||
|
||
void __attribute__((weak)) | ||
rust_libloading_dlerror_mutex_unlock(void) | ||
{ | ||
if (pthread_mutex_unlock(&rust_libloading_dlerror_mutex) != 0) { | ||
abort(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters