diff options
author | Mike Hommey <mh@glandium.org> | 2018-02-22 13:39:45 +0900 |
---|---|---|
committer | Mike Hommey <mh@glandium.org> | 2018-02-22 13:39:45 +0900 |
commit | fcee092fbb17e040df7e1e26d8ed5e725e20e168 (patch) | |
tree | 91e5f7e429c3858d4466836f1ae37b8a64bbd086 | |
parent | 470f4454769ab742c7f8f167d616adfc557a50af (diff) | |
download | nspr-hg-fcee092fbb17e040df7e1e26d8ed5e725e20e168.tar.gz |
Bug 1399746 - Use atexit() to register _PR_Fini on OSX. r=kaieNSPR_4_19_BETA1
-rw-r--r-- | pr/src/pthreads/ptthread.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/pr/src/pthreads/ptthread.c b/pr/src/pthreads/ptthread.c index 6046d5d8..e61a4cbd 100644 --- a/pr/src/pthreads/ptthread.c +++ b/pr/src/pthreads/ptthread.c @@ -978,7 +978,23 @@ void _PR_InitThreads( * GCC supports the constructor and destructor attributes as of * version 2.5. */ +#if defined(DARWIN) +/* + * The dynamic linker on OSX doesn't execute __attribute__((destructor)) + * destructors in the right order wrt non-__attribute((destructor)) destructors + * in other libraries. So use atexit() instead, which does. + * See https://bugzilla.mozilla.org/show_bug.cgi?id=1399746#c99 + */ +static void _PR_Fini(void); + +__attribute__ ((constructor)) +static void _register_PR_Fini() { + atexit(_PR_Fini); +} +#else static void _PR_Fini(void) __attribute__ ((destructor)); +#endif + #elif defined(__SUNPRO_C) /* * Sun Studio compiler |