proplib: use GCC atomic builtins if supported.

This commit is contained in:
Juan RP
2014-10-09 14:41:43 +02:00
parent 09c630a825
commit fe76af7702
3 changed files with 65 additions and 12 deletions

25
configure vendored
View File

@@ -340,6 +340,31 @@ echo "CPPFLAGS += -I\$(TOPDIR)/lib/portableproplib/prop" >>$CONFIG_MK
echo "LDFLAGS += -lpthread" >>$CONFIG_MK
echo "STATIC_LIBS += -lpthread" >>$CONFIG_MK
#
# Check for GCC atomic builtins.
#
func=atomic
printf "Checking for GCC atomic builtins ... "
cat <<EOF >_$func.c
int main() {
volatile unsigned long val = 1;
__sync_fetch_and_add(&val, 1);
__sync_fetch_and_sub(&val, 1);
__sync_add_and_fetch(&val, 1);
__sync_sub_and_fetch(&val, 1);
return 0;
}
EOF
if $XCC _$func.c -o _$func 2>/dev/null; then
echo yes.
HAVE_ATOMICS=1
else
echo no.
fi
rm -f _$func.c _$func
if test -n "$HAVE_ATOMICS"; then
echo "CPPFLAGS += -DHAVE_ATOMICS" >> $CONFIG_MK
fi
#
# Check for vasprintf().
#