diff options
| author | Garrett D'Amore <garrett@damore.org> | 2017-07-10 15:02:38 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2017-07-10 15:02:38 -0700 |
| commit | 795aebbee77bb74d8792df96dfe1aa79ec9548fc (patch) | |
| tree | 58c16424c16b9e71cebdceaee4507ab6608f80da /src/platform/windows/win_thread.c | |
| parent | de90f97167d2df6739db47b2c6aad85f06250270 (diff) | |
| download | nng-795aebbee77bb74d8792df96dfe1aa79ec9548fc.tar.gz nng-795aebbee77bb74d8792df96dfe1aa79ec9548fc.tar.bz2 nng-795aebbee77bb74d8792df96dfe1aa79ec9548fc.zip | |
Give up on uncrustify; switch to clang-format.
Diffstat (limited to 'src/platform/windows/win_thread.c')
| -rw-r--r-- | src/platform/windows/win_thread.c | 42 |
1 files changed, 12 insertions, 30 deletions
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index bc2d7a0c..693516bd 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -22,7 +22,6 @@ nni_alloc(size_t sz) return (v); } - void nni_free(void *b, size_t z) { @@ -30,7 +29,6 @@ nni_free(void *b, size_t z) HeapFree(GetProcessHeap(), 0, b); } - int nni_plat_mtx_init(nni_plat_mtx *mtx) { @@ -39,28 +37,24 @@ nni_plat_mtx_init(nni_plat_mtx *mtx) return (0); } - void nni_plat_mtx_fini(nni_plat_mtx *mtx) { mtx->init = 0; } - void nni_plat_mtx_lock(nni_plat_mtx *mtx) { AcquireSRWLockExclusive(&mtx->srl); } - void nni_plat_mtx_unlock(nni_plat_mtx *mtx) { ReleaseSRWLockExclusive(&mtx->srl); } - int nni_plat_cv_init(nni_plat_cv *cv, nni_plat_mtx *mtx) { @@ -69,49 +63,43 @@ nni_plat_cv_init(nni_plat_cv *cv, nni_plat_mtx *mtx) return (0); } - void nni_plat_cv_wake(nni_plat_cv *cv) { WakeAllConditionVariable(&cv->cv); } - void nni_plat_cv_wait(nni_plat_cv *cv) { (void) SleepConditionVariableSRW(&cv->cv, cv->srl, INFINITE, 0); } - int nni_plat_cv_until(nni_plat_cv *cv, nni_time until) { nni_time now; - DWORD msec; - BOOL ok; + DWORD msec; + BOOL ok; now = nni_plat_clock(); if (now > until) { msec = 0; } else { // times are in usec, but win32 wants millis - msec = (DWORD) (((until - now) + 999)/1000); + msec = (DWORD)(((until - now) + 999) / 1000); } ok = SleepConditionVariableSRW(&cv->cv, cv->srl, msec, 0); return (ok ? 0 : NNG_ETIMEDOUT); } - void nni_plat_cv_fini(nni_plat_cv *cv) { } - -static unsigned int __stdcall -nni_plat_thr_main(void *arg) +static unsigned int __stdcall nni_plat_thr_main(void *arg) { nni_plat_thr *thr = arg; @@ -119,25 +107,22 @@ nni_plat_thr_main(void *arg) return (0); } - int nni_plat_thr_init(nni_plat_thr *thr, void (*fn)(void *), void *arg) { thr->func = fn; - thr->arg = arg; + thr->arg = arg; // We could probably even go down to 8k... but crypto for some // protocols might get bigger than this. 1MB is waaay too big. - thr->handle = (HANDLE) _beginthreadex(NULL, 16384, - nni_plat_thr_main, thr, STACK_SIZE_PARAM_IS_A_RESERVATION, - NULL); + thr->handle = (HANDLE) _beginthreadex(NULL, 16384, nni_plat_thr_main, + thr, STACK_SIZE_PARAM_IS_A_RESERVATION, NULL); if (thr->handle == NULL) { - return (NNG_ENOMEM); // Best guess... + return (NNG_ENOMEM); // Best guess... } return (0); } - void nni_plat_thr_fini(nni_plat_thr *thr) { @@ -149,23 +134,22 @@ nni_plat_thr_fini(nni_plat_thr *thr) } } - int nni_plat_init(int (*helper)(void)) { - static LONG inited = 0; - int rv; + static LONG inited = 0; + int rv; static SRWLOCK lock = SRWLOCK_INIT; if (inited) { - return (0); // fast path + return (0); // fast path } AcquireSRWLockExclusive(&lock); if (!inited) { WSADATA data; - WORD ver; + WORD ver; ver = MAKEWORD(2, 2); if (WSAStartup(MAKEWORD(2, 2), &data) != 0) { if ((LOBYTE(data.wVersion) != 2) || @@ -195,7 +179,6 @@ out: return (rv); } - void nni_plat_fini(void) { @@ -205,7 +188,6 @@ nni_plat_fini(void) WSACleanup(); } - #else // Suppress empty symbols warnings in ranlib. |
