Skip to content

Commit

Permalink
Refactor macro
Browse files Browse the repository at this point in the history
  • Loading branch information
nabla-c0d3 committed Mar 1, 2017
1 parent 1d3fe43 commit 564255a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions TrustKit/Dependencies/RSSwizzle/RSSwizzle.m
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,9 @@
#if BASE_SDK_HIGHER_THAN_10
#import <os/lock.h>
#else
// Below iOS 10, OS_UNFAIR_LOCK_INIT will not exist. Note that this type works with OSSpinLock
#define OS_UNFAIR_LOCK_INIT ((os_unfair_lock){0})

typedef struct _os_unfair_lock_s {
uint32_t _os_unfair_lock_opaque;
} os_unfair_lock, *os_unfair_lock_t;
Expand Down Expand Up @@ -272,16 +275,7 @@ static void swizzle(Class classToSwizzle,
NSCAssert(blockIsAnImpFactoryBlock(factoryBlock),
@"Wrong type of implementation factory block.");

__block os_unfair_lock lock;
if (DEVICE_HIGHER_THAN_10)
{
lock = OS_UNFAIR_LOCK_INIT;
}
else
{
// Below iOS 10, OS_UNFAIR_LOCK_INIT will not exist. Note that this type works with OSSpinLock
lock = ((os_unfair_lock){0});
}
__block os_unfair_lock lock = OS_UNFAIR_LOCK_INIT;

// To keep things thread-safe, we fill in the originalIMP later,
// with the result of the class_replaceMethod call below.
Expand Down

0 comments on commit 564255a

Please sign in to comment.