Detect whether __sync_moo is usable, don't just fail if it's not.
May not be perfect, but this unhides a few ports on mips64* and hppa. ok landry@ sthen@
This commit is contained in:
parent
5abb33d175
commit
9aad273be3
@ -1,7 +1,4 @@
|
||||
# $OpenBSD: Makefile,v 1.12 2015/08/24 18:35:39 jca Exp $
|
||||
|
||||
BROKEN-hppa= undefined reference to __sync_val_compare_and_swap_4
|
||||
BROKEN-mips64= undefined reference to __sync_val_compare_and_swap_4
|
||||
# $OpenBSD: Makefile,v 1.13 2015/08/25 11:37:02 jca Exp $
|
||||
|
||||
COMMENT= JSON implementation in C
|
||||
|
||||
@ -18,7 +15,8 @@ PERMIT_PACKAGE_CDROM= Yes
|
||||
|
||||
MASTER_SITES = https://s3.amazonaws.com/json-c_releases/releases/
|
||||
|
||||
CONFIGURE_STYLE= gnu
|
||||
CONFIGURE_STYLE= autoconf autoheader
|
||||
AUTOCONF_VERSION= 2.69
|
||||
|
||||
# not enabled by default at present, but we want to make sure we
|
||||
# don't use it if it's later enabled as it disables using random(4).
|
||||
|
25
devel/json-c/patches/patch-configure_ac
Normal file
25
devel/json-c/patches/patch-configure_ac
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-configure_ac,v 1.1 2015/08/25 11:37:02 jca Exp $
|
||||
--- configure.ac.orig Mon Aug 24 20:07:25 2015
|
||||
+++ configure.ac Mon Aug 24 20:06:41 2015
|
||||
@@ -66,6 +66,21 @@ int main(int c,char* v) {return 0;}
|
||||
AC_MSG_RESULT(no)
|
||||
])
|
||||
|
||||
+AC_MSG_CHECKING([if compiler supports __sync_val_compare_and_swap with int objects])
|
||||
+AC_LINK_IFELSE([AC_LANG_SOURCE([[
|
||||
+int
|
||||
+main(void) {
|
||||
+ int r = 0;
|
||||
+ __sync_val_compare_and_swap(&r, 0, 1);
|
||||
+ return 0;
|
||||
+}
|
||||
+]])], [
|
||||
+ AC_DEFINE(HAS___SYNC_VAL_COMPARE_AND_SWAP_INT, 1, [Define if compiler supports __sync_val_compare_and_swap.])
|
||||
+ AC_MSG_RESULT(yes)
|
||||
+], [
|
||||
+ AC_MSG_RESULT(no)
|
||||
+])
|
||||
+
|
||||
AC_LANG_POP([C])
|
||||
|
||||
AM_PROG_LIBTOOL
|
25
devel/json-c/patches/patch-linkhash_c
Normal file
25
devel/json-c/patches/patch-linkhash_c
Normal file
@ -0,0 +1,25 @@
|
||||
$OpenBSD: patch-linkhash_c,v 1.1 2015/08/25 11:37:02 jca Exp $
|
||||
--- linkhash.c.orig Fri Apr 11 02:41:08 2014
|
||||
+++ linkhash.c Mon Aug 24 20:41:34 2015
|
||||
@@ -23,6 +23,7 @@
|
||||
|
||||
#include "random_seed.h"
|
||||
#include "linkhash.h"
|
||||
+#include "config.h"
|
||||
|
||||
void lh_abort(const char *msg, ...)
|
||||
{
|
||||
@@ -405,12 +406,11 @@ unsigned long lh_char_hash(const void *k)
|
||||
int seed;
|
||||
/* we can't use -1 as it is the unitialized sentinel */
|
||||
while ((seed = json_c_get_random_seed()) == -1);
|
||||
-#if defined __GNUC__
|
||||
+#if defined HAS___SYNC_VAL_COMPARE_AND_SWAP_INT
|
||||
__sync_val_compare_and_swap(&random_seed, -1, seed);
|
||||
#elif defined _MSC_VER
|
||||
InterlockedCompareExchange(&random_seed, seed, -1);
|
||||
#else
|
||||
-#warning "racy random seed initializtion if used by multiple threads"
|
||||
random_seed = seed; /* potentially racy */
|
||||
#endif
|
||||
}
|
Loading…
Reference in New Issue
Block a user