r1306, r1307, r1308, r1309, r1310, r1311, r1322, r1325 merge:
Sun Studio related fixes
Igor Sysoev
15 years ago
1 | 1 | # Copyright (C) Igor Sysoev |
2 | 2 | |
3 | 3 | |
4 | # Sun C 5.7 Patch 117837-04 2005/05/11 | |
5 | # Sun C 5.8 2005/10/13 | |
4 | # Sun C 5.7 Patch 117837-04 2005/05/11 Sun Studio 10 | |
5 | # Sun C 5.8 2005/10/13 Sun Studio 11 | |
6 | # Sun C 5.9 SunOS_i386 2007/05/03 Sun Studio 12 | |
7 | # Sun C 5.9 SunOS_sparc 2007/05/03 | |
6 | 8 | |
7 | 9 | NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \ |
8 | 10 | | sed -e 's/^.* Sun C \(.*\)/\1/'` |
11 | 13 | |
12 | 14 | have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define |
13 | 15 | |
16 | ||
17 | cat << END > $NGX_AUTOTEST.c | |
18 | ||
19 | int main() { printf("%d", __SUNPRO_C); } | |
20 | ||
21 | END | |
22 | ||
23 | eval "$CC -o $NGX_AUTOTEST $NGX_AUTOTEST.c >> $NGX_ERR 2>&1" | |
24 | ||
25 | if [ -x $NGX_AUTOTEST ]; then | |
26 | ngx_sunc_ver=`$NGX_AUTOTEST` | |
27 | fi | |
28 | ||
29 | rm $NGX_AUTOTEST* | |
30 | ||
31 | # 1424 == 0x590, Sun Studio 12 | |
32 | ||
33 | if [ "$ngx_sunc_ver" -ge 1424 ]; then | |
34 | ngx_sparc32="-m32" | |
35 | ngx_sparc64="-m64" | |
36 | ngx_amd64="-m64" | |
37 | ||
38 | else | |
39 | ngx_sparc32="-xarch=v8plus" | |
40 | ngx_sparc64="-xarch=v9" | |
41 | ngx_amd64="-amd64" | |
42 | fi | |
14 | 43 | |
15 | 44 | case "$NGX_MACHINE" in |
16 | 45 | |
34 | 63 | ;; |
35 | 64 | |
36 | 65 | sun4u | sun4v) |
37 | # "-xarch=v9" enables the "casa" assembler instruction | |
38 | CFLAGS="$CFLAGS -xarch=v9" | |
39 | CORE_LINK="$CORE_LINK -xarch=v9" | |
40 | 66 | NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il" |
41 | 67 | ;; |
42 | 68 | |
45 | 71 | |
46 | 72 | # optimizations |
47 | 73 | |
48 | CFLAGS="$CFLAGS -fast" | |
74 | IPO=-xipo | |
75 | CFLAGS="$CFLAGS -fast $IPO" | |
76 | CORE_LINK="$CORE_LINK -fast $IPO" | |
49 | 77 | |
50 | 78 | |
51 | 79 | case $CPU in |
80 | 108 | CPU_OPT="$CPU_OPT -xcache=64/64/2:1024/64/16" |
81 | 109 | ;; |
82 | 110 | |
111 | sparc32) | |
112 | # build 32-bit UltraSparc binary | |
113 | CPU_OPT="$ngx_sparc32" | |
114 | CORE_LINK="$CORE_LINK $ngx_sparc32" | |
115 | CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc32" | |
116 | NGX_CPU_CACHE_LINE=64 | |
117 | ;; | |
118 | ||
119 | sparc64) | |
120 | # build 64-bit UltraSparc binary | |
121 | CPU_OPT="$ngx_sparc64" | |
122 | CORE_LINK="$CORE_LINK $ngx_sparc64" | |
123 | CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_sparc64" | |
124 | NGX_CPU_CACHE_LINE=64 | |
125 | ;; | |
126 | ||
83 | 127 | amd64) |
84 | 128 | # build 64-bit amd64 binary |
85 | CPU_OPT="-xarch=amd64" | |
86 | CORE_LINK="$CORE_LINK -xarch=amd64" | |
129 | CPU_OPT="$ngx_amd64" | |
130 | CORE_LINK="$CORE_LINK $ngx_amd64" | |
131 | CC_AUX_FLAGS="$CC_AUX_FLAGS $ngx_amd64" | |
87 | 132 | NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il" |
133 | NGX_CPU_CACHE_LINE=64 | |
88 | 134 | ;; |
89 | 135 | |
90 | 136 | esac |
94 | 140 | |
95 | 141 | |
96 | 142 | if [ ".$PCRE_OPT" = "." ]; then |
97 | PCRE_OPT="-fast $CPU_OPT" | |
143 | PCRE_OPT="-fast $IPO $CPU_OPT" | |
98 | 144 | fi |
99 | 145 | |
100 | 146 | if [ ".$MD5_OPT" = "." ]; then |
101 | MD5_OPT="-fast $CPU_OPT" | |
147 | MD5_OPT="-fast $IPO $CPU_OPT" | |
102 | 148 | fi |
103 | 149 | |
104 | 150 | if [ ".$ZLIB_OPT" = "." ]; then |
105 | ZLIB_OPT="-fast $CPU_OPT" | |
151 | ZLIB_OPT="-fast $IPO $CPU_OPT" | |
106 | 152 | fi |
107 | 153 | |
108 | 154 |
16 | 16 | CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib" |
17 | 17 | ;; |
18 | 18 | |
19 | icc* | sunc ) | |
19 | icc* ) | |
20 | 20 | have=NGX_PCRE . auto/have |
21 | 21 | CORE_DEPS="$CORE_DEPS $PCRE/pcre.h" |
22 | 22 | |
24 | 24 | |
25 | 25 | echo $ngx_n "checking for PCRE library ...$ngx_c" |
26 | 26 | |
27 | if [ -e $PCRE/pcre.h ]; then | |
27 | if [ -f $PCRE/pcre.h ]; then | |
28 | 28 | ngx_pcre_ver=`grep PCRE_MAJOR $PCRE/pcre.h \ |
29 | 29 | | sed -e 's/^.*PCRE_MAJOR.* \(.*\)$/\1/'` |
30 | 30 | |
31 | else | |
31 | else if [ -f $PCRE/configure.in ]; then | |
32 | 32 | ngx_pcre_ver=`grep PCRE_MAJOR= $PCRE/configure.in \ |
33 | 33 | | sed -e 's/^.*=\(.*\)$/\1/'` |
34 | ||
35 | else | |
36 | ngx_pcre_ver=`grep pcre_major, $PCRE/configure.ac \ | |
37 | | sed -e 's/^.*pcre_major,.*\[\(.*\)\].*$/\1/'` | |
38 | fi | |
34 | 39 | fi |
35 | 40 | |
36 | 41 | echo " $ngx_pcre_ver major version found" |
104 | 104 | u_char * |
105 | 105 | ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args) |
106 | 106 | { |
107 | u_char *p, zero, *last, temp[NGX_INT64_LEN + 1]; | |
107 | u_char *p, zero, *last, temp[NGX_INT64_LEN + 1]; | |
108 | 108 | /* |
109 | 109 | * really we need temp[NGX_INT64_LEN] only, |
110 | 110 | * but icc issues the warning |
111 | 111 | */ |
112 | int d; | |
113 | size_t len; | |
114 | uint32_t ui32; | |
115 | int64_t i64; | |
116 | uint64_t ui64; | |
117 | ngx_msec_t ms; | |
118 | ngx_str_t *s; | |
119 | ngx_uint_t width, sign, hexadecimal, max_width; | |
120 | static u_char hex[] = "0123456789abcdef"; | |
121 | static u_char HEX[] = "0123456789ABCDEF"; | |
112 | int d; | |
113 | size_t len; | |
114 | uint32_t ui32; | |
115 | int64_t i64; | |
116 | uint64_t ui64; | |
117 | ngx_msec_t ms; | |
118 | ngx_uint_t width, sign, hexadecimal, max_width; | |
119 | ngx_variable_value_t *v; | |
120 | static u_char hex[] = "0123456789abcdef"; | |
121 | static u_char HEX[] = "0123456789ABCDEF"; | |
122 | 122 | |
123 | 123 | if (max == 0) { |
124 | 124 | return buf; |
187 | 187 | switch (*fmt) { |
188 | 188 | |
189 | 189 | case 'V': |
190 | s = va_arg(args, ngx_str_t *); | |
191 | ||
192 | len = s->len & 0xffff; | |
190 | v = va_arg(args, ngx_variable_value_t *); | |
191 | ||
192 | len = v->len; | |
193 | 193 | len = (buf + len < last) ? len : (size_t) (last - buf); |
194 | 194 | |
195 | buf = ngx_cpymem(buf, s->data, len); | |
195 | buf = ngx_cpymem(buf, v->data, len); | |
196 | 196 | fmt++; |
197 | 197 | |
198 | 198 | continue; |
12 | 12 | |
13 | 13 | |
14 | 14 | typedef struct { |
15 | size_t len; | |
16 | u_char *data; | |
15 | size_t len; | |
16 | u_char *data; | |
17 | 17 | } ngx_str_t; |
18 | 18 | |
19 | 19 | |
20 | 20 | typedef struct { |
21 | ngx_str_t key; | |
22 | ngx_str_t value; | |
21 | ngx_str_t key; | |
22 | ngx_str_t value; | |
23 | 23 | } ngx_keyval_t; |
24 | ||
25 | ||
26 | typedef struct { | |
27 | unsigned len:29; | |
28 | ||
29 | unsigned valid:1; | |
30 | unsigned no_cachable:1; | |
31 | unsigned not_found:1; | |
32 | ||
33 | u_char *data; | |
34 | } ngx_variable_value_t; | |
24 | 35 | |
25 | 36 | |
26 | 37 | #define ngx_string(str) { sizeof(str) - 1, (u_char *) str } |
186 | 186 | { |
187 | 187 | u_char *ct; |
188 | 188 | ngx_int_t charset, source_charset; |
189 | ngx_str_t *mc, *from, *to; | |
189 | ngx_str_t *mc, *from, *to, s; | |
190 | 190 | ngx_uint_t n; |
191 | 191 | ngx_http_charset_t *charsets; |
192 | 192 | ngx_http_charset_ctx_t *ctx; |
255 | 255 | return NGX_ERROR; |
256 | 256 | } |
257 | 257 | |
258 | charset = ngx_http_charset_get_charset(charsets, n, | |
259 | (ngx_str_t *) vv); | |
258 | s.len = vv->len; | |
259 | s.data = vv->data; | |
260 | ||
261 | charset = ngx_http_charset_get_charset(charsets, n, &s); | |
260 | 262 | } |
261 | 263 | } |
262 | 264 | |
302 | 304 | return NGX_ERROR; |
303 | 305 | } |
304 | 306 | |
305 | source_charset = ngx_http_charset_get_charset(charsets, n, | |
306 | (ngx_str_t *) vv); | |
307 | s.len = vv->len; | |
308 | s.data = vv->data; | |
309 | ||
310 | source_charset = ngx_http_charset_get_charset(charsets, n, &s); | |
307 | 311 | } |
308 | 312 | |
309 | 313 | if (charset != NGX_HTTP_NO_CHARSET) { |
372 | 376 | ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n, |
373 | 377 | ngx_str_t *charset) |
374 | 378 | { |
375 | size_t len; | |
376 | 379 | ngx_uint_t i; |
377 | 380 | |
378 | len = charset->len & 0xffff; | |
379 | ||
380 | 381 | for (i = 0; i < n; i++) { |
381 | if (charsets[i].name.len != len) { | |
382 | if (charsets[i].name.len != charset->len) { | |
382 | 383 | continue; |
383 | 384 | } |
384 | 385 | |
385 | if (ngx_strncasecmp(charsets[i].name.data, charset->data, len) == 0) { | |
386 | if (ngx_strncasecmp(charsets[i].name.data, charset->data, charset->len) | |
387 | == 0) | |
388 | { | |
386 | 389 | return i; |
387 | 390 | } |
388 | 391 | } |
196 | 196 | { |
197 | 197 | ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; |
198 | 198 | |
199 | size_t len; | |
199 | size_t len; | |
200 | ngx_str_t s; | |
200 | 201 | |
201 | 202 | if (r->connection->ssl) { |
202 | 203 | |
203 | (void) handler(r->connection, NULL, (ngx_str_t *) v); | |
204 | (void) handler(r->connection, NULL, &s); | |
205 | ||
206 | v->data = s.data; | |
204 | 207 | |
205 | 208 | for (len = 0; v->data[len]; len++) { /* void */ } |
206 | 209 | |
224 | 227 | { |
225 | 228 | ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data; |
226 | 229 | |
230 | ngx_str_t s; | |
231 | ||
227 | 232 | if (r->connection->ssl) { |
228 | if (handler(r->connection, r->pool, (ngx_str_t *) v) != NGX_OK) { | |
233 | ||
234 | if (handler(r->connection, r->pool, &s) != NGX_OK) { | |
229 | 235 | return NGX_ERROR; |
230 | 236 | } |
237 | ||
238 | v->len = s.len; | |
239 | v->data = s.data; | |
231 | 240 | |
232 | 241 | if (v->len) { |
233 | 242 | v->valid = 1; |
500 | 500 | ssize_t s, *sp; |
501 | 501 | ngx_str_t val; |
502 | 502 | |
503 | val.len = v->len & 0xffff; | |
503 | val.len = v->len; | |
504 | 504 | val.data = v->data; |
505 | 505 | |
506 | 506 | s = ngx_parse_size(&val); |
13 | 13 | #include <ngx_http.h> |
14 | 14 | |
15 | 15 | |
16 | typedef struct { | |
17 | unsigned len:29; | |
18 | ||
19 | unsigned valid:1; | |
20 | unsigned no_cachable:1; | |
21 | unsigned not_found:1; | |
22 | ||
23 | u_char *data; | |
24 | } ngx_http_variable_value_t; | |
16 | typedef ngx_variable_value_t ngx_http_variable_value_t; | |
25 | 17 | |
26 | 18 | #define ngx_http_variable(v) { sizeof(v) - 1, 1, 0, 0, (u_char *) v } |
27 | 19 |
86 | 86 | ngx_atomic_int_t |
87 | 87 | ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); |
88 | 88 | |
89 | /* | |
90 | * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
91 | * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_x86.il | |
92 | */ | |
93 | ||
94 | void | |
95 | ngx_cpu_pause(void); | |
96 | ||
89 | 97 | /* the code in src/os/unix/ngx_sunpro_x86.il */ |
90 | 98 | |
91 | 99 | #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
92 | #define ngx_cpu_pause() __asm ("pause") | |
93 | 100 | |
94 | 101 | |
95 | 102 | #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
120 | 127 | ngx_atomic_int_t |
121 | 128 | ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add); |
122 | 129 | |
130 | /* | |
131 | * Sun Studio 12 exits with segmentation fault on '__asm ("pause")', | |
132 | * so ngx_cpu_pause is declared in src/os/unix/ngx_sunpro_amd64.il | |
133 | */ | |
134 | ||
135 | void | |
136 | ngx_cpu_pause(void); | |
137 | ||
123 | 138 | /* the code in src/os/unix/ngx_sunpro_amd64.il */ |
124 | 139 | |
125 | 140 | #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile") |
126 | #define ngx_cpu_pause() __asm ("pause") | |
127 | 141 | |
128 | 142 | |
129 | 143 | #else /* ( __GNUC__ || __INTEL_COMPILER ) */ |
135 | 149 | #endif |
136 | 150 | |
137 | 151 | |
138 | #elif ( __sparc__ || __sparcv9 ) | |
152 | #elif ( __sparc__ || __sparc || __sparcv9 ) | |
139 | 153 | |
140 | 154 | #if (NGX_PTR_SIZE == 8) |
141 | 155 |