*** ./sapi/fpm/fpm/fpm_conf.h.ORIG	Wed Dec 19 00:20:53 2012
--- ./sapi/fpm/fpm/fpm_conf.h	Wed Dec 19 00:21:28 2012
***************
*** 5,11 ****
--- 5,15 ----
  #ifndef FPM_CONF_H
  #define FPM_CONF_H 1
  
+ #if defined(_AIX) && defined(_AIX52)
  #include <stdint.h>
+ #else
+ #include <inttypes.h>
+ #endif
  #include "php.h"
  
  #define PM2STR(a) (a == PM_STYLE_STATIC ? "static" : (a == PM_STYLE_DYNAMIC ? "dynamic" : "ondemand"))
*** ./sapi/fpm/fpm/fpm_env.c.ORIG	Wed Dec 19 08:05:37 2012
--- ./sapi/fpm/fpm/fpm_env.c	Wed Dec 19 08:05:59 2012
***************
*** 85,90 ****
--- 85,105 ----
  #endif
  
  #ifndef HAVE_UNSETENV
+ static char * nvmatch(char *s1, char *s2) /* {{{ */
+ {
+ 	while(*s1 == *s2++)
+ 	{
+ 		if(*s1++ == '=') { 
+ 			return s2;
+ 		}
+ 	}
+ 	if(*s1 == '\0' && *(s2-1) == '=') { 
+ 		return s2;
+ 	}
+ 	return NULL;
+ }
+ /* }}} */
+ 
  void unsetenv(const char *name) /* {{{ */
  {
  	if(getenv(name) != NULL) {
***************
*** 99,119 ****
  		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
--- 114,119 ----
*** ./sapi/fpm/fpm/fpm_atomic.h.ORIG	Wed Nov 21 06:12:20 2012
--- ./sapi/fpm/fpm/fpm_atomic.h	Wed Dec 19 08:03:46 2012
***************
*** 137,144 ****
--- 137,262 ----
  #error Sparc v8 and predecessors are not and will not be supported (see bug report 53310)
  #endif /* #if (__sparcv9 || __sparcv9__) */
  
+ #elif ( _AIX )
+ 
+ #if (__64BIT__)
+ 
+ typedef int64_t                     atomic_int_t;
+ typedef uint64_t                   atomic_uint_t;
+ typedef volatile          atomic_uint_t atomic_t;
+ 
+ static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, atomic_uint_t set) /* {{{ */
+ {
+     atomic_uint_t  res, temp;
+ 
+     __asm__ volatile (
+ 
+     "    li      %0, 0       \n" /* preset "0" to "res"                      */
+     "    lwsync              \n" /* write barrier                            */
+     "1:                      \n"
+     "    ldarx   %1, 0, %2   \n" /* load from [lock] into "temp"             */
+                                  /*   and store reservation                  */
+     "    cmpd    %1, %3      \n" /* compare "temp" and "old"                 */
+     "    bne-    2f          \n" /* not equal                                */
+     "    stdcx.  %4, 0, %2   \n" /* store "set" into [lock] if reservation   */
+                                  /*   is not cleared                         */
+     "    bne-    1b          \n" /* the reservation was cleared              */
+     "    isync               \n" /* read barrier                             */
+     "    li      %0, 1       \n" /* set "1" to "res"                         */
+     "2:                      \n"
+ 
+     : "=&b" (res), "=&b" (temp)
+     : "b" (lock), "b" (old), "b" (set)
+     : "cc", "memory");
+ 
+     return res;
+ }
+ /* }}} */
+ 
+ static inline atomic_int_t atomic_fetch_add(atomic_t *value, atomic_int_t add) /* {{{ */
+ {
+     atomic_uint_t  res, temp;
+ 
+     __asm__ volatile (
+ 
+     "    lwsync              \n" /* write barrier                            */
+     "1:  ldarx   %0, 0, %2   \n" /* load from [value] into "res"             */
+                                  /*   and store reservation                  */
+     "    add     %1, %0, %3  \n" /* "res" + "add" store in "temp"            */
+     "    stdcx.  %1, 0, %2   \n" /* store "temp" into [value] if reservation */
+                                  /*   is not cleared                         */
+     "    bne-    1b          \n" /* try again if reservation was cleared     */
+     "    isync               \n" /* read barrier                             */
+ 
+     : "=&b" (res), "=&b" (temp)
+     : "b" (value), "b" (add)
+     : "cc", "memory");
+ 
+     return res;
+ }
+ /* }}} */
+ 
  #else
+  
+ typedef int32_t                     atomic_int_t;
+ typedef uint32_t                   atomic_uint_t;
+ typedef volatile          atomic_uint_t atomic_t;
  
+ static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, atomic_uint_t set) /* {{{ */
+ {
+     atomic_uint_t  res, temp;
+ 
+     __asm__ volatile (
+ 
+     "    li      %0, 0       \n" /* preset "0" to "res"                      */
+     "    eieio               \n" /* write barrier                            */
+     "1:                      \n"
+     "    lwarx   %1, 0, %2   \n" /* load from [lock] into "temp"             */
+                                  /*   and store reservation                  */
+     "    cmpw    %1, %3      \n" /* compare "temp" and "old"                 */
+     "    bne-    2f          \n" /* not equal                                */
+     "    stwcx.  %4, 0, %2   \n" /* store "set" into [lock] if reservation   */
+                                  /*   is not cleared                         */
+     "    bne-    1b          \n" /* the reservation was cleared              */
+     "    isync               \n" /* read barrier                             */
+     "    li      %0, 1       \n" /* set "1" to "res"                         */
+     "2:                      \n"
+ 
+     : "=&b" (res), "=&b" (temp)
+     : "b" (lock), "b" (old), "b" (set)
+     : "cc", "memory");
+ 
+     return res;
+ }
+ /* }}} */
+ 
+ static inline atomic_int_t atomic_fetch_add(atomic_t *value, atomic_int_t add) /* {{{ */
+ {
+     atomic_uint_t  res, temp;
+ 
+     __asm__ volatile (
+ 
+     "    eieio               \n" /* write barrier                            */
+     "1:  lwarx   %0, 0, %2   \n" /* load from [value] into "res"             */
+                                  /*   and store reservation                  */
+     "    add     %1, %0, %3  \n" /* "res" + "add" store in "temp"            */
+     "    stwcx.  %1, 0, %2   \n" /* store "temp" into [value] if reservation */
+                                  /*   is not cleared                         */
+     "    bne-    1b          \n" /* try again if reservation was cleared     */
+     "    isync               \n" /* read barrier                             */
+ 
+     : "=&b" (res), "=&b" (temp)
+     : "b" (value), "b" (add)
+     : "cc", "memory");
+ 
+     return res;
+ }
+ /* }}} */
+ 
+ #endif
+ 
+ #else
+  
  #error Unsupported processor. Please open a bug report (bugs.php.net).
  
  #endif
*** ./sapi/fpm/fpm/fpm_children.c.ORIG	Wed Dec 19 08:15:01 2012
--- ./sapi/fpm/fpm/fpm_children.c	Wed Dec 19 08:17:17 2012
***************
*** 174,179 ****
--- 174,184 ----
  }
  /* }}} */
  
+ /* AIX does not have WCOREDUMP */
+ #ifdef _AIX
+ #define WCOREDUMP(x) 0
+ #endif
+ 
  void fpm_children_bury() /* {{{ */
  {
  	int status;
*** ./configure.ORIG	Wed Dec 19 09:37:20 2012
--- ./configure	Wed Dec 19 09:38:17 2012
***************
*** 12777,12782 ****
--- 12777,12783 ----
  
    case $host_alias in
        *aix*)
+         PHP_FPM_OBJS="$PHP_FPM_OBJS main/internal_functions.lo"
          BUILD_FPM="echo '\#! .' > php.sym && echo >>php.sym && nm -BCpg \`echo \$(PHP_GLOBAL_OBJS) \$(PHP_BINARY_OBJS) \$(PHP_FPM_OBJS) | sed 's/\([A-Za-z0-9_]*\)\.lo/\1.o/g'\` | \$(AWK) '{ if (((\$\$2 == \"T\") || (\$\$2 == \"D\") || (\$\$2 == \"B\")) && (substr(\$\$3,1,1) != \".\")) { print \$\$3 } }' | sort -u >> php.sym && \$(LIBTOOL) --mode=link \$(CC) -export-dynamic \$(CFLAGS_CLEAN) \$(EXTRA_CFLAGS) \$(EXTRA_LDFLAGS_PROGRAM) \$(LDFLAGS) -Wl,-brtl -Wl,-bE:php.sym \$(PHP_RPATHS) \$(PHP_GLOBAL_OBJS) \$(PHP_FPM_OBJS) \$(EXTRA_LIBS) \$(FPM_EXTRA_LIBS) \$(ZEND_EXTRA_LIBS) -o \$(SAPI_FPM_PATH)"
          ;;
        *darwin*)
