[libc-commits] [libc] [llvm] [libc][freebsd] initialize freebsd support (PR #124459)
Schrodinger ZHU Yifan via libc-commits
libc-commits at lists.llvm.org
Wed May 13 19:12:19 PDT 2026
https://github.com/SchrodingerZhu updated https://github.com/llvm/llvm-project/pull/124459
>From 25cf9e1b7c8e8b874a6c80e320731625977c1012 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Wed, 13 May 2026 22:05:33 -0400
Subject: [PATCH 01/15] [libc] Fix tuple std injection in userspace builds
---
libc/src/__support/CPP/tuple.h | 9 +++++++++
1 file changed, 9 insertions(+)
diff --git a/libc/src/__support/CPP/tuple.h b/libc/src/__support/CPP/tuple.h
index fa4fcd08cc04f..f3cac1b4b5781 100644
--- a/libc/src/__support/CPP/tuple.h
+++ b/libc/src/__support/CPP/tuple.h
@@ -125,7 +125,12 @@ LIBC_INLINE constexpr auto tuple_cat(const Tuples &...tuples) {
} // namespace LIBC_NAMESPACE_DECL
// Standard namespace definitions required for structured binding support.
+
+#ifdef _LIBCPP_BEGIN_NAMESPACE_STD
+_LIBCPP_BEGIN_NAMESPACE_STD
+#else
namespace std {
+#endif
template <class T> struct tuple_size;
template <size_t Idx, class T> struct tuple_element;
@@ -139,6 +144,10 @@ struct tuple_element<Idx, LIBC_NAMESPACE::cpp::tuple<Ts...>>
: LIBC_NAMESPACE::cpp::tuple_element<Idx,
LIBC_NAMESPACE::cpp::tuple<Ts...>> {};
+#ifdef _LIBCPP_END_NAMESPACE_STD
+_LIBCPP_END_NAMESPACE_STD
+#else
} // namespace std
+#endif
#endif // LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_TUPLE_H
>From b2b6ab6910e563b6a023eaa6ab4ea56071106165 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Sun, 26 Jan 2025 20:22:58 +0800
Subject: [PATCH 02/15] [libc][freebsd] initialize freebsd support
---
.../cmake/modules/LLVMLibCArchitectures.cmake | 7 +
libc/config/freebsd/x86_64/entrypoints.txt | 656 ++++++++++++++++++
libc/config/freebsd/x86_64/headers.txt | 9 +
.../__support/OSUtil/freebsd/CMakeLists.txt | 18 +
libc/src/__support/OSUtil/freebsd/exit.cpp | 31 +
libc/src/__support/OSUtil/freebsd/io.h | 25 +
libc/src/__support/OSUtil/freebsd/syscall.h | 39 ++
.../freebsd/syscall_wrappers/CMakeLists.txt | 92 +++
.../OSUtil/freebsd/syscall_wrappers/close.h | 31 +
.../freebsd/syscall_wrappers/getrandom.h | 33 +
.../OSUtil/freebsd/syscall_wrappers/mmap.h | 34 +
.../freebsd/syscall_wrappers/mprotect.h | 32 +
.../OSUtil/freebsd/syscall_wrappers/munmap.h | 31 +
.../OSUtil/freebsd/syscall_wrappers/open.h | 32 +
.../OSUtil/freebsd/syscall_wrappers/read.h | 32 +
.../OSUtil/freebsd/syscall_wrappers/write.h | 32 +
.../OSUtil/freebsd/x86_64/CMakeLists.txt | 7 +
.../__support/OSUtil/freebsd/x86_64/syscall.h | 120 ++++
libc/src/__support/OSUtil/io.h | 2 +
libc/src/__support/OSUtil/syscall.h | 2 +
libc/test/UnitTest/FPExceptMatcher.cpp | 4 +
21 files changed, 1269 insertions(+)
create mode 100644 libc/config/freebsd/x86_64/entrypoints.txt
create mode 100644 libc/config/freebsd/x86_64/headers.txt
create mode 100644 libc/src/__support/OSUtil/freebsd/CMakeLists.txt
create mode 100644 libc/src/__support/OSUtil/freebsd/exit.cpp
create mode 100644 libc/src/__support/OSUtil/freebsd/io.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/CMakeLists.txt
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
create mode 100644 libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
create mode 100644 libc/src/__support/OSUtil/freebsd/x86_64/CMakeLists.txt
create mode 100644 libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
diff --git a/libc/cmake/modules/LLVMLibCArchitectures.cmake b/libc/cmake/modules/LLVMLibCArchitectures.cmake
index 095531c0f6bec..4c2e63868e83d 100644
--- a/libc/cmake/modules/LLVMLibCArchitectures.cmake
+++ b/libc/cmake/modules/LLVMLibCArchitectures.cmake
@@ -59,11 +59,15 @@ function(get_arch_and_system_from_triple triple arch_var sys_var)
set(${arch_var} ${target_arch} PARENT_SCOPE)
list(GET triple_comps ${system_index} target_sys)
+ list(GET triple_comps 2 target_os)
# Correcting OS name for Apple's systems.
if(target_sys STREQUAL "apple")
list(GET triple_comps 2 target_sys)
endif()
+ if(target_os MATCHES "^freebsd")
+ set(target_sys ${target_os})
+ endif()
# Strip version from `darwin###`
if(target_sys MATCHES "^darwin")
set(target_sys "darwin")
@@ -209,6 +213,9 @@ elseif(LIBC_TARGET_OS STREQUAL "darwin")
set(LIBC_TARGET_OS_IS_DARWIN TRUE)
elseif(LIBC_TARGET_OS STREQUAL "windows")
set(LIBC_TARGET_OS_IS_WINDOWS TRUE)
+elseif(LIBC_TARGET_OS MATCHES "^freebsd.*")
+ set(LIBC_TARGET_OS_IS_FREEBSD TRUE)
+ set(LIBC_TARGET_OS "freebsd")
elseif(LIBC_TARGET_OS STREQUAL "gpu")
set(LIBC_TARGET_OS_IS_GPU TRUE)
elseif(LIBC_TARGET_OS STREQUAL "uefi")
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
new file mode 100644
index 0000000000000..31d421555624d
--- /dev/null
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -0,0 +1,656 @@
+set(TARGET_LIBC_ENTRYPOINTS
+ # ctype.h entrypoints
+ libc.src.ctype.isalnum
+ libc.src.ctype.isalpha
+ libc.src.ctype.isascii
+ libc.src.ctype.isblank
+ libc.src.ctype.iscntrl
+ libc.src.ctype.isdigit
+ libc.src.ctype.isgraph
+ libc.src.ctype.islower
+ libc.src.ctype.isprint
+ libc.src.ctype.ispunct
+ libc.src.ctype.isspace
+ libc.src.ctype.isupper
+ libc.src.ctype.isxdigit
+ libc.src.ctype.toascii
+ libc.src.ctype.tolower
+ libc.src.ctype.toupper
+
+ # string.h entrypoints
+ libc.src.string.memccpy
+ libc.src.string.memchr
+ libc.src.string.memcmp
+ libc.src.string.memcpy
+ libc.src.string.memmem
+ libc.src.string.memmove
+ libc.src.string.mempcpy
+ libc.src.string.memrchr
+ libc.src.string.memset
+ libc.src.string.stpcpy
+ libc.src.string.stpncpy
+ libc.src.string.strcasestr
+ libc.src.string.strcat
+ libc.src.string.strchr
+ libc.src.string.strchrnul
+ libc.src.string.strcmp
+ libc.src.string.strcpy
+ libc.src.string.strcspn
+ libc.src.string.strlcat
+ libc.src.string.strlcpy
+ libc.src.string.strlen
+ libc.src.string.strncat
+ libc.src.string.strncmp
+ libc.src.string.strncpy
+ libc.src.string.strnlen
+ libc.src.string.strpbrk
+ libc.src.string.strrchr
+ libc.src.string.strspn
+ libc.src.string.strstr
+ libc.src.string.strtok
+ libc.src.string.strtok_r
+
+ # string.h entrypoints that depend on malloc
+ libc.src.string.strdup
+ libc.src.string.strndup
+
+ # strings.h entrypoints
+ libc.src.strings.bcmp
+ libc.src.strings.bcopy
+ libc.src.strings.bzero
+ libc.src.strings.strcasecmp
+ libc.src.strings.strncasecmp
+
+ # inttypes.h entrypoints
+ libc.src.inttypes.imaxabs
+ libc.src.inttypes.imaxdiv
+ libc.src.inttypes.strtoimax
+ libc.src.inttypes.strtoumax
+
+ # stdlib.h entrypoints
+ libc.src.stdlib.abs
+ libc.src.stdlib.atoi
+ libc.src.stdlib.atof
+ libc.src.stdlib.atol
+ libc.src.stdlib.atoll
+ libc.src.stdlib.bsearch
+ libc.src.stdlib.div
+ libc.src.stdlib.labs
+ libc.src.stdlib.ldiv
+ libc.src.stdlib.llabs
+ libc.src.stdlib.lldiv
+ libc.src.stdlib.qsort
+ libc.src.stdlib.strtod
+ libc.src.stdlib.strtof
+ libc.src.stdlib.strtol
+ libc.src.stdlib.strtold
+ libc.src.stdlib.strtoll
+ libc.src.stdlib.strtoul
+ libc.src.stdlib.strtoull
+
+ # stdlib.h external entrypoints
+ libc.src.stdlib.malloc
+ libc.src.stdlib.calloc
+ libc.src.stdlib.realloc
+ libc.src.stdlib.aligned_alloc
+ libc.src.stdlib.free
+
+ # errno.h entrypoints
+ libc.src.errno.errno
+)
+
+set(TARGET_LIBM_ENTRYPOINTS
+ # fenv.h entrypoints
+ libc.src.fenv.feclearexcept
+ libc.src.fenv.fedisableexcept
+ libc.src.fenv.feenableexcept
+ libc.src.fenv.fegetenv
+ libc.src.fenv.fegetexcept
+ libc.src.fenv.fegetexceptflag
+ libc.src.fenv.fegetround
+ libc.src.fenv.feholdexcept
+ libc.src.fenv.fesetenv
+ libc.src.fenv.fesetexcept
+ libc.src.fenv.fesetexceptflag
+ libc.src.fenv.fesetround
+ libc.src.fenv.feraiseexcept
+ libc.src.fenv.fetestexcept
+ libc.src.fenv.fetestexceptflag
+ libc.src.fenv.feupdateenv
+
+ # math.h entrypoints
+ libc.src.math.acosf
+ libc.src.math.acoshf
+ libc.src.math.asinf
+ libc.src.math.asinhf
+ libc.src.math.atan2
+ libc.src.math.atan2f
+ libc.src.math.atanf
+ libc.src.math.atanhf
+ libc.src.math.cbrt
+ libc.src.math.cbrtf
+ libc.src.math.copysign
+ libc.src.math.copysignf
+ libc.src.math.copysignl
+ libc.src.math.ceil
+ libc.src.math.ceilf
+ libc.src.math.ceill
+ libc.src.math.cos
+ libc.src.math.cosf
+ libc.src.math.coshf
+ libc.src.math.daddl
+ libc.src.math.ddivl
+ libc.src.math.dfmal
+ libc.src.math.dsubl
+ libc.src.math.erff
+ libc.src.math.exp
+ libc.src.math.expf
+ libc.src.math.exp10
+ libc.src.math.exp10f
+ libc.src.math.exp2
+ libc.src.math.exp2f
+ libc.src.math.expm1
+ libc.src.math.expm1f
+ libc.src.math.fabs
+ libc.src.math.fabsf
+ libc.src.math.fabsl
+ libc.src.math.fadd
+ libc.src.math.faddl
+ libc.src.math.fdim
+ libc.src.math.fdimf
+ libc.src.math.fdiml
+ libc.src.math.fdiv
+ libc.src.math.fdivl
+ libc.src.math.ffma
+ libc.src.math.ffmal
+ libc.src.math.floor
+ libc.src.math.floorf
+ libc.src.math.floorl
+ libc.src.math.fma
+ libc.src.math.fmaf
+ libc.src.math.fmin
+ libc.src.math.fminf
+ libc.src.math.fminl
+ libc.src.math.fmax
+ libc.src.math.fmaxf
+ libc.src.math.fmaxl
+ libc.src.math.fmaximum
+ libc.src.math.fmaximumf
+ libc.src.math.fmaximuml
+ libc.src.math.fmaximum_num
+ libc.src.math.fmaximum_numf
+ libc.src.math.fmaximum_numl
+ libc.src.math.fmaximum_mag
+ libc.src.math.fmaximum_magf
+ libc.src.math.fmaximum_magl
+ libc.src.math.fmaximum_mag_num
+ libc.src.math.fmaximum_mag_numf
+ libc.src.math.fmaximum_mag_numl
+ libc.src.math.fminimum
+ libc.src.math.fminimumf
+ libc.src.math.fminimuml
+ libc.src.math.fminimum_num
+ libc.src.math.fminimum_numf
+ libc.src.math.fminimum_numl
+ libc.src.math.fminimum_mag
+ libc.src.math.fminimum_magf
+ libc.src.math.fminimum_magl
+ libc.src.math.fminimum_mag_num
+ libc.src.math.fminimum_mag_numf
+ libc.src.math.fminimum_mag_numl
+ libc.src.math.fmul
+ libc.src.math.fmod
+ libc.src.math.fmodf
+ libc.src.math.fmodl
+ libc.src.math.frexp
+ libc.src.math.frexpf
+ libc.src.math.frexpl
+ libc.src.math.fsub
+ libc.src.math.fsubl
+ libc.src.math.hypot
+ libc.src.math.hypotf
+ libc.src.math.ilogb
+ libc.src.math.ilogbf
+ libc.src.math.ilogbl
+ libc.src.math.ldexp
+ libc.src.math.ldexpf
+ libc.src.math.ldexpl
+ libc.src.math.llrint
+ libc.src.math.llrintf
+ libc.src.math.llrintl
+ libc.src.math.llround
+ libc.src.math.llroundf
+ libc.src.math.llroundl
+ libc.src.math.log10
+ libc.src.math.log10f
+ libc.src.math.log1p
+ libc.src.math.log1pf
+ libc.src.math.log2
+ libc.src.math.log2f
+ libc.src.math.log
+ libc.src.math.logf
+ libc.src.math.logb
+ libc.src.math.logbf
+ libc.src.math.logbl
+ libc.src.math.lrint
+ libc.src.math.lrintf
+ libc.src.math.lrintl
+ libc.src.math.lround
+ libc.src.math.lroundf
+ libc.src.math.lroundl
+ libc.src.math.modf
+ libc.src.math.modff
+ libc.src.math.modfl
+ libc.src.math.nan
+ libc.src.math.nanf
+ libc.src.math.nanl
+ libc.src.math.nearbyint
+ libc.src.math.nearbyintf
+ libc.src.math.nearbyintl
+ libc.src.math.nextafter
+ libc.src.math.nextafterf
+ libc.src.math.nextafterl
+ libc.src.math.nexttoward
+ libc.src.math.nexttowardf
+ libc.src.math.nexttowardl
+ libc.src.math.pow
+ libc.src.math.powf
+ libc.src.math.remainderf
+ libc.src.math.remainder
+ libc.src.math.remainderl
+ libc.src.math.remquof
+ libc.src.math.remquo
+ libc.src.math.remquol
+ libc.src.math.rint
+ libc.src.math.rintf
+ libc.src.math.rintl
+ libc.src.math.round
+ libc.src.math.roundf
+ libc.src.math.roundl
+ libc.src.math.scalbln
+ libc.src.math.scalblnf
+ libc.src.math.scalblnl
+ libc.src.math.scalbn
+ libc.src.math.scalbnf
+ libc.src.math.scalbnl
+ libc.src.math.sin
+ libc.src.math.sincosf
+ libc.src.math.sincosf
+ libc.src.math.sinf
+ libc.src.math.sinhf
+ libc.src.math.sqrt
+ libc.src.math.sqrtf
+ libc.src.math.sqrtl
+ libc.src.math.tan
+ libc.src.math.tanf
+ libc.src.math.tanhf
+ libc.src.math.trunc
+ libc.src.math.truncf
+ libc.src.math.truncl
+)
+
+list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.acos
+ libc.src.math.acospif
+ libc.src.math.asin
+ libc.src.math.asinpi
+ libc.src.math.asinpif
+ libc.src.math.atan
+ libc.src.math.canonicalize
+ libc.src.math.canonicalizef
+ libc.src.math.canonicalizel
+ libc.src.math.cbrtbf16
+ libc.src.math.cospif
+ libc.src.math.dmull
+ libc.src.math.dsqrtl
+ libc.src.math.exp10m1f
+ libc.src.math.exp2m1f
+ libc.src.math.fmabf16
+ libc.src.math.fmull
+ libc.src.math.fromfp
+ libc.src.math.fromfpf
+ libc.src.math.fromfpl
+ libc.src.math.fromfpx
+ libc.src.math.fromfpxf
+ libc.src.math.fromfpxl
+ libc.src.math.fsqrt
+ libc.src.math.fsqrtl
+ libc.src.math.getpayload
+ libc.src.math.getpayloadf
+ libc.src.math.getpayloadl
+ libc.src.math.iscanonical
+ libc.src.math.iscanonicalf
+ libc.src.math.iscanonicall
+ libc.src.math.isnan
+ libc.src.math.isnanf
+ libc.src.math.isnanl
+ libc.src.math.issignaling
+ libc.src.math.issignalingf
+ libc.src.math.issignalingl
+ libc.src.math.llogb
+ libc.src.math.llogbf
+ libc.src.math.llogbl
+ libc.src.math.nextdown
+ libc.src.math.nextdownf
+ libc.src.math.nextdownl
+ libc.src.math.nextup
+ libc.src.math.nextupf
+ libc.src.math.nextupl
+ libc.src.math.roundeven
+ libc.src.math.roundevenf
+ libc.src.math.roundevenl
+ libc.src.math.setpayload
+ libc.src.math.setpayloadf
+ libc.src.math.setpayloadl
+ libc.src.math.setpayloadsig
+ libc.src.math.setpayloadsigf
+ libc.src.math.setpayloadsigl
+ libc.src.math.sincos
+ libc.src.math.sinpif
+ libc.src.math.tanpif
+ libc.src.math.totalorder
+ libc.src.math.totalorderf
+ libc.src.math.totalorderl
+ libc.src.math.totalordermag
+ libc.src.math.totalordermagf
+ libc.src.math.totalordermagl
+ libc.src.math.ufromfp
+ libc.src.math.ufromfpf
+ libc.src.math.ufromfpl
+ libc.src.math.ufromfpx
+ libc.src.math.ufromfpxf
+ libc.src.math.ufromfpxl
+)
+
+if(LIBC_TYPES_HAS_FLOAT16)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.acosf16
+ libc.src.math.acoshf16
+ libc.src.math.acospif16
+ libc.src.math.asinf16
+ libc.src.math.asinhf16
+ libc.src.math.asinpif16
+ libc.src.math.atanf16
+ libc.src.math.atan2f16
+ libc.src.math.atanhf16
+ libc.src.math.atanpif16
+ libc.src.math.canonicalizef16
+ libc.src.math.ceilf16
+ libc.src.math.copysignf16
+ libc.src.math.cosf16
+ libc.src.math.coshf16
+ libc.src.math.cospif16
+ libc.src.math.erff16
+ libc.src.math.erfcf16
+ libc.src.math.exp10f16
+ libc.src.math.exp10m1f16
+ libc.src.math.exp2f16
+ libc.src.math.exp2m1f16
+ libc.src.math.expf16
+ libc.src.math.expm1f16
+ libc.src.math.f16add
+ libc.src.math.f16addf
+ libc.src.math.f16addl
+ libc.src.math.f16div
+ libc.src.math.f16divf
+ libc.src.math.f16divl
+ libc.src.math.f16fma
+ libc.src.math.f16fmaf
+ libc.src.math.f16fmal
+ libc.src.math.f16mul
+ libc.src.math.f16mulf
+ libc.src.math.f16mull
+ libc.src.math.f16sqrt
+ libc.src.math.f16sqrtf
+ libc.src.math.f16sqrtl
+ libc.src.math.f16sub
+ libc.src.math.f16subf
+ libc.src.math.f16subl
+ libc.src.math.fabsf16
+ libc.src.math.fdimf16
+ libc.src.math.floorf16
+ libc.src.math.fmaf16
+ libc.src.math.fmaxf16
+ libc.src.math.fmaximum_mag_numf16
+ libc.src.math.fmaximum_magf16
+ libc.src.math.fmaximum_numf16
+ libc.src.math.fmaximumf16
+ libc.src.math.fminf16
+ libc.src.math.fminimum_mag_numf16
+ libc.src.math.fminimum_magf16
+ libc.src.math.fminimum_numf16
+ libc.src.math.fminimumf16
+ libc.src.math.fmodf16
+ libc.src.math.frexpf16
+ libc.src.math.fromfpf16
+ libc.src.math.fromfpxf16
+ libc.src.math.getpayloadf16
+ libc.src.math.hypotf16
+ libc.src.math.ilogbf16
+ libc.src.math.iscanonicalf16
+ libc.src.math.issignalingf16
+ libc.src.math.ldexpf16
+ libc.src.math.llogbf16
+ libc.src.math.llrintf16
+ libc.src.math.llroundf16
+ libc.src.math.log10f16
+ libc.src.math.log10p1f16
+ libc.src.math.log2f16
+ libc.src.math.log2p1f16
+ libc.src.math.logbf16
+ libc.src.math.logf16
+ libc.src.math.lrintf16
+ libc.src.math.lroundf16
+ libc.src.math.modff16
+ libc.src.math.nanf16
+ libc.src.math.nearbyintf16
+ libc.src.math.nextafterf16
+ libc.src.math.nextdownf16
+ libc.src.math.nexttowardf16
+ libc.src.math.nextupf16
+ libc.src.math.remainderf16
+ libc.src.math.remquof16
+ libc.src.math.rintf16
+ libc.src.math.roundevenf16
+ libc.src.math.roundf16
+ libc.src.math.rsqrtf
+ libc.src.math.rsqrtf16
+ libc.src.math.scalblnf16
+ libc.src.math.scalbnf16
+ libc.src.math.setpayloadf16
+ libc.src.math.setpayloadsigf16
+ libc.src.math.sinf16
+ libc.src.math.sinhf16
+ libc.src.math.sinpif16
+ libc.src.math.sqrtf16
+ libc.src.math.tanf16
+ libc.src.math.tanhf16
+ libc.src.math.tanpif16
+ libc.src.math.totalorderf16
+ libc.src.math.totalordermagf16
+ libc.src.math.truncf16
+ libc.src.math.ufromfpf16
+ libc.src.math.ufromfpxf16
+ )
+
+ if(LIBC_TYPES_HAS_FLOAT128)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.f16addf128
+ libc.src.math.f16divf128
+ libc.src.math.f16fmaf128
+ libc.src.math.f16mulf128
+ libc.src.math.f16sqrtf128
+ libc.src.math.f16subf128
+ )
+ endif()
+endif()
+
+if(LIBC_TYPES_HAS_FLOAT128)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.atan2f128
+ libc.src.math.atan2l
+ libc.src.math.canonicalizef128
+ libc.src.math.ceilf128
+ libc.src.math.copysignf128
+ libc.src.math.daddf128
+ libc.src.math.ddivf128
+ libc.src.math.dfmaf128
+ libc.src.math.dmulf128
+ libc.src.math.dsqrtf128
+ libc.src.math.dsubf128
+ libc.src.math.fabsf128
+ libc.src.math.faddf128
+ libc.src.math.fdimf128
+ libc.src.math.fdivf128
+ libc.src.math.ffmaf128
+ libc.src.math.floorf128
+ libc.src.math.fmaxf128
+ libc.src.math.fmaximum_mag_numf128
+ libc.src.math.fmaximum_magf128
+ libc.src.math.fmaximum_numf128
+ libc.src.math.fmaximumf128
+ libc.src.math.fminf128
+ libc.src.math.fminimum_mag_numf128
+ libc.src.math.fminimum_magf128
+ libc.src.math.fminimum_numf128
+ libc.src.math.fminimumf128
+ libc.src.math.fmodf128
+ libc.src.math.fmulf128
+ libc.src.math.frexpf128
+ libc.src.math.fromfpf128
+ libc.src.math.fromfpxf128
+ libc.src.math.fsqrtf128
+ libc.src.math.fsubf128
+ libc.src.math.getpayloadf128
+ libc.src.math.ilogbf128
+ libc.src.math.iscanonicalf128
+ libc.src.math.issignalingf128
+ libc.src.math.ldexpf128
+ libc.src.math.llogbf128
+ libc.src.math.llrintf128
+ libc.src.math.llroundf128
+ libc.src.math.logbf128
+ libc.src.math.lrintf128
+ libc.src.math.lroundf128
+ libc.src.math.modff128
+ libc.src.math.nanf128
+ libc.src.math.nearbyintf128
+ libc.src.math.nextafterf128
+ libc.src.math.nextdownf128
+ libc.src.math.nextupf128
+ libc.src.math.remainderf128
+ libc.src.math.remquof128
+ libc.src.math.rintf128
+ libc.src.math.roundevenf128
+ libc.src.math.roundf128
+ libc.src.math.scalblnf128
+ libc.src.math.scalbnf128
+ libc.src.math.setpayloadf128
+ libc.src.math.setpayloadsigf128
+ libc.src.math.sqrtf128
+ libc.src.math.totalorderf128
+ libc.src.math.totalordermagf128
+ libc.src.math.truncf128
+ libc.src.math.ufromfpf128
+ libc.src.math.ufromfpxf128
+ )
+endif()
+
+list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.atanbf16
+ libc.src.math.asinbf16
+ libc.src.math.bf16add
+ libc.src.math.bf16addf
+ libc.src.math.bf16addl
+ libc.src.math.bf16div
+ libc.src.math.bf16divf
+ libc.src.math.bf16divl
+ libc.src.math.bf16fma
+ libc.src.math.bf16fmaf
+ libc.src.math.bf16fmal
+ libc.src.math.bf16mul
+ libc.src.math.bf16mulf
+ libc.src.math.bf16mull
+ libc.src.math.bf16sub
+ libc.src.math.bf16subf
+ libc.src.math.bf16subl
+ libc.src.math.canonicalizebf16
+ libc.src.math.ceilbf16
+ libc.src.math.copysignbf16
+ libc.src.math.fabsbf16
+ libc.src.math.fdimbf16
+ libc.src.math.floorbf16
+ libc.src.math.fmaxbf16
+ libc.src.math.fmaximumbf16
+ libc.src.math.fmaximum_magbf16
+ libc.src.math.fmaximum_mag_numbf16
+ libc.src.math.fmaximum_numbf16
+ libc.src.math.fminbf16
+ libc.src.math.fminimumbf16
+ libc.src.math.fminimum_magbf16
+ libc.src.math.fminimum_mag_numbf16
+ libc.src.math.fminimum_numbf16
+ libc.src.math.fmodbf16
+ libc.src.math.frexpbf16
+ libc.src.math.fromfpbf16
+ libc.src.math.fromfpxbf16
+ libc.src.math.getpayloadbf16
+ libc.src.math.hypotbf16
+ libc.src.math.ilogbbf16
+ libc.src.math.iscanonicalbf16
+ libc.src.math.issignalingbf16
+ libc.src.math.ldexpbf16
+ libc.src.math.llogbbf16
+ libc.src.math.llrintbf16
+ libc.src.math.llroundbf16
+ libc.src.math.log_bf16
+ libc.src.math.logbbf16
+ libc.src.math.lrintbf16
+ libc.src.math.lroundbf16
+ libc.src.math.modfbf16
+ libc.src.math.nanbf16
+ libc.src.math.nearbyintbf16
+ libc.src.math.nextafterbf16
+ libc.src.math.nextdownbf16
+ libc.src.math.nexttowardbf16
+ libc.src.math.nextupbf16
+ libc.src.math.remainderbf16
+ libc.src.math.remquobf16
+ libc.src.math.rintbf16
+ libc.src.math.roundbf16
+ libc.src.math.roundevenbf16
+ libc.src.math.scalblnbf16
+ libc.src.math.scalbnbf16
+ libc.src.math.setpayloadbf16
+ libc.src.math.setpayloadsigbf16
+ libc.src.math.sqrtbf16
+ libc.src.math.truncbf16
+ libc.src.math.totalorderbf16
+ libc.src.math.totalordermagbf16
+ libc.src.math.ufromfpbf16
+ libc.src.math.ufromfpxbf16
+)
+
+if(LIBC_TYPES_HAS_FLOAT128)
+ list(APPEND TARGET_LIBM_ENTRYPOINTS
+ libc.src.math.bf16addf128
+ libc.src.math.bf16divf128
+ libc.src.math.bf16fmaf128
+ libc.src.math.bf16mulf128
+ libc.src.math.bf16subf128
+ )
+endif()
+
+set(TARGET_LIBMVEC_ENTRYPOINTS)
+
+if(LIBC_COMPILER_HAS_EXT_VECTOR_TYPE)
+ list(APPEND TARGET_LIBMVEC_ENTRYPOINTS
+ libc.src.mathvec.expf
+ )
+endif()
+
+set(TARGET_LLVMLIBC_ENTRYPOINTS
+ ${TARGET_LIBC_ENTRYPOINTS}
+ ${TARGET_LIBM_ENTRYPOINTS}
+ ${TARGET_LIBMVEC_ENTRYPOINTS}
+)
diff --git a/libc/config/freebsd/x86_64/headers.txt b/libc/config/freebsd/x86_64/headers.txt
new file mode 100644
index 0000000000000..bccc04f7697e5
--- /dev/null
+++ b/libc/config/freebsd/x86_64/headers.txt
@@ -0,0 +1,9 @@
+set(TARGET_PUBLIC_HEADERS
+ libc.include.ctype
+ libc.include.string
+ libc.include.inttypes
+ libc.include.stdlib
+ libc.include.errno
+ libc.include.fenv
+ libc.include.math
+)
diff --git a/libc/src/__support/OSUtil/freebsd/CMakeLists.txt b/libc/src/__support/OSUtil/freebsd/CMakeLists.txt
new file mode 100644
index 0000000000000..a635feb37b120
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/CMakeLists.txt
@@ -0,0 +1,18 @@
+if(NOT EXISTS ${CMAKE_CURRENT_SOURCE_DIR}/${LIBC_TARGET_ARCHITECTURE})
+ return()
+endif()
+
+add_subdirectory(${LIBC_TARGET_ARCHITECTURE})
+add_subdirectory(syscall_wrappers)
+
+add_object_library(
+ freebsd_util
+ SRCS
+ exit.cpp
+ HDRS
+ io.h
+ DEPENDS
+ .${LIBC_TARGET_ARCHITECTURE}.freebsd_${LIBC_TARGET_ARCHITECTURE}_util
+ libc.src.__support.OSUtil.freebsd.syscall_wrappers.write
+ libc.src.__support.macros.config
+)
diff --git a/libc/src/__support/OSUtil/freebsd/exit.cpp b/libc/src/__support/OSUtil/freebsd/exit.cpp
new file mode 100644
index 0000000000000..fd2ec67c3cf5b
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/exit.cpp
@@ -0,0 +1,31 @@
+//===--------- Freebsd implementation of an exit function -------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace internal {
+
+// mark as no_stack_protector for x86 since TLS can be torn down before calling
+// exit so that the stack protector canary cannot be loaded.
+#ifdef LIBC_TARGET_ARCH_IS_X86
+__attribute__((no_stack_protector))
+#endif
+__attribute__((noreturn)) void
+exit(int status) {
+ for (;;) {
+ LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
+ }
+}
+
+} // namespace internal
+} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/OSUtil/freebsd/io.h b/libc/src/__support/OSUtil/freebsd/io.h
new file mode 100644
index 0000000000000..348d39adb621c
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/io.h
@@ -0,0 +1,25 @@
+//===-------------- FreeBSD implementation of IO utils ----------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_IO_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_IO_H
+
+#include "src/__support/CPP/string_view.h"
+#include "src/__support/OSUtil/freebsd/syscall_wrappers/write.h"
+#include "src/__support/macros/config.h"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
+ LIBC_NAMESPACE::freebsd_syscalls::write(2 /* stderr */, msg.data(),
+ msg.size());
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_IO_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall.h b/libc/src/__support/OSUtil/freebsd/syscall.h
new file mode 100644
index 0000000000000..daaa437131c45
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall.h
@@ -0,0 +1,39 @@
+//===----------------------- FreeBSD syscalls -------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
+
+#include "src/__support/CPP/bit.h"
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+#include "src/__support/macros/properties/architectures.h"
+
+#ifdef LIBC_TARGET_ARCH_IS_X86_32
+#include "i386/syscall.h"
+#elif defined(LIBC_TARGET_ARCH_IS_X86_64)
+#include "x86_64/syscall.h"
+#elif defined(LIBC_TARGET_ARCH_IS_AARCH64)
+#include "aarch64/syscall.h"
+#elif defined(LIBC_TARGET_ARCH_IS_ARM)
+#include "arm/syscall.h"
+#elif defined(LIBC_TARGET_ARCH_IS_ANY_RISCV)
+#include "riscv/syscall.h"
+#endif
+
+namespace LIBC_NAMESPACE_DECL {
+
+template <typename R, typename... Ts>
+LIBC_INLINE R syscall_impl(long __number, Ts... ts) {
+ static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall");
+ return cpp::bit_or_static_cast<R>(syscall_impl(__number, (long)ts...));
+}
+
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/CMakeLists.txt b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/CMakeLists.txt
new file mode 100644
index 0000000000000..f11863635c6c2
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/CMakeLists.txt
@@ -0,0 +1,92 @@
+add_header_library(
+ close
+ HDRS
+ close.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ getrandom
+ HDRS
+ getrandom.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.hdr.types.ssize_t
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ mmap
+ HDRS
+ mmap.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.hdr.types.off_t
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ mprotect
+ HDRS
+ mprotect.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ munmap
+ HDRS
+ munmap.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ open
+ HDRS
+ open.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.hdr.types.mode_t
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ read
+ HDRS
+ read.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.hdr.types.ssize_t
+ libc.include.sys_syscall
+)
+
+add_header_library(
+ write
+ HDRS
+ write.h
+ DEPENDS
+ libc.src.__support.common
+ libc.src.__support.error_or
+ libc.src.__support.macros.config
+ libc.hdr.types.ssize_t
+ libc.include.sys_syscall
+)
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
new file mode 100644
index 0000000000000..e863d4890bb74
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
@@ -0,0 +1,31 @@
+//===-- Implementation header for close -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_CLOSE_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_CLOSE_H
+
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<int> close(int fd) {
+ int ret = syscall_impl<int>(SYS_close, fd);
+ if (ret < 0)
+ return Error(-ret);
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_CLOSE_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
new file mode 100644
index 0000000000000..9c264b47efc97
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
@@ -0,0 +1,33 @@
+//===-- Implementation header for getrandom ---------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_GETRANDOM_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_GETRANDOM_H
+
+#include "hdr/types/ssize_t.h"
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<ssize_t> getrandom(void *buf, size_t buflen,
+ unsigned int flags) {
+ ssize_t ret = syscall_impl<ssize_t>(SYS_getrandom, buf, buflen, flags);
+ if (ret < 0)
+ return Error(-static_cast<int>(ret));
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_GETRANDOM_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
new file mode 100644
index 0000000000000..b299463a34825
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
@@ -0,0 +1,34 @@
+//===-- Syscall wrapper for mmap --------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MMAP_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MMAP_H
+
+#include "hdr/types/off_t.h"
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<void *> mmap(void *addr, size_t size, int prot, int flags,
+ int fd, off_t offset) {
+ long ret = syscall_impl<long>(SYS_mmap, reinterpret_cast<long>(addr), size,
+ prot, flags, fd, static_cast<long>(offset));
+ if (ret < 0)
+ return Error(-static_cast<int>(ret));
+ return reinterpret_cast<void *>(ret);
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MMAP_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
new file mode 100644
index 0000000000000..4eca3e6973b00
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
@@ -0,0 +1,32 @@
+//===-- Syscall wrapper for mprotect ----------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
+
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<int> mprotect(void *addr, size_t size, int prot) {
+ int ret =
+ syscall_impl<int>(SYS_mprotect, reinterpret_cast<long>(addr), size, prot);
+ if (ret < 0)
+ return Error(-ret);
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
new file mode 100644
index 0000000000000..54722cab54926
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
@@ -0,0 +1,31 @@
+//===-- Syscall wrapper for munmap ------------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
+
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<int> munmap(void *addr, size_t size) {
+ int ret = syscall_impl<int>(SYS_munmap, reinterpret_cast<long>(addr), size);
+ if (ret < 0)
+ return Error(-ret);
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
new file mode 100644
index 0000000000000..7b74cf983e871
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for open --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_OPEN_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_OPEN_H
+
+#include "hdr/types/mode_t.h"
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<int> open(const char *path, int flags, mode_t mode_flags) {
+ int fd = syscall_impl<int>(SYS_open, path, flags, mode_flags);
+ if (fd < 0)
+ return Error(-fd);
+ return fd;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_OPEN_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
new file mode 100644
index 0000000000000..6c9ca71f5935b
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for read --------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_READ_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_READ_H
+
+#include "hdr/types/ssize_t.h"
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<ssize_t> read(int fd, void *buf, size_t count) {
+ ssize_t ret = syscall_impl<ssize_t>(SYS_read, fd, buf, count);
+ if (ret < 0)
+ return Error(-static_cast<int>(ret));
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_READ_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
new file mode 100644
index 0000000000000..affd881fc0ccf
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
@@ -0,0 +1,32 @@
+//===-- Implementation header for write -------------------------*- C++ -*-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_WRITE_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_WRITE_H
+
+#include "hdr/types/ssize_t.h"
+#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
+#include "src/__support/common.h"
+#include "src/__support/error_or.h"
+#include "src/__support/macros/config.h"
+#include <sys/syscall.h> // For syscall numbers.
+
+namespace LIBC_NAMESPACE_DECL {
+namespace freebsd_syscalls {
+
+LIBC_INLINE ErrorOr<ssize_t> write(int fd, const void *buf, size_t count) {
+ ssize_t ret = syscall_impl<ssize_t>(SYS_write, fd, buf, count);
+ if (ret < 0)
+ return Error(-static_cast<int>(ret));
+ return ret;
+}
+
+} // namespace freebsd_syscalls
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_WRITE_H
diff --git a/libc/src/__support/OSUtil/freebsd/x86_64/CMakeLists.txt b/libc/src/__support/OSUtil/freebsd/x86_64/CMakeLists.txt
new file mode 100644
index 0000000000000..9a853b74e72d1
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/x86_64/CMakeLists.txt
@@ -0,0 +1,7 @@
+add_header_library(
+ freebsd_x86_64_util
+ HDRS
+ syscall.h
+ DEPENDS
+ libc.src.__support.common
+)
diff --git a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
new file mode 100644
index 0000000000000..43b22f0afe803
--- /dev/null
+++ b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
@@ -0,0 +1,120 @@
+//===---------- inline implementation of x86_64 syscalls ----------* C++ *-===//
+//
+// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+// See https://llvm.org/LICENSE.txt for license information.
+// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+//
+//===----------------------------------------------------------------------===//
+
+#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_X86_64_SYSCALL_H
+#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_X86_64_SYSCALL_H
+
+#include "src/__support/common.h"
+#include "src/__support/macros/config.h"
+
+#define SYSCALL_CLOBBER_LIST "rcx", "r11", "memory", "cc"
+
+namespace LIBC_NAMESPACE_DECL {
+
+LIBC_INLINE long syscall_impl(long __number) {
+ long retcode;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1) {
+ long retcode;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2) {
+ long retcode;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3) {
+ long retcode;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4) {
+ long retcode;
+ register long r10 __asm__("r10") = __arg4;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
+ "r"(r10)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4, long __arg5) {
+ long retcode;
+ register long r10 __asm__("r10") = __arg4;
+ register long r8 __asm__("r8") = __arg5;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
+ "r"(r10), "r"(r8)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4, long __arg5,
+ long __arg6) {
+ long retcode;
+ register long r10 __asm__("r10") = __arg4;
+ register long r8 __asm__("r8") = __arg5;
+ register long r9 __asm__("r9") = __arg6;
+ LIBC_INLINE_ASM("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
+ "r"(r10), "r"(r8), "r"(r9)
+ : SYSCALL_CLOBBER_LIST);
+ return retcode;
+}
+
+#undef SYSCALL_CLOBBER_LIST
+} // namespace LIBC_NAMESPACE_DECL
+
+#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_X86_64_SYSCALL_H
diff --git a/libc/src/__support/OSUtil/io.h b/libc/src/__support/OSUtil/io.h
index 66af31f3cc8c6..1e0f6e581eccf 100644
--- a/libc/src/__support/OSUtil/io.h
+++ b/libc/src/__support/OSUtil/io.h
@@ -21,6 +21,8 @@
#include "fuchsia/io.h"
#elif defined(_WIN32)
#include "windows/io.h"
+#elif defined(__FreeBSD__)
+#include "freebsd/io.h"
#elif defined(__ELF__)
// TODO: Ideally we would have LIBC_TARGET_OS_IS_BAREMETAL.
#include "baremetal/io.h"
diff --git a/libc/src/__support/OSUtil/syscall.h b/libc/src/__support/OSUtil/syscall.h
index fc697a7c09821..08f5e14a7122c 100644
--- a/libc/src/__support/OSUtil/syscall.h
+++ b/libc/src/__support/OSUtil/syscall.h
@@ -13,6 +13,8 @@
#include "darwin/syscall.h"
#elif defined(__linux__)
#include "linux/syscall.h"
+#elif defined(__FreeBSD__)
+#include "freebsd/syscall.h"
#endif
#endif // LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_H
diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp
index 3f5329bbdc53f..ad0c0c5b5cc2d 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -30,6 +30,10 @@ namespace testing {
#define siglongjmp(buf, val) longjmp(buf, val)
#endif
+#ifdef __FreeBSD__
+using sighandler_t = __sighandler_t *;
+#endif
+
static thread_local sigjmp_buf jumpBuffer;
static thread_local bool caughtExcept;
>From 959f0243dbc3bb123f4206a600f0beddee7f86fa Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 02:01:29 -0400
Subject: [PATCH 03/15] fix FE_DENORMAL
---
libc/test/src/math/FModTest.h | 2 ++
libc/test/src/math/smoke/FModTest.h | 2 ++
2 files changed, 4 insertions(+)
diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h
index 7889a0c0ef727..46fd9f187882f 100644
--- a/libc/test/src/math/FModTest.h
+++ b/libc/test/src/math/FModTest.h
@@ -19,6 +19,8 @@
#ifdef FE_DENORM
#define DENORM_EXCEPT FE_DENORM
+#elif defined(FE_DENORMAL)
+#define DENORM_EXCEPT FE_DENORMAL
#elif defined(__FE_DENORM)
#define DENORM_EXCEPT __FE_DENORM
#else
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index ab336cd240580..9fe907db9bc6d 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -20,6 +20,8 @@
#ifdef FE_DENORM
#define DENORM_EXCEPT FE_DENORM
+#elif defined(FE_DENORMAL)
+#define DENORM_EXCEPT FE_DENORMAL
#elif defined(__FE_DENORM)
#define DENORM_EXCEPT __FE_DENORM
#else
>From ca8a381dccd5525fd8c4749c290911412b3caacf Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 15:59:15 -0400
Subject: [PATCH 04/15] add freebsd vm ci
---
.github/workflows/libc-freebsd-vm-tests.yml | 61 +++++++++++++++++++++
1 file changed, 61 insertions(+)
create mode 100644 .github/workflows/libc-freebsd-vm-tests.yml
diff --git a/.github/workflows/libc-freebsd-vm-tests.yml b/.github/workflows/libc-freebsd-vm-tests.yml
new file mode 100644
index 0000000000000..2891d327e367c
--- /dev/null
+++ b/.github/workflows/libc-freebsd-vm-tests.yml
@@ -0,0 +1,61 @@
+# This workflow is for pre-commit testing of the LLVM-libc project.
+name: LLVM-libc Pre-commit Overlay Tests (FreeBSD VM)
+permissions:
+ contents: read
+on:
+ pull_request:
+ branches: [ "main" ]
+ paths:
+ - 'libc/**'
+ - '.github/workflows/libc-freebsd-vm-tests.yml'
+
+jobs:
+ build:
+ runs-on: ubuntu-24.04
+
+ steps:
+ - uses: actions/checkout at de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
+ with:
+ persist-credentials: false
+
+ # MPFR is required by some of the mathlib tests.
+ - name: Setup FreeBSD
+ uses: vmactions/freebsd-vm at 5b592a73e766fea2379264365f3a1a6b089ec989
+ with:
+ usesh: true
+ sync: nfs
+ release: "15.0"
+ run: |
+ pkg update
+ pkg upgrade -y
+ pkg install -y mpfr gmp mpc ninja cmake llvm22
+
+ # Use MinSizeRel to reduce the size of the build.
+ # Notice that CMP0141=NEW and MSVC_DEBUG_INFORMATION_FORMAT=Embedded are required
+ # by the sccache tool.
+ - name: Configure CMake
+ shell: freebsd {0}
+ run: >
+ cmake -B build
+ -DCMAKE_CXX_COMPILER=clang++22
+ -DCMAKE_C_COMPILER=clang22
+ -DCMAKE_BUILD_TYPE=RelWithDebInfo
+ -DLLVM_ENABLE_RUNTIMES=libc
+ -G Ninja
+ -S runtimes
+
+ - name: Build
+ shell: freebsd {0}
+ run: >
+ cmake
+ --build build
+ --parallel
+ --target libc
+
+ - name: Test
+ shell: freebsd {0}
+ run: >
+ cmake
+ --build build
+ --parallel
+ --target check-libc
>From 6afbec5ef8d5c1b942b27dc99c1db13a96046520 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 16:06:31 -0400
Subject: [PATCH 05/15] migrate asm syscall stubs
---
.../__support/OSUtil/freebsd/x86_64/syscall.h | 103 +++++++++---------
1 file changed, 51 insertions(+), 52 deletions(-)
diff --git a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
index 43b22f0afe803..3398be9fe969d 100644
--- a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
@@ -18,50 +18,50 @@ namespace LIBC_NAMESPACE_DECL {
LIBC_INLINE long syscall_impl(long __number) {
long retcode;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
LIBC_INLINE long syscall_impl(long __number, long __arg1) {
long retcode;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2) {
long retcode;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1), "S"(__arg2)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
long __arg3) {
long retcode;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
@@ -69,14 +69,13 @@ LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
long __arg3, long __arg4) {
long retcode;
register long r10 __asm__("r10") = __arg4;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
- "r"(r10)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
@@ -85,14 +84,14 @@ LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
long retcode;
register long r10 __asm__("r10") = __arg4;
register long r8 __asm__("r8") = __arg5;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
- "r"(r10), "r"(r8)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10),
+ "r"(r8)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
@@ -103,14 +102,14 @@ LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
register long r10 __asm__("r10") = __arg4;
register long r8 __asm__("r8") = __arg5;
register long r9 __asm__("r9") = __arg6;
- LIBC_INLINE_ASM("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
- : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3),
- "r"(r10), "r"(r8), "r"(r9)
- : SYSCALL_CLOBBER_LIST);
+ asm volatile("syscall\n\t"
+ "jnc 1f\n\t"
+ "neg %%rax\n"
+ "1:"
+ : "=a"(retcode)
+ : "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10),
+ "r"(r8), "r"(r9)
+ : SYSCALL_CLOBBER_LIST);
return retcode;
}
>From 7d8af933ebe57d617b1153eee996f3a26f40e97a Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 16:16:54 -0400
Subject: [PATCH 06/15] update
---
.github/workflows/libc-freebsd-vm-tests.yml | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/.github/workflows/libc-freebsd-vm-tests.yml b/.github/workflows/libc-freebsd-vm-tests.yml
index 2891d327e367c..b321f56d65e75 100644
--- a/.github/workflows/libc-freebsd-vm-tests.yml
+++ b/.github/workflows/libc-freebsd-vm-tests.yml
@@ -28,7 +28,7 @@ jobs:
run: |
pkg update
pkg upgrade -y
- pkg install -y mpfr gmp mpc ninja cmake llvm22
+ pkg install -y mpfr gmp mpc ninja cmake llvm22 python3
# Use MinSizeRel to reduce the size of the build.
# Notice that CMP0141=NEW and MSVC_DEBUG_INFORMATION_FORMAT=Embedded are required
@@ -41,6 +41,8 @@ jobs:
-DCMAKE_C_COMPILER=clang22
-DCMAKE_BUILD_TYPE=RelWithDebInfo
-DLLVM_ENABLE_RUNTIMES=libc
+ -DLLVM_LIBC_MPFR_INSTALL_PATH=/usr/local
+ -DLIBC_MPC_INSTALL_PATH=/usr/local
-G Ninja
-S runtimes
>From a741ab32aab1569d6b4773e8871f1a6f4103591c Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 16:24:50 -0400
Subject: [PATCH 07/15] update
---
.github/workflows/libc-freebsd-vm-tests.yml | 1 +
1 file changed, 1 insertion(+)
diff --git a/.github/workflows/libc-freebsd-vm-tests.yml b/.github/workflows/libc-freebsd-vm-tests.yml
index b321f56d65e75..ff7ca952c61f9 100644
--- a/.github/workflows/libc-freebsd-vm-tests.yml
+++ b/.github/workflows/libc-freebsd-vm-tests.yml
@@ -25,6 +25,7 @@ jobs:
usesh: true
sync: nfs
release: "15.0"
+ mem: 12288
run: |
pkg update
pkg upgrade -y
>From 3d2023fcde33dad7bdc80432ab08ea25cf0a7f92 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 16:41:45 -0400
Subject: [PATCH 08/15] update
---
libc/src/__support/OSUtil/freebsd/exit.cpp | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libc/src/__support/OSUtil/freebsd/exit.cpp b/libc/src/__support/OSUtil/freebsd/exit.cpp
index fd2ec67c3cf5b..d656163fc8941 100644
--- a/libc/src/__support/OSUtil/freebsd/exit.cpp
+++ b/libc/src/__support/OSUtil/freebsd/exit.cpp
@@ -20,8 +20,7 @@ namespace internal {
#ifdef LIBC_TARGET_ARCH_IS_X86
__attribute__((no_stack_protector))
#endif
-__attribute__((noreturn)) void
-exit(int status) {
+__attribute__((noreturn)) void exit(int status) {
for (;;) {
LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
}
>From 7cc2f6c87c882c514b4ce0c25c8b91b58e47d4e4 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 17:07:12 -0400
Subject: [PATCH 09/15] update
---
libc/test/src/CMakeLists.txt | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/test/src/CMakeLists.txt b/libc/test/src/CMakeLists.txt
index b877c7455fc34..a5eade34b90d3 100644
--- a/libc/test/src/CMakeLists.txt
+++ b/libc/test/src/CMakeLists.txt
@@ -34,8 +34,8 @@ function(add_fp_unittest name)
endif()
set(test_type UNIT_TEST_ONLY)
list(APPEND MATH_UNITTEST_LINK_LIBRARIES libcMPFRWrapper -lmpfr -lgmp)
- if(NOT(LIBC_TARGET_OS_IS_DARWIN))
- # macOS does not have libatomic.
+ if(NOT(LIBC_TARGET_OS_IS_DARWIN) AND NOT(LIBC_TARGET_OS_IS_FREEBSD))
+ # macOS/FreeBSD does not have libatomic.
list(APPEND MATH_UNITTEST_LINK_LIBRARIES -latomic)
endif()
endif()
>From 01810f457ed9b51bed38cdec82883459b8609705 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 18:23:45 -0400
Subject: [PATCH 10/15] remove tanhf from list
---
libc/config/freebsd/x86_64/entrypoints.txt | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index 31d421555624d..f385d7d8a2d0c 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -283,7 +283,8 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.sqrtl
libc.src.math.tan
libc.src.math.tanf
- libc.src.math.tanhf
+ # FIXME: this is broken
+ # libc.src.math.tanhf
libc.src.math.trunc
libc.src.math.truncf
libc.src.math.truncl
>From 38e0c2c396e7882a0b840686afafb89f776935b2 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 21:16:14 -0400
Subject: [PATCH 11/15] update
---
libc/src/__support/OSUtil/freebsd/exit.cpp | 2 +-
libc/src/__support/OSUtil/freebsd/syscall.h | 16 +++-
.../OSUtil/freebsd/syscall_wrappers/close.h | 8 +-
.../freebsd/syscall_wrappers/getrandom.h | 8 +-
.../OSUtil/freebsd/syscall_wrappers/mmap.h | 10 +--
.../freebsd/syscall_wrappers/mprotect.h | 11 +--
.../OSUtil/freebsd/syscall_wrappers/munmap.h | 10 ++-
.../OSUtil/freebsd/syscall_wrappers/open.h | 8 +-
.../OSUtil/freebsd/syscall_wrappers/read.h | 8 +-
.../OSUtil/freebsd/syscall_wrappers/write.h | 8 +-
.../__support/OSUtil/freebsd/x86_64/syscall.h | 88 +++++++++----------
11 files changed, 91 insertions(+), 86 deletions(-)
diff --git a/libc/src/__support/OSUtil/freebsd/exit.cpp b/libc/src/__support/OSUtil/freebsd/exit.cpp
index d656163fc8941..29ee4c057b67a 100644
--- a/libc/src/__support/OSUtil/freebsd/exit.cpp
+++ b/libc/src/__support/OSUtil/freebsd/exit.cpp
@@ -22,7 +22,7 @@ __attribute__((no_stack_protector))
#endif
__attribute__((noreturn)) void exit(int status) {
for (;;) {
- LIBC_NAMESPACE::syscall_impl<long>(SYS_exit, status);
+ LIBC_NAMESPACE::syscall_impl(SYS_exit, status);
}
}
diff --git a/libc/src/__support/OSUtil/freebsd/syscall.h b/libc/src/__support/OSUtil/freebsd/syscall.h
index daaa437131c45..08f0fec68fa89 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall.h
@@ -9,11 +9,19 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
-#include "src/__support/CPP/bit.h"
#include "src/__support/common.h"
#include "src/__support/macros/config.h"
#include "src/__support/macros/properties/architectures.h"
+namespace LIBC_NAMESPACE_DECL {
+
+struct SyscallReturn {
+ long value;
+ bool is_error;
+};
+
+} // namespace LIBC_NAMESPACE_DECL
+
#ifdef LIBC_TARGET_ARCH_IS_X86_32
#include "i386/syscall.h"
#elif defined(LIBC_TARGET_ARCH_IS_X86_64)
@@ -28,10 +36,10 @@
namespace LIBC_NAMESPACE_DECL {
-template <typename R, typename... Ts>
-LIBC_INLINE R syscall_impl(long __number, Ts... ts) {
+template <typename... Ts> LIBC_INLINE SyscallReturn syscall_impl(long __number,
+ Ts... ts) {
static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall");
- return cpp::bit_or_static_cast<R>(syscall_impl(__number, (long)ts...));
+ return syscall_impl(__number, (long)ts...);
}
} // namespace LIBC_NAMESPACE_DECL
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
index e863d4890bb74..a1e8878eeb3b9 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
@@ -19,10 +19,10 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<int> close(int fd) {
- int ret = syscall_impl<int>(SYS_close, fd);
- if (ret < 0)
- return Error(-ret);
- return ret;
+ SyscallReturn ret = syscall_impl(SYS_close, fd);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<int>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
index 9c264b47efc97..a01dbad0d5e78 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
@@ -21,10 +21,10 @@ namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<ssize_t> getrandom(void *buf, size_t buflen,
unsigned int flags) {
- ssize_t ret = syscall_impl<ssize_t>(SYS_getrandom, buf, buflen, flags);
- if (ret < 0)
- return Error(-static_cast<int>(ret));
- return ret;
+ SyscallReturn ret = syscall_impl(SYS_getrandom, buf, buflen, flags);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<ssize_t>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
index b299463a34825..94d14256c73e5 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
@@ -21,11 +21,11 @@ namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<void *> mmap(void *addr, size_t size, int prot, int flags,
int fd, off_t offset) {
- long ret = syscall_impl<long>(SYS_mmap, reinterpret_cast<long>(addr), size,
- prot, flags, fd, static_cast<long>(offset));
- if (ret < 0)
- return Error(-static_cast<int>(ret));
- return reinterpret_cast<void *>(ret);
+ SyscallReturn ret = syscall_impl(SYS_mmap, reinterpret_cast<long>(addr), size,
+ prot, flags, fd, static_cast<long>(offset));
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return reinterpret_cast<void *>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
index 4eca3e6973b00..d671c2c485f1d 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
+#include "hdr/types/size_t.h"
#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
#include "src/__support/common.h"
#include "src/__support/error_or.h"
@@ -19,11 +20,11 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<int> mprotect(void *addr, size_t size, int prot) {
- int ret =
- syscall_impl<int>(SYS_mprotect, reinterpret_cast<long>(addr), size, prot);
- if (ret < 0)
- return Error(-ret);
- return ret;
+ SyscallReturn ret =
+ syscall_impl(SYS_mprotect, reinterpret_cast<long>(addr), size, prot);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<int>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
index 54722cab54926..81249d1e4feae 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
@@ -9,6 +9,7 @@
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
+#include "hdr/types/size_t.h"
#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
#include "src/__support/common.h"
#include "src/__support/error_or.h"
@@ -19,10 +20,11 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<int> munmap(void *addr, size_t size) {
- int ret = syscall_impl<int>(SYS_munmap, reinterpret_cast<long>(addr), size);
- if (ret < 0)
- return Error(-ret);
- return ret;
+ SyscallReturn ret =
+ syscall_impl(SYS_munmap, reinterpret_cast<long>(addr), size);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<int>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
index 7b74cf983e871..434c3b2a57bed 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
@@ -20,10 +20,10 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<int> open(const char *path, int flags, mode_t mode_flags) {
- int fd = syscall_impl<int>(SYS_open, path, flags, mode_flags);
- if (fd < 0)
- return Error(-fd);
- return fd;
+ SyscallReturn ret = syscall_impl(SYS_open, path, flags, mode_flags);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<int>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
index 6c9ca71f5935b..fafd56ea11bb5 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
@@ -20,10 +20,10 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<ssize_t> read(int fd, void *buf, size_t count) {
- ssize_t ret = syscall_impl<ssize_t>(SYS_read, fd, buf, count);
- if (ret < 0)
- return Error(-static_cast<int>(ret));
- return ret;
+ SyscallReturn ret = syscall_impl(SYS_read, fd, buf, count);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<ssize_t>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
index affd881fc0ccf..46ba210ba8239 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
@@ -20,10 +20,10 @@ namespace LIBC_NAMESPACE_DECL {
namespace freebsd_syscalls {
LIBC_INLINE ErrorOr<ssize_t> write(int fd, const void *buf, size_t count) {
- ssize_t ret = syscall_impl<ssize_t>(SYS_write, fd, buf, count);
- if (ret < 0)
- return Error(-static_cast<int>(ret));
- return ret;
+ SyscallReturn ret = syscall_impl(SYS_write, fd, buf, count);
+ if (ret.is_error)
+ return Error(static_cast<int>(ret.value));
+ return static_cast<ssize_t>(ret.value);
}
} // namespace freebsd_syscalls
diff --git a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
index 3398be9fe969d..0a09d78f45292 100644
--- a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
@@ -16,101 +16,95 @@
namespace LIBC_NAMESPACE_DECL {
-LIBC_INLINE long syscall_impl(long __number) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number) {
long retcode;
+ bool is_error;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1) {
long retcode;
+ bool is_error;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1,
+ long __arg2) {
long retcode;
+ bool is_error;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1), "S"(__arg2)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
- long __arg3) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3) {
long retcode;
+ bool is_error;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
- long __arg3, long __arg4) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4) {
long retcode;
+ bool is_error;
register long r10 __asm__("r10") = __arg4;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
- long __arg3, long __arg4, long __arg5) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4, long __arg5) {
long retcode;
+ bool is_error;
register long r10 __asm__("r10") = __arg4;
register long r8 __asm__("r8") = __arg5;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10),
"r"(r8)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
-LIBC_INLINE long syscall_impl(long __number, long __arg1, long __arg2,
- long __arg3, long __arg4, long __arg5,
- long __arg6) {
+LIBC_INLINE SyscallReturn syscall_impl(long __number, long __arg1, long __arg2,
+ long __arg3, long __arg4, long __arg5,
+ long __arg6) {
long retcode;
+ bool is_error;
register long r10 __asm__("r10") = __arg4;
register long r8 __asm__("r8") = __arg5;
register long r9 __asm__("r9") = __arg6;
asm volatile("syscall\n\t"
- "jnc 1f\n\t"
- "neg %%rax\n"
- "1:"
- : "=a"(retcode)
+ "setc %1"
+ : "=a"(retcode), "=qm"(is_error)
: "a"(__number), "D"(__arg1), "S"(__arg2), "d"(__arg3), "r"(r10),
"r"(r8), "r"(r9)
: SYSCALL_CLOBBER_LIST);
- return retcode;
+ return {retcode, is_error};
}
#undef SYSCALL_CLOBBER_LIST
>From beac5aada25a917fb08002be539191a0d3e4438b Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Mon, 11 May 2026 21:30:43 -0400
Subject: [PATCH 12/15] update
---
libc/src/__support/OSUtil/freebsd/syscall.h | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/libc/src/__support/OSUtil/freebsd/syscall.h b/libc/src/__support/OSUtil/freebsd/syscall.h
index 08f0fec68fa89..862077001b6b6 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall.h
@@ -36,8 +36,8 @@ struct SyscallReturn {
namespace LIBC_NAMESPACE_DECL {
-template <typename... Ts> LIBC_INLINE SyscallReturn syscall_impl(long __number,
- Ts... ts) {
+template <typename... Ts>
+LIBC_INLINE SyscallReturn syscall_impl(long __number, Ts... ts) {
static_assert(sizeof...(Ts) <= 6, "Too many arguments for syscall");
return syscall_impl(__number, (long)ts...);
}
>From 17613e9f3e52842350a87b94a5f02d6469c93bef Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Wed, 13 May 2026 00:12:47 -0400
Subject: [PATCH 13/15] update
---
libc/config/freebsd/x86_64/entrypoints.txt | 3 +--
1 file changed, 1 insertion(+), 2 deletions(-)
diff --git a/libc/config/freebsd/x86_64/entrypoints.txt b/libc/config/freebsd/x86_64/entrypoints.txt
index f385d7d8a2d0c..31d421555624d 100644
--- a/libc/config/freebsd/x86_64/entrypoints.txt
+++ b/libc/config/freebsd/x86_64/entrypoints.txt
@@ -283,8 +283,7 @@ set(TARGET_LIBM_ENTRYPOINTS
libc.src.math.sqrtl
libc.src.math.tan
libc.src.math.tanf
- # FIXME: this is broken
- # libc.src.math.tanhf
+ libc.src.math.tanhf
libc.src.math.trunc
libc.src.math.truncf
libc.src.math.truncl
>From a916949dc57dcc2822374da3831ba6de46350a82 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Wed, 13 May 2026 21:56:33 -0400
Subject: [PATCH 14/15] [libc] partially address michael's comments
---
libc/Maintainers.md | 2 +-
libc/src/__support/OSUtil/freebsd/exit.cpp | 5 ++---
libc/src/__support/OSUtil/freebsd/io.h | 3 +--
3 files changed, 4 insertions(+), 6 deletions(-)
diff --git a/libc/Maintainers.md b/libc/Maintainers.md
index eea620f7c5b16..94576c9dbb7c7 100644
--- a/libc/Maintainers.md
+++ b/libc/Maintainers.md
@@ -29,7 +29,7 @@ This file is a list of the [maintainers](https://llvm.org/docs/DeveloperPolicy.h
- Nicolas Celik
- its.overmighty at gmail.com (email), [OverMighty](https://github.com/overmighty) (github)
-## Threading
+## Threading, FreeBSD
- Yifan Zhu
- yifanzhu at rochester.edu (email), [Schrodinger ZHU Yifan](https://github.com/schrodingerzhu) (github)
diff --git a/libc/src/__support/OSUtil/freebsd/exit.cpp b/libc/src/__support/OSUtil/freebsd/exit.cpp
index 29ee4c057b67a..8ec57b15e8a32 100644
--- a/libc/src/__support/OSUtil/freebsd/exit.cpp
+++ b/libc/src/__support/OSUtil/freebsd/exit.cpp
@@ -21,9 +21,8 @@ namespace internal {
__attribute__((no_stack_protector))
#endif
__attribute__((noreturn)) void exit(int status) {
- for (;;) {
- LIBC_NAMESPACE::syscall_impl(SYS_exit, status);
- }
+ for (;;)
+ syscall_impl(SYS_exit, status);
}
} // namespace internal
diff --git a/libc/src/__support/OSUtil/freebsd/io.h b/libc/src/__support/OSUtil/freebsd/io.h
index 348d39adb621c..2f399eece0446 100644
--- a/libc/src/__support/OSUtil/freebsd/io.h
+++ b/libc/src/__support/OSUtil/freebsd/io.h
@@ -14,9 +14,8 @@
#include "src/__support/macros/config.h"
namespace LIBC_NAMESPACE_DECL {
-
LIBC_INLINE void write_to_stderr(cpp::string_view msg) {
- LIBC_NAMESPACE::freebsd_syscalls::write(2 /* stderr */, msg.data(),
+ freebsd_syscalls::write(2 /* stderr */, msg.data(),
msg.size());
}
>From 43785c2ce7310b96e3cab2a46c02b2fd089afb81 Mon Sep 17 00:00:00 2001
From: Schrodinger ZHU Yifan <i at zhuyi.fan>
Date: Wed, 13 May 2026 22:02:51 -0400
Subject: [PATCH 15/15] migrate header style
---
libc/src/__support/CPP/tuple.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/exit.cpp | 7 ++++++-
libc/src/__support/OSUtil/freebsd/io.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h | 7 ++++++-
.../__support/OSUtil/freebsd/syscall_wrappers/getrandom.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h | 7 ++++++-
.../__support/OSUtil/freebsd/syscall_wrappers/mprotect.h | 7 ++++++-
.../src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h | 7 ++++++-
libc/src/__support/OSUtil/freebsd/x86_64/syscall.h | 7 ++++++-
libc/src/__support/OSUtil/io.h | 7 ++++++-
libc/src/__support/OSUtil/syscall.h | 7 ++++++-
libc/test/UnitTest/FPExceptMatcher.cpp | 7 ++++++-
libc/test/src/math/FModTest.h | 7 ++++++-
libc/test/src/math/smoke/FModTest.h | 7 ++++++-
18 files changed, 108 insertions(+), 18 deletions(-)
diff --git a/libc/src/__support/CPP/tuple.h b/libc/src/__support/CPP/tuple.h
index f3cac1b4b5781..8b38512092c1a 100644
--- a/libc/src/__support/CPP/tuple.h
+++ b/libc/src/__support/CPP/tuple.h
@@ -1,10 +1,15 @@
-//===-- tuple utility -------------------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Tuple utility.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_TUPLE_H
#define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_TUPLE_H
diff --git a/libc/src/__support/OSUtil/freebsd/exit.cpp b/libc/src/__support/OSUtil/freebsd/exit.cpp
index 8ec57b15e8a32..495af6cae04a7 100644
--- a/libc/src/__support/OSUtil/freebsd/exit.cpp
+++ b/libc/src/__support/OSUtil/freebsd/exit.cpp
@@ -1,10 +1,15 @@
-//===--------- Freebsd implementation of an exit function -------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// FreeBSD implementation of an exit function.
+///
+//===----------------------------------------------------------------------===//
#include "src/__support/OSUtil/freebsd/syscall.h" // syscall_impl
#include "src/__support/common.h"
diff --git a/libc/src/__support/OSUtil/freebsd/io.h b/libc/src/__support/OSUtil/freebsd/io.h
index 2f399eece0446..329dfb9f7fee5 100644
--- a/libc/src/__support/OSUtil/freebsd/io.h
+++ b/libc/src/__support/OSUtil/freebsd/io.h
@@ -1,10 +1,15 @@
-//===-------------- FreeBSD implementation of IO utils ----------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// FreeBSD implementation of IO utils.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_IO_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_IO_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall.h b/libc/src/__support/OSUtil/freebsd/syscall.h
index 862077001b6b6..40c2bf3623b6b 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall.h
@@ -1,10 +1,15 @@
-//===----------------------- FreeBSD syscalls -------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// FreeBSD syscalls.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
index a1e8878eeb3b9..47bf3fc9a3dc5 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/close.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for close -------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for close.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_CLOSE_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_CLOSE_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
index a01dbad0d5e78..0bc27b2ba79cc 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/getrandom.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for getrandom ---------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for getrandom.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_GETRANDOM_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_GETRANDOM_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
index 94d14256c73e5..7a1b9a4c5836b 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mmap.h
@@ -1,10 +1,15 @@
-//===-- Syscall wrapper for mmap --------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Syscall wrapper for mmap.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MMAP_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MMAP_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
index d671c2c485f1d..8856407dc62bf 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/mprotect.h
@@ -1,10 +1,15 @@
-//===-- Syscall wrapper for mprotect ----------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Syscall wrapper for mprotect.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MPROTECT_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
index 81249d1e4feae..ab0996314be70 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/munmap.h
@@ -1,10 +1,15 @@
-//===-- Syscall wrapper for munmap ------------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Syscall wrapper for munmap.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_MUNMAP_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
index 434c3b2a57bed..5f6ad953dd12d 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/open.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for open --------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for open.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_OPEN_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_OPEN_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
index fafd56ea11bb5..0b5bc6ae37a83 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/read.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for read --------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for read.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_READ_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_READ_H
diff --git a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
index 46ba210ba8239..9693066eda1eb 100644
--- a/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
+++ b/libc/src/__support/OSUtil/freebsd/syscall_wrappers/write.h
@@ -1,10 +1,15 @@
-//===-- Implementation header for write -------------------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation header for write.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_WRITE_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_SYSCALL_WRAPPERS_WRITE_H
diff --git a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
index 0a09d78f45292..6ca30dd1c3514 100644
--- a/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
+++ b/libc/src/__support/OSUtil/freebsd/x86_64/syscall.h
@@ -1,10 +1,15 @@
-//===---------- inline implementation of x86_64 syscalls ----------* C++ *-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Inline implementation of x86_64 syscalls.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_X86_64_SYSCALL_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_FREEBSD_X86_64_SYSCALL_H
diff --git a/libc/src/__support/OSUtil/io.h b/libc/src/__support/OSUtil/io.h
index 1e0f6e581eccf..fc49a3678e82b 100644
--- a/libc/src/__support/OSUtil/io.h
+++ b/libc/src/__support/OSUtil/io.h
@@ -1,10 +1,15 @@
-//===---------------- Implementation of IO utils ----------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Implementation of IO utils.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_IO_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_IO_H
diff --git a/libc/src/__support/OSUtil/syscall.h b/libc/src/__support/OSUtil/syscall.h
index 08f5e14a7122c..ec66a880c42db 100644
--- a/libc/src/__support/OSUtil/syscall.h
+++ b/libc/src/__support/OSUtil/syscall.h
@@ -1,10 +1,15 @@
-//===--------------- Internal syscall declarations --------------*- C++ -*-===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Internal syscall declarations.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_H
#define LLVM_LIBC_SRC___SUPPORT_OSUTIL_SYSCALL_H
diff --git a/libc/test/UnitTest/FPExceptMatcher.cpp b/libc/test/UnitTest/FPExceptMatcher.cpp
index ad0c0c5b5cc2d..d46cd7a24b80f 100644
--- a/libc/test/UnitTest/FPExceptMatcher.cpp
+++ b/libc/test/UnitTest/FPExceptMatcher.cpp
@@ -1,10 +1,15 @@
-//===-- FPExceptMatchers.cpp ----------------------------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// FPExceptMatchers.cpp.
+///
+//===----------------------------------------------------------------------===//
#undef LIBC_MATH_USE_SYSTEM_FENV
diff --git a/libc/test/src/math/FModTest.h b/libc/test/src/math/FModTest.h
index 46fd9f187882f..c8ac74e5e20e1 100644
--- a/libc/test/src/math/FModTest.h
+++ b/libc/test/src/math/FModTest.h
@@ -1,10 +1,15 @@
-//===-- Utility class to test fmod special numbers ------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fmod special numbers.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
diff --git a/libc/test/src/math/smoke/FModTest.h b/libc/test/src/math/smoke/FModTest.h
index 9fe907db9bc6d..cacd7a68d7cc6 100644
--- a/libc/test/src/math/smoke/FModTest.h
+++ b/libc/test/src/math/smoke/FModTest.h
@@ -1,10 +1,15 @@
-//===-- Utility class to test fmod special numbers ------------------------===//
+//===----------------------------------------------------------------------===//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//===----------------------------------------------------------------------===//
+///
+/// \file
+/// Utility class to test fmod special numbers.
+///
+//===----------------------------------------------------------------------===//
#ifndef LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
#define LLVM_LIBC_TEST_SRC_MATH_FMODTEST_H
More information about the libc-commits
mailing list