From 79f99ba65d96a35a79911daf1b67559dd52a684d Mon Sep 17 00:00:00 2001 From: Brad Smith Date: Tue, 12 Jan 2021 14:16:15 -0500 Subject: [PATCH] [libcxx] Port to OpenBSD Add initial OpenBSD support. Reviewed By: ldionne Differential Revision: https://reviews.llvm.org/D94205 --- libcxx/include/CMakeLists.txt | 1 + libcxx/include/__config | 15 ++++++++++----- libcxx/include/__locale | 2 ++ libcxx/include/support/openbsd/xlocale.h | 19 +++++++++++++++++++ 4 files changed, 32 insertions(+), 5 deletions(-) create mode 100644 libcxx/include/support/openbsd/xlocale.h diff --git a/libcxx/include/CMakeLists.txt b/libcxx/include/CMakeLists.txt index cd12f60a049c..2ffdf07efcd4 100644 --- a/libcxx/include/CMakeLists.txt +++ b/libcxx/include/CMakeLists.txt @@ -159,6 +159,7 @@ set(files support/musl/xlocale.h support/newlib/xlocale.h support/nuttx/xlocale.h + support/openbsd/xlocale.h support/solaris/floatingpoint.h support/solaris/wchar.h support/solaris/xlocale.h diff --git a/libcxx/include/__config b/libcxx/include/__config index 4537d249cf4f..f1606c6d3b1c 100644 --- a/libcxx/include/__config +++ b/libcxx/include/__config @@ -264,14 +264,14 @@ # endif // __LONG_LONG_SUPPORTED #endif // __FreeBSD__ -#ifdef __NetBSD__ +#if defined(__NetBSD__) || defined(__OpenBSD__) # include # if _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_LITTLE_ENDIAN # else // _BYTE_ORDER == _LITTLE_ENDIAN # define _LIBCPP_BIG_ENDIAN # endif // _BYTE_ORDER == _LITTLE_ENDIAN -#endif // __NetBSD__ +#endif // defined(__NetBSD__) || defined(__OpenBSD__) #if defined(_WIN32) # define _LIBCPP_WIN32API @@ -312,7 +312,7 @@ # endif #endif // __sun__ -#if defined(__CloudABI__) +#if defined(__OpenBSD__) || defined(__CloudABI__) // Certain architectures provide arc4random(). Prefer using // arc4random() over /dev/{u,}random to make it possible to obtain // random data even when using sandboxing mechanisms such as chroots, @@ -370,6 +370,9 @@ # define _LIBCPP_HAS_ALIGNED_ALLOC # define _LIBCPP_HAS_QUICK_EXIT # define _LIBCPP_HAS_TIMESPEC_GET +# elif defined(__OpenBSD__) +# define _LIBCPP_HAS_ALIGNED_ALLOC +# define _LIBCPP_HAS_TIMESPEC_GET # elif defined(__linux__) # if !defined(_LIBCPP_HAS_MUSL_LIBC) # if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__) @@ -1109,6 +1112,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( # if defined(__FreeBSD__) || \ defined(__wasi__) || \ defined(__NetBSD__) || \ + defined(__OpenBSD__) || \ defined(__NuttX__) || \ defined(__linux__) || \ defined(__GNU__) || \ @@ -1204,14 +1208,15 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container( // Some systems do not provide gets() in their C library, for security reasons. #ifndef _LIBCPP_C_HAS_NO_GETS # if defined(_LIBCPP_MSVCRT) || \ - (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) + (defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \ + defined(__OpenBSD__) # define _LIBCPP_C_HAS_NO_GETS # endif #endif #if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \ defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \ - defined(__MVS__) + defined(__MVS__) || defined(__OpenBSD__) #define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE #endif diff --git a/libcxx/include/__locale b/libcxx/include/__locale index f32bd59ae585..4e9e0c08acf0 100644 --- a/libcxx/include/__locale +++ b/libcxx/include/__locale @@ -33,6 +33,8 @@ # include #elif defined(_NEWLIB_VERSION) # include +#elif defined(__OpenBSD__) +# include #elif (defined(__APPLE__) || defined(__FreeBSD__) \ || defined(__EMSCRIPTEN__) || defined(__IBMCPP__)) # include diff --git a/libcxx/include/support/openbsd/xlocale.h b/libcxx/include/support/openbsd/xlocale.h new file mode 100644 index 000000000000..fbfaedd127c6 --- /dev/null +++ b/libcxx/include/support/openbsd/xlocale.h @@ -0,0 +1,19 @@ +// -*- C++ -*- +//===-------------------- support/openbsd/xlocale.h -----------------------===// +// +// 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 _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H +#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H + +#include +#include +#include +#include +#include + +#endif