Skip to content

Commit 5053c5e

Browse files
libcxx: fixups for __BIONIC__
A few header guards seem to check various libc's, but not Android's libc (Bionic). Bionic supports: - arc4random - copy_file_range - getcwd() extension Link: https://android-review.git.corp.google.com/c/platform/bionic/+/41445 Link: https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/SYSCALLS.TXT Link: https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/upstream-openbsd/lib/libc/crypt/arc4random.c
1 parent 3891bea commit 5053c5e

3 files changed

Lines changed: 8 additions & 7 deletions

File tree

libcxx/include/__config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,8 @@
8282
// Use rand_s(), for use on Windows.
8383
// When this option is used, the token passed to `std::random_device`'s
8484
// constructor *must* be "/dev/urandom" -- anything else is an error.
85-
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
86-
defined(__DragonFly__)
85+
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
86+
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__BIONIC__)
8787
# define _LIBCPP_USING_ARC4_RANDOM
8888
# elif defined(__wasi__) || defined(__EMSCRIPTEN__)
8989
# define _LIBCPP_USING_GETENTROPY

libcxx/include/__cxx03/__config

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,8 +269,8 @@ _LIBCPP_HARDENING_MODE_DEBUG
269269
// Use rand_s(), for use on Windows.
270270
// When this option is used, the token passed to `std::random_device`'s
271271
// constructor *must* be "/dev/urandom" -- anything else is an error.
272-
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || defined(__OpenBSD__) || \
273-
defined(__DragonFly__)
272+
# if defined(__APPLE__) || defined(__FreeBSD__) || defined(__NetBSD__) || \
273+
defined(__OpenBSD__) || defined(__DragonFly__) || defined(__BIONIC__)
274274
# define _LIBCPP_USING_ARC4_RANDOM
275275
# elif defined(__wasi__) || defined(__EMSCRIPTEN__)
276276
# define _LIBCPP_USING_GETENTROPY

libcxx/src/filesystem/operations.cpp

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,9 @@
4040
#include <fcntl.h> /* values for fchmodat */
4141
#include <time.h>
4242

43-
// since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided by glibc >= 2.27 and musl
44-
#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__)
43+
// Since Linux 4.5 and FreeBSD 13, but the Linux libc wrapper is only provided
44+
// by glibc >= 2.27, musl, and Bionic.
45+
#if _LIBCPP_GLIBC_PREREQ(2, 27) || _LIBCPP_HAS_MUSL_LIBC || defined(__FreeBSD__) || defined(__BIONIC__)
4546
# define _LIBCPP_FILESYSTEM_USE_COPY_FILE_RANGE
4647
#endif
4748

@@ -564,7 +565,7 @@ void __create_symlink(path const& from, path const& to, error_code* ec) {
564565
path __current_path(error_code* ec) {
565566
ErrorHandler<path> err("current_path", ec);
566567

567-
#if defined(_WIN32) || defined(__GLIBC__) || defined(__APPLE__)
568+
#if defined(_WIN32) || defined(__GLIBC__) || defined(__APPLE__) || defined(__BIONIC__)
568569
// Common extension outside of POSIX getcwd() spec, without needing to
569570
// preallocate a buffer. Also supported by a number of other POSIX libcs.
570571
int size = 0;

0 commit comments

Comments
 (0)