Skip to content

Commit

Permalink
Make feature test check for locking
Browse files Browse the repository at this point in the history
  • Loading branch information
lrstewart committed Jun 15, 2023
1 parent 255447e commit b113101
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions tests/features/S2N_ATOMIC_SUPPORTED.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,17 @@
*/

#include <signal.h>
#include <stddef.h>

int main() {
/* Atomic builtins are supported by gcc 4.7.3 and later. */
sig_atomic_t atomic = 0;
__atomic_test_and_set(&atomic, __ATOMIC_RELAXED);
__atomic_clear(&atomic, __ATOMIC_RELAXED);

/* _Static_assert is supported for C99 by gcc 4.6 and later,
* so using it here shouldn't limit use of the atomic builtins. */
_Static_assert(__atomic_always_lock_free(sizeof(sig_atomic_t), NULL),
"Atomic operations in this environment would require locking");
return 0;
}

0 comments on commit b113101

Please sign in to comment.