summaryrefslogtreecommitdiffhomepage
path: root/src/core
diff options
context:
space:
mode:
Diffstat (limited to 'src/core')
-rw-r--r--src/core/nginx.c12
-rw-r--r--src/core/ngx_alloc.c12
-rw-r--r--src/core/ngx_atomic.h38
-rw-r--r--src/core/ngx_config.h4
4 files changed, 36 insertions, 30 deletions
diff --git a/src/core/nginx.c b/src/core/nginx.c
index a9418992e..592711522 100644
--- a/src/core/nginx.c
+++ b/src/core/nginx.c
@@ -649,10 +649,18 @@ static void ngx_worker_process_cycle(ngx_cycle_t *cycle, void *data)
#if (NGX_THREADS)
- ngx_init_threads(5, 128 * 1024 * 1024, cycle->log);
+ if (ngx_init_threads(5, 128 * 1024 * 1024, cycle->log) == NGX_ERROR) {
+ /* fatal */
+ exit(1);
+ }
for (i = 0; i < 1; i++) {
- ngx_create_thread(&tid, ngx_worker_thread_cycle, cycle, cycle->log);
+ if (ngx_create_thread(&tid, ngx_worker_thread_cycle,
+ cycle, cycle->log) != 0)
+ {
+ /* fatal */
+ exit(1);
+ }
}
#endif
diff --git a/src/core/ngx_alloc.c b/src/core/ngx_alloc.c
index ae96564fc..1cbd4c8c8 100644
--- a/src/core/ngx_alloc.c
+++ b/src/core/ngx_alloc.c
@@ -9,10 +9,11 @@ void *ngx_alloc(size_t size, ngx_log_t *log)
if (!(p = malloc(size))) {
ngx_log_error(NGX_LOG_EMERG, log, ngx_errno,
- "malloc() %d bytes failed", size);
+ "malloc() " SIZE_T_FMT " bytes failed", size);
}
- ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0, "malloc: %08x:%d", p, size);
+ ngx_log_debug2(NGX_LOG_DEBUG_ALLOC, log, 0,
+ "malloc: " PTR_FMT ":" SIZE_T_FMT, p, size);
return p;
}
@@ -57,7 +58,7 @@ void ngx_destroy_pool(ngx_pool_t *pool)
for (l = pool->large; l; l = l->next) {
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
- "free: %08x", l->alloc);
+ "free: " PTR_FMT, l->alloc);
if (l->alloc) {
free(l->alloc);
@@ -72,7 +73,8 @@ void ngx_destroy_pool(ngx_pool_t *pool)
*/
for (p = pool, n = pool->next; /* void */; p = n, n = n->next) {
- ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0, "free: %08x", p);
+ ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
+ "free: " PTR_FMT, p);
if (n == NULL) {
break;
@@ -179,7 +181,7 @@ void ngx_pfree(ngx_pool_t *pool, void *p)
for (l = pool->large; l; l = l->next) {
if (p == l->alloc) {
ngx_log_debug1(NGX_LOG_DEBUG_ALLOC, pool->log, 0,
- "free: %08x", l->alloc);
+ "free: " PTR_FMT, l->alloc);
free(l->alloc);
l->alloc = NULL;
}
diff --git a/src/core/ngx_atomic.h b/src/core/ngx_atomic.h
index f5edd1966..5f5add9df 100644
--- a/src/core/ngx_atomic.h
+++ b/src/core/ngx_atomic.h
@@ -6,9 +6,9 @@
#include <ngx_core.h>
-#ifdef __i386__
+#if ( __i386__ || __amd64__ )
-typedef uint32_t ngx_atomic_t;
+typedef volatile uint32_t ngx_atomic_t;
#if (NGX_SMP)
#define NGX_SMP_LOCK "lock"
@@ -21,13 +21,13 @@ static ngx_inline uint32_t ngx_atomic_inc(ngx_atomic_t *value)
{
uint32_t old;
- __asm__ __volatile ("
+ __asm__ volatile (
- movl $1, %0
- " NGX_SMP_LOCK
- " xaddl %0, %1
+ " movl $1, %0; "
+ NGX_SMP_LOCK
+ " xaddl %0, %1; "
- ": "=a" (old) : "m" (*value));
+ : "=a" (old) : "m" (*value));
return old;
}
@@ -37,13 +37,13 @@ static ngx_inline uint32_t ngx_atomic_dec(ngx_atomic_t *value)
{
uint32_t old;
- __asm__ __volatile ("
+ __asm__ volatile (
- movl $-1, %0
- " NGX_SMP_LOCK
- " xaddl %0, %1
+ " movl $-1, %0; "
+ NGX_SMP_LOCK
+ " xaddl %0, %1; "
- ": "=a" (old) : "m" (*value));
+ : "=a" (old) : "m" (*value));
return old;
}
@@ -55,21 +55,21 @@ static ngx_inline uint32_t ngx_atomic_cmp_set(ngx_atomic_t *lock,
{
uint32_t res;
- __asm__ __volatile ("
+ __asm__ volatile (
- " NGX_SMP_LOCK
- " cmpxchgl %3, %1
- setzb %%al
- movzbl %%al, %0
+ NGX_SMP_LOCK
+ " cmpxchgl %3, %1; "
+ " setzb %%al; "
+ " movzbl %%al, %0; "
- ": "=a" (res) : "m" (*lock), "a" (old), "q" (set));
+ : "=a" (res) : "m" (*lock), "a" (old), "q" (set));
return res;
}
#else
-typedef uint32_t ngx_atomic_t;
+typedef volatile uint32_t ngx_atomic_t;
/* STUB */
#define ngx_atomic_inc(x) x++;
diff --git a/src/core/ngx_config.h b/src/core/ngx_config.h
index 67e17d0a3..e56edc9ac 100644
--- a/src/core/ngx_config.h
+++ b/src/core/ngx_config.h
@@ -46,10 +46,6 @@ typedef u_int ngx_uint_t;
typedef int ngx_flag_t;
-/* STUB: autoconf */
-#define PTR_FMT "%08X"
-
-
#ifndef NGX_SERVER_ROOT
#define NGX_SERVER_ROOT "./"
#if 0