]> git.saurik.com Git - apple/libc.git/blobdiff - stdlib/FreeBSD/exit.c
Libc-1244.50.9.tar.gz
[apple/libc.git] / stdlib / FreeBSD / exit.c
index aa23703ec0c6e0489716829f65c310baee6a198c..ba66bc6644ff357674b69163510e8ec001a4c9e8 100644 (file)
@@ -41,16 +41,23 @@ __FBSDID("$FreeBSD: src/lib/libc/stdlib/exit.c,v 1.9 2007/01/09 00:28:09 imp Exp
 #include "atexit.h"
 #include "libc_private.h"
 
+#include <TargetConditionals.h>
+
 void (*__cleanup)(void);
-extern void __exit(int);
+extern void __exit(int) __attribute__((noreturn));
+#if !TARGET_IPHONE_SIMULATOR && (__i386__ || __x86_64__)
+extern void _tlv_exit();
+#endif
 
 /*
  * Exit, flushing stdio buffers if necessary.
  */
 void
-exit(status)
-       int status;
+exit(int status)
 {
+#if !TARGET_IPHONE_SIMULATOR && (__i386__ || __x86_64__)
+       _tlv_exit(); // C++11 requires thread_local objects to be destroyed before global objects
+#endif
        __cxa_finalize(NULL);
        if (__cleanup)
                (*__cleanup)();