summary refs log tree commit diff stats
path: root/lib/nimbase.h
diff options
context:
space:
mode:
authorAraq <rumpf_a@web.de>2011-12-22 15:04:00 +0100
committerAraq <rumpf_a@web.de>2011-12-22 15:04:00 +0100
commitcd83cc81aa58922e0a8370ae5928d5b5aaa16f84 (patch)
treee3abff5b7a2cd46977e8435a4ebbfdde0c19ba07 /lib/nimbase.h
parentf19c1c0f6e93a561dc13ef57d136957edeba9ed4 (diff)
downloadNim-cd83cc81aa58922e0a8370ae5928d5b5aaa16f84.tar.gz
code gen can generate code to keep alive stack roots
Diffstat (limited to 'lib/nimbase.h')
-rwxr-xr-xlib/nimbase.h8
1 files changed, 8 insertions, 0 deletions
diff --git a/lib/nimbase.h b/lib/nimbase.h
index bc8c3c28c..e2afed8f9 100755
--- a/lib/nimbase.h
+++ b/lib/nimbase.h
@@ -16,6 +16,7 @@ __GNUC__
 __DMC__
 __POCC__
 __TINYC__
+__clang__
 */
 
 
@@ -437,4 +438,11 @@ __declspec(naked) int __fastcall NimXadd(volatile int* pNum, int val) {
 #  define unlikely(x) (x)
 #endif
 
+#if defined(__GNUC__) || defined(__clang__)
+static inline void GCGuard (void *ptr) { asm volatile ("" :: "X" (ptr)); }
+#  define GC_GUARD __attribute__ ((cleanup(GCGuard)))
+#else
+#  define GC_GUARD
+#endif
+
 #endif