# HG changeset patch # User GP Orcullo # Date 1668075042 -28800 # Node ID 25195da82745d77d6863315ace5eafba93c3c7e1 # Parent fdd7f9938e59595f409180bb5c90eb3b13709503 replaced depreciated functions diff -r fdd7f9938e59 -r 25195da82745 targets/OSX/plc_OSX_main.c --- a/targets/OSX/plc_OSX_main.c Thu Nov 10 10:45:40 2022 +0800 +++ b/targets/OSX/plc_OSX_main.c Thu Nov 10 18:10:42 2022 +0800 @@ -12,7 +12,7 @@ #include #include -static sem_t Run_PLC; +static dispatch_semaphore_t Run_PLC; long AtomicCompareExchange(long *atomicvar, long compared, long exchange) { @@ -46,7 +46,7 @@ static inline void PLC_timer_notify(void *arg) { PLC_GetTime(&__CURRENT_TIME); - sem_post(&Run_PLC); + dispatch_semaphore_signal(Run_PLC); } void PLC_SetTimer(unsigned long long next, unsigned long long period) @@ -87,7 +87,7 @@ void PLC_thread_proc(void *arg) { while (!PLC_shutdown) { - sem_wait(&Run_PLC); + dispatch_semaphore_wait(Run_PLC, DISPATCH_TIME_FOREVER); __run(); } pthread_exit(0); @@ -100,7 +100,7 @@ PLC_shutdown = 0; - sem_init(&Run_PLC, 0, 0); + Run_PLC = dispatch_semaphore_create(0); pthread_create(&PLC_thread, NULL, (void *)&PLC_thread_proc, NULL); @@ -151,10 +151,11 @@ { /* Stop the PLC */ PLC_shutdown = 1; - sem_post(&Run_PLC); + dispatch_semaphore_signal(Run_PLC); PLC_SetTimer(0, 0); pthread_join(PLC_thread, NULL); - sem_destroy(&Run_PLC); + dispatch_release(Run_PLC); + Run_PLC = NULL; dispatch_source_cancel(PLC_timer); __cleanup(); pthread_mutex_destroy(&debug_wait_mutex);