about summary refs log tree commit diff
path: root/stdlib/cxa_atexit.c
diff options
context:
space:
mode:
Diffstat (limited to 'stdlib/cxa_atexit.c')
-rw-r--r--stdlib/cxa_atexit.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/stdlib/cxa_atexit.c b/stdlib/cxa_atexit.c
index 490776105f..9b7a932b85 100644
--- a/stdlib/cxa_atexit.c
+++ b/stdlib/cxa_atexit.c
@@ -21,6 +21,8 @@
 
 #include <bits/libc-lock.h>
 #include "exit.h"
+#include <atomic.h>
+#include <sysdep.h>
 
 #undef __cxa_atexit
 
@@ -35,10 +37,14 @@ __cxa_atexit (void (*func) (void *), void *arg, void *d)
   if (new == NULL)
     return -1;
 
-  new->flavor = ef_cxa;
+#ifdef PTR_MANGLE
+  PTR_MANGLE (func);
+#endif
   new->func.cxa.fn = (void (*) (void *, int)) func;
   new->func.cxa.arg = arg;
   new->func.cxa.dso_handle = d;
+  atomic_write_barrier ();
+  new->flavor = ef_cxa;
   return 0;
 }
 INTDEF(__cxa_atexit)