tony2001                                 Wed, 02 Dec 2009 16:37:42 +0000

Revision: http://svn.php.net/viewvc?view=revision&revision=291595

Log:
add support for some weird platforms

Changed paths:
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_atomic.h
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_conf.c
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_env.c
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_php_trace.c
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_trace_pread.c
    U   php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/xml_config.h

Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_atomic.h
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_atomic.h  2009-12-02 
15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_atomic.h  2009-12-02 
16:37:42 UTC (rev 291595)
@@ -5,7 +5,11 @@
 #ifndef FPM_ATOMIC_H
 #define FPM_ATOMIC_H 1

-#include <stdint.h>
+#if HAVE_INTTYPES_H
+# include <stdint.h>
+#else
+# include <stdint.h>
+#endif
 #include <sched.h>

 #if ( __i386__ || __i386 )
@@ -57,8 +61,58 @@
        return res;
 }

+#if (__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
+
+#elif ( __arm__ || __arm ) /* W-Mark Kubacki */
+
+#if (__arch64__ || __arch64)
+typedef int64_t                     atomic_int_t;
+typedef uint64_t                    atomic_uint_t;
 #else
+typedef int32_t                     atomic_int_t;
+typedef uint32_t                    atomic_uint_t;
+#endif

+#define atomic_cmp_set(a,b,c) __sync_bool_compare_and_swap(a,b,c)
+
+#endif /* defined (__GNUC__) &&... */
+
+#elif ( __sparc__ || __sparc ) /* Marcin Ochab */
+
+#if (__arch64__ || __arch64)
+typedef uint64_t                    atomic_uint_t;
+typedef volatile atomic_uint_t      atomic_t;
+
+static inline int atomic_cas_64(atomic_t *lock, atomic_uint_t old, 
atomic_uint_t new)
+{
+       __asm__ __volatile__("casx [%2], %3, %0 " : "=&r"(new)  : "0"(new), 
"r"(lock), "r"(old): "memory");
+
+       return new;
+}
+
+static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, 
atomic_uint_t set)
+{
+       return (atomic_cas_64(lock, old, set)==old);
+}
+#else
+typedef uint32_t                    atomic_uint_t;
+typedef volatile atomic_uint_t      atomic_t;
+
+static inline int atomic_cas_32(atomic_t *lock, atomic_uint_t old, 
atomic_uint_t new)
+{
+       __asm__ __volatile__("cas [%2], %3, %0 " : "=&r"(new)  : "0"(new), 
"r"(lock), "r"(old): "memory");
+
+       return new;
+}
+
+static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, 
atomic_uint_t set)
+{
+       return (atomic_cas_32(lock, old, set)==old);
+}
+#endif
+
+#else
+
 #error unsupported processor. please write a patch and send it to me

 #endif

Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_conf.c
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_conf.c    2009-12-02 
15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_conf.c    2009-12-02 
16:37:42 UTC (rev 291595)
@@ -10,7 +10,12 @@
 #include <string.h>
 #include <stdlib.h>
 #include <stddef.h>
-#include <stdint.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# include <stdint.h>
+#endif
+
 #include <stdio.h>
 #include <unistd.h>


Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_env.c
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_env.c     2009-12-02 
15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_env.c     2009-12-02 
16:37:42 UTC (rev 291595)
@@ -15,6 +15,24 @@
 #include "zlog.h"

 #ifndef HAVE_SETENV
+# ifdef (__sparc__ || __sparc)
+int setenv(char *name, char *value, int clobber)
+{
+       char   *malloc();
+       char   *getenv();
+       char   *cp;
+
+       if (clobber == 0 && getenv(name) != 0) {
+               return 0;
+       }
+
+       if ((cp = malloc(strlen(name) + strlen(value) + 2)) == 0) {
+               return 1;
+       }
+       sprintf(cp, "%s=%s", name, value);
+       return putenv(cp);
+}
+# else
 int setenv(char *name, char *value, int overwrite)
 {
        int name_len = strlen(name);
@@ -31,6 +49,7 @@

        return putenv(var);
 }
+# endif
 #endif

 #ifndef HAVE_CLEARENV
@@ -55,7 +74,37 @@
 }
 #endif

+#ifndef HAVE_UNSETENV
+void unsetenv(const char *name)
+{
+       if(getenv(name) != NULL) {
+               int ct = 0;
+               int del = 0;

+               while(environ[ct] != NULL) {
+                       if (nvmatch(name, environ[ct]) != 0) del=ct; /* <--- 
WTF?! */
+                       { ct++; } /* <--- WTF?! */
+               }
+               /* isn't needed free here?? */
+               environ[del] = environ[ct-1];
+               environ[ct-1] = NULL;
+       }
+}
+static char * nvmatch(char *s1, char *s2)
+{
+       while(*s1 == *s2++)
+       {
+               if(*s1++ == '=') {
+                       return s2;
+               }
+       }
+       if(*s1 == '\0' && *(s2-1) == '=') {
+               return s2;
+       }
+       return(NULL);
+}
+#endif
+
 int fpm_env_init_child(struct fpm_worker_pool_s *wp)
 {
        struct key_value_s *kv;

Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_php_trace.c
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_php_trace.c       
2009-12-02 15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_php_trace.c       
2009-12-02 16:37:42 UTC (rev 291595)
@@ -11,7 +11,11 @@

 #include <stdio.h>
 #include <stddef.h>
-#include <stdint.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# include <stdint.h>
+#endif
 #include <unistd.h>
 #include <sys/time.h>
 #include <sys/types.h>

Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_trace_pread.c
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_trace_pread.c     
2009-12-02 15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/fpm_trace_pread.c     
2009-12-02 16:37:42 UTC (rev 291595)
@@ -11,7 +11,11 @@

 #include <fcntl.h>
 #include <stdio.h>
-#include <stdint.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# include <stdint.h>
+#endif

 #include "fpm_trace.h"
 #include "fpm_process_ctl.h"

Modified: php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/xml_config.h
===================================================================
--- php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/xml_config.h  2009-12-02 
15:05:12 UTC (rev 291594)
+++ php/php-src/branches/PHP_5_3_FPM/sapi/fpm/fpm/xml_config.h  2009-12-02 
16:37:42 UTC (rev 291595)
@@ -5,7 +5,11 @@
 #ifndef XML_CONFIG_H
 #define XML_CONFIG_H 1

-#include <stdint.h>
+#if HAVE_INTTYPES_H
+# include <inttypes.h>
+#else
+# include <stdint.h>
+#endif

 struct xml_value_parser;


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to