Skip to content

Commit 79f99ba

Browse files
committed
[libcxx] Port to OpenBSD
Add initial OpenBSD support. Reviewed By: ldionne Differential Revision: https://reviews.llvm.org/D94205
1 parent eef4bdb commit 79f99ba

File tree

4 files changed

+32
-5
lines changed

4 files changed

+32
-5
lines changed

libcxx/include/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -159,6 +159,7 @@ set(files
159159
support/musl/xlocale.h
160160
support/newlib/xlocale.h
161161
support/nuttx/xlocale.h
162+
support/openbsd/xlocale.h
162163
support/solaris/floatingpoint.h
163164
support/solaris/wchar.h
164165
support/solaris/xlocale.h

libcxx/include/__config

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -264,14 +264,14 @@
264264
# endif // __LONG_LONG_SUPPORTED
265265
#endif // __FreeBSD__
266266

267-
#ifdef __NetBSD__
267+
#if defined(__NetBSD__) || defined(__OpenBSD__)
268268
# include <sys/endian.h>
269269
# if _BYTE_ORDER == _LITTLE_ENDIAN
270270
# define _LIBCPP_LITTLE_ENDIAN
271271
# else // _BYTE_ORDER == _LITTLE_ENDIAN
272272
# define _LIBCPP_BIG_ENDIAN
273273
# endif // _BYTE_ORDER == _LITTLE_ENDIAN
274-
#endif // __NetBSD__
274+
#endif // defined(__NetBSD__) || defined(__OpenBSD__)
275275

276276
#if defined(_WIN32)
277277
# define _LIBCPP_WIN32API
@@ -312,7 +312,7 @@
312312
# endif
313313
#endif // __sun__
314314

315-
#if defined(__CloudABI__)
315+
#if defined(__OpenBSD__) || defined(__CloudABI__)
316316
// Certain architectures provide arc4random(). Prefer using
317317
// arc4random() over /dev/{u,}random to make it possible to obtain
318318
// random data even when using sandboxing mechanisms such as chroots,
@@ -370,6 +370,9 @@
370370
# define _LIBCPP_HAS_ALIGNED_ALLOC
371371
# define _LIBCPP_HAS_QUICK_EXIT
372372
# define _LIBCPP_HAS_TIMESPEC_GET
373+
# elif defined(__OpenBSD__)
374+
# define _LIBCPP_HAS_ALIGNED_ALLOC
375+
# define _LIBCPP_HAS_TIMESPEC_GET
373376
# elif defined(__linux__)
374377
# if !defined(_LIBCPP_HAS_MUSL_LIBC)
375378
# if _LIBCPP_GLIBC_PREREQ(2, 15) || defined(__BIONIC__)
@@ -1109,6 +1112,7 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
11091112
# if defined(__FreeBSD__) || \
11101113
defined(__wasi__) || \
11111114
defined(__NetBSD__) || \
1115+
defined(__OpenBSD__) || \
11121116
defined(__NuttX__) || \
11131117
defined(__linux__) || \
11141118
defined(__GNU__) || \
@@ -1204,14 +1208,15 @@ extern "C" _LIBCPP_FUNC_VIS void __sanitizer_annotate_contiguous_container(
12041208
// Some systems do not provide gets() in their C library, for security reasons.
12051209
#ifndef _LIBCPP_C_HAS_NO_GETS
12061210
# if defined(_LIBCPP_MSVCRT) || \
1207-
(defined(__FreeBSD_version) && __FreeBSD_version >= 1300043)
1211+
(defined(__FreeBSD_version) && __FreeBSD_version >= 1300043) || \
1212+
defined(__OpenBSD__)
12081213
# define _LIBCPP_C_HAS_NO_GETS
12091214
# endif
12101215
#endif
12111216

12121217
#if defined(__BIONIC__) || defined(__CloudABI__) || defined(__NuttX__) || \
12131218
defined(__Fuchsia__) || defined(__wasi__) || defined(_LIBCPP_HAS_MUSL_LIBC) || \
1214-
defined(__MVS__)
1219+
defined(__MVS__) || defined(__OpenBSD__)
12151220
#define _LIBCPP_PROVIDES_DEFAULT_RUNE_TABLE
12161221
#endif
12171222

libcxx/include/__locale

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
# include <support/solaris/xlocale.h>
3434
#elif defined(_NEWLIB_VERSION)
3535
# include <support/newlib/xlocale.h>
36+
#elif defined(__OpenBSD__)
37+
# include <support/openbsd/xlocale.h>
3638
#elif (defined(__APPLE__) || defined(__FreeBSD__) \
3739
|| defined(__EMSCRIPTEN__) || defined(__IBMCPP__))
3840
# include <xlocale.h>
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
// -*- C++ -*-
2+
//===-------------------- support/openbsd/xlocale.h -----------------------===//
3+
//
4+
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
5+
// See https://llvm.org/LICENSE.txt for license information.
6+
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7+
//
8+
//===----------------------------------------------------------------------===//
9+
10+
#ifndef _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
11+
#define _LIBCPP_SUPPORT_OPENBSD_XLOCALE_H
12+
13+
#include <cstdlib>
14+
#include <clocale>
15+
#include <cwctype>
16+
#include <ctype.h>
17+
#include <support/xlocale/__strtonum_fallback.h>
18+
19+
#endif

0 commit comments

Comments
 (0)