]> granicus.if.org Git - php/commitdiff
- Fixed bug #55874 (GCC does not provide __sync_fetch_and_add on some archs)
authorFelipe Pena <felipe@php.net>
Tue, 15 Nov 2011 20:33:26 +0000 (20:33 +0000)
committerFelipe Pena <felipe@php.net>
Tue, 15 Nov 2011 20:33:26 +0000 (20:33 +0000)
  patch by: klightspeed at netspace dot net dot au

NEWS
configure.in
ext/standard/php_crypt_r.c

diff --git a/NEWS b/NEWS
index 350ede99651c0b1dca0ab8927e70a00578299654..63714b54a1f9007cfa49c2551f1b69ecd8753ed4 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -3,6 +3,8 @@ PHP                                                                        NEWS
 ?? ??? 2011, PHP 5.3.9
 
 - Core:
+  . Fixed bug #55874 (GCC does not provide __sync_fetch_and_add on some archs).
+    (klightspeed at netspace dot net dot au)
   . Fixed bug #52624 (tempnam() by-pass open_basedir with inexistent directory).
     (Felipe)
 
index a63afa7868da3b6080251d6ed882f3c49dfef8e1..3ab1e4632c772e6d2866161e425ba82fb41c0e5d 100644 (file)
@@ -661,6 +661,13 @@ if test "$ac_cv_func_getaddrinfo" = yes; then
   AC_DEFINE(HAVE_GETADDRINFO,1,[Define if you have the getaddrinfo function])
 fi
 
+dnl Check for the __sync_fetch_and_add builtin
+AC_CACHE_CHECK([for __sync_fetch_and_add], ac_cv_func_sync_fetch_and_add,
+[AC_TRY_LINK([],[int x;__sync_fetch_and_add(&x,1);],ac_cv_func_sync_fetch_and_add=yes,ac_cv_func_sync_fetch_and_add=no)])
+if test "$ac_cv_func_sync_fetch_and_add" = yes; then
+  AC_DEFINE(HAVE_SYNC_FETCH_AND_ADD,1,[Define if you have the __sync_fetch_and_add function])
+fi
+
 AC_REPLACE_FUNCS(strlcat strlcpy getopt)
 AC_FUNC_UTIME_NULL
 AC_FUNC_ALLOCA
index 042bcb9742eb67c336822ccacb4f9fa9526a6134..13db65e1a72088d355ba710b402fa8eba7fa7d9b 100644 (file)
@@ -94,8 +94,7 @@ void _crypt_extended_init_r(void)
        if (!initialized) {
 #ifdef PHP_WIN32
                InterlockedIncrement(&initialized);
-#elif (defined(__GNUC__) && !defined(__hpux) && !defined(__hppa__) && (__GNUC__ > 4 || \
-    (__GNUC__ == 4 && (__GNUC_MINOR__ > 1 || (__GNUC_MINOR__ == 1 && __GNUC_PATCHLEVEL__ > 1)))))
+#elif defined(HAVE_SYNC_FETCH_AND_ADD)
                __sync_fetch_and_add(&initialized, 1);
 #elif defined(HAVE_ATOMIC_H) /* Solaris 10 defines atomic API within */
                membar_producer();