atomic-test: unbreak on FreeBSD (cpuset_t)
authorGreg V <greg@unrelenting.technology>
Sun, 29 Nov 2020 18:31:27 +0000 (21:31 +0300)
committerPulseAudio Marge Bot <pulseaudio-maintainers@lists.freedesktop.org>
Mon, 18 Jan 2021 16:33:53 +0000 (16:33 +0000)
Part-of: <https://gitlab.freedesktop.org/pulseaudio/pulseaudio/-/merge_requests/277>

src/tests/atomic-test.c

index eb986e7..86b3d77 100644 (file)
@@ -47,6 +47,9 @@
 #include <pulse/xmalloc.h>
 #include <pulsecore/semaphore.h>
 #include <pthread.h>
+#ifdef __FreeBSD__
+#include <pthread_np.h>
+#endif
 #include <pulsecore/atomic.h>
 
 #define MEMORY_SIZE (8 * 2 * 1024 * 1024)
 typedef struct io_t {
    pa_atomic_t *flag;
    char* memory;
+#ifdef __FreeBSD__
+   cpuset_t cpuset;
+#else
    cpu_set_t cpuset;
+#endif
 } io_t;
 
 static void read_func(void* data) {
    io_t *io = (io_t *) data;
    size_t expect = 0;
    size_t value = 0;
-   pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &io->cpuset);
+   pthread_setaffinity_np(pthread_self(), sizeof(io->cpuset), &io->cpuset);
    while(1) {
       if(pa_atomic_load(io->flag) == 1) {
          memcpy(&value, io->memory, sizeof(value));
@@ -76,7 +83,7 @@ static void read_func(void* data) {
 static void write_func(void* data) {
    io_t *io = (io_t *) data;
    size_t value = 0;
-   pthread_setaffinity_np(pthread_self(), sizeof(cpu_set_t), &io->cpuset);
+   pthread_setaffinity_np(pthread_self(), sizeof(io->cpuset), &io->cpuset);
    while(1) {
       if(pa_atomic_load(io->flag) == 0) {
          memcpy(io->memory, &value, sizeof(value));