]> Cypherpunks repositories - gostls13.git/commitdiff
[release-branch.go1.10] misc/cgo/test: fix issue 24161 test for 1.11 and earlier
authorKeith Randall <khr@google.com>
Thu, 12 Jul 2018 23:51:27 +0000 (16:51 -0700)
committerIan Lance Taylor <iant@golang.org>
Wed, 8 Aug 2018 00:26:58 +0000 (00:26 +0000)
The test uses functions from C that were introduced in OSX 1.12.
Include stubs for those functions when compiling for 1.11 and earlier.
This test really a compile-time test, it doesn't matter much what the
executed code actually does.
Use a nasty #define hack to work around the fact that cgo doesn't
support static global variables.

Update #25036

Change-Id: Icf6f7bc9b6b36cacc81d5d0e033a2ebaff7e0298
Reviewed-on: https://go-review.googlesource.com/123715
Run-TryBot: Keith Randall <khr@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-on: https://go-review.googlesource.com/124216

misc/cgo/test/issue24161e0/main.go
misc/cgo/test/issue24161e1/main.go
misc/cgo/test/issue24161e2/main.go

index ec5bea9662c7569405989db4dc027c91dcffd875..4e2e4b01d397dd4d4424a34e624b7809bd71ad06 100644 (file)
@@ -11,6 +11,12 @@ package issue24161e0
 #cgo LDFLAGS: -framework CoreFoundation -framework Security
 #include <CoreFoundation/CoreFoundation.h>
 #include <Security/Security.h>
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+  typedef CFStringRef SecKeyAlgorithm;
+  static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+  #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+  static SecKeyAlgorithm foo(void){return NULL;}
+#endif
 */
 import "C"
 import "testing"
index aea0ff50c50e674f7a7a78f648ca68bf049acc43..3e2aba2742c7bc11dc8e08a2e5d0b508f2139076 100644 (file)
@@ -11,6 +11,12 @@ package issue24161e1
 #cgo LDFLAGS: -framework CoreFoundation -framework Security
 #include <CoreFoundation/CoreFoundation.h>
 #include <Security/Security.h>
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+  typedef CFStringRef SecKeyAlgorithm;
+  static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+  #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+  static SecKeyAlgorithm foo(void){return NULL;}
+#endif
 */
 import "C"
 import (
index c6675a76894c04a2b570d7e6583328dbaadd4484..9e4053eba59d81fc5c787d5047041db3aab7948e 100644 (file)
@@ -11,6 +11,12 @@ package issue24161e2
 #cgo LDFLAGS: -framework CoreFoundation -framework Security
 #include <CoreFoundation/CoreFoundation.h>
 #include <Security/Security.h>
+#if __ENVIRONMENT_MAC_OS_X_VERSION_MIN_REQUIRED__ < 101200
+  typedef CFStringRef SecKeyAlgorithm;
+  static CFDataRef SecKeyCreateSignature(SecKeyRef key, SecKeyAlgorithm algorithm, CFDataRef dataToSign, CFErrorRef *error){return NULL;}
+  #define kSecKeyAlgorithmECDSASignatureDigestX962SHA1 foo()
+  static SecKeyAlgorithm foo(void){return NULL;}
+#endif
 */
 import "C"
 import (