Revision: 13081
          http://sourceforge.net/p/skim-app/code/13081
Author:   hofman
Date:     2022-09-21 14:19:38 +0000 (Wed, 21 Sep 2022)
Log Message:
-----------
replace OSAtomic with stdatomic

Modified Paths:
--------------
    trunk/SKPDFSynchronizer.h
    trunk/SKPDFSynchronizer.m
    trunk/SKSyncDot.h
    trunk/SKSyncDot.m

Modified: trunk/SKPDFSynchronizer.h
===================================================================
--- trunk/SKPDFSynchronizer.h   2022-09-13 22:42:00 UTC (rev 13080)
+++ trunk/SKPDFSynchronizer.h   2022-09-21 14:19:38 UTC (rev 13081)
@@ -38,6 +38,7 @@
 
 #import <Cocoa/Cocoa.h>
 #import "synctex_parser.h"
+#import <stdatomic.h>
 
 typedef NS_OPTIONS(NSUInteger, SKPDFSynchronizerOption) {
     SKPDFSynchronizerDefaultOptions = 0,
@@ -66,7 +67,7 @@
     NSMapTable *filenames;
     synctex_scanner_p scanner;
     
-    volatile int32_t shouldKeepRunning;
+    _Atomic(BOOL) shouldKeepRunning;
 }
 
 @property (nonatomic, assign) id <SKPDFSynchronizerDelegate> delegate;

Modified: trunk/SKPDFSynchronizer.m
===================================================================
--- trunk/SKPDFSynchronizer.m   2022-09-13 22:42:00 UTC (rev 13080)
+++ trunk/SKPDFSynchronizer.m   2022-09-21 14:19:38 UTC (rev 13081)
@@ -37,7 +37,6 @@
  */
 
 #import "SKPDFSynchronizer.h"
-#import <libkern/OSAtomic.h>
 #import "SKPDFSyncRecord.h"
 #import "NSCharacterSet_SKExtensions.h"
 #import "NSScanner_SKExtensions.h"
@@ -84,7 +83,7 @@
         filenames = nil;
         scanner = NULL;
         
-        shouldKeepRunning = 1;
+        shouldKeepRunning = YES;
         
         // it is not safe to use the defaultManager on background threads
         fileManager = [[NSFileManager alloc] init];
@@ -111,14 +110,13 @@
     // make sure we're not calling our delegate
     delegate = nil;
     // set the stop flag immediately, so any running task may stop in its 
tracks
-    OSAtomicCompareAndSwap32Barrier(1, 0, (int32_t *)&shouldKeepRunning);
+    atomic_store(&shouldKeepRunning, NO);
 }
 
 #pragma mark Thread safe accessors
 
 - (BOOL)shouldKeepRunning {
-    OSMemoryBarrier();
-    return shouldKeepRunning == 1;
+    return atomic_load(&shouldKeepRunning);
 }
 
 - (NSString *)fileName {

Modified: trunk/SKSyncDot.h
===================================================================
--- trunk/SKSyncDot.h   2022-09-13 22:42:00 UTC (rev 13080)
+++ trunk/SKSyncDot.h   2022-09-21 14:19:38 UTC (rev 13081)
@@ -38,6 +38,7 @@
 
 #import <Cocoa/Cocoa.h>
 #import <Quartz/Quartz.h>
+#import <stdatomic.h>
 
 
 typedef void (^SKSyncDotUpdateBlock)(BOOL finished);
@@ -46,7 +47,7 @@
     NSPoint point;
     PDFPage *page;
     NSTimer *timer;
-    volatile int32_t phase;
+    _Atomic(NSInteger) phase;
     SKSyncDotUpdateBlock handler;
     BOOL shouldHideReadingBar;
 }

Modified: trunk/SKSyncDot.m
===================================================================
--- trunk/SKSyncDot.m   2022-09-13 22:42:00 UTC (rev 13080)
+++ trunk/SKSyncDot.m   2022-09-21 14:19:38 UTC (rev 13081)
@@ -39,7 +39,6 @@
 #import "SKSyncDot.h"
 #import "NSGeometry_SKExtensions.h"
 #import "NSShadow_SKExtensions.h"
-#import <libkern/OSAtomic.h>
 
 
 @interface SKSyncDot (SKPrivate)
@@ -80,7 +79,7 @@
 }
 
 - (void)animate:(NSTimer *)aTimer {
-    if (OSAtomicIncrement32Barrier(&phase) >= 10) {
+    if (atomic_fetch_add(&phase, 1) >= 9) {
         [timer invalidate];
         [timer release];
         timer = [[NSTimer scheduledTimerWithTimeInterval:5.0 target:self 
selector:@selector(finish:) userInfo:NULL repeats:NO] retain];
@@ -103,9 +102,9 @@
     
     CGColorRef color;
     CGFloat s = 6.0;
-    OSMemoryBarrier();
-    if (phase < 10) {
-        s += 8.0 * sin(phase * 0.1 * M_PI);
+    NSInteger aPhase = atomic_load(&phase);
+    if (aPhase < 10) {
+        s += 8.0 * sin(aPhase * 0.1 * M_PI);
         CGFloat components[8] = {1.0, 0.3, 0.3, 1.0, 1.0, 0.0, 0.0, 1.0};
         CGFloat locations[2] = {0.0, 1.0};
         CGColorSpaceRef colorspace = 
CGColorSpaceCreateWithName(kCGColorSpaceGenericRGB);

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.



_______________________________________________
Skim-app-commit mailing list
Skim-app-commit@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/skim-app-commit

Reply via email to