aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/core/basetypes/MCLock.h
blob: 1717a602b5fb244367b83e0060af1555077dc5bf (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
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