diff options
Diffstat (limited to 'mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits')
10 files changed, 384 insertions, 219 deletions
diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/bionic_multibyte_result.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/bionic_multibyte_result.h new file mode 100644 index 00000000..0d5cf21d --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/bionic_multibyte_result.h @@ -0,0 +1,68 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +/** + * @file bits/bionic_multibyte_result.h + * @brief Named values for the magic number return values of multibyte + * conversion APIs defined by C. + */ + +#include <stddef.h> +#include <sys/cdefs.h> + +__BEGIN_DECLS + +/** + * @brief The error values defined by C for multibyte conversion APIs. + * + * Refer to C23 7.30.1 Restartable multibyte/wide character conversion functions + * for more details. + */ +enum : size_t { + /// @brief An encoding error occurred. The bytes read are not a valid unicode + /// character, nor are they a partially valid character. + BIONIC_MULTIBYTE_RESULT_ILLEGAL_SEQUENCE = -1UL, +#define BIONIC_MULTIBYTE_RESULT_ILLEGAL_SEQUENCE BIONIC_MULTIBYTE_RESULT_ILLEGAL_SEQUENCE + + /// @brief The bytes read may produce a valid unicode character, but the + /// sequence is incomplete. Future calls may complete the character. + BIONIC_MULTIBYTE_RESULT_INCOMPLETE_SEQUENCE = -2UL, +#define BIONIC_MULTIBYTE_RESULT_INCOMPLETE_SEQUENCE BIONIC_MULTIBYTE_RESULT_INCOMPLETE_SEQUENCE + + /// @brief The output of the call was the result of a previous successful + /// decoding. No new bytes were consumed. + /// + /// The common case for this return value is when mbrtoc16 returns the low + /// surrogate of a pair. + BIONIC_MULTIBYTE_RESULT_NO_BYTES_CONSUMED = -3UL, +#define BIONIC_MULTIBYTE_RESULT_NO_BYTES_CONSUMED BIONIC_MULTIBYTE_RESULT_NO_BYTES_CONSUMED +}; + +__END_DECLS diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/ctype_inlines.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/ctype_inlines.h deleted file mode 100644 index 089a6421..00000000 --- a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/ctype_inlines.h +++ /dev/null @@ -1,209 +0,0 @@ -/* - * Copyright (C) 2014 The Android Open Source Project - * All rights reserved. - * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions - * are met: - * * Redistributions of source code must retain the above copyright - * notice, this list of conditions and the following disclaimer. - * * Redistributions in binary form must reproduce the above copyright - * notice, this list of conditions and the following disclaimer in - * the documentation and/or other materials provided with the - * distribution. - * - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS - * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE - * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, - * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS - * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED - * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, - * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT - * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF - * SUCH DAMAGE. - */ - -#pragma once - -#include <sys/cdefs.h> -#include <xlocale.h> - -#if !defined(__BIONIC_CTYPE_INLINE) -#define __BIONIC_CTYPE_INLINE static __inline -#endif - -/** Internal implementation detail. Do not use. */ -#define _CTYPE_U 0x01 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_L 0x02 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_D 0x04 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_S 0x08 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_P 0x10 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_C 0x20 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_X 0x40 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_B 0x80 -/** Internal implementation detail. Do not use. */ -#define _CTYPE_R (_CTYPE_P|_CTYPE_U|_CTYPE_L|_CTYPE_D|_CTYPE_B) -/** Internal implementation detail. Do not use. */ -#define _CTYPE_A (_CTYPE_L|_CTYPE_U) -/** Internal implementation detail. Do not use. */ -#define _CTYPE_N _CTYPE_D - -__BEGIN_DECLS - -/** Internal implementation detail. Do not use. */ -extern const char* _Nonnull _ctype_; - -/** Returns true if `ch` is in `[A-Za-z0-9]`. */ -__BIONIC_CTYPE_INLINE int isalnum(int __ch) { - // `isalnum(c)` is `isalpha(c) || isdigit(c)`, but there's no obvious way - // to simplify that, and the table lookup is just slightly faster... - // Note that this is unsafe for inputs less than -1 (EOF) or greater than - // 0xff. This is true of other C libraries too. - return (_ctype_[__ch + 1] & (_CTYPE_U|_CTYPE_L|_CTYPE_N)); -} - -/** Returns true if `ch` is in `[A-Za-z]`. */ -__BIONIC_CTYPE_INLINE int isalpha(int __ch) { - return (__ch >= 'A' && __ch <= 'Z') || (__ch >= 'a' && __ch <= 'z'); -} - -/** Returns true if `ch` is a space or tab. */ -__BIONIC_CTYPE_INLINE int isblank(int __ch) { - return __ch == ' ' || __ch == '\t'; -} - -/** Returns true if `ch` is a control character (any character before space, plus DEL). */ -__BIONIC_CTYPE_INLINE int iscntrl(int __ch) { - return (__BIONIC_CAST(static_cast, unsigned, __ch) < ' ') || __ch == 0x7f; -} - -/** Returns true if `ch` is in `[0-9]`. */ -__BIONIC_CTYPE_INLINE int isdigit(int __ch) { - return (__ch >= '0' && __ch <= '9'); -} - -/** Returns true if `ch` is `[A-Za-z0-9]` or punctuation. */ -__BIONIC_CTYPE_INLINE int isgraph(int __ch) { - return (__ch >= '!' && __ch <= '~'); -} - -/** Returns true if `ch` is in `[a-z]`. */ -__BIONIC_CTYPE_INLINE int islower(int __ch) { - return (__ch >= 'a' && __ch <= 'z'); -} - -/** Returns true if `ch` is `[A-Za-z0-9]` or punctuation or space. */ -__BIONIC_CTYPE_INLINE int isprint(int __ch) { - return (__ch >= ' ' && __ch <= '~'); -} - -/** Returns true if `ch` is punctuation. */ -__BIONIC_CTYPE_INLINE int ispunct(int __ch) { - // `ispunct(c)` is `isgraph(c) && !isalnum(c)`, but there's no obvious way - // to simplify that, and the table lookup is just slightly faster... - // Note that this is unsafe for inputs less than -1 (EOF) or greater than - // 0xff. This is true of other C libraries too. - return (_ctype_[__ch + 1] & _CTYPE_P); -} - -/** Returns true if `ch` is in `[ \f\n\r\t\v]`. */ -__BIONIC_CTYPE_INLINE int isspace(int __ch) { - return __ch == ' ' || (__ch >= '\t' && __ch <= '\r'); -} - -/** Returns true if `ch` is in `[A-Z]`. */ -__BIONIC_CTYPE_INLINE int isupper(int __ch) { - return (__ch >= 'A' && __ch <= 'Z'); -} - -/** Returns true if `ch` is in `[0-9A-Fa-f]`. */ -__BIONIC_CTYPE_INLINE int isxdigit(int __ch) { - return (__ch >= '0' && __ch <= '9') || (__ch >= 'a' && __ch <= 'f') || (__ch >= 'A' && __ch <= 'F'); -} - -/** - * Returns the corresponding lower-case character if `ch` is upper-case, or undefined otherwise. - * - * Prefer tolower() instead. - */ -__BIONIC_CTYPE_INLINE int _tolower(int __ch) { - return __ch | 0x20; -} - -/** Returns the corresponding lower-case character if `ch` is upper-case, or `ch` otherwise. */ -__BIONIC_CTYPE_INLINE int tolower(int __ch) { - if (__ch >= 'A' && __ch <= 'Z') return _tolower(__ch); - return __ch; -} - -/** - * Returns the corresponding upper-case character if `ch` is lower-case, or undefined otherwise. - * - * Prefer toupper() instead. - */ -__BIONIC_CTYPE_INLINE int _toupper(int __ch) { - // Using EOR rather than AND makes no difference on arm, but saves an - // instruction on arm64. - return __ch ^ 0x20; -} - -/** Returns the corresponding upper-case character if `ch` is lower-case, or `ch` otherwise. */ -__BIONIC_CTYPE_INLINE int toupper(int __ch) { - if (__ch >= 'a' && __ch <= 'z') return _toupper(__ch); - return __ch; -} - -/** Returns true if `ch` is less than 0x80. */ -__BIONIC_CTYPE_INLINE int isascii(int __ch) { - return __BIONIC_CAST(static_cast, unsigned, __ch) < 0x80; -} - -/** Returns `ch & 0x7f`. */ -__BIONIC_CTYPE_INLINE int toascii(int __ch) { - return __ch & 0x7f; -} - -#if __ANDROID_API__ >= 21 -/** Like isalnum but with an ignored `locale_t`. */ -int isalnum_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isalpha but with an ignored `locale_t`. */ -int isalpha_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isblank but with an ignored `locale_t`. */ -int isblank_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like iscntrl but with an ignored `locale_t`. */ -int iscntrl_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isdigit but with an ignored `locale_t`. */ -int isdigit_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isgraph but with an ignored `locale_t`. */ -int isgraph_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like islower but with an ignored `locale_t`. */ -int islower_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isprint but with an ignored `locale_t`. */ -int isprint_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like ispunct but with an ignored `locale_t`. */ -int ispunct_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isspace but with an ignored `locale_t`. */ -int isspace_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isupper but with an ignored `locale_t`. */ -int isupper_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like isxdigit but with an ignored `locale_t`. */ -int isxdigit_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like tolower but with an ignored `locale_t`. */ -int tolower_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -/** Like toupper but with an ignored `locale_t`. */ -int toupper_l(int __ch, locale_t _Nonnull __l) __INTRODUCED_IN(21); -#else -// Implemented as static inlines in libc++ before 21. -#endif - -__END_DECLS diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/elf_common.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/elf_common.h index b3c57a28..0856f452 100644 --- a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/elf_common.h +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/elf_common.h @@ -1248,6 +1248,7 @@ /* * RISC-V relocation types. + * https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#relocations */ /* Relocation types used by the dynamic linker. */ @@ -1263,6 +1264,7 @@ #define R_RISCV_TLS_DTPREL64 9 #define R_RISCV_TLS_TPREL32 10 #define R_RISCV_TLS_TPREL64 11 +#define R_RISCV_TLSDESC 12 /* Relocation types not used by the dynamic linker. */ #define R_RISCV_BRANCH 16 @@ -1304,6 +1306,13 @@ #define R_RISCV_SET32 56 #define R_RISCV_32_PCREL 57 #define R_RISCV_IRELATIVE 58 +#define R_RISCV_PLT32 59 +#define R_RISCV_SET_ULEB128 60 +#define R_RISCV_SUB_ULEB128 61 +#define R_RISCV_TLSDESC_HI20 62 +#define R_RISCV_TLSDESC_LOAD_LO12 63 +#define R_RISCV_TLSDESC_ADD_LO12 64 +#define R_RISCV_TLSDESC_CALL 65 #define R_SPARC_NONE 0 #define R_SPARC_8 1 diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/getentropy.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/getentropy.h new file mode 100644 index 00000000..a5a14f71 --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/getentropy.h @@ -0,0 +1,53 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +/** + * @file bits/getentropy.h + * @brief The getentropy() function. + */ + +#include <sys/cdefs.h> +#include <sys/types.h> + +__BEGIN_DECLS + +/** + * [getentropy(3)](http://man7.org/linux/man-pages/man3/getentropy.3.html) fills the given buffer + * with random bytes. + * + * Returns 0 on success, and returns -1 and sets `errno` on failure. + * + * Available since API level 28. + * + * See also arc4random_buf() which is available in all API levels. + */ +int getentropy(void* _Nonnull __buffer, size_t __buffer_size) __wur __INTRODUCED_IN(28); + +__END_DECLS diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/glibc-syscalls.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/glibc-syscalls.h index 79f7da06..83fb2571 100644 --- a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/glibc-syscalls.h +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/glibc-syscalls.h @@ -60,6 +60,9 @@ #if defined(__NR_brk) #define SYS_brk __NR_brk #endif +#if defined(__NR_cachestat) + #define SYS_cachestat __NR_cachestat +#endif #if defined(__NR_capget) #define SYS_capget __NR_capget #endif @@ -219,6 +222,9 @@ #if defined(__NR_fchmodat) #define SYS_fchmodat __NR_fchmodat #endif +#if defined(__NR_fchmodat2) + #define SYS_fchmodat2 __NR_fchmodat2 +#endif #if defined(__NR_fchown) #define SYS_fchown __NR_fchown #endif @@ -300,12 +306,21 @@ #if defined(__NR_futex) #define SYS_futex __NR_futex #endif +#if defined(__NR_futex_requeue) + #define SYS_futex_requeue __NR_futex_requeue +#endif #if defined(__NR_futex_time64) #define SYS_futex_time64 __NR_futex_time64 #endif +#if defined(__NR_futex_wait) + #define SYS_futex_wait __NR_futex_wait +#endif #if defined(__NR_futex_waitv) #define SYS_futex_waitv __NR_futex_waitv #endif +#if defined(__NR_futex_wake) + #define SYS_futex_wake __NR_futex_wake +#endif #if defined(__NR_futimesat) #define SYS_futimesat __NR_futimesat #endif @@ -570,6 +585,9 @@ #if defined(__NR_madvise) #define SYS_madvise __NR_madvise #endif +#if defined(__NR_map_shadow_stack) + #define SYS_map_shadow_stack __NR_map_shadow_stack +#endif #if defined(__NR_mbind) #define SYS_mbind __NR_mbind #endif @@ -909,6 +927,9 @@ #if defined(__NR_riscv_flush_icache) #define SYS_riscv_flush_icache __NR_riscv_flush_icache #endif +#if defined(__NR_riscv_hwprobe) + #define SYS_riscv_hwprobe __NR_riscv_hwprobe +#endif #if defined(__NR_rmdir) #define SYS_rmdir __NR_rmdir #endif diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/page_size.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/page_size.h new file mode 100644 index 00000000..ca434e56 --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/page_size.h @@ -0,0 +1,40 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include <sys/cdefs.h> + +__BEGIN_DECLS + +#if !defined(__BIONIC_NO_PAGE_SIZE_MACRO) +#define PAGE_SIZE 4096 +#define PAGE_MASK (~(PAGE_SIZE - 1)) +#endif + +__END_DECLS diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/signal_types.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/signal_types.h index 699e2572..d98901c9 100644 --- a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/signal_types.h +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/signal_types.h @@ -28,18 +28,11 @@ #pragma once -#include <limits.h> #include <sys/cdefs.h> -#include <sys/types.h> -/* For 64-bit, the kernel's struct sigaction doesn't match the POSIX one, - * so we need to expose our own and translate behind the scenes. - * For 32-bit, we're stuck with the definitions we already shipped, - * even though they contain a sigset_t that's too small. See sigaction64. - */ -#define sigaction __kernel_sigaction +#include <limits.h> #include <linux/signal.h> -#undef sigaction +#include <sys/types.h> /* The arm and x86 kernel header files don't define _NSIG. */ #ifndef _KERNEL__NSIG @@ -64,8 +57,13 @@ typedef sigset_t sigset64_t; typedef struct { unsigned long __bits[_KERNEL__NSIG/(8*sizeof(long))]; } sigset64_t; #endif +/* The kernel's struct sigaction doesn't match the POSIX one. */ + #if defined(__LP64__) +/* For 64-bit, that's the only problem, and we only need two structs + * for source compatibility with 32-bit. */ + #define __SIGACTION_BODY \ int sa_flags; \ union { \ @@ -82,6 +80,12 @@ struct sigaction64 { __SIGACTION_BODY }; #else +/* For 32-bit, Android's ABIs used a too-small sigset_t that doesn't + * support RT signals, so we need two different structs. + */ + +/* The arm32 kernel headers also pollute the namespace with these, + * but our header scrubber doesn't know how to remove #defines. */ #undef sa_handler #undef sa_sigaction @@ -95,7 +99,6 @@ struct sigaction { void (*sa_restorer)(void); }; -/* This matches the kernel's internal structure. */ struct sigaction64 { union { sighandler_t sa_handler; diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/sockaddr_storage.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/sockaddr_storage.h new file mode 100644 index 00000000..effafab0 --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/sockaddr_storage.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +/** + * @file bits/sockaddr_storage.h + * @brief The `sockaddr_storage` struct. + */ + +#include <sys/cdefs.h> + +#include <bits/sa_family_t.h> + +#pragma clang diagnostic push +#pragma clang diagnostic ignored "-Wnullability-completeness" +/** + * [sockaddr_storage](https://man7.org/linux/man-pages/man3/sockaddr.3type.html) + * is a structure large enough to contain any other `sockaddr_*` type, used to + * pass socket addresses without needing to know what kind of socket address + * you're passing. + */ +struct sockaddr_storage { + union { + struct { + sa_family_t ss_family; + char __data[128 - sizeof(sa_family_t)]; + }; + void* __align; + }; +}; +#pragma clang diagnostic pop diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/tcphdr.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/tcphdr.h new file mode 100644 index 00000000..a9b6fe07 --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/tcphdr.h @@ -0,0 +1,71 @@ +/* + * Copyright (C) 2008 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include <sys/cdefs.h> +#include <stdint.h> + +__BEGIN_DECLS + +struct tcphdr { + __extension__ union { + struct { + uint16_t th_sport; + uint16_t th_dport; + uint32_t th_seq; + uint32_t th_ack; + uint8_t th_x2:4; + uint8_t th_off:4; + uint8_t th_flags; + uint16_t th_win; + uint16_t th_sum; + uint16_t th_urp; + }; + struct { + uint16_t source; + uint16_t dest; + uint32_t seq; + uint32_t ack_seq; + uint16_t res1:4; + uint16_t doff:4; + uint16_t fin:1; + uint16_t syn:1; + uint16_t rst:1; + uint16_t psh:1; + uint16_t ack:1; + uint16_t urg:1; + uint16_t res2:2; + uint16_t window; + uint16_t check; + uint16_t urg_ptr; + }; + }; +}; + +__END_DECLS diff --git a/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/termios_winsize_inlines.h b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/termios_winsize_inlines.h new file mode 100644 index 00000000..ae246e40 --- /dev/null +++ b/mainline/runtime/sdk/linux_bionic/include/bionic/libc/include/bits/termios_winsize_inlines.h @@ -0,0 +1,52 @@ +/* + * Copyright (C) 2023 The Android Open Source Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS + * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE + * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, + * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, + * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS + * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED + * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, + * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT + * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ + +#pragma once + +#include <errno.h> +#include <sys/cdefs.h> +#include <sys/ioctl.h> +#include <sys/types.h> + +#include <linux/termios.h> + +#if !defined(__BIONIC_TERMIOS_WINSIZE_INLINE) +#define __BIONIC_TERMIOS_WINSIZE_INLINE static __inline +#endif + +__BEGIN_DECLS + +__BIONIC_TERMIOS_WINSIZE_INLINE int tcgetwinsize(int __fd, struct winsize* _Nonnull __size) { + return ioctl(__fd, TIOCGWINSZ, __size); +} + +__BIONIC_TERMIOS_WINSIZE_INLINE int tcsetwinsize(int __fd, const struct winsize* _Nonnull __size) { + return ioctl(__fd, TIOCSWINSZ, __size); +} + +__END_DECLS |