Skip to content

Commit

Permalink
Check for standard threads.
Browse files Browse the repository at this point in the history
Even GCC on macOS does not support standard threads.
  • Loading branch information
tfpf committed Apr 25, 2024
1 parent 971a6b7 commit a1f7e65
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions tests/tests.c
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,10 @@
#include <stdbool.h>
#include <stddef.h>
#include <stdio.h>

#ifndef __STDC_NO_THREADS__
#include <threads.h>
#endif

#define WORKERS_SIZE 8
#define CUSTOM_ITERATIONS (1L << 16)
Expand Down Expand Up @@ -71,14 +74,22 @@ main(void)
hdrbg_tests(hds[i], tv);
rewind(tv);
}
#ifndef __STDC_NO_THREADS__
thrd_t workers[WORKERS_SIZE];
#endif
for (int i = 0; i < WORKERS_SIZE; ++i)
{
#ifndef __STDC_NO_THREADS__
thrd_create(workers + i, hdrbg_tests_custom, hds[i]);
#else
hdrbg_tests_custom(hds[i]);
#endif
}
for (int i = 0; i < WORKERS_SIZE; ++i)
{
#ifndef __STDC_NO_THREADS__
thrd_join(workers[i], NULL);
#endif
hdrbg_zero(hds[i]);
}
printf("All tests passed.\n");
Expand Down

0 comments on commit a1f7e65

Please sign in to comment.