diff options
-rw-r--r-- | compat/shm.c | 22 | ||||
-rw-r--r-- | compat/shm.h | 14 |
2 files changed, 19 insertions, 17 deletions
diff --git a/compat/shm.c b/compat/shm.c index d0c72781..95263a08 100644 --- a/compat/shm.c +++ b/compat/shm.c @@ -41,7 +41,7 @@ fail: SHM_FUN_NAME(free)(self); } -SHM_FUN(void, free) +SHM_FUN0(void, free) { if (self->mem) (void) UnmapViewOfFile(self->mem); @@ -57,18 +57,18 @@ SHM_FUN(void, free) self->mutex = NULL; } -SHM_FUN(void, lock) +SHM_FUN0(void, lock) { if (self->mutex) (void)(WaitForSingleObject(self->mutex, INFINITE) == WAIT_OBJECT_0); } -SHM_FUN(void, unlock) +SHM_FUN0(void, unlock) { (void) ReleaseMutex(self->mutex); } -SHM_FUN(bool, success) +SHM_FUN0(bool, success) { return self->mem != NULL; } @@ -115,7 +115,7 @@ fail: SHM_FUN_NAME(free)(self); } -SHM_FUN(void, free) +SHM_FUN0(void, free) { if (self->mem != (void*)-1) (void)munmap(self->mem, self->size); @@ -127,24 +127,24 @@ SHM_FUN(void, free) self->size = 0; } -SHM_FUN(void, lock) +SHM_FUN0(void, lock) { - return flock(self->fd, LOCK_EX) == 0; + flock(self->fd, LOCK_EX); } -SHM_FUN(void, unlock) +SHM_FUN0(void, unlock) { - return flock(self->fd, LOCK_UN) == 0; + flock(self->fd, LOCK_UN); } -SHM_FUN(bool, success) +SHM_FUN0(bool, success) { return self->mem != (void*) -1; } #endif -SHM_FUN(void*, ptr) +SHM_FUN0(void*, ptr) { return self->mem; } diff --git a/compat/shm.h b/compat/shm.h index 7cd7693d..856b9c8c 100644 --- a/compat/shm.h +++ b/compat/shm.h @@ -49,14 +49,16 @@ struct SHM_TYPE_NAME { }; #define SHM_FUN_NAME(f) PP_CAT(SHM_FUN_PREFIX, f) -#define SHM_FUN(r, f, ...) SHM_EXTERN SHM_EXPORT r SHM_FUN_NAME(f)(SHM_TYPE_NAME* __restrict self, __VA_ARGS__) +#define SHM_FUN_(r, f)SHM_EXTERN SHM_EXPORT r SHM_FUN_NAME(f) +#define SHM_FUN(r, f, ...) SHM_FUN_(r, f)(SHM_TYPE_NAME* self, __VA_ARGS__) +#define SHM_FUN0(r, f) SHM_FUN_(r, f)(SHM_TYPE_NAME* self) SHM_FUN(void, init, const char* shm_name, const char* mutex_name, int map_size); -SHM_FUN(void, free); -SHM_FUN(void, lock); -SHM_FUN(void, unlock); -SHM_FUN(void*,ptr); -SHM_FUN(bool, success); +SHM_FUN0(void, free); +SHM_FUN0(void, lock); +SHM_FUN0(void, unlock); +SHM_FUN0(void*,ptr); +SHM_FUN0(bool, success); #ifndef BUILD_SHM # undef SHM_FUN |