diff options
| author | Igor Sysoev <igor@sysoev.ru> | 2004-06-30 15:30:41 +0000 |
|---|---|---|
| committer | Igor Sysoev <igor@sysoev.ru> | 2004-06-30 15:30:41 +0000 |
| commit | 078d1b2c2263690f2f6b7217b567eeeb525910d0 (patch) | |
| tree | dfb82cccd10c3dee8a500506f7692b0445200e5c /src/os/win32 | |
| parent | 0a94cfd2ae9ca87b4d988b5066f739a3034f3bff (diff) | |
| download | nginx-078d1b2c2263690f2f6b7217b567eeeb525910d0.tar.gz nginx-078d1b2c2263690f2f6b7217b567eeeb525910d0.tar.bz2 | |
nginx-0.0.7-2004-06-30-19:30:41 import
Diffstat (limited to 'src/os/win32')
| -rw-r--r-- | src/os/win32/ngx_atomic.h | 33 | ||||
| -rw-r--r-- | src/os/win32/ngx_os.h | 1 | ||||
| -rw-r--r-- | src/os/win32/ngx_process.h | 3 | ||||
| -rw-r--r-- | src/os/win32/ngx_win32_init.c | 2 |
4 files changed, 39 insertions, 0 deletions
diff --git a/src/os/win32/ngx_atomic.h b/src/os/win32/ngx_atomic.h new file mode 100644 index 000000000..fcc3ff1ee --- /dev/null +++ b/src/os/win32/ngx_atomic.h @@ -0,0 +1,33 @@ +#ifndef _NGX_ATOMIC_H_INCLUDED_ +#define _NGX_ATOMIC_H_INCLUDED_ + + +#include <ngx_config.h> +#include <ngx_core.h> + + +#define ngx_atomic_inc(p) InterlockedIncrement((long *) p) +#define ngx_atomic_dec(p) InterlockedDecrement((long *) p) + + +#if defined( __WATCOMC__ ) || defined( __BORLANDC__ ) + +#define ngx_atomic_cmp_set(lock, old, set) \ + (InterlockedCompareExchange((long *) lock, set, old) == old) + +#else + +#define ngx_atomic_cmp_set(lock, old, set) \ + (InterlockedCompareExchange((void **) lock, (void *) set, (void *) old) \ + == (void *) old) + +#endif + + +void ngx_spinlock(ngx_atomic_t *lock, ngx_uint_t spin); + +#define ngx_trylock(lock) (*(lock) == 0 && ngx_atomic_cmp_set(lock, 0, 1)) +#define ngx_unlock(lock) *(lock) = 0 + + +#endif /* _NGX_ATOMIC_H_INCLUDED_ */ diff --git a/src/os/win32/ngx_os.h b/src/os/win32/ngx_os.h index aa66e70d3..84b81a1c4 100644 --- a/src/os/win32/ngx_os.h +++ b/src/os/win32/ngx_os.h @@ -44,6 +44,7 @@ ngx_chain_t *ngx_overlapped_wsasend_chain(ngx_connection_t *c, ngx_chain_t *in, extern ngx_os_io_t ngx_os_io; +extern int ngx_ncpu; extern int ngx_max_sockets; extern int ngx_inherited_nonblocking; extern int ngx_win32_version; diff --git a/src/os/win32/ngx_process.h b/src/os/win32/ngx_process.h index c8587688b..2866c449b 100644 --- a/src/os/win32/ngx_process.h +++ b/src/os/win32/ngx_process.h @@ -23,6 +23,9 @@ typedef struct { ngx_pid_t ngx_execute(ngx_cycle_t *cycle, ngx_exec_ctx_t *ctx); +#define ngx_sched_yeld() Sleep(0) + + extern ngx_pid_t ngx_pid; diff --git a/src/os/win32/ngx_win32_init.c b/src/os/win32/ngx_win32_init.c index 7a25b2845..7d9d433e5 100644 --- a/src/os/win32/ngx_win32_init.c +++ b/src/os/win32/ngx_win32_init.c @@ -4,6 +4,7 @@ int ngx_win32_version; +int ngx_ncpu; int ngx_max_sockets; int ngx_inherited_nonblocking = 1; @@ -124,6 +125,7 @@ int ngx_os_init(ngx_log_t *log) GetSystemInfo(&si); ngx_pagesize = si.dwPageSize; + ngx_ncpu = si.dwNumberOfProcessors; /* init Winsock */ |
