opnsense-src/lib/libc/tests/stdlib/Makefile
Dag-Erling Smørgrav b9c361e4af libc: Rewrite quick_exit() and at_quick_exit() using C11 atomics.
Compiler memory barriers do not prevent the CPU from executing the code
out of order.  Switch to C11 atomics.  This also lets us get rid of the
mutex; instead, loop until the compare_exchange succeeds.

While here, change the return value of at_quick_exit() on failure to
the more traditional -1, matching atexit().

Sponsored by:	Klara, Inc.
Reviewed by:	Olivier Certner, kevans, kib
Differential Revision:	https://reviews.freebsd.org/D41936

(cherry picked from commit 1dc3abb052430279e47c8922d22b30922adcf0f6)

libc: Add a rudimentary test for quick_exit(3).

Sponsored by:	Klara, Inc.
Reviewed by:	kib
Differential Revision:	https://reviews.freebsd.org/D41937

(cherry picked from commit c7dd4601aeebbc1bbe131cbe6747476c124b47fe)
2023-10-05 01:59:43 +02:00

83 lines
2.1 KiB
Makefile

.include <src.opts.mk>
ATF_TESTS_C+= clearenv_test
ATF_TESTS_C+= dynthr_test
ATF_TESTS_C+= heapsort_test
ATF_TESTS_C+= mergesort_test
ATF_TESTS_C+= qsort_test
.if ${COMPILER_TYPE} == "clang"
ATF_TESTS_C+= qsort_b_test
.endif
ATF_TESTS_C+= qsort_r_compat_test
ATF_TESTS_C+= qsort_r_test
ATF_TESTS_C+= qsort_s_test
ATF_TESTS_C+= quick_exit_test
ATF_TESTS_C+= set_constraint_handler_s_test
ATF_TESTS_C+= strfmon_test
ATF_TESTS_C+= tsearch_test
ATF_TESTS_CXX+= cxa_thread_atexit_test
ATF_TESTS_CXX+= cxa_thread_atexit_nothr_test
# All architectures on FreeBSD have fenv.h
CFLAGS+= -D__HAVE_FENV
# Define __HAVE_LONG_DOUBLE for architectures whose long double has greater
# precision than their double.
.if ${MACHINE_CPUARCH} == "aarch64" || \
${MACHINE_CPUARCH} == "amd64" || \
${MACHINE_CPUARCH} == "i386" || \
${MACHINE_CPUARCH} == "riscv"
CFLAGS+= -D__HAVE_LONG_DOUBLE
.endif
# TODO: t_getenv_thread, t_mi_vector_hash, t_strtoi
NETBSD_ATF_TESTS_C+= abs_test
NETBSD_ATF_TESTS_C+= atoi_test
NETBSD_ATF_TESTS_C+= div_test
NETBSD_ATF_TESTS_C+= getenv_test
NETBSD_ATF_TESTS_C+= exit_test
NETBSD_ATF_TESTS_C+= hsearch_test
NETBSD_ATF_TESTS_C+= posix_memalign_test
NETBSD_ATF_TESTS_C+= random_test
NETBSD_ATF_TESTS_C+= strtod_test
NETBSD_ATF_TESTS_C+= strtol_test
NETBSD_ATF_TESTS_C+= system_test
# TODO: need to come up with a correct explanation of what the patch pho does
# with h_atexit
#ATF_TESTS_SH= atexit_test
NETBSD_ATF_TESTS_SH= getopt_test
.include "../Makefile.netbsd-tests"
BINDIR= ${TESTSDIR}
# TODO: see comment above
#PROGS+= h_atexit
PROGS+= h_getopt h_getopt_long
CFLAGS+= -I${.CURDIR}
CXXSTD.cxa_thread_atexit_test= c++11
CXXSTD.cxa_thread_atexit_nothr_test= c++11
LIBADD.cxa_thread_atexit_test+= pthread
# Tests that requires Blocks feature
.for t in qsort_b_test
CFLAGS.${t}.c+= -fblocks
LIBADD.${t}+= BlocksRuntime
.endfor
.for t in h_getopt h_getopt_long
CFLAGS.$t+= -I${LIBNETBSD_SRCDIR} -I${SRCTOP}/contrib/netbsd-tests
LDFLAGS.$t+= -L${LIBNETBSD_OBJDIR}
LIBADD.${t}+= netbsd util
.endfor
LIBADD.strtod_test+= m
SUBDIR+= dynthr_mod
.include <bsd.test.mk>