mirror of
https://github.com/RPCS3/libusb.git
synced 2026-07-21 00:16:04 -04:00
darwin: use destructor function instead of atexit to cleanup state
Using an atexit function to cleanup the state could cause weird interactions with other atexit functions. Ensure the darwin cleanup function is called last by making it a destructor function instead. Signed-off-by: Nathan Hjelm <hjelmn@me.com>
This commit is contained in:
@@ -401,7 +401,8 @@ static void *darwin_event_thread_main (void *arg0) {
|
||||
pthread_exit (NULL);
|
||||
}
|
||||
|
||||
static void _darwin_finalize(void) {
|
||||
/* cleanup function to destroy cached devices */
|
||||
static void __attribute__((destructor)) _darwin_finalize(void) {
|
||||
struct darwin_cached_device *dev, *next;
|
||||
|
||||
usbi_mutex_lock(&darwin_cached_devices_lock);
|
||||
@@ -413,7 +414,6 @@ static void _darwin_finalize(void) {
|
||||
|
||||
static int darwin_init(struct libusb_context *ctx) {
|
||||
host_name_port_t host_self;
|
||||
static int initted = 0;
|
||||
int rc;
|
||||
|
||||
rc = darwin_scan_devices (ctx);
|
||||
@@ -424,11 +424,6 @@ static int darwin_init(struct libusb_context *ctx) {
|
||||
if (OSAtomicIncrement32Barrier(&initCount) == 1) {
|
||||
/* create the clocks that will be used */
|
||||
|
||||
if (!initted) {
|
||||
initted = 1;
|
||||
atexit(_darwin_finalize);
|
||||
}
|
||||
|
||||
host_self = mach_host_self();
|
||||
host_get_clock_service(host_self, CALENDAR_CLOCK, &clock_realtime);
|
||||
host_get_clock_service(host_self, SYSTEM_CLOCK, &clock_monotonic);
|
||||
|
||||
@@ -1 +1 @@
|
||||
#define LIBUSB_NANO 10869
|
||||
#define LIBUSB_NANO 10870
|
||||
|
||||
Reference in New Issue
Block a user