Skip to content

Commit 362109b

Browse files
committed
Replace deprecated OSSpinLock with pthread_mutex_t
Cherry-pick fix from upstream mailcore2 PR #1953. OSSpinLock is deprecated on Apple platforms since macOS 10.12/iOS 10.0 due to priority inversion issues. This causes deprecation warnings during compilation. This fix replaces OSSpinLock with pthread_mutex_t on all platforms, which is already used on non-Apple platforms. pthread_mutex_t is a safe, portable alternative that: 1. Avoids priority inversion issues 2. Eliminates platform-specific code paths 3. Is already being used elsewhere in the codebase Upstream: MailCore/mailcore2#1953 Related: MailCore/mailcore2#1785
1 parent f67ccbb commit 362109b

File tree

3 files changed

+0
-23
lines changed

3 files changed

+0
-23
lines changed

Vendor/mailcore2/src/core/basetypes/MCLock.h

Lines changed: 0 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -9,17 +9,6 @@
99
#ifndef mailcore2_MCLock_h
1010
#define mailcore2_MCLock_h
1111

12-
#if __APPLE__
13-
14-
#include <libkern/OSAtomic.h>
15-
16-
#define MC_LOCK_TYPE OSSpinLock
17-
#define MC_LOCK_INITIAL_VALUE OS_SPINLOCK_INIT
18-
#define MC_LOCK(l) OSSpinLockLock(l)
19-
#define MC_UNLOCK(l) OSSpinLockUnlock(l)
20-
21-
#else
22-
2312
#include <pthread.h>
2413

2514
#define MC_LOCK_TYPE pthread_mutex_t
@@ -28,5 +17,3 @@
2817
#define MC_UNLOCK(l) pthread_mutex_unlock(l)
2918

3019
#endif
31-
32-
#endif

Vendor/mailcore2/src/core/basetypes/MCObject.cpp

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -33,18 +33,12 @@ Object::Object()
3333

3434
Object::~Object()
3535
{
36-
#ifndef __APPLE__
3736
pthread_mutex_destroy(&mLock);
38-
#endif
3937
}
4038

4139
void Object::init()
4240
{
43-
#if __APPLE__
44-
mLock = OS_SPINLOCK_INIT;
45-
#else
4641
pthread_mutex_init(&mLock, NULL);
47-
#endif
4842
mCounter = 1;
4943
}
5044

Vendor/mailcore2/src/core/basetypes/MCObject.h

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -57,11 +57,7 @@ namespace mailcore {
5757
public: // private
5858

5959
private:
60-
#if __APPLE__
61-
OSSpinLock mLock;
62-
#else
6360
pthread_mutex_t mLock;
64-
#endif
6561
int mCounter;
6662
void init();
6763
static void initObjectConstructors();

0 commit comments

Comments
 (0)