Skip to content

Commit ca1896c

Browse files
committed
add support for some weird platforms
1 parent 4211223 commit ca1896c

File tree

6 files changed

+125
-5
lines changed

6 files changed

+125
-5
lines changed

sapi/fpm/fpm/fpm_atomic.h

Lines changed: 55 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#ifndef FPM_ATOMIC_H
66
#define FPM_ATOMIC_H 1
77

8-
#include <stdint.h>
8+
#if HAVE_INTTYPES_H
9+
# include <stdint.h>
10+
#else
11+
# include <stdint.h>
12+
#endif
913
#include <sched.h>
1014

1115
#if ( __i386__ || __i386 )
@@ -57,6 +61,56 @@ static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, at
5761
return res;
5862
}
5963

64+
#if (__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 2))
65+
66+
#elif ( __arm__ || __arm ) /* W-Mark Kubacki */
67+
68+
#if (__arch64__ || __arch64)
69+
typedef int64_t atomic_int_t;
70+
typedef uint64_t atomic_uint_t;
71+
#else
72+
typedef int32_t atomic_int_t;
73+
typedef uint32_t atomic_uint_t;
74+
#endif
75+
76+
#define atomic_cmp_set(a,b,c) __sync_bool_compare_and_swap(a,b,c)
77+
78+
#endif /* defined (__GNUC__) &&... */
79+
80+
#elif ( __sparc__ || __sparc ) /* Marcin Ochab */
81+
82+
#if (__arch64__ || __arch64)
83+
typedef uint64_t atomic_uint_t;
84+
typedef volatile atomic_uint_t atomic_t;
85+
86+
static inline int atomic_cas_64(atomic_t *lock, atomic_uint_t old, atomic_uint_t new)
87+
{
88+
__asm__ __volatile__("casx [%2], %3, %0 " : "=&r"(new) : "0"(new), "r"(lock), "r"(old): "memory");
89+
90+
return new;
91+
}
92+
93+
static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, atomic_uint_t set)
94+
{
95+
return (atomic_cas_64(lock, old, set)==old);
96+
}
97+
#else
98+
typedef uint32_t atomic_uint_t;
99+
typedef volatile atomic_uint_t atomic_t;
100+
101+
static inline int atomic_cas_32(atomic_t *lock, atomic_uint_t old, atomic_uint_t new)
102+
{
103+
__asm__ __volatile__("cas [%2], %3, %0 " : "=&r"(new) : "0"(new), "r"(lock), "r"(old): "memory");
104+
105+
return new;
106+
}
107+
108+
static inline atomic_uint_t atomic_cmp_set(atomic_t *lock, atomic_uint_t old, atomic_uint_t set)
109+
{
110+
return (atomic_cas_32(lock, old, set)==old);
111+
}
112+
#endif
113+
60114
#else
61115

62116
#error unsupported processor. please write a patch and send it to me

sapi/fpm/fpm/fpm_conf.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,12 @@
1010
#include <string.h>
1111
#include <stdlib.h>
1212
#include <stddef.h>
13-
#include <stdint.h>
13+
#if HAVE_INTTYPES_H
14+
# include <inttypes.h>
15+
#else
16+
# include <stdint.h>
17+
#endif
18+
1419
#include <stdio.h>
1520
#include <unistd.h>
1621

sapi/fpm/fpm/fpm_env.c

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,24 @@
1515
#include "zlog.h"
1616

1717
#ifndef HAVE_SETENV
18+
# ifdef (__sparc__ || __sparc)
19+
int setenv(char *name, char *value, int clobber)
20+
{
21+
char *malloc();
22+
char *getenv();
23+
char *cp;
24+
25+
if (clobber == 0 && getenv(name) != 0) {
26+
return 0;
27+
}
28+
29+
if ((cp = malloc(strlen(name) + strlen(value) + 2)) == 0) {
30+
return 1;
31+
}
32+
sprintf(cp, "%s=%s", name, value);
33+
return putenv(cp);
34+
}
35+
# else
1836
int setenv(char *name, char *value, int overwrite)
1937
{
2038
int name_len = strlen(name);
@@ -31,6 +49,7 @@ int setenv(char *name, char *value, int overwrite)
3149

3250
return putenv(var);
3351
}
52+
# endif
3453
#endif
3554

3655
#ifndef HAVE_CLEARENV
@@ -55,6 +74,36 @@ void clearenv()
5574
}
5675
#endif
5776

77+
#ifndef HAVE_UNSETENV
78+
void unsetenv(const char *name)
79+
{
80+
if(getenv(name) != NULL) {
81+
int ct = 0;
82+
int del = 0;
83+
84+
while(environ[ct] != NULL) {
85+
if (nvmatch(name, environ[ct]) != 0) del=ct; /* <--- WTF?! */
86+
{ ct++; } /* <--- WTF?! */
87+
}
88+
/* isn't needed free here?? */
89+
environ[del] = environ[ct-1];
90+
environ[ct-1] = NULL;
91+
}
92+
}
93+
static char * nvmatch(char *s1, char *s2)
94+
{
95+
while(*s1 == *s2++)
96+
{
97+
if(*s1++ == '=') {
98+
return s2;
99+
}
100+
}
101+
if(*s1 == '\0' && *(s2-1) == '=') {
102+
return s2;
103+
}
104+
return(NULL);
105+
}
106+
#endif
58107

59108
int fpm_env_init_child(struct fpm_worker_pool_s *wp)
60109
{

sapi/fpm/fpm/fpm_php_trace.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
#include <stdio.h>
1313
#include <stddef.h>
14-
#include <stdint.h>
14+
#if HAVE_INTTYPES_H
15+
# include <inttypes.h>
16+
#else
17+
# include <stdint.h>
18+
#endif
1519
#include <unistd.h>
1620
#include <sys/time.h>
1721
#include <sys/types.h>

sapi/fpm/fpm/fpm_trace_pread.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,11 @@
1111

1212
#include <fcntl.h>
1313
#include <stdio.h>
14-
#include <stdint.h>
14+
#if HAVE_INTTYPES_H
15+
# include <inttypes.h>
16+
#else
17+
# include <stdint.h>
18+
#endif
1519

1620
#include "fpm_trace.h"
1721
#include "fpm_process_ctl.h"

sapi/fpm/fpm/xml_config.h

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,11 @@
55
#ifndef XML_CONFIG_H
66
#define XML_CONFIG_H 1
77

8-
#include <stdint.h>
8+
#if HAVE_INTTYPES_H
9+
# include <inttypes.h>
10+
#else
11+
# include <stdint.h>
12+
#endif
913

1014
struct xml_value_parser;
1115

0 commit comments

Comments
 (0)