diff options
author | Igor Sysoev <igor@sysoev.ru> | 2004-07-07 19:01:00 +0400 |
---|---|---|
committer | Igor Sysoev <igor@sysoev.ru> | 2004-07-07 19:01:00 +0400 |
commit | 2b97993c7a6525bf41c694414450943d39605757 (patch) | |
tree | b3b3870575cd65e64ef59de5359bfdd3695bc77c /src/os/unix/ngx_freebsd_rfork_thread.h | |
parent | c78c41cefcf1e1fa8005f81b7c6cc0c857bcf46f (diff) |
nginx-0.0.7-2004-07-07-19:01:00 import
Diffstat (limited to 'src/os/unix/ngx_freebsd_rfork_thread.h')
-rw-r--r-- | src/os/unix/ngx_freebsd_rfork_thread.h | 31 |
1 files changed, 23 insertions, 8 deletions
diff --git a/src/os/unix/ngx_freebsd_rfork_thread.h b/src/os/unix/ngx_freebsd_rfork_thread.h index c9ae99c09..ce68a4efc 100644 --- a/src/os/unix/ngx_freebsd_rfork_thread.h +++ b/src/os/unix/ngx_freebsd_rfork_thread.h @@ -13,14 +13,6 @@ typedef pid_t ngx_tid_t; #define ngx_log_tid 0 #define TID_T_FMT PID_T_FMT - - -extern void **ngx_tls; - -#define ngx_thread_create_tls() 0 -#define ngx_thread_create_tls_n "" -#define ngx_thread_get_tls() ngx_tls[ngx_gettid()] -ngx_int_t ngx_thread_set_tls(void *value); #define NGX_MUTEX_LIGHT 1 @@ -87,6 +79,29 @@ static inline int ngx_gettid() ngx_tid_t ngx_thread_self(); +typedef ngx_uint_t ngx_tls_key_t; + +#define NGX_THREAD_KEYS_MAX 16 + +extern void **ngx_tls; + +ngx_int_t ngx_thread_key_create(ngx_tls_key_t *key); +#define ngx_thread_key_create_n "the tls key creation" + +ngx_int_t ngx_thread_set_tls(ngx_tls_key_t key, void *value); +#define ngx_thread_set_tls_n "the tls key setting" + + +static void *ngx_thread_get_tls(ngx_tls_key_t key) +{ + if (key >= NGX_THREAD_KEYS_MAX) { + return NULL; + } + + return ngx_tls[key * NGX_THREAD_KEYS_MAX + ngx_gettid()]; +} + + #define ngx_mutex_trylock(m) ngx_mutex_dolock(m, 1) #define ngx_mutex_lock(m) ngx_mutex_dolock(m, 0) ngx_int_t ngx_mutex_dolock(ngx_mutex_t *m, ngx_int_t try); |