diff options
author | David Robillard <d@drobilla.net> | 2022-08-18 20:02:18 -0400 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2022-08-18 20:02:18 -0400 |
commit | 12cac42e31653323ec607ba3b6512fe9a734d083 (patch) | |
tree | c7d98780b43ba112a4df5898b1161c0bd3ec39bd | |
parent | 89d750689d7824066b9783da54186df3748a0ee0 (diff) | |
download | zix-12cac42e31653323ec607ba3b6512fe9a734d083.tar.gz zix-12cac42e31653323ec607ba3b6512fe9a734d083.tar.bz2 zix-12cac42e31653323ec607ba3b6512fe9a734d083.zip |
Add return status to zix_ring_mlock()
-rw-r--r-- | include/zix/ring.h | 2 | ||||
-rw-r--r-- | src/ring.c | 9 |
2 files changed, 6 insertions, 5 deletions
diff --git a/include/zix/ring.h b/include/zix/ring.h index 872f963..8100d2b 100644 --- a/include/zix/ring.h +++ b/include/zix/ring.h @@ -66,7 +66,7 @@ zix_ring_free(ZixRing* ZIX_NULLABLE ring); using the ring. */ ZIX_API -void +ZixStatus zix_ring_mlock(ZixRing* ZIX_NONNULL ring); /** @@ -14,7 +14,7 @@ # define ZIX_MLOCK(ptr, size) mlock((ptr), (size)) #elif defined(_WIN32) # include <windows.h> -# define ZIX_MLOCK(ptr, size) VirtualLock((ptr), (size)) +# define ZIX_MLOCK(ptr, size) !VirtualLock((ptr), (size)) #else # pragma message("warning: No memory locking, possible RT violations") # define ZIX_MLOCK(ptr, size) @@ -106,11 +106,12 @@ zix_ring_free(ZixRing* const ring) } } -void +ZixStatus zix_ring_mlock(ZixRing* const ring) { - ZIX_MLOCK(ring, sizeof(ZixRing)); - ZIX_MLOCK(ring->buf, ring->size); + return (ZIX_MLOCK(ring, sizeof(ZixRing)) || ZIX_MLOCK(ring->buf, ring->size)) + ? ZIX_STATUS_ERROR + : ZIX_STATUS_SUCCESS; } void |