macOS does not support sem_init. use sem_open instead

This commit is contained in:
Ryo Nakamura
2023-03-15 23:18:33 +09:00
parent e038b3020d
commit f0c70a148b
3 changed files with 43 additions and 6 deletions

View File

@@ -1,4 +1,5 @@
#ifdef __APPLE__
#include <stdlib.h>
#include <sys/types.h>
#include <sys/sysctl.h>
#elif linux
@@ -32,6 +33,11 @@ int set_thread_affinity(pthread_t tid, int core)
return 0;
}
int get_random(int max)
{
return arc4random() % max;
}
#endif
#ifdef linux
@@ -56,5 +62,10 @@ int set_thread_affinity(pthread_t tid, int core)
core, strerrno());
return ret;
}
int get_random(int max)
{
return random() % max;
}
#endif