diff options
| author | Garrett D'Amore <garrett@damore.org> | 2018-08-25 11:41:44 -0700 |
|---|---|---|
| committer | Garrett D'Amore <garrett@damore.org> | 2018-08-27 15:33:26 -0700 |
| commit | 84a1e7455c158441dd7b33d2eb296cc33dd5a6df (patch) | |
| tree | 333f17970a90643a40d3392e161e81e9903477f7 /src/platform/windows/win_thread.c | |
| parent | 83b7a9afec7b3659974c614cea69fa3abb904d24 (diff) | |
| download | nng-84a1e7455c158441dd7b33d2eb296cc33dd5a6df.tar.gz nng-84a1e7455c158441dd7b33d2eb296cc33dd5a6df.tar.bz2 nng-84a1e7455c158441dd7b33d2eb296cc33dd5a6df.zip | |
fixes #674 want 64-bit atomics (for stats)
Diffstat (limited to 'src/platform/windows/win_thread.c')
| -rw-r--r-- | src/platform/windows/win_thread.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index b9743c5e..f80c8e3f 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -121,6 +121,44 @@ nni_atomic_flag_reset(nni_atomic_flag *f) InterlockedExchange(&f->f, 0); } +void +nni_atomic_inc64(nni_atomic_u64 *v, uint64_t bump) +{ + InterlockedAddNoFence64(&v->v, (LONGLONG) bump); +} + +void +nni_atomic_dec64(nni_atomic_u64 *v, uint64_t bump) +{ + // Windows lacks a sub, so we add the negative. + InterlockedAddNoFence64(&v->v, (0ll - (LONGLONG) bump)); +} + +uint64_t +nni_atomic_get64(nni_atomic_u64 *v) +{ + + return ((uint64_t)(InterlockedExchangeAdd64(&v->v, 0))); +} + +void +nni_atomic_set64(nni_atomic_u64 *v, uint64_t u) +{ + return (InterlockedExchange64(&v->v, (LONGLONG) u)); +} + +uint64_t +nni_atomic_swap64(nni_atomic_u64 *v, uint64_t u) +{ + return ((uint64_t)(InterlockedExchange64(&v->v, (LONGLONG) u))); +} + +void +nni_atomic_init64(nni_atomic_u64 *v) +{ + InterlockedExchange64(&v->v, 0); +} + static unsigned int __stdcall nni_plat_thr_main(void *arg) { nni_plat_thr *thr = arg; |
