[libcxx] Port to OpenBSD

Add initial OpenBSD support.

Reviewed By: ldionne

Differential Revision: https://reviews.llvm.org/D94205
This commit is contained in:
Brad Smith 2021-01-12 14:16:15 -05:00
parent eef4bdbb34
commit 79f99ba65d
4 changed files with 32 additions and 5 deletions

View File

@ -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

View File

@ -264,14 +264,14 @@
# endif // __LONG_LONG_SUPPORTED
#endif // __FreeBSD__
#ifdef __NetBSD__
#if defined(__NetBSD__) || defined(__OpenBSD__)
# include <sys/endian.h>
# 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

View File

@ -33,6 +33,8 @@
# include <support/solaris/xlocale.h>
#elif defined(_NEWLIB_VERSION)
# include <support/newlib/xlocale.h>
#elif defined(__OpenBSD__)
# include <support/openbsd/xlocale.h>
#elif (defined(__APPLE__) || defined(__FreeBSD__) \
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
# include <xlocale.h>

View File

@ -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 <cstdlib>
#include <clocale>
#include <cwctype>
#include <ctype.h>
#include <support/xlocale/__strtonum_fallback.h>
#endif