Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 1 | |
| 2 | /* |
Igor Sysoev | ff8da91 | 2004-09-29 16:00:49 +0000 | [diff] [blame] | 3 | * Copyright (C) Igor Sysoev |
Maxim Konovalov | f8d59e3 | 2012-01-18 15:07:43 +0000 | [diff] [blame] | 4 | * Copyright (C) Nginx, Inc. |
Igor Sysoev | d90282d | 2004-09-28 08:34:51 +0000 | [diff] [blame] | 5 | */ |
| 6 | |
| 7 | |
Igor Sysoev | b54698b | 2004-02-23 20:57:12 +0000 | [diff] [blame] | 8 | #ifndef _NGX_THREAD_H_INCLUDED_ |
| 9 | #define _NGX_THREAD_H_INCLUDED_ |
| 10 | |
| 11 | |
| 12 | #include <ngx_config.h> |
| 13 | #include <ngx_core.h> |
| 14 | |
Valentin Bartenev | 27e49d7 | 2015-03-14 17:37:07 +0300 | [diff] [blame] | 15 | #if (NGX_THREADS) |
| 16 | |
| 17 | #include <pthread.h> |
| 18 | |
| 19 | |
| 20 | typedef pthread_mutex_t ngx_thread_mutex_t; |
| 21 | |
| 22 | ngx_int_t ngx_thread_mutex_create(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
| 23 | ngx_int_t ngx_thread_mutex_destroy(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
| 24 | ngx_int_t ngx_thread_mutex_lock(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
| 25 | ngx_int_t ngx_thread_mutex_unlock(ngx_thread_mutex_t *mtx, ngx_log_t *log); |
| 26 | |
| 27 | |
| 28 | typedef pthread_cond_t ngx_thread_cond_t; |
| 29 | |
| 30 | ngx_int_t ngx_thread_cond_create(ngx_thread_cond_t *cond, ngx_log_t *log); |
| 31 | ngx_int_t ngx_thread_cond_destroy(ngx_thread_cond_t *cond, ngx_log_t *log); |
| 32 | ngx_int_t ngx_thread_cond_signal(ngx_thread_cond_t *cond, ngx_log_t *log); |
| 33 | ngx_int_t ngx_thread_cond_wait(ngx_thread_cond_t *cond, ngx_thread_mutex_t *mtx, |
| 34 | ngx_log_t *log); |
| 35 | |
| 36 | |
| 37 | #if (NGX_LINUX) |
| 38 | |
| 39 | typedef pid_t ngx_tid_t; |
| 40 | #define NGX_TID_T_FMT "%P" |
| 41 | |
| 42 | #elif (NGX_FREEBSD) |
| 43 | |
| 44 | typedef uint32_t ngx_tid_t; |
| 45 | #define NGX_TID_T_FMT "%uD" |
| 46 | |
| 47 | #elif (NGX_DARWIN) |
| 48 | |
| 49 | typedef uint64_t ngx_tid_t; |
| 50 | #define NGX_TID_T_FMT "%uA" |
| 51 | |
| 52 | #else |
| 53 | |
| 54 | typedef uint64_t ngx_tid_t; |
| 55 | #define NGX_TID_T_FMT "%uA" |
| 56 | |
| 57 | #endif |
| 58 | |
| 59 | ngx_tid_t ngx_thread_tid(void); |
| 60 | |
| 61 | #define ngx_log_tid ngx_thread_tid() |
| 62 | |
| 63 | #else |
| 64 | |
Igor Sysoev | 1b73583 | 2004-11-11 14:07:14 +0000 | [diff] [blame] | 65 | #define ngx_log_tid 0 |
| 66 | #define NGX_TID_T_FMT "%d" |
Igor Sysoev | b54698b | 2004-02-23 20:57:12 +0000 | [diff] [blame] | 67 | |
Valentin Bartenev | 27e49d7 | 2015-03-14 17:37:07 +0300 | [diff] [blame] | 68 | #endif |
| 69 | |
Igor Sysoev | b54698b | 2004-02-23 20:57:12 +0000 | [diff] [blame] | 70 | |
Igor Sysoev | b54698b | 2004-02-23 20:57:12 +0000 | [diff] [blame] | 71 | #endif /* _NGX_THREAD_H_INCLUDED_ */ |