Klaus Demo nginx / 64bb1e3
r1306, r1307, r1308, r1309, r1310, r1311, r1322, r1325 merge: Sun Studio related fixes Igor Sysoev 15 years ago
11 changed file(s) with 153 addition(s) and 59 deletion(s). Raw diff Collapse all Expand all
11 # Copyright (C) Igor Sysoev
22
33
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
68
79 NGX_SUNC_VER=`$CC -V 2>&1 | grep 'Sun C' 2>&1 \
810 | sed -e 's/^.* Sun C \(.*\)/\1/'`
1113
1214 have=NGX_COMPILER value="\"Sun C $NGX_SUNC_VER\"" . auto/define
1315
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
1443
1544 case "$NGX_MACHINE" in
1645
3463 ;;
3564
3665 sun4u | sun4v)
37 # "-xarch=v9" enables the "casa" assembler instruction
38 CFLAGS="$CFLAGS -xarch=v9"
39 CORE_LINK="$CORE_LINK -xarch=v9"
4066 NGX_AUX=" src/os/unix/ngx_sunpro_sparc64.il"
4167 ;;
4268
4571
4672 # optimizations
4773
48 CFLAGS="$CFLAGS -fast"
74 IPO=-xipo
75 CFLAGS="$CFLAGS -fast $IPO"
76 CORE_LINK="$CORE_LINK -fast $IPO"
4977
5078
5179 case $CPU in
80108 CPU_OPT="$CPU_OPT -xcache=64/64/2:1024/64/16"
81109 ;;
82110
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
83127 amd64)
84128 # 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"
87132 NGX_AUX=" src/os/unix/ngx_sunpro_amd64.il"
133 NGX_CPU_CACHE_LINE=64
88134 ;;
89135
90136 esac
94140
95141
96142 if [ ".$PCRE_OPT" = "." ]; then
97 PCRE_OPT="-fast $CPU_OPT"
143 PCRE_OPT="-fast $IPO $CPU_OPT"
98144 fi
99145
100146 if [ ".$MD5_OPT" = "." ]; then
101 MD5_OPT="-fast $CPU_OPT"
147 MD5_OPT="-fast $IPO $CPU_OPT"
102148 fi
103149
104150 if [ ".$ZLIB_OPT" = "." ]; then
105 ZLIB_OPT="-fast $CPU_OPT"
151 ZLIB_OPT="-fast $IPO $CPU_OPT"
106152 fi
107153
108154
1616 CORE_LIBS="$CORE_LIBS $PCRE/pcre.lib"
1717 ;;
1818
19 icc* | sunc )
19 icc* )
2020 have=NGX_PCRE . auto/have
2121 CORE_DEPS="$CORE_DEPS $PCRE/pcre.h"
2222
2424
2525 echo $ngx_n "checking for PCRE library ...$ngx_c"
2626
27 if [ -e $PCRE/pcre.h ]; then
27 if [ -f $PCRE/pcre.h ]; then
2828 ngx_pcre_ver=`grep PCRE_MAJOR $PCRE/pcre.h \
2929 | sed -e 's/^.*PCRE_MAJOR.* \(.*\)$/\1/'`
3030
31 else
31 else if [ -f $PCRE/configure.in ]; then
3232 ngx_pcre_ver=`grep PCRE_MAJOR= $PCRE/configure.in \
3333 | 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
3439 fi
3540
3641 echo " $ngx_pcre_ver major version found"
104104 u_char *
105105 ngx_vsnprintf(u_char *buf, size_t max, const char *fmt, va_list args)
106106 {
107 u_char *p, zero, *last, temp[NGX_INT64_LEN + 1];
107 u_char *p, zero, *last, temp[NGX_INT64_LEN + 1];
108108 /*
109109 * really we need temp[NGX_INT64_LEN] only,
110110 * but icc issues the warning
111111 */
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";
122122
123123 if (max == 0) {
124124 return buf;
187187 switch (*fmt) {
188188
189189 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;
193193 len = (buf + len < last) ? len : (size_t) (last - buf);
194194
195 buf = ngx_cpymem(buf, s->data, len);
195 buf = ngx_cpymem(buf, v->data, len);
196196 fmt++;
197197
198198 continue;
1212
1313
1414 typedef struct {
15 size_t len;
16 u_char *data;
15 size_t len;
16 u_char *data;
1717 } ngx_str_t;
1818
1919
2020 typedef struct {
21 ngx_str_t key;
22 ngx_str_t value;
21 ngx_str_t key;
22 ngx_str_t value;
2323 } 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;
2435
2536
2637 #define ngx_string(str) { sizeof(str) - 1, (u_char *) str }
186186 {
187187 u_char *ct;
188188 ngx_int_t charset, source_charset;
189 ngx_str_t *mc, *from, *to;
189 ngx_str_t *mc, *from, *to, s;
190190 ngx_uint_t n;
191191 ngx_http_charset_t *charsets;
192192 ngx_http_charset_ctx_t *ctx;
255255 return NGX_ERROR;
256256 }
257257
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);
260262 }
261263 }
262264
302304 return NGX_ERROR;
303305 }
304306
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);
307311 }
308312
309313 if (charset != NGX_HTTP_NO_CHARSET) {
372376 ngx_http_charset_get_charset(ngx_http_charset_t *charsets, ngx_uint_t n,
373377 ngx_str_t *charset)
374378 {
375 size_t len;
376379 ngx_uint_t i;
377380
378 len = charset->len & 0xffff;
379
380381 for (i = 0; i < n; i++) {
381 if (charsets[i].name.len != len) {
382 if (charsets[i].name.len != charset->len) {
382383 continue;
383384 }
384385
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 {
386389 return i;
387390 }
388391 }
196196 {
197197 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data;
198198
199 size_t len;
199 size_t len;
200 ngx_str_t s;
200201
201202 if (r->connection->ssl) {
202203
203 (void) handler(r->connection, NULL, (ngx_str_t *) v);
204 (void) handler(r->connection, NULL, &s);
205
206 v->data = s.data;
204207
205208 for (len = 0; v->data[len]; len++) { /* void */ }
206209
224227 {
225228 ngx_ssl_variable_handler_pt handler = (ngx_ssl_variable_handler_pt) data;
226229
230 ngx_str_t s;
231
227232 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) {
229235 return NGX_ERROR;
230236 }
237
238 v->len = s.len;
239 v->data = s.data;
231240
232241 if (v->len) {
233242 v->valid = 1;
500500 ssize_t s, *sp;
501501 ngx_str_t val;
502502
503 val.len = v->len & 0xffff;
503 val.len = v->len;
504504 val.data = v->data;
505505
506506 s = ngx_parse_size(&val);
1313 #include <ngx_http.h>
1414
1515
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;
2517
2618 #define ngx_http_variable(v) { sizeof(v) - 1, 1, 0, 0, (u_char *) v }
2719
8686 ngx_atomic_int_t
8787 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
8888
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
8997 /* the code in src/os/unix/ngx_sunpro_x86.il */
9098
9199 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
92 #define ngx_cpu_pause() __asm ("pause")
93100
94101
95102 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
120127 ngx_atomic_int_t
121128 ngx_atomic_fetch_add(ngx_atomic_t *value, ngx_atomic_int_t add);
122129
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
123138 /* the code in src/os/unix/ngx_sunpro_amd64.il */
124139
125140 #define ngx_memory_barrier() __asm (".volatile"); __asm (".nonvolatile")
126 #define ngx_cpu_pause() __asm ("pause")
127141
128142
129143 #else /* ( __GNUC__ || __INTEL_COMPILER ) */
135149 #endif
136150
137151
138 #elif ( __sparc__ || __sparcv9 )
152 #elif ( __sparc__ || __sparc || __sparcv9 )
139153
140154 #if (NGX_PTR_SIZE == 8)
141155
2727 lock
2828 xaddq %rax, (%rdi)
2929 .end
30
31
32 / ngx_cpu_pause()
33
34 .inline ngx_cpu_pause,0
35 pause
36 .end
2828 lock
2929 xaddl %eax, (%ecx)
3030 .end
31
32
33 / ngx_cpu_pause()
34
35 .inline ngx_cpu_pause,0
36 pause
37 .end