diff options
Diffstat (limited to 'src/platform/windows')
| -rw-r--r-- | src/platform/windows/win_impl.h | 6 | ||||
| -rw-r--r-- | src/platform/windows/win_thread.c | 12 |
2 files changed, 17 insertions, 1 deletions
diff --git a/src/platform/windows/win_impl.h b/src/platform/windows/win_impl.h index de4f8e5b..608a065e 100644 --- a/src/platform/windows/win_impl.h +++ b/src/platform/windows/win_impl.h @@ -1,5 +1,5 @@ // -// Copyright 2018 Staysail Systems, Inc. <info@staysail.tech> +// Copyright 2021 Staysail Systems, Inc. <info@staysail.tech> // Copyright 2018 Capitar IT Group BV <info@capitar.com> // // This software is supplied under the terms of the MIT License, a @@ -67,6 +67,10 @@ struct nni_atomic_u64 { LONGLONG v; }; +struct nni_atomic_ptr { + LONGLONG v; +}; + // nni_win_io is used with io completion ports. This allows us to get // to a specific completion callback without requiring the poller (in the // completion port) to know anything about the event itself. diff --git a/src/platform/windows/win_thread.c b/src/platform/windows/win_thread.c index 9c7c09d3..31e783a3 100644 --- a/src/platform/windows/win_thread.c +++ b/src/platform/windows/win_thread.c @@ -223,6 +223,18 @@ nni_atomic_set64(nni_atomic_u64 *v, uint64_t u) (void) InterlockedExchange64(&v->v, (LONGLONG) u); } +void * +nni_atomic_get_ptr(nni_atomic_ptr *v) +{ + return ((void *) (InterlockedExchangeAdd64(&v->v, 0))); +} + +void +nni_atomic_set_ptr(nni_atomic_ptr *v) +{ + (void) InterlockedExchange64(&v->v, (LONGLONG) (uintptr_t) v); +} + uint64_t nni_atomic_swap64(nni_atomic_u64 *v, uint64_t u) { |
