diff options
-rw-r--r-- | src/core/basetypes/MCLock.h | 32 |
1 files changed, 32 insertions, 0 deletions
diff --git a/src/core/basetypes/MCLock.h b/src/core/basetypes/MCLock.h new file mode 100644 index 00000000..1717a602 --- /dev/null +++ b/src/core/basetypes/MCLock.h @@ -0,0 +1,32 @@ +// +// MCLock.h +// mailcore2 +// +// Created by Hoa V. DINH on 1/23/15. +// Copyright (c) 2015 MailCore. All rights reserved. +// + +#ifndef mailcore2_MCLock_h +#define mailcore2_MCLock_h + +#if __APPLE__ + +#include <libkern/OSAtomic.h> + +#define MC_LOCK_TYPE OSSpinLock +#define MC_LOCK_INITIAL_VALUE OS_SPINLOCK_INIT +#define MC_LOCK(l) OSSpinLockLock(l) +#define MC_UNLOCK(l) OSSpinLockUnlock(l) + +#else + +#include <pthread.h> + +#define MC_LOCK_TYPE pthread_mutex_t +#define MC_LOCK_INITIAL_VALUE PTHREAD_MUTEX_INITIALIZER +#define MC_LOCK(l) pthread_mutex_lock(l) +#define MC_UNLOCK(l) pthread_mutex_unlock(l) + +#endif + +#endif |