1 /* (c) 2007,2008 Andrei Nigmatulin */ 2 3 #include <php_config.h> 4 5 #ifdef HAVE_ARPA_INET_H 6 # include <arpa/inet.h> 7 #endif 8 #ifdef HAVE_NETINET_IN_H 9 # include <netinet/in.h> 10 #endif 11 #ifdef HAVE_SYS_TIME_H 12 # include <sys/time.h> 13 #endif 14 15 /* Solaris does not have it */ 16 #ifndef INADDR_NONE 17 # define INADDR_NONE (-1) 18 #endif 19 20 21 /* If we're not using GNU C, elide __attribute__ */ 22 #ifndef __GNUC__ 23 # define __attribute__(x) /*NOTHING*/ 24 #endif 25 26 /* Missing timer* macros (for solaris) */ 27 #ifndef timerisset 28 # define timerisset(tvp) ((tvp)->tv_sec || (tvp)->tv_usec) 29 #endif 30 31 #ifndef timerclear 32 # define timerclear(tvp) ((tvp)->tv_sec = (tvp)->tv_usec = 0) 33 #endif 34 35 #ifndef timersub 36 # define timersub(tvp, uvp, vvp) \ 37 do { \ 38 (vvp)->tv_sec = (tvp)->tv_sec - (uvp)->tv_sec; \ 39 (vvp)->tv_usec = (tvp)->tv_usec - (uvp)->tv_usec; \ 40 if ((vvp)->tv_usec < 0) { \ 41 (vvp)->tv_sec--; \ 42 (vvp)->tv_usec += 1000000; \ 43 } \ 44 } while (0) 45 #endif 46 47 #ifndef timeradd 48 # define timeradd(a, b, result) \ 49 do { \ 50 (result)->tv_sec = (a)->tv_sec + (b)->tv_sec; \ 51 (result)->tv_usec = (a)->tv_usec + (b)->tv_usec; \ 52 if ((result)->tv_usec >= 1000000) \ 53 { \ 54 ++(result)->tv_sec; \ 55 (result)->tv_usec -= 1000000; \ 56 } \ 57 } while (0) 58 #endif 59 60 #ifndef timercmp 61 /* does not work for >= and <= */ 62 # define timercmp(a, b, CMP) \ 63 (((a)->tv_sec == (b)->tv_sec) ? \ 64 ((a)->tv_usec CMP (b)->tv_usec) : \ 65 ((a)->tv_sec CMP (b)->tv_sec)) 66 #endif 67 /* endof timer* macros */ 68 69 #ifndef MIN 70 # define MIN(a,b) (((a)<(b))?(a):(b)) 71 #endif 72 73 #ifndef MAX 74 # define MAX(a,b) (((a)>(b))?(a):(b)) 75 #endif 76 77 #if defined(HAVE_PTRACE) || defined(PROC_MEM_FILE) || defined(HAVE_MACH_VM_READ) 78 # define HAVE_FPM_TRACE 1 79 #else 80 # define HAVE_FPM_TRACE 0 81 #endif 82 83 #if defined(HAVE_LQ_TCP_INFO) || defined(HAVE_LQ_TCP_CONNECTION_INFO) || defined(HAVE_LQ_SO_LISTENQ) 84 # define HAVE_FPM_LQ 1 85 #else 86 # define HAVE_FPM_LQ 0 87 #endif 88