Skip to contentSkip to conversation

configure.ac: rework compiler builtin atomic tests

PATCH In review Jonathan Gray 2 participants 2 messages Aug 29, 2015 – Nov 16, 2015

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 configure.ac: rework compiler builtin atomic tests

The libdrm autoconf test for atomics uses __sync_val_compare_and_swap with the address of a function argument which triggers a gcc ICE on sparc64 with the OpenBSD system compiler.

Mark Kettenis pointed out that while other architectures probably spill the argument onto the stack this is likely not the case on register window architectures like SPARC and suggested passing a pointer as an argument instead which avoids the ICE and allows the drm libraries requiring atomics to build on sparc64 with the autoconf build.

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +2 -2
index f07507b..705ac3e 100644
@@ -210,8 +210,8 @@ AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [
 	drm_cv_atomic_primitives="none"
 
 	AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-	int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
-	int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
+	int atomic_add(int *i) { return __sync_fetch_and_add (i, 1); }
+	int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
 					  ]],[[]])], [drm_cv_atomic_primitives="Intel"],[])
 
 	if test "x$drm_cv_atomic_primitives" = "xnone"; then
Signature · 6 lines
2.4.6

_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel
#1 lore raw

Hi Jonathan,

Quoted 23 lines · Jonathan Gray

The libdrm autoconf test for atomics uses __sync_val_compare_and_swap with the address of a function argument which triggers a gcc ICE on sparc64 with the OpenBSD system compiler.

Mark Kettenis pointed out that while other architectures probably spill the argument onto the stack this is likely not the case on register window architectures like SPARC and suggested passing a pointer as an argument instead which avoids the ICE and allows the drm libraries requiring atomics to build on sparc64 with the autoconf build.

---
 configure.ac | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
configure.ac +0 -0
index f07507b..705ac3e 100644

configure.ac AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [ · line 216

Quoted 9 lines
configure.ac +2 -2
@@ -210,8 +210,8 @@ AC_CACHE_CHECK([for native atomic primitives], drm_cv_atomic_primitives, [
        drm_cv_atomic_primitives="none"
 
        AC_LINK_IFELSE([AC_LANG_PROGRAM([[
-       int atomic_add(int i) { return __sync_fetch_and_add (&i, 1); }
-       int atomic_cmpxchg(int i, int j, int k) { return __sync_val_compare_and_swap (&i, j, k); }
+       int atomic_add(int *i) { return __sync_fetch_and_add (i, 1); }
+       int atomic_cmpxchg(int *i, int j, int k) { return __sync_val_compare_and_swap (i, j, k); }
                                          ]],[[]])], [drm_cv_atomic_primitives="Intel"],[])
 

Just pushed this patch to master.

Sorry that it took so long - must have missed it. Feel free to ping if you catch us 'sleeping on the job'.

Thanks
Emil
_______________________________________________
dri-devel mailing list
[email protected]
http://lists.freedesktop.org/mailman/listinfo/dri-devel