summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--include/zix/ring.h2
-rw-r--r--src/ring.c9
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);
/**
diff --git a/src/ring.c b/src/ring.c
index 922def8..4932e9e 100644
--- a/src/ring.c
+++ b/src/ring.c
@@ -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