[libcxx-commits] [libcxx] [libcxx] Re-include <osreldate.h> in __config for FreeBSD (PR #77242)

Dimitry Andric via libcxx-commits libcxx-commits at lists.llvm.org
Sun Jan 7 08:01:26 PST 2024


https://github.com/DimitryAndric created https://github.com/llvm/llvm-project/pull/77242

In 0a97720d0197 some changes were made to `__config` for assuming that `__BYTE_ORDER__` is always present.

However, this deleted a `<osreldate.h>` include for FreeBSD, which is required to get the value of `__FreeBSD_version`, and that is used later in the file to determine whether `_LIBCPP_C_HAS_NO_GETS` needs to be enabled.

Include `<osreldate.h>` just after the other includes used for feature detection, to fix this.

Note that when FreeBSD 13 is EOLed, this can be removed, as then all supported FreeBSD versions will no longer have `gets()`.


>From 142bdbc8f3cdef5f55a7941139e8c96b9269f886 Mon Sep 17 00:00:00 2001
From: Dimitry Andric <dimitry at andric.com>
Date: Sun, 7 Jan 2024 16:59:32 +0100
Subject: [PATCH] [libcxx] Re-include <osreldate.h> in __config for FreeBSD

In 0a97720d0197 some changes were made to `__config` for assuming that
`__BYTE_ORDER__` is always present.

However, this deleted a `<osreldate.h>` include for FreeBSD, which is
required to get the value of `__FreeBSD_version`, and that is used later
in the file to determine whether `_LIBCPP_C_HAS_NO_GETS` needs to be
enabled.

Include `<osreldate.h>` just after the other includes used for feature
detection, to fix this.

Note that when FreeBSD 13 is EOLed, this can be removed, as then all
supported FreeBSD versions will no longer have `gets()`.
---
 libcxx/include/__config | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/libcxx/include/__config b/libcxx/include/__config
index 082c73e672c749..359f4141146d62 100644
--- a/libcxx/include/__config
+++ b/libcxx/include/__config
@@ -484,6 +484,10 @@ _LIBCPP_HARDENING_MODE_DEBUG
 #    include <features.h> // for __NATIVE_ASCII_F
 #  endif
 
+#  ifdef __FreeBSD__
+#    include <osreldate.h> // for __FreeBSD_version
+#  endif
+
 #  ifndef __BYTE_ORDER__
 #    error                                                                                                             \
         "Your compiler doesn't seem to define __BYTE_ORDER__, which is required by libc++ to know the endianness of your target platform"



More information about the libcxx-commits mailing list