]> Cypherpunks repositories - gostls13.git/commitdiff
misc/cgo/test: skip test7978 when using unsupported compilers
authorShenghou Ma <minux@golang.org>
Fri, 26 Dec 2014 06:20:29 +0000 (01:20 -0500)
committerMinux Ma <minux@golang.org>
Fri, 6 Feb 2015 05:49:47 +0000 (05:49 +0000)
On Darwin/ARM, because libSystem doesn't provide functions for
__sync_fetch_and_add, and only clang can inline that function,
skip the test when building with GCC.

Change-Id: Id5e9d8f9bbe1e6bcb2f381f0f66cf68aa95277c7
Reviewed-on: https://go-review.googlesource.com/2125
Reviewed-by: Ian Lance Taylor <iant@golang.org>
misc/cgo/test/issue7978.go

index 9e2afcf8d45641a033012d56797800429f22dcd1..613f28e11f7a1bdfd749bef25c6ed3ab90be5b8b 100644 (file)
@@ -12,9 +12,23 @@ package cgotest
 
 void issue7978cb(void);
 
+#if defined(__APPLE__) && defined(__arm__)
+// on Darwin/ARM, libSystem doesn't provide implementation of the __sync_fetch_and_add
+// primitive, and although gcc supports it, it doesn't inline its definition.
+// Clang could inline its definition, so we require clang on Darwin/ARM.
+#if defined(__clang__)
+#define HAS_SYNC_FETCH_AND_ADD 1
+#else
+#define HAS_SYNC_FETCH_AND_ADD 0
+#endif
+#else
+#define HAS_SYNC_FETCH_AND_ADD 1
+#endif
+
 // use ugly atomic variable sync since that doesn't require calling back into
 // Go code or OS dependencies
 static void issue7978c(uint32_t *sync) {
+#if HAS_SYNC_FETCH_AND_ADD
        while(__sync_fetch_and_add(sync, 0) != 0)
                ;
        __sync_fetch_and_add(sync, 1);
@@ -24,6 +38,7 @@ static void issue7978c(uint32_t *sync) {
        __sync_fetch_and_add(sync, 1);
        while(__sync_fetch_and_add(sync, 0) != 6)
                ;
+#endif
 }
 */
 import "C"
@@ -85,6 +100,9 @@ func test7978(t *testing.T) {
        if runtime.Compiler == "gccgo" {
                t.Skip("gccgo can not do stack traces of C code")
        }
+       if C.HAS_SYNC_FETCH_AND_ADD == 0 {
+               t.Skip("clang required for __sync_fetch_and_add support on darwin/arm")
+       }
        if os.Getenv("GOTRACEBACK") != "2" {
                t.Fatalf("GOTRACEBACK must be 2")
        }