Index: libcfa/prelude/sync-builtins.cf
===================================================================
--- libcfa/prelude/sync-builtins.cf	(revision 686f731009686a6516b3765a330ea882719321f4)
+++ libcfa/prelude/sync-builtins.cf	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
@@ -323,4 +323,5 @@
 _Bool __sync_bool_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
 #endif
+forall(dtype T) _Bool __sync_bool_compare_and_swap(T * volatile *, T *, T*, ...);
 
 char __sync_val_compare_and_swap(volatile char *, char, char,...);
@@ -348,4 +349,5 @@
 unsigned __int128 __sync_val_compare_and_swap_16(volatile unsigned __int128 *, unsigned __int128, unsigned __int128,...);
 #endif
+forall(dtype T) T * __sync_val_compare_and_swap(T * volatile *, T *, T*,...);
 
 char __sync_lock_test_and_set(volatile char *, char,...);
@@ -434,39 +436,41 @@
 #endif
 
-char __atomic_exchange_n(volatile char *, volatile char *, int);
+char __atomic_exchange_n(volatile char *, char, int);
 char __atomic_exchange_1(volatile char *, char, int);
 void __atomic_exchange(volatile char *, volatile char *, volatile char *, int);
-signed char __atomic_exchange_n(volatile signed char *, volatile signed char *, int);
+signed char __atomic_exchange_n(volatile signed char *, signed char, int);
 signed char __atomic_exchange_1(volatile signed char *, signed char, int);
 void __atomic_exchange(volatile signed char *, volatile signed char *, volatile signed char *, int);
-unsigned char __atomic_exchange_n(volatile unsigned char *, volatile unsigned char *, int);
+unsigned char __atomic_exchange_n(volatile unsigned char *, unsigned char, int);
 unsigned char __atomic_exchange_1(volatile unsigned char *, unsigned char, int);
 void __atomic_exchange(volatile unsigned char *, volatile unsigned char *, volatile unsigned char *, int);
-signed short __atomic_exchange_n(volatile signed short *, volatile signed short *, int);
+signed short __atomic_exchange_n(volatile signed short *, signed short, int);
 signed short __atomic_exchange_2(volatile signed short *, signed short, int);
 void __atomic_exchange(volatile signed short *, volatile signed short *, volatile signed short *, int);
-unsigned short __atomic_exchange_n(volatile unsigned short *, volatile unsigned short *, int);
+unsigned short __atomic_exchange_n(volatile unsigned short *, unsigned short, int);
 unsigned short __atomic_exchange_2(volatile unsigned short *, unsigned short, int);
 void __atomic_exchange(volatile unsigned short *, volatile unsigned short *, volatile unsigned short *, int);
-signed int __atomic_exchange_n(volatile signed int *, volatile signed int *, int);
+signed int __atomic_exchange_n(volatile signed int *, signed int, int);
 signed int __atomic_exchange_4(volatile signed int *, signed int, int);
 void __atomic_exchange(volatile signed int *, volatile signed int *, volatile signed int *, int);
-unsigned int __atomic_exchange_n(volatile unsigned int *, volatile unsigned int *, int);
+unsigned int __atomic_exchange_n(volatile unsigned int *, unsigned int, int);
 unsigned int __atomic_exchange_4(volatile unsigned int *, unsigned int, int);
 void __atomic_exchange(volatile unsigned int *, volatile unsigned int *, volatile unsigned int *, int);
-signed long long int __atomic_exchange_n(volatile signed long long int *, volatile signed long long int *, int);
+signed long long int __atomic_exchange_n(volatile signed long long int *, signed long long int, int);
 signed long long int __atomic_exchange_8(volatile signed long long int *, signed long long int, int);
 void __atomic_exchange(volatile signed long long int *, volatile signed long long int *, volatile signed long long int *, int);
-unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, volatile unsigned long long int *, int);
+unsigned long long int __atomic_exchange_n(volatile unsigned long long int *, unsigned long long int, int);
 unsigned long long int __atomic_exchange_8(volatile unsigned long long int *, unsigned long long int, int);
 void __atomic_exchange(volatile unsigned long long int *, volatile unsigned long long int *, volatile unsigned long long int *, int);
 #if defined(__SIZEOF_INT128__)
-signed __int128 __atomic_exchange_n(volatile signed __int128 *, volatile signed __int128 *, int);
+signed __int128 __atomic_exchange_n(volatile signed __int128 *, signed __int128, int);
 signed __int128 __atomic_exchange_16(volatile signed __int128 *, signed __int128, int);
 void __atomic_exchange(volatile signed __int128 *, volatile signed __int128 *, volatile signed __int128 *, int);
-unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, volatile unsigned __int128 *, int);
+unsigned __int128 __atomic_exchange_n(volatile unsigned __int128 *, unsigned __int128, int);
 unsigned __int128 __atomic_exchange_16(volatile unsigned __int128 *, unsigned __int128, int);
 void __atomic_exchange(volatile unsigned __int128 *, volatile unsigned __int128 *, volatile unsigned __int128 *, int);
 #endif
+forall(dtype T) T * __atomic_exchange_n(T * volatile *, T *, int);
+forall(dtype T) void __atomic_exchange(T * volatile *, T * volatile *, T * volatile *, int);
 
 _Bool __atomic_load_n(const volatile _Bool *, int);
@@ -507,4 +511,6 @@
 void __atomic_load(const volatile unsigned __int128 *, volatile unsigned __int128 *, int);
 #endif
+forall(dtype T) T * __atomic_load_n(T * const volatile *, int);
+forall(dtype T) void __atomic_load(T * const volatile *, T **, int);
 
 _Bool __atomic_compare_exchange_n(volatile char *, char *, char, _Bool, int, int);
@@ -543,4 +549,6 @@
 _Bool __atomic_compare_exchange   (volatile unsigned __int128 *, unsigned __int128 *, unsigned __int128 *, _Bool, int, int);
 #endif
+forall(dtype T) _Bool __atomic_compare_exchange_n (T * volatile *, T **, T*, _Bool, int, int);
+forall(dtype T) _Bool __atomic_compare_exchange   (T * volatile *, T **, T**, _Bool, int, int);
 
 void __atomic_store_n(volatile _Bool *, _Bool, int);
@@ -581,4 +589,6 @@
 void __atomic_store(volatile unsigned __int128 *, unsigned __int128 *, int);
 #endif
+forall(dtype T) void __atomic_store_n(T * volatile *, T *, int);
+forall(dtype T) void __atomic_store(T * volatile *, T **, int);
 
 char __atomic_add_fetch  (volatile char *, char, int);
Index: tests/builtins/sync.cfa
===================================================================
--- tests/builtins/sync.cfa	(revision 686f731009686a6516b3765a330ea882719321f4)
+++ tests/builtins/sync.cfa	(revision 98d4df99d1a62214a4467c21f220c266138e9826)
@@ -11,4 +11,5 @@
 	volatile __int128 * vp16 = 0; __int128 * rp16 = 0; __int128 v16 = 0;
 	#endif
+	struct type * volatile * vpp = 0; struct type ** rpp = 0; struct type * vp = 0;
 
 	{ char ret; ret = __sync_fetch_and_add(vp1, v1); }
@@ -180,4 +181,5 @@
 	{ _Bool ret; ret = __sync_bool_compare_and_swap_16(vp16, v16,v16); }
 	#endif
+	{ _Bool ret; ret = __sync_bool_compare_and_swap(vpp, vp, vp); }
 
 	{ char ret; ret = __sync_val_compare_and_swap(vp1, v1, v1); }
@@ -193,4 +195,6 @@
 	{ __int128 ret; ret = __sync_val_compare_and_swap_16(vp16, v16,v16); }
 	#endif
+	{ struct type * ret; ret = __sync_val_compare_and_swap(vpp, vp, vp); }
+
 
 	{ char ret; ret = __sync_lock_test_and_set(vp1, v1); }
@@ -230,21 +234,23 @@
 	{ __atomic_clear(vp1, v1); }
 
-	{ char ret; ret = __atomic_exchange_n(vp1, &v1, __ATOMIC_SEQ_CST); }
+	{ char ret; ret = __atomic_exchange_n(vp1, v1, __ATOMIC_SEQ_CST); }
 	{ char ret; ret = __atomic_exchange_1(vp1, v1, __ATOMIC_SEQ_CST); }
 	{ char ret; __atomic_exchange(vp1, &v1, &ret, __ATOMIC_SEQ_CST); }
-	{ short ret; ret = __atomic_exchange_n(vp2, &v2, __ATOMIC_SEQ_CST); }
+	{ short ret; ret = __atomic_exchange_n(vp2, v2, __ATOMIC_SEQ_CST); }
 	{ short ret; ret = __atomic_exchange_2(vp2, v2, __ATOMIC_SEQ_CST); }
 	{ short ret; __atomic_exchange(vp2, &v2, &ret, __ATOMIC_SEQ_CST); }
-	{ int ret; ret = __atomic_exchange_n(vp4, &v4, __ATOMIC_SEQ_CST); }
+	{ int ret; ret = __atomic_exchange_n(vp4, v4, __ATOMIC_SEQ_CST); }
 	{ int ret; ret = __atomic_exchange_4(vp4, v4, __ATOMIC_SEQ_CST); }
 	{ int ret; __atomic_exchange(vp4, &v4, &ret, __ATOMIC_SEQ_CST); }
-	{ long long int ret; ret = __atomic_exchange_n(vp8, &v8, __ATOMIC_SEQ_CST); }
+	{ long long int ret; ret = __atomic_exchange_n(vp8, v8, __ATOMIC_SEQ_CST); }
 	{ long long int ret; ret = __atomic_exchange_8(vp8, v8, __ATOMIC_SEQ_CST); }
 	{ long long int ret; __atomic_exchange(vp8, &v8, &ret, __ATOMIC_SEQ_CST); }
 	#if defined(__SIZEOF_INT128__)
-	{ __int128 ret; ret = __atomic_exchange_n(vp16, &v16, __ATOMIC_SEQ_CST); }
+	{ __int128 ret; ret = __atomic_exchange_n(vp16, v16, __ATOMIC_SEQ_CST); }
 	{ __int128 ret; ret = __atomic_exchange_16(vp16, v16, __ATOMIC_SEQ_CST); }
 	{ __int128 ret; __atomic_exchange(vp16, &v16, &ret, __ATOMIC_SEQ_CST); }
 	#endif
+	{ struct type * ret; ret = __atomic_exchange_n(vpp, vp, __ATOMIC_SEQ_CST); }
+	{ struct type * ret; __atomic_exchange(vpp, &vp, &ret, __ATOMIC_SEQ_CST); }
 
 	{ char ret; ret = __atomic_load_n(vp1, __ATOMIC_SEQ_CST); }
@@ -265,4 +271,6 @@
 	{ __int128 ret; __atomic_load(vp16, &ret, __ATOMIC_SEQ_CST); }
 	#endif
+	{ struct type * ret; ret = __atomic_load_n(vpp, __ATOMIC_SEQ_CST); }
+	{ struct type * ret; __atomic_load(vpp, &ret, __ATOMIC_SEQ_CST); }
 
 	{ _Bool ret; ret = __atomic_compare_exchange_n(vp1, rp1, v1, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
@@ -283,4 +291,6 @@
 	{ _Bool ret; ret = __atomic_compare_exchange(vp16, rp16, &v16, 0, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
 	#endif
+	{ _Bool ret; ret = __atomic_compare_exchange_n(vpp, rpp, vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
+	{ _Bool ret; ret = __atomic_compare_exchange(vpp, rpp, &vp, false, __ATOMIC_SEQ_CST, __ATOMIC_SEQ_CST); }
 
 	{ __atomic_store_n(vp1, v1, __ATOMIC_SEQ_CST); }
@@ -301,4 +311,6 @@
 	{ __atomic_store(vp16, &v16, __ATOMIC_SEQ_CST); }
 	#endif
+	{ __atomic_store_n(vpp, vp, __ATOMIC_SEQ_CST); }
+	{ __atomic_store(vpp, &vp, __ATOMIC_SEQ_CST); }
 
 	{ char ret; ret = __atomic_add_fetch(vp1, v1, __ATOMIC_SEQ_CST); }
