Merge "Add tid to trace info if available" into main
diff --git a/Android.mk b/Android.mk
deleted file mode 100644
index 888404c..0000000
--- a/Android.mk
+++ /dev/null
@@ -1,4 +0,0 @@
-LOCAL_PATH := $(call my-dir)
-
-include $(call all-makefiles-under,$(LOCAL_PATH))
-
diff --git a/README.md b/README.md
index 0ad06a8..953e983 100644
--- a/README.md
+++ b/README.md
@@ -1,15 +1,11 @@
-# bionic
+# bionic maintainer overview
[bionic](https://en.wikipedia.org/wiki/Bionic_(software)) is Android's
C library, math library, and dynamic linker.
-# Using bionic as an app developer
-
-See the [user documentation](docs/).
-
-# Working on bionic itself
-
-This documentation is about making changes to bionic itself.
+This document is a high-level overview of making changes to bionic itself.
+If you're trying to _use_ bionic, or want more in-depth information about
+some part of the implementation, see [all the bionic documentation](docs/).
## What are the big pieces of bionic?
@@ -181,7 +177,7 @@
library that would make more sense as the place to add the wrapper.
In all other cases, you should use
-[syscall(3)](http://man7.org/linux/man-pages/man2/syscall.2.html) instead.
+[syscall(3)](https://man7.org/linux/man-pages/man2/syscall.2.html) instead.
Adding a system call usually involves:
diff --git a/android-changes-for-ndk-developers.md b/android-changes-for-ndk-developers.md
index 8d507d1..e9cfbac 100644
--- a/android-changes-for-ndk-developers.md
+++ b/android-changes-for-ndk-developers.md
@@ -445,6 +445,18 @@
| No `dlclose` | Works | Works | Works |
+## ELF TLS (Available for API level >= 29)
+
+Android supports [ELF TLS](docs/elf-tls.md) starting at API level 29. Since
+NDK r26, clang will automatically enable ELF TLS for `minSdkVersion 29` or
+higher. Otherwise, the existing emutls implementation (which uses
+`pthread_key_create()` behind the scenes) will continue to be used. This
+means that convenient C/C++ thread-local syntax is available at any API level;
+at worst it will perform similarly to "roll your own" thread locals using
+`pthread_key_create()` but at best you'll get the performance benefit of
+ELF TLS, and the NDK will take care of the details.
+
+
## Use of IFUNC in libc (True for all API levels on devices running Android 10)
On devices running API level 29, libc uses
diff --git a/benchmarks/README.md b/benchmarks/README.md
index 3819b1a..319db25 100644
--- a/benchmarks/README.md
+++ b/benchmarks/README.md
@@ -19,6 +19,12 @@
By default, `bionic-benchmarks` runs all of the benchmarks in alphabetical order. Pass
`--benchmark_filter=getpid` to run just the benchmarks with "getpid" in their name.
+Note that we also build _static_ benchmark binaries.
+They're useful for testing on devices running different versions of Android, or running non-Android OSes.
+Those binaries are called `bionic-benchmarks-static` instead.
+Copy from `out/target/product/<device>/symbols/data/benchmarktest64/bionic-benchmarks-static` instead of
+`out/target/product/<device>/data/benchmarktest64/bionic-benchmarks-static` if you want symbols for perf(1).
+
### Host benchmarks
See the `benchmarks/run-on-host.sh` script. The host benchmarks can be run with 32-bit or 64-bit
@@ -183,6 +189,5 @@
Some devices have a `perf-setup.sh` script that locks CPU and GPU frequencies. Some TradeFed
benchmarks appear to be using the script. For more information:
- * run `get_build_var BOARD_PERFSETUP_SCRIPT`
- * run `m perf-setup` to install the script into `${OUT}/data/local/tmp/perf-setup.sh`
+ * run `adb shell perf-setup.sh` to execute the script, it is already by default be installed on device for eng and userdebug build
* see: https://android.googlesource.com/platform/platform_testing/+/refs/heads/main/scripts/perf-setup/
diff --git a/benchmarks/bionic_benchmarks.cpp b/benchmarks/bionic_benchmarks.cpp
index 81f1842..b88c6e5 100644
--- a/benchmarks/bionic_benchmarks.cpp
+++ b/benchmarks/bionic_benchmarks.cpp
@@ -372,7 +372,7 @@
void RegisterGoogleBenchmarks(bench_opts_t primary_opts, bench_opts_t secondary_opts,
const std::string& fn_name, args_vector_t* run_args) {
- if (g_str_to_func.find(fn_name) == g_str_to_func.end()) {
+ if (!g_str_to_func.contains(fn_name)) {
errx(1, "ERROR: No benchmark for function %s", fn_name.c_str());
}
long iterations_to_use = primary_opts.num_iterations ? primary_opts.num_iterations :
diff --git a/benchmarks/ctype_benchmark.cpp b/benchmarks/ctype_benchmark.cpp
index c6c23b0..b162ea7 100644
--- a/benchmarks/ctype_benchmark.cpp
+++ b/benchmarks/ctype_benchmark.cpp
@@ -16,81 +16,47 @@
#include <ctype.h>
+#include <array>
+#include <numeric>
+#include <random>
+
#include <benchmark/benchmark.h>
#include "util.h"
-// Avoid optimization.
-volatile int A = 'A';
-volatile int a = 'a';
-volatile int X = 'X';
-volatile int x = 'x';
-volatile int backspace = '\b';
-volatile int del = '\x7f';
-volatile int space = ' ';
-volatile int tab = '\t';
-volatile int zero = '0';
-volatile int underscore = '_';
-volatile int top_bit_set = 0x88;
+static std::array<int, 128> RandomAscii() {
+ std::array<int, 128> result;
+ std::iota(result.begin(), result.end(), 0);
+ std::shuffle(result.begin(), result.end(), std::mt19937{std::random_device{}()});
+ return result;
+}
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y1, isalnum(A));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y2, isalnum(a));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_y3, isalnum(zero));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalnum_n, isalnum(underscore));
+#define CTYPE_BENCHMARK(__benchmark, fn) \
+ static void __benchmark##_##fn(benchmark::State& state) { \
+ auto chars = RandomAscii(); \
+ for (auto _ : state) { \
+ for (char ch : chars) { \
+ benchmark::DoNotOptimize(fn(ch)); \
+ } \
+ } \
+ state.SetBytesProcessed(state.iterations() * chars.size()); \
+ } \
+ BIONIC_BENCHMARK(__benchmark##_##fn)
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_y1, isalpha(A));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_y2, isalpha(a));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isalpha_n, isalpha(underscore));
+CTYPE_BENCHMARK(BM_ctype, isalpha);
+CTYPE_BENCHMARK(BM_ctype, isalnum);
+CTYPE_BENCHMARK(BM_ctype, isascii);
+CTYPE_BENCHMARK(BM_ctype, isblank);
+CTYPE_BENCHMARK(BM_ctype, iscntrl);
+CTYPE_BENCHMARK(BM_ctype, isgraph);
+CTYPE_BENCHMARK(BM_ctype, islower);
+CTYPE_BENCHMARK(BM_ctype, isprint);
+CTYPE_BENCHMARK(BM_ctype, ispunct);
+CTYPE_BENCHMARK(BM_ctype, isspace);
+CTYPE_BENCHMARK(BM_ctype, isupper);
+CTYPE_BENCHMARK(BM_ctype, isxdigit);
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isascii_y, isascii(x));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isascii_n, isascii(top_bit_set));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_y1, isblank(space));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_y2, isblank(tab));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isblank_n, isblank(underscore));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_y1, iscntrl(backspace));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_y2, iscntrl(del));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_iscntrl_n, iscntrl(underscore));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isdigit_y, iscntrl(zero));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isdigit_n, iscntrl(underscore));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y1, isgraph(A));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y2, isgraph(a));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y3, isgraph(zero));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_y4, isgraph(underscore));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isgraph_n, isgraph(space));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_islower_y, islower(x));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_islower_n, islower(X));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y1, isprint(A));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y2, isprint(a));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y3, isprint(zero));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y4, isprint(underscore));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_y5, isprint(space));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isprint_n, isprint(backspace));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_ispunct_y, ispunct(underscore));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_ispunct_n, ispunct(A));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_y1, isspace(space));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_y2, isspace(tab));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isspace_n, isspace(A));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isupper_y, isupper(X));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isupper_n, isupper(x));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y1, isxdigit(zero));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y2, isxdigit(a));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_y3, isxdigit(A));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_isxdigit_n, isxdigit(underscore));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toascii_y, isascii(x));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toascii_n, isascii(top_bit_set));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_tolower_y, tolower(X));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_tolower_n, tolower(x));
-
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toupper_y, toupper(x));
-BIONIC_TRIVIAL_BENCHMARK(BM_ctype_toupper_n, toupper(X));
+CTYPE_BENCHMARK(BM_ctype, toascii);
+CTYPE_BENCHMARK(BM_ctype, tolower);
+CTYPE_BENCHMARK(BM_ctype, _tolower);
+CTYPE_BENCHMARK(BM_ctype, toupper);
+CTYPE_BENCHMARK(BM_ctype, _toupper);
diff --git a/benchmarks/linker_relocation/include/linker_reloc_bench_asm.h b/benchmarks/linker_relocation/include/linker_reloc_bench_asm.h
index 885e47f..ea63e36 100644
--- a/benchmarks/linker_relocation/include/linker_reloc_bench_asm.h
+++ b/benchmarks/linker_relocation/include/linker_reloc_bench_asm.h
@@ -44,9 +44,7 @@
#elif defined(__riscv)
-// No `lga` in clang unless https://reviews.llvm.org/D107278 lands.
-// `la` is equivalent when using PIC (which we do) though.
-#define GOT_RELOC(sym) la a0, sym
+#define GOT_RELOC(sym) lga a0, sym
#define CALL(sym) call sym@plt
#define DATA_WORD(val) .quad val
#define MAIN .globl main; main: li a0, 0; ret
diff --git a/benchmarks/property_benchmark.cpp b/benchmarks/property_benchmark.cpp
index 1b4ba23..b356ab7 100644
--- a/benchmarks/property_benchmark.cpp
+++ b/benchmarks/property_benchmark.cpp
@@ -28,8 +28,7 @@
#if defined(__BIONIC__)
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
+#include <sys/system_properties.h>
#include <benchmark/benchmark.h>
#include <system_properties/system_properties.h>
diff --git a/benchmarks/util.h b/benchmarks/util.h
index 99eed5f..347dc35 100644
--- a/benchmarks/util.h
+++ b/benchmarks/util.h
@@ -71,7 +71,7 @@
bool LockToCPU(int cpu_to_lock);
-static __inline __attribute__ ((__always_inline__)) void MakeAllocationResident(
+static inline __attribute__((__always_inline__)) void MakeAllocationResident(
void* ptr, size_t nbytes, int pagesize) {
uint8_t* data = reinterpret_cast<uint8_t*>(ptr);
for (size_t i = 0; i < nbytes; i += pagesize) {
diff --git a/benchmarks/wctype_benchmark.cpp b/benchmarks/wctype_benchmark.cpp
index cdf5568..cf96057 100644
--- a/benchmarks/wctype_benchmark.cpp
+++ b/benchmarks/wctype_benchmark.cpp
@@ -16,17 +16,73 @@
#include <wctype.h>
+#include <numeric>
+#include <random>
+#include <vector>
+
#include <benchmark/benchmark.h>
#include "util.h"
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towlower_ascii_y, towlower('X'));
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towlower_ascii_n, towlower('x'));
+static std::vector<wint_t> RandomAscii() {
+ std::vector<wint_t> result(128);
+ std::iota(result.begin(), result.end(), 0);
+ std::shuffle(result.begin(), result.end(), std::mt19937{std::random_device{}()});
+ return result;
+}
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towlower_unicode_y, towlower(0x0391));
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towlower_unicode_n, towlower(0x03b1));
+static std::vector<wint_t> RandomNonAscii() {
+ std::vector<wint_t> result;
+ std::mt19937 rng{std::random_device{}()};
+ std::uniform_int_distribution<> d(0x80, 0xffff);
+ for (size_t i = 0; i < 128; i++) result.push_back(d(rng));
+ return result;
+}
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towupper_ascii_y, towupper('x'));
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towupper_ascii_n, towupper('X'));
+#define WCTYPE_BENCHMARK(__benchmark, fn, random_fn) \
+ static void __benchmark##_##fn(benchmark::State& state) { \
+ auto chars = random_fn(); \
+ for (auto _ : state) { \
+ for (char ch : chars) { \
+ benchmark::DoNotOptimize(fn(ch)); \
+ } \
+ } \
+ state.SetBytesProcessed(state.iterations() * chars.size()); \
+ } \
+ BIONIC_BENCHMARK(__benchmark##_##fn)
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towupper_unicode_y, towupper(0x03b1));
-BIONIC_TRIVIAL_BENCHMARK(BM_wctype_towupper_unicode_n, towupper(0x0391));
+#define WCTYPE_BENCHMARK_ASCII(__benchmark, fn) WCTYPE_BENCHMARK(__benchmark, fn, RandomAscii)
+
+#define WCTYPE_BENCHMARK_NON_ASCII(__benchmark, fn) \
+ WCTYPE_BENCHMARK(__benchmark, fn, RandomNonAscii)
+
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswalnum);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswalpha);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswblank);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswcntrl);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswdigit);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswgraph);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswlower);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswprint);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswpunct);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswspace);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswupper);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii, iswxdigit);
+
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii_transform, towlower);
+WCTYPE_BENCHMARK_ASCII(BM_wctype_ascii_transform, towupper);
+
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswalnum);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswalpha);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswblank);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswcntrl);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswdigit);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswgraph);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswlower);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswprint);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswpunct);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswspace);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswupper);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii, iswxdigit);
+
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii_transform, towlower);
+WCTYPE_BENCHMARK_NON_ASCII(BM_wctype_non_ascii_transform, towupper);
diff --git a/cpu_target_features/Android.bp b/cpu_target_features/Android.bp
new file mode 100644
index 0000000..25f37d1
--- /dev/null
+++ b/cpu_target_features/Android.bp
@@ -0,0 +1,18 @@
+package {
+ default_applicable_licenses: ["Android-Apache-2.0"],
+}
+
+cc_binary {
+ name: "cpu-target-features",
+ srcs: [
+ "main.cpp",
+ ],
+ generated_headers: ["print_target_features.inc"],
+}
+
+genrule {
+ name: "print_target_features.inc",
+ out: ["print_target_features.inc"],
+ tool_files: ["generate_printer.py"],
+ cmd: "$(location generate_printer.py) $(out)",
+}
diff --git a/cpu_target_features/generate_printer.py b/cpu_target_features/generate_printer.py
new file mode 100755
index 0000000..dc56eb5
--- /dev/null
+++ b/cpu_target_features/generate_printer.py
@@ -0,0 +1,107 @@
+#!/usr/bin/env python3
+
+"""Generate the compilation target feature printing source code.
+
+The source code for detecting target features is heavily redundant and
+copy-pasted, and is easier to maintain using a generative script.
+
+This script creates the source and the include files in its current
+directory.
+"""
+
+import argparse
+from pathlib import Path
+from typing import Dict, List, Iterable
+
+_CPP_BOILERPLATE: str = """\
+#include <stdio.h>
+
+#define TO_STRING_EXP(DEF) #DEF
+#define TO_STRING(DEF) TO_STRING_EXP(DEF)
+"""
+
+_FEATURES = {
+ "Aarch64": [
+ "__ARM_FEATURE_AES",
+ "__ARM_FEATURE_BTI",
+ "__ARM_FEATURE_CRC32",
+ "__ARM_FEATURE_CRYPTO",
+ "__ARM_FEATURE_PAC_DEFAULT",
+ "__ARM_FEATURE_SHA2",
+ "__ARM_FEATURE_SHA3",
+ "__ARM_FEATURE_SHA512",
+ ],
+ "Arm32": [
+ "__ARM_ARCH_ISA_THUMB",
+ "__ARM_FEATURE_AES",
+ "__ARM_FEATURE_BTI",
+ "__ARM_FEATURE_CRC32",
+ "__ARM_FEATURE_CRYPTO",
+ "__ARM_FEATURE_PAC_DEFAULT",
+ "__ARM_FEATURE_SHA2",
+ ],
+ "X86": [
+ "__AES__",
+ "__AVX__",
+ "__CRC32__",
+ "__POPCNT__",
+ "__SHA512__",
+ "__SHA__",
+ ],
+ "Riscv": [
+ "__riscv_vector",
+ ],
+}
+
+
+def _make_function_sig(name: str) -> str:
+ return f"void print{name}TargetFeatures()"
+
+
+def check_template(define: str) -> List[str]:
+ return [
+ f"#if defined({define})",
+ f' printf("%s=%s\\n", TO_STRING_EXP({define}), TO_STRING({define}));',
+ "#else",
+ f' printf("%s not defined\\n", TO_STRING_EXP({define}));',
+ "#endif",
+ ]
+
+
+def generate_cpp_file(define_mapping: Dict[str, List[str]]) -> List[str]:
+ out: List[str] = _CPP_BOILERPLATE.split("\n")
+ for target, defines in define_mapping.items():
+ out.append("")
+ out.extend(generate_print_function(target, defines))
+ return out
+
+
+def generate_print_function(name: str, defines: List[str]) -> List[str]:
+ """Generate a print<DEFINE>TargetFeatures function."""
+ function_body = [_make_function_sig(name) + " {"]
+ for d in defines:
+ function_body.extend(check_template(d))
+ function_body.append("}")
+ return function_body
+
+
+def parse_args() -> argparse.Namespace:
+ parser = argparse.ArgumentParser(description=__doc__)
+ parser.add_argument(
+ "cpp_in",
+ type=Path,
+ help="Output path to generate the cpp file.",
+ )
+ return parser.parse_args()
+
+
+def main() -> None:
+ args = parse_args()
+ printer_cpp_filepath = args.cpp_in
+ printer_cpp_filepath.write_text(
+ "\n".join(generate_cpp_file(_FEATURES)), encoding="utf-8"
+ )
+
+
+if __name__ == "__main__":
+ main()
diff --git a/cpu_target_features/main.cpp b/cpu_target_features/main.cpp
new file mode 100644
index 0000000..61f3d25
--- /dev/null
+++ b/cpu_target_features/main.cpp
@@ -0,0 +1,37 @@
+/*
+ * Copyright (C) 2024 The Android Open Source Project
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+#include <stdio.h>
+
+#include "print_target_features.inc"
+
+int main() {
+#if defined(__aarch64__)
+ printAarch64TargetFeatures();
+ return 0;
+#elif defined(__arm__)
+ printArm32TargetFeatures();
+ return 0;
+#elif defined(__x86_64__) || defined(__i386__)
+ printX86TargetFeatures();
+ return 0;
+#elif defined(__riscv)
+ printRiscvTargetFeatures();
+ return 0;
+#else
+#error Unsupported arch. This binary only supports aarch64, arm, x86, x86-64, and risc-v
+#endif
+}
diff --git a/docs/README.md b/docs/README.md
new file mode 100644
index 0000000..2825eac
--- /dev/null
+++ b/docs/README.md
@@ -0,0 +1,34 @@
+# bionic documentation
+
+[bionic](https://en.wikipedia.org/wiki/Bionic_(software)) is Android's
+C library, math library, and dynamic linker.
+
+## User documentation
+
+* [Android bionic status](status.md) - where we are in terms of standards,
+ and what changed with each OS release.
+* [32-bit ABI bugs](32-bit-abi.md) - historical accidents we can never fix.
+* [`EINTR`](EINTR.md) - what is the `EINTR` failure,
+ and how can code deal with it?
+* [When to use which `#define`](defines.md) - how to choose between
+ `__ANDROID__` and `__BIONIC__` and all the other options for conditional
+ compilation.
+* [fdsan](fdsan.md) - bionic's file descriptor sanitizer,
+ which detects use-after-close() bugs.
+* [fdtrack](fdtrack.md) - bionic's file descriptor tracker,
+ which helps debug file descriptor leaks.
+
+## Maintainer documentation
+
+If you're trying to make changes to bionic _itself_, start with the
+[bionic maintainer documentation](../README.md).
+
+We also have more detail on several specific parts of the implementation:
+
+* [The anatomy of bionic's `_FORTIFY_SOURCE`](clang_fortify_anatomy.md) -
+ how does `_FORTIFY_SOURCE` work on bionic (primarily "with clang").
+* [Android ELF TLS](elf-tls.md) - details of bionic's ELF TLS implementation.
+* [Validating libc assembler](libc_assembler.md) - how to test changes to
+ libc assembler routines.
+* [Validating native allocator changes](native_allocator.md) - how to test
+ changes to the native allocator.
diff --git a/docs/elf-tls.md b/docs/elf-tls.md
index d408b3f..450f362 100644
--- a/docs/elf-tls.md
+++ b/docs/elf-tls.md
@@ -1,9 +1,10 @@
-# Android ELF TLS (Draft)
+# Android ELF TLS
-Internal links:
- * [go/android-elf-tls](http://go/android-elf-tls)
- * [One-pager](https://docs.google.com/document/d/1leyPTnwSs24P2LGiqnU6HetnN5YnDlZkihigi6qdf_M)
- * Tracking bugs: http://b/110100012, http://b/78026329
+App developers probably just want to read the
+[quick ELS TLS status summary](../android-changes-for-ndk-developers.md#elf-tls-available-for-api-level-29)
+instead.
+
+This document covers the detailed design and implementation choices.
[TOC]
@@ -215,7 +216,7 @@
* https://bugzilla.redhat.com/show_bug.cgi?id=1124987
* web search: [`"dlopen: cannot load any more object with static TLS"`][glibc-static-tls-error]
-Neither musl nor the Bionic TLS prototype currently allocate any surplus TLS memory.
+Neither bionic nor musl currently allocate any surplus TLS memory.
In general, supporting surplus TLS memory probably requires maintaining a thread list so that
`dlopen` can initialize the new static TLS memory in all existing threads. A thread list could be
@@ -489,19 +490,6 @@
[quietly ignored]: https://android.googlesource.com/platform/bionic/+/android-8.1.0_r48/linker/linker.cpp#2784
[added compatibility checks]: https://android-review.googlesource.com/c/platform/bionic/+/648760
-# Bionic Prototype Notes
-
-There is an [ELF TLS prototype] uploaded on Gerrit. It implements:
- * Static TLS Block allocation for static and dynamic executables
- * TLS for dynamically loaded and unloaded modules (`__tls_get_addr`)
- * TLSDESC for arm64 only
-
-Missing:
- * `dlsym` of a TLS variable
- * debugger support
-
-[ELF TLS prototype]: https://android-review.googlesource.com/q/topic:%22elf-tls-prototype%22+(status:open%20OR%20status:merged)
-
## Loader/libc Communication
The loader exposes a list of TLS modules ([`struct TlsModules`][TlsModules]) to `libc.so` using the
@@ -515,13 +503,14 @@
## TLS Allocator
-The prototype currently allocates a `pthread_internal_t` object and static TLS in a single mmap'ed
+bionic currently allocates a `pthread_internal_t` object and static TLS in a single mmap'ed
region, along with a thread's stack if it needs one allocated. It doesn't place TLS memory on a
preallocated stack (either the main thread's stack or one provided with `pthread_attr_setstack`).
The DTV and blocks for dlopen'ed modules are instead allocated using the Bionic loader's
-`LinkerMemoryAllocator`, adapted to avoid the STL and to provide `memalign`. The prototype tries to
-achieve async-signal safety by blocking signals and acquiring a lock.
+`LinkerMemoryAllocator`, adapted to avoid the STL and to provide `memalign`.
+The implementation tries to achieve async-signal safety by blocking signals and
+acquiring a lock.
There are three "entry points" to dynamically locate a TLS variable's address:
* libc.so: `__tls_get_addr`
@@ -529,10 +518,10 @@
* loader: dlsym
The loader's entry points need to call `__tls_get_addr`, which needs to allocate memory. Currently,
-the prototype uses a [special function pointer] to call libc.so's `__tls_get_addr` from the loader.
+the implementation uses a [special function pointer] to call libc.so's `__tls_get_addr` from the loader.
(This should probably be removed.)
-The prototype currently allows for arbitrarily-large TLS variable alignment. IIRC, different
+The implementation currently allows for arbitrarily-large TLS variable alignment. IIRC, different
implementations (glibc, musl, FreeBSD) vary in their level of respect for TLS alignment. It looks
like the Bionic loader ignores segments' alignment and aligns loaded libraries to 256 KiB. See
`ReserveAligned`.
@@ -541,7 +530,7 @@
## Async-Signal Safety
-The prototype's `__tls_get_addr` might be async-signal safe. Making it AS-safe is a good idea if
+The implementation's `__tls_get_addr` might be async-signal safe. Making it AS-safe is a good idea if
it's feasible. musl's function is AS-safe, but glibc's isn't (or wasn't). Google had a patch to make
glibc AS-safe back in 2012-2013. See:
* https://sourceware.org/glibc/wiki/TLSandSignals
@@ -550,7 +539,7 @@
## Out-of-Memory Handling (abort)
-The prototype lazily allocates TLS memory for dlopen'ed modules (see `__tls_get_addr`), and an
+The implementation lazily allocates TLS memory for dlopen'ed modules (see `__tls_get_addr`), and an
out-of-memory error on a TLS access aborts the process. musl, on the other hand, preallocates TLS
memory on `pthread_create` and `dlopen`, so either function can return out-of-memory. Both functions
probably need to acquire the same lock.
@@ -572,7 +561,7 @@
FWIW: emutls also aborts on out-of-memory.
-## ELF TLS Not Usable in libc
+## ELF TLS Not Usable in libc Itself
The dynamic loader currently can't use ELF TLS, so any part of libc linked into the loader (i.e.
most of it) also can't use ELF TLS. It might be possible to lift this restriction, perhaps with
@@ -649,7 +638,7 @@
It seems easy to fix the incompatibility for variant 2 (x86 and x86_64) by splitting out the Bionic
slots into a new data structure. Variant 1 is a harder problem.
-The TLS prototype currently uses a patched LLD that uses a variant 1 TLS layout with a 16-word TCB
+The TLS prototype used a patched LLD that uses a variant 1 TLS layout with a 16-word TCB
on all architectures.
Aside: gcc's arm64ilp32 target uses a 32-bit unsigned offset for a TLS IE access
@@ -821,8 +810,8 @@
### Workaround for Go: place pthread keys after the executable's TLS
-Most Android executables do not use any `thread_local` variables. In the current prototype, with the
-AOSP hikey960 build, only `/system/bin/netd` has a TLS segment, and it's only 32 bytes. As long as
+Most Android executables do not use any `thread_local` variables. In the prototype, with the
+AOSP hikey960 build, only `/system/bin/netd` had a TLS segment, and it was only 32 bytes. As long as
`/system/bin/app_process{32,64}` limits its use of TLS memory, then the pthread keys could be
allocated after `app_process`' TLS segment, and Go will still find them.
@@ -847,6 +836,12 @@
* It looks like glibc's ld.so re-relocates itself after loading a program, so a program's symbols
can interpose call in the loader: https://sourceware.org/ml/libc-alpha/2014-01/msg00501.html
+## TODO: Other
+
+Missing:
+ * `dlsym` of a TLS variable
+ * debugger support
+
# References
General (and x86/x86-64)
diff --git a/docs/fdsan.md b/docs/fdsan.md
index f5d1ab5..5aeb7de 100644
--- a/docs/fdsan.md
+++ b/docs/fdsan.md
@@ -62,7 +62,9 @@
- fatal (`ANDROID_FDSAN_ERROR_LEVEL_FATAL`)
- Abort upon detecting an error.
-In Android Q, fdsan has a global default of warn-once. fdsan can be made more or less strict at runtime via the `android_fdsan_set_error_level` function in [`<android/fdsan.h>`](https://android.googlesource.com/platform/bionic/+/main/libc/include/android/fdsan.h).
+In API level 29, fdsan had a global default of warn-once.
+In API level 30 and higher, fdsan has a global default of fatal.
+fdsan can be made more or less strict at runtime via the `android_fdsan_set_error_level` function in [`<android/fdsan.h>`](https://android.googlesource.com/platform/bionic/+/main/libc/include/android/fdsan.h).
The likelihood of fdsan catching a file descriptor error is proportional to the percentage of file descriptors in your process that are tagged with an owner.
@@ -344,7 +346,8 @@
// These functions are marked with __attribute__((weak)), so that their
// availability can be determined at runtime. These wrappers will use them
- // if available, and fall back to no-ops or regular close on pre-Q devices.
+ // if available, and fall back to no-ops or regular close on devices older
+ // than API level 29.
static void exchange_tag(int fd, uint64_t old_tag, uint64_t new_tag) {
if (android_fdsan_exchange_owner_tag) {
android_fdsan_exchange_owner_tag(fd, old_tag, new_tag);
diff --git a/docs/fdtrack.md b/docs/fdtrack.md
index 07c69b3..8928a5c 100644
--- a/docs/fdtrack.md
+++ b/docs/fdtrack.md
@@ -4,9 +4,11 @@
fdtrack is a file descriptor leak checker added to Android in API level 30.
-fdtrack consists of two parts: a set of hooks in bionic to register a callback
-that's invoked on file descriptor operations, and a library that implements a
-hook to perform and store backtraces for file descriptor creation.
+fdtrack consists of several parts: a set of hooks in bionic to register a
+callback that's invoked on file descriptor operations, a library that implements
+a hook to perform and store backtraces for file descriptor creation, and
+code in frameworks to automatically enable it (and deliberately crash a process
+that's leaking).
### bionic hooks
bionic provides a header in the `bionic_libc_platform_headers` header_lib at <[bionic/fdtrack.h](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libc/platform/bionic/fdtrack.h)>.
@@ -21,6 +23,28 @@
[libfdtrack](https://android.googlesource.com/platform/bionic/+/refs/heads/main/libfdtrack)
implements a library that uses libunwindstack to unwind and store fd creation backtraces.
+### frameworks
+As the name implies, `spawnFdLeakCheckThread` in SystemServer spawns a thread
+to monitor the number of open file descriptors every so often.
+If that passes a certain threshold, fdtrack is enabled.
+If it passes another threshold, the process is aborted.
+These thresholds are configurable via system properties:
+```
+ // Number of open file descriptors before fdtrack starts; default 1600.
+ private static final String SYSPROP_FDTRACK_ENABLE_THRESHOLD =
+ "persist.sys.debug.fdtrack_enable_threshold";
+
+ // Number of open file descriptors before aborting; default 3000.
+ private static final String SYSPROP_FDTRACK_ABORT_THRESHOLD =
+ "persist.sys.debug.fdtrack_abort_threshold";
+
+ // Number of seconds between open fd count checks; default 120s.
+ private static final String SYSPROP_FDTRACK_INTERVAL =
+ "persist.sys.debug.fdtrack_interval";
+```
+Note that it's also possible to monitor the number of open file descriptors for
+a given process from the shell. `adb shell watch ls -l /proc/<pid>/fd` will show
+them (and you can choose your own update rate as an argument to `watch`).
#### Using libfdtrack
libfdtrack registers its hook upon being loaded, so to start capturing
diff --git a/docs/status.md b/docs/status.md
index 2919471..94784de 100644
--- a/docs/status.md
+++ b/docs/status.md
@@ -32,10 +32,14 @@
* `ualarm`
Missing functionality:
- * `<aio.h>`
+ * `<aio.h>`. No particular reason not to have this other than that no-one's
+ needed it yet, and it's relatively complex. If/when llvm-libc adds this,
+ maybe we'll just reuse that.
* `<monetary.h>`. See
[discussion](https://github.com/android/ndk/issues/1182).
- * `<wordexp.h>`
+ * `<wordexp.h>`. Unsafe because it passes user input to the shell (!),
+ and often should just be a call to glob() anyway. See also
+ [OpenBSD's discussion about adding wordexp()](https://www.mail-archive.com/tech@openbsd.org/msg02325.html).
* Locales. Although bionic contains the various `_l()` functions, the only
locale supported is a UTF-8 C/POSIX locale. Most of the POSIX APIs are
insufficient to support the wide range of languages used by Android users,
@@ -55,6 +59,11 @@
Current libc symbols: https://android.googlesource.com/platform/bionic/+/main/libc/libc.map.txt
+New libc functions in API level 36:
+ * `qsort_r`, `sig2str`/`str2sig` (POSIX Issue 8 additions).
+ * GNU/BSD extension `lchmod`.
+ * New system call wrapper: `mseal` (`<sys/mman.h>`).
+
New libc functions in V (API level 35):
* New `android_crash_detail_register`, `android_crash_detail_unregister`,
`android_crash_detail_replace_name`, and `android_crash_detail_replace_data`
@@ -125,6 +134,7 @@
* `getloadavg` (BSD/GNU extension in <stdlib.h>)
New libc behavior in Q (API level 29):
+ * Support for [ELF TLS](elf-tls.md).
* Whole printf family now supports the GNU `%m` extension, rather than a
special-case hack in `syslog`.
* `popen` now always uses `O_CLOEXEC`, not just with the `e` extension.
@@ -282,23 +292,31 @@
libc function count over time:
-| OS | API level | Function count |
-|-------|-----------|----------------|
-| J | 16 | 842 |
-| J MR1 | 17 | 870 |
-| J MR2 | 18 | 878 |
-| K | 19 | 893 |
-| L | 21 | 1118 |
-| M | 23 | 1183 |
-| N | 24 | 1228 |
-| O | 26 | 1280 |
-| P | 28 | 1378 |
-| Q | 29 | 1394 |
+| API level | Function count |
+|-----------|----------------|
+| 16 | 842 |
+| 17 | 870 |
+| 18 | 878 |
+| 19 | 893 |
+| 21 | 1016 |
+| 22 | 1038 |
+| 23 | 1103 |
+| 24 | 1147 |
+| 25 | 1147 |
+| 26 | 1199 |
+| 27 | 1199 |
+| 28 | 1298 |
+| 29 | 1312 |
+| 30 | 1368 |
+| 31 | 1379 |
+| 32 | 1379 |
+| 33 | 1386 |
+| 34 | 1392 |
Data collected by:
```
-ndk-r21$ for i in `ls -1v platforms/android-*/arch-arm/usr/lib/libc.so` ; do \
- echo $i; nm $i | grep -w T | wc -l ; done
+ndk-r26c$ for i in `ls -1v toolchains/llvm/prebuilt/linux-x86_64/sysroot/usr/lib/aarch64-linux-android/*/libc.so` ; \
+ do echo $i; nm $i | grep -w T | wc -l ; done
```
### libm
@@ -397,22 +415,25 @@
overrun is detected, the program is safely aborted as in this
[example](https://source.android.com/devices/tech/debug/native-crash#fortify).
-Note that in recent releases Android's FORTIFY has been extended to
-cover other issues. It can now detect, for example, passing `O_CREAT`
-to open(2) without specifying a mode. It also performs some checking
-regardless of whether the caller was built with FORTIFY enabled. In P,
-for example, calling a `pthread_mutex_` function on a destroyed mutex,
-calling a `<dirent.h>` function on a null pointer, using `%n` with the
-printf(3) family, or using the scanf(3) `m` modifier incorrectly will
-all result in FORTIFY failures even for code not built with FORTIFY.
+Note that Android's FORTIFY has been extended to cover other issues. It can
+detect, for example, passing `O_CREAT` to open(2) without specifying a mode. It
+also performs some checking regardless of whether the caller was built with
+FORTIFY enabled. From API level 28, for example, calling a `pthread_mutex_`
+function on a destroyed mutex, calling a `<dirent.h>` function on a null
+pointer, using `%n` with the printf(3) family, or using the scanf(3) `m`
+modifier incorrectly will all result in FORTIFY failures even for code not built
+with FORTIFY.
More background information is available in our
[FORTIFY in Android](https://android-developers.googleblog.com/2017/04/fortify-in-android.html)
-blog post.
+blog post, and there's more detail about the implementation in
+[The Anatomy of Clang FORTIFY](clang_fortify_anatomy.md).
-The Android platform is built with `-D_FORTIFY_SOURCE=2`, but NDK users
-need to manually enable FORTIFY by setting that themselves in whatever
-build system they're using. The exact subset of FORTIFY available to
+The Android platform is built with `-D_FORTIFY_SOURCE=2`. Users of ndk-build
+or the NDK's CMake toolchain file also get this by default with NDK r21 or
+newer. Users of other build systems
+need to manually enable FORTIFY by setting `_FORTIFY_SOURCE` themselves in
+whatever build system they're using. The exact subset of FORTIFY available to
NDK users will depend on their target ABI level, because when a FORTIFY
check can't be guaranteed at compile-time, a call to a run-time `_chk`
function is added.
diff --git a/libc/Android.bp b/libc/Android.bp
index 84fa498..776f101 100644
--- a/libc/Android.bp
+++ b/libc/Android.bp
@@ -1,5 +1,3 @@
-// Define the common source files for all the libc instances
-// =========================================================
package {
default_applicable_licenses: ["bionic_libc_license"],
}
@@ -55,7 +53,9 @@
cc_defaults {
name: "libc_defaults",
defaults: ["linux_bionic_supported"],
- cflags: libc_common_flags,
+ cflags: libc_common_flags + [
+ "-DUSE_SCUDO",
+ ],
asflags: libc_common_flags,
conlyflags: ["-std=gnu99"],
cppflags: [],
@@ -87,10 +87,6 @@
recovery_available: true,
native_bridge_supported: true,
- // lld complains about duplicate symbols in libcrt and libgcc. Suppress the
- // warning since this is intended right now.
- ldflags: ["-Wl,-z,muldefs"],
-
product_variables: {
malloc_zero_contents: {
cflags: ["-DSCUDO_ZERO_CONTENTS"],
@@ -98,8 +94,8 @@
malloc_pattern_fill_contents: {
cflags: ["-DSCUDO_PATTERN_FILL_CONTENTS"],
},
- malloc_not_svelte: {
- cflags: ["-DUSE_SCUDO"],
+ malloc_low_memory: {
+ cflags: ["-UUSE_SCUDO"],
},
},
@@ -112,32 +108,90 @@
tidy_disabled_srcs: ["upstream-*/**/*.c"],
}
-libc_scudo_product_variables = {
- malloc_not_svelte: {
- cflags: ["-DUSE_SCUDO"],
- whole_static_libs: ["libscudo"],
- exclude_static_libs: [
- "libjemalloc5",
- "libc_jemalloc_wrapper",
- ],
+// Workaround for b/24465209.
+// We're unlikely to be able to remove this before we just
+// remove ILP32 support completely.
+// Note that we also still have `pack_relocations: false`
+// for both libc and libm, even on LP64.
+// ========================================================
+cc_defaults {
+ name: "bug_24465209_workaround",
+ target: {
+ android_arm: {
+ pack_relocations: false,
+ ldflags: ["-Wl,--hash-style=both"],
+ },
+ android_x86: {
+ pack_relocations: false,
+ ldflags: ["-Wl,--hash-style=both"],
+ },
+ },
+}
+
+// Leave the symbols in the shared library so that stack unwinders can produce
+// meaningful name resolution. This is a bit more ugly than it sounds because
+// arm32 is a bit broken.
+// ========================================================
+cc_defaults {
+ name: "keep_symbols",
+ arch: {
+ arm: {
+ // arm32 does not produce complete exidx unwind information,
+ // so keep the .debug_frame which is relatively small and does
+ // include needed unwind information.
+ // See b/132992102 for details.
+ strip: {
+ keep_symbols_and_debug_frame: true,
+ },
+ },
+ arm64: {
+ strip: {
+ keep_symbols: true,
+ },
+ },
+ riscv64: {
+ strip: {
+ keep_symbols: true,
+ },
+ },
+ x86: {
+ strip: {
+ keep_symbols: true,
+ },
+ },
+ x86_64: {
+ strip: {
+ keep_symbols: true,
+ },
+ },
},
}
// Defaults for native allocator libs/includes to make it
// easier to change.
-// To disable scudo for the non-svelte config remove the line:
-// product_variables: libc_scudo_product_variables,
-// in the cc_defaults below.
// ========================================================
cc_defaults {
name: "libc_native_allocator_defaults",
whole_static_libs: [
- "libjemalloc5",
- "libc_jemalloc_wrapper",
+ "libscudo",
+ ],
+ cflags: [
+ "-DUSE_SCUDO",
],
header_libs: ["gwp_asan_headers"],
- product_variables: libc_scudo_product_variables,
+ product_variables: {
+ malloc_low_memory: {
+ cflags: ["-UUSE_SCUDO"],
+ whole_static_libs: [
+ "libjemalloc5",
+ "libc_jemalloc_wrapper",
+ ],
+ exclude_static_libs: [
+ "libscudo",
+ ],
+ },
+ },
}
// Functions not implemented by jemalloc directly, or that need to
@@ -335,6 +389,7 @@
"upstream-freebsd/lib/libc/stdlib/hdestroy_r.c",
"upstream-freebsd/lib/libc/stdlib/hsearch_r.c",
"upstream-freebsd/lib/libc/stdlib/qsort.c",
+ "upstream-freebsd/lib/libc/stdlib/qsort_r.c",
"upstream-freebsd/lib/libc/stdlib/quick_exit.c",
"upstream-freebsd/lib/libc/string/wcpcpy.c",
"upstream-freebsd/lib/libc/string/wcpncpy.c",
@@ -516,7 +571,6 @@
"upstream-openbsd/lib/libc/stdio/fgetwc.c",
"upstream-openbsd/lib/libc/stdio/fgetws.c",
"upstream-openbsd/lib/libc/stdio/flags.c",
- "upstream-openbsd/lib/libc/stdio/fpurge.c",
"upstream-openbsd/lib/libc/stdio/fputwc.c",
"upstream-openbsd/lib/libc/stdio/fputws.c",
"upstream-openbsd/lib/libc/stdio/fvwrite.c",
@@ -570,10 +624,12 @@
"upstream-openbsd/lib/libc/string/wcslcpy.c",
"upstream-openbsd/lib/libc/string/wcswidth.c",
- // This file is originally from OpenBSD, and benefits from
- // being compiled with openbsd-compat.h.
- // TODO: clean this up instead.
+ // These files are originally from OpenBSD,
+ // and benefit from being compiled with openbsd-compat.h.
+ // TODO: clean them up instead.
"bionic/fts.c",
+ "stdio/vfprintf.cpp",
+ "stdio/vfwprintf.cpp",
],
// Each architecture has optimized versions of some routines,
@@ -632,9 +688,11 @@
local_include_dirs: [
"private",
- "upstream-openbsd/android/include",
"stdio",
- "upstream-openbsd/lib/libc/include",
+ "upstream-openbsd/android/include/",
+ "upstream-openbsd/lib/libc/gdtoa/",
+ "upstream-openbsd/lib/libc/include/",
+ "upstream-openbsd/lib/libc/stdio/",
],
name: "libc_openbsd",
@@ -644,8 +702,6 @@
name: "libc_openbsd_large_stack",
defaults: ["libc_defaults"],
srcs: [
- "stdio/vfprintf.cpp",
- "stdio/vfwprintf.cpp",
"upstream-openbsd/lib/libc/string/memmem.c",
"upstream-openbsd/lib/libc/string/strstr.c",
],
@@ -656,11 +712,7 @@
],
local_include_dirs: [
- "private",
"upstream-openbsd/android/include/",
- "upstream-openbsd/lib/libc/gdtoa/",
- "upstream-openbsd/lib/libc/include/",
- "upstream-openbsd/lib/libc/stdio/",
],
}
@@ -861,6 +913,7 @@
"bionic/isatty.cpp",
"bionic/killpg.cpp",
"bionic/langinfo.cpp",
+ "bionic/lchmod.cpp",
"bionic/lchown.cpp",
"bionic/lfs64_support.cpp",
"bionic/libc_init_common.cpp",
@@ -878,7 +931,6 @@
"bionic/mkfifo.cpp",
"bionic/mknod.cpp",
"bionic/mntent.cpp",
- "bionic/mremap.cpp",
"bionic/netdb.cpp",
"bionic/net_if.cpp",
"bionic/netinet_ether.cpp",
@@ -978,7 +1030,6 @@
"bionic/thread_private.cpp",
"bionic/threads.cpp",
"bionic/time.cpp",
- "bionic/time_l.cpp",
"bionic/tmpfile.cpp",
"bionic/umount.cpp",
"bionic/unlink.cpp",
@@ -1002,11 +1053,6 @@
"stdio/stdio_ext.cpp",
"stdio/vfscanf.cpp",
"stdio/vfwscanf.cpp",
-
- // TODO: why isn't this in a static-libc-only module?
- // This contains a weak stub implementation of __find_icu_symbol for wctype.cpp,
- // which will be overridden by the actual one in libc.so.
- "bionic/icu_static.cpp",
],
arch: {
@@ -1223,9 +1269,6 @@
// off64_t/time64_t support on LP32.
"bionic/legacy_32_bit_support.cpp",
"bionic/time64.c",
-
- // TODO: move to libc/bionic/legacy_32_bit_support.cpp or #if __LP64__ instead.
- "bionic/mmap.cpp",
],
},
},
@@ -1370,43 +1413,13 @@
}
// ========================================================
-// libc_static_dispatch.a --- libc.a ifuncs
+// libc_static_dispatch.a/libc_dynamic_dispatch.a --- string/memory "ifuncs"
+// (Actually ifuncs for libc.so, but a home-grown alternative for libc.a.)
// ========================================================
-cc_library_static {
+
+cc_defaults {
+ name: "libc_dispatch_defaults",
defaults: ["libc_defaults"],
- name: "libc_static_dispatch",
-
- arch: {
- x86_64: {
- srcs: ["arch-x86_64/static_function_dispatch.S"],
- },
- x86: {
- srcs: ["arch-x86/static_function_dispatch.S"],
- },
- arm: {
- srcs: ["arch-arm/static_function_dispatch.S"],
- },
- arm64: {
- srcs: ["arch-arm64/static_function_dispatch.S"],
- },
- riscv64: {
- srcs: ["arch-riscv64/static_function_dispatch.S"],
- },
- },
-}
-
-// ========================================================
-// libc_dynamic_dispatch.a --- libc.so ifuncs
-// ========================================================
-cc_library_static {
- defaults: ["libc_defaults"],
- name: "libc_dynamic_dispatch",
-
- cflags: [
- "-ffreestanding",
- "-fno-stack-protector",
- "-fno-jump-tables",
- ],
arch: {
x86_64: {
srcs: ["arch-x86_64/dynamic_function_dispatch.cpp"],
@@ -1424,6 +1437,30 @@
srcs: ["arch-riscv64/dynamic_function_dispatch.cpp"],
},
},
+ // Prevent the compiler from inserting calls to libc/taking the address of
+ // a jump table from within an ifunc (or, in the static case, code that
+ // can be executed arbitrarily early).
+ cflags: [
+ "-ffreestanding",
+ "-fno-stack-protector",
+ "-fno-jump-tables",
+ ],
+}
+
+cc_library_static {
+ name: "libc_static_dispatch",
+ defaults: ["libc_dispatch_defaults"],
+ cflags: [
+ "-DBIONIC_STATIC_DISPATCH",
+ ],
+}
+
+cc_library_static {
+ name: "libc_dynamic_dispatch",
+ defaults: ["libc_dispatch_defaults"],
+ cflags: [
+ "-DBIONIC_DYNAMIC_DISPATCH",
+ ],
}
// ========================================================
@@ -1512,6 +1549,7 @@
srcs: [
"bionic/gwp_asan_wrappers.cpp",
"bionic/heap_tagging.cpp",
+ "bionic/icu_static.cpp",
"bionic/malloc_common.cpp",
"bionic/malloc_limit.cpp",
],
@@ -1532,6 +1570,8 @@
defaults: [
"libc_defaults",
"libc_native_allocator_defaults",
+ "bug_24465209_workaround",
+ "keep_symbols",
],
name: "libc_library_defaults",
product_variables: {
@@ -1544,7 +1584,6 @@
cflags: ["-DLIBC_STATIC"],
whole_static_libs: [
"gwp_asan",
- "gwp_asan_crash_handler",
"libc_init_static",
"libc_common_static",
"libc_unwind_static",
@@ -1554,7 +1593,6 @@
srcs: [":libc_sources_shared"],
whole_static_libs: [
"gwp_asan",
- "gwp_asan_crash_handler",
"libc_init_dynamic",
"libc_common_shared",
"libunwind-exported",
@@ -1569,14 +1607,6 @@
// Do not pack libc.so relocations; see http://b/20645321 for details.
pack_relocations: false,
- // WARNING: The only libraries libc.so should depend on are libdl.so and ld-android.so!
- // If you add other libraries, make sure to add -Wl,--exclude-libs=libgcc.a to the
- // LOCAL_LDFLAGS for those libraries. This ensures that symbols that are pulled into
- // those new libraries from libgcc.a are not declared external; if that were the case,
- // then libc would not pull those symbols from libgcc.a as it should, instead relying
- // on the external symbols from the dependent libraries. That would create a "cloaked"
- // dependency on libgcc.a in libc though the libraries, which is not what you wanted!
-
shared_libs: [
"ld-android",
"libdl",
@@ -1589,15 +1619,6 @@
arch: {
arm: {
- // TODO: This is to work around b/24465209. Remove after root cause is fixed.
- pack_relocations: false,
- ldflags: [
- "-Wl,--hash-style=both",
- // Since we are preserving the debug_frame, do not compress
- // in this case to make unwinds as fast as possible.
- "-Wl,--compress-debug-sections=none",
- ],
-
version_script: ":libc.arm.map",
no_libcrt: true,
@@ -1605,68 +1626,37 @@
srcs: [":libc_sources_shared_arm"],
// special for arm
cflags: ["-DCRT_LEGACY_WORKAROUND"],
- // For backwards-compatibility, some arm32 builtins are exported from libc.so.
+ // For backwards compatibility, some arm32 builtins are exported from libc.so.
static_libs: ["libclang_rt.builtins-exported"],
},
- // Arm 32 bit does not produce complete exidx unwind information
- // so keep the .debug_frame which is relatively small and does
- // include needed unwind information.
- // See b/132992102 for details.
- strip: {
- keep_symbols_and_debug_frame: true,
- },
+ ldflags: [
+ // Since we preserve the debug_frame for libc, do not compress
+ // in this case to make unwinds as fast as possible.
+ "-Wl,--compress-debug-sections=none",
+ ],
},
arm64: {
version_script: ":libc.arm64.map",
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
riscv64: {
version_script: ":libc.riscv64.map",
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
x86: {
- // TODO: This is to work around b/24465209. Remove after root cause is fixed.
- pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
-
version_script: ":libc.x86.map",
no_libcrt: true,
shared: {
- // For backwards-compatibility, some x86 builtins are exported from libc.so.
+ // For backwards compatibility, some x86 builtins are exported from libc.so.
static_libs: ["libclang_rt.builtins-exported"],
},
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
x86_64: {
version_script: ":libc.x86_64.map",
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
},
apex_available: [
- "//apex_available:platform",
"com.android.runtime",
],
@@ -1696,8 +1686,7 @@
llndk: {
symbol_file: "libc.map.txt",
export_headers_as_system: true,
- export_preprocessed_headers: ["include"],
- export_llndk_headers: ["libc_llndk_headers"],
+ export_llndk_headers: ["libc_headers"],
},
}
@@ -1808,7 +1797,7 @@
}
cc_library_headers {
- name: "libc_llndk_headers",
+ name: "libc_uapi_headers",
visibility: [
"//external/musl",
],
@@ -1903,13 +1892,13 @@
target: {
android: {
export_system_include_dirs: ["include"],
- header_libs: ["libc_llndk_headers"],
- export_header_lib_headers: ["libc_llndk_headers"],
+ header_libs: ["libc_uapi_headers"],
+ export_header_lib_headers: ["libc_uapi_headers"],
},
linux_bionic: {
export_system_include_dirs: ["include"],
- header_libs: ["libc_llndk_headers"],
- export_header_lib_headers: ["libc_llndk_headers"],
+ header_libs: ["libc_uapi_headers"],
+ export_header_lib_headers: ["libc_uapi_headers"],
},
},
}
@@ -1919,7 +1908,10 @@
// ========================================================
cc_library {
- defaults: ["libc_defaults"],
+ defaults: [
+ "libc_defaults",
+ "bug_24465209_workaround",
+ ],
include_dirs: ["bionic/libstdc++/include"],
srcs: [
"bionic/__cxa_guard.cpp",
@@ -1944,12 +1936,8 @@
},
},
- //TODO (dimitry): This is to work around b/24465209. Remove after root cause is fixed
arch: {
arm: {
- // TODO: This is to work around b/24465209. Remove after root cause is fixed.
- pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
version_script: ":libstdc++.arm.map",
},
arm64: {
@@ -1959,8 +1947,6 @@
version_script: ":libstdc++.riscv64.map",
},
x86: {
- pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
version_script: ":libstdc++.x86.map",
},
x86_64: {
@@ -2230,19 +2216,31 @@
nocrt: true,
stl: "none",
visibility: [
- "//packages/modules/Virtualization/vmbase",
+ "//packages/modules/Virtualization/libs/libvmbase",
],
+
+ // b/358211032: This library gets linked into a rust rlib. Disable LTO
+ // until cross-language lto is supported.
+ lto: {
+ never: true,
+ },
}
// ========================================================
// NDK headers.
// ========================================================
-versioned_ndk_headers {
+ndk_headers {
name: "common_libc",
from: "include",
to: "",
+ srcs: ["include/**/*.h"],
license: "NOTICE",
+ // These don't pass the bad verification we do because many of them are
+ // arch-specific, and they aren't necessarily independently includable.
+ // That's not much of a problem though, since C-incompaitibilities in the
+ // UAPI headers should run into problems long before they reach us.
+ skip_verification: true,
}
ndk_headers {
@@ -2262,6 +2260,7 @@
"kernel/uapi/xen/**/*.h",
],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2278,6 +2277,7 @@
to: "scsi",
srcs: ["kernel/android/scsi/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2286,6 +2286,7 @@
to: "arm-linux-androideabi",
srcs: ["kernel/uapi/asm-arm/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2294,6 +2295,7 @@
to: "aarch64-linux-android",
srcs: ["kernel/uapi/asm-arm64/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2302,6 +2304,7 @@
to: "riscv64-linux-android",
srcs: ["kernel/uapi/asm-riscv/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2310,6 +2313,7 @@
to: "i686-linux-android",
srcs: ["kernel/uapi/asm-x86/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_headers {
@@ -2318,23 +2322,13 @@
to: "x86_64-linux-android",
srcs: ["kernel/uapi/asm-x86/**/*.h"],
license: "NOTICE",
+ skip_verification: true,
}
ndk_library {
name: "libc",
symbol_file: "libc.map.txt",
first_version: "9",
- export_header_libs: [
- "common_libc",
- "libc_uapi",
- "libc_kernel_android_uapi_linux",
- "libc_kernel_android_scsi",
- "libc_asm_arm",
- "libc_asm_arm64",
- "libc_asm_riscv64",
- "libc_asm_x86",
- "libc_asm_x86_64",
- ],
}
ndk_library {
@@ -2990,3 +2984,8 @@
name: "versioner-dependencies",
srcs: ["versioner-dependencies/**/*"],
}
+
+filegroup {
+ name: "linux_capability_header",
+ srcs: ["kernel/uapi/linux/capability.h"],
+}
diff --git a/libc/SECCOMP_ALLOWLIST_APP.TXT b/libc/SECCOMP_ALLOWLIST_APP.TXT
index 7e1ecde..80b15b2 100644
--- a/libc/SECCOMP_ALLOWLIST_APP.TXT
+++ b/libc/SECCOMP_ALLOWLIST_APP.TXT
@@ -4,36 +4,36 @@
# This file is processed by a python script named genseccomp.py.
# Needed for debugging 32-bit Chrome
-int pipe:pipe(int pipefd[2]) lp32
+int pipe(int pipefd[2]) lp32
# b/34651972
-int access:access(const char *pathname, int mode) lp32
-int stat64:stat64(const char*, struct stat64*) lp32
+int access(const char *pathname, int mode) lp32
+int stat64(const char*, struct stat64*) lp32
# b/34813887
-int open:open(const char *path, int oflag, ... ) lp32,x86_64
-int getdents:getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count) lp32,x86_64
+int open(const char *path, int oflag, ... ) lp32,x86_64
+int getdents(unsigned int fd, struct linux_dirent *dirp, unsigned int count) lp32,x86_64
# b/34719286
-int eventfd:eventfd(unsigned int initval, int flags) lp32
+int eventfd(unsigned int initval, int flags) lp32
# b/34817266
-int epoll_wait:epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) lp32
+int epoll_wait(int epfd, struct epoll_event *events, int maxevents, int timeout) lp32
# b/34908783
-int epoll_create:epoll_create(int size) lp32
+int epoll_create(int size) lp32
# b/34979910
-int creat:creat(const char *pathname, mode_t mode) lp32
-int unlink:unlink(const char *pathname) lp32
+int creat(const char *pathname, mode_t mode) lp32
+int unlink(const char *pathname) lp32
# b/35059702
-int lstat64:lstat64(const char*, struct stat64*) lp32
+int lstat64(const char*, struct stat64*) lp32
# b/35217603
-int fcntl:fcntl(int fd, int cmd, ... /* arg */ ) lp32
-pid_t fork:fork() lp32
-int poll:poll(struct pollfd *fds, nfds_t nfds, int timeout) lp32
+int fcntl(int fd, int cmd, ... /* arg */ ) lp32
+pid_t fork() lp32
+int poll(struct pollfd *fds, nfds_t nfds, int timeout) lp32
# b/35906875
int inotify_init() lp32
diff --git a/libc/SECCOMP_BLOCKLIST_APP.TXT b/libc/SECCOMP_BLOCKLIST_APP.TXT
index 049d577..b9ecc02 100644
--- a/libc/SECCOMP_BLOCKLIST_APP.TXT
+++ b/libc/SECCOMP_BLOCKLIST_APP.TXT
@@ -6,40 +6,39 @@
#
# This file is processed by a python script named genseccomp.py.
-# Note: Some privileged syscalls are still needed in app process after fork before uid change,
-# including capset and setresuid. This is because the seccomp filter must be installed while
-# the process still has CAP_SYS_ADMIN; changing the uid would remove that capability.
-
-# syscalls to modify IDs
-int setgid:setgid32(gid_t) lp32
-int setgid:setgid(gid_t) lp64
-int setuid:setuid32(uid_t) lp32
-int setuid:setuid(uid_t) lp64
-int setregid:setregid32(gid_t, gid_t) lp32
-int setregid:setregid(gid_t, gid_t) lp64
-int setreuid:setreuid32(uid_t, uid_t) lp32
-int setreuid:setreuid(uid_t, uid_t) lp64
-int setresgid:setresgid32(gid_t, gid_t, gid_t) lp32
-int setresgid:setresgid(gid_t, gid_t, gid_t) lp64
+# Syscalls to modify IDs.
+# Note: Some privileged syscalls are still needed in app_process after fork but
+# before uid change, including capset and setresuid. This is because the seccomp
+# filter must be installed while the process still has CAP_SYS_ADMIN; changing
+# the uid would remove that capability.
+int setgid32(gid_t) lp32
+int setgid(gid_t) lp64
+int setuid32(uid_t) lp32
+int setuid(uid_t) lp64
+int setregid32(gid_t, gid_t) lp32
+int setregid(gid_t, gid_t) lp64
+int setreuid32(uid_t, uid_t) lp32
+int setreuid(uid_t, uid_t) lp64
+int setresgid32(gid_t, gid_t, gid_t) lp32
+int setresgid(gid_t, gid_t, gid_t) lp64
# setresuid is explicitly allowed, see above.
-int setfsgid:setfsgid32(gid_t) lp32
-int setfsgid:setfsgid(gid_t) lp64
-int setfsuid:setfsuid32(uid_t) lp32
-int setfsuid:setfsuid(uid_t) lp64
-int setgroups:setgroups32(int, const gid_t*) lp32
-int setgroups:setgroups(int, const gid_t*) lp64
+int setfsgid32(gid_t) lp32
+int setfsgid(gid_t) lp64
+int setfsuid32(uid_t) lp32
+int setfsuid(uid_t) lp64
+int setgroups32(int, const gid_t*) lp32
+int setgroups(int, const gid_t*) lp64
-# syscalls to modify times
+# Syscalls to modify times.
int adjtimex(struct timex*) all
int clock_adjtime(clockid_t, struct timex*) all
int clock_settime(clockid_t, const struct timespec*) all
int settimeofday(const struct timeval*, const struct timezone*) all
int acct(const char* filepath) all
-int klogctl:syslog(int, char*, int) all
+int syslog(int, char*, int) all
int chroot(const char*) all
-# syscalls to change machine various configurations
int init_module(void*, unsigned long, const char*) all
int delete_module(const char*, unsigned int) all
int mount(const char*, const char*, const char*, unsigned long, const void*) all
@@ -48,4 +47,4 @@
int swapoff(const char*) all
int setdomainname(const char*, size_t) all
int sethostname(const char*, size_t) all
-int __reboot:reboot(int, int, int, void*) all
+int reboot(int, int, int, void*) all
diff --git a/libc/SYSCALLS.TXT b/libc/SYSCALLS.TXT
index 0db5d79..8c5572e 100644
--- a/libc/SYSCALLS.TXT
+++ b/libc/SYSCALLS.TXT
@@ -65,7 +65,7 @@
int tgkill(pid_t tgid, pid_t tid, int sig) all
void* __brk:brk(void*) all
-int __execve:execve(const char*, char* const*, char* const*) all
+int execve(const char*, char* const*, char* const*) all
int __ptrace:ptrace(int request, int pid, void* addr, void* data) all
# <sys/resource.h>
@@ -88,7 +88,6 @@
int setregid:setregid(gid_t, gid_t) lp64
int chroot(const char*) all
int prctl(int, unsigned long, unsigned long, unsigned long, unsigned long) all
-long __arch_prctl:arch_prctl(int, unsigned long) x86_64
int capget(cap_user_header_t header, cap_user_data_t data) all
int capset(cap_user_header_t header, const cap_user_data_t data) all
int sigaltstack(const stack_t*, stack_t*) all
@@ -118,7 +117,6 @@
pid_t __getpid:getpid() all
int memfd_create(const char*, unsigned) all
int munmap(void*, size_t) all
-void* __mremap:mremap(void*, size_t, size_t, int, void*) all
int msync(const void*, size_t, int) all
int mprotect(const void*, size_t, int) all
int madvise(void*, size_t, int) all
@@ -127,6 +125,7 @@
int mlock2(const void* addr, size_t len, int flags) all
int munlock(const void* addr, size_t len) all
int mlockall(int flags) all
+int mseal(void*, size_t, unsigned long) lp64
int munlockall() all
int mincore(void* start, size_t length, unsigned char* vec) all
int __ioctl:ioctl(int, int, void*) all
@@ -174,20 +173,25 @@
off_t lseek(int, off_t, int) lp32
int __llseek:_llseek(int, unsigned long, unsigned long, off64_t*, int) lp32
off_t lseek|lseek64(int, off_t, int) lp64
-int ftruncate64(int, off64_t) lp32
-int ftruncate|ftruncate64(int, off_t) lp64
ssize_t sendfile(int out_fd, int in_fd, off_t* offset, size_t count) lp32
ssize_t sendfile64(int out_fd, int in_fd, off64_t* offset, size_t count) lp32
ssize_t sendfile|sendfile64(int out_fd, int in_fd, off_t* offset, size_t count) lp64
int truncate(const char*, off_t) lp32
int truncate64(const char*, off64_t) lp32
int truncate|truncate64(const char*, off_t) lp64
-# (mmap only gets two lines because we only used the 64-bit variant on 32-bit systems.)
-void* __mmap2:mmap2(void*, size_t, int, int, int, long) lp32
-void* mmap|mmap64(void*, size_t, int, int, int, off_t) lp64
# (fallocate only gets two lines because there is no 32-bit variant.)
int fallocate64:fallocate(int, int, off64_t, off64_t) lp32
int fallocate|fallocate64(int, int, off_t, off_t) lp64
+# (ftruncate only gets two lines because 32-bit bionic only uses the 64-bit call.)
+int ftruncate64(int, off64_t) lp32
+int ftruncate|ftruncate64(int, off_t) lp64
+# (mmap only gets two lines because 32-bit bionic only uses the 64-bit call.)
+void* __mmap2:mmap2(void*, size_t, int, int, int, long) lp32
+void* mmap|mmap64(void*, size_t, int, int, int, off_t) lp64
+
+# mremap is in C++ for 32-bit so we can add the PTRDIFF_MAX check.
+void* __mremap:mremap(void*, size_t, size_t, int, void*) lp32
+void* mremap(void*, size_t, size_t, int, void*) lp64
# posix_fadvise64 is awkward: arm has shuffled arguments,
# the POSIX functions don't set errno, and no architecture has posix_fadvise.
@@ -326,7 +330,7 @@
int __eventfd:eventfd2(unsigned int, int) all
-void __exit_group:exit_group(int) all
+void _exit|_Exit:exit_group(int) all
void __exit:exit(int) all
int inotify_init1(int) all
@@ -346,7 +350,7 @@
int setdomainname(const char*, size_t) all
int sethostname(const char*, size_t) all
-int __sync_file_range:sync_file_range(int, off64_t, off64_t, unsigned int) x86,lp64
+int sync_file_range(int, off64_t, off64_t, unsigned int) x86,lp64
int __sync_file_range2:sync_file_range2(int, unsigned int, off64_t, off64_t) arm
pid_t wait4(pid_t, int*, int, struct rusage*) all
@@ -361,6 +365,7 @@
# x86-specific
int __set_thread_area:set_thread_area(void*) x86
+long arch_prctl(int, unsigned long) x86_64
# vdso stuff.
int __clock_getres:clock_getres(clockid_t, struct timespec*) all
diff --git a/libc/arch-arm/dynamic_function_dispatch.cpp b/libc/arch-arm/dynamic_function_dispatch.cpp
index 1d2f38f..f984421 100644
--- a/libc/arch-arm/dynamic_function_dispatch.cpp
+++ b/libc/arch-arm/dynamic_function_dispatch.cpp
@@ -27,27 +27,26 @@
*/
#include <fcntl.h>
-#include <sys/syscall.h>
-
#include <private/bionic_ifuncs.h>
+#include <sys/syscall.h>
extern "C" {
enum CpuVariant {
- kUnknown = 0,
- kGeneric,
- kCortexA7,
- kCortexA9,
- kCortexA53,
- kCortexA55,
- kKrait,
- kKryo,
+ kUnknown = 0,
+ kGeneric,
+ kCortexA7,
+ kCortexA9,
+ kCortexA53,
+ kCortexA55,
+ kKrait,
+ kKryo,
};
static constexpr int MAX_CPU_NAME_LEN = 12;
struct CpuVariantNames {
- alignas(alignof(int)) char name[MAX_CPU_NAME_LEN];
- CpuVariant variant;
+ alignas(alignof(int)) char name[MAX_CPU_NAME_LEN];
+ CpuVariant variant;
};
static constexpr CpuVariantNames cpu_variant_names[] = {
@@ -66,227 +65,237 @@
};
static long ifunc_open(const char* pathname) {
- register long r0 __asm__("r0") = AT_FDCWD;
- register long r1 __asm__("r1") = reinterpret_cast<long>(pathname);
- register long r2 __asm__("r2") = O_RDONLY;
- register long r3 __asm__("r3") = 0;
- register long r7 __asm__("r7") = __NR_openat;
- __asm__ volatile("swi #0" : "=r"(r0) : "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r7));
- return r0;
+ register long r0 __asm__("r0") = AT_FDCWD;
+ register long r1 __asm__("r1") = reinterpret_cast<long>(pathname);
+ register long r2 __asm__("r2") = O_RDONLY;
+ register long r3 __asm__("r3") = 0;
+ register long r7 __asm__("r7") = __NR_openat;
+ __asm__ volatile("swi #0"
+ : "=r"(r0)
+ : "r"(r0), "r"(r1), "r"(r2), "r"(r3), "r"(r7));
+ return r0;
}
static ssize_t ifunc_read(int fd, void* buf, size_t count) {
- register long r0 __asm__("r0") = fd;
- register long r1 __asm__("r1") = reinterpret_cast<long>(buf);
- register long r2 __asm__("r2") = count;
- register long r7 __asm__("r7") = __NR_read;
- __asm__ volatile("swi #0" : "=r"(r0) : "r"(r0), "r"(r1), "r"(r2), "r"(r7) : "memory");
- return r0;
+ register long r0 __asm__("r0") = fd;
+ register long r1 __asm__("r1") = reinterpret_cast<long>(buf);
+ register long r2 __asm__("r2") = count;
+ register long r7 __asm__("r7") = __NR_read;
+ __asm__ volatile("swi #0"
+ : "=r"(r0)
+ : "r"(r0), "r"(r1), "r"(r2), "r"(r7)
+ : "memory");
+ return r0;
}
static int ifunc_close(int fd) {
- register long r0 __asm__("r0") = fd;
- register long r7 __asm__("r7") = __NR_close;
- __asm__ volatile("swi #0" : "=r"(r0) : "r"(r0), "r"(r7));
- return r0;
+ register long r0 __asm__("r0") = fd;
+ register long r7 __asm__("r7") = __NR_close;
+ __asm__ volatile("swi #0" : "=r"(r0) : "r"(r0), "r"(r7));
+ return r0;
}
static bool is_same_name(const char* a, const char* b) {
- static_assert(MAX_CPU_NAME_LEN % sizeof(int) == 0, "");
- const int* ia = reinterpret_cast<const int*>(a);
- const int* ib = reinterpret_cast<const int*>(b);
- for (size_t i = 0; i < MAX_CPU_NAME_LEN / sizeof(int); ++i) {
- if (ia[i] != ib[i]) {
- return false;
- }
+ static_assert(MAX_CPU_NAME_LEN % sizeof(int) == 0, "");
+ const int* ia = reinterpret_cast<const int*>(a);
+ const int* ib = reinterpret_cast<const int*>(b);
+ for (size_t i = 0; i < MAX_CPU_NAME_LEN / sizeof(int); ++i) {
+ if (ia[i] != ib[i]) {
+ return false;
}
- return true;
+ }
+ return true;
}
static CpuVariant init_cpu_variant() {
- int fd = ifunc_open("/dev/cpu_variant:arm");
- if (fd < 0) return kGeneric;
+ int fd = ifunc_open("/dev/cpu_variant:arm");
+ if (fd < 0) return kGeneric;
- alignas(alignof(int)) char name[MAX_CPU_NAME_LEN] = {};
+ alignas(alignof(int)) char name[MAX_CPU_NAME_LEN] = {};
- int bytes_read, total_read = 0;
- while (total_read < MAX_CPU_NAME_LEN - 1 &&
- (bytes_read = ifunc_read(fd, name + total_read,
- MAX_CPU_NAME_LEN - 1 - total_read)) > 0) {
- total_read += bytes_read;
- }
- ifunc_close(fd);
+ int bytes_read, total_read = 0;
+ while (total_read < MAX_CPU_NAME_LEN - 1 &&
+ (bytes_read = ifunc_read(fd, name + total_read,
+ MAX_CPU_NAME_LEN - 1 - total_read)) > 0) {
+ total_read += bytes_read;
+ }
+ ifunc_close(fd);
- if (bytes_read != 0) {
- // The file is too big. We haven't reach the end. Or maybe there is an
- // error when reading.
- return kGeneric;
- }
- name[total_read] = 0;
-
- const CpuVariantNames* cpu_variant = cpu_variant_names;
- while (cpu_variant->variant != kUnknown) {
- if (is_same_name(cpu_variant->name, name)) {
- return cpu_variant->variant;
- }
- cpu_variant++;
- }
+ if (bytes_read != 0) {
+ // The file is too big. We haven't reach the end. Or maybe there is an
+ // error when reading.
return kGeneric;
+ }
+ name[total_read] = 0;
+
+ const CpuVariantNames* cpu_variant = cpu_variant_names;
+ while (cpu_variant->variant != kUnknown) {
+ if (is_same_name(cpu_variant->name, name)) {
+ return cpu_variant->variant;
+ }
+ cpu_variant++;
+ }
+ return kGeneric;
}
static CpuVariant get_cpu_variant() {
- static CpuVariant cpu_variant = kUnknown;
- if (cpu_variant == kUnknown) {
- cpu_variant = init_cpu_variant();
- }
- return cpu_variant;
+ static CpuVariant cpu_variant = kUnknown;
+ if (cpu_variant == kUnknown) {
+ cpu_variant = init_cpu_variant();
+ }
+ return cpu_variant;
}
-typedef void* memmove_func(void* __dst, const void* __src, size_t __n);
DEFINE_IFUNC_FOR(memmove) {
- RETURN_FUNC(memmove_func, memmove_a15);
+ RETURN_FUNC(memmove_func_t, memmove_a15);
}
+MEMMOVE_SHIM()
-typedef void* memcpy_func(void*, const void*, size_t);
DEFINE_IFUNC_FOR(memcpy) {
- return memmove_resolver(hwcap);
+ return memmove_resolver(hwcap);
}
+MEMCPY_SHIM()
-typedef void* __memcpy_func(void*, const void*, size_t);
+// On arm32, __memcpy() is not publicly exposed, but gets called by memmove()
+// in cases where the copy is known to be overlap-safe.
+typedef void* __memcpy_func_t(void*, const void*, size_t);
DEFINE_IFUNC_FOR(__memcpy) {
- switch(get_cpu_variant()) {
- case kCortexA7:
- RETURN_FUNC(__memcpy_func, __memcpy_a7);
- case kCortexA9:
- RETURN_FUNC(__memcpy_func, __memcpy_a9);
- case kKrait:
- RETURN_FUNC(__memcpy_func, __memcpy_krait);
- case kCortexA53:
- RETURN_FUNC(__memcpy_func, __memcpy_a53);
- case kCortexA55:
- RETURN_FUNC(__memcpy_func, __memcpy_a55);
- case kKryo:
- RETURN_FUNC(__memcpy_func, __memcpy_kryo);
- default:
- RETURN_FUNC(__memcpy_func, __memcpy_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA7:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_a7);
+ case kCortexA9:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_a9);
+ case kKrait:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_krait);
+ case kCortexA53:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_a53);
+ case kCortexA55:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_a55);
+ case kKryo:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_kryo);
+ default:
+ RETURN_FUNC(__memcpy_func_t, __memcpy_a15);
+ }
}
+DEFINE_STATIC_SHIM(void* __memcpy(void* dst, const void* src, size_t n) {
+ FORWARD(__memcpy)(dst, src, n);
+})
-typedef void* __memset_chk_func(void* s, int c, size_t n, size_t n2);
DEFINE_IFUNC_FOR(__memset_chk) {
- switch(get_cpu_variant()) {
- case kCortexA7:
- case kCortexA53:
- case kCortexA55:
- case kKryo:
- RETURN_FUNC(__memset_chk_func, __memset_chk_a7);
- case kCortexA9:
- RETURN_FUNC(__memset_chk_func, __memset_chk_a9);
- case kKrait:
- RETURN_FUNC(__memset_chk_func, __memset_chk_krait);
- default:
- RETURN_FUNC(__memset_chk_func, __memset_chk_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA7:
+ case kCortexA53:
+ case kCortexA55:
+ case kKryo:
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_a7);
+ case kCortexA9:
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_a9);
+ case kKrait:
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_krait);
+ default:
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_a15);
+ }
}
+__MEMSET_CHK_SHIM()
-typedef void* memset_func(void* __dst, int __ch, size_t __n);
DEFINE_IFUNC_FOR(memset) {
- switch(get_cpu_variant()) {
- case kCortexA7:
- case kCortexA53:
- case kCortexA55:
- case kKryo:
- RETURN_FUNC(memset_func, memset_a7);
- case kCortexA9:
- RETURN_FUNC(memset_func, memset_a9);
- case kKrait:
- RETURN_FUNC(memset_func, memset_krait);
- default:
- RETURN_FUNC(memset_func, memset_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA7:
+ case kCortexA53:
+ case kCortexA55:
+ case kKryo:
+ RETURN_FUNC(memset_func_t, memset_a7);
+ case kCortexA9:
+ RETURN_FUNC(memset_func_t, memset_a9);
+ case kKrait:
+ RETURN_FUNC(memset_func_t, memset_krait);
+ default:
+ RETURN_FUNC(memset_func_t, memset_a15);
+ }
}
+MEMSET_SHIM()
-typedef char* strcpy_func(char* __dst, const char* __src);
DEFINE_IFUNC_FOR(strcpy) {
- switch(get_cpu_variant()) {
- case kCortexA9:
- RETURN_FUNC(strcpy_func, strcpy_a9);
- default:
- RETURN_FUNC(strcpy_func, strcpy_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA9:
+ RETURN_FUNC(strcpy_func_t, strcpy_a9);
+ default:
+ RETURN_FUNC(strcpy_func_t, strcpy_a15);
+ }
}
+STRCPY_SHIM()
-typedef char* __strcpy_chk_func(char* dst, const char* src, size_t dst_len);
DEFINE_IFUNC_FOR(__strcpy_chk) {
- switch(get_cpu_variant()) {
- case kCortexA7:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_a7);
- case kCortexA9:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_a9);
- case kKrait:
- case kKryo:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_krait);
- case kCortexA53:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_a53);
- case kCortexA55:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_a55);
- default:
- RETURN_FUNC(__strcpy_chk_func, __strcpy_chk_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA7:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_a7);
+ case kCortexA9:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_a9);
+ case kKrait:
+ case kKryo:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_krait);
+ case kCortexA53:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_a53);
+ case kCortexA55:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_a55);
+ default:
+ RETURN_FUNC(__strcpy_chk_func_t, __strcpy_chk_a15);
+ }
}
+__STRCPY_CHK_SHIM()
-typedef char* stpcpy_func(char* __dst, const char* __src);
DEFINE_IFUNC_FOR(stpcpy) {
- switch(get_cpu_variant()) {
- case kCortexA9:
- RETURN_FUNC(stpcpy_func, stpcpy_a9);
- default:
- RETURN_FUNC(stpcpy_func, stpcpy_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA9:
+ RETURN_FUNC(stpcpy_func_t, stpcpy_a9);
+ default:
+ RETURN_FUNC(stpcpy_func_t, stpcpy_a15);
+ }
}
+STPCPY_SHIM()
-typedef char* strcat_func(char* __dst, const char* __src);
DEFINE_IFUNC_FOR(strcat) {
- switch(get_cpu_variant()) {
- case kCortexA9:
- RETURN_FUNC(strcat_func, strcat_a9);
- default:
- RETURN_FUNC(strcat_func, strcat_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA9:
+ RETURN_FUNC(strcat_func_t, strcat_a9);
+ default:
+ RETURN_FUNC(strcat_func_t, strcat_a15);
+ }
}
+STRCAT_SHIM()
-typedef char* __strcat_chk_func(char* dst, const char* src, size_t dst_buf_size);
DEFINE_IFUNC_FOR(__strcat_chk) {
- switch(get_cpu_variant()) {
- case kCortexA7:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_a7);
- case kCortexA9:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_a9);
- case kKrait:
- case kKryo:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_krait);
- case kCortexA53:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_a53);
- case kCortexA55:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_a55);
- default:
- RETURN_FUNC(__strcat_chk_func, __strcat_chk_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA7:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_a7);
+ case kCortexA9:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_a9);
+ case kKrait:
+ case kKryo:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_krait);
+ case kCortexA53:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_a53);
+ case kCortexA55:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_a55);
+ default:
+ RETURN_FUNC(__strcat_chk_func_t, __strcat_chk_a15);
+ }
}
+__STRCAT_CHK_SHIM()
-typedef int strcmp_func(const char* __lhs, const char* __rhs);
DEFINE_IFUNC_FOR(strcmp) {
- RETURN_FUNC(strcmp_func, strcmp_a15);
+ RETURN_FUNC(strcmp_func_t, strcmp_a15);
}
+STRCMP_SHIM()
-typedef size_t strlen_func(const char* __s);
DEFINE_IFUNC_FOR(strlen) {
- switch(get_cpu_variant()) {
- case kCortexA9:
- RETURN_FUNC(strlen_func, strlen_a9);
- default:
- RETURN_FUNC(strlen_func, strlen_a15);
- }
+ switch (get_cpu_variant()) {
+ case kCortexA9:
+ RETURN_FUNC(strlen_func_t, strlen_a9);
+ default:
+ RETURN_FUNC(strlen_func_t, strlen_a15);
+ }
}
+STRLEN_SHIM()
} // extern "C"
diff --git a/libc/arch-arm/static_function_dispatch.S b/libc/arch-arm/static_function_dispatch.S
deleted file mode 100644
index a8235c2..0000000
--- a/libc/arch-arm/static_function_dispatch.S
+++ /dev/null
@@ -1,46 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#include <private/bionic_asm.h>
-
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- b impl; \
-END(name)
-
-FUNCTION_DELEGATE(memmove, memmove_generic)
-FUNCTION_DELEGATE(memcpy, memmove_generic)
-FUNCTION_DELEGATE(memset, memset_generic)
-FUNCTION_DELEGATE(__memset_chk, __memset_chk_generic)
-FUNCTION_DELEGATE(strcpy, strcpy_generic)
-FUNCTION_DELEGATE(__strcpy_chk, __strcpy_chk_generic)
-FUNCTION_DELEGATE(stpcpy, stpcpy_generic)
-FUNCTION_DELEGATE(strcat, strcat_generic)
-FUNCTION_DELEGATE(__strcat_chk, __strcat_chk_generic)
-FUNCTION_DELEGATE(strcmp, strcmp_generic)
-FUNCTION_DELEGATE(strlen, strlen_generic)
diff --git a/libc/arch-arm64/dynamic_function_dispatch.cpp b/libc/arch-arm64/dynamic_function_dispatch.cpp
index a42c361..29e47b3 100644
--- a/libc/arch-arm64/dynamic_function_dispatch.cpp
+++ b/libc/arch-arm64/dynamic_function_dispatch.cpp
@@ -28,142 +28,147 @@
#include <private/bionic_ifuncs.h>
#include <stddef.h>
-#include <sys/auxv.h>
static inline bool __bionic_is_oryon(unsigned long hwcap) {
- if (!(hwcap & HWCAP_CPUID)) return false;
+ if (!(hwcap & HWCAP_CPUID)) return false;
- // Extract the implementor and variant bits from MIDR_EL1.
- // https://www.kernel.org/doc/html/latest/arch/arm64/cpu-feature-registers.html#list-of-registers-with-visible-features
- unsigned long midr;
- __asm__ __volatile__("mrs %0, MIDR_EL1" : "=r"(midr));
- uint16_t cpu = (midr >> 20) & 0xfff;
+ // Extract the implementor and variant bits from MIDR_EL1.
+ // https://www.kernel.org/doc/html/latest/arch/arm64/cpu-feature-registers.html#list-of-registers-with-visible-features
+ unsigned long midr;
+ __asm__ __volatile__("mrs %0, MIDR_EL1" : "=r"(midr));
+ uint16_t cpu = (midr >> 20) & 0xfff;
- auto make_cpu = [](unsigned implementor, unsigned variant) {
- return (implementor << 4) | variant;
- };
+ auto make_cpu = [](unsigned implementor, unsigned variant) {
+ return (implementor << 4) | variant;
+ };
- // Check for implementor Qualcomm's variants 0x1..0x5 (Oryon).
- return cpu >= make_cpu('Q', 0x1) && cpu <= make_cpu('Q', 0x5);
+ // Check for implementor Qualcomm's variants 0x1..0x5 (Oryon).
+ return cpu >= make_cpu('Q', 0x1) && cpu <= make_cpu('Q', 0x5);
}
extern "C" {
-typedef void* memchr_func(const void*, int, size_t);
DEFINE_IFUNC_FOR(memchr) {
- if (arg->_hwcap2 & HWCAP2_MTE) {
- RETURN_FUNC(memchr_func, __memchr_aarch64_mte);
- } else {
- RETURN_FUNC(memchr_func, __memchr_aarch64);
- }
-}
-
-typedef int memcmp_func(const void*, const void*, size_t);
-DEFINE_IFUNC_FOR(memcmp) {
- // TODO: enable the SVE version.
- RETURN_FUNC(memcmp_func, __memcmp_aarch64);
-}
-
-typedef void* memcpy_func(void*, const void*, size_t);
-DEFINE_IFUNC_FOR(memcpy) {
- if (__bionic_is_oryon(arg->_hwcap)) {
- RETURN_FUNC(memcpy_func, __memcpy_aarch64_nt);
- } else if (arg->_hwcap & HWCAP_ASIMD) {
- RETURN_FUNC(memcpy_func, __memcpy_aarch64_simd);
- } else {
- RETURN_FUNC(memcpy_func, __memcpy_aarch64);
- }
-}
-
-typedef void* memmove_func(void*, const void*, size_t);
-DEFINE_IFUNC_FOR(memmove) {
- if (__bionic_is_oryon(arg->_hwcap)) {
- RETURN_FUNC(memcpy_func, __memmove_aarch64_nt);
- } else if (arg->_hwcap & HWCAP_ASIMD) {
- RETURN_FUNC(memmove_func, __memmove_aarch64_simd);
+ if (arg->_hwcap2 & HWCAP2_MTE) {
+ RETURN_FUNC(memchr_func_t, __memchr_aarch64_mte);
} else {
- RETURN_FUNC(memmove_func, __memmove_aarch64);
+ RETURN_FUNC(memchr_func_t, __memchr_aarch64);
}
}
+MEMCHR_SHIM()
-typedef int memrchr_func(const void*, int, size_t);
+DEFINE_IFUNC_FOR(memcmp) {
+ // TODO: enable the SVE version.
+ RETURN_FUNC(memcmp_func_t, __memcmp_aarch64);
+}
+MEMCMP_SHIM()
+
+DEFINE_IFUNC_FOR(memcpy) {
+ if (arg->_hwcap2 & HWCAP2_MOPS) {
+ RETURN_FUNC(memcpy_func_t, __memmove_aarch64_mops);
+ } else if (__bionic_is_oryon(arg->_hwcap)) {
+ RETURN_FUNC(memcpy_func_t, __memcpy_aarch64_nt);
+ } else if (arg->_hwcap & HWCAP_ASIMD) {
+ RETURN_FUNC(memcpy_func_t, __memcpy_aarch64_simd);
+ } else {
+ RETURN_FUNC(memcpy_func_t, __memcpy_aarch64);
+ }
+}
+MEMCPY_SHIM()
+
+DEFINE_IFUNC_FOR(memmove) {
+ if (arg->_hwcap2 & HWCAP2_MOPS) {
+ RETURN_FUNC(memmove_func_t, __memmove_aarch64_mops);
+ } else if (__bionic_is_oryon(arg->_hwcap)) {
+ RETURN_FUNC(memmove_func_t, __memmove_aarch64_nt);
+ } else if (arg->_hwcap & HWCAP_ASIMD) {
+ RETURN_FUNC(memmove_func_t, __memmove_aarch64_simd);
+ } else {
+ RETURN_FUNC(memmove_func_t, __memmove_aarch64);
+ }
+}
+MEMMOVE_SHIM()
+
DEFINE_IFUNC_FOR(memrchr) {
- RETURN_FUNC(memrchr_func, __memrchr_aarch64);
+ RETURN_FUNC(memrchr_func_t, __memrchr_aarch64);
}
+MEMRCHR_SHIM()
-typedef int memset_func(void*, int, size_t);
DEFINE_IFUNC_FOR(memset) {
- if (__bionic_is_oryon(arg->_hwcap)) {
- RETURN_FUNC(memset_func, __memset_aarch64_nt);
- } else {
- RETURN_FUNC(memset_func, __memset_aarch64);
- }
+ if (arg->_hwcap2 & HWCAP2_MOPS) {
+ RETURN_FUNC(memset_func_t, __memset_aarch64_mops);
+ } else if (__bionic_is_oryon(arg->_hwcap)) {
+ RETURN_FUNC(memset_func_t, __memset_aarch64_nt);
+ } else {
+ RETURN_FUNC(memset_func_t, __memset_aarch64);
+ }
}
+MEMSET_SHIM()
-typedef char* stpcpy_func(char*, const char*, size_t);
DEFINE_IFUNC_FOR(stpcpy) {
- // TODO: enable the SVE version.
- RETURN_FUNC(stpcpy_func, __stpcpy_aarch64);
+ // TODO: enable the SVE version.
+ RETURN_FUNC(stpcpy_func_t, __stpcpy_aarch64);
}
+STPCPY_SHIM()
-typedef char* strchr_func(const char*, int);
DEFINE_IFUNC_FOR(strchr) {
- if (arg->_hwcap2 & HWCAP2_MTE) {
- RETURN_FUNC(strchr_func, __strchr_aarch64_mte);
- } else {
- RETURN_FUNC(strchr_func, __strchr_aarch64);
- }
+ if (arg->_hwcap2 & HWCAP2_MTE) {
+ RETURN_FUNC(strchr_func_t, __strchr_aarch64_mte);
+ } else {
+ RETURN_FUNC(strchr_func_t, __strchr_aarch64);
+ }
}
+STRCHR_SHIM()
-typedef char* strchrnul_func(const char*, int);
DEFINE_IFUNC_FOR(strchrnul) {
- if (arg->_hwcap2 & HWCAP2_MTE) {
- RETURN_FUNC(strchrnul_func, __strchrnul_aarch64_mte);
- } else {
- RETURN_FUNC(strchrnul_func, __strchrnul_aarch64);
- }
+ if (arg->_hwcap2 & HWCAP2_MTE) {
+ RETURN_FUNC(strchrnul_func_t, __strchrnul_aarch64_mte);
+ } else {
+ RETURN_FUNC(strchrnul_func_t, __strchrnul_aarch64);
+ }
}
+STRCHRNUL_SHIM()
-typedef int strcmp_func(const char*, const char*);
DEFINE_IFUNC_FOR(strcmp) {
- // TODO: enable the SVE version.
- RETURN_FUNC(strcmp_func, __strcmp_aarch64);
+ // TODO: enable the SVE version.
+ RETURN_FUNC(strcmp_func_t, __strcmp_aarch64);
}
+STRCMP_SHIM()
-typedef char* strcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(strcpy) {
- // TODO: enable the SVE version.
- RETURN_FUNC(strcpy_func, __strcpy_aarch64);
+ // TODO: enable the SVE version.
+ RETURN_FUNC(strcpy_func_t, __strcpy_aarch64);
}
+STRCPY_SHIM()
-typedef size_t strlen_func(const char*);
DEFINE_IFUNC_FOR(strlen) {
- if (arg->_hwcap2 & HWCAP2_MTE) {
- RETURN_FUNC(strlen_func, __strlen_aarch64_mte);
- } else {
- RETURN_FUNC(strlen_func, __strlen_aarch64);
- }
+ if (arg->_hwcap2 & HWCAP2_MTE) {
+ RETURN_FUNC(strlen_func_t, __strlen_aarch64_mte);
+ } else {
+ RETURN_FUNC(strlen_func_t, __strlen_aarch64);
+ }
}
+STRLEN_SHIM()
-typedef int strncmp_func(const char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncmp) {
- // TODO: enable the SVE version.
- RETURN_FUNC(strncmp_func, __strncmp_aarch64);
+ // TODO: enable the SVE version.
+ RETURN_FUNC(strncmp_func_t, __strncmp_aarch64);
}
+STRNCMP_SHIM()
-typedef size_t strnlen_func(const char*, size_t);
DEFINE_IFUNC_FOR(strnlen) {
- // TODO: enable the SVE version.
- RETURN_FUNC(strnlen_func, __strnlen_aarch64);
+ // TODO: enable the SVE version.
+ RETURN_FUNC(strnlen_func_t, __strnlen_aarch64);
}
+STRNLEN_SHIM()
-typedef char* strrchr_func(const char*, int);
DEFINE_IFUNC_FOR(strrchr) {
- if (arg->_hwcap2 & HWCAP2_MTE) {
- RETURN_FUNC(strrchr_func, __strrchr_aarch64_mte);
- } else {
- RETURN_FUNC(strrchr_func, __strrchr_aarch64);
- }
+ if (arg->_hwcap2 & HWCAP2_MTE) {
+ RETURN_FUNC(strrchr_func_t, __strrchr_aarch64_mte);
+ } else {
+ RETURN_FUNC(strrchr_func_t, __strrchr_aarch64);
+ }
}
+STRRCHR_SHIM()
} // extern "C"
diff --git a/libc/arch-arm64/static_function_dispatch.S b/libc/arch-arm64/static_function_dispatch.S
deleted file mode 100644
index 18c3783..0000000
--- a/libc/arch-arm64/static_function_dispatch.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2019 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.
- */
-
-#include <private/bionic_asm.h>
-
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- b impl; \
-END(name)
-
-FUNCTION_DELEGATE(memchr, __memchr_aarch64_mte)
-FUNCTION_DELEGATE(memcmp, __memcmp_aarch64)
-FUNCTION_DELEGATE(memcpy, __memcpy_aarch64)
-FUNCTION_DELEGATE(memmove, __memmove_aarch64)
-FUNCTION_DELEGATE(memrchr, __memrchr_aarch64)
-FUNCTION_DELEGATE(memset, __memset_aarch64)
-FUNCTION_DELEGATE(stpcpy, __stpcpy_aarch64)
-FUNCTION_DELEGATE(strchr, __strchr_aarch64_mte)
-FUNCTION_DELEGATE(strchrnul, __strchrnul_aarch64_mte)
-FUNCTION_DELEGATE(strcmp, __strcmp_aarch64)
-FUNCTION_DELEGATE(strcpy, __strcpy_aarch64)
-FUNCTION_DELEGATE(strlen, __strlen_aarch64_mte)
-FUNCTION_DELEGATE(strrchr, __strrchr_aarch64_mte)
-FUNCTION_DELEGATE(strncmp, __strncmp_aarch64)
-FUNCTION_DELEGATE(strnlen, __strnlen_aarch64)
-
-NOTE_GNU_PROPERTY()
diff --git a/libc/arch-riscv64/dynamic_function_dispatch.cpp b/libc/arch-riscv64/dynamic_function_dispatch.cpp
index bb2ba51..ce6c028 100644
--- a/libc/arch-riscv64/dynamic_function_dispatch.cpp
+++ b/libc/arch-riscv64/dynamic_function_dispatch.cpp
@@ -27,12 +27,11 @@
*/
#include <fcntl.h>
+#include <private/bionic_ifuncs.h>
#include <stddef.h>
#include <sys/syscall.h>
#include <unistd.h>
-#include <private/bionic_ifuncs.h>
-
extern "C" {
static inline __always_inline int ifunc_faccessat(int dir_fd, const char* path, int mode) {
@@ -53,94 +52,94 @@
return result;
}
-typedef void* memchr_func(const void*, int, size_t);
DEFINE_IFUNC_FOR(memchr) {
- if (have_fast_v()) RETURN_FUNC(memchr_func, memchr_v);
- RETURN_FUNC(memchr_func, memchr_gc);
+ if (have_fast_v()) RETURN_FUNC(memchr_func_t, memchr_v);
+ RETURN_FUNC(memchr_func_t, memchr_gc);
}
+MEMCHR_SHIM()
-typedef int memcmp_func(const void*, const void*, size_t);
DEFINE_IFUNC_FOR(memcmp) {
- if (have_fast_v()) RETURN_FUNC(memcmp_func, memcmp_v);
- RETURN_FUNC(memcmp_func, memcmp_gc);
+ if (have_fast_v()) RETURN_FUNC(memcmp_func_t, memcmp_v);
+ RETURN_FUNC(memcmp_func_t, memcmp_gc);
}
+MEMCMP_SHIM()
-typedef void* memcpy_func(void*, const void*, size_t);
DEFINE_IFUNC_FOR(memcpy) {
- if (have_fast_v()) RETURN_FUNC(memcpy_func, memcpy_v);
- RETURN_FUNC(memcpy_func, memcpy_gc);
+ if (have_fast_v()) RETURN_FUNC(memcpy_func_t, memcpy_v);
+ RETURN_FUNC(memcpy_func_t, memcpy_gc);
}
+MEMCPY_SHIM()
-typedef void* memmove_func(void*, const void*, size_t);
DEFINE_IFUNC_FOR(memmove) {
- if (have_fast_v()) RETURN_FUNC(memmove_func, memmove_v);
- RETURN_FUNC(memmove_func, memmove_gc);
+ if (have_fast_v()) RETURN_FUNC(memmove_func_t, memmove_v);
+ RETURN_FUNC(memmove_func_t, memmove_gc);
}
+MEMMOVE_SHIM()
-typedef void* memset_func(void*, int, size_t);
DEFINE_IFUNC_FOR(memset) {
- if (have_fast_v()) RETURN_FUNC(memset_func, memset_v);
- RETURN_FUNC(memset_func, memset_gc);
+ if (have_fast_v()) RETURN_FUNC(memset_func_t, memset_v);
+ RETURN_FUNC(memset_func_t, memset_gc);
}
+MEMSET_SHIM()
-typedef char* stpcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(stpcpy) {
- if (have_fast_v()) RETURN_FUNC(stpcpy_func, stpcpy_v);
- RETURN_FUNC(stpcpy_func, stpcpy_gc);
+ if (have_fast_v()) RETURN_FUNC(stpcpy_func_t, stpcpy_v);
+ RETURN_FUNC(stpcpy_func_t, stpcpy_gc);
}
+STPCPY_SHIM()
-typedef char* strcat_func(char*, const char*);
DEFINE_IFUNC_FOR(strcat) {
- if (have_fast_v()) RETURN_FUNC(strcat_func, strcat_v);
- RETURN_FUNC(strcat_func, strcat_gc);
+ if (have_fast_v()) RETURN_FUNC(strcat_func_t, strcat_v);
+ RETURN_FUNC(strcat_func_t, strcat_gc);
}
+STRCAT_SHIM()
-typedef char* strchr_func(const char*, int);
DEFINE_IFUNC_FOR(strchr) {
- if (have_fast_v()) RETURN_FUNC(strchr_func, strchr_v);
- RETURN_FUNC(strchr_func, strchr_gc);
+ if (have_fast_v()) RETURN_FUNC(strchr_func_t, strchr_v);
+ RETURN_FUNC(strchr_func_t, strchr_gc);
}
+STRCHR_SHIM()
-typedef int strcmp_func(const char*, const char*);
DEFINE_IFUNC_FOR(strcmp) {
- if (have_fast_v()) RETURN_FUNC(strcmp_func, strcmp_v);
- RETURN_FUNC(strcmp_func, strcmp_gc);
+ if (have_fast_v()) RETURN_FUNC(strcmp_func_t, strcmp_v);
+ RETURN_FUNC(strcmp_func_t, strcmp_gc);
}
+STRCMP_SHIM()
-typedef char* strcpy_func(char*, const char*);
DEFINE_IFUNC_FOR(strcpy) {
- if (have_fast_v()) RETURN_FUNC(strcpy_func, strcpy_v);
- RETURN_FUNC(strcpy_func, strcpy_gc);
+ if (have_fast_v()) RETURN_FUNC(strcpy_func_t, strcpy_v);
+ RETURN_FUNC(strcpy_func_t, strcpy_gc);
}
+STRCPY_SHIM()
-typedef size_t strlen_func(const char*);
DEFINE_IFUNC_FOR(strlen) {
- if (have_fast_v()) RETURN_FUNC(strlen_func, strlen_v);
- RETURN_FUNC(strlen_func, strlen_gc);
+ if (have_fast_v()) RETURN_FUNC(strlen_func_t, strlen_v);
+ RETURN_FUNC(strlen_func_t, strlen_gc);
}
+STRLEN_SHIM()
-typedef char* strncat_func(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncat) {
- if (have_fast_v()) RETURN_FUNC(strncat_func, strncat_v);
- RETURN_FUNC(strncat_func, strncat_gc);
+ if (have_fast_v()) RETURN_FUNC(strncat_func_t, strncat_v);
+ RETURN_FUNC(strncat_func_t, strncat_gc);
}
+STRNCAT_SHIM()
-typedef int strncmp_func(const char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncmp) {
- if (have_fast_v()) RETURN_FUNC(strncmp_func, strncmp_v);
- RETURN_FUNC(strncmp_func, strncmp_gc);
+ if (have_fast_v()) RETURN_FUNC(strncmp_func_t, strncmp_v);
+ RETURN_FUNC(strncmp_func_t, strncmp_gc);
}
+STRNCMP_SHIM()
-typedef char* strncpy_func(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strncpy) {
- if (have_fast_v()) RETURN_FUNC(strncpy_func, strncpy_v);
- RETURN_FUNC(strncpy_func, strncpy_gc);
+ if (have_fast_v()) RETURN_FUNC(strncpy_func_t, strncpy_v);
+ RETURN_FUNC(strncpy_func_t, strncpy_gc);
}
+STRNCPY_SHIM()
-typedef size_t strnlen_func(const char*, size_t);
DEFINE_IFUNC_FOR(strnlen) {
- if (have_fast_v()) RETURN_FUNC(strnlen_func, strnlen_v);
- RETURN_FUNC(strnlen_func, strnlen_gc);
+ if (have_fast_v()) RETURN_FUNC(strnlen_func_t, strnlen_v);
+ RETURN_FUNC(strnlen_func_t, strnlen_gc);
}
+STRNLEN_SHIM()
} // extern "C"
diff --git a/libc/arch-riscv64/static_function_dispatch.S b/libc/arch-riscv64/static_function_dispatch.S
deleted file mode 100644
index accfec8..0000000
--- a/libc/arch-riscv64/static_function_dispatch.S
+++ /dev/null
@@ -1,51 +0,0 @@
-/*
- * 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.
- */
-
-#include <private/bionic_asm.h>
-
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- j impl; \
-END(name)
-
-// TODO: switch to the V variants when qemu is fixed.
-FUNCTION_DELEGATE(memchr, memchr_gc)
-FUNCTION_DELEGATE(memcmp, memcmp_gc)
-FUNCTION_DELEGATE(memcpy, memcpy_gc)
-FUNCTION_DELEGATE(memmove, memmove_gc)
-FUNCTION_DELEGATE(memset, memset_gc)
-FUNCTION_DELEGATE(stpcpy, stpcpy_gc)
-FUNCTION_DELEGATE(strcat, strcat_gc)
-FUNCTION_DELEGATE(strchr, strchr_gc)
-FUNCTION_DELEGATE(strcmp, strcmp_gc)
-FUNCTION_DELEGATE(strcpy, strcpy_gc)
-FUNCTION_DELEGATE(strlen, strlen_gc)
-FUNCTION_DELEGATE(strncat, strncat_gc)
-FUNCTION_DELEGATE(strncmp, strncmp_gc)
-FUNCTION_DELEGATE(strncpy, strncpy_gc)
-FUNCTION_DELEGATE(strnlen, strnlen_gc)
diff --git a/libc/arch-x86/dynamic_function_dispatch.cpp b/libc/arch-x86/dynamic_function_dispatch.cpp
index 38d8a0a..9d7a4c9 100644
--- a/libc/arch-x86/dynamic_function_dispatch.cpp
+++ b/libc/arch-x86/dynamic_function_dispatch.cpp
@@ -26,129 +26,150 @@
* SUCH DAMAGE.
*/
-#include <stddef.h>
-
#include <private/bionic_ifuncs.h>
+#include <stddef.h>
extern "C" {
-typedef int memcmp_func(const void* __lhs, const void* __rhs, size_t __n);
DEFINE_IFUNC_FOR(memcmp) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(memcmp_func, memcmp_atom);
- if (__builtin_cpu_supports("sse4.1")) RETURN_FUNC(memcmp_func, memcmp_sse4);
- RETURN_FUNC(memcmp_func, memcmp_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(memcmp_func_t, memcmp_atom);
+ if (__builtin_cpu_supports("sse4.1")) RETURN_FUNC(memcmp_func_t, memcmp_sse4);
+ RETURN_FUNC(memcmp_func_t, memcmp_generic);
}
+MEMCMP_SHIM()
-typedef void* memset_func(void* __dst, int __ch, size_t __n);
DEFINE_IFUNC_FOR(memset) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(memset_func, memset_atom);
- RETURN_FUNC(memset_func, memset_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(memset_func_t, memset_atom);
+ RETURN_FUNC(memset_func_t, memset_generic);
}
+MEMSET_SHIM()
-typedef void* __memset_chk_func(void *s, int c, size_t n, size_t n2);
DEFINE_IFUNC_FOR(__memset_chk) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(__memset_chk_func, __memset_chk_atom);
- RETURN_FUNC(__memset_chk_func, __memset_chk_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(__memset_chk_func_t, __memset_chk_atom);
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_generic);
}
+__MEMSET_CHK_SHIM()
-typedef void* memmove_func(void* __dst, const void* __src, size_t __n);
DEFINE_IFUNC_FOR(memmove) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(memmove_func, memmove_atom);
- RETURN_FUNC(memmove_func, memmove_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(memmove_func_t, memmove_atom);
+ RETURN_FUNC(memmove_func_t, memmove_generic);
}
+MEMMOVE_SHIM()
-typedef void* memcpy_func(void*, const void*, size_t);
-DEFINE_IFUNC_FOR(memcpy) {
- return memmove_resolver();
-}
+DEFINE_IFUNC_FOR(memcpy) { return memmove_resolver(); }
+MEMCPY_SHIM()
-typedef char* strcpy_func(char* __dst, const char* __src);
DEFINE_IFUNC_FOR(strcpy) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(strcpy_func, strcpy_atom);
- RETURN_FUNC(strcpy_func, strcpy_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(strcpy_func_t, strcpy_atom);
+ RETURN_FUNC(strcpy_func_t, strcpy_generic);
}
+STRCPY_SHIM()
-typedef char* strncpy_func(char* __dst, const char* __src, size_t __n);
DEFINE_IFUNC_FOR(strncpy) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(strncpy_func, strncpy_atom);
- RETURN_FUNC(strncpy_func, strncpy_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(strncpy_func_t, strncpy_atom);
+ RETURN_FUNC(strncpy_func_t, strncpy_generic);
}
+STRNCPY_SHIM()
-typedef size_t strlen_func(const char* __s);
DEFINE_IFUNC_FOR(strlen) {
- __builtin_cpu_init();
- if (__builtin_cpu_is("atom")) RETURN_FUNC(strlen_func, strlen_atom);
- RETURN_FUNC(strlen_func, strlen_generic);
+ __builtin_cpu_init();
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(strlen_func_t, strlen_atom);
+ RETURN_FUNC(strlen_func_t, strlen_generic);
}
+STRLEN_SHIM()
-typedef int wmemcmp_func(const wchar_t* __lhs, const wchar_t* __rhs, size_t __n);
-DEFINE_IFUNC_FOR(wmemcmp) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("sse4.1")) RETURN_FUNC(wmemcmp_func, wmemcmp_sse4);
- if (__builtin_cpu_is("atom")) RETURN_FUNC(wmemcmp_func, wmemcmp_atom);
- RETURN_FUNC(wmemcmp_func, wmemcmp_freebsd);
-}
-
-typedef int strcmp_func(const char* __lhs, const char* __rhs);
DEFINE_IFUNC_FOR(strcmp) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strcmp_func, strcmp_ssse3);
- RETURN_FUNC(strcmp_func, strcmp_generic);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strcmp_func_t, strcmp_ssse3);
+ RETURN_FUNC(strcmp_func_t, strcmp_generic);
}
+STRCMP_SHIM()
-typedef int strncmp_func(const char* __lhs, const char* __rhs, size_t __n);
DEFINE_IFUNC_FOR(strncmp) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strncmp_func, strncmp_ssse3);
- RETURN_FUNC(strncmp_func, strncmp_generic);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3"))
+ RETURN_FUNC(strncmp_func_t, strncmp_ssse3);
+ RETURN_FUNC(strncmp_func_t, strncmp_generic);
}
+STRNCMP_SHIM()
-typedef char* strcat_func(char* __dst, const char* __src);
DEFINE_IFUNC_FOR(strcat) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strcat_func, strcat_ssse3);
- RETURN_FUNC(strcat_func, strcat_generic);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strcat_func_t, strcat_ssse3);
+ RETURN_FUNC(strcat_func_t, strcat_generic);
}
+STRCAT_SHIM()
-typedef char* strncat_func(char* __dst, const char* __src, size_t __n);
DEFINE_IFUNC_FOR(strncat) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strncat_func, strncat_ssse3);
- RETURN_FUNC(strncat_func, strncat_openbsd);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strncat_func_t, strncat_ssse3);
+ RETURN_FUNC(strncat_func_t, strncat_openbsd);
}
+STRNCAT_SHIM()
-typedef size_t strlcat_func(char *dst, const char *src, size_t dsize);
+typedef size_t strlcat_func_t(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strlcat) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strlcat_func, strlcat_ssse3);
- RETURN_FUNC(strlcat_func, strlcat_openbsd);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strlcat_func_t, strlcat_ssse3);
+ RETURN_FUNC(strlcat_func_t, strlcat_openbsd);
}
+DEFINE_STATIC_SHIM(size_t strlcat(char* dst, const char* src, size_t n) {
+ FORWARD(strlcat)(dst, src, n);
+})
-typedef size_t strlcpy_func(char *dst, const char *src, size_t dsize);
+typedef size_t strlcpy_func_t(char*, const char*, size_t);
DEFINE_IFUNC_FOR(strlcpy) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strlcpy_func, strlcpy_ssse3);
- RETURN_FUNC(strlcpy_func, strlcpy_openbsd);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(strlcpy_func_t, strlcpy_ssse3);
+ RETURN_FUNC(strlcpy_func_t, strlcpy_openbsd);
}
+DEFINE_STATIC_SHIM(size_t strlcpy(char* dst, const char* src, size_t n) {
+ FORWARD(strlcpy)(dst, src, n);
+})
-typedef wchar_t* wcscat_func(wchar_t *s1, const wchar_t *s2);
+typedef wchar_t* wcscat_func_t(wchar_t*, const wchar_t*);
DEFINE_IFUNC_FOR(wcscat) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(wcscat_func, wcscat_ssse3);
- RETURN_FUNC(wcscat_func, wcscat_freebsd);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(wcscat_func_t, wcscat_ssse3);
+ RETURN_FUNC(wcscat_func_t, wcscat_freebsd);
}
+DEFINE_STATIC_SHIM(wchar_t* wcscat(wchar_t* dst, const wchar_t* src) {
+ FORWARD(wcscat)(dst, src);
+})
-typedef wchar_t* wcscpy_func(wchar_t *s1, const wchar_t *s2);
+typedef wchar_t* wcscpy_func_t(wchar_t*, const wchar_t*);
DEFINE_IFUNC_FOR(wcscpy) {
- __builtin_cpu_init();
- if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(wcscpy_func, wcscpy_ssse3);
- RETURN_FUNC(wcscpy_func, wcscpy_freebsd);
+ __builtin_cpu_init();
+ // TODO: ssse3 is required by our x86 abi!
+ if (__builtin_cpu_supports("ssse3")) RETURN_FUNC(wcscpy_func_t, wcscpy_ssse3);
+ RETURN_FUNC(wcscpy_func_t, wcscpy_freebsd);
}
+DEFINE_STATIC_SHIM(wchar_t* wcscpy(wchar_t* dst, const wchar_t* src) {
+ FORWARD(wcscpy)(dst, src);
+})
+
+typedef int wmemcmp_func_t(const wchar_t*, const wchar_t*, size_t);
+DEFINE_IFUNC_FOR(wmemcmp) {
+ __builtin_cpu_init();
+ if (__builtin_cpu_supports("sse4.1")) RETURN_FUNC(wmemcmp_func_t, wmemcmp_sse4);
+ if (__builtin_cpu_is("atom")) RETURN_FUNC(wmemcmp_func_t, wmemcmp_atom);
+ RETURN_FUNC(wmemcmp_func_t, wmemcmp_freebsd);
+}
+DEFINE_STATIC_SHIM(int wmemcmp(const wchar_t* lhs, const wchar_t* rhs, size_t n) {
+ FORWARD(wmemcmp)(lhs, rhs, n);
+})
} // extern "C"
diff --git a/libc/arch-x86/static_function_dispatch.S b/libc/arch-x86/static_function_dispatch.S
deleted file mode 100644
index 7e8e63d..0000000
--- a/libc/arch-x86/static_function_dispatch.S
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- * Copyright (C) 2018 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.
- */
-
-#include <private/bionic_asm.h>
-
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- jmp impl; \
-END(name)
-
-FUNCTION_DELEGATE(memcmp, memcmp_generic)
-FUNCTION_DELEGATE(memset, memset_generic)
-FUNCTION_DELEGATE(__memset_chk, __memset_chk_generic)
-FUNCTION_DELEGATE(memcpy, memmove_generic)
-FUNCTION_DELEGATE(memmove, memmove_generic)
-FUNCTION_DELEGATE(strcpy, strcpy_generic)
-FUNCTION_DELEGATE(strncpy, strncpy_generic)
-FUNCTION_DELEGATE(strlen, strlen_generic)
-FUNCTION_DELEGATE(strcmp, strcmp_generic)
-FUNCTION_DELEGATE(strncmp, strncmp_generic)
-FUNCTION_DELEGATE(strcat, strcat_generic)
-FUNCTION_DELEGATE(wmemcmp, wmemcmp_freebsd)
-FUNCTION_DELEGATE(wcscat, wcscat_freebsd)
-FUNCTION_DELEGATE(strncat, strncat_openbsd)
-FUNCTION_DELEGATE(strlcat, strlcat_openbsd)
-FUNCTION_DELEGATE(strlcpy, strlcpy_openbsd)
-FUNCTION_DELEGATE(wcscpy, wcscpy_freebsd)
diff --git a/libc/arch-x86/string/cache.h b/libc/arch-x86/string/cache.h
deleted file mode 100644
index 33719a0..0000000
--- a/libc/arch-x86/string/cache.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-Copyright (c) 2010, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-#ifdef FOR_ATOM
-#define SHARED_CACHE_SIZE (512 * 1024) /* Atom L2 Cache */
-#endif
-#ifdef FOR_SILVERMONT
-#define SHARED_CACHE_SIZE (1024 * 1024) /* Silvermont L2 Cache */
-#endif
-
-#define DATA_CACHE_SIZE (24 * 1024) /* Atom and Silvermont L1 Data Cache */
-
-#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
-#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
diff --git a/libc/arch-x86/string/sse2-memmove-slm.S b/libc/arch-x86/string/sse2-memmove-slm.S
index 79b5d1b..7f42374 100644
--- a/libc/arch-x86/string/sse2-memmove-slm.S
+++ b/libc/arch-x86/string/sse2-memmove-slm.S
@@ -29,7 +29,6 @@
*/
#define FOR_SILVERMONT
-#include "cache.h"
#ifndef MEMMOVE
# define MEMMOVE memmove_generic
@@ -94,6 +93,8 @@
#define RETURN_END POP (%ebx); ret
#define RETURN RETURN_END; CFI_PUSH (%ebx)
+#define SETUP_PIC_REG(x) call __x86.get_pc_thunk.x
+
.section .text.sse2,"ax",@progbits
ENTRY (MEMMOVE)
ENTRANCE
@@ -193,7 +194,13 @@
cmp %edi, %ebx
jbe L(mm_copy_remaining_forward)
- cmp $SHARED_CACHE_SIZE_HALF, %ecx
+ PUSH(%ebx)
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ cmp __x86_shared_cache_size_half@GOTOFF(%ebx), %ecx
+ /* Restore ebx. We can place a pop before jump as it doesn't affect any flags. */
+ POP(%ebx)
+
jae L(mm_large_page_loop_forward)
.p2align 4
@@ -424,7 +431,13 @@
cmp %edi, %ebx
jae L(mm_main_loop_backward_end)
- cmp $SHARED_CACHE_SIZE_HALF, %ecx
+ PUSH(%ebx)
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ cmp __x86_shared_cache_size_half@GOTOFF(%ebx), %ecx
+ /* Restore ebx. We can place a pop before jump as it doesn't affect any flags. */
+ POP(%ebx)
+
jae L(mm_large_page_loop_backward)
.p2align 4
diff --git a/libc/arch-x86/string/sse2-memset-atom.S b/libc/arch-x86/string/sse2-memset-atom.S
index 320afec..e43ead0 100644
--- a/libc/arch-x86/string/sse2-memset-atom.S
+++ b/libc/arch-x86/string/sse2-memset-atom.S
@@ -31,7 +31,6 @@
#include <private/bionic_asm.h>
#define FOR_ATOM
-#include "cache.h"
#ifndef L
# define L(label) .L##label
@@ -64,6 +63,8 @@
#define RETURN RETURN_END; CFI_PUSH(%ebx)
#define JMPTBL(I, B) I - B
+#define SETUP_PIC_REG(x) call __x86.get_pc_thunk.x
+
/* Load an entry in a jump table into EBX and branch to it. TABLE is a
jump table with relative offsets. */
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
@@ -256,14 +257,20 @@
ALIGN(4)
L(128bytesormore):
PUSH(%ebx)
- mov $SHARED_CACHE_SIZE, %ebx
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ mov __x86_shared_cache_size@GOTOFF(%ebx), %ebx
cmp %ebx, %ecx
jae L(128bytesormore_nt_start)
POP(%ebx)
# define RESTORE_EBX_STATE CFI_PUSH(%ebx)
- cmp $DATA_CACHE_SIZE, %ecx
+ PUSH(%ebx)
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ cmp __x86_data_cache_size@GOTOFF(%ebx), %ecx
+ POP(%ebx)
jae L(128bytes_L2_normal)
subl $128, %ecx
diff --git a/libc/arch-x86/string/sse2-memset-slm.S b/libc/arch-x86/string/sse2-memset-slm.S
index 5cff141..e4c8fa1 100644
--- a/libc/arch-x86/string/sse2-memset-slm.S
+++ b/libc/arch-x86/string/sse2-memset-slm.S
@@ -31,7 +31,6 @@
#include <private/bionic_asm.h>
#define FOR_SILVERMONT
-#include "cache.h"
#ifndef L
# define L(label) .L##label
@@ -64,6 +63,8 @@
# define RETURN RETURN_END; CFI_PUSH(%ebx)
# define JMPTBL(I, B) I - B
+#define SETUP_PIC_REG(x) call __x86.get_pc_thunk.x
+
/* Load an entry in a jump table into EBX and branch to it. TABLE is a
jump table with relative offsets. */
# define BRANCH_TO_JMPTBL_ENTRY(TABLE) \
@@ -177,14 +178,18 @@
ALIGN(4)
L(128bytesormore):
PUSH(%ebx)
- mov $SHARED_CACHE_SIZE, %ebx
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ mov __x86_shared_cache_size@GOTOFF(%ebx), %ebx
cmp %ebx, %ecx
jae L(128bytesormore_nt_start)
POP(%ebx)
PUSH(%ebx)
- mov $DATA_CACHE_SIZE, %ebx
+ SETUP_PIC_REG(bx)
+ add $_GLOBAL_OFFSET_TABLE_, %ebx
+ mov __x86_data_cache_size@GOTOFF(%ebx), %ebx
cmp %ebx, %ecx
jae L(128bytes_L2_normal)
diff --git a/libc/arch-x86/string/ssse3-memcpy-atom.S b/libc/arch-x86/string/ssse3-memcpy-atom.S
index fe3082e..83e1985 100644
--- a/libc/arch-x86/string/ssse3-memcpy-atom.S
+++ b/libc/arch-x86/string/ssse3-memcpy-atom.S
@@ -29,7 +29,6 @@
*/
#define FOR_ATOM
-#include "cache.h"
#ifndef MEMCPY
# define MEMCPY memcpy_atom
diff --git a/libc/arch-x86_64/bionic/__set_tls.c b/libc/arch-x86_64/bionic/__set_tls.c
index 10fd36f..9460a03 100644
--- a/libc/arch-x86_64/bionic/__set_tls.c
+++ b/libc/arch-x86_64/bionic/__set_tls.c
@@ -27,11 +27,12 @@
*/
#include <sys/cdefs.h>
-#include <asm/prctl.h>
-#include <stdint.h>
-extern int __arch_prctl(int, unsigned long);
+// ARCH_SET_FS is not exposed via <sys/prctl.h> or <linux/prctl.h>.
+#include <asm/prctl.h>
+
+extern int arch_prctl(int, unsigned long);
__LIBC_HIDDEN__ int __set_tls(void* ptr) {
- return __arch_prctl(ARCH_SET_FS, (uintptr_t) ptr);
+ return arch_prctl(ARCH_SET_FS, (unsigned long) ptr);
}
diff --git a/libc/arch-x86_64/dynamic_function_dispatch.cpp b/libc/arch-x86_64/dynamic_function_dispatch.cpp
index c846ded..cbe68a3 100644
--- a/libc/arch-x86_64/dynamic_function_dispatch.cpp
+++ b/libc/arch-x86_64/dynamic_function_dispatch.cpp
@@ -32,18 +32,18 @@
extern "C" {
-typedef int memset_func(void* __dst, int __ch, size_t __n);
DEFINE_IFUNC_FOR(memset) {
__builtin_cpu_init();
- if (__builtin_cpu_supports("avx2")) RETURN_FUNC(memset_func, memset_avx2);
- RETURN_FUNC(memset_func, memset_generic);
+ if (__builtin_cpu_supports("avx2")) RETURN_FUNC(memset_func_t, memset_avx2);
+ RETURN_FUNC(memset_func_t, memset_generic);
}
+MEMSET_SHIM()
-typedef void* __memset_chk_func(void* s, int c, size_t n, size_t n2);
DEFINE_IFUNC_FOR(__memset_chk) {
__builtin_cpu_init();
- if (__builtin_cpu_supports("avx2")) RETURN_FUNC(__memset_chk_func, __memset_chk_avx2);
- RETURN_FUNC(__memset_chk_func, __memset_chk_generic);
+ if (__builtin_cpu_supports("avx2")) RETURN_FUNC(__memset_chk_func_t, __memset_chk_avx2);
+ RETURN_FUNC(__memset_chk_func_t, __memset_chk_generic);
}
+__MEMSET_CHK_SHIM()
} // extern "C"
diff --git a/libc/arch-x86_64/string/avx2-memset-kbl.S b/libc/arch-x86_64/string/avx2-memset-kbl.S
index ca62a9f..35d682a 100644
--- a/libc/arch-x86_64/string/avx2-memset-kbl.S
+++ b/libc/arch-x86_64/string/avx2-memset-kbl.S
@@ -30,7 +30,6 @@
#include <private/bionic_asm.h>
-#include "cache.h"
#ifndef L
# define L(label) .L##label
@@ -117,11 +116,8 @@
cmpq %rcx, %rdx
je L(done)
-#ifdef SHARED_CACHE_SIZE
- cmp $SHARED_CACHE_SIZE, %r8
-#else
- cmp __x86_64_shared_cache_size(%rip), %r8
-#endif
+ cmp __x86_shared_cache_size(%rip), %r8
+
ja L(non_temporal_loop)
ALIGN (4)
diff --git a/libc/arch-x86_64/string/cache.h b/libc/arch-x86_64/string/cache.h
deleted file mode 100644
index 4131509..0000000
--- a/libc/arch-x86_64/string/cache.h
+++ /dev/null
@@ -1,36 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-/* Values are optimized for Core Architecture */
-#define SHARED_CACHE_SIZE (4096*1024) /* Core Architecture L2 Cache */
-#define DATA_CACHE_SIZE (24*1024) /* Core Architecture L1 Data Cache */
-
-#define SHARED_CACHE_SIZE_HALF (SHARED_CACHE_SIZE / 2)
-#define DATA_CACHE_SIZE_HALF (DATA_CACHE_SIZE / 2)
diff --git a/libc/arch-x86_64/string/sse2-memmove-slm.S b/libc/arch-x86_64/string/sse2-memmove-slm.S
index 7395028..8b32680 100644
--- a/libc/arch-x86_64/string/sse2-memmove-slm.S
+++ b/libc/arch-x86_64/string/sse2-memmove-slm.S
@@ -28,7 +28,6 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "cache.h"
#ifndef MEMMOVE
# define MEMMOVE memmove
@@ -189,8 +188,9 @@
cmp %r8, %rbx
jbe L(mm_copy_remaining_forward)
- cmp $SHARED_CACHE_SIZE_HALF, %rdx
- jae L(mm_large_page_loop_forward)
+ cmp __x86_shared_cache_size_half(%rip), %rdx
+
+ ja L(mm_overlapping_check_forward)
.p2align 4
L(mm_main_loop_forward):
@@ -414,8 +414,9 @@
cmp %r9, %rbx
jae L(mm_recalc_len)
- cmp $SHARED_CACHE_SIZE_HALF, %rdx
- jae L(mm_large_page_loop_backward)
+ cmp __x86_shared_cache_size_half(%rip), %rdx
+
+ ja L(mm_overlapping_check_backward)
.p2align 4
L(mm_main_loop_backward):
@@ -481,6 +482,13 @@
/* Big length copy forward part. */
.p2align 4
+
+L(mm_overlapping_check_forward):
+ mov %rsi, %r9
+ add %rdx, %r9
+ cmp __x86_shared_cache_size(%rip), %r9
+ jbe L(mm_main_loop_forward)
+
L(mm_large_page_loop_forward):
movdqu (%r8, %rsi), %xmm0
movdqu 16(%r8, %rsi), %xmm1
@@ -498,6 +506,14 @@
/* Big length copy backward part. */
.p2align 4
+
+L(mm_overlapping_check_backward):
+ mov %rdi, %r11
+ sub %rsi, %r11 /* r11 = dst - src, diff */
+ add %rdx, %r11
+ cmp __x86_shared_cache_size(%rip), %r11
+ jbe L(mm_main_loop_backward)
+
L(mm_large_page_loop_backward):
movdqu -64(%r9, %r8), %xmm0
movdqu -48(%r9, %r8), %xmm1
diff --git a/libc/arch-x86_64/string/sse2-memset-slm.S b/libc/arch-x86_64/string/sse2-memset-slm.S
index cceadd2..84ab327 100644
--- a/libc/arch-x86_64/string/sse2-memset-slm.S
+++ b/libc/arch-x86_64/string/sse2-memset-slm.S
@@ -30,7 +30,6 @@
#include <private/bionic_asm.h>
-#include "cache.h"
#ifndef L
# define L(label) .L##label
@@ -116,11 +115,8 @@
cmpq %rcx, %rdx
je L(return)
-#ifdef SHARED_CACHE_SIZE
- cmp $SHARED_CACHE_SIZE, %r8
-#else
- cmp __x86_64_shared_cache_size(%rip), %r8
-#endif
+ cmp __x86_shared_cache_size(%rip), %r8
+
ja L(128bytesmore_nt)
ALIGN (4)
diff --git a/libc/arch-x86_64/string/sse4-memcmp-slm.S b/libc/arch-x86_64/string/sse4-memcmp-slm.S
index 8a8b180..46ad78d 100644
--- a/libc/arch-x86_64/string/sse4-memcmp-slm.S
+++ b/libc/arch-x86_64/string/sse4-memcmp-slm.S
@@ -28,7 +28,6 @@
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include "cache.h"
#ifndef MEMCMP
# define MEMCMP memcmp
@@ -353,11 +352,7 @@
ALIGN (4)
L(512bytesormore):
-#ifdef DATA_CACHE_SIZE_HALF
- mov $DATA_CACHE_SIZE_HALF, %r8
-#else
- mov __x86_64_data_cache_size_half(%rip), %r8
-#endif
+ mov __x86_data_cache_size_half(%rip), %r8
mov %r8, %r9
shr $1, %r8
add %r9, %r8
@@ -669,11 +664,7 @@
ALIGN (4)
L(512bytesormorein2aligned):
-#ifdef DATA_CACHE_SIZE_HALF
- mov $DATA_CACHE_SIZE_HALF, %r8
-#else
- mov __x86_64_data_cache_size_half(%rip), %r8
-#endif
+ mov __x86_data_cache_size_half(%rip), %r8
mov %r8, %r9
shr $1, %r8
add %r9, %r8
diff --git a/libc/bionic/NetdClientDispatch.cpp b/libc/bionic/NetdClientDispatch.cpp
index e6f4a97..be5fb11 100644
--- a/libc/bionic/NetdClientDispatch.cpp
+++ b/libc/bionic/NetdClientDispatch.cpp
@@ -20,18 +20,12 @@
#include "private/bionic_fdtrack.h"
-#ifdef __i386__
-#define __socketcall __attribute__((__cdecl__))
-#else
-#define __socketcall
-#endif
-
-extern "C" __socketcall int __accept4(int, sockaddr*, socklen_t*, int);
-extern "C" __socketcall int __connect(int, const sockaddr*, socklen_t);
-extern "C" __socketcall int __sendmmsg(int, const mmsghdr*, unsigned int, int);
-extern "C" __socketcall ssize_t __sendmsg(int, const msghdr*, unsigned int);
-extern "C" __socketcall int __sendto(int, const void*, size_t, int, const sockaddr*, socklen_t);
-extern "C" __socketcall int __socket(int, int, int);
+extern "C" int __accept4(int, sockaddr*, socklen_t*, int);
+extern "C" int __connect(int, const sockaddr*, socklen_t);
+extern "C" int __sendmmsg(int, const mmsghdr*, unsigned int, int);
+extern "C" ssize_t __sendmsg(int, const msghdr*, unsigned int);
+extern "C" int __sendto(int, const void*, size_t, int, const sockaddr*, socklen_t);
+extern "C" int __socket(int, int, int);
static unsigned fallBackNetIdForResolv(unsigned netId) {
return netId;
diff --git a/libc/bionic/abort.cpp b/libc/bionic/abort.cpp
index c8bba01..1b7a5e6 100644
--- a/libc/bionic/abort.cpp
+++ b/libc/bionic/abort.cpp
@@ -29,27 +29,27 @@
#include <signal.h>
#include <stdlib.h>
-#include <sys/syscall.h>
#include <unistd.h>
#include "private/bionic_inline_raise.h"
void abort() {
- // Don't block SIGABRT to give any signal handler a chance; we ignore
- // any errors -- X311J doesn't allow abort to return anyway.
- sigset64_t mask;
- sigfillset64(&mask);
- sigdelset64(&mask, SIGABRT);
+ // Since abort() must not return, there's no error checking in this function:
+ // there's no way to report an error anyway.
- sigprocmask64(SIG_SETMASK, &mask, nullptr);
+ // Unblock SIGABRT to give any signal handler a chance.
+ sigset64_t mask;
+ sigemptyset64(&mask);
+ sigaddset64(&mask, SIGABRT);
+ sigprocmask64(SIG_UNBLOCK, &mask, nullptr);
+
+ // Use inline_raise() to raise SIGABRT without adding an uninteresting
+ // stack frame that anyone investigating the crash would have to ignore.
inline_raise(SIGABRT);
- // If SIGABRT is ignored or it's caught and the handler returns,
- // remove the SIGABRT signal handler and raise SIGABRT again.
- struct sigaction64 sa = { .sa_handler = SIG_DFL, .sa_flags = SA_RESTART };
- sigaction64(SIGABRT, &sa, nullptr);
-
- sigprocmask64(SIG_SETMASK, &mask, nullptr);
+ // If that signal was ignored or was caught and the handler returned,
+ // remove the signal handler and raise SIGABRT again.
+ signal(SIGABRT, SIG_DFL);
inline_raise(SIGABRT);
// If we get this far, just exit.
diff --git a/libc/bionic/bionic_allocator.cpp b/libc/bionic/bionic_allocator.cpp
index 80e8b08..41baf8b 100644
--- a/libc/bionic/bionic_allocator.cpp
+++ b/libc/bionic/bionic_allocator.cpp
@@ -299,7 +299,7 @@
log2_size = kSmallObjectMinSizeLog2;
}
- return get_small_object_allocator(log2_size)->alloc();
+ return get_small_object_allocator_unchecked(log2_size)->alloc();
}
void* BionicAllocator::alloc(size_t size) {
@@ -330,9 +330,10 @@
inline page_info* BionicAllocator::get_page_info(void* ptr) {
page_info* info = get_page_info_unchecked(ptr);
if (memcmp(info->signature, kSignature, sizeof(kSignature)) != 0) {
- async_safe_fatal("invalid pointer %p (page signature mismatch)", ptr);
+ async_safe_fatal("invalid pointer %p (page signature %04x instead of %04x)", ptr,
+ *reinterpret_cast<const unsigned*>(info->signature),
+ *reinterpret_cast<const unsigned*>(kSignature));
}
-
return info;
}
@@ -353,12 +354,7 @@
if (info->type == kLargeObject) {
old_size = info->allocated_size - (static_cast<char*>(ptr) - reinterpret_cast<char*>(info));
} else {
- BionicSmallObjectAllocator* allocator = get_small_object_allocator(info->type);
- if (allocator != info->allocator_addr) {
- async_safe_fatal("invalid pointer %p (page signature mismatch)", ptr);
- }
-
- old_size = allocator->get_block_size();
+ old_size = get_small_object_allocator(info, ptr)->get_block_size();
}
if (old_size < size) {
@@ -377,16 +373,10 @@
}
page_info* info = get_page_info(ptr);
-
if (info->type == kLargeObject) {
munmap(info, info->allocated_size);
} else {
- BionicSmallObjectAllocator* allocator = get_small_object_allocator(info->type);
- if (allocator != info->allocator_addr) {
- async_safe_fatal("invalid pointer %p (invalid allocator address for the page)", ptr);
- }
-
- allocator->free(ptr);
+ get_small_object_allocator(info, ptr)->free(ptr);
}
}
@@ -402,7 +392,7 @@
return info->allocated_size - (static_cast<char*>(ptr) - reinterpret_cast<char*>(info));
}
- BionicSmallObjectAllocator* allocator = get_small_object_allocator(info->type);
+ BionicSmallObjectAllocator* allocator = get_small_object_allocator_unchecked(info->type);
if (allocator != info->allocator_addr) {
// Invalid pointer.
return 0;
@@ -410,7 +400,7 @@
return allocator->get_block_size();
}
-BionicSmallObjectAllocator* BionicAllocator::get_small_object_allocator(uint32_t type) {
+BionicSmallObjectAllocator* BionicAllocator::get_small_object_allocator_unchecked(uint32_t type) {
if (type < kSmallObjectMinSizeLog2 || type > kSmallObjectMaxSizeLog2) {
async_safe_fatal("invalid type: %u", type);
}
@@ -418,3 +408,11 @@
initialize_allocators();
return &allocators_[type - kSmallObjectMinSizeLog2];
}
+
+BionicSmallObjectAllocator* BionicAllocator::get_small_object_allocator(page_info* pi, void* ptr) {
+ BionicSmallObjectAllocator* result = get_small_object_allocator_unchecked(pi->type);
+ if (result != pi->allocator_addr) {
+ async_safe_fatal("invalid pointer %p (invalid allocator address for the page)", ptr);
+ }
+ return result;
+}
\ No newline at end of file
diff --git a/libc/bionic/bionic_elf_tls.cpp b/libc/bionic/bionic_elf_tls.cpp
index a053c27..3245b90 100644
--- a/libc/bionic/bionic_elf_tls.cpp
+++ b/libc/bionic/bionic_elf_tls.cpp
@@ -400,9 +400,10 @@
// segment.
//
// On most targets, this accessor function is __tls_get_addr and
-// TLS_GET_ADDR_CCONV is unset. 32-bit x86 uses ___tls_get_addr instead and a
-// regparm() calling convention.
-extern "C" void* TLS_GET_ADDR(const TlsIndex* ti) TLS_GET_ADDR_CCONV {
+// TLS_GET_ADDR_CALLING_CONVENTION is unset, but 32-bit x86 uses
+// ___tls_get_addr (with three underscores) instead, and a regparm
+// calling convention.
+extern "C" void* TLS_GET_ADDR(const TlsIndex* ti) TLS_GET_ADDR_CALLING_CONVENTION {
TlsDtv* dtv = __get_tcb_dtv(__get_bionic_tcb());
// TODO: See if we can use a relaxed memory ordering here instead.
diff --git a/libc/bionic/clock.cpp b/libc/bionic/clock.cpp
index 31e6c3c..45d29b7 100644
--- a/libc/bionic/clock.cpp
+++ b/libc/bionic/clock.cpp
@@ -32,7 +32,7 @@
#include "private/bionic_constants.h"
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/clock.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/clock.html
clock_t clock() {
timespec ts;
clock_gettime(CLOCK_PROCESS_CPUTIME_ID, &ts);
diff --git a/libc/bionic/exec.cpp b/libc/bionic/exec.cpp
index 863aa97..56544d0 100644
--- a/libc/bionic/exec.cpp
+++ b/libc/bionic/exec.cpp
@@ -41,10 +41,8 @@
#include "private/FdPath.h"
#include "private/__bionic_get_shell_path.h"
-#include "pthread_internal.h"
extern "C" char** environ;
-extern "C" int __execve(const char* pathname, char* const* argv, char* const* envp);
enum { ExecL, ExecLE, ExecLP };
@@ -183,8 +181,3 @@
if (errno == ENOENT) errno = EBADF;
return -1;
}
-
-__attribute__((no_sanitize("memtag"))) int execve(const char* pathname, char* const* argv,
- char* const* envp) {
- return __execve(pathname, argv, envp);
-}
diff --git a/libc/bionic/execinfo.cpp b/libc/bionic/execinfo.cpp
index d129f7c..e53a037 100644
--- a/libc/bionic/execinfo.cpp
+++ b/libc/bionic/execinfo.cpp
@@ -73,6 +73,11 @@
#elif defined(__aarch64__)
// All instructions are 4 bytes long, skip back one instruction.
ip -= 4;
+#elif defined(__riscv)
+ // C instructions are the shortest at 2 bytes long. (Unlike thumb, it's
+ // non-trivial to recognize C instructions when going backwards in the
+ // instruction stream.)
+ ip -= 2;
#elif defined(__i386__) || defined(__x86_64__)
// It's difficult to decode exactly where the previous instruction is,
// so subtract 1 to estimate where the instruction lives.
diff --git a/libc/bionic/exit.cpp b/libc/bionic/exit.cpp
index 04baac2..8eda5b2 100644
--- a/libc/bionic/exit.cpp
+++ b/libc/bionic/exit.cpp
@@ -26,24 +26,22 @@
* SUCH DAMAGE.
*/
+#include <pthread.h>
#include <stdlib.h>
#include <unistd.h>
#include "private/bionic_defs.h"
-#include "pthread_internal.h"
extern "C" void __cxa_finalize(void* dso_handle);
extern "C" void __cxa_thread_finalize();
-extern "C" __noreturn void __exit_group(int status);
-__attribute__((no_sanitize("memtag"))) void _exit(int status) {
- __exit_group(status);
-}
-
-__strong_alias(_Exit, _exit);
+static pthread_mutex_t g_exit_mutex = PTHREAD_RECURSIVE_MUTEX_INITIALIZER_NP;
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
void exit(int status) {
+ // https://austingroupbugs.net/view.php?id=1845
+ pthread_mutex_lock(&g_exit_mutex);
+
__cxa_thread_finalize();
__cxa_finalize(nullptr);
_exit(status);
diff --git a/libc/bionic/getauxval.cpp b/libc/bionic/getauxval.cpp
index a3c6b19..51ff949 100644
--- a/libc/bionic/getauxval.cpp
+++ b/libc/bionic/getauxval.cpp
@@ -26,18 +26,18 @@
* SUCH DAMAGE.
*/
-#include <stddef.h>
-#include <sys/cdefs.h>
-#include <sys/auxv.h>
-#include <private/bionic_auxv.h>
-#include <private/bionic_globals.h>
-#include <private/bionic_ifuncs.h>
#include <elf.h>
#include <errno.h>
+#include <private/bionic_auxv.h>
+#include <private/bionic_globals.h>
+#include <stddef.h>
+#include <sys/auxv.h>
// This function needs to be safe to call before TLS is set up, so it can't
// access errno or the stack protector.
-__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) {
+// Cannot use HWASan, as this is called during setup of the HWASan runtime to
+// determine the page size.
+__LIBC_HIDDEN__ unsigned long __bionic_getauxval(unsigned long type, bool* exists) __attribute__((no_sanitize("hwaddress"))) {
for (ElfW(auxv_t)* v = __libc_shared_globals()->auxv; v->a_type != AT_NULL; ++v) {
if (v->a_type == type) {
*exists = true;
@@ -48,7 +48,9 @@
return 0;
}
-extern "C" unsigned long getauxval(unsigned long type) {
+// Cannot use HWASan, as this is called during setup of the HWASan runtime to
+// determine the page size.
+extern "C" unsigned long getauxval(unsigned long type) __attribute__((no_sanitize("hwaddress"))) {
bool exists;
unsigned long result = __bionic_getauxval(type, &exists);
if (!exists) errno = ENOENT;
diff --git a/libc/bionic/getpagesize.cpp b/libc/bionic/getpagesize.cpp
index da97633..fbcabd8 100644
--- a/libc/bionic/getpagesize.cpp
+++ b/libc/bionic/getpagesize.cpp
@@ -29,7 +29,6 @@
#include <unistd.h>
#include "platform/bionic/page.h"
-// Portable code should use sysconf(_SC_PAGE_SIZE) directly instead.
int getpagesize() {
// We dont use sysconf(3) here because that drags in stdio, which makes static binaries fat.
return page_size();
diff --git a/libc/bionic/gwp_asan_wrappers.cpp b/libc/bionic/gwp_asan_wrappers.cpp
index 11f7ced..2124f51 100644
--- a/libc/bionic/gwp_asan_wrappers.cpp
+++ b/libc/bionic/gwp_asan_wrappers.cpp
@@ -57,7 +57,7 @@
static gwp_asan::GuardedPoolAllocator GuardedAlloc;
static const MallocDispatch* prev_dispatch;
-using Action = android_mallopt_gwp_asan_options_t::Action;
+using Mode = android_mallopt_gwp_asan_options_t::Mode;
using Options = gwp_asan::options::Options;
// basename() is a mess, see the manpage. Let's be explicit what handling we
@@ -261,8 +261,8 @@
options->Recoverable = true;
GwpAsanRecoverable = true;
- if (mallopt_options.desire == Action::TURN_ON_WITH_SAMPLING ||
- mallopt_options.desire == Action::TURN_ON_FOR_APP_SAMPLED_NON_CRASHING) {
+ if (mallopt_options.mode == Mode::SYSTEM_PROCESS_OR_SYSTEM_APP ||
+ mallopt_options.mode == Mode::APP_MANIFEST_DEFAULT) {
*process_sample_rate = kDefaultProcessSampling;
} else {
*process_sample_rate = 1;
@@ -285,7 +285,7 @@
// be used. Tests still continue to use the environment variable though.
if (*basename != '\0') {
const char* default_sysprop = system_sysprop;
- if (mallopt_options.desire == Action::TURN_ON_FOR_APP) {
+ if (mallopt_options.mode == Mode::APP_MANIFEST_ALWAYS) {
default_sysprop = app_sysprop;
}
async_safe_format_buffer(&program_specific_sysprop[0], kSyspropMaxLen, "%s%s",
@@ -425,7 +425,7 @@
Options options;
unsigned process_sample_rate = kDefaultProcessSampling;
if (!GetGwpAsanOptions(&options, &process_sample_rate, mallopt_options) &&
- mallopt_options.desire == Action::DONT_TURN_ON_UNLESS_OVERRIDDEN) {
+ mallopt_options.mode == Mode::APP_MANIFEST_NEVER) {
return false;
}
@@ -492,7 +492,7 @@
android_mallopt_gwp_asan_options_t mallopt_options;
mallopt_options.program_name = progname;
- mallopt_options.desire = Action::TURN_ON_WITH_SAMPLING;
+ mallopt_options.mode = Mode::SYSTEM_PROCESS_OR_SYSTEM_APP;
return MaybeInitGwpAsan(globals, mallopt_options);
}
diff --git a/libc/bionic/heap_tagging.cpp b/libc/bionic/heap_tagging.cpp
index 4d1981c..6741be3 100644
--- a/libc/bionic/heap_tagging.cpp
+++ b/libc/bionic/heap_tagging.cpp
@@ -34,10 +34,16 @@
#include <platform/bionic/malloc.h>
#include <sanitizer/hwasan_interface.h>
#include <sys/auxv.h>
+#include <sys/prctl.h>
extern "C" void scudo_malloc_disable_memory_tagging();
extern "C" void scudo_malloc_set_track_allocation_stacks(int);
+extern "C" const char* __scudo_get_stack_depot_addr();
+extern "C" const char* __scudo_get_ring_buffer_addr();
+extern "C" size_t __scudo_get_ring_buffer_size();
+extern "C" size_t __scudo_get_stack_depot_size();
+
// Protected by `g_heap_tagging_lock`.
static HeapTaggingLevel heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
@@ -47,6 +53,8 @@
heap_tagging_level = __libc_shared_globals()->initial_heap_tagging_level;
#endif
+ __libc_memtag_stack_abi = __libc_shared_globals()->initial_memtag_stack_abi;
+
__libc_globals.mutate([](libc_globals* globals) {
switch (heap_tagging_level) {
case M_HEAP_TAGGING_LEVEL_TBI:
@@ -158,6 +166,10 @@
set_tcf_on_all_threads(PR_MTE_TCF_SYNC);
#if defined(USE_SCUDO) && !__has_feature(hwaddress_sanitizer)
scudo_malloc_set_track_allocation_stacks(1);
+ __libc_shared_globals()->scudo_ring_buffer = __scudo_get_ring_buffer_addr();
+ __libc_shared_globals()->scudo_ring_buffer_size = __scudo_get_ring_buffer_size();
+ __libc_shared_globals()->scudo_stack_depot = __scudo_get_stack_depot_addr();
+ __libc_shared_globals()->scudo_stack_depot_size = __scudo_get_stack_depot_size();
#endif
}
break;
@@ -174,6 +186,9 @@
#ifdef __aarch64__
static inline __attribute__((no_sanitize("memtag"))) void untag_memory(void* from, void* to) {
+ if (from == to) {
+ return;
+ }
__asm__ __volatile__(
".arch_extension mte\n"
"1:\n"
diff --git a/libc/bionic/icu_static.cpp b/libc/bionic/icu_static.cpp
index e81e291..cf24a38 100644
--- a/libc/bionic/icu_static.cpp
+++ b/libc/bionic/icu_static.cpp
@@ -29,6 +29,6 @@
#include "private/icu.h"
// We don't have dlopen/dlsym for static binaries yet.
-__attribute__((weak)) void* __find_icu_symbol(const char*) {
+void* __find_icu_symbol(const char*) {
return nullptr;
}
diff --git a/libc/bionic/icu_wrappers.cpp b/libc/bionic/icu_wrappers.cpp
index d9f2745..523f5a6 100644
--- a/libc/bionic/icu_wrappers.cpp
+++ b/libc/bionic/icu_wrappers.cpp
@@ -40,10 +40,3 @@
reinterpret_cast<u_getIntPropertyValue_t>(__find_icu_symbol("u_getIntPropertyValue"));
return u_getIntPropertyValue ? u_getIntPropertyValue(wc, property) : 0;
}
-
-bool __icu_hasBinaryProperty(wint_t wc, UProperty property, int (*fallback)(int)) {
- typedef UBool (*u_hasBinaryProperty_t)(UChar32, UProperty);
- static auto u_hasBinaryProperty =
- reinterpret_cast<u_hasBinaryProperty_t>(__find_icu_symbol("u_hasBinaryProperty"));
- return u_hasBinaryProperty ? u_hasBinaryProperty(wc, property) : fallback(wc);
-}
diff --git a/libc/bionic/jemalloc_wrapper.cpp b/libc/bionic/jemalloc_wrapper.cpp
index a2bb1db..1bbdb29 100644
--- a/libc/bionic/jemalloc_wrapper.cpp
+++ b/libc/bionic/jemalloc_wrapper.cpp
@@ -77,9 +77,13 @@
int je_mallopt(int param, int value) {
// The only parameter we currently understand is M_DECAY_TIME.
if (param == M_DECAY_TIME) {
- // Only support setting the value to 1 or 0.
+ // Only support setting the value to -1 or 0 or 1.
ssize_t decay_time_ms;
- if (value) {
+ if (value < 0) {
+ // Given that SSIZE_MAX may not be supported in jemalloc, set this to a
+ // sufficiently large number that essentially disables the decay timer.
+ decay_time_ms = 10000000;
+ } else if (value) {
decay_time_ms = 1000;
} else {
decay_time_ms = 0;
diff --git a/libc/bionic/langinfo.cpp b/libc/bionic/langinfo.cpp
index 6f5057c..9645475 100644
--- a/libc/bionic/langinfo.cpp
+++ b/libc/bionic/langinfo.cpp
@@ -98,6 +98,4 @@
return const_cast<char*>(result);
}
-char* nl_langinfo_l(nl_item item, locale_t) {
- return nl_langinfo(item);
-}
+__strong_alias(nl_langinfo_l, nl_langinfo)
diff --git a/libc/bionic/time_l.cpp b/libc/bionic/lchmod.cpp
similarity index 84%
rename from libc/bionic/time_l.cpp
rename to libc/bionic/lchmod.cpp
index e5fa9a5..928a724 100644
--- a/libc/bionic/time_l.cpp
+++ b/libc/bionic/lchmod.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,11 @@
* SUCH DAMAGE.
*/
-#include <time.h>
-//#include <xlocale.h>
+#include <fcntl.h>
+#include <sys/stat.h>
+#include <sys/types.h>
+#include <unistd.h>
-char* strptime_l(const char* buf, const char* fmt, struct tm* tm, locale_t) {
- return strptime(buf, fmt, tm);
+int lchmod(const char* path, mode_t mode) {
+ return fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW);
}
diff --git a/libc/bionic/legacy_32_bit_support.cpp b/libc/bionic/legacy_32_bit_support.cpp
index 41108e6..e66126b 100644
--- a/libc/bionic/legacy_32_bit_support.cpp
+++ b/libc/bionic/legacy_32_bit_support.cpp
@@ -31,23 +31,28 @@
#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
+#include <stdint.h>
+#include <sys/mman.h>
#include <sys/resource.h>
#include <sys/types.h>
-#include <sys/uio.h>
-#include <sys/vfs.h>
#include <unistd.h>
+#include "platform/bionic/macros.h"
+#include "platform/bionic/page.h"
+#include "private/ErrnoRestorer.h"
#include "private/bionic_fdtrack.h"
#if defined(__LP64__)
#error This code is only needed on 32-bit systems!
#endif
-// System calls we need.
+// To implement lseek64() on ILP32, we need to use the _llseek() system call
+// which splits the off64_t into two 32-bit arguments and returns the off64_t
+// result via a pointer because 32-bit kernels can't accept 64-bit arguments
+// or return 64-bit results. (Our symbol is __llseek with two underscores for
+// historical reasons, but it's exposed as ABI so we can't fix it.)
extern "C" int __llseek(int, unsigned long, unsigned long, off64_t*, int);
-// For lseek64 we need to use the llseek system call which splits the off64_t in two and
-// returns the off64_t result via a pointer because 32-bit kernels can't return 64-bit results.
off64_t lseek64(int fd, off64_t off, int whence) {
off64_t result;
unsigned long off_hi = static_cast<unsigned long>(off >> 32);
@@ -101,3 +106,64 @@
}
return result;
}
+
+// mmap2(2) is like mmap(2), but the offset is in 4096-byte blocks (regardless
+// of page size), not bytes, to enable mapping parts of large files past the
+// 4GiB limit but without the inconvenience of dealing with 64-bit values, with
+// no down side since mappings need to be page aligned anyway, and the 32-bit
+// architectures that support this system call all have 4KiB pages.
+extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
+
+void* mmap64(void* addr, size_t size, int prot, int flags, int fd, off64_t offset) {
+ static constexpr size_t MMAP2_SHIFT = 12;
+
+ if (offset < 0 || (offset & ((1UL << MMAP2_SHIFT) - 1)) != 0) {
+ errno = EINVAL;
+ return MAP_FAILED;
+ }
+
+ // Prevent allocations large enough for `end - start` to overflow,
+ // to avoid security bugs.
+ size_t rounded = __BIONIC_ALIGN(size, page_size());
+ if (rounded < size || rounded > PTRDIFF_MAX) {
+ errno = ENOMEM;
+ return MAP_FAILED;
+ }
+
+ return __mmap2(addr, size, prot, flags, fd, offset >> MMAP2_SHIFT);
+}
+
+void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) {
+ return mmap64(addr, size, prot, flags, fd, static_cast<off64_t>(offset));
+}
+
+// The only difference here is that the libc API uses varargs for the
+// optional `new_address` argument that's only used by MREMAP_FIXED.
+extern "C" void* __mremap(void*, size_t, size_t, int, void*);
+
+void* mremap(void* old_address, size_t old_size, size_t new_size, int flags, ...) {
+ // Prevent allocations large enough for `end - start` to overflow,
+ // to avoid security bugs.
+ size_t rounded = __BIONIC_ALIGN(new_size, page_size());
+ if (rounded < new_size || rounded > PTRDIFF_MAX) {
+ errno = ENOMEM;
+ return MAP_FAILED;
+ }
+
+ // The optional argument is only valid if the MREMAP_FIXED flag is set,
+ // so we assume it's not present otherwise.
+ void* new_address = nullptr;
+ if ((flags & MREMAP_FIXED) != 0) {
+ va_list ap;
+ va_start(ap, flags);
+ new_address = va_arg(ap, void*);
+ va_end(ap);
+ }
+ return __mremap(old_address, old_size, new_size, flags, new_address);
+}
+
+// mseal(2) is LP64-only.
+int mseal(void*, size_t, unsigned long) {
+ errno = ENOSYS;
+ return -1;
+}
diff --git a/libc/bionic/libc_init_common.cpp b/libc/bionic/libc_init_common.cpp
index c82c52e..94ba7e4 100644
--- a/libc/bionic/libc_init_common.cpp
+++ b/libc/bionic/libc_init_common.cpp
@@ -58,11 +58,34 @@
__LIBC_HIDDEN__ constinit WriteProtected<libc_globals> __libc_globals;
__LIBC_HIDDEN__ constinit _Atomic(bool) __libc_memtag_stack;
+__LIBC_HIDDEN__ constinit bool __libc_memtag_stack_abi;
// Not public, but well-known in the BSDs.
__BIONIC_WEAK_VARIABLE_FOR_NATIVE_BRIDGE
const char* __progname;
+#if defined(__i386__) || defined(__x86_64__)
+// Default sizes based on the old hard-coded values for Atom/Silvermont (x86) and Core 2 (x86-64)...
+size_t __x86_data_cache_size = 24 * 1024;
+size_t __x86_data_cache_size_half = __x86_data_cache_size / 2;
+size_t __x86_shared_cache_size = sizeof(long) == 8 ? 4096 * 1024 : 1024 * 1024;
+size_t __x86_shared_cache_size_half = __x86_shared_cache_size / 2;
+// ...overwritten at runtime based on the cpu's reported cache sizes.
+static void __libc_init_x86_cache_info() {
+ // Handle the case where during early boot /sys fs may not yet be ready,
+ // resulting in sysconf() returning 0, leading to crashes.
+ // In that case (basically just init), we keep the defaults.
+ if (sysconf(_SC_LEVEL1_DCACHE_SIZE) != 0) {
+ __x86_data_cache_size = sysconf(_SC_LEVEL1_DCACHE_SIZE);
+ __x86_data_cache_size_half = __x86_data_cache_size / 2;
+ }
+ if (sysconf(_SC_LEVEL2_CACHE_SIZE) != 0) {
+ __x86_shared_cache_size = sysconf(_SC_LEVEL2_CACHE_SIZE);
+ __x86_shared_cache_size_half = __x86_shared_cache_size / 2;
+ }
+}
+#endif
+
void __libc_init_globals() {
// Initialize libc globals that are needed in both the linker and in libc.
// In dynamic binaries, this is run at least twice for different copies of the
@@ -77,8 +100,10 @@
#if !defined(__LP64__)
static void __check_max_thread_id() {
if (gettid() > 65535) {
- async_safe_fatal("Limited by the size of pthread_mutex_t, 32 bit bionic libc only accepts "
- "pid <= 65535, but current pid is %d", gettid());
+ async_safe_fatal("32-bit pthread_mutex_t only supports pids <= 65535; "
+ "current pid %d; "
+ "`echo 65535 > /proc/sys/kernel/pid_max` as root",
+ gettid());
}
}
#endif
@@ -172,6 +197,10 @@
__system_properties_init(); // Requires 'environ'.
__libc_init_fdsan(); // Requires system properties (for debug.fdsan).
__libc_init_fdtrack();
+
+#if defined(__i386__) || defined(__x86_64__)
+ __libc_init_x86_cache_info();
+#endif
}
void __libc_init_fork_handler() {
@@ -181,9 +210,9 @@
extern "C" void scudo_malloc_set_add_large_allocation_slack(int add_slack);
-__BIONIC_WEAK_FOR_NATIVE_BRIDGE void __libc_set_target_sdk_version(int target __unused) {
+__BIONIC_WEAK_FOR_NATIVE_BRIDGE void __libc_set_target_sdk_version(int target_api_level __unused) {
#if defined(USE_SCUDO) && !__has_feature(hwaddress_sanitizer)
- scudo_malloc_set_add_large_allocation_slack(target < __ANDROID_API_S__);
+ scudo_malloc_set_add_large_allocation_slack(target_api_level < 31);
#endif
}
diff --git a/libc/bionic/libc_init_dynamic.cpp b/libc/bionic/libc_init_dynamic.cpp
index 1180a51..541e71c 100644
--- a/libc/bionic/libc_init_dynamic.cpp
+++ b/libc/bionic/libc_init_dynamic.cpp
@@ -61,8 +61,9 @@
};
void memtag_stack_dlopen_callback() {
- async_safe_format_log(ANDROID_LOG_INFO, "libc", "remapping stacks as PROT_MTE");
- __pthread_internal_remap_stack_with_mte();
+ if (__pthread_internal_remap_stack_with_mte()) {
+ async_safe_format_log(ANDROID_LOG_DEBUG, "libc", "remapped stacks as PROT_MTE");
+ }
}
// Use an initializer so __libc_sysinfo will have a fallback implementation
diff --git a/libc/bionic/libc_init_static.cpp b/libc/bionic/libc_init_static.cpp
index d86df30..f8f7d2a 100644
--- a/libc/bionic/libc_init_static.cpp
+++ b/libc/bionic/libc_init_static.cpp
@@ -30,6 +30,7 @@
#include <elf.h>
#include <errno.h>
#include <malloc.h>
+#include <signal.h>
#include <stddef.h>
#include <stdint.h>
#include <stdio.h>
@@ -289,12 +290,54 @@
// We can't short-circuit the environment override, as `stack` is still inherited from the
// binary's settings.
- if (get_environment_memtag_setting(&level)) {
- if (level == M_HEAP_TAGGING_LEVEL_NONE || level == M_HEAP_TAGGING_LEVEL_TBI) {
- *stack = false;
+ get_environment_memtag_setting(&level);
+ return level;
+}
+
+static void __enable_mte_signal_handler(int, siginfo_t* info, void*) {
+ if (info->si_code != SI_TIMER) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Got BIONIC_ENABLE_MTE not from SI_TIMER");
+ return;
+ }
+ int tagged_addr_ctrl = prctl(PR_GET_TAGGED_ADDR_CTRL, 0, 0, 0, 0);
+ if (tagged_addr_ctrl < 0) {
+ async_safe_fatal("failed to PR_GET_TAGGED_ADDR_CTRL: %m");
+ }
+ if ((tagged_addr_ctrl & PR_MTE_TCF_MASK) != PR_MTE_TCF_NONE) {
+ return;
+ }
+ async_safe_format_log(ANDROID_LOG_INFO, "libc",
+ "Re-enabling MTE, value: %x (tagged_addr_ctrl %lu)",
+ info->si_value.sival_int, info->si_value.sival_int & PR_MTE_TCF_MASK);
+ tagged_addr_ctrl =
+ (tagged_addr_ctrl & ~PR_MTE_TCF_MASK) | (info->si_value.sival_int & PR_MTE_TCF_MASK);
+ if (prctl(PR_SET_TAGGED_ADDR_CTRL, tagged_addr_ctrl, 0, 0, 0) < 0) {
+ async_safe_fatal("failed to PR_SET_TAGGED_ADDR_CTRL %d: %m", tagged_addr_ctrl);
+ }
+}
+
+static int64_t __get_memtag_upgrade_secs() {
+ char* env = getenv("BIONIC_MEMTAG_UPGRADE_SECS");
+ if (!env) return 0;
+ int64_t timed_upgrade = 0;
+ static const char kAppProcessName[] = "app_process64";
+ const char* progname = __libc_shared_globals()->init_progname;
+ progname = progname ? __gnu_basename(progname) : nullptr;
+ // disable timed upgrade for zygote, as the thread spawned will violate the requirement
+ // that it be single-threaded.
+ if (!progname || strncmp(progname, kAppProcessName, sizeof(kAppProcessName)) != 0) {
+ char* endptr;
+ timed_upgrade = strtoll(env, &endptr, 10);
+ if (*endptr != '\0' || timed_upgrade < 0) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "Invalid value for BIONIC_MEMTAG_UPGRADE_SECS: %s", env);
+ timed_upgrade = 0;
}
}
- return level;
+ // Make sure that this does not get passed to potential processes inheriting
+ // this environment.
+ unsetenv("BIONIC_MEMTAG_UPGRADE_SECS");
+ return timed_upgrade;
}
// Figure out the desired memory tagging mode (sync/async, heap/globals/stack) for this executable.
@@ -305,39 +348,16 @@
bool memtag_stack = false;
HeapTaggingLevel level =
__get_tagging_level(memtag_dynamic_entries, phdr_start, phdr_ct, load_bias, &memtag_stack);
- // This is used by the linker (in linker.cpp) to communicate than any library linked by this
- // executable enables memtag-stack.
- if (__libc_shared_globals()->initial_memtag_stack) {
- if (!memtag_stack) {
- async_safe_format_log(ANDROID_LOG_INFO, "libc", "enabling PROT_MTE as requested by linker");
- }
+ // initial_memtag_stack is used by the linker (in linker.cpp) to communicate than any library
+ // linked by this executable enables memtag-stack.
+ // memtag_stack is also set for static executables if they request memtag stack via the note,
+ // in which case it will differ from initial_memtag_stack.
+ if (__libc_shared_globals()->initial_memtag_stack || memtag_stack) {
memtag_stack = true;
+ __libc_shared_globals()->initial_memtag_stack_abi = true;
+ __get_bionic_tcb()->tls_slot(TLS_SLOT_STACK_MTE) = __allocate_stack_mte_ringbuffer(0, nullptr);
}
- char* env = getenv("BIONIC_MEMTAG_UPGRADE_SECS");
- static const char kAppProcessName[] = "app_process64";
- const char* progname = __libc_shared_globals()->init_progname;
- progname = progname ? __gnu_basename(progname) : nullptr;
- if (progname &&
- strncmp(progname, kAppProcessName, sizeof(kAppProcessName)) == 0) {
- // disable timed upgrade for zygote, as the thread spawned will violate the requirement
- // that it be single-threaded.
- env = nullptr;
- }
- int64_t timed_upgrade = 0;
- if (env) {
- char* endptr;
- timed_upgrade = strtoll(env, &endptr, 10);
- if (*endptr != '\0' || timed_upgrade < 0) {
- async_safe_format_log(ANDROID_LOG_ERROR, "libc",
- "Invalid value for BIONIC_MEMTAG_UPGRADE_SECS: %s",
- env);
- timed_upgrade = 0;
- }
- // Make sure that this does not get passed to potential processes inheriting
- // this environment.
- unsetenv("BIONIC_MEMTAG_UPGRADE_SECS");
- }
- if (timed_upgrade) {
+ if (int64_t timed_upgrade = __get_memtag_upgrade_secs()) {
if (level == M_HEAP_TAGGING_LEVEL_ASYNC) {
async_safe_format_log(ANDROID_LOG_INFO, "libc",
"Attempting timed MTE upgrade from async to sync.");
@@ -369,7 +389,10 @@
async_safe_fatal("error: failed to set PROT_MTE on main thread stack: %m");
}
}
-
+ struct sigaction action = {};
+ action.sa_flags = SA_SIGINFO | SA_RESTART;
+ action.sa_sigaction = __enable_mte_signal_handler;
+ sigaction(BIONIC_ENABLE_MTE, &action, nullptr);
return;
}
}
diff --git a/libc/bionic/locale.cpp b/libc/bionic/locale.cpp
index 2f4d206..a1d6909 100644
--- a/libc/bionic/locale.cpp
+++ b/libc/bionic/locale.cpp
@@ -35,17 +35,8 @@
#include <time.h>
#include <wchar.h>
-#include "platform/bionic/macros.h"
-
-#if defined(__BIONIC_BUILD_FOR_ANDROID_SUPPORT)
-#define USE_TLS_SLOT 0
-#else
-#define USE_TLS_SLOT 1
-#endif
-
-#if USE_TLS_SLOT
#include "bionic/pthread_internal.h"
-#endif
+#include "platform/bionic/macros.h"
// We only support two locales, the "C" locale (also known as "POSIX"),
// and the "C.UTF-8" locale (also known as "en_US.UTF-8").
@@ -82,10 +73,6 @@
return get_locale_mb_cur_max(uselocale(nullptr));
}
-#if !USE_TLS_SLOT
-static thread_local locale_t g_current_locale;
-#endif
-
static pthread_once_t g_locale_once = PTHREAD_ONCE_INIT;
static lconv g_locale;
@@ -180,11 +167,7 @@
}
static locale_t* get_current_locale_ptr() {
-#if USE_TLS_SLOT
return &__get_bionic_tls().locale;
-#else
- return &g_current_locale;
-#endif
}
locale_t uselocale(locale_t new_locale) {
diff --git a/libc/bionic/lockf.cpp b/libc/bionic/lockf.cpp
index 804ad68..54e13f5 100644
--- a/libc/bionic/lockf.cpp
+++ b/libc/bionic/lockf.cpp
@@ -68,6 +68,12 @@
return -1;
}
+#if defined(__LP64__)
+// For LP64, off_t == off64_t.
+__strong_alias(lockf, lockf64);
+#else
+// For ILP32 we need a shim that truncates the off64_t to off_t.
int lockf(int fd, int cmd, off_t length) {
return lockf64(fd, cmd, length);
}
+#endif
diff --git a/libc/bionic/malloc_common.cpp b/libc/bionic/malloc_common.cpp
index 9932e3e..596a1fc 100644
--- a/libc/bionic/malloc_common.cpp
+++ b/libc/bionic/malloc_common.cpp
@@ -123,7 +123,7 @@
// Track the M_DECAY_TIME mallopt calls.
if (param == M_DECAY_TIME && retval == 1) {
__libc_globals.mutate([value](libc_globals* globals) {
- if (value == 0) {
+ if (value <= 0) {
atomic_store(&globals->decay_time_enabled, false);
} else {
atomic_store(&globals->decay_time_enabled, true);
diff --git a/libc/bionic/malloc_limit.cpp b/libc/bionic/malloc_limit.cpp
index deb63f4..5128a35 100644
--- a/libc/bionic/malloc_limit.cpp
+++ b/libc/bionic/malloc_limit.cpp
@@ -31,6 +31,7 @@
#include <stdatomic.h>
#include <stdint.h>
#include <stdio.h>
+#include <unistd.h>
#include <private/bionic_malloc_dispatch.h>
diff --git a/libc/bionic/mmap.cpp b/libc/bionic/mmap.cpp
deleted file mode 100644
index f05dcb8..0000000
--- a/libc/bionic/mmap.cpp
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * 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.
- */
-
-#include <errno.h>
-#include <stdint.h>
-#include <sys/mman.h>
-#include <unistd.h>
-
-#include "platform/bionic/macros.h"
-#include "platform/bionic/page.h"
-#include "private/ErrnoRestorer.h"
-
-// mmap2(2) is like mmap(2), but the offset is in 4096-byte blocks, not bytes.
-extern "C" void* __mmap2(void*, size_t, int, int, int, size_t);
-
-#define MMAP2_SHIFT 12 // 2**12 == 4096
-
-void* mmap64(void* addr, size_t size, int prot, int flags, int fd, off64_t offset) {
- if (offset < 0 || (offset & ((1UL << MMAP2_SHIFT)-1)) != 0) {
- errno = EINVAL;
- return MAP_FAILED;
- }
-
- // Prevent allocations large enough for `end - start` to overflow.
- size_t rounded = __BIONIC_ALIGN(size, page_size());
- if (rounded < size || rounded > PTRDIFF_MAX) {
- errno = ENOMEM;
- return MAP_FAILED;
- }
-
- return __mmap2(addr, size, prot, flags, fd, offset >> MMAP2_SHIFT);
-}
-
-void* mmap(void* addr, size_t size, int prot, int flags, int fd, off_t offset) {
- return mmap64(addr, size, prot, flags, fd, static_cast<off64_t>(offset));
-}
diff --git a/libc/bionic/mremap.cpp b/libc/bionic/mremap.cpp
deleted file mode 100644
index 88ec829..0000000
--- a/libc/bionic/mremap.cpp
+++ /dev/null
@@ -1,58 +0,0 @@
-/*
- * Copyright (C) 2015 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.
- */
-
-#include <errno.h>
-#include <sys/mman.h>
-#include <stdarg.h>
-#include <stdint.h>
-#include <unistd.h>
-
-#include "platform/bionic/macros.h"
-#include "platform/bionic/page.h"
-
-extern "C" void* __mremap(void*, size_t, size_t, int, void*);
-
-void* mremap(void* old_address, size_t old_size, size_t new_size, int flags, ...) {
- // prevent allocations large enough for `end - start` to overflow
- size_t rounded = __BIONIC_ALIGN(new_size, page_size());
- if (rounded < new_size || rounded > PTRDIFF_MAX) {
- errno = ENOMEM;
- return MAP_FAILED;
- }
-
- void* new_address = nullptr;
- // The optional argument is only valid if the MREMAP_FIXED flag is set,
- // so we assume it's not present otherwise.
- if ((flags & MREMAP_FIXED) != 0) {
- va_list ap;
- va_start(ap, flags);
- new_address = va_arg(ap, void*);
- va_end(ap);
- }
- return __mremap(old_address, old_size, new_size, flags, new_address);
-}
diff --git a/libc/bionic/new.cpp b/libc/bionic/new.cpp
index c9ce163..5a6acc0 100644
--- a/libc/bionic/new.cpp
+++ b/libc/bionic/new.cpp
@@ -16,13 +16,14 @@
#include <new>
-#include <errno.h>
#include <stdlib.h>
#include <async_safe/log.h>
__attribute__((weak)) const std::nothrow_t std::nothrow = {};
+// We can't throw in bionic, so we go straight to the equivalent of
+// std::terminate for these two instead.
void* operator new(std::size_t size) {
void* p = malloc(size);
if (p == nullptr) {
@@ -30,7 +31,6 @@
}
return p;
}
-
void* operator new[](std::size_t size) {
void* p = malloc(size);
if (p == nullptr) {
@@ -39,26 +39,21 @@
return p;
}
-void operator delete(void* ptr) throw() {
- free(ptr);
-}
-
-void operator delete[](void* ptr) throw() {
- free(ptr);
-}
-
+// These two are the "nothrow" variants, so we just return nullptr on failure.
void* operator new(std::size_t size, const std::nothrow_t&) {
return malloc(size);
}
-
void* operator new[](std::size_t size, const std::nothrow_t&) {
return malloc(size);
}
-void operator delete(void* ptr, const std::nothrow_t&) throw() {
- free(ptr);
-}
+// free() can't throw anyway (except on heap corruption, which is always fatal),
+// so there's no difference between the regular and "nothrow" variants here.
+void operator delete(void* p) noexcept { free(p); }
+void operator delete[](void* p) noexcept { free(p); }
+void operator delete(void* p, const std::nothrow_t&) noexcept { free(p); }
+void operator delete[](void* p, const std::nothrow_t&) noexcept { free(p); }
-void operator delete[](void* ptr, const std::nothrow_t&) throw() {
- free(ptr);
-}
+// TODO: these can use free_sized() once we have it (http://b/284321795).
+void operator delete(void* p, std::size_t) noexcept { free(p); }
+void operator delete[](void* p, std::size_t) noexcept { free(p); }
diff --git a/libc/bionic/poll.cpp b/libc/bionic/poll.cpp
index 7d80b4c..5b58425 100644
--- a/libc/bionic/poll.cpp
+++ b/libc/bionic/poll.cpp
@@ -48,11 +48,17 @@
return __ppoll(fds, fd_count, ts_ptr, nullptr, 0);
}
+// The underlying ppoll(2) system call only takes `sigset64_t`.
+#if defined(__LP64__)
+// That's fine for LP64 where `sigset_t` and `sigset64_t` are the same.
+__strong_alias(ppoll, ppoll64);
+#else
+// ILP32 needs a shim.
int ppoll(pollfd* fds, nfds_t fd_count, const timespec* ts, const sigset_t* ss) {
- // The underlying `__ppoll` system call only takes `sigset64_t`.
SigSetConverter set{ss};
return ppoll64(fds, fd_count, ts, set.ptr);
}
+#endif
int ppoll64(pollfd* fds, nfds_t fd_count, const timespec* ts, const sigset64_t* ss) {
// The underlying __ppoll system call modifies its `struct timespec` argument.
@@ -90,12 +96,19 @@
return result;
}
+// The underlying pselect6(2) system call only takes `sigset64_t`.
+#if defined(__LP64__)
+// That's fine for LP64 where `sigset_t` and `sigset64_t` are the same.
+__strong_alias(pselect, pselect64);
+#else
+// ILP32 needs a shim.
int pselect(int fd_count, fd_set* read_fds, fd_set* write_fds, fd_set* error_fds,
const timespec* ts, const sigset_t* ss) {
// The underlying `__pselect6` system call only takes `sigset64_t`.
SigSetConverter set{ss};
return pselect64(fd_count, read_fds, write_fds, error_fds, ts, set.ptr);
}
+#endif
int pselect64(int fd_count, fd_set* read_fds, fd_set* write_fds, fd_set* error_fds,
const timespec* ts, const sigset64_t* ss) {
diff --git a/libc/bionic/posix_timers.cpp b/libc/bionic/posix_timers.cpp
index f522516..65749a4 100644
--- a/libc/bionic/posix_timers.cpp
+++ b/libc/bionic/posix_timers.cpp
@@ -34,6 +34,8 @@
#include <string.h>
#include <time.h>
+#include "private/bionic_lock.h"
+
// System calls.
extern "C" int __rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t);
extern "C" int __rt_sigtimedwait(const sigset64_t*, siginfo_t*, const timespec*, size_t);
@@ -60,6 +62,7 @@
int sigev_notify;
// The fields below are only needed for a SIGEV_THREAD timer.
+ Lock startup_handshake_lock;
pthread_t callback_thread;
void (*callback)(sigval_t);
sigval_t callback_argument;
@@ -73,6 +76,18 @@
static void* __timer_thread_start(void* arg) {
PosixTimer* timer = reinterpret_cast<PosixTimer*>(arg);
+ // Check that our parent managed to create the kernel timer and bail if not...
+ timer->startup_handshake_lock.lock();
+ if (timer->kernel_timer_id == -1) {
+ free(timer);
+ return nullptr;
+ }
+
+ // Give ourselves a specific meaningful name now we have a kernel timer.
+ char name[16]; // 16 is the kernel-imposed limit.
+ snprintf(name, sizeof(name), "POSIX timer %d", to_kernel_timer_id(timer));
+ pthread_setname_np(timer->callback_thread, name);
+
sigset64_t sigset = {};
sigaddset64(&sigset, TIMER_SIGNAL);
@@ -102,13 +117,14 @@
pthread_kill(timer->callback_thread, TIMER_SIGNAL);
}
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_create.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/timer_create.html
int timer_create(clockid_t clock_id, sigevent* evp, timer_t* timer_id) {
PosixTimer* timer = reinterpret_cast<PosixTimer*>(malloc(sizeof(PosixTimer)));
if (timer == nullptr) {
return -1;
}
+ timer->kernel_timer_id = -1;
timer->sigev_notify = (evp == nullptr) ? SIGEV_SIGNAL : evp->sigev_notify;
// If not a SIGEV_THREAD timer, the kernel can handle it without our help.
@@ -149,6 +165,10 @@
sigaddset64(&sigset, TIMER_SIGNAL);
sigset64_t old_sigset;
+ // Prevent the child thread from running until the timer has been created.
+ timer->startup_handshake_lock.init(false);
+ timer->startup_handshake_lock.lock();
+
// Use __rt_sigprocmask instead of sigprocmask64 to avoid filtering out TIMER_SIGNAL.
__rt_sigprocmask(SIG_BLOCK, &sigset, &old_sigset, sizeof(sigset));
@@ -162,26 +182,26 @@
return -1;
}
+ // Try to create the kernel timer.
sigevent se = *evp;
se.sigev_signo = TIMER_SIGNAL;
se.sigev_notify = SIGEV_THREAD_ID;
se.sigev_notify_thread_id = pthread_gettid_np(timer->callback_thread);
- if (__timer_create(clock_id, &se, &timer->kernel_timer_id) == -1) {
- __timer_thread_stop(timer);
+ rc = __timer_create(clock_id, &se, &timer->kernel_timer_id);
+
+ // Let the child run (whether we created the kernel timer or not).
+ timer->startup_handshake_lock.unlock();
+ // If __timer_create(2) failed, the child will kill itself and free the
+ // timer struct, so we just need to exit.
+ if (rc == -1) {
return -1;
}
- // Give the thread a specific meaningful name.
- // It can't do this itself because the kernel timer isn't created until after it's running.
- char name[16]; // 16 is the kernel-imposed limit.
- snprintf(name, sizeof(name), "POSIX timer %d", to_kernel_timer_id(timer));
- pthread_setname_np(timer->callback_thread, name);
-
*timer_id = timer;
return 0;
}
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_delete.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/timer_delete.html
int timer_delete(timer_t id) {
int rc = __timer_delete(to_kernel_timer_id(id));
if (rc == -1) {
@@ -200,12 +220,12 @@
return 0;
}
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_gettime.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/timer_gettime.html
int timer_gettime(timer_t id, itimerspec* ts) {
return __timer_gettime(to_kernel_timer_id(id), ts);
}
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_settime.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/timer_settime.html
// When using timer_settime to disarm a repeatable SIGEV_THREAD timer with a very small
// period (like below 1ms), the kernel may continue to send events to the callback thread
// for a few extra times. This behavior is fine because in POSIX standard: The effect of
@@ -215,7 +235,7 @@
return __timer_settime(timer->kernel_timer_id, flags, ts, ots);
}
-// http://pubs.opengroup.org/onlinepubs/9699919799/functions/timer_getoverrun.html
+// https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/timer_getoverrun.html
int timer_getoverrun(timer_t id) {
return __timer_getoverrun(to_kernel_timer_id(id));
}
diff --git a/libc/bionic/pthread_create.cpp b/libc/bionic/pthread_create.cpp
index 5bd4f16..ba20c51 100644
--- a/libc/bionic/pthread_create.cpp
+++ b/libc/bionic/pthread_create.cpp
@@ -65,6 +65,7 @@
}
void __init_bionic_tls_ptrs(bionic_tcb* tcb, bionic_tls* tls) {
+ tcb->thread()->bionic_tcb = tcb;
tcb->thread()->bionic_tls = tls;
tcb->tls_slot(TLS_SLOT_BIONIC_TLS) = tls;
}
@@ -117,12 +118,15 @@
static void __init_shadow_call_stack(pthread_internal_t* thread __unused) {
#if defined(__aarch64__) || defined(__riscv)
- // Allocate the stack and the guard region.
+ // Allocate the shadow call stack and its guard region.
char* scs_guard_region = reinterpret_cast<char*>(
- mmap(nullptr, SCS_GUARD_REGION_SIZE, 0, MAP_PRIVATE | MAP_ANON, -1, 0));
+ mmap(nullptr, SCS_GUARD_REGION_SIZE, PROT_NONE, MAP_PRIVATE | MAP_ANON, -1, 0));
+ if (scs_guard_region == MAP_FAILED) {
+ async_safe_fatal("failed to allocate shadow stack: %m");
+ }
thread->shadow_call_stack_guard_region = scs_guard_region;
- // The address is aligned to SCS_SIZE so that we only need to store the lower log2(SCS_SIZE) bits
+ // Align the address to SCS_SIZE so that we only need to store the lower log2(SCS_SIZE) bits
// in jmp_buf. See the SCS commentary in pthread_internal.h for more detail.
char* scs_aligned_guard_region =
reinterpret_cast<char*>(align_up(reinterpret_cast<uintptr_t>(scs_guard_region), SCS_SIZE));
@@ -348,7 +352,7 @@
extern "C" int __rt_sigprocmask(int, const sigset64_t*, sigset64_t*, size_t);
__attribute__((no_sanitize("hwaddress")))
-#ifdef __aarch64__
+#if defined(__aarch64__)
// This function doesn't return, but it does appear in stack traces. Avoid using return PAC in this
// function because we may end up resetting IA, which may confuse unwinders due to mismatching keys.
__attribute__((target("branch-protection=bti")))
@@ -367,13 +371,13 @@
__set_stack_and_tls_vma_name(false);
__init_additional_stacks(thread);
__rt_sigprocmask(SIG_SETMASK, &thread->start_mask, nullptr, sizeof(thread->start_mask));
-#ifdef __aarch64__
+#if defined(__aarch64__)
// Chrome's sandbox prevents this prctl, so only reset IA if the target SDK level is high enough.
// Furthermore, processes loaded from vendor partitions may have their own sandboxes that would
- // reject the prctl. Because no devices launched with PAC enabled before S, we can avoid issues on
- // upgrading devices by checking for PAC support before issuing the prctl.
+ // reject the prctl. Because no devices launched with PAC enabled before API level 31, we can
+ // avoid issues on upgrading devices by checking for PAC support before issuing the prctl.
static const bool pac_supported = getauxval(AT_HWCAP) & HWCAP_PACA;
- if (pac_supported && android_get_application_target_sdk_version() >= __ANDROID_API_S__) {
+ if (pac_supported && android_get_application_target_sdk_version() >= 31) {
prctl(PR_PAC_RESET_KEYS, PR_PAC_APIAKEY, 0, 0, 0);
}
#endif
@@ -443,6 +447,14 @@
ScopedReadLock locker(&g_thread_creation_lock);
+// This has to be done under g_thread_creation_lock or g_thread_list_lock to avoid racing with
+// __pthread_internal_remap_stack_with_mte.
+#ifdef __aarch64__
+ if (__libc_memtag_stack_abi) {
+ tcb->tls_slot(TLS_SLOT_STACK_MTE) = __allocate_stack_mte_ringbuffer(0, thread);
+ }
+#endif
+
sigset64_t block_all_mask;
sigfillset64(&block_all_mask);
__rt_sigprocmask(SIG_SETMASK, &block_all_mask, &thread->start_mask, sizeof(thread->start_mask));
diff --git a/libc/bionic/pthread_exit.cpp b/libc/bionic/pthread_exit.cpp
index f584b27..0181aba 100644
--- a/libc/bionic/pthread_exit.cpp
+++ b/libc/bionic/pthread_exit.cpp
@@ -133,20 +133,17 @@
// pthread_internal_t is freed below with stack, not here.
__pthread_internal_remove(thread);
-
- if (thread->mmap_size != 0) {
- // We need to free mapped space for detached threads when they exit.
- // That's not something we can do in C.
- __notify_thread_exit_callbacks();
- __hwasan_thread_exit();
- _exit_with_stack_teardown(thread->mmap_base, thread->mmap_size);
- }
}
- // No need to free mapped space. Either there was no space mapped, or it is left for
- // the pthread_join caller to clean up.
__notify_thread_exit_callbacks();
__hwasan_thread_exit();
+ if (old_state == THREAD_DETACHED && thread->mmap_size != 0) {
+ // We need to free mapped space for detached threads when they exit.
+ // That's not something we can do in C.
+ _exit_with_stack_teardown(thread->mmap_base, thread->mmap_size);
+ }
+ // No need to free mapped space. Either there was no space mapped,
+ // or it is left for the pthread_join caller to clean up.
__exit(0);
}
diff --git a/libc/bionic/pthread_internal.cpp b/libc/bionic/pthread_internal.cpp
index 2342aff..14cc7da 100644
--- a/libc/bionic/pthread_internal.cpp
+++ b/libc/bionic/pthread_internal.cpp
@@ -33,9 +33,12 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/prctl.h>
#include <async_safe/log.h>
+#include <bionic/mte.h>
#include <bionic/reserved_signals.h>
+#include <bionic/tls_defines.h>
#include "private/ErrnoRestorer.h"
#include "private/ScopedRWLock.h"
@@ -73,6 +76,15 @@
}
static void __pthread_internal_free(pthread_internal_t* thread) {
+#ifdef __aarch64__
+ if (void* stack_mte_tls = thread->bionic_tcb->tls_slot(TLS_SLOT_STACK_MTE)) {
+ size_t size =
+ stack_mte_ringbuffer_size_from_pointer(reinterpret_cast<uintptr_t>(stack_mte_tls));
+ void* ptr = reinterpret_cast<void*>(reinterpret_cast<uintptr_t>(stack_mte_tls) &
+ ((1ULL << 56ULL) - 1ULL));
+ munmap(ptr, size);
+ }
+#endif
if (thread->mmap_size != 0) {
// Free mapped space, including thread stack and pthread_internal_t.
munmap(thread->mmap_base, thread->mmap_size);
@@ -176,12 +188,40 @@
async_safe_fatal("stack not found in /proc/self/maps");
}
-void __pthread_internal_remap_stack_with_mte() {
#if defined(__aarch64__)
- // If process doesn't have MTE enabled, we don't need to do anything.
- if (!atomic_load(&__libc_globals->memtag)) return;
- bool prev = atomic_exchange(&__libc_memtag_stack, true);
- if (prev) return;
+__LIBC_HIDDEN__ void* __allocate_stack_mte_ringbuffer(size_t n, pthread_internal_t* thread) {
+ const char* name;
+ if (thread == nullptr) {
+ name = "stack_mte_ring:main";
+ } else {
+ // The kernel doesn't copy the name string, but this variable will last at least as long as the
+ // mapped area. We unmap the ring buffer before unmapping the rest of the thread storage.
+ auto& name_buffer = thread->stack_mte_ringbuffer_vma_name_buffer;
+ static_assert(arraysize(name_buffer) >= arraysize("stack_mte_ring:") + 11 + 1);
+ async_safe_format_buffer(name_buffer, arraysize(name_buffer), "stack_mte_ring:%d", thread->tid);
+ name = name_buffer;
+ }
+ void* ret = stack_mte_ringbuffer_allocate(n, name);
+ if (!ret) async_safe_fatal("error: failed to allocate stack mte ring buffer");
+ return ret;
+}
+#endif
+
+bool __pthread_internal_remap_stack_with_mte() {
+#if defined(__aarch64__)
+ ScopedWriteLock creation_locker(&g_thread_creation_lock);
+ ScopedReadLock list_locker(&g_thread_list_lock);
+ // If process already uses memtag-stack ABI, we don't need to do anything.
+ if (__libc_memtag_stack_abi) return false;
+ __libc_memtag_stack_abi = true;
+
+ for (pthread_internal_t* t = g_thread_list; t != nullptr; t = t->next) {
+ if (t->terminating) continue;
+ t->bionic_tcb->tls_slot(TLS_SLOT_STACK_MTE) =
+ __allocate_stack_mte_ringbuffer(0, t->is_main() ? nullptr : t);
+ }
+ if (!atomic_load(&__libc_globals->memtag)) return false;
+ if (atomic_exchange(&__libc_memtag_stack, true)) return false;
uintptr_t lo, hi;
__find_main_stack_limits(&lo, &hi);
@@ -189,8 +229,6 @@
PROT_READ | PROT_WRITE | PROT_MTE | PROT_GROWSDOWN)) {
async_safe_fatal("error: failed to set PROT_MTE on main thread");
}
- ScopedWriteLock creation_locker(&g_thread_creation_lock);
- ScopedReadLock list_locker(&g_thread_list_lock);
for (pthread_internal_t* t = g_thread_list; t != nullptr; t = t->next) {
if (t->terminating || t->is_main()) continue;
if (mprotect(t->mmap_base_unguarded, t->mmap_size_unguarded,
@@ -198,7 +236,10 @@
async_safe_fatal("error: failed to set PROT_MTE on thread: %d", t->tid);
}
}
-#endif
+ return true;
+#else
+ return false;
+#endif // defined(__aarch64__)
}
bool android_run_on_all_threads(bool (*func)(void*), void* arg) {
diff --git a/libc/bionic/pthread_internal.h b/libc/bionic/pthread_internal.h
index 091f711..5db42ab 100644
--- a/libc/bionic/pthread_internal.h
+++ b/libc/bionic/pthread_internal.h
@@ -178,6 +178,10 @@
bionic_tls* bionic_tls;
int errno_value;
+
+ bionic_tcb* bionic_tcb;
+ char stack_mte_ringbuffer_vma_name_buffer[32];
+
bool is_main() { return start_routine == nullptr; }
};
@@ -209,6 +213,9 @@
__LIBC_HIDDEN__ void __pthread_internal_remove(pthread_internal_t* thread);
__LIBC_HIDDEN__ void __pthread_internal_remove_and_free(pthread_internal_t* thread);
__LIBC_HIDDEN__ void __find_main_stack_limits(uintptr_t* low, uintptr_t* high);
+#if defined(__aarch64__)
+__LIBC_HIDDEN__ void* __allocate_stack_mte_ringbuffer(size_t n, pthread_internal_t* thread);
+#endif
static inline __always_inline bionic_tcb* __get_bionic_tcb() {
return reinterpret_cast<bionic_tcb*>(&__get_tls()[MIN_TLS_SLOT]);
@@ -240,7 +247,7 @@
// On LP64, we could use more but there's no obvious advantage to doing
// so, and the various media processes use RLIMIT_AS as a way to limit
// the amount of allocation they'll do.
-#define PTHREAD_GUARD_SIZE max_page_size()
+#define PTHREAD_GUARD_SIZE max_android_page_size()
// SIGSTKSZ (8KiB) is not big enough.
// An snprintf to a stack buffer of size PATH_MAX consumes ~7KiB of stack.
@@ -268,8 +275,9 @@
__LIBC_HIDDEN__ extern void __bionic_atfork_run_child();
__LIBC_HIDDEN__ extern void __bionic_atfork_run_parent();
-// Re-map all threads and successively launched threads with PROT_MTE.
-__LIBC_HIDDEN__ void __pthread_internal_remap_stack_with_mte();
+// Re-map all threads and successively launched threads with PROT_MTE. Returns 'true' if remapping
+// took place, 'false' on error or if the stacks were already remapped in the past.
+__LIBC_HIDDEN__ bool __pthread_internal_remap_stack_with_mte();
extern "C" bool android_run_on_all_threads(bool (*func)(void*), void* arg);
diff --git a/libc/bionic/pthread_sigqueue.cpp b/libc/bionic/pthread_sigqueue.cpp
index 93c349e..7c10b25 100644
--- a/libc/bionic/pthread_sigqueue.cpp
+++ b/libc/bionic/pthread_sigqueue.cpp
@@ -40,14 +40,16 @@
int pthread_sigqueue(pthread_t t, int sig, const union sigval value) {
ErrnoRestorer errno_restorer;
+ pid_t pid = getpid();
+
pid_t tid = __pthread_internal_gettid(t, "pthread_sigqueue");
if (tid == -1) return ESRCH;
- siginfo_t siginfo;
- siginfo.si_code = SI_QUEUE;
- siginfo.si_pid = getpid();
+ siginfo_t siginfo = { .si_code = SI_QUEUE };
+ siginfo.si_signo = sig;
+ siginfo.si_pid = pid;
siginfo.si_uid = getuid();
siginfo.si_value = value;
- return syscall(__NR_rt_tgsigqueueinfo, getpid(), tid, sig, &siginfo) ? errno : 0;
+ return syscall(__NR_rt_tgsigqueueinfo, pid, tid, sig, &siginfo) ? errno : 0;
}
diff --git a/libc/bionic/signal.cpp b/libc/bionic/signal.cpp
index 2cf9940..5979ed7 100644
--- a/libc/bionic/signal.cpp
+++ b/libc/bionic/signal.cpp
@@ -219,10 +219,8 @@
}
int sigqueue(pid_t pid, int sig, const sigval value) {
- siginfo_t info;
- memset(&info, 0, sizeof(siginfo_t));
+ siginfo_t info = { .si_code = SI_QUEUE };
info.si_signo = sig;
- info.si_code = SI_QUEUE;
info.si_pid = getpid();
info.si_uid = getuid();
info.si_value = value;
diff --git a/libc/bionic/sigprocmask.cpp b/libc/bionic/sigprocmask.cpp
index 6d436a6..10e2fa3 100644
--- a/libc/bionic/sigprocmask.cpp
+++ b/libc/bionic/sigprocmask.cpp
@@ -41,18 +41,6 @@
// can't allow clang to decide to inline sigprocmask.
//
-int sigprocmask(int how,
- const sigset_t* bionic_new_set,
- sigset_t* bionic_old_set) __attribute__((__noinline__)) {
- SigSetConverter new_set{bionic_new_set};
- SigSetConverter old_set{bionic_old_set};
- int rc = sigprocmask64(how, new_set.ptr, old_set.ptr);
- if (rc == 0 && bionic_old_set != nullptr) {
- old_set.copy_out();
- }
- return rc;
-}
-
int sigprocmask64(int how,
const sigset64_t* new_set,
sigset64_t* old_set) __attribute__((__noinline__)) {
@@ -70,3 +58,21 @@
}
return __rt_sigprocmask(how, mutable_new_set_ptr, old_set, sizeof(*new_set));
}
+
+#if defined(__LP64__)
+// For LP64, `sigset64_t` and `sigset_t` are the same.
+__strong_alias(sigprocmask, sigprocmask64);
+#else
+// ILP32 needs a shim.
+int sigprocmask(int how,
+ const sigset_t* bionic_new_set,
+ sigset_t* bionic_old_set) __attribute__((__noinline__)) {
+ SigSetConverter new_set{bionic_new_set};
+ SigSetConverter old_set{bionic_old_set};
+ int rc = sigprocmask64(how, new_set.ptr, old_set.ptr);
+ if (rc == 0 && bionic_old_set != nullptr) {
+ old_set.copy_out();
+ }
+ return rc;
+}
+#endif
diff --git a/libc/bionic/spawn.cpp b/libc/bionic/spawn.cpp
index 38f99ad..d97057f 100644
--- a/libc/bionic/spawn.cpp
+++ b/libc/bionic/spawn.cpp
@@ -186,8 +186,8 @@
char* const argv[],
char* const env[],
int exec_fn(const char* path, char* const argv[], char* const env[])) {
- // See http://man7.org/linux/man-pages/man3/posix_spawn.3.html
- // and http://pubs.opengroup.org/onlinepubs/9699919799/functions/posix_spawn.html
+ // See https://man7.org/linux/man-pages/man3/posix_spawn.3.html
+ // and https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/posix_spawn.html
ScopedSignalBlocker ssb;
diff --git a/libc/bionic/stdlib_l.cpp b/libc/bionic/stdlib_l.cpp
index 18e9f86..a636d08 100644
--- a/libc/bionic/stdlib_l.cpp
+++ b/libc/bionic/stdlib_l.cpp
@@ -37,23 +37,6 @@
return strtof(s, end_ptr);
}
-long strtol_l(const char* s, char** end_ptr, int base, locale_t) {
- return strtol(s, end_ptr, base);
-}
-
long double strtold_l(const char* s, char** end_ptr, locale_t) {
return strtold(s, end_ptr);
}
-
-long long strtoll_l(const char* s, char** end_ptr, int base, locale_t) {
- return strtoll(s, end_ptr, base);
-}
-
-unsigned long strtoul_l(const char* s, char** end_ptr, int base, locale_t) {
- return strtoul(s, end_ptr, base);
-}
-
-unsigned long long strtoull_l(const char* s, char** end_ptr, int base, locale_t) {
- return strtoull(s, end_ptr, base);
-}
-
diff --git a/libc/bionic/strerror.cpp b/libc/bionic/strerror.cpp
index 743130d..c41b547 100644
--- a/libc/bionic/strerror.cpp
+++ b/libc/bionic/strerror.cpp
@@ -102,3 +102,4 @@
strerror_r(error_number, result, sizeof(tls.strerror_buf));
return result;
}
+__strong_alias(strerror_l, strerror);
diff --git a/libc/bionic/string_l.cpp b/libc/bionic/string_l.cpp
index 66bfb0e..84396bf 100644
--- a/libc/bionic/string_l.cpp
+++ b/libc/bionic/string_l.cpp
@@ -33,10 +33,6 @@
return strcoll(s1, s2);
}
-char* strerror_l(int error, locale_t) {
- return strerror(error);
-}
-
size_t strxfrm_l(char* dst, const char* src, size_t n, locale_t) {
return strxfrm(dst, src, n);
}
diff --git a/libc/bionic/strsignal.cpp b/libc/bionic/strsignal.cpp
index f18b6d0..29c22e2 100644
--- a/libc/bionic/strsignal.cpp
+++ b/libc/bionic/strsignal.cpp
@@ -27,29 +27,29 @@
*/
#include <signal.h>
+#include <stdlib.h>
#include <string.h>
#include "bionic/pthread_internal.h"
+// Maps regular signals like SIGSEGV to strings like "Segmentation fault".
+// Signal 0 and all the real-time signals are just nullptr, but that's the ABI.
const char* const sys_siglist[NSIG] = {
#define __BIONIC_SIGDEF(signal_number, signal_description) [signal_number] = signal_description,
#include "private/bionic_sigdefs.h"
};
+// Maps regular signals like SIGSEGV to strings like "SEGV".
+// Signal 0 and all the real-time signals are just nullptr, but that's the ABI.
const char* const sys_signame[NSIG] = {
#define __BIONIC_SIGDEF(signal_number, unused) [signal_number] = &(#signal_number)[3],
#include "private/bionic_sigdefs.h"
};
extern "C" __LIBC_HIDDEN__ const char* __strsignal(int signal_number, char* buf, size_t buf_len) {
- const char* signal_name = nullptr;
- if (signal_number >= 0 && signal_number < NSIG) {
- signal_name = sys_siglist[signal_number];
+ if (signal_number >= SIGHUP && signal_number < SIGSYS) {
+ return sys_siglist[signal_number];
}
- if (signal_name != nullptr) {
- return signal_name;
- }
-
const char* prefix = "Unknown";
if (signal_number >= SIGRTMIN && signal_number <= SIGRTMAX) {
prefix = "Real-time";
@@ -66,3 +66,72 @@
bionic_tls& tls = __get_bionic_tls();
return const_cast<char*>(__strsignal(signal_number, tls.strsignal_buf, sizeof(tls.strsignal_buf)));
}
+
+int sig2str(int sig, char* str) {
+ if (sig >= SIGHUP && sig <= SIGSYS) {
+ strcpy(str, sys_signame[sig]);
+ return 0;
+ }
+ if (sig == SIGRTMIN) {
+ strcpy(str, "RTMIN");
+ return 0;
+ }
+ if (sig == SIGRTMAX) {
+ strcpy(str, "RTMAX");
+ return 0;
+ }
+ if (sig > SIGRTMIN && sig < SIGRTMAX) {
+ if (sig - SIGRTMIN <= SIGRTMAX - sig) {
+ sprintf(str, "RTMIN+%d", sig - SIGRTMIN);
+ } else {
+ sprintf(str, "RTMAX-%d", SIGRTMAX - sig);
+ }
+ return 0;
+ }
+ return -1;
+}
+
+int str2sig(const char* str, int* sig) {
+ // A name in our list, like "SEGV"?
+ for (size_t i = SIGHUP; i <= SIGSYS; ++i) {
+ if (!strcmp(str, sys_signame[i])) {
+ *sig = i;
+ return 0;
+ }
+ }
+
+ // The two named special cases?
+ if (!strcmp(str, "RTMIN")) {
+ *sig = SIGRTMIN;
+ return 0;
+ }
+ if (!strcmp(str, "RTMAX")) {
+ *sig = SIGRTMAX;
+ return 0;
+ }
+
+ // Must be either an integer corresponding to a regular signal such as "9",
+ // or a string of the form "RTMIN+%d" or "RTMAX-%d".
+ int base = 0;
+ if (!strncmp(str, "RTMIN+", 6)) {
+ base = SIGRTMIN;
+ str += 5;
+ } else if (!strncmp(str, "RTMAX-", 6)) {
+ base = SIGRTMAX;
+ str += 5;
+ }
+ char* end = nullptr;
+ errno = 0;
+ int offset = strtol(str, &end, 10);
+ if (errno || *end) return -1;
+
+ // Reject out of range integers (like "666"),
+ // and out of range real-time signals (like "RTMIN+666" or "RTMAX-666").
+ int result = base + offset;
+ bool regular = (base == 0 && result >= SIGHUP && result <= SIGSYS);
+ bool realtime = (result >= SIGRTMIN && result <= SIGRTMAX);
+ if (!regular && !realtime) return -1;
+
+ *sig = result;
+ return 0;
+}
diff --git a/libc/bionic/strtol.cpp b/libc/bionic/strtol.cpp
index def7921..607145d 100644
--- a/libc/bionic/strtol.cpp
+++ b/libc/bionic/strtol.cpp
@@ -142,34 +142,42 @@
long strtol(const char* s, char** end, int base) {
return StrToI<long, LONG_MIN, LONG_MAX, char>(s, end, base);
}
+__strong_alias(strtol_l, strtol);
long wcstol(const wchar_t* s, wchar_t** end, int base) {
return StrToI<long, LONG_MIN, LONG_MAX, wchar_t>(s, end, base);
}
+__strong_alias(wcstol_l, wcstol);
long long strtoll(const char* s, char** end, int base) {
return StrToI<long long, LLONG_MIN, LLONG_MAX, char>(s, end, base);
}
+__strong_alias(strtoll_l, strtoll);
long long wcstoll(const wchar_t* s, wchar_t** end, int base) {
return StrToI<long long, LLONG_MIN, LLONG_MAX, wchar_t>(s, end, base);
}
+__strong_alias(wcstoll_l, wcstoll);
unsigned long strtoul(const char* s, char** end, int base) {
return StrToI<unsigned long, 0, ULONG_MAX, char>(s, end, base);
}
+__strong_alias(strtoul_l, strtoul);
unsigned long wcstoul(const wchar_t* s, wchar_t** end, int base) {
return StrToI<unsigned long, 0, ULONG_MAX, wchar_t>(s, end, base);
}
+__strong_alias(wcstoul_l, wcstoul);
unsigned long long strtoull(const char* s, char** end, int base) {
return StrToI<unsigned long long, 0, ULLONG_MAX, char>(s, end, base);
}
+__strong_alias(strtoull_l, strtoull);
unsigned long long wcstoull(const wchar_t* s, wchar_t** end, int base) {
return StrToI<unsigned long long, 0, ULLONG_MAX, wchar_t>(s, end, base);
}
+__strong_alias(wcstoull_l, wcstoull);
uintmax_t strtoumax(const char* s, char** end, int base) {
return StrToI<uintmax_t, 0, UINTMAX_MAX, char>(s, end, base);
diff --git a/libc/bionic/sync_file_range.cpp b/libc/bionic/sync_file_range.cpp
index 7f60882..e7b904d 100644
--- a/libc/bionic/sync_file_range.cpp
+++ b/libc/bionic/sync_file_range.cpp
@@ -28,13 +28,12 @@
#include <fcntl.h>
-extern "C" int __sync_file_range(int, off64_t, off64_t, unsigned int);
-extern "C" int __sync_file_range2(int, unsigned int, off64_t, off64_t);
-
-int sync_file_range(int fd, off64_t offset, off64_t length, unsigned int flags) {
#if __arm__
+// Only arm32 is missing the sync_file_range() syscall,
+// and needs us to manually re-order arguments for it.
+// (Because arm32 needs register pairs for 64-bit values to start on an even register.)
+extern "C" int __sync_file_range2(int, unsigned int, off64_t, off64_t);
+int sync_file_range(int fd, off64_t offset, off64_t length, unsigned int flags) {
return __sync_file_range2(fd, flags, offset, length);
-#else
- return __sync_file_range(fd, offset, length, flags);
-#endif
}
+#endif
diff --git a/libc/bionic/sys_msg.cpp b/libc/bionic/sys_msg.cpp
index 462c83b..9780d38 100644
--- a/libc/bionic/sys_msg.cpp
+++ b/libc/bionic/sys_msg.cpp
@@ -36,33 +36,17 @@
// Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
cmd |= IPC_64;
#endif
-#if defined(SYS_msgctl)
return syscall(SYS_msgctl, id, cmd, buf);
-#else
- return syscall(SYS_ipc, MSGCTL, id, cmd, 0, buf, 0);
-#endif
}
int msgget(key_t key, int flags) {
-#if defined(SYS_msgget)
return syscall(SYS_msgget, key, flags);
-#else
- return syscall(SYS_ipc, MSGGET, key, flags, 0, 0, 0);
-#endif
}
ssize_t msgrcv(int id, void* msg, size_t n, long type, int flags) {
-#if defined(SYS_msgrcv)
return syscall(SYS_msgrcv, id, msg, n, type, flags);
-#else
- return syscall(SYS_ipc, IPCCALL(1, MSGRCV), id, n, flags, msg, type);
-#endif
}
int msgsnd(int id, const void* msg, size_t n, int flags) {
-#if defined(SYS_msgsnd)
return syscall(SYS_msgsnd, id, msg, n, flags);
-#else
- return syscall(SYS_ipc, MSGSND, id, n, flags, msg, 0);
-#endif
}
diff --git a/libc/bionic/sys_sem.cpp b/libc/bionic/sys_sem.cpp
index 058cfef..b97bf46 100644
--- a/libc/bionic/sys_sem.cpp
+++ b/libc/bionic/sys_sem.cpp
@@ -41,19 +41,11 @@
va_start(ap, cmd);
semun arg = va_arg(ap, semun);
va_end(ap);
-#if defined(SYS_semctl)
return syscall(SYS_semctl, id, num, cmd, arg);
-#else
- return syscall(SYS_ipc, SEMCTL, id, num, cmd, &arg, 0);
-#endif
}
int semget(key_t key, int n, int flags) {
-#if defined(SYS_semget)
return syscall(SYS_semget, key, n, flags);
-#else
- return syscall(SYS_ipc, SEMGET, key, n, flags, 0, 0);
-#endif
}
int semop(int id, sembuf* ops, size_t op_count) {
@@ -64,6 +56,9 @@
#if defined(SYS_semtimedop)
return syscall(SYS_semtimedop, id, ops, op_count, ts);
#else
+ // 32-bit x86 -- the only architecture without semtimedop(2) -- only has
+ // semtimedop_time64(2), but since we don't have any timespec64 stuff,
+ // it's less painful for us to just stick with the legacy ipc(2) here.
return syscall(SYS_ipc, SEMTIMEDOP, id, op_count, 0, ops, ts);
#endif
}
diff --git a/libc/bionic/sys_shm.cpp b/libc/bionic/sys_shm.cpp
index f780e04..777b3ad 100644
--- a/libc/bionic/sys_shm.cpp
+++ b/libc/bionic/sys_shm.cpp
@@ -32,16 +32,7 @@
#include <unistd.h>
void* shmat(int id, const void* address, int flags) {
-#if defined(SYS_shmat)
return reinterpret_cast<void*>(syscall(SYS_shmat, id, address, flags));
-#else
- // See the kernel's ipc/syscall.c for the other side of this dance.
- void* result = nullptr;
- if (syscall(SYS_ipc, SHMAT, id, flags, &result, address, 0) == -1) {
- return reinterpret_cast<void*>(-1);
- }
- return result;
-#endif
}
int shmctl(int id, int cmd, struct shmid_ds* buf) {
@@ -49,25 +40,13 @@
// Annoyingly, the kernel requires this for 32-bit but rejects it for 64-bit.
cmd |= IPC_64;
#endif
-#if defined(SYS_shmctl)
return syscall(SYS_shmctl, id, cmd, buf);
-#else
- return syscall(SYS_ipc, SHMCTL, id, cmd, 0, buf, 0);
-#endif
}
int shmdt(const void* address) {
-#if defined(SYS_shmdt)
return syscall(SYS_shmdt, address);
-#else
- return syscall(SYS_ipc, SHMDT, 0, 0, 0, address, 0);
-#endif
}
int shmget(key_t key, size_t size, int flags) {
-#if defined(SYS_shmget)
return syscall(SYS_shmget, key, size, flags);
-#else
- return syscall(SYS_ipc, SHMGET, key, size, flags, 0, 0);
-#endif
}
diff --git a/libc/bionic/sys_thread_properties.cpp b/libc/bionic/sys_thread_properties.cpp
index d1a73b7..064bca1 100644
--- a/libc/bionic/sys_thread_properties.cpp
+++ b/libc/bionic/sys_thread_properties.cpp
@@ -61,7 +61,7 @@
if (modules.first_thread_exit_callback == nullptr) {
modules.first_thread_exit_callback = cb;
return;
- };
+ }
BionicAllocator& allocator = __libc_shared_globals()->tls_allocator;
CallbackHolder* new_node =
@@ -77,35 +77,9 @@
// Find the thread-pointer register for the given thread.
void** tp_reg = nullptr;
-#if defined(__x86_64__)
- {
- ErrnoRestorer errno_restorer;
- errno = 0;
- uintptr_t fs_base = ptrace(PTRACE_PEEKUSER, tid, offsetof(user_regs_struct, fs_base), nullptr);
- if (errno == 0) {
- tp_reg = reinterpret_cast<void**>(fs_base);
- }
- }
-#elif defined(__i386__)
- struct user_regs_struct regs;
- struct iovec pt_iov = {
- .iov_base = ®s,
- .iov_len = sizeof(regs),
- };
-
- if (ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &pt_iov) == 0) {
- struct user_desc u_info;
- u_info.entry_number = regs.xgs >> 3;
- if (ptrace(PTRACE_GET_THREAD_AREA, tid, u_info.entry_number, &u_info) == 0) {
- tp_reg = reinterpret_cast<void**>(u_info.base_addr);
- }
- }
-#elif defined(__aarch64__)
+#if defined(__aarch64__)
uint64_t reg;
- struct iovec pt_iov {
- .iov_base = ®, .iov_len = sizeof(reg),
- };
-
+ struct iovec pt_iov { .iov_base = ®, .iov_len = sizeof(reg) };
if (ptrace(PTRACE_GETREGSET, tid, NT_ARM_TLS, &pt_iov) == 0) {
tp_reg = reinterpret_cast<void**>(reg);
}
@@ -114,6 +88,31 @@
// Reset the tp_reg if ptrace was unsuccessful.
tp_reg = nullptr;
}
+#elif defined(__i386__)
+ struct user_regs_struct regs;
+ struct iovec pt_iov = { .iov_base = ®s, .iov_len = sizeof(regs) };
+ if (ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &pt_iov) == 0) {
+ struct user_desc u_info;
+ u_info.entry_number = regs.xgs >> 3;
+ if (ptrace(PTRACE_GET_THREAD_AREA, tid, u_info.entry_number, &u_info) == 0) {
+ tp_reg = reinterpret_cast<void**>(u_info.base_addr);
+ }
+ }
+#elif defined(__riscv)
+ struct user_regs_struct regs;
+ struct iovec pt_iov = { .iov_base = ®s, .iov_len = sizeof(regs) };
+ if (ptrace(PTRACE_GETREGSET, tid, NT_PRSTATUS, &pt_iov) == 0) {
+ tp_reg = reinterpret_cast<void**>(regs.tp);
+ }
+#elif defined(__x86_64__)
+ {
+ ErrnoRestorer errno_restorer;
+ errno = 0;
+ uintptr_t fs_base = ptrace(PTRACE_PEEKUSER, tid, offsetof(user_regs_struct, fs_base), nullptr);
+ if (errno == 0) {
+ tp_reg = reinterpret_cast<void**>(fs_base);
+ }
+ }
#endif
if (tp_reg == nullptr) {
diff --git a/libc/bionic/system.cpp b/libc/bionic/system.cpp
index 93d7497..8349498 100644
--- a/libc/bionic/system.cpp
+++ b/libc/bionic/system.cpp
@@ -38,7 +38,7 @@
int system(const char* command) {
// "The system() function shall always return non-zero when command is NULL."
- // http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
+ // https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/system.html
if (command == nullptr) return 1;
ScopedSignalBlocker sigchld_blocker(SIGCHLD);
diff --git a/libc/bionic/system_property_api.cpp b/libc/bionic/system_property_api.cpp
index 8fdea59..ed30fc2 100644
--- a/libc/bionic/system_property_api.cpp
+++ b/libc/bionic/system_property_api.cpp
@@ -26,8 +26,7 @@
* SUCH DAMAGE.
*/
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
+#include <sys/system_properties.h>
#include <async_safe/CHECK.h>
#include <system_properties/prop_area.h>
diff --git a/libc/bionic/system_property_set.cpp b/libc/bionic/system_property_set.cpp
index 6e49bce..9d73445 100644
--- a/libc/bionic/system_property_set.cpp
+++ b/libc/bionic/system_property_set.cpp
@@ -34,11 +34,10 @@
#include <stdlib.h>
#include <string.h>
#include <sys/socket.h>
+#include <sys/system_properties.h>
#include <sys/types.h>
#include <sys/uio.h>
#include <sys/un.h>
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
#include <unistd.h>
#include <async_safe/log.h>
@@ -257,6 +256,21 @@
}
}
+static const char* __prop_error_to_string(int error) {
+ switch (error) {
+ case PROP_ERROR_READ_CMD: return "PROP_ERROR_READ_CMD";
+ case PROP_ERROR_READ_DATA: return "PROP_ERROR_READ_DATA";
+ case PROP_ERROR_READ_ONLY_PROPERTY: return "PROP_ERROR_READ_ONLY_PROPERTY";
+ case PROP_ERROR_INVALID_NAME: return "PROP_ERROR_INVALID_NAME";
+ case PROP_ERROR_INVALID_VALUE: return "PROP_ERROR_INVALID_VALUE";
+ case PROP_ERROR_PERMISSION_DENIED: return "PROP_ERROR_PERMISSION_DENIED";
+ case PROP_ERROR_INVALID_CMD: return "PROP_ERROR_INVALID_CMD";
+ case PROP_ERROR_HANDLE_CONTROL_MESSAGE: return "PROP_ERROR_HANDLE_CONTROL_MESSAGE";
+ case PROP_ERROR_SET_FAILED: return "PROP_ERROR_SET_FAILED";
+ }
+ return "<unknown>";
+}
+
__BIONIC_WEAK_FOR_NATIVE_BRIDGE
int __system_property_set(const char* key, const char* value) {
if (key == nullptr) return -1;
@@ -310,8 +324,8 @@
if (result != PROP_SUCCESS) {
async_safe_format_log(ANDROID_LOG_WARN, "libc",
- "Unable to set property \"%s\" to \"%s\": error code: 0x%x", key, value,
- result);
+ "Unable to set property \"%s\" to \"%s\": %s (0x%x)", key, value,
+ __prop_error_to_string(result), result);
return -1;
}
diff --git a/libc/bionic/wchar_l.cpp b/libc/bionic/wchar_l.cpp
index 1e7a231..b2c4a00 100644
--- a/libc/bionic/wchar_l.cpp
+++ b/libc/bionic/wchar_l.cpp
@@ -41,34 +41,6 @@
return wcscoll(ws1, ws2);
}
-double wcstod_l(const wchar_t* s, wchar_t** end_ptr, locale_t) {
- return wcstod(s, end_ptr);
-}
-
-float wcstof_l(const wchar_t* s, wchar_t** end_ptr, locale_t) {
- return wcstof(s, end_ptr);
-}
-
-long wcstol_l(const wchar_t* s, wchar_t** end_ptr, int base, locale_t) {
- return wcstol(s, end_ptr, base);
-}
-
-long long wcstoll_l(const wchar_t* s, wchar_t** end_ptr, int base, locale_t) {
- return wcstoll(s, end_ptr, base);
-}
-
-unsigned long wcstoul_l(const wchar_t* s, wchar_t** end_ptr, int base, locale_t) {
- return wcstoul(s, end_ptr, base);
-}
-
-unsigned long long wcstoull_l(const wchar_t* s, wchar_t** end_ptr, int base, locale_t) {
- return wcstoull(s, end_ptr, base);
-}
-
-long double wcstold_l(const wchar_t* s, wchar_t** end_ptr, locale_t) {
- return wcstold(s, end_ptr);
-}
-
size_t wcsxfrm_l(wchar_t* dst, const wchar_t* src, size_t n, locale_t) {
return wcsxfrm(dst, src, n);
}
diff --git a/libc/bionic/wcstod.cpp b/libc/bionic/wcstod.cpp
index c82d788..00c8a08 100644
--- a/libc/bionic/wcstod.cpp
+++ b/libc/bionic/wcstod.cpp
@@ -94,11 +94,14 @@
float wcstof(const wchar_t* s, wchar_t** end) {
return wcstod<float>(s, end, strtof);
}
+__strong_alias(wcstof_l, wcstof);
double wcstod(const wchar_t* s, wchar_t** end) {
return wcstod<double>(s, end, strtod);
}
+__strong_alias(wcstod_l, wcstod);
long double wcstold(const wchar_t* s, wchar_t** end) {
return wcstod<long double>(s, end, strtold);
}
+__strong_alias(wcstold_l, wcstold);
diff --git a/libc/bionic/wctype.cpp b/libc/bionic/wctype.cpp
index 082dada..94597d9 100644
--- a/libc/bionic/wctype.cpp
+++ b/libc/bionic/wctype.cpp
@@ -34,6 +34,7 @@
#include <string.h>
#include <wchar.h>
+#include "bionic/macros.h"
#include "private/icu.h"
enum {
@@ -53,113 +54,104 @@
WC_TYPE_MAX
};
-int iswalnum(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_POSIX_ALNUM, isalnum); }
-int iswalpha(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_ALPHABETIC, isalpha); }
-int iswblank(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_POSIX_BLANK, isblank); }
-int iswgraph(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_POSIX_GRAPH, isgraph); }
-int iswlower(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_LOWERCASE, islower); }
-int iswprint(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_POSIX_PRINT, isprint); }
-int iswspace(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_WHITE_SPACE, isspace); }
-int iswupper(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_UPPERCASE, isupper); }
-int iswxdigit(wint_t wc) { return __icu_hasBinaryProperty(wc, UCHAR_POSIX_XDIGIT, isxdigit); }
+static u_hasBinaryProperty_t __find_u_hasBinaryProperty() {
+ static auto u_hasBinaryProperty =
+ reinterpret_cast<u_hasBinaryProperty_t>(__find_icu_symbol("u_hasBinaryProperty"));
+ return u_hasBinaryProperty;
+}
+
+#define DO_ISW(icu_constant, narrow_fn) \
+ u_hasBinaryProperty_t u_hasBinaryProperty; \
+ if (__predict_true(wc < 0x80) || \
+ !(u_hasBinaryProperty = __find_u_hasBinaryProperty())) { \
+ return narrow_fn(wc); \
+ } \
+ return u_hasBinaryProperty(wc, icu_constant); \
+
+int iswalnum(wint_t wc) { DO_ISW(UCHAR_POSIX_ALNUM, isalnum); }
+__strong_alias(iswalnum_l, iswalnum);
+int iswalpha(wint_t wc) { DO_ISW(UCHAR_ALPHABETIC, isalpha); }
+__strong_alias(iswalpha_l, iswalpha);
+int iswblank(wint_t wc) { DO_ISW(UCHAR_POSIX_BLANK, isblank); }
+__strong_alias(iswblank_l, iswblank);
+int iswgraph(wint_t wc) { DO_ISW(UCHAR_POSIX_GRAPH, isgraph); }
+__strong_alias(iswgraph_l, iswgraph);
+int iswlower(wint_t wc) { DO_ISW(UCHAR_LOWERCASE, islower); }
+__strong_alias(iswlower_l, iswlower);
+int iswprint(wint_t wc) { DO_ISW(UCHAR_POSIX_PRINT, isprint); }
+__strong_alias(iswprint_l, iswprint);
+int iswspace(wint_t wc) { DO_ISW(UCHAR_WHITE_SPACE, isspace); }
+__strong_alias(iswspace_l, iswspace);
+int iswupper(wint_t wc) { DO_ISW(UCHAR_UPPERCASE, isupper); }
+__strong_alias(iswupper_l, iswupper);
+int iswxdigit(wint_t wc) { DO_ISW(UCHAR_POSIX_XDIGIT, isxdigit); }
+__strong_alias(iswxdigit_l, iswxdigit);
int iswcntrl(wint_t wc) {
+ if (wc < 0x80) return iscntrl(wc);
typedef int8_t (*FnT)(UChar32);
static auto u_charType = reinterpret_cast<FnT>(__find_icu_symbol("u_charType"));
return u_charType ? (u_charType(wc) == U_CONTROL_CHAR) : iscntrl(wc);
}
+__strong_alias(iswcntrl_l, iswcntrl);
int iswdigit(wint_t wc) {
+ if (wc < 0x80) return isdigit(wc);
typedef UBool (*FnT)(UChar32);
static auto u_isdigit = reinterpret_cast<FnT>(__find_icu_symbol("u_isdigit"));
return u_isdigit ? u_isdigit(wc) : isdigit(wc);
}
+__strong_alias(iswdigit_l, iswdigit);
int iswpunct(wint_t wc) {
+ if (wc < 0x80) return ispunct(wc);
typedef UBool (*FnT)(UChar32);
static auto u_ispunct = reinterpret_cast<FnT>(__find_icu_symbol("u_ispunct"));
return u_ispunct ? u_ispunct(wc) : ispunct(wc);
}
-
-int iswalnum_l(wint_t c, locale_t) { return iswalnum(c); }
-int iswalpha_l(wint_t c, locale_t) { return iswalpha(c); }
-int iswblank_l(wint_t c, locale_t) { return iswblank(c); }
-int iswcntrl_l(wint_t c, locale_t) { return iswcntrl(c); }
-int iswdigit_l(wint_t c, locale_t) { return iswdigit(c); }
-int iswgraph_l(wint_t c, locale_t) { return iswgraph(c); }
-int iswlower_l(wint_t c, locale_t) { return iswlower(c); }
-int iswprint_l(wint_t c, locale_t) { return iswprint(c); }
-int iswpunct_l(wint_t c, locale_t) { return iswpunct(c); }
-int iswspace_l(wint_t c, locale_t) { return iswspace(c); }
-int iswupper_l(wint_t c, locale_t) { return iswupper(c); }
-int iswxdigit_l(wint_t c, locale_t) { return iswxdigit(c); }
+__strong_alias(iswpunct_l, iswpunct);
int iswctype(wint_t wc, wctype_t char_class) {
- switch (char_class) {
- case WC_TYPE_ALNUM: return iswalnum(wc);
- case WC_TYPE_ALPHA: return iswalpha(wc);
- case WC_TYPE_BLANK: return iswblank(wc);
- case WC_TYPE_CNTRL: return iswcntrl(wc);
- case WC_TYPE_DIGIT: return iswdigit(wc);
- case WC_TYPE_GRAPH: return iswgraph(wc);
- case WC_TYPE_LOWER: return iswlower(wc);
- case WC_TYPE_PRINT: return iswprint(wc);
- case WC_TYPE_PUNCT: return iswpunct(wc);
- case WC_TYPE_SPACE: return iswspace(wc);
- case WC_TYPE_UPPER: return iswupper(wc);
- case WC_TYPE_XDIGIT: return iswxdigit(wc);
- default: return 0;
- }
+ if (char_class < WC_TYPE_ALNUM || char_class > WC_TYPE_XDIGIT) return 0;
+ static int (*fns[])(wint_t) = {
+ iswalnum, iswalpha, iswblank, iswcntrl, iswdigit, iswgraph,
+ iswlower, iswprint, iswpunct, iswspace, iswupper, iswxdigit
+ };
+ return fns[char_class - WC_TYPE_ALNUM](wc);
}
-
-int iswctype_l(wint_t wc, wctype_t char_class, locale_t) {
- return iswctype(wc, char_class);
-}
+__strong_alias(iswctype_l, iswctype);
wint_t towlower(wint_t wc) {
- if (wc < 0x80) {
- if (wc >= 'A' && wc <= 'Z') return wc | 0x20;
- return wc;
- }
+ if (wc < 0x80) return tolower(wc);
typedef UChar32 (*FnT)(UChar32);
static auto u_tolower = reinterpret_cast<FnT>(__find_icu_symbol("u_tolower"));
return u_tolower ? u_tolower(wc) : tolower(wc);
}
+__strong_alias(towlower_l, towlower);
wint_t towupper(wint_t wc) {
- if (wc < 0x80) {
- // Using EOR rather than AND makes no difference on arm, but saves an
- // instruction on arm64.
- if (wc >= 'a' && wc <= 'z') return wc ^ 0x20;
- return wc;
- }
+ if (wc < 0x80) return toupper(wc);
typedef UChar32 (*FnT)(UChar32);
static auto u_toupper = reinterpret_cast<FnT>(__find_icu_symbol("u_toupper"));
return u_toupper ? u_toupper(wc) : toupper(wc);
}
-
-wint_t towupper_l(wint_t c, locale_t) { return towupper(c); }
-wint_t towlower_l(wint_t c, locale_t) { return towlower(c); }
+__strong_alias(towupper_l, towupper);
wctype_t wctype(const char* property) {
- static const char* const properties[WC_TYPE_MAX] = {
- "<invalid>",
+ static const char* const properties[WC_TYPE_MAX - 1] = {
"alnum", "alpha", "blank", "cntrl", "digit", "graph",
"lower", "print", "punct", "space", "upper", "xdigit"
};
- for (size_t i = 0; i < WC_TYPE_MAX; ++i) {
+ for (size_t i = 0; i < arraysize(properties); ++i) {
if (!strcmp(properties[i], property)) {
- return static_cast<wctype_t>(i);
+ return static_cast<wctype_t>(WC_TYPE_ALNUM + i);
}
}
return static_cast<wctype_t>(0);
}
-
-wctype_t wctype_l(const char* property, locale_t) {
- return wctype(property);
-}
+__strong_alias(wctype_l, wctype);
static wctrans_t wctrans_tolower = wctrans_t(1);
static wctrans_t wctrans_toupper = wctrans_t(2);
@@ -167,20 +159,15 @@
wctrans_t wctrans(const char* name) {
if (strcmp(name, "tolower") == 0) return wctrans_tolower;
if (strcmp(name, "toupper") == 0) return wctrans_toupper;
+ errno = EINVAL;
return nullptr;
}
-
-wctrans_t wctrans_l(const char* name, locale_t) {
- return wctrans(name);
-}
+__strong_alias(wctrans_l, wctrans);
wint_t towctrans(wint_t c, wctrans_t t) {
if (t == wctrans_tolower) return towlower(c);
if (t == wctrans_toupper) return towupper(c);
errno = EINVAL;
- return 0;
+ return c;
}
-
-wint_t towctrans_l(wint_t c, wctrans_t t, locale_t) {
- return towctrans(c, t);
-}
+__strong_alias(towctrans_l, towctrans);
diff --git a/libc/bionic/wcwidth.cpp b/libc/bionic/wcwidth.cpp
index 9676b5a..776321f 100644
--- a/libc/bionic/wcwidth.cpp
+++ b/libc/bionic/wcwidth.cpp
@@ -52,12 +52,15 @@
return -1;
case U_NON_SPACING_MARK:
case U_ENCLOSING_MARK:
- case U_FORMAT_CHAR:
return 0;
+ case U_FORMAT_CHAR:
+ // A special case for soft hyphen (U+00AD) to match historical practice.
+ // See the tests for more commentary.
+ return (wc == 0x00ad) ? 1 : 0;
}
- if (__icu_hasBinaryProperty(wc, UCHAR_DEFAULT_IGNORABLE_CODE_POINT, nullptr)) return 0;
- // Medial and final jamo render as zero width when used correctly.
+ // Medial and final jamo render as zero width when used correctly,
+ // so we handle them specially rather than relying on East Asian Width.
switch (__icu_getIntPropertyValue(wc, UCHAR_HANGUL_SYLLABLE_TYPE)) {
case U_HST_VOWEL_JAMO:
case U_HST_TRAILING_JAMO:
@@ -68,6 +71,13 @@
return 2;
}
+ // Hangeul choseong filler U+115F is default ignorable, so we check default
+ // ignorability only after we've already handled Hangeul jamo above.
+ static auto u_hasBinaryProperty =
+ reinterpret_cast<u_hasBinaryProperty_t>(__find_icu_symbol("u_hasBinaryProperty"));
+ if (u_hasBinaryProperty && u_hasBinaryProperty(wc, UCHAR_DEFAULT_IGNORABLE_CODE_POINT)) return 0;
+
+ // A few weird special cases where EastAsianWidth is not helpful for us.
if (wc >= 0x3248 && wc <= 0x4dff) {
// Circled two-digit CJK "speed sign" numbers. EastAsianWidth is ambiguous,
// but wide makes more sense.
@@ -77,6 +87,7 @@
}
// The EastAsianWidth property is at least defined by the Unicode standard!
+ // https://www.unicode.org/reports/tr11/
switch (__icu_getIntPropertyValue(wc, UCHAR_EAST_ASIAN_WIDTH)) {
case U_EA_AMBIGUOUS:
case U_EA_HALFWIDTH:
diff --git a/libc/dns/include/resolv_private.h b/libc/dns/include/resolv_private.h
index 3054555..1593aca 100644
--- a/libc/dns/include/resolv_private.h
+++ b/libc/dns/include/resolv_private.h
@@ -504,15 +504,7 @@
// ...but NetBSD calls it res_randomid.
#define res_randomid __res_randomid
-#ifdef __i386__
-# define __socketcall extern __attribute__((__cdecl__))
-#else
-# define __socketcall extern
-#endif
-
-__socketcall int __connect(int, const struct sockaddr*, socklen_t);
-
-#undef __socketcall
+int __connect(int, const struct sockaddr*, socklen_t);
// Symbols that are supposed to be in resolv.h, but that we aren't exporting.
int ns_parserr2(ns_msg*, ns_sect, int, ns_rr2*);
diff --git a/libc/dns/resolv/res_cache.c b/libc/dns/resolv/res_cache.c
index d6416e5..38de84b 100644
--- a/libc/dns/resolv/res_cache.c
+++ b/libc/dns/resolv/res_cache.c
@@ -1166,23 +1166,19 @@
}
}
-static inline void
-entry_mru_remove( Entry* e )
-{
- e->mru_prev->mru_next = e->mru_next;
- e->mru_next->mru_prev = e->mru_prev;
+static __inline__ void entry_mru_remove(Entry* e) {
+ e->mru_prev->mru_next = e->mru_next;
+ e->mru_next->mru_prev = e->mru_prev;
}
-static inline void
-entry_mru_add( Entry* e, Entry* list )
-{
- Entry* first = list->mru_next;
+static __inline__ void entry_mru_add(Entry* e, Entry* list) {
+ Entry* first = list->mru_next;
- e->mru_next = first;
- e->mru_prev = list;
+ e->mru_next = first;
+ e->mru_prev = list;
- list->mru_next = e;
- first->mru_prev = e;
+ list->mru_next = e;
+ first->mru_prev = e;
}
/* compute the hash of a given entry, this is a hash of most
diff --git a/libc/include/alloca.h b/libc/include/alloca.h
index e05dea6..2786e2f 100644
--- a/libc/include/alloca.h
+++ b/libc/include/alloca.h
@@ -36,7 +36,7 @@
#include <sys/cdefs.h>
/**
- * [alloca(3)](http://man7.org/linux/man-pages/man3/alloca.3.html) allocates space on the stack.
+ * [alloca(3)](https://man7.org/linux/man-pages/man3/alloca.3.html) allocates space on the stack.
*
* New code should not use alloca because it cannot report failure.
* Use regular heap allocation instead.
diff --git a/libc/include/android/api-level.h b/libc/include/android/api-level.h
index 113897c..1bde3a5 100644
--- a/libc/include/android/api-level.h
+++ b/libc/include/android/api-level.h
@@ -168,7 +168,10 @@
*/
#define __ANDROID_API_U__ 34
-/** Names the "V" API level (35), for comparison against `__ANDROID_API__`. */
+/**
+ * Names the Android 15 (aka "V" or "VanillaIceCream") API level (35),
+ * for comparison against `__ANDROID_API__`.
+ */
#define __ANDROID_API_V__ 35
/* This file is included in <features.h>, and might be used from .S files. */
@@ -191,7 +194,7 @@
#if __ANDROID_API__ < 29
/* android_get_device_api_level is a static inline before API level 29. */
-#define __BIONIC_GET_DEVICE_API_LEVEL_INLINE static inline
+#define __BIONIC_GET_DEVICE_API_LEVEL_INLINE static __inline
#include <bits/get_device_api_level_inlines.h>
#undef __BIONIC_GET_DEVICE_API_LEVEL_INLINE
diff --git a/libc/include/android/dlext.h b/libc/include/android/dlext.h
index a5061c7..842ceea 100644
--- a/libc/include/android/dlext.h
+++ b/libc/include/android/dlext.h
@@ -14,8 +14,7 @@
* limitations under the License.
*/
-#ifndef __ANDROID_DLEXT_H__
-#define __ANDROID_DLEXT_H__
+#pragma once
#include <stdbool.h>
#include <stddef.h>
@@ -31,7 +30,7 @@
/**
* \file
* Advanced dynamic library opening support. Most users will want to use
- * the standard [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html)
+ * the standard [dlopen(3)](https://man7.org/linux/man-pages/man3/dlopen.3.html)
* functionality in `<dlfcn.h>` instead.
*/
@@ -101,7 +100,7 @@
ANDROID_DLEXT_FORCE_LOAD = 0x40,
// Historically we had two other options for ART.
- // They were last available in Android P.
+ // They were last available in API level 28.
// Reuse these bits last!
// ANDROID_DLEXT_FORCE_FIXED_VADDR = 0x80
// ANDROID_DLEXT_LOAD_AT_FIXED_ADDRESS = 0x100
@@ -115,7 +114,7 @@
ANDROID_DLEXT_USE_NAMESPACE = 0x200,
/**
- * Instructs dlopen to apply `ANDROID_DLEXT_RESERVED_ADDRESS`,
+ * Instructs dlopen() to apply `ANDROID_DLEXT_RESERVED_ADDRESS`,
* `ANDROID_DLEXT_RESERVED_ADDRESS_HINT`, `ANDROID_DLEXT_WRITE_RELRO` and
* `ANDROID_DLEXT_USE_RELRO` to any libraries loaded as dependencies of the
* main library as well.
@@ -151,7 +150,7 @@
struct android_namespace_t;
-/** Used to pass Android-specific arguments to `android_dlopen_ext`. */
+/** Used to pass Android-specific arguments to android_dlopen_ext(). */
typedef struct {
/** A bitmask of `ANDROID_DLEXT_` enum values. */
uint64_t flags;
@@ -175,7 +174,7 @@
/**
* Opens the given library. The `__filename` and `__flags` arguments are
- * the same as for [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html),
+ * the same as for [dlopen(3)](https://man7.org/linux/man-pages/man3/dlopen.3.html),
* with the Android-specific flags supplied via the `flags` member of `__info`.
*/
void* _Nullable android_dlopen_ext(const char* _Nullable __filename, int __flags, const android_dlextinfo* _Nullable __info);
@@ -183,5 +182,3 @@
__END_DECLS
/** @} */
-
-#endif
diff --git a/libc/include/android/legacy_stdlib_inlines.h b/libc/include/android/legacy_stdlib_inlines.h
index 0ca1022..a5a07ef 100644
--- a/libc/include/android/legacy_stdlib_inlines.h
+++ b/libc/include/android/legacy_stdlib_inlines.h
@@ -38,18 +38,14 @@
__BEGIN_DECLS
-static inline double strtod_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) {
+static __inline double strtod_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) {
return strtod(__s, __end_ptr);
}
-static inline float strtof_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) {
+static __inline float strtof_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) {
return strtof(__s, __end_ptr);
}
-static inline long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) {
- return strtol(__s, __end_ptr, __base);
-}
-
__END_DECLS
#endif
diff --git a/libc/include/android/legacy_termios_inlines.h b/libc/include/android/legacy_termios_inlines.h
index e557525..a816b40 100644
--- a/libc/include/android/legacy_termios_inlines.h
+++ b/libc/include/android/legacy_termios_inlines.h
@@ -39,14 +39,14 @@
#include <sys/ioctl.h>
#include <sys/types.h>
-#define __BIONIC_TERMIOS_INLINE static inline
+#define __BIONIC_TERMIOS_INLINE static __inline
#include <bits/termios_inlines.h>
#endif
#if __ANDROID_API__ < 35
-#define __BIONIC_TERMIOS_WINSIZE_INLINE static inline
+#define __BIONIC_TERMIOS_WINSIZE_INLINE static __inline
#include <bits/termios_winsize_inlines.h>
#endif
diff --git a/libc/include/android/legacy_threads_inlines.h b/libc/include/android/legacy_threads_inlines.h
index 06e7438..c614cd0 100644
--- a/libc/include/android/legacy_threads_inlines.h
+++ b/libc/include/android/legacy_threads_inlines.h
@@ -32,7 +32,7 @@
#if __ANDROID_API__ < 30
-#define __BIONIC_THREADS_INLINE static inline
+#define __BIONIC_THREADS_INLINE static __inline
#include <bits/threads_inlines.h>
#endif
diff --git a/libc/include/android/legacy_unistd_inlines.h b/libc/include/android/legacy_unistd_inlines.h
index ac9f3b3..4a5206b 100644
--- a/libc/include/android/legacy_unistd_inlines.h
+++ b/libc/include/android/legacy_unistd_inlines.h
@@ -32,7 +32,7 @@
#if __ANDROID_API__ < 28
-#define __BIONIC_SWAB_INLINE static inline
+#define __BIONIC_SWAB_INLINE static __inline
#include <bits/swab.h>
#endif
diff --git a/libc/include/android/versioning.h b/libc/include/android/versioning.h
index c5adc02..ecbc33f 100644
--- a/libc/include/android/versioning.h
+++ b/libc/include/android/versioning.h
@@ -20,15 +20,14 @@
// we should only annotate headers when we are running versioner.
#if defined(__BIONIC_VERSIONER)
-#define __INTRODUCED_IN(api_level) __attribute__((annotate("introduced_in=" #api_level)))
-#define __INTRODUCED_IN_NO_GUARD_FOR_NDK(api_level) __attribute__((annotate("introduced_in=" #api_level))) __VERSIONER_NO_GUARD
-#define __DEPRECATED_IN(api_level) __attribute__((annotate("deprecated_in=" #api_level)))
-#define __REMOVED_IN(api_level) __attribute__((annotate("obsoleted_in=" #api_level)))
-#define __INTRODUCED_IN_32(api_level) __attribute__((annotate("introduced_in_32=" #api_level)))
-#define __INTRODUCED_IN_64(api_level) __attribute__((annotate("introduced_in_64=" #api_level)))
+#define __INTRODUCED_IN(api_level) __attribute__((__annotate__("introduced_in=" #api_level)))
+#define __DEPRECATED_IN(api_level, msg) __attribute__((__annotate__("deprecated_in=" #api_level)))
+#define __REMOVED_IN(api_level, msg) __attribute__((__annotate__("obsoleted_in=" #api_level)))
+#define __INTRODUCED_IN_32(api_level) __attribute__((__annotate__("introduced_in_32=" #api_level)))
+#define __INTRODUCED_IN_64(api_level) __attribute__((__annotate__("introduced_in_64=" #api_level)))
-#define __VERSIONER_NO_GUARD __attribute__((annotate("versioner_no_guard")))
-#define __VERSIONER_FORTIFY_INLINE __attribute__((annotate("versioner_fortify_inline")))
+#define __VERSIONER_NO_GUARD __attribute__((__annotate__("versioner_no_guard")))
+#define __VERSIONER_FORTIFY_INLINE __attribute__((__annotate__("versioner_fortify_inline")))
#else
@@ -41,22 +40,15 @@
// be enforced. In the case, the absence of 'strict' makes it possible to call an unavailable API
// without the __builtin_available check, which will cause a link error at runtime.
// Android platform build system defines this macro along with -Wunguarded-availability
-//
-// The _NO_GUARD_FOR_NDK variants keep the __VERSIONER_NO_GUARD behavior working for the NDK. This
-// allows libc++ to refer to these functions in inlines without needing to guard them, needed since
-// libc++ doesn't currently guard these calls. There's no risk to the apps though because using
-// those APIs will still cause a link error.
#if defined(__ANDROID_UNAVAILABLE_SYMBOLS_ARE_WEAK__)
-#define __BIONIC_AVAILABILITY(__what) __attribute__((__availability__(android,__what)))
-#define __INTRODUCED_IN_NO_GUARD_FOR_NDK(api_level) __INTRODUCED_IN(api_level)
+#define __BIONIC_AVAILABILITY(__what, ...) __attribute__((__availability__(android,__what __VA_OPT__(,) __VA_ARGS__)))
#else
-#define __BIONIC_AVAILABILITY(__what) __attribute__((__availability__(android,strict,__what)))
-#define __INTRODUCED_IN_NO_GUARD_FOR_NDK(api_level)
+#define __BIONIC_AVAILABILITY(__what, ...) __attribute__((__availability__(android,strict,__what __VA_OPT__(,) __VA_ARGS__)))
#endif
#define __INTRODUCED_IN(api_level) __BIONIC_AVAILABILITY(introduced=api_level)
-#define __DEPRECATED_IN(api_level) __BIONIC_AVAILABILITY(deprecated=api_level)
-#define __REMOVED_IN(api_level) __BIONIC_AVAILABILITY(obsoleted=api_level)
+#define __DEPRECATED_IN(api_level, msg) __BIONIC_AVAILABILITY(deprecated=api_level, message=msg)
+#define __REMOVED_IN(api_level, msg) __BIONIC_AVAILABILITY(obsoleted=api_level, message=msg)
// The same availability attribute can't be annotated multiple times. Therefore, the macros are
// defined for the configuration that it is valid for so that declarations like the below doesn't
@@ -80,5 +72,5 @@
// Vendor modules do not follow SDK versioning. Ignore NDK guards for vendor modules.
#if defined(__ANDROID_VENDOR__)
#undef __BIONIC_AVAILABILITY
-#define __BIONIC_AVAILABILITY(x)
+#define __BIONIC_AVAILABILITY(api_level, ...)
#endif // defined(__ANDROID_VENDOR__)
diff --git a/libc/include/bits/fcntl.h b/libc/include/bits/fcntl.h
index ee5a6e1..e3f3548 100644
--- a/libc/include/bits/fcntl.h
+++ b/libc/include/bits/fcntl.h
@@ -38,7 +38,7 @@
__BEGIN_DECLS
/**
- * [fcntl(3)](http://man7.org/linux/man-pages/man2/fcntl.2.html) performs various operations
+ * [fcntl(3)](https://man7.org/linux/man-pages/man2/fcntl.2.html) performs various operations
* on file descriptors.
*
* The return value depends on the operation.
diff --git a/libc/include/bits/fortify/socket.h b/libc/include/bits/fortify/socket.h
index 02f94cc..1c3605b 100644
--- a/libc/include/bits/fortify/socket.h
+++ b/libc/include/bits/fortify/socket.h
@@ -30,8 +30,7 @@
#error "Never include this file directly; instead, include <sys/socket.h>"
#endif
-extern ssize_t __sendto_chk(int, const void* _Nonnull, size_t, size_t, int, const struct sockaddr* _Nullable,
- socklen_t) __INTRODUCED_IN(26);
+ssize_t __sendto_chk(int, const void* _Nonnull, size_t, size_t, int, const struct sockaddr* _Nullable, socklen_t) __INTRODUCED_IN(26);
ssize_t __recvfrom_chk(int, void* _Nullable, size_t, size_t, int, struct sockaddr* _Nullable, socklen_t* _Nullable);
#if defined(__BIONIC_FORTIFY)
diff --git a/libc/include/bits/fortify/string.h b/libc/include/bits/fortify/string.h
index 7df0b05..4d32b04 100644
--- a/libc/include/bits/fortify/string.h
+++ b/libc/include/bits/fortify/string.h
@@ -38,7 +38,7 @@
size_t __strlcat_chk(char* _Nonnull, const char* _Nonnull, size_t, size_t);
#if defined(__BIONIC_FORTIFY)
-extern void* _Nullable __memrchr_real(const void* _Nonnull, int, size_t) __RENAME(memrchr);
+void* _Nullable __memrchr_real(const void* _Nonnull, int, size_t) __RENAME(memrchr);
#if __BIONIC_FORTIFY_RUNTIME_CHECKS_ENABLED
/* No diag -- clang diagnoses misuses of this on its own. */
diff --git a/libc/include/bits/getentropy.h b/libc/include/bits/getentropy.h
index a5a14f7..b9be4d1 100644
--- a/libc/include/bits/getentropy.h
+++ b/libc/include/bits/getentropy.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [getentropy(3)](http://man7.org/linux/man-pages/man3/getentropy.3.html) fills the given buffer
+ * [getentropy(3)](https://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.
@@ -48,6 +48,6 @@
*
* See also arc4random_buf() which is available in all API levels.
*/
-int getentropy(void* _Nonnull __buffer, size_t __buffer_size) __wur __INTRODUCED_IN(28);
+__wur int getentropy(void* _Nonnull __buffer, size_t __buffer_size) __INTRODUCED_IN(28);
__END_DECLS
diff --git a/libc/include/bits/getopt.h b/libc/include/bits/getopt.h
index 60a89ed..8fc0463 100644
--- a/libc/include/bits/getopt.h
+++ b/libc/include/bits/getopt.h
@@ -33,7 +33,7 @@
__BEGIN_DECLS
/**
- * [getopt(3)](http://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
+ * [getopt(3)](https://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
*
* Returns the next option character on success, returns -1 if all options have been parsed, and
* returns `'?'` on error.
diff --git a/libc/include/bits/glibc-syscalls.h b/libc/include/bits/glibc-syscalls.h
index eceb334..7b171e8 100644
--- a/libc/include/bits/glibc-syscalls.h
+++ b/libc/include/bits/glibc-syscalls.h
@@ -693,6 +693,9 @@
#if defined(__NR_mremap)
#define SYS_mremap __NR_mremap
#endif
+#if defined(__NR_mseal)
+ #define SYS_mseal __NR_mseal
+#endif
#if defined(__NR_msgctl)
#define SYS_msgctl __NR_msgctl
#endif
diff --git a/libc/include/bits/ioctl.h b/libc/include/bits/ioctl.h
index 260eb7d..ae75880 100644
--- a/libc/include/bits/ioctl.h
+++ b/libc/include/bits/ioctl.h
@@ -38,7 +38,7 @@
__BEGIN_DECLS
/**
- * [ioctl(2)](http://man7.org/linux/man-pages/man2/ioctl.2.html) operates on device files.
+ * [ioctl(2)](https://man7.org/linux/man-pages/man2/ioctl.2.html) operates on device files.
*/
int ioctl(int __fd, int __op, ...);
diff --git a/libc/include/bits/lockf.h b/libc/include/bits/lockf.h
index d9f5987..195b34a 100644
--- a/libc/include/bits/lockf.h
+++ b/libc/include/bits/lockf.h
@@ -48,7 +48,7 @@
__BEGIN_DECLS
/**
- * [lockf(3)](http://man7.org/linux/man-pages/man3/lockf.3.html) manipulates POSIX file locks.
+ * [lockf(3)](https://man7.org/linux/man-pages/man3/lockf.3.html) manipulates POSIX file locks.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*
diff --git a/libc/include/bits/posix_limits.h b/libc/include/bits/posix_limits.h
index 452f5f6..d98be27 100644
--- a/libc/include/bits/posix_limits.h
+++ b/libc/include/bits/posix_limits.h
@@ -40,7 +40,7 @@
(((__ANDROID_API__) >= (level)) ? _POSIX_VERSION : __BIONIC_POSIX_FEATURE_MISSING)
/* Availability macros. */
-/* See http://man7.org/linux/man-pages/man7/posixoptions.7.html for documentation. */
+/* See https://man7.org/linux/man-pages/man7/posixoptions.7.html for documentation. */
/* Keep this list sorted by name. */
#define _POSIX_ADVISORY_INFO __BIONIC_POSIX_FEATURE_SINCE(23) /* posix_memadvise arrived late. */
#define _POSIX_ASYNCHRONOUS_IO __BIONIC_POSIX_FEATURE_MISSING
diff --git a/libc/include/bits/pthread_types.h b/libc/include/bits/pthread_types.h
index f359696..e30c4c1 100644
--- a/libc/include/bits/pthread_types.h
+++ b/libc/include/bits/pthread_types.h
@@ -43,7 +43,6 @@
#endif
} pthread_attr_t;
-#if __ANDROID_API__ >= 24
typedef struct {
#if defined(__LP64__)
int64_t __private[4];
@@ -51,11 +50,8 @@
int32_t __private[8];
#endif
} pthread_barrier_t;
-#endif
-#if __ANDROID_API__ >= 24
typedef int pthread_barrierattr_t;
-#endif
typedef struct {
#if defined(__LP64__)
@@ -91,7 +87,6 @@
typedef long pthread_rwlockattr_t;
-#if __ANDROID_API__ >= 24
typedef struct {
#if defined(__LP64__)
int64_t __private;
@@ -99,6 +94,5 @@
int32_t __private[2];
#endif
} pthread_spinlock_t;
-#endif
typedef long pthread_t;
diff --git a/libc/include/bits/seek_constants.h b/libc/include/bits/seek_constants.h
index 6f3f22d..bfc02a8 100644
--- a/libc/include/bits/seek_constants.h
+++ b/libc/include/bits/seek_constants.h
@@ -46,7 +46,7 @@
* Seek to the first data (non-hole) location in the file
* greater than or equal to the given offset.
*
- * See [lseek(2)](http://man7.org/linux/man-pages/man2/lseek.2.html).
+ * See [lseek(2)](https://man7.org/linux/man-pages/man2/lseek.2.html).
*/
#define SEEK_DATA 3
@@ -54,7 +54,7 @@
* Seek to the first hole (non-data) location in the file
* greater than or equal to the given offset.
*
- * See [lseek(2)](http://man7.org/linux/man-pages/man2/lseek.2.html).
+ * See [lseek(2)](https://man7.org/linux/man-pages/man2/lseek.2.html).
*/
#define SEEK_HOLE 4
diff --git a/libc/include/bits/stdatomic.h b/libc/include/bits/stdatomic.h
index bd94b2d..c74eafd 100644
--- a/libc/include/bits/stdatomic.h
+++ b/libc/include/bits/stdatomic.h
@@ -138,11 +138,11 @@
* 7.17.4 Fences.
*/
-static inline void atomic_thread_fence(memory_order __order __attribute__((unused))) {
+static __inline void atomic_thread_fence(memory_order __order __attribute__((__unused__))) {
__c11_atomic_thread_fence(__order);
}
-static inline void atomic_signal_fence(memory_order __order __attribute__((unused))) {
+static __inline void atomic_signal_fence(memory_order __order __attribute__((__unused__))) {
__c11_atomic_signal_fence(__order);
}
@@ -269,18 +269,18 @@
#define ATOMIC_FLAG_INIT { ATOMIC_VAR_INIT(false) }
-static inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) {
+static __inline bool atomic_flag_test_and_set_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) {
return (atomic_exchange_explicit(&__object->__flag, 1, __order));
}
-static inline void atomic_flag_clear_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) {
+static __inline void atomic_flag_clear_explicit(volatile atomic_flag * _Nonnull __object, memory_order __order) {
atomic_store_explicit(&__object->__flag, 0, __order);
}
-static inline bool atomic_flag_test_and_set(volatile atomic_flag * _Nonnull __object) {
+static __inline bool atomic_flag_test_and_set(volatile atomic_flag * _Nonnull __object) {
return (atomic_flag_test_and_set_explicit(__object, memory_order_seq_cst));
}
-static inline void atomic_flag_clear(volatile atomic_flag * _Nonnull __object) {
+static __inline void atomic_flag_clear(volatile atomic_flag * _Nonnull __object) {
atomic_flag_clear_explicit(__object, memory_order_seq_cst);
}
diff --git a/libc/include/bits/strcasecmp.h b/libc/include/bits/strcasecmp.h
index 23acbe5..be910ad 100644
--- a/libc/include/bits/strcasecmp.h
+++ b/libc/include/bits/strcasecmp.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [strcasecmp(3)](http://man7.org/linux/man-pages/man3/strcasecmp.3.html) compares two strings
+ * [strcasecmp(3)](https://man7.org/linux/man-pages/man3/strcasecmp.3.html) compares two strings
* ignoring case.
*
* Returns an integer less than, equal to, or greater than zero if the first string is less than,
@@ -54,7 +54,7 @@
int strcasecmp_l(const char* _Nonnull __s1, const char* _Nonnull __s2, locale_t _Nonnull __l) __attribute_pure__ __INTRODUCED_IN(23);
/**
- * [strncasecmp(3)](http://man7.org/linux/man-pages/man3/strncasecmp.3.html) compares the first
+ * [strncasecmp(3)](https://man7.org/linux/man-pages/man3/strncasecmp.3.html) compares the first
* `n` bytes of two strings ignoring case.
*
* Returns an integer less than, equal to, or greater than zero if the first `n` bytes of the
diff --git a/libc/include/bits/struct_file.h b/libc/include/bits/struct_file.h
index abbd320..8cb8d28 100644
--- a/libc/include/bits/struct_file.h
+++ b/libc/include/bits/struct_file.h
@@ -39,6 +39,6 @@
#else
char __private[84];
#endif
-} __attribute__((aligned(sizeof(void*))));
+} __attribute__((__aligned__(sizeof(void*))));
__END_DECLS
diff --git a/libc/include/bits/swab.h b/libc/include/bits/swab.h
index ebb7c74..9591c2e 100644
--- a/libc/include/bits/swab.h
+++ b/libc/include/bits/swab.h
@@ -33,7 +33,7 @@
#include <sys/types.h>
#if !defined(__BIONIC_SWAB_INLINE)
-#define __BIONIC_SWAB_INLINE static inline
+#define __BIONIC_SWAB_INLINE static __inline
#endif
__BEGIN_DECLS
diff --git a/libc/include/bits/termios_inlines.h b/libc/include/bits/termios_inlines.h
index 702f433..a884b59 100644
--- a/libc/include/bits/termios_inlines.h
+++ b/libc/include/bits/termios_inlines.h
@@ -37,7 +37,7 @@
#include <linux/termios.h>
#if !defined(__BIONIC_TERMIOS_INLINE)
-#define __BIONIC_TERMIOS_INLINE static inline
+#define __BIONIC_TERMIOS_INLINE static __inline
#endif
__BEGIN_DECLS
@@ -45,7 +45,7 @@
// Supporting separate input and output speeds would require an ABI
// change for `struct termios`.
-static inline speed_t cfgetspeed(const struct termios* _Nonnull s) {
+static __inline speed_t cfgetspeed(const struct termios* _Nonnull s) {
return __BIONIC_CAST(static_cast, speed_t, s->c_cflag & CBAUD);
}
diff --git a/libc/include/bits/termios_winsize_inlines.h b/libc/include/bits/termios_winsize_inlines.h
index 0d188e7..ae246e4 100644
--- a/libc/include/bits/termios_winsize_inlines.h
+++ b/libc/include/bits/termios_winsize_inlines.h
@@ -36,7 +36,7 @@
#include <linux/termios.h>
#if !defined(__BIONIC_TERMIOS_WINSIZE_INLINE)
-#define __BIONIC_TERMIOS_WINSIZE_INLINE static inline
+#define __BIONIC_TERMIOS_WINSIZE_INLINE static __inline
#endif
__BEGIN_DECLS
diff --git a/libc/include/bits/threads_inlines.h b/libc/include/bits/threads_inlines.h
index 074e1ca..05b785a 100644
--- a/libc/include/bits/threads_inlines.h
+++ b/libc/include/bits/threads_inlines.h
@@ -38,7 +38,7 @@
__BEGIN_DECLS
-static inline int __bionic_thrd_error(int __pthread_code) {
+static __inline int __bionic_thrd_error(int __pthread_code) {
switch (__pthread_code) {
case 0: return 0;
case ENOMEM: return thrd_nomem;
@@ -116,15 +116,12 @@
return __bionic_thrd_error(pthread_mutex_unlock(__mtx));
}
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wnullability-completeness"
struct __bionic_thrd_data {
- thrd_start_t __func;
- void* __arg;
+ thrd_start_t _Nonnull __func;
+ void* _Nullable __arg;
};
-#pragma clang diagnostic pop
-static inline void* _Nonnull __bionic_thrd_trampoline(void* _Nonnull __arg) {
+static __inline void* _Nonnull __bionic_thrd_trampoline(void* _Nonnull __arg) {
struct __bionic_thrd_data __data =
*__BIONIC_CAST(static_cast, struct __bionic_thrd_data*, __arg);
free(__arg);
diff --git a/libc/include/bits/wctype.h b/libc/include/bits/wctype.h
index 11d5fde..13a4254 100644
--- a/libc/include/bits/wctype.h
+++ b/libc/include/bits/wctype.h
@@ -58,8 +58,8 @@
int iswctype(wint_t __wc, wctype_t __type);
typedef const void* wctrans_t;
-wint_t towctrans(wint_t __wc, wctrans_t _Nonnull __transform) __INTRODUCED_IN_NO_GUARD_FOR_NDK(26);
-wctrans_t _Nullable wctrans(const char* _Nonnull __name) __INTRODUCED_IN_NO_GUARD_FOR_NDK(26);
+wint_t towctrans(wint_t __wc, wctrans_t _Nonnull __transform) __INTRODUCED_IN(26);
+wctrans_t _Nullable wctrans(const char* _Nonnull __name) __INTRODUCED_IN(26);
__END_DECLS
diff --git a/libc/include/byteswap.h b/libc/include/byteswap.h
index 0773426..a679ea0 100644
--- a/libc/include/byteswap.h
+++ b/libc/include/byteswap.h
@@ -37,19 +37,19 @@
#include <sys/endian.h>
/**
- * [bswap_16(3)](http://man7.org/linux/man-pages/man3/bswap_16.3.html) swaps the bytes in a
+ * [bswap_16(3)](https://man7.org/linux/man-pages/man3/bswap_16.3.html) swaps the bytes in a
* 16-bit value.
*/
#define bswap_16(x) __swap16(x)
/**
- * [bswap_32(3)](http://man7.org/linux/man-pages/man3/bswap_32.3.html) swaps the bytes in a
+ * [bswap_32(3)](https://man7.org/linux/man-pages/man3/bswap_32.3.html) swaps the bytes in a
* 32-bit value.
*/
#define bswap_32(x) __swap32(x)
/**
- * [bswap_64(3)](http://man7.org/linux/man-pages/man3/bswap_64.3.html) swaps the bytes in a
+ * [bswap_64(3)](https://man7.org/linux/man-pages/man3/bswap_64.3.html) swaps the bytes in a
* 64-bit value.
*/
#define bswap_64(x) __swap64(x)
diff --git a/libc/include/ctype.h b/libc/include/ctype.h
index 5cad412..cb926a4 100644
--- a/libc/include/ctype.h
+++ b/libc/include/ctype.h
@@ -42,7 +42,7 @@
* also provide actual symbols for any caller that needs them.
*/
#if !defined(__BIONIC_CTYPE_INLINE)
-#define __BIONIC_CTYPE_INLINE static inline
+#define __BIONIC_CTYPE_INLINE static __inline
#endif
/** Internal implementation detail. Do not use. */
@@ -73,9 +73,35 @@
/** Internal implementation detail. Do not use. */
extern const char* _ctype_;
+/**
+ * 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 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;
+}
+
+/** Internal implementation detail. Do not use. */
+__attribute__((__no_sanitize__("unsigned-integer-overflow")))
+static inline int __bionic_ctype_in_range(unsigned __lo, int __ch, unsigned __hi) {
+ return (__BIONIC_CAST(static_cast, unsigned, __ch) - __lo) < (__hi - __lo + 1);
+}
+
/** 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');
+ return __bionic_ctype_in_range('a', _tolower(__ch), 'z');
}
/** Returns true if `ch` is a space or tab. */
@@ -90,37 +116,37 @@
/** Returns true if `ch` is in `[0-9]`. */
__BIONIC_CTYPE_INLINE int isdigit(int __ch) {
- return (__ch >= '0' && __ch <= '9');
+ return __bionic_ctype_in_range('0', __ch, '9');
}
/** Returns true if `ch` is `[A-Za-z0-9]` or punctuation. */
__BIONIC_CTYPE_INLINE int isgraph(int __ch) {
- return (__ch >= '!' && __ch <= '~');
+ return __bionic_ctype_in_range('!', __ch, '~');
}
/** Returns true if `ch` is in `[a-z]`. */
__BIONIC_CTYPE_INLINE int islower(int __ch) {
- return (__ch >= 'a' && __ch <= 'z');
+ return __bionic_ctype_in_range('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 <= '~');
+ return __bionic_ctype_in_range(' ', __ch, '~');
}
/** Returns true if `ch` is in `[ \f\n\r\t\v]`. */
__BIONIC_CTYPE_INLINE int isspace(int __ch) {
- return __ch == ' ' || (__ch >= '\t' && __ch <= '\r');
+ return __ch == ' ' || __bionic_ctype_in_range('\t', __ch, '\r');
}
/** Returns true if `ch` is in `[A-Z]`. */
__BIONIC_CTYPE_INLINE int isupper(int __ch) {
- return (__ch >= 'A' && __ch <= 'Z');
+ return __bionic_ctype_in_range('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');
+ return isdigit(__ch) || __bionic_ctype_in_range('a', _tolower(__ch), 'f') ;
}
/** Returns true if `ch` is in `[A-Za-z0-9]`. */
@@ -133,36 +159,14 @@
return isgraph(__ch) && !isalnum(__ch);
}
-/**
- * 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;
+ return (__bionic_ctype_in_range('A', __ch, 'Z')) ? _tolower(__ch) : __ch;
}
/** 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;
+ return (__bionic_ctype_in_range('a', __ch, 'z')) ? _toupper(__ch) : __ch;
}
/** Returns true if `ch` is less than 0x80. */
diff --git a/libc/include/dirent.h b/libc/include/dirent.h
index 4f5d0fb..5333d78 100644
--- a/libc/include/dirent.h
+++ b/libc/include/dirent.h
@@ -90,7 +90,7 @@
typedef struct DIR DIR;
/**
- * [opendir(3)](http://man7.org/linux/man-pages/man3/opendir.3.html)
+ * [opendir(3)](https://man7.org/linux/man-pages/man3/opendir.3.html)
* opens a directory stream for the directory at `__path`.
*
* Returns null and sets `errno` on failure.
@@ -98,7 +98,7 @@
DIR* _Nullable opendir(const char* _Nonnull __path);
/**
- * [fopendir(3)](http://man7.org/linux/man-pages/man3/opendir.3.html)
+ * [fopendir(3)](https://man7.org/linux/man-pages/man3/opendir.3.html)
* opens a directory stream for the directory at `__dir_fd`.
*
* Returns null and sets `errno` on failure.
@@ -106,7 +106,7 @@
DIR* _Nullable fdopendir(int __dir_fd);
/**
- * [readdir(3)](http://man7.org/linux/man-pages/man3/readdir.3.html)
+ * [readdir(3)](https://man7.org/linux/man-pages/man3/readdir.3.html)
* returns the next directory entry in the given directory.
*
* Returns a pointer to a directory entry on success,
@@ -116,7 +116,7 @@
struct dirent* _Nullable readdir(DIR* _Nonnull __dir);
/**
- * [readdir64(3)](http://man7.org/linux/man-pages/man3/readdir.3.html)
+ * [readdir64(3)](https://man7.org/linux/man-pages/man3/readdir.3.html)
* returns the next directory entry in the given directory.
*
* Returns a pointer to a directory entry on success,
@@ -129,7 +129,7 @@
int readdir64_r(DIR* _Nonnull __dir, struct dirent64* _Nonnull __entry, struct dirent64* _Nullable * _Nonnull __buffer) __attribute__((__deprecated__("readdir64_r is deprecated; use readdir64 instead")));
/**
- * [closedir(3)](http://man7.org/linux/man-pages/man3/closedir.3.html)
+ * [closedir(3)](https://man7.org/linux/man-pages/man3/closedir.3.html)
* closes a directory stream.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -137,13 +137,13 @@
int closedir(DIR* _Nonnull __dir);
/**
- * [rewinddir(3)](http://man7.org/linux/man-pages/man3/rewinddir.3.html)
+ * [rewinddir(3)](https://man7.org/linux/man-pages/man3/rewinddir.3.html)
* rewinds a directory stream to the first entry.
*/
void rewinddir(DIR* _Nonnull __dir);
/**
- * [seekdir(3)](http://man7.org/linux/man-pages/man3/seekdir.3.html)
+ * [seekdir(3)](https://man7.org/linux/man-pages/man3/seekdir.3.html)
* seeks a directory stream to the given entry, which must be a value returned
* by telldir().
*
@@ -152,7 +152,7 @@
void seekdir(DIR* _Nonnull __dir, long __location) __INTRODUCED_IN(23);
/**
- * [telldir(3)](http://man7.org/linux/man-pages/man3/telldir.3.html)
+ * [telldir(3)](https://man7.org/linux/man-pages/man3/telldir.3.html)
* returns a value representing the current position in the directory
* for use with seekdir().
*
@@ -163,7 +163,7 @@
long telldir(DIR* _Nonnull __dir) __INTRODUCED_IN(23);
/**
- * [dirfd(3)](http://man7.org/linux/man-pages/man3/dirfd.3.html)
+ * [dirfd(3)](https://man7.org/linux/man-pages/man3/dirfd.3.html)
* returns the file descriptor backing the given directory stream.
*
* Returns a file descriptor on success and returns -1 and sets `errno` on failure.
@@ -171,19 +171,19 @@
int dirfd(DIR* _Nonnull __dir);
/**
- * [alphasort](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a
+ * [alphasort](https://man7.org/linux/man-pages/man3/alphasort.3.html) is a
* comparator for use with scandir() that uses strcoll().
*/
int alphasort(const struct dirent* _Nonnull * _Nonnull __lhs, const struct dirent* _Nonnull * _Nonnull __rhs);
/**
- * [alphasort64](http://man7.org/linux/man-pages/man3/alphasort.3.html) is a
+ * [alphasort64](https://man7.org/linux/man-pages/man3/alphasort.3.html) is a
* comparator for use with scandir64() that uses strcmp().
*/
int alphasort64(const struct dirent64* _Nonnull * _Nonnull __lhs, const struct dirent64* _Nonnull * _Nonnull __rhs);
/**
- * [scandir(3)](http://man7.org/linux/man-pages/man3/scandir.3.html)
+ * [scandir(3)](https://man7.org/linux/man-pages/man3/scandir.3.html)
* scans all the directory `__path`, filtering entries with `__filter` and
* sorting them with qsort() using the given `__comparator`, and storing them
* into `__name_list`. Passing NULL as the filter accepts all entries.
@@ -195,7 +195,7 @@
int scandir(const char* _Nonnull __path, struct dirent* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent* _Nonnull), int (* _Nullable __comparator)(const struct dirent* _Nonnull * _Nonnull, const struct dirent* _Nonnull * _Nonnull));
/**
- * [scandir64(3)](http://man7.org/linux/man-pages/man3/scandir.3.html)
+ * [scandir64(3)](https://man7.org/linux/man-pages/man3/scandir.3.html)
* scans all the directory `__path`, filtering entries with `__filter` and
* sorting them with qsort() using the given `__comparator`, and storing them
* into `__name_list`. Passing NULL as the filter accepts all entries.
@@ -209,7 +209,7 @@
#if defined(__USE_GNU)
/**
- * [scandirat64(3)](http://man7.org/linux/man-pages/man3/scandirat.3.html)
+ * [scandirat64(3)](https://man7.org/linux/man-pages/man3/scandirat.3.html)
* scans all the directory referenced by the pair of `__dir_fd` and `__path`,
* filtering entries with `__filter` and sorting them with qsort() using the
* given `__comparator`, and storing them into `__name_list`. Passing NULL as
@@ -224,7 +224,7 @@
int scandirat64(int __dir_fd, const char* _Nonnull __path, struct dirent64* _Nonnull * _Nonnull * _Nonnull __name_list, int (* _Nullable __filter)(const struct dirent64* _Nonnull), int (* _Nullable __comparator)(const struct dirent64* _Nonnull * _Nonnull, const struct dirent64* _Nonnull * _Nonnull)) __INTRODUCED_IN(24);
/**
- * [scandirat(3)](http://man7.org/linux/man-pages/man3/scandirat.3.html)
+ * [scandirat(3)](https://man7.org/linux/man-pages/man3/scandirat.3.html)
* scans all the directory referenced by the pair of `__dir_fd` and `__path`,
* filtering entries with `__filter` and sorting them with qsort() using the
* given `__comparator`, and storing them into `__name_list`. Passing NULL as
diff --git a/libc/include/dlfcn.h b/libc/include/dlfcn.h
index a90c4f8..071d50a 100644
--- a/libc/include/dlfcn.h
+++ b/libc/include/dlfcn.h
@@ -48,7 +48,7 @@
} Dl_info;
/**
- * [dlopen(3)](http://man7.org/linux/man-pages/man3/dlopen.3.html)
+ * [dlopen(3)](https://man7.org/linux/man-pages/man3/dlopen.3.html)
* loads the given shared library.
*
* Returns a pointer to an opaque handle for use with other <dlfcn.h> functions
@@ -58,7 +58,7 @@
void* _Nullable dlopen(const char* _Nullable __filename, int __flag);
/**
- * [dlclose(3)](http://man7.org/linux/man-pages/man3/dlclose.3.html)
+ * [dlclose(3)](https://man7.org/linux/man-pages/man3/dlclose.3.html)
* decrements the reference count for the given shared library (and
* any libraries brought in by that library's DT_NEEDED entries).
*
@@ -84,7 +84,7 @@
int dlclose(void* _Nonnull __handle);
/**
- * [dlerror(3)](http://man7.org/linux/man-pages/man3/dlerror.3.html)
+ * [dlerror(3)](https://man7.org/linux/man-pages/man3/dlerror.3.html)
* returns a human-readable error message describing the most recent
* failure from one of the <dlfcn.h> functions on the calling thread.
*
@@ -97,7 +97,7 @@
char* _Nullable dlerror(void);
/**
- * [dlsym(3)](http://man7.org/linux/man-pages/man3/dlsym.3.html)
+ * [dlsym(3)](https://man7.org/linux/man-pages/man3/dlsym.3.html)
* returns a pointer to the symbol with the given name in the shared
* library represented by the given handle. The handle may have been
* returned from dlopen(), or can be RTLD_DEFAULT or RTLD_NEXT.
@@ -108,7 +108,7 @@
void* _Nullable dlsym(void* __BIONIC_COMPLICATED_NULLNESS __handle, const char* _Nullable __symbol);
/**
- * [dlvsym(3)](http://man7.org/linux/man-pages/man3/dlvsym.3.html)
+ * [dlvsym(3)](https://man7.org/linux/man-pages/man3/dlvsym.3.html)
* returns a pointer to the symbol with the given name and version in the shared
* library represented by the given handle. The handle may have been
* returned from dlopen(), or can be RTLD_DEFAULT or RTLD_NEXT.
@@ -119,7 +119,7 @@
void* _Nullable dlvsym(void* __BIONIC_COMPLICATED_NULLNESS __handle, const char* _Nullable __symbol, const char* _Nullable __version) __INTRODUCED_IN(24);
/**
- * [dladdr(3)](http://man7.org/linux/man-pages/man3/dladdr.3.html)
+ * [dladdr(3)](https://man7.org/linux/man-pages/man3/dladdr.3.html)
* returns information about the symbol at the given address.
*
* Returns non-zero on success, and returns 0 on failure. Note that unlike
@@ -146,7 +146,11 @@
*/
#define RTLD_LOCAL 0
-/** Not supported on Android; Android always uses RTLD_NOW. */
+/**
+ * Not supported on Android. Android always uses RTLD_NOW for security reasons.
+ * Resolving all undefined symbols before dlopen() returns means that RELRO
+ * protections can be applied to the PLT before dlopen() returns.
+ */
#define RTLD_LAZY 0x00001
/** A dlopen() flag to resolve all undefined symbols before dlopen() returns. */
diff --git a/libc/include/elf.h b/libc/include/elf.h
index 1275f2e..24454d7 100644
--- a/libc/include/elf.h
+++ b/libc/include/elf.h
@@ -223,8 +223,6 @@
#undef SHT_NUM
#define SHT_NUM 20
-#define SHT_RISCV_ATTRIBUTES 0x70000003
-
/*
* Experimental support for SHT_RELR sections. For details, see proposal
* at https://groups.google.com/forum/#!topic/generic-abi/bX460iggiKg.
@@ -254,6 +252,8 @@
#define DT_ANDROID_RELA 0x60000011 // DT_LOOS + 4
#define DT_ANDROID_RELASZ 0x60000012 // DT_LOOS + 5
+/* arm64 psabi. */
+
/* TODO: upstreamed to FreeBSD as https://github.com/freebsd/freebsd-src/pull/1141/. */
#define DT_AARCH64_MEMTAG_MODE 0x70000009
#define DT_AARCH64_MEMTAG_HEAP 0x7000000b
@@ -270,19 +270,25 @@
#define R_ARM_TLS_DESC 13
#define R_ARM_IRELATIVE 160
-/* FreeBSD is missing these, found in
+/* riscv64 psabi. */
+
+/*
* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#relocations
- * so I've sent https://github.com/freebsd/freebsd-src/pull/1141 upstream.
+ * Missing from FreeBSD and the Linux uapi headers.
+ * TODO: upstreamed to FreeBSD as https://github.com/freebsd/freebsd-src/pull/1141.
*/
#define R_RISCV_TLSDESC 12
-#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
+/* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#program-header-table */
+#define PT_RISCV_ATTRIBUTES 0x70000003
+
+/* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#section-types */
+#define SHT_RISCV_ATTRIBUTES 0x70000003
+
/* FreeBSD spells this slightly differently to Linux. Linux is correct according to
* https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#file-header
* so I've sent https://github.com/freebsd/freebsd-src/pull/1148 upstream.
diff --git a/libc/include/err.h b/libc/include/err.h
index af44514..d8122d7 100644
--- a/libc/include/err.h
+++ b/libc/include/err.h
@@ -43,7 +43,7 @@
__BEGIN_DECLS
/**
- * [err(3)](http://man7.org/linux/man-pages/man3/err.3.html) outputs the program name,
+ * [err(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name,
* the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
*
* Calls exit() with `__status`.
@@ -53,7 +53,7 @@
__noreturn void err(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3);
/**
- * [verr(3)](http://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name,
+ * [verr(3)](https://man7.org/linux/man-pages/man3/verr.3.html) outputs the program name,
* the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
*
* Calls exit() with `__status`.
@@ -63,7 +63,7 @@
__noreturn void verr(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0);
/**
- * [errx(3)](http://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and
+ * [errx(3)](https://man7.org/linux/man-pages/man3/errx.3.html) outputs the program name, and
* the printf()-like formatted message.
*
* Calls exit() with `__status`.
@@ -73,7 +73,7 @@
__noreturn void errx(int __status, const char* _Nullable __fmt, ...) __printflike(2, 3);
/**
- * [verrx(3)](http://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and
+ * [verrx(3)](https://man7.org/linux/man-pages/man3/err.3.html) outputs the program name, and
* the vprintf()-like formatted message.
*
* Calls exit() with `__status`.
@@ -83,7 +83,7 @@
__noreturn void verrx(int __status, const char* _Nullable __fmt, va_list __args) __printflike(2, 0);
/**
- * [warn(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name,
+ * [warn(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name,
* the printf()-like formatted message, and the result of strerror() if `errno` is non-zero.
*
* New code should consider error() in `<error.h>`.
@@ -91,7 +91,7 @@
void warn(const char* _Nullable __fmt, ...) __printflike(1, 2);
/**
- * [vwarn(3)](http://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name,
+ * [vwarn(3)](https://man7.org/linux/man-pages/man3/vwarn.3.html) outputs the program name,
* the vprintf()-like formatted message, and the result of strerror() if `errno` is non-zero.
*
* New code should consider error() in `<error.h>`.
@@ -99,7 +99,7 @@
void vwarn(const char* _Nullable __fmt, va_list __args) __printflike(1, 0);
/**
- * [warnx(3)](http://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and
+ * [warnx(3)](https://man7.org/linux/man-pages/man3/warnx.3.html) outputs the program name, and
* the printf()-like formatted message.
*
* New code should consider error() in `<error.h>`.
@@ -107,7 +107,7 @@
void warnx(const char* _Nullable __fmt, ...) __printflike(1, 2);
/**
- * [vwarnx(3)](http://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and
+ * [vwarnx(3)](https://man7.org/linux/man-pages/man3/warn.3.html) outputs the program name, and
* the vprintf()-like formatted message.
*
* New code should consider error() in `<error.h>`.
diff --git a/libc/include/errno.h b/libc/include/errno.h
index 12ebdf7..0b79592 100644
--- a/libc/include/errno.h
+++ b/libc/include/errno.h
@@ -52,7 +52,7 @@
int* _Nonnull __errno(void) __attribute_const__;
/**
- * [errno(3)](http://man7.org/linux/man-pages/man3/errno.3.html) is the last error on the calling
+ * [errno(3)](https://man7.org/linux/man-pages/man3/errno.3.html) is the last error on the calling
* thread.
*/
#define errno (*__errno())
diff --git a/libc/include/error.h b/libc/include/error.h
index 187ee17..cb867cd 100644
--- a/libc/include/error.h
+++ b/libc/include/error.h
@@ -38,7 +38,7 @@
__BEGIN_DECLS
/**
- * [error_print_progname(3)](http://man7.org/linux/man-pages/man3/error_print_progname.3.html) is
+ * [error_print_progname(3)](https://man7.org/linux/man-pages/man3/error_print_progname.3.html) is
* a function pointer that, if non-null, is called by error() instead of prefixing errors with the
* program name.
*
@@ -47,7 +47,7 @@
extern void (* _Nullable error_print_progname)(void) __INTRODUCED_IN(23);
/**
- * [error_message_count(3)](http://man7.org/linux/man-pages/man3/error_message_count.3.html) is
+ * [error_message_count(3)](https://man7.org/linux/man-pages/man3/error_message_count.3.html) is
* a global count of the number of calls to error() and error_at_line().
*
* Available since API level 23.
@@ -55,7 +55,7 @@
extern unsigned int error_message_count __INTRODUCED_IN(23);
/**
- * [error_one_per_line(3)](http://man7.org/linux/man-pages/man3/error_one_per_line.3.html) is
+ * [error_one_per_line(3)](https://man7.org/linux/man-pages/man3/error_one_per_line.3.html) is
* a global flag that if non-zero disables printing multiple errors with the same filename and
* line number.
*
@@ -64,7 +64,7 @@
extern int error_one_per_line __INTRODUCED_IN(23);
/**
- * [error(3)](http://man7.org/linux/man-pages/man3/error.3.html) formats the given printf()-like
+ * [error(3)](https://man7.org/linux/man-pages/man3/error.3.html) formats the given printf()-like
* error message, preceded by the program name. Calls exit if `__status` is non-zero, and appends
* the result of strerror() if `__errno` is non-zero.
*
@@ -73,7 +73,7 @@
void error(int __status, int __errno, const char* _Nonnull __fmt, ...) __printflike(3, 4) __INTRODUCED_IN(23);
/**
- * [error_at_line(3)](http://man7.org/linux/man-pages/man3/error_at_line.3.html) formats the given
+ * [error_at_line(3)](https://man7.org/linux/man-pages/man3/error_at_line.3.html) formats the given
* printf()-like error message, preceded by the program name and the given filename and line number.
* Calls exit if `__status` is non-zero, and appends the result of strerror() if `__errno` is
* non-zero.
diff --git a/libc/include/fcntl.h b/libc/include/fcntl.h
index 16ce6fa..1e9a285 100644
--- a/libc/include/fcntl.h
+++ b/libc/include/fcntl.h
@@ -93,17 +93,15 @@
/** Flag for splice(). */
#define SPLICE_F_GIFT 8
-#if __ANDROID_API__ >= 26
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_BEFORE 1
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WRITE 2
/** Flag for sync_file_range(). */
#define SYNC_FILE_RANGE_WAIT_AFTER 4
-#endif
/**
- * [creat(2)](http://man7.org/linux/man-pages/man2/creat.2.html)
+ * [creat(2)](https://man7.org/linux/man-pages/man2/creat.2.html)
* creates a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
@@ -114,7 +112,7 @@
int creat64(const char* _Nonnull __path, mode_t __mode);
/**
- * [openat(2)](http://man7.org/linux/man-pages/man2/openat.2.html)
+ * [openat(2)](https://man7.org/linux/man-pages/man2/openat.2.html)
* opens (and possibly creates) a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
@@ -125,7 +123,7 @@
int openat64(int __dir_fd, const char* _Nonnull __path, int __flags, ...);
/**
- * [open(2)](http://man7.org/linux/man-pages/man2/open.2.html)
+ * [open(2)](https://man7.org/linux/man-pages/man2/open.2.html)
* opens (and possibly creates) a file.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
@@ -136,7 +134,7 @@
int open64(const char* _Nonnull __path, int __flags, ...);
/**
- * [splice(2)](http://man7.org/linux/man-pages/man2/splice.2.html)
+ * [splice(2)](https://man7.org/linux/man-pages/man2/splice.2.html)
* splices data to/from a pipe.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
@@ -148,7 +146,7 @@
ssize_t splice(int __in_fd, off64_t* __BIONIC_COMPLICATED_NULLNESS __in_offset, int __out_fd, off64_t* __BIONIC_COMPLICATED_NULLNESS __out_offset, size_t __length, unsigned int __flags);
/**
- * [tee(2)](http://man7.org/linux/man-pages/man2/tee.2.html)
+ * [tee(2)](https://man7.org/linux/man-pages/man2/tee.2.html)
* duplicates data from one pipe to another.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
@@ -160,7 +158,7 @@
ssize_t tee(int __in_fd, int __out_fd, size_t __length, unsigned int __flags);
/**
- * [vmsplice(2)](http://man7.org/linux/man-pages/man2/vmsplice.2.html)
+ * [vmsplice(2)](https://man7.org/linux/man-pages/man2/vmsplice.2.html)
* splices data to/from a pipe.
*
* Valid flags are `SPLICE_F_MOVE`, `SPLICE_F_NONBLOCK`, `SPLICE_F_MORE`, and
@@ -172,7 +170,7 @@
ssize_t vmsplice(int __fd, const struct iovec* _Nonnull __iov, size_t __count, unsigned int __flags);
/**
- * [fallocate(2)](http://man7.org/linux/man-pages/man2/fallocate.2.html)
+ * [fallocate(2)](https://man7.org/linux/man-pages/man2/fallocate.2.html)
* is a Linux-specific extension of posix_fallocate().
*
* Valid flags are `FALLOC_FL_KEEP_SIZE`, `FALLOC_FL_PUNCH_HOLE`,
@@ -187,7 +185,7 @@
int fallocate64(int __fd, int __mode, off64_t __offset, off64_t __length);
/**
- * [posix_fadvise(2)](http://man7.org/linux/man-pages/man2/posix_fadvise.2.html)
+ * [posix_fadvise(2)](https://man7.org/linux/man-pages/man2/posix_fadvise.2.html)
* declares an expected access pattern for file data.
*
* Valid flags are `POSIX_FADV_NORMAL`, `POSIX_FADV_RANDOM`,
@@ -201,7 +199,7 @@
int posix_fadvise64(int __fd, off64_t __offset, off64_t __length, int __advice);
/**
- * [posix_fallocate(2)](http://man7.org/linux/man-pages/man2/posix_fallocate.2.html)
+ * [posix_fallocate(2)](https://man7.org/linux/man-pages/man2/posix_fallocate.2.html)
* allocates file space.
*
* Returns 0 on success and returns an error number on failure.
@@ -213,7 +211,7 @@
#if defined(__USE_GNU)
/**
- * [readahead(2)](http://man7.org/linux/man-pages/man2/readahead.2.html)
+ * [readahead(2)](https://man7.org/linux/man-pages/man2/readahead.2.html)
* initiates readahead for the given file.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -221,7 +219,7 @@
ssize_t readahead(int __fd, off64_t __offset, size_t __length);
/**
- * [sync_file_range(2)](http://man7.org/linux/man-pages/man2/sync_file_range.2.html)
+ * [sync_file_range(2)](https://man7.org/linux/man-pages/man2/sync_file_range.2.html)
* syncs part of a file with disk.
*
* Valid flags are `SYNC_FILE_RANGE_WAIT_BEFORE`, `SYNC_FILE_RANGE_WRITE`, and
diff --git a/libc/include/fenv.h b/libc/include/fenv.h
index f7dcc8e..4c1d490 100644
--- a/libc/include/fenv.h
+++ b/libc/include/fenv.h
@@ -49,7 +49,7 @@
__BEGIN_DECLS
/**
- * [feclearexcept(3)](http://man7.org/linux/man-pages/man3/feclearexcept.3.html)
+ * [feclearexcept(3)](https://man7.org/linux/man-pages/man3/feclearexcept.3.html)
* clears the given `exceptions` in hardware.
*
* Returns 0 on success, and returns non-zero on failure.
@@ -57,7 +57,7 @@
int feclearexcept(int __exceptions);
/**
- * [fegetexceptflag(3)](http://man7.org/linux/man-pages/man3/fegetexceptflag.3.html)
+ * [fegetexceptflag(3)](https://man7.org/linux/man-pages/man3/fegetexceptflag.3.html)
* copies the state of the given `exceptions` from hardware into `*flag_ptr`.
* See fesetexceptflag().
*
@@ -66,7 +66,7 @@
int fegetexceptflag(fexcept_t* _Nonnull __flag_ptr, int __exceptions);
/**
- * [feraiseexcept(3)](http://man7.org/linux/man-pages/man3/feraiseexcept.3.html)
+ * [feraiseexcept(3)](https://man7.org/linux/man-pages/man3/feraiseexcept.3.html)
* raises the given `exceptions` in hardware.
*
* Returns 0 on success, and returns non-zero on failure.
@@ -74,7 +74,7 @@
int feraiseexcept(int __exceptions);
/**
- * [fesetexceptflag(3)](http://man7.org/linux/man-pages/man3/fesetexceptflag.3.html)
+ * [fesetexceptflag(3)](https://man7.org/linux/man-pages/man3/fesetexceptflag.3.html)
* copies the state of the given `exceptions` from `*flag_ptr` into hardware.
* See fesetexceptflag().
*
@@ -83,7 +83,7 @@
int fesetexceptflag(const fexcept_t* _Nonnull __flag_ptr, int __exceptions);
/**
- * [fetestexcept(3)](http://man7.org/linux/man-pages/man3/fetestexcept.3.html)
+ * [fetestexcept(3)](https://man7.org/linux/man-pages/man3/fetestexcept.3.html)
* tests whether the given `exceptions` are set in hardware.
*
* Returns the currently-set subset of `exceptions`.
@@ -91,7 +91,7 @@
int fetestexcept(int __exceptions);
/**
- * [fegetround(3)](http://man7.org/linux/man-pages/man3/fegetround.3.html)
+ * [fegetround(3)](https://man7.org/linux/man-pages/man3/fegetround.3.html)
* returns the current rounding mode.
*
* Returns the rounding mode on success, and returns a negative value on failure.
@@ -99,7 +99,7 @@
int fegetround(void);
/**
- * [fesetround(3)](http://man7.org/linux/man-pages/man3/fesetround.3.html)
+ * [fesetround(3)](https://man7.org/linux/man-pages/man3/fesetround.3.html)
* sets the current rounding mode.
*
* Returns 0 on success, and returns non-zero on failure.
@@ -107,7 +107,7 @@
int fesetround(int __rounding_mode);
/**
- * [fegetenv(3)](http://man7.org/linux/man-pages/man3/fegetenv.3.html)
+ * [fegetenv(3)](https://man7.org/linux/man-pages/man3/fegetenv.3.html)
* gets the current floating-point environment. See fesetenv().
*
* Returns 0 on success, and returns non-zero on failure.
@@ -115,7 +115,7 @@
int fegetenv(fenv_t* _Nonnull __env);
/**
- * [feholdexcept(3)](http://man7.org/linux/man-pages/man3/feholdexcept.3.html)
+ * [feholdexcept(3)](https://man7.org/linux/man-pages/man3/feholdexcept.3.html)
* gets the current floating-point environment, clears the status flags, and
* ignores floating point exceptions. See fesetenv()/feupdateenv().
*
@@ -124,7 +124,7 @@
int feholdexcept(fenv_t* _Nonnull __env);
/**
- * [fesetenv(3)](http://man7.org/linux/man-pages/man3/fesetenv.3.html)
+ * [fesetenv(3)](https://man7.org/linux/man-pages/man3/fesetenv.3.html)
* sets the current floating-point environment. See fegetenv().
*
* Returns 0 on success, and returns non-zero on failure.
@@ -132,7 +132,7 @@
int fesetenv(const fenv_t* _Nonnull __env);
/**
- * [feupdateenv(3)](http://man7.org/linux/man-pages/man3/feupdateenv.3.html)
+ * [feupdateenv(3)](https://man7.org/linux/man-pages/man3/feupdateenv.3.html)
* sets the current floating-point environment to `*env` but with currently-raised
* exceptions still raised. See fesetenv().
*
@@ -141,7 +141,7 @@
int feupdateenv(const fenv_t* _Nonnull __env);
/**
- * [feenableexcept(3)](http://man7.org/linux/man-pages/man3/feenableexcept.3.html)
+ * [feenableexcept(3)](https://man7.org/linux/man-pages/man3/feenableexcept.3.html)
* sets the given `exceptions` to trap, if the hardware supports it. This is not
* generally useful on Android, because only x86/x86-64 can trap.
*
@@ -150,7 +150,7 @@
int feenableexcept(int __exceptions);
/**
- * [fedisableexcept(3)](http://man7.org/linux/man-pages/man3/fedisableexcept.3.html)
+ * [fedisableexcept(3)](https://man7.org/linux/man-pages/man3/fedisableexcept.3.html)
* sets the given `exceptions` to not trap, if the hardware supports it. This is not
* generally useful on Android, because only x86/x86-64 can trap.
*
@@ -159,7 +159,7 @@
int fedisableexcept(int __exceptions);
/**
- * [fegetexcept(3)](http://man7.org/linux/man-pages/man3/fegetexcept.3.html)
+ * [fegetexcept(3)](https://man7.org/linux/man-pages/man3/fegetexcept.3.html)
* returns the exceptions that currently trap. This is not generally useful on
* Android, because only x86/x86-64 can trap.
*
diff --git a/libc/include/fnmatch.h b/libc/include/fnmatch.h
index 1788a27..e3b17fd 100644
--- a/libc/include/fnmatch.h
+++ b/libc/include/fnmatch.h
@@ -60,7 +60,7 @@
#define FNM_FILE_NAME FNM_PATHNAME
/**
- * [fnmatch(3)](http://man7.org/linux/man-pages/man3/fnmatch.3.html) matches `__string` against
+ * [fnmatch(3)](https://man7.org/linux/man-pages/man3/fnmatch.3.html) matches `__string` against
* the shell wildcard `__pattern`.
*
* Returns 0 on success, and returns `FNM_NOMATCH` on failure.
diff --git a/libc/include/fts.h b/libc/include/fts.h
index 8dfd213..aabe2db 100644
--- a/libc/include/fts.h
+++ b/libc/include/fts.h
@@ -119,7 +119,7 @@
FTSENT* _Nullable fts_children(FTS* _Nonnull __fts, int __options);
int fts_close(FTS* _Nonnull __fts);
-FTS* _Nullable fts_open(char* _Nonnull const* _Nonnull __path, int __options, int (* _Nullable __comparator)(const FTSENT* _Nonnull * _Nonnull __lhs, const FTSENT* _Nonnull * _Nonnull __rhs));
+FTS* _Nullable fts_open(char* _Nullable const* _Nonnull __path, int __options, int (* _Nullable __comparator)(const FTSENT* _Nonnull * _Nonnull __lhs, const FTSENT* _Nonnull * _Nonnull __rhs));
FTSENT* _Nullable fts_read(FTS* _Nonnull __fts);
int fts_set(FTS* _Nonnull __fts, FTSENT* _Nonnull __entry, int __options);
diff --git a/libc/include/getopt.h b/libc/include/getopt.h
index c1c0442..1a30eb7 100644
--- a/libc/include/getopt.h
+++ b/libc/include/getopt.h
@@ -70,12 +70,12 @@
__BEGIN_DECLS
/**
- * [getopt_long(3)](http://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
+ * [getopt_long(3)](https://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
*/
int getopt_long(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);
/**
- * [getopt_long_only(3)](http://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
+ * [getopt_long_only(3)](https://man7.org/linux/man-pages/man3/getopt.3.html) parses command-line options.
*/
int getopt_long_only(int __argc, char* _Nonnull const* _Nonnull __argv, const char* _Nonnull __options, const struct option* _Nonnull __long_options, int* _Nullable __long_index);
diff --git a/libc/include/iconv.h b/libc/include/iconv.h
index 27e04bb..9da46b4 100644
--- a/libc/include/iconv.h
+++ b/libc/include/iconv.h
@@ -47,7 +47,7 @@
typedef struct __iconv_t* iconv_t;
/**
- * [iconv_open(3)](http://man7.org/linux/man-pages/man3/iconv_open.3.html) allocates a new converter
+ * [iconv_open(3)](https://man7.org/linux/man-pages/man3/iconv_open.3.html) allocates a new converter
* from `__src_encoding` to `__dst_encoding`.
*
* Android supports the `utf8`, `ascii`, `usascii`, `utf16be`, `utf16le`, `utf32be`, `utf32le`,
@@ -63,7 +63,7 @@
iconv_t _Nonnull iconv_open(const char* _Nonnull __dst_encoding, const char* _Nonnull __src_encoding) __INTRODUCED_IN(28);
/**
- * [iconv(3)](http://man7.org/linux/man-pages/man3/iconv.3.html) converts characters from one
+ * [iconv(3)](https://man7.org/linux/man-pages/man3/iconv.3.html) converts characters from one
* encoding to another.
*
* Returns the number of characters converted on success and returns `((size_t) -1)` and
@@ -74,7 +74,7 @@
size_t iconv(iconv_t _Nonnull __converter, char* _Nullable * _Nullable __src_buf, size_t* __BIONIC_COMPLICATED_NULLNESS __src_bytes_left, char* _Nullable * _Nullable __dst_buf, size_t* __BIONIC_COMPLICATED_NULLNESS __dst_bytes_left) __INTRODUCED_IN(28);
/**
- * [iconv_close(3)](http://man7.org/linux/man-pages/man3/iconv_close.3.html) deallocates a converter
+ * [iconv_close(3)](https://man7.org/linux/man-pages/man3/iconv_close.3.html) deallocates a converter
* returned by iconv_open().
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
diff --git a/libc/include/ifaddrs.h b/libc/include/ifaddrs.h
index 7c0dcbf..c4d0e10 100644
--- a/libc/include/ifaddrs.h
+++ b/libc/include/ifaddrs.h
@@ -72,7 +72,7 @@
#define ifa_dstaddr ifa_ifu.ifu_dstaddr
/**
- * [getifaddrs(3)](http://man7.org/linux/man-pages/man3/getifaddrs.3.html) creates a linked list
+ * [getifaddrs(3)](https://man7.org/linux/man-pages/man3/getifaddrs.3.html) creates a linked list
* of `struct ifaddrs`. The list must be freed by freeifaddrs().
*
* Returns 0 and stores the list in `*__list_ptr` on success,
@@ -83,7 +83,7 @@
int getifaddrs(struct ifaddrs* _Nullable * _Nonnull __list_ptr) __INTRODUCED_IN(24);
/**
- * [freeifaddrs(3)](http://man7.org/linux/man-pages/man3/freeifaddrs.3.html) frees a linked list
+ * [freeifaddrs(3)](https://man7.org/linux/man-pages/man3/freeifaddrs.3.html) frees a linked list
* of `struct ifaddrs` returned by getifaddrs().
*
* Available since API level 24.
diff --git a/libc/include/libgen.h b/libc/include/libgen.h
index 474f066..8f2ea2b 100644
--- a/libc/include/libgen.h
+++ b/libc/include/libgen.h
@@ -41,7 +41,7 @@
__BEGIN_DECLS
/**
- * [basename(3)](http://man7.org/linux/man-pages/man3/basename.3.html)
+ * [basename(3)](https://man7.org/linux/man-pages/man3/basename.3.html)
* returns the final component of the given path.
*
* See `<string.h>` for the GNU basename(). Including `<libgen.h>`,
@@ -59,7 +59,7 @@
#define basename __posix_basename
/**
- * [dirname(3)](http://man7.org/linux/man-pages/man3/dirname.3.html)
+ * [dirname(3)](https://man7.org/linux/man-pages/man3/dirname.3.html)
* returns all but the final component of the given path.
*
* Note that Android's cv-qualifiers differ from POSIX; Android's implementation doesn't
diff --git a/libc/include/limits.h b/libc/include/limits.h
index 80fc45d..e1f566c 100644
--- a/libc/include/limits.h
+++ b/libc/include/limits.h
@@ -148,9 +148,15 @@
/* >= _POSIX_THREAD_DESTRUCTOR_ITERATIONS */
#define PTHREAD_DESTRUCTOR_ITERATIONS 4
-/* >= _POSIX_THREAD_KEYS_MAX */
+
+/**
+ * The number of calls to pthread_key_create() without intervening calls to
+ * pthread_key_delete() that are guaranteed to succeed. See pthread_key_create()
+ * for more details and ways to avoid hitting this limit.
+ */
#define PTHREAD_KEYS_MAX 128
-/* bionic has no specific limit */
+
+/** bionic has no specific limit on the number of threads. */
#undef PTHREAD_THREADS_MAX
#endif /* !_LIMITS_H_ */
diff --git a/libc/include/link.h b/libc/include/link.h
index 33fea49..216502e 100644
--- a/libc/include/link.h
+++ b/libc/include/link.h
@@ -25,8 +25,13 @@
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*/
-#ifndef _LINK_H_
-#define _LINK_H_
+
+#pragma once
+
+/**
+ * @file link.h
+ * @brief Extra dynamic linker functionality (see also <dlfcn.h>).
+ */
#include <stdint.h>
#include <sys/cdefs.h>
@@ -37,32 +42,80 @@
__BEGIN_DECLS
#if defined(__LP64__)
+/** Convenience macro to get the appropriate 32-bit or 64-bit <elf.h> type for the caller's bitness. */
#define ElfW(type) Elf64_ ## type
#else
+/** Convenience macro to get the appropriate 32-bit or 64-bit <elf.h> type for the caller's bitness. */
#define ElfW(type) Elf32_ ## type
#endif
+/**
+ * Information passed by dl_iterate_phdr() to the callback.
+ */
struct dl_phdr_info {
+ /** The address of the shared object. */
ElfW(Addr) dlpi_addr;
+ /** The name of the shared object. */
const char* _Nullable dlpi_name;
+ /** Pointer to the shared object's program headers. */
const ElfW(Phdr)* _Nullable dlpi_phdr;
+ /** Number of program headers pointed to by `dlpi_phdr`. */
ElfW(Half) dlpi_phnum;
- // These fields were added in Android R.
+ /**
+ * The total number of library load events at the time dl_iterate_phdr() was
+ * called.
+ *
+ * This field is only available since API level 30; you can use the size
+ * passed to the callback to determine whether you have the full struct,
+ * or just the fields up to and including `dlpi_phnum`.
+ */
unsigned long long dlpi_adds;
+ /**
+ * The total number of library unload events at the time dl_iterate_phdr() was
+ * called.
+ *
+ * This field is only available since API level 30; you can use the size
+ * passed to the callback to determine whether you have the full struct,
+ * or just the fields up to and including `dlpi_phnum`.
+ */
unsigned long long dlpi_subs;
+ /**
+ * The module ID for TLS relocations in this shared object.
+ *
+ * This field is only available since API level 30; you can use the size
+ * passed to the callback to determine whether you have the full struct,
+ * or just the fields up to and including `dlpi_phnum`.
+ */
size_t dlpi_tls_modid;
+ /**
+ * The caller's TLS data for this shared object.
+ *
+ * This field is only available since API level 30; you can use the size
+ * passed to the callback to determine whether you have the full struct,
+ * or just the fields up to and including `dlpi_phnum`.
+ */
void* _Nullable dlpi_tls_data;
};
-int dl_iterate_phdr(int (* _Nonnull __callback)(struct dl_phdr_info* _Nonnull, size_t, void* _Nullable), void* _Nullable __data);
+/**
+ * [dl_iterate_phdr(3)](https://man7.org/linux/man-pages/man3/dl_iterate_phdr.3.html)
+ * calls the given callback once for every loaded shared object. The size
+ * argument to the callback lets you determine whether you have a smaller
+ * `dl_phdr_info` from before API level 30, or the newer full one.
+ * The data argument to the callback is whatever you pass as the data argument
+ * to dl_iterate_phdr().
+ *
+ * Returns the value returned by the final call to the callback.
+ */
+int dl_iterate_phdr(int (* _Nonnull __callback)(struct dl_phdr_info* _Nonnull __info, size_t __size, void* _Nullable __data), void* _Nullable __data);
#ifdef __arm__
typedef uintptr_t _Unwind_Ptr;
_Unwind_Ptr dl_unwind_find_exidx(_Unwind_Ptr, int* _Nonnull);
#endif
-/* Used by the dynamic linker to communicate with the debugger. */
+/** Used by the dynamic linker to communicate with the debugger. */
struct link_map {
ElfW(Addr) l_addr;
char* _Nullable l_name;
@@ -71,7 +124,7 @@
struct link_map* _Nullable l_prev;
};
-/* Used by the dynamic linker to communicate with the debugger. */
+/** Used by the dynamic linker to communicate with the debugger. */
struct r_debug {
int32_t r_version;
struct link_map* _Nullable r_map;
@@ -85,5 +138,3 @@
};
__END_DECLS
-
-#endif
diff --git a/libc/include/malloc.h b/libc/include/malloc.h
index d22b85c..77b5b02 100644
--- a/libc/include/malloc.h
+++ b/libc/include/malloc.h
@@ -34,7 +34,7 @@
#define __BIONIC_ALLOC_SIZE(...) __attribute__((__alloc_size__(__VA_ARGS__)))
/**
- * [malloc(3)](http://man7.org/linux/man-pages/man3/malloc.3.html) allocates
+ * [malloc(3)](https://man7.org/linux/man-pages/man3/malloc.3.html) allocates
* memory on the heap.
*
* Returns a pointer to the allocated memory on success and returns a null
@@ -55,29 +55,29 @@
* other processes. Obviously this is not the case for apps, which will
* be killed in preference to killing other processes.
*/
-void* _Nullable malloc(size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1) __wur;
+__wur void* _Nullable malloc(size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(1);
/**
- * [calloc(3)](http://man7.org/linux/man-pages/man3/calloc.3.html) allocates
+ * [calloc(3)](https://man7.org/linux/man-pages/man3/calloc.3.html) allocates
* and clears memory on the heap.
*
* Returns a pointer to the allocated memory on success and returns a null
* pointer and sets `errno` on failure (but see the notes for malloc()).
*/
-void* _Nullable calloc(size_t __item_count, size_t __item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2) __wur;
+__wur void* _Nullable calloc(size_t __item_count, size_t __item_size) __mallocfunc __BIONIC_ALLOC_SIZE(1,2);
/**
- * [realloc(3)](http://man7.org/linux/man-pages/man3/realloc.3.html) resizes
+ * [realloc(3)](https://man7.org/linux/man-pages/man3/realloc.3.html) resizes
* allocated memory on the heap.
*
* Returns a pointer (which may be different from `__ptr`) to the resized
* memory on success and returns a null pointer and sets `errno` on failure
* (but see the notes for malloc()).
*/
-void* _Nullable realloc(void* _Nullable __ptr, size_t __byte_count) __BIONIC_ALLOC_SIZE(2) __wur;
+__wur void* _Nullable realloc(void* _Nullable __ptr, size_t __byte_count) __BIONIC_ALLOC_SIZE(2);
/**
- * [reallocarray(3)](http://man7.org/linux/man-pages/man3/realloc.3.html) resizes
+ * [reallocarray(3)](https://man7.org/linux/man-pages/man3/realloc.3.html) resizes
* allocated memory on the heap.
*
* Equivalent to `realloc(__ptr, __item_count * __item_size)` but fails if the
@@ -87,16 +87,28 @@
* memory on success and returns a null pointer and sets `errno` on failure
* (but see the notes for malloc()).
*/
-void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __wur __INTRODUCED_IN(29);
+#if __ANDROID_API__ >= 29
+__wur void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) __BIONIC_ALLOC_SIZE(2, 3) __INTRODUCED_IN(29);
+#else
+#include <errno.h>
+static __inline __wur void* _Nullable reallocarray(void* _Nullable __ptr, size_t __item_count, size_t __item_size) {
+ size_t __new_size;
+ if (__builtin_mul_overflow(__item_count, __item_size, &__new_size)) {
+ errno = ENOMEM;
+ return NULL;
+ }
+ return realloc(__ptr, __new_size);
+}
+#endif
/**
- * [free(3)](http://man7.org/linux/man-pages/man3/free.3.html) deallocates
+ * [free(3)](https://man7.org/linux/man-pages/man3/free.3.html) deallocates
* memory on the heap.
*/
void free(void* _Nullable __ptr);
/**
- * [memalign(3)](http://man7.org/linux/man-pages/man3/memalign.3.html) allocates
+ * [memalign(3)](https://man7.org/linux/man-pages/man3/memalign.3.html) allocates
* memory on the heap with the required alignment.
*
* Returns a pointer to the allocated memory on success and returns a null
@@ -104,13 +116,13 @@
*
* See also posix_memalign().
*/
-void* _Nullable memalign(size_t __alignment, size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2) __wur;
+__wur void* _Nullable memalign(size_t __alignment, size_t __byte_count) __mallocfunc __BIONIC_ALLOC_SIZE(2);
/**
- * [malloc_usable_size(3)](http://man7.org/linux/man-pages/man3/malloc_usable_size.3.html)
+ * [malloc_usable_size(3)](https://man7.org/linux/man-pages/man3/malloc_usable_size.3.html)
* returns the actual size of the given heap block.
*/
-size_t malloc_usable_size(const void* _Nullable __ptr);
+__wur size_t malloc_usable_size(const void* _Nullable __ptr);
#define __MALLINFO_BODY \
/** Total number of non-mmapped bytes currently allocated from OS. */ \
@@ -140,7 +152,7 @@
#endif
/**
- * [mallinfo(3)](http://man7.org/linux/man-pages/man3/mallinfo.3.html) returns
+ * [mallinfo(3)](https://man7.org/linux/man-pages/man3/mallinfo.3.html) returns
* information about the current state of the heap. Note that mallinfo() is
* inherently unreliable and consider using malloc_info() instead.
*/
@@ -152,14 +164,14 @@
struct mallinfo2 { __MALLINFO_BODY };
/**
- * [mallinfo2(3)](http://man7.org/linux/man-pages/man3/mallinfo2.3.html) returns
+ * [mallinfo2(3)](https://man7.org/linux/man-pages/man3/mallinfo2.3.html) returns
* information about the current state of the heap. Note that mallinfo2() is
* inherently unreliable and consider using malloc_info() instead.
*/
struct mallinfo2 mallinfo2(void) __RENAME(mallinfo);
/**
- * [malloc_info(3)](http://man7.org/linux/man-pages/man3/malloc_info.3.html)
+ * [malloc_info(3)](https://man7.org/linux/man-pages/man3/malloc_info.3.html)
* writes information about the current state of the heap to the given stream.
*
* The XML structure for malloc_info() is as follows:
@@ -186,7 +198,11 @@
int malloc_info(int __must_be_zero, FILE* _Nonnull __fp) __INTRODUCED_IN(23);
/**
- * mallopt() option to set the decay time. Valid values are 0 and 1.
+ * mallopt() option to set the decay time. Valid values are -1, 0 and 1.
+ * -1 : Disable the releasing of unused pages. This value is available since
+ * API level 35.
+ * 0 : Release the unused pages immediately.
+ * 1 : Release the unused pages at a device-specific interval.
*
* Available since API level 27.
*/
@@ -345,7 +361,7 @@
#define M_LOG_STATS (-205)
/**
- * [mallopt(3)](http://man7.org/linux/man-pages/man3/mallopt.3.html) modifies
+ * [mallopt(3)](https://man7.org/linux/man-pages/man3/mallopt.3.html) modifies
* heap behavior. Values of `__option` are the `M_` constants from this header.
*
* Returns 1 on success, 0 on error.
@@ -355,7 +371,7 @@
int mallopt(int __option, int __value) __INTRODUCED_IN(26);
/**
- * [__malloc_hook(3)](http://man7.org/linux/man-pages/man3/__malloc_hook.3.html)
+ * [__malloc_hook(3)](https://man7.org/linux/man-pages/man3/__malloc_hook.3.html)
* is called to implement malloc(). By default this points to the system's
* implementation.
*
@@ -366,7 +382,7 @@
extern void* _Nonnull (*volatile _Nonnull __malloc_hook)(size_t __byte_count, const void* _Nonnull __caller) __INTRODUCED_IN(28);
/**
- * [__realloc_hook(3)](http://man7.org/linux/man-pages/man3/__realloc_hook.3.html)
+ * [__realloc_hook(3)](https://man7.org/linux/man-pages/man3/__realloc_hook.3.html)
* is called to implement realloc(). By default this points to the system's
* implementation.
*
@@ -377,7 +393,7 @@
extern void* _Nonnull (*volatile _Nonnull __realloc_hook)(void* _Nullable __ptr, size_t __byte_count, const void* _Nonnull __caller) __INTRODUCED_IN(28);
/**
- * [__free_hook(3)](http://man7.org/linux/man-pages/man3/__free_hook.3.html)
+ * [__free_hook(3)](https://man7.org/linux/man-pages/man3/__free_hook.3.html)
* is called to implement free(). By default this points to the system's
* implementation.
*
@@ -388,7 +404,7 @@
extern void (*volatile _Nonnull __free_hook)(void* _Nullable __ptr, const void* _Nonnull __caller) __INTRODUCED_IN(28);
/**
- * [__memalign_hook(3)](http://man7.org/linux/man-pages/man3/__memalign_hook.3.html)
+ * [__memalign_hook(3)](https://man7.org/linux/man-pages/man3/__memalign_hook.3.html)
* is called to implement memalign(). By default this points to the system's
* implementation.
*
diff --git a/libc/include/math.h b/libc/include/math.h
index fc6c228..343ab98 100644
--- a/libc/include/math.h
+++ b/libc/include/math.h
@@ -68,10 +68,7 @@
#define isnormal(x) __builtin_isnormal(x)
-#define signbit(x) \
- ((sizeof(x) == sizeof(float)) ? __builtin_signbitf(x) \
- : (sizeof(x) == sizeof(double)) ? __builtin_signbit(x) \
- : __builtin_signbitl(x))
+#define signbit(x) __builtin_signbit(x)
double acos(double __x);
float acosf(float __x);
@@ -308,20 +305,6 @@
#define islessgreater(x, y) __builtin_islessgreater((x), (y))
#define isunordered(x, y) __builtin_isunordered((x), (y))
-/*
- * https://code.google.com/p/android/issues/detail?id=271629
- * To be fully compliant with C++, we need to not define these (C doesn't
- * specify them either). Exposing these means that isinf and isnan will have a
- * return type of int in C++ rather than bool like they're supposed to be.
- *
- * GNU libstdc++ 4.9 isn't able to handle a standard compliant C library. Its
- * <cmath> will `#undef isnan` from math.h and only adds the function overloads
- * to the std namespace, making it impossible to use both <cmath> (which gets
- * included by a lot of other standard headers) and ::isnan.
- */
-int (isinf)(double __x) __attribute_const__;
-int (isnan)(double __x) __attribute_const__;
-
/* POSIX extensions. */
extern int signgam;
@@ -362,6 +345,7 @@
double scalb(double __x, double __exponent);
double drem(double __x, double __y);
int finite(double __x) __attribute_const__;
+int isinff(float __x) __attribute_const__;
int isnanf(float __x) __attribute_const__;
double gamma_r(double __x, int* _Nonnull __sign);
double lgamma_r(double __x, int* _Nonnull __sign);
@@ -402,6 +386,8 @@
#define M_2_SQRTPIl 1.128379167095512573896158903121545172L /* 2/sqrt(pi) */
#define M_SQRT2l 1.414213562373095048801688724209698079L /* sqrt(2) */
#define M_SQRT1_2l 0.707106781186547524400844362104849039L /* 1/sqrt(2) */
+int isinfl(long double __x) __attribute_const__;
+int isnanl(long double __x) __attribute_const__;
#endif
__END_DECLS
diff --git a/libc/include/netinet/ether.h b/libc/include/netinet/ether.h
index 4af7eda..a847385 100644
--- a/libc/include/netinet/ether.h
+++ b/libc/include/netinet/ether.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [ether_ntoa(3)](http://man7.org/linux/man-pages/man3/ether_ntoa.3.html) returns a string
+ * [ether_ntoa(3)](https://man7.org/linux/man-pages/man3/ether_ntoa.3.html) returns a string
* representation of the given Ethernet (MAC) address.
*
* Returns a pointer to a static buffer.
@@ -47,7 +47,7 @@
char* _Nonnull ether_ntoa(const struct ether_addr* _Nonnull __addr);
/**
- * [ether_ntoa_r(3)](http://man7.org/linux/man-pages/man3/ether_ntoa_r.3.html) returns a string
+ * [ether_ntoa_r(3)](https://man7.org/linux/man-pages/man3/ether_ntoa_r.3.html) returns a string
* representation of the given Ethernet (MAC) address.
*
* Returns a pointer to the given buffer.
@@ -55,7 +55,7 @@
char* _Nonnull ether_ntoa_r(const struct ether_addr* _Nonnull __addr, char* _Nonnull __buf);
/**
- * [ether_aton(3)](http://man7.org/linux/man-pages/man3/ether_aton.3.html) returns an `ether_addr`
+ * [ether_aton(3)](https://man7.org/linux/man-pages/man3/ether_aton.3.html) returns an `ether_addr`
* corresponding to the given Ethernet (MAC) address string.
*
* Returns a pointer to a static buffer, or NULL if the given string isn't a valid MAC address.
@@ -63,7 +63,7 @@
struct ether_addr* _Nullable ether_aton(const char* _Nonnull __ascii);
/**
- * [ether_aton_r(3)](http://man7.org/linux/man-pages/man3/ether_aton_r.3.html) returns an
+ * [ether_aton_r(3)](https://man7.org/linux/man-pages/man3/ether_aton_r.3.html) returns an
* `ether_addr` corresponding to the given Ethernet (MAC) address string.
*
* Returns a pointer to the given buffer, or NULL if the given string isn't a valid MAC address.
diff --git a/libm/fenv-access.h b/libc/include/netinet/igmp.h
similarity index 67%
rename from libm/fenv-access.h
rename to libc/include/netinet/igmp.h
index 7acb34d..497d02d 100644
--- a/libm/fenv-access.h
+++ b/libc/include/netinet/igmp.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,29 @@
#pragma once
-#if defined(__x86_64__) || defined(__i386__)
-#pragma STDC FENV_ACCESS ON
-#endif
+/**
+ * @file netinet/igmp.h
+ * @brief Internet Group Management Protocol (IGMP).
+ */
+
+#include <sys/cdefs.h>
+#include <netinet/in.h>
+
+#include <linux/igmp.h>
+
+/**
+ * The uapi type is called `igmphdr`,
+ * doesn't have the `igmp_` prefix on each field,
+ * and uses a `__be32` for the group address.
+ *
+ * This is the type that BSDs and musl/glibc expose to userspace.
+ */
+struct igmp {
+ uint8_t igmp_type;
+ uint8_t igmp_code;
+ uint16_t igmp_cksum;
+ struct in_addr igmp_group;
+};
+
+/** Commonly-used BSD synonym for the Linux constant. */
+#define IGMP_MEMBERSHIP_QUERY IGMP_HOST_MEMBERSHIP_QUERY
diff --git a/libc/include/netinet/in6.h b/libc/include/netinet/in6.h
index ae20f83..44b3e3e 100644
--- a/libc/include/netinet/in6.h
+++ b/libc/include/netinet/in6.h
@@ -89,7 +89,7 @@
(IN6_IS_ADDR_MULTICAST(a) && (IPV6_ADDR_MC_SCOPE(a) == IPV6_ADDR_SCOPE_GLOBAL))
#define IN6_ARE_ADDR_EQUAL(a, b) \
- (memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
+ (__builtin_memcmp(&(a)->s6_addr[0], &(b)->s6_addr[0], sizeof(struct in6_addr)) == 0)
#define INET6_ADDRSTRLEN 46
diff --git a/libc/include/nl_types.h b/libc/include/nl_types.h
index f4d7f43..6c9935d 100644
--- a/libc/include/nl_types.h
+++ b/libc/include/nl_types.h
@@ -56,7 +56,7 @@
typedef int nl_item;
/**
- * [catopen(3)](http://man7.org/linux/man-pages/man3/catopen.3.html) opens a message catalog.
+ * [catopen(3)](https://man7.org/linux/man-pages/man3/catopen.3.html) opens a message catalog.
*
* On Android, this always returns failure: `((nl_catd) -1)`.
*
@@ -65,7 +65,7 @@
nl_catd _Nonnull catopen(const char* _Nonnull __name, int __flag) __INTRODUCED_IN(26);
/**
- * [catgets(3)](http://man7.org/linux/man-pages/man3/catgets.3.html) translates the given message
+ * [catgets(3)](https://man7.org/linux/man-pages/man3/catgets.3.html) translates the given message
* using the given message catalog.
*
* On Android, this always returns `__msg`.
@@ -75,7 +75,7 @@
char* _Nonnull catgets(nl_catd _Nonnull __catalog, int __set_number, int __msg_number, const char* _Nonnull __msg) __INTRODUCED_IN(26);
/**
- * [catclose(3)](http://man7.org/linux/man-pages/man3/catclose.3.html) closes a message catalog.
+ * [catclose(3)](https://man7.org/linux/man-pages/man3/catclose.3.html) closes a message catalog.
*
* On Android, this always returns -1 with `errno` set to `EBADF`.
*/
diff --git a/libc/include/poll.h b/libc/include/poll.h
index 6bdc886..0dda3da 100644
--- a/libc/include/poll.h
+++ b/libc/include/poll.h
@@ -44,7 +44,7 @@
typedef unsigned int nfds_t;
/**
- * [poll(3)](http://man7.org/linux/man-pages/man3/poll.3.html) waits on a set of file descriptors.
+ * [poll(3)](https://man7.org/linux/man-pages/man3/poll.3.html) waits on a set of file descriptors.
*
* Returns the number of ready file descriptors on success, 0 for timeout,
* and returns -1 and sets `errno` on failure.
@@ -52,7 +52,7 @@
int poll(struct pollfd* _Nullable __fds, nfds_t __count, int __timeout_ms);
/**
- * [ppoll(3)](http://man7.org/linux/man-pages/man3/ppoll.3.html) waits on a set of file descriptors
+ * [ppoll(3)](https://man7.org/linux/man-pages/man3/ppoll.3.html) waits on a set of file descriptors
* or a signal. Set `__timeout` to null for no timeout. Set `__mask` to null to not set the signal
* mask.
*
diff --git a/libc/include/pthread.h b/libc/include/pthread.h
index 871c62c..33c637f 100644
--- a/libc/include/pthread.h
+++ b/libc/include/pthread.h
@@ -70,9 +70,7 @@
#define PTHREAD_ONCE_INIT 0
-#if __ANDROID_API__ >= 24
#define PTHREAD_BARRIER_SERIAL_THREAD (-1)
-#endif
#if defined(__LP64__)
#define PTHREAD_STACK_MIN 16384
@@ -144,20 +142,7 @@
const struct timespec* _Nullable __timeout) __INTRODUCED_IN_64(28);
int pthread_cond_wait(pthread_cond_t* _Nonnull __cond, pthread_mutex_t* _Nonnull __mutex);
-#if defined(__clang__)
-/*
- * Disable -Wbuiltin-requires-header because clang confuses this declaration with the one defined in
- * "llvm/tools/clang/include/clang/Basic/Builtins.def", which did not define any formal arguments.
- * It seems to be an upstream bug and the fix (https://reviews.llvm.org/D58531) is still under
- * review. Thus, let's disable the warning for this function declaration.
- */
-#pragma clang diagnostic push
-#pragma clang diagnostic ignored "-Wbuiltin-requires-header"
-#endif
int pthread_create(pthread_t* _Nonnull __pthread_ptr, pthread_attr_t const* _Nullable __attr, void* _Nonnull (* _Nonnull __start_routine)(void* _Nonnull), void* _Nullable);
-#if defined(__clang__)
-#pragma clang diagnostic pop
-#endif
int pthread_detach(pthread_t __pthread);
void pthread_exit(void* _Nullable __return_value) __noreturn;
@@ -174,7 +159,29 @@
int pthread_join(pthread_t __pthread, void* _Nullable * _Nullable __return_value_ptr);
+/**
+ * [pthread_key_create(3)](https://man7.org/linux/man-pages/man3/pthread_key_create.3p.html)
+ * creates a key for thread-specific data.
+ *
+ * There is a limit of `PTHREAD_KEYS_MAX` keys per process, but most callers
+ * should just use the C or C++ `thread_local` storage specifier anyway. When
+ * targeting new enough OS versions, the compiler will automatically use
+ * ELF TLS; when targeting old OS versions the emutls implementation will
+ * multiplex pthread keys behind the scenes, using one per library rather than
+ * one per thread-local variable. If you are implementing the runtime for a
+ * different language, you should consider similar implementation choices and
+ * avoid a direct one-to-one mapping from thread locals to pthread keys.
+ *
+ * Returns 0 on success and returns an error number on failure.
+ */
int pthread_key_create(pthread_key_t* _Nonnull __key_ptr, void (* _Nullable __key_destructor)(void* _Nullable));
+
+/**
+ * [pthread_key_delete(3)](https://man7.org/linux/man-pages/man3/pthread_key_delete.3p.html)
+ * deletes a key for thread-specific data.
+ *
+ * Returns 0 on success and returns an error number on failure.
+ */
int pthread_key_delete(pthread_key_t __key);
int pthread_mutexattr_destroy(pthread_mutexattr_t* _Nonnull __attr);
@@ -237,26 +244,20 @@
int pthread_rwlock_unlock(pthread_rwlock_t* _Nonnull __rwlock);
int pthread_rwlock_wrlock(pthread_rwlock_t* _Nonnull __rwlock);
-#if __ANDROID_API__ >= 24
int pthread_barrierattr_init(pthread_barrierattr_t* _Nonnull __attr) __INTRODUCED_IN(24);
int pthread_barrierattr_destroy(pthread_barrierattr_t* _Nonnull __attr) __INTRODUCED_IN(24);
int pthread_barrierattr_getpshared(const pthread_barrierattr_t* _Nonnull __attr, int* _Nonnull __shared) __INTRODUCED_IN(24);
int pthread_barrierattr_setpshared(pthread_barrierattr_t* _Nonnull __attr, int __shared) __INTRODUCED_IN(24);
-#endif
-#if __ANDROID_API__ >= 24
int pthread_barrier_init(pthread_barrier_t* _Nonnull __barrier, const pthread_barrierattr_t* _Nullable __attr, unsigned __count) __INTRODUCED_IN(24);
int pthread_barrier_destroy(pthread_barrier_t* _Nonnull __barrier) __INTRODUCED_IN(24);
int pthread_barrier_wait(pthread_barrier_t* _Nonnull __barrier) __INTRODUCED_IN(24);
-#endif
-#if __ANDROID_API__ >= 24
int pthread_spin_destroy(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
int pthread_spin_init(pthread_spinlock_t* _Nonnull __spinlock, int __shared) __INTRODUCED_IN(24);
int pthread_spin_lock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
int pthread_spin_trylock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
int pthread_spin_unlock(pthread_spinlock_t* _Nonnull __spinlock) __INTRODUCED_IN(24);
-#endif
pthread_t pthread_self(void) __attribute_const__;
diff --git a/libc/include/pty.h b/libc/include/pty.h
index be447d6..1cfb772 100644
--- a/libc/include/pty.h
+++ b/libc/include/pty.h
@@ -41,7 +41,7 @@
__BEGIN_DECLS
/**
- * [openpty(3)](http://man7.org/linux/man-pages/man3/openpty.3.html) finds
+ * [openpty(3)](https://man7.org/linux/man-pages/man3/openpty.3.html) finds
* a free pseudoterminal and configures it with the given terminal and window
* size settings.
*
@@ -52,7 +52,7 @@
int openpty(int* _Nonnull __pty_fd, int* _Nonnull __tty_fd, char* _Nullable __tty_name, const struct termios* _Nullable __termios_ptr, const struct winsize* _Nullable __winsize_ptr) __INTRODUCED_IN(23);
/**
- * [forkpty(3)](http://man7.org/linux/man-pages/man3/forkpty.3.html) creates
+ * [forkpty(3)](https://man7.org/linux/man-pages/man3/forkpty.3.html) creates
* a new process connected to a pseudoterminal from openpty().
*
* Returns 0 in the child/the pid of the child in the parent on success,
diff --git a/libc/include/sched.h b/libc/include/sched.h
index 9f043b6..e8f7736 100644
--- a/libc/include/sched.h
+++ b/libc/include/sched.h
@@ -45,42 +45,42 @@
*
* (Linux's name for POSIX's SCHED_OTHER.)
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
* @def SCHED_FIFO
* The real-time first-in/first-out scheduling policy.
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
* @def SCHED_RR
* The real-time round-robin policy. (See also SCHED_NORMAL/SCHED_OTHER.)
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
* @def SCHED_BATCH
* The batch scheduling policy.
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
* @def SCHED_IDLE
* The low priority "only when otherwise idle" scheduling priority.
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
* @def SCHED_DEADLINE
* The deadline scheduling policy.
*
- * See [sched(7)](http://man7.org/linux/man-pages/man7/sched.7.html)
+ * See [sched(7)](https://man7.org/linux/man-pages/man7/sched.7.html)
*/
/*
@@ -116,7 +116,7 @@
int sched_getscheduler(pid_t __pid);
/**
- * [sched_yield(2)](http://man7.org/linux/man-pages/man2/sched_yield.2.html)
+ * [sched_yield(2)](https://man7.org/linux/man-pages/man2/sched_yield.2.html)
* voluntarily gives up using the CPU so that another thread can run.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -124,7 +124,7 @@
int sched_yield(void);
/**
- * [sched_get_priority_max(2)](http://man7.org/linux/man-pages/man2/sched_get_priority_max.2.html)
+ * [sched_get_priority_max(2)](https://man7.org/linux/man-pages/man2/sched_get_priority_max.2.html)
* gets the maximum priority value allowed for the given scheduling policy.
*
* Returns a priority on success and returns -1 and sets `errno` on failure.
@@ -132,7 +132,7 @@
int sched_get_priority_max(int __policy);
/**
- * [sched_get_priority_min(2)](http://man7.org/linux/man-pages/man2/sched_get_priority_min.2.html)
+ * [sched_get_priority_min(2)](https://man7.org/linux/man-pages/man2/sched_get_priority_min.2.html)
* gets the minimum priority value allowed for the given scheduling policy.
*
* Returns a priority on success and returns -1 and sets `errno` on failure.
@@ -140,7 +140,7 @@
int sched_get_priority_min(int __policy);
/**
- * [sched_setparam(2)](http://man7.org/linux/man-pages/man2/sched_setparam.2.html)
+ * [sched_setparam(2)](https://man7.org/linux/man-pages/man2/sched_setparam.2.html)
* sets the scheduling parameters for the given thread.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -148,7 +148,7 @@
int sched_setparam(pid_t __pid, const struct sched_param* _Nonnull __param);
/**
- * [sched_getparam(2)](http://man7.org/linux/man-pages/man2/sched_getparam.2.html)
+ * [sched_getparam(2)](https://man7.org/linux/man-pages/man2/sched_getparam.2.html)
* gets the scheduling parameters for the given thread.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -156,7 +156,7 @@
int sched_getparam(pid_t __pid, struct sched_param* _Nonnull __param);
/**
- * [sched_rr_get_interval(2)](http://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html)
+ * [sched_rr_get_interval(2)](https://man7.org/linux/man-pages/man2/sched_rr_get_interval.2.html)
* queries the round-robin time quantum for the given thread.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -166,7 +166,7 @@
#if defined(__USE_GNU)
/**
- * [clone(2)](http://man7.org/linux/man-pages/man2/clone.2.html)
+ * [clone(2)](https://man7.org/linux/man-pages/man2/clone.2.html)
* creates a new child process.
*
* Returns the pid of the child to the caller on success and
@@ -175,7 +175,7 @@
int clone(int (* __BIONIC_COMPLICATED_NULLNESS __fn)(void* __BIONIC_COMPLICATED_NULLNESS ), void* __BIONIC_COMPLICATED_NULLNESS __child_stack, int __flags, void* _Nullable __arg, ...);
/**
- * [unshare(2)](http://man7.org/linux/man-pages/man2/unshare.2.html)
+ * [unshare(2)](https://man7.org/linux/man-pages/man2/unshare.2.html)
* disassociates part of the caller's execution context.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -183,7 +183,7 @@
int unshare(int __flags);
/**
- * [setns(2)](http://man7.org/linux/man-pages/man2/setns.2.html)
+ * [setns(2)](https://man7.org/linux/man-pages/man2/setns.2.html)
* reassociates a thread with a different namespace.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -191,7 +191,7 @@
int setns(int __fd, int __ns_type);
/**
- * [sched_getcpu(3)](http://man7.org/linux/man-pages/man3/sched_getcpu.3.html)
+ * [sched_getcpu(3)](https://man7.org/linux/man-pages/man3/sched_getcpu.3.html)
* reports which CPU the caller is running on.
*
* Returns a non-negative CPU number on success and returns -1 and sets
@@ -219,7 +219,7 @@
} cpu_set_t;
/**
- * [sched_setaffinity(2)](http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html)
+ * [sched_setaffinity(2)](https://man7.org/linux/man-pages/man2/sched_setaffinity.2.html)
* sets the CPU affinity mask for the given thread.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -227,7 +227,7 @@
int sched_setaffinity(pid_t __pid, size_t __set_size, const cpu_set_t* _Nonnull __set);
/**
- * [sched_getaffinity(2)](http://man7.org/linux/man-pages/man2/sched_getaffinity.2.html)
+ * [sched_getaffinity(2)](https://man7.org/linux/man-pages/man2/sched_getaffinity.2.html)
* gets the CPU affinity mask for the given thread.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
diff --git a/libc/include/search.h b/libc/include/search.h
index fe897d1..85e31ee 100644
--- a/libc/include/search.h
+++ b/libc/include/search.h
@@ -64,19 +64,19 @@
__BEGIN_DECLS
/**
- * [insque(3)](http://man7.org/linux/man-pages/man3/insque.3.html) inserts
+ * [insque(3)](https://man7.org/linux/man-pages/man3/insque.3.html) inserts
* an item in a queue (an intrusive doubly-linked list).
*/
void insque(void* _Nonnull __element, void* _Nullable __previous);
/**
- * [remque(3)](http://man7.org/linux/man-pages/man3/remque.3.html) removes
+ * [remque(3)](https://man7.org/linux/man-pages/man3/remque.3.html) removes
* an item from a queue (an intrusive doubly-linked list).
*/
void remque(void* _Nonnull __element);
/**
- * [hcreate(3)](http://man7.org/linux/man-pages/man3/hcreate.3.html)
+ * [hcreate(3)](https://man7.org/linux/man-pages/man3/hcreate.3.html)
* initializes the global hash table, with space for at least `__n` elements.
*
* See hcreate_r() if you need more than one hash table.
@@ -88,7 +88,7 @@
int hcreate(size_t __n) __INTRODUCED_IN(28);
/**
- * [hdestroy(3)](http://man7.org/linux/man-pages/man3/hdestroy.3.html) destroys
+ * [hdestroy(3)](https://man7.org/linux/man-pages/man3/hdestroy.3.html) destroys
* the global hash table.
*
* See hdestroy_r() if you need more than one hash table.
@@ -98,7 +98,7 @@
void hdestroy(void) __INTRODUCED_IN(28);
/**
- * [hsearch(3)](http://man7.org/linux/man-pages/man3/hsearch.3.html) finds or
+ * [hsearch(3)](https://man7.org/linux/man-pages/man3/hsearch.3.html) finds or
* inserts `__entry` in the global hash table, based on `__action`.
*
* See hsearch_r() if you need more than one hash table.
@@ -113,7 +113,7 @@
#if defined(__USE_BSD) || defined(__USE_GNU)
/**
- * [hcreate_r(3)](http://man7.org/linux/man-pages/man3/hcreate_r.3.html)
+ * [hcreate_r(3)](https://man7.org/linux/man-pages/man3/hcreate_r.3.html)
* initializes a hash table `__table` with space for at least `__n` elements.
*
* Returns *non-zero* on success and returns 0 and sets `errno` on failure.
@@ -123,7 +123,7 @@
int hcreate_r(size_t __n, struct hsearch_data* _Nonnull __table) __INTRODUCED_IN(28);
/**
- * [hdestroy_r(3)](http://man7.org/linux/man-pages/man3/hdestroy_r.3.html) destroys
+ * [hdestroy_r(3)](https://man7.org/linux/man-pages/man3/hdestroy_r.3.html) destroys
* the hash table `__table`.
*
* Available since API level 28.
@@ -131,7 +131,7 @@
void hdestroy_r(struct hsearch_data* _Nonnull __table) __INTRODUCED_IN(28);
/**
- * [hsearch_r(3)](http://man7.org/linux/man-pages/man3/hsearch_r.3.html) finds or
+ * [hsearch_r(3)](https://man7.org/linux/man-pages/man3/hsearch_r.3.html) finds or
* inserts `__entry` in the hash table `__table`, based on `__action`.
*
* Returns *non-zero* on success and returns 0 and sets `errno` on failure.
@@ -144,7 +144,7 @@
#endif
/**
- * [lfind(3)](http://man7.org/linux/man-pages/man3/lfind.3.html) brute-force
+ * [lfind(3)](https://man7.org/linux/man-pages/man3/lfind.3.html) brute-force
* searches the unsorted array `__array` (of `__count` items each of size `__size`)
* for `__key`, using `__comparator`.
*
@@ -155,7 +155,7 @@
void* _Nullable lfind(const void* _Nonnull __key, const void* _Nonnull __array, size_t* _Nonnull __count, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull, const void* _Nonnull));
/**
- * [lsearch(3)](http://man7.org/linux/man-pages/man3/lsearch.3.html) brute-force
+ * [lsearch(3)](https://man7.org/linux/man-pages/man3/lsearch.3.html) brute-force
* searches the unsorted array `__array` (of `__count` items each of size `__size`)
* for `__key`, using `__comparator`.
*
@@ -168,7 +168,7 @@
void* _Nonnull lsearch(const void* _Nonnull __key, void* _Nonnull __array, size_t* _Nonnull __count, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull, const void* _Nonnull));
/**
- * [tdelete(3)](http://man7.org/linux/man-pages/man3/tdelete.3.html) searches
+ * [tdelete(3)](https://man7.org/linux/man-pages/man3/tdelete.3.html) searches
* for and removes an element in the tree `*__root_ptr`. The search is performed
* using `__comparator`.
*
@@ -177,13 +177,13 @@
void* _Nullable tdelete(const void* _Nonnull __key, void* _Nullable * _Nullable __root_ptr, int (* _Nonnull __comparator)(const void* _Nonnull, const void* _Nonnull));
/**
- * [tdestroy(3)](http://man7.org/linux/man-pages/man3/tdestroy.3.html) destroys
+ * [tdestroy(3)](https://man7.org/linux/man-pages/man3/tdestroy.3.html) destroys
* the hash table `__root` using `__free_fn` on each node.
*/
void tdestroy(void* _Nullable __root, void (* _Nullable __free_fn)(void* _Nullable));
/**
- * [tfind(3)](http://man7.org/linux/man-pages/man3/tfind.3.html) searches
+ * [tfind(3)](https://man7.org/linux/man-pages/man3/tfind.3.html) searches
* for an element in the tree `*__root_ptr`. The search is performed using
* `__comparator`.
*
@@ -192,7 +192,7 @@
void* _Nullable tfind(const void* _Nonnull __key, void* _Nullable const* _Nullable __root_ptr, int (* _Nonnull __comparator)(const void* _Nonnull, const void* _Nonnull));
/**
- * [tsearch(3)](http://man7.org/linux/man-pages/man3/tsearch.3.html) searches
+ * [tsearch(3)](https://man7.org/linux/man-pages/man3/tsearch.3.html) searches
* for an element in the tree `*__root_ptr`. The search is performed using
* `__comparator`.
*
@@ -203,7 +203,7 @@
void* _Nullable tsearch(const void* _Nonnull __key, void* _Nullable * _Nullable __root_ptr, int (* _Nonnull __comparator)(const void* _Nonnull, const void* _Nonnull));
/**
- * [twalk(3)](http://man7.org/linux/man-pages/man3/twalk.3.html) calls
+ * [twalk(3)](https://man7.org/linux/man-pages/man3/twalk.3.html) calls
* `__visitor` on every node in the tree.
*/
void twalk(const void* _Nullable __root, void (* _Nullable __visitor)(const void* _Nullable, VISIT, int));
diff --git a/libc/include/setjmp.h b/libc/include/setjmp.h
index 0aaaac5..6c141cb 100644
--- a/libc/include/setjmp.h
+++ b/libc/include/setjmp.h
@@ -111,7 +111,7 @@
__noreturn void longjmp(jmp_buf __env, int __value);
/**
- * [sigsetjmp(3)](http://man7.org/linux/man-pages/man3/sigsetjmp.3.html)
+ * [sigsetjmp(3)](https://man7.org/linux/man-pages/man3/sigsetjmp.3.html)
* sets the target of a future siglongjmp() call, saving or not saving the
* current signal mask based on the second argument.
*
@@ -121,7 +121,7 @@
int sigsetjmp(sigjmp_buf __env, int __save_signal_mask) __returns_twice;
/**
- * [siglongjmp(3)](http://man7.org/linux/man-pages/man3/siglongjmp.3.html)
+ * [siglongjmp(3)](https://man7.org/linux/man-pages/man3/siglongjmp.3.html)
* transfers control back to the site of the sigsetjmp() call that initialized
* the given jump buffer, returning the given value.
*
diff --git a/libc/include/signal.h b/libc/include/signal.h
index cf83db8..893fa9d 100644
--- a/libc/include/signal.h
+++ b/libc/include/signal.h
@@ -86,17 +86,17 @@
int sigwait64(const sigset64_t* _Nonnull __set, int* _Nonnull __signal) __INTRODUCED_IN(28);
int sighold(int __signal)
- __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
+ __attribute__((__deprecated__("use sigprocmask() or pthread_sigmask() instead")))
__INTRODUCED_IN(26);
int sigignore(int __signal)
- __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
+ __attribute__((__deprecated__("use sigaction() instead"))) __INTRODUCED_IN(26);
int sigpause(int __signal)
- __attribute__((deprecated("use sigsuspend() instead"))) __INTRODUCED_IN(26);
+ __attribute__((__deprecated__("use sigsuspend() instead"))) __INTRODUCED_IN(26);
int sigrelse(int __signal)
- __attribute__((deprecated("use sigprocmask() or pthread_sigmask() instead")))
+ __attribute__((__deprecated__("use sigprocmask() or pthread_sigmask() instead")))
__INTRODUCED_IN(26);
sighandler_t _Nonnull sigset(int __signal, sighandler_t _Nullable __handler)
- __attribute__((deprecated("use sigaction() instead"))) __INTRODUCED_IN(26);
+ __attribute__((__deprecated__("use sigaction() instead"))) __INTRODUCED_IN(26);
int raise(int __signal);
int kill(pid_t __pid, int __signal);
@@ -122,6 +122,34 @@
int sigwaitinfo(const sigset_t* _Nonnull __set, siginfo_t* _Nullable __info) __INTRODUCED_IN(23);
int sigwaitinfo64(const sigset64_t* _Nonnull __set, siginfo_t* _Nullable __info) __INTRODUCED_IN(28);
+/**
+ * Buffer size suitable for any call to sig2str().
+ */
+#define SIG2STR_MAX 32
+
+/**
+ * [sig2str(3)](https://man7.org/linux/man-pages/man3/sig2str.3.html)
+ * converts the integer corresponding to SIGSEGV (say) into a string
+ * like "SEGV" (not including the "SIG" used in the constants).
+ * SIG2STR_MAX is a safe size to use for the buffer.
+ *
+ * Returns 0 on success, and returns -1 _without_ setting errno otherwise.
+ *
+ * Available since API level 36.
+ */
+int sig2str(int __signal, char* _Nonnull __buf) __INTRODUCED_IN(36);
+
+/**
+ * [str2sig(3)](https://man7.org/linux/man-pages/man3/str2sig.3.html)
+ * converts a string like "SEGV" (not including the "SIG" used in the constants)
+ * into the integer corresponding to SIGSEGV.
+ *
+ * Returns 0 on success, and returns -1 _without_ setting errno otherwise.
+ *
+ * Available since API level 36.
+ */
+int str2sig(const char* _Nonnull __name, int* _Nonnull __signal) __INTRODUCED_IN(36);
+
__END_DECLS
#endif
diff --git a/libc/include/spawn.h b/libc/include/spawn.h
index 3ce402f..f366239 100644
--- a/libc/include/spawn.h
+++ b/libc/include/spawn.h
@@ -46,14 +46,17 @@
#define POSIX_SPAWN_USEVFORK 64
#define POSIX_SPAWN_SETSID 128
#endif
-// mark all fds (except stdin/out/err) as close-on-exec prior to executing registered file actions
+/**
+ * Used with posix_spawnattr_setflags() to mark all fds except
+ * stdin/stdout/stderr as O_CLOEXEC prior to executing registered file actions.
+ */
#define POSIX_SPAWN_CLOEXEC_DEFAULT 256
typedef struct __posix_spawnattr* posix_spawnattr_t;
typedef struct __posix_spawn_file_actions* posix_spawn_file_actions_t;
-int posix_spawn(pid_t* _Nullable __pid, const char* _Nonnull __path, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nonnull __argv[_Nonnull], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
-int posix_spawnp(pid_t* _Nullable __pid, const char* _Nonnull __file, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nonnull __argv[_Nonnull], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
+int posix_spawn(pid_t* _Nullable __pid, const char* _Nonnull __path, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nullable __argv[_Nullable], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
+int posix_spawnp(pid_t* _Nullable __pid, const char* _Nonnull __file, const posix_spawn_file_actions_t _Nullable * _Nullable __actions, const posix_spawnattr_t _Nullable * _Nullable __attr, char* const _Nullable __argv[_Nullable], char* const _Nullable __env[_Nullable]) __INTRODUCED_IN(28);
int posix_spawnattr_init(posix_spawnattr_t _Nullable * _Nonnull __attr) __INTRODUCED_IN(28);
int posix_spawnattr_destroy(posix_spawnattr_t _Nonnull * _Nonnull __attr) __INTRODUCED_IN(28);
diff --git a/libc/include/stdio.h b/libc/include/stdio.h
index 312b356..d99d032 100644
--- a/libc/include/stdio.h
+++ b/libc/include/stdio.h
@@ -69,7 +69,7 @@
#define stderr stderr
#else
/* Before M the actual symbols for stdin and friends had different names. */
-extern FILE __sF[] __REMOVED_IN(23);
+extern FILE __sF[] __REMOVED_IN(23, "Use stdin/stdout/stderr");
#define stdin (&__sF[0])
#define stdout (&__sF[1])
@@ -105,10 +105,10 @@
void clearerr(FILE* _Nonnull __fp);
int fclose(FILE* _Nonnull __fp);
-int feof(FILE* _Nonnull __fp);
-int ferror(FILE* _Nonnull __fp);
+__wur int feof(FILE* _Nonnull __fp);
+__wur int ferror(FILE* _Nonnull __fp);
int fflush(FILE* _Nullable __fp);
-int fgetc(FILE* _Nonnull __fp);
+__wur int fgetc(FILE* _Nonnull __fp);
char* _Nullable fgets(char* _Nonnull __buf, int __size, FILE* _Nonnull __fp);
int fprintf(FILE* _Nonnull __fp , const char* _Nonnull __fmt, ...) __printflike(2, 3);
int fputc(int __ch, FILE* _Nonnull __fp);
@@ -116,8 +116,8 @@
size_t fread(void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp);
int fscanf(FILE* _Nonnull __fp, const char* _Nonnull __fmt, ...) __scanflike(2, 3);
size_t fwrite(const void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp);
-int getc(FILE* _Nonnull __fp);
-int getchar(void);
+__wur int getc(FILE* _Nonnull __fp);
+__wur int getchar(void);
ssize_t getdelim(char* _Nullable * _Nonnull __line_ptr, size_t* _Nonnull __line_length_ptr, int __delimiter, FILE* _Nonnull __fp);
ssize_t getline(char* _Nullable * _Nonnull __line_ptr, size_t* _Nonnull __line_length_ptr, FILE* _Nonnull __fp);
@@ -141,7 +141,7 @@
#if (defined(__STDC_VERSION__) && __STDC_VERSION__ < 201112L) || \
(defined(__cplusplus) && __cplusplus <= 201103L)
-char* _Nullable gets(char* _Nonnull __buf) __attribute__((deprecated("gets is unsafe, use fgets instead")));
+char* _Nullable gets(char* _Nonnull __buf) __attribute__((__deprecated__("gets is unsafe, use fgets instead")));
#endif
int sprintf(char* __BIONIC_COMPLICATED_NULLNESS __s, const char* _Nonnull __fmt, ...)
__printflike(2, 3) __warnattr_strict("sprintf is often misused; please use snprintf");
@@ -154,7 +154,7 @@
__warnattr("tempnam is unsafe, use mkstemp or tmpfile instead");
/**
- * [rename(2)](http://man7.org/linux/man-pages/man2/rename.2.html) changes
+ * [rename(2)](https://man7.org/linux/man-pages/man2/rename.2.html) changes
* the name or location of a file.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -162,7 +162,7 @@
int rename(const char* _Nonnull __old_path, const char* _Nonnull __new_path);
/**
- * [renameat(2)](http://man7.org/linux/man-pages/man2/renameat.2.html) changes
+ * [renameat(2)](https://man7.org/linux/man-pages/man2/renameat.2.html) changes
* the name or location of a file, interpreting relative paths using an fd.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -172,25 +172,25 @@
#if defined(__USE_GNU)
/**
- * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html)
+ * Flag for [renameat2(2)](https://man7.org/linux/man-pages/man2/renameat2.2.html)
* to fail if the new path already exists.
*/
#define RENAME_NOREPLACE (1<<0)
/**
- * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html)
+ * Flag for [renameat2(2)](https://man7.org/linux/man-pages/man2/renameat2.2.html)
* to atomically exchange the two paths.
*/
#define RENAME_EXCHANGE (1<<1)
/**
- * Flag for [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html)
+ * Flag for [renameat2(2)](https://man7.org/linux/man-pages/man2/renameat2.2.html)
* to create a union/overlay filesystem object.
*/
#define RENAME_WHITEOUT (1<<2)
/**
- * [renameat2(2)](http://man7.org/linux/man-pages/man2/renameat2.2.html) changes
+ * [renameat2(2)](https://man7.org/linux/man-pages/man2/renameat2.2.html) changes
* the name or location of a file, interpreting relative paths using an fd,
* with optional `RENAME_` flags.
*
@@ -201,17 +201,17 @@
#endif
int fseek(FILE* _Nonnull __fp, long __offset, int __whence);
-long ftell(FILE* _Nonnull __fp);
+__wur long ftell(FILE* _Nonnull __fp);
/* See https://android.googlesource.com/platform/bionic/+/main/docs/32-bit-abi.md */
#if defined(__USE_FILE_OFFSET64)
int fgetpos(FILE* _Nonnull __fp, fpos_t* _Nonnull __pos) __RENAME(fgetpos64) __INTRODUCED_IN(24);
int fsetpos(FILE* _Nonnull __fp, const fpos_t* _Nonnull __pos) __RENAME(fsetpos64) __INTRODUCED_IN(24);
int fseeko(FILE* _Nonnull __fp, off_t __offset, int __whence) __RENAME(fseeko64) __INTRODUCED_IN(24);
-off_t ftello(FILE* _Nonnull __fp) __RENAME(ftello64) __INTRODUCED_IN(24);
+__wur off_t ftello(FILE* _Nonnull __fp) __RENAME(ftello64) __INTRODUCED_IN(24);
# if defined(__USE_BSD)
/* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */
-FILE* _Nullable funopen(const void* _Nullable __cookie,
+__wur FILE* _Nullable funopen(const void* _Nullable __cookie,
int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int),
int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int),
fpos_t (* _Nullable __seek_fn)(void* _Nonnull, fpos_t, int),
@@ -221,10 +221,10 @@
int fgetpos(FILE* _Nonnull __fp, fpos_t* _Nonnull __pos);
int fsetpos(FILE* _Nonnull __fp, const fpos_t* _Nonnull __pos);
int fseeko(FILE* _Nonnull __fp, off_t __offset, int __whence);
-off_t ftello(FILE* _Nonnull __fp);
+__wur off_t ftello(FILE* _Nonnull __fp);
# if defined(__USE_BSD)
/* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */
-FILE* _Nullable funopen(const void* _Nullable __cookie,
+__wur FILE* _Nullable funopen(const void* _Nullable __cookie,
int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int),
int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int),
fpos_t (* _Nullable __seek_fn)(void* _Nonnull, fpos_t, int),
@@ -234,22 +234,22 @@
int fgetpos64(FILE* _Nonnull __fp, fpos64_t* _Nonnull __pos) __INTRODUCED_IN(24);
int fsetpos64(FILE* _Nonnull __fp, const fpos64_t* _Nonnull __pos) __INTRODUCED_IN(24);
int fseeko64(FILE* _Nonnull __fp, off64_t __offset, int __whence) __INTRODUCED_IN(24);
-off64_t ftello64(FILE* _Nonnull __fp) __INTRODUCED_IN(24);
+__wur off64_t ftello64(FILE* _Nonnull __fp) __INTRODUCED_IN(24);
#if defined(__USE_BSD)
/* If __read_fn and __write_fn are both nullptr, it will cause EINVAL */
-FILE* _Nullable funopen64(const void* _Nullable __cookie,
+__wur FILE* _Nullable funopen64(const void* _Nullable __cookie,
int (* __BIONIC_COMPLICATED_NULLNESS __read_fn)(void* _Nonnull, char* _Nonnull, int),
int (* __BIONIC_COMPLICATED_NULLNESS __write_fn)(void* _Nonnull, const char* _Nonnull, int),
fpos64_t (* _Nullable __seek_fn)(void* _Nonnull, fpos64_t, int),
int (* _Nullable __close_fn)(void* _Nonnull)) __INTRODUCED_IN(24);
#endif
-FILE* _Nullable fopen(const char* _Nonnull __path, const char* _Nonnull __mode);
-FILE* _Nullable fopen64(const char* _Nonnull __path, const char* _Nonnull __mode) __INTRODUCED_IN(24);
+__wur FILE* _Nullable fopen(const char* _Nonnull __path, const char* _Nonnull __mode);
+__wur FILE* _Nullable fopen64(const char* _Nonnull __path, const char* _Nonnull __mode) __INTRODUCED_IN(24);
FILE* _Nullable freopen(const char* _Nullable __path, const char* _Nonnull __mode, FILE* _Nonnull __fp);
FILE* _Nullable freopen64(const char* _Nullable __path, const char* _Nonnull __mode, FILE* _Nonnull __fp) __INTRODUCED_IN(24);
-FILE* _Nullable tmpfile(void);
-FILE* _Nullable tmpfile64(void) __INTRODUCED_IN(24);
+__wur FILE* _Nullable tmpfile(void);
+__wur FILE* _Nullable tmpfile64(void) __INTRODUCED_IN(24);
int snprintf(char* __BIONIC_COMPLICATED_NULLNESS __buf, size_t __size, const char* _Nonnull __fmt, ...) __printflike(3, 4);
int vfscanf(FILE* _Nonnull __fp, const char* _Nonnull __fmt, va_list __args) __scanflike(2, 0);
@@ -260,20 +260,20 @@
#define L_ctermid 1024 /* size for ctermid() */
char* _Nonnull ctermid(char* _Nullable __buf) __INTRODUCED_IN(26);
-FILE* _Nullable fdopen(int __fd, const char* _Nonnull __mode);
-int fileno(FILE* _Nonnull __fp);
+__wur FILE* _Nullable fdopen(int __fd, const char* _Nonnull __mode);
+__wur int fileno(FILE* _Nonnull __fp);
int pclose(FILE* _Nonnull __fp);
-FILE* _Nullable popen(const char* _Nonnull __command, const char* _Nonnull __mode);
+__wur FILE* _Nullable popen(const char* _Nonnull __command, const char* _Nonnull __mode);
void flockfile(FILE* _Nonnull __fp);
int ftrylockfile(FILE* _Nonnull __fp);
void funlockfile(FILE* _Nonnull __fp);
-int getc_unlocked(FILE* _Nonnull __fp);
-int getchar_unlocked(void);
+__wur int getc_unlocked(FILE* _Nonnull __fp);
+__wur int getchar_unlocked(void);
int putc_unlocked(int __ch, FILE* _Nonnull __fp);
int putchar_unlocked(int __ch);
-FILE* _Nullable fmemopen(void* _Nullable __buf, size_t __size, const char* _Nonnull __mode) __INTRODUCED_IN(23);
-FILE* _Nullable open_memstream(char* _Nonnull * _Nonnull __ptr, size_t* _Nonnull __size_ptr) __INTRODUCED_IN(23);
+__wur FILE* _Nullable fmemopen(void* _Nullable __buf, size_t __size, const char* _Nonnull __mode) __INTRODUCED_IN(23);
+__wur FILE* _Nullable open_memstream(char* _Nonnull * _Nonnull __ptr, size_t* _Nonnull __size_ptr) __INTRODUCED_IN(23);
#if defined(__USE_BSD) || defined(__BIONIC__) /* Historically bionic exposed these. */
int asprintf(char* _Nullable * _Nonnull __s_ptr, const char* _Nonnull __fmt, ...) __printflike(2, 3);
@@ -283,16 +283,16 @@
int setlinebuf(FILE* _Nonnull __fp);
int vasprintf(char* _Nullable * _Nonnull __s_ptr, const char* _Nonnull __fmt, va_list __args) __printflike(2, 0);
void clearerr_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
-int feof_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
-int ferror_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
-int fileno_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(24);
+__wur int feof_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
+__wur int ferror_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
+__wur int fileno_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(24);
#define fropen(cookie, fn) funopen(cookie, fn, 0, 0, 0)
#define fwopen(cookie, fn) funopen(cookie, 0, fn, 0, 0)
#endif
#if defined(__USE_BSD)
int fflush_unlocked(FILE* _Nullable __fp) __INTRODUCED_IN(28);
-int fgetc_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(28);
+__wur int fgetc_unlocked(FILE* _Nonnull __fp) __INTRODUCED_IN(28);
int fputc_unlocked(int __ch, FILE* _Nonnull __fp) __INTRODUCED_IN(28);
size_t fread_unlocked(void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp) __INTRODUCED_IN(28);
size_t fwrite_unlocked(const void* _Nonnull __buf, size_t __size, size_t __count, FILE* _Nonnull __fp) __INTRODUCED_IN(28);
diff --git a/libc/include/stdio_ext.h b/libc/include/stdio_ext.h
index 8b106a6..d426a4a 100644
--- a/libc/include/stdio_ext.h
+++ b/libc/include/stdio_ext.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [__fbufsize(3)](http://man7.org/linux/man-pages/man3/__fbufsize.3.html) returns the size of
+ * [__fbufsize(3)](https://man7.org/linux/man-pages/man3/__fbufsize.3.html) returns the size of
* the stream's buffer.
*
* Available since API level 23.
@@ -47,7 +47,7 @@
size_t __fbufsize(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
/**
- * [__freadable(3)](http://man7.org/linux/man-pages/man3/__freadable.3.html) returns non-zero if
+ * [__freadable(3)](https://man7.org/linux/man-pages/man3/__freadable.3.html) returns non-zero if
* the stream allows reading, 0 otherwise.
*
* Available since API level 23.
@@ -55,7 +55,7 @@
int __freadable(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
/**
- * [__freading(3)](http://man7.org/linux/man-pages/man3/__freading.3.html) returns non-zero if
+ * [__freading(3)](https://man7.org/linux/man-pages/man3/__freading.3.html) returns non-zero if
* the stream's last operation was a read, 0 otherwise.
*
* Available since API level 28.
@@ -63,7 +63,7 @@
int __freading(FILE* _Nonnull __fp) __INTRODUCED_IN(28);
/**
- * [__fwritable(3)](http://man7.org/linux/man-pages/man3/__fwritable.3.html) returns non-zero if
+ * [__fwritable(3)](https://man7.org/linux/man-pages/man3/__fwritable.3.html) returns non-zero if
* the stream allows writing, 0 otherwise.
*
* Available since API level 23.
@@ -71,7 +71,7 @@
int __fwritable(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
/**
- * [__fwriting(3)](http://man7.org/linux/man-pages/man3/__fwriting.3.html) returns non-zero if
+ * [__fwriting(3)](https://man7.org/linux/man-pages/man3/__fwriting.3.html) returns non-zero if
* the stream's last operation was a write, 0 otherwise.
*
* Available since API level 28.
@@ -79,7 +79,7 @@
int __fwriting(FILE* _Nonnull __fp) __INTRODUCED_IN(28);
/**
- * [__flbf(3)](http://man7.org/linux/man-pages/man3/__flbf.3.html) returns non-zero if
+ * [__flbf(3)](https://man7.org/linux/man-pages/man3/__flbf.3.html) returns non-zero if
* the stream is line-buffered, 0 otherwise.
*
* Available since API level 23.
@@ -87,15 +87,13 @@
int __flbf(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
/**
- * [__fpurge(3)](http://man7.org/linux/man-pages/man3/__fpurge.3.html) discards the contents of
+ * [__fpurge(3)](https://man7.org/linux/man-pages/man3/__fpurge.3.html) discards the contents of
* the stream's buffer.
- *
- * Available since API level 23.
*/
-void __fpurge(FILE* _Nonnull __fp) __INTRODUCED_IN(23);
+void __fpurge(FILE* _Nonnull __fp) __RENAME(fpurge);
/**
- * [__fpending(3)](http://man7.org/linux/man-pages/man3/__fpending.3.html) returns the number of
+ * [__fpending(3)](https://man7.org/linux/man-pages/man3/__fpending.3.html) returns the number of
* bytes in the output buffer. See __freadahead() for the input buffer.
*
* Available since API level 23.
@@ -111,7 +109,7 @@
size_t __freadahead(FILE* _Nonnull __fp) __INTRODUCED_IN(34);
/**
- * [_flushlbf(3)](http://man7.org/linux/man-pages/man3/_flushlbf.3.html) flushes all
+ * [_flushlbf(3)](https://man7.org/linux/man-pages/man3/_flushlbf.3.html) flushes all
* line-buffered streams.
*
* Available since API level 23.
@@ -134,7 +132,7 @@
#define FSETLOCKING_BYCALLER 2
/**
- * [__fsetlocking(3)](http://man7.org/linux/man-pages/man3/__fsetlocking.3.html) sets the
+ * [__fsetlocking(3)](https://man7.org/linux/man-pages/man3/__fsetlocking.3.html) sets the
* stream's locking mode to one of the `FSETLOCKING_` types.
*
* Returns the current locking style, `FSETLOCKING_INTERNAL` or `FSETLOCKING_BYCALLER`.
diff --git a/libc/include/stdlib.h b/libc/include/stdlib.h
index 2830a49..b31b122 100644
--- a/libc/include/stdlib.h
+++ b/libc/include/stdlib.h
@@ -57,7 +57,7 @@
int clearenv(void);
char* _Nullable mkdtemp(char* _Nonnull __template);
-char* _Nullable mktemp(char* _Nonnull __template) __attribute__((deprecated("mktemp is unsafe, use mkstemp or tmpfile instead")));
+char* _Nullable mktemp(char* _Nonnull __template) __attribute__((__deprecated__("mktemp is unsafe, use mkstemp or tmpfile instead")));
int mkostemp64(char* _Nonnull __template, int __flags) __INTRODUCED_IN(23);
int mkostemp(char* _Nonnull __template, int __flags) __INTRODUCED_IN(23);
@@ -68,28 +68,23 @@
int mkstemps64(char* _Nonnull __template, int __flags) __INTRODUCED_IN(23);
int mkstemps(char* _Nonnull __template, int __flags);
-long strtol(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
-long long strtoll(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
-unsigned long strtoul(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
-unsigned long long strtoull(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
-
int posix_memalign(void* _Nullable * _Nullable __memptr, size_t __alignment, size_t __size);
-void* _Nullable aligned_alloc(size_t __alignment, size_t __size) __INTRODUCED_IN(28);
-
-double strtod(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
-long double strtold(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
-
-unsigned long strtoul_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __INTRODUCED_IN(26);
-
-int atoi(const char* _Nonnull __s) __attribute_pure__;
-long atol(const char* _Nonnull __s) __attribute_pure__;
-long long atoll(const char* _Nonnull __s) __attribute_pure__;
+/**
+ * [aligned_alloc(3)](https://man7.org/linux/man-pages/man3/aligned_alloc.3.html)
+ * allocates the given number of bytes with the given alignment.
+ *
+ * Returns a pointer to the allocated memory on success and returns a null
+ * pointer and sets `errno` on failure.
+ *
+ * Available since API level 28.
+ */
+__wur void* _Nullable aligned_alloc(size_t __alignment, size_t __size) __INTRODUCED_IN(28);
__wur char* _Nullable realpath(const char* _Nonnull __path, char* _Nullable __resolved);
/**
- * [system(3)](http://man7.org/linux/man-pages/man3/system.3.html) executes
+ * [system(3)](https://man7.org/linux/man-pages/man3/system.3.html) executes
* the given command in a new shell process.
*
* On Android, the special case of `system(NULL)` always returns 1,
@@ -100,14 +95,34 @@
* or permanently (for lack of permission, say).
*
* Returns -1 and sets errno if process creation fails; returns a
- * [waitpid(2)](http://man7.org/linux/man-pages/man2/waitpid.2.html)
+ * [waitpid(2)](https://man7.org/linux/man-pages/man2/waitpid.2.html)
* status otherwise.
*/
int system(const char* _Nonnull __command);
-void* _Nullable bsearch(const void* _Nonnull __key, const void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull __lhs, const void* _Nonnull __rhs));
+/**
+ * [bsearch(3)](https://man7.org/linux/man-pages/man3/bsearch.3.html) searches
+ * a sorted array.
+ *
+ * Returns a pointer to a matching item on success,
+ * or NULL if no matching item is found.
+ */
+__wur void* _Nullable bsearch(const void* _Nonnull __key, const void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nonnull __lhs, const void* _Nonnull __rhs));
-void qsort(void* _Nullable __base, size_t __nmemb, size_t __size, int (* _Nonnull __comparator)(const void* _Nullable __lhs, const void* _Nullable __rhs));
+/**
+ * [qsort(3)](https://man7.org/linux/man-pages/man3/qsort.3.html) sorts an array
+ * of n elements each of the given size, using the given comparator.
+ */
+void qsort(void* _Nullable __array, size_t __n, size_t __size, int (* _Nonnull __comparator)(const void* _Nullable __lhs, const void* _Nullable __rhs));
+
+/**
+ * [qsort_r(3)](https://man7.org/linux/man-pages/man3/qsort_r.3.html) sorts an
+ * array of n elements each of the given size, using the given comparator,
+ * and passing the given context argument to the comparator.
+ *
+ * Available since API level 36.
+ */
+void qsort_r(void* _Nullable __array, size_t __n, size_t __size, int (* _Nonnull __comparator)(const void* _Nullable __lhs, const void* _Nullable __rhs, void* _Nullable __context), void* _Nullable __context) __INTRODUCED_IN(36);
uint32_t arc4random(void);
uint32_t arc4random_uniform(uint32_t __upper_bound);
@@ -160,7 +175,7 @@
lldiv_t lldiv(long long __numerator, long long __denominator) __attribute_const__;
/**
- * [getloadavg(3)](http://man7.org/linux/man-pages/man3/getloadavg.3.html) queries the
+ * [getloadavg(3)](https://man7.org/linux/man-pages/man3/getloadavg.3.html) queries the
* number of runnable processes averaged over time. The Linux kernel supports averages
* over the last 1, 5, and 15 minutes.
*
@@ -172,7 +187,7 @@
const char* _Nullable getprogname(void);
void setprogname(const char* _Nonnull __name);
-int mblen(const char* _Nullable __s, size_t __n) __INTRODUCED_IN_NO_GUARD_FOR_NDK(26);
+int mblen(const char* _Nullable __s, size_t __n) __INTRODUCED_IN(26);
size_t mbstowcs(wchar_t* _Nullable __dst, const char* _Nullable __src, size_t __n);
int mbtowc(wchar_t* _Nullable __wc_ptr, const char* _Nullable __s, size_t __n);
int wctomb(char* _Nullable __dst, wchar_t __wc);
@@ -190,22 +205,134 @@
long labs(long __x) __attribute_const__;
long long llabs(long long __x) __attribute_const__;
-float strtof(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
-double atof(const char* _Nonnull __s) __attribute_pure__;
int rand(void);
void srand(unsigned int __seed);
long random(void);
void srandom(unsigned int __seed);
int grantpt(int __fd);
+/**
+ * [atof(3)](https://man7.org/linux/man-pages/man3/atof.3.html) converts a
+ * string to a double.
+ *
+ * Returns the double; use strtof() or strtod() if you need to detect errors.
+ */
+double atof(const char* _Nonnull __s) __attribute_pure__;
+
+/**
+ * [atoi(3)](https://man7.org/linux/man-pages/man3/atoi.3.html) converts a
+ * string to an int.
+ *
+ * Returns the int or 0 on error; use strtol() if you need to detect errors.
+ */
+int atoi(const char* _Nonnull __s) __attribute_pure__;
+
+/**
+ * [atol(3)](https://man7.org/linux/man-pages/man3/atol.3.html) converts a
+ * string to a long.
+ *
+ * Returns the long or 0 on error; use strtol() if you need to detect errors.
+ */
+long atol(const char* _Nonnull __s) __attribute_pure__;
+
+/**
+ * [atoll(3)](https://man7.org/linux/man-pages/man3/atoll.3.html) converts a
+ * string to a long long.
+ *
+ * Returns the long long or 0 on error; use strtol() if you need to detect errors.
+ */
+long long atoll(const char* _Nonnull __s) __attribute_pure__;
+
+/**
+ * [strtol(3)](https://man7.org/linux/man-pages/man3/strtol.3.html) converts a
+ * string to a long.
+ *
+ * Returns the long.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+long strtol(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+
+/** Equivalent to strtol() on Android. */
+long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int, locale_t _Nonnull __l) __RENAME(strtol);
+
+/**
+ * [strtoll(3)](https://man7.org/linux/man-pages/man3/strtoll.3.html) converts a
+ * string to a long long.
+ *
+ * Returns the long long.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+long long strtoll(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+
+/** Equivalent to strtoll() on Android. */
long long strtoll_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l);
+
+/**
+ * [strtoul(3)](https://man7.org/linux/man-pages/man3/strtoul.3.html) converts a
+ * string to an unsigned long.
+ *
+ * Returns the unsigned long.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+unsigned long strtoul(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+
+/** Equivalent to strtoul() on Android. */
+unsigned long strtoul_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __RENAME(strtoul);
+
+/**
+ * [strtoull(3)](https://man7.org/linux/man-pages/man3/strtoull.3.html) converts a
+ * string to an unsigned long long.
+ *
+ * Returns the unsigned long long.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+unsigned long long strtoull(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base);
+
+/** Equivalent to strtoull() on Android. */
unsigned long long strtoull_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int __base, locale_t _Nonnull __l);
+
+/**
+ * [strtof(3)](https://man7.org/linux/man-pages/man3/strtof.3.html) converts a
+ * string to a float.
+ *
+ * Returns the float.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+float strtof(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
+
+/**
+ * [strtod(3)](https://man7.org/linux/man-pages/man3/strtod.3.html) converts a
+ * string to a double.
+ *
+ * Returns the double.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+double strtod(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
+
+/**
+ * [strtold(3)](https://man7.org/linux/man-pages/man3/strtold.3.html) converts a
+ * string to a long double.
+ *
+ * Returns the long double.
+ * `__end_ptr` is set to the last character in `__s` that was converted.
+ * errno is set to ERANGE if the result overflowed or underflowed.
+ */
+long double strtold(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr);
+
+/** Equivalent to strtold() on Android. */
long double strtold_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l);
#if __ANDROID_API__ >= 26
+/** Equivalent to strtod() on Android. */
double strtod_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) __INTRODUCED_IN(26);
+/** Equivalent to strtof() on Android. */
float strtof_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, locale_t _Nonnull __l) __INTRODUCED_IN(26);
-long strtol_l(const char* _Nonnull __s, char* _Nullable * _Nullable __end_ptr, int, locale_t _Nonnull __l) __INTRODUCED_IN(26);
#else
// Implemented as static inlines before 26.
#endif
diff --git a/libc/include/string.h b/libc/include/string.h
index 47bdd72..7c1c3be 100644
--- a/libc/include/string.h
+++ b/libc/include/string.h
@@ -57,7 +57,7 @@
void* _Nonnull memmove(void* _Nonnull __dst, const void* _Nonnull __src, size_t __n);
/**
- * [memset(3)](http://man7.org/linux/man-pages/man3/memset.3.html) writes the
+ * [memset(3)](https://man7.org/linux/man-pages/man3/memset.3.html) writes the
* bottom 8 bits of the given int to the next `n` bytes of `dst`.
*
* Returns `dst`.
@@ -65,7 +65,7 @@
void* _Nonnull memset(void* _Nonnull __dst, int __ch, size_t __n);
/**
- * [memset_explicit(3)](http://man7.org/linux/man-pages/man3/memset_explicit.3.html)
+ * [memset_explicit(3)](https://man7.org/linux/man-pages/man3/memset_explicit.3.html)
* writes the bottom 8 bits of the given int to the next `n` bytes of `dst`,
* but won't be optimized out by the compiler.
*
@@ -108,8 +108,35 @@
char* _Nullable strtok(char* _Nullable __s, const char* _Nonnull __delimiter);
char* _Nullable strtok_r(char* _Nullable __s, const char* _Nonnull __delimiter, char* _Nonnull * _Nonnull __pos_ptr);
+/**
+ * [strerror(3)](https://man7.org/linux/man-pages/man3/strerror.3.html)
+ * returns a string describing the given errno value.
+ * `strerror(EINVAL)` would return "Invalid argument", for example.
+ *
+ * On Android, unknown errno values return a string such as "Unknown error 666".
+ * These unknown errno value strings live in thread-local storage, and are valid
+ * until the next call of strerror() on the same thread.
+ *
+ * Returns a pointer to a string.
+ */
char* _Nonnull strerror(int __errno_value);
-char* _Nonnull strerror_l(int __errno_value, locale_t _Nonnull __l) __INTRODUCED_IN(23);
+
+/**
+ * Equivalent to strerror() on Android where only C/POSIX locales are available.
+ */
+char* _Nonnull strerror_l(int __errno_value, locale_t _Nonnull __l) __RENAME(strerror);
+
+/**
+ * [strerror_r(3)](https://man7.org/linux/man-pages/man3/strerror_r.3.html)
+ * writes a string describing the given errno value into the given buffer.
+ *
+ * There are two variants of this function, POSIX and GNU.
+ * The GNU variant returns a pointer to the buffer.
+ * The POSIX variant returns 0 on success or an errno value on failure.
+ *
+ * The GNU variant is available since API level 23 if `_GNU_SOURCE` is defined.
+ * The POSIX variant is available otherwise.
+ */
#if defined(__USE_GNU) && __ANDROID_API__ >= 23
char* _Nonnull strerror_r(int __errno_value, char* _Nullable __buf, size_t __n) __RENAME(__gnu_strerror_r) __INTRODUCED_IN(23);
#else /* POSIX */
@@ -117,7 +144,7 @@
#endif
/**
- * [strerrorname_np(3)](http://man7.org/linux/man-pages/man3/strerrordesc_np.3.html)
+ * [strerrorname_np(3)](https://man7.org/linux/man-pages/man3/strerrordesc_np.3.html)
* returns the name of the errno constant corresponding to its argument.
* `strerrorname_np(38)` would return "ENOSYS", because `ENOSYS` is errno 38. This
* is mostly useful for error reporting in cases where a string like "ENOSYS" is
@@ -133,7 +160,7 @@
#endif
/**
- * [strerrordesc_np(3)](http://man7.org/linux/man-pages/man3/strerrordesc_np.3.html)
+ * [strerrordesc_np(3)](https://man7.org/linux/man-pages/man3/strerrordesc_np.3.html)
* is like strerror() but without localization. Since Android's strerror()
* does not localize, this is the same as strerror() on Android.
*
@@ -185,11 +212,10 @@
/* Const-correct overloads. Placed after FORTIFY so we call those functions, if possible. */
#if defined(__cplusplus)
-/*
- * Use two enable_ifs so these overloads don't conflict with + are preferred over libcxx's. This can
- * be reduced to 1 after libcxx recognizes that we have const-correct overloads.
- */
-#define __prefer_this_overload __enable_if(true, "preferred overload") __enable_if(true, "")
+/* libcxx tries to provide these. Suppress that, since libcxx's impl doesn't respect FORTIFY. */
+#define __CORRECT_ISO_CPP_STRING_H_PROTO
+/* Used to make these preferable over regular <string.h> signatures for overload resolution. */
+#define __prefer_this_overload __enable_if(true, "")
extern "C++" {
inline __always_inline
void* _Nullable __bionic_memchr(const void* _Nonnull const s __pass_object_size, int c, size_t n) {
diff --git a/libc/include/strings.h b/libc/include/strings.h
index 6ec3bdf..d203bd2 100644
--- a/libc/include/strings.h
+++ b/libc/include/strings.h
@@ -50,7 +50,7 @@
#include <bits/strcasecmp.h>
#if !defined(__BIONIC_STRINGS_INLINE)
-#define __BIONIC_STRINGS_INLINE static inline
+#define __BIONIC_STRINGS_INLINE static __inline
#endif
#undef ffs
@@ -61,18 +61,18 @@
/** Deprecated. Use memmove() instead. */
#define bcopy(b1, b2, len) __bionic_bcopy((b1), (b2), (len))
-static inline __always_inline void __bionic_bcopy(const void* _Nonnull b1, void* _Nonnull b2, size_t len) {
+static __inline __always_inline void __bionic_bcopy(const void* _Nonnull b1, void* _Nonnull b2, size_t len) {
__builtin_memmove(b2, b1, len);
}
/** Deprecated. Use memset() instead. */
#define bzero(b, len) __bionic_bzero((b), (len))
-static inline __always_inline void __bionic_bzero(void* _Nonnull b, size_t len) {
+static __inline __always_inline void __bionic_bzero(void* _Nonnull b, size_t len) {
__builtin_memset(b, 0, len);
}
/**
- * [ffs(3)](http://man7.org/linux/man-pages/man3/ffs.3.html) finds the
+ * [ffs(3)](https://man7.org/linux/man-pages/man3/ffs.3.html) finds the
* first set bit in `__n`.
*
* Returns 0 if no bit is set, or the index of the lowest set bit (counting
@@ -83,7 +83,7 @@
}
/**
- * [ffsl(3)](http://man7.org/linux/man-pages/man3/ffsl.3.html) finds the
+ * [ffsl(3)](https://man7.org/linux/man-pages/man3/ffsl.3.html) finds the
* first set bit in `__n`.
*
* Returns 0 if no bit is set, or the index of the lowest set bit (counting
@@ -94,7 +94,7 @@
}
/**
- * [ffsll(3)](http://man7.org/linux/man-pages/man3/ffsll.3.html) finds the
+ * [ffsll(3)](https://man7.org/linux/man-pages/man3/ffsll.3.html) finds the
* first set bit in `__n`.
*
* Returns 0 if no bit is set, or the index of the lowest set bit (counting
diff --git a/libc/include/sys/_system_properties.h b/libc/include/sys/_system_properties.h
index 078e857..12cafec 100644
--- a/libc/include/sys/_system_properties.h
+++ b/libc/include/sys/_system_properties.h
@@ -1,150 +1 @@
-/*
- * 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.
- */
-
-#ifndef _INCLUDE_SYS__SYSTEM_PROPERTIES_H
-#define _INCLUDE_SYS__SYSTEM_PROPERTIES_H
-
-#include <sys/cdefs.h>
-#include <stdint.h>
-
-#ifndef _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#error you should #include <sys/system_properties.h> instead
-#endif
-
#include <sys/system_properties.h>
-
-__BEGIN_DECLS
-
-#define PROP_SERVICE_NAME "property_service"
-#define PROP_SERVICE_FOR_SYSTEM_NAME "property_service_for_system"
-#define PROP_DIRNAME "/dev/__properties__"
-
-#define PROP_MSG_SETPROP 1
-#define PROP_MSG_SETPROP2 0x00020001
-
-#define PROP_SUCCESS 0
-#define PROP_ERROR_READ_CMD 0x0004
-#define PROP_ERROR_READ_DATA 0x0008
-#define PROP_ERROR_READ_ONLY_PROPERTY 0x000B
-#define PROP_ERROR_INVALID_NAME 0x0010
-#define PROP_ERROR_INVALID_VALUE 0x0014
-#define PROP_ERROR_PERMISSION_DENIED 0x0018
-#define PROP_ERROR_INVALID_CMD 0x001B
-#define PROP_ERROR_HANDLE_CONTROL_MESSAGE 0x0020
-#define PROP_ERROR_SET_FAILED 0x0024
-
-/*
-** This was previously for testing, but now that SystemProperties is its own testable class,
-** there is never a reason to call this function and its implementation simply returns -1.
-*/
-int __system_property_set_filename(const char* __unused __filename);
-
-/*
-** Initialize the area to be used to store properties. Can
-** only be done by a single process that has write access to
-** the property area.
-*/
-int __system_property_area_init(void);
-
-/* Read the global serial number of the system properties
-**
-** Called to predict if a series of cached __system_property_find
-** objects will have seen __system_property_serial values change.
-** But also aids the converse, as changes in the global serial can
-** also be used to predict if a failed __system_property_find
-** could in-turn now find a new object; thus preventing the
-** cycles of effort to poll __system_property_find.
-**
-** Typically called at beginning of a cache cycle to signal if _any_ possible
-** changes have occurred since last. If there is, one may check each individual
-** __system_property_serial to confirm dirty, or __system_property_find
-** to check if the property now exists. If a call to __system_property_add
-** or __system_property_update has completed between two calls to
-** __system_property_area_serial then the second call will return a larger
-** value than the first call. Beware of race conditions as changes to the
-** properties are not atomic, the main value of this call is to determine
-** whether the expensive __system_property_find is worth retrying to see if
-** a property now exists.
-**
-** Returns the serial number on success, -1 on error.
-*/
-uint32_t __system_property_area_serial(void);
-
-/* Add a new system property. Can only be done by a single
-** process that has write access to the property area, and
-** that process must handle sequencing to ensure the property
-** does not already exist and that only one property is added
-** or updated at a time.
-**
-** Returns 0 on success, -1 if the property area is full.
-*/
-int __system_property_add(const char* _Nonnull __name, unsigned int __name_length, const char* _Nonnull __value, unsigned int __value_length);
-
-/* Update the value of a system property returned by
-** __system_property_find. Can only be done by a single process
-** that has write access to the property area, and that process
-** must handle sequencing to ensure that only one property is
-** updated at a time.
-**
-** Returns 0 on success, -1 if the parameters are incorrect.
-*/
-int __system_property_update(prop_info* _Nonnull __pi, const char* _Nonnull __value, unsigned int __value_length);
-
-/* Read the serial number of a system property returned by
-** __system_property_find.
-**
-** Returns the serial number on success, -1 on error.
-*/
-uint32_t __system_property_serial(const prop_info* _Nonnull __pi);
-
-/* Initialize the system properties area in read only mode.
- * Should be done by all processes that need to read system
- * properties.
- *
- * Returns 0 on success, -1 otherwise.
- */
-int __system_properties_init(void);
-
-/*
- * Reloads the system properties from disk.
- * Not intended for use by any apps except the Zygote. Should only be called from the main thread.
- *
- * NOTE: Any pointers received from methods such as __system_property_find should be assumed to be
- * invalid after this method is called.
- *
- * Returns 0 on success, -1 if the system properties failed to re-initialize (same conditions as
- * __system properties_init)
- */
-int __system_properties_zygote_reload(void) __INTRODUCED_IN(__ANDROID_API_V__);
-
-/* Deprecated: use __system_property_wait instead. */
-uint32_t __system_property_wait_any(uint32_t __old_serial);
-
-__END_DECLS
-
-#endif
diff --git a/libc/include/sys/auxv.h b/libc/include/sys/auxv.h
index b664e2a..732f944 100644
--- a/libc/include/sys/auxv.h
+++ b/libc/include/sys/auxv.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [getauxval(3)](http://man7.org/linux/man-pages/man3/getauxval.3.html) returns values from
+ * [getauxval(3)](https://man7.org/linux/man-pages/man3/getauxval.3.html) returns values from
* the ELF auxiliary vector passed by the kernel.
*
* Returns the corresponding value on success,
diff --git a/libc/include/sys/capability.h b/libc/include/sys/capability.h
index b43bbf0..3d1d896 100644
--- a/libc/include/sys/capability.h
+++ b/libc/include/sys/capability.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [capget(2)](http://man7.org/linux/man-pages/man2/capget.2.html) gets the calling
+ * [capget(2)](https://man7.org/linux/man-pages/man2/capget.2.html) gets the calling
* thread's capabilities.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -47,7 +47,7 @@
int capget(cap_user_header_t _Nonnull __hdr_ptr, cap_user_data_t _Nullable __data_ptr);
/**
- * [capset(2)](http://man7.org/linux/man-pages/man2/capset.2.html) sets the calling
+ * [capset(2)](https://man7.org/linux/man-pages/man2/capset.2.html) sets the calling
* thread's capabilities.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/cdefs.h b/libc/include/sys/cdefs.h
index e587fe7..5d1718e 100644
--- a/libc/include/sys/cdefs.h
+++ b/libc/include/sys/cdefs.h
@@ -87,9 +87,12 @@
#define __STRING(x) #x
#define ___STRING(x) __STRING(x)
-#if defined(__cplusplus)
-#define __inline inline /* convert to C++ keyword */
-#endif /* !__cplusplus */
+// C++ has `inline` as a keyword, as does C99, but ANSI C (aka C89 aka C90)
+// does not. Everything accepts the `__inline__` extension though. We could
+// just use that directly in our own code, but there's historical precedent
+// for `__inline` meaning it's still used in upstream BSD code (and potentially
+// downstream in vendor or app code).
+#define __inline __inline__
#define __always_inline __attribute__((__always_inline__))
#define __attribute_const__ __attribute__((__const__))
@@ -139,12 +142,12 @@
#define __wur __attribute__((__warn_unused_result__))
-#define __errorattr(msg) __attribute__((unavailable(msg)))
-#define __warnattr(msg) __attribute__((deprecated(msg)))
-#define __warnattr_real(msg) __attribute__((deprecated(msg)))
-#define __enable_if(cond, msg) __attribute__((enable_if(cond, msg)))
-#define __clang_error_if(cond, msg) __attribute__((diagnose_if(cond, msg, "error")))
-#define __clang_warning_if(cond, msg) __attribute__((diagnose_if(cond, msg, "warning")))
+#define __errorattr(msg) __attribute__((__unavailable__(msg)))
+#define __warnattr(msg) __attribute__((__deprecated__(msg)))
+#define __warnattr_real(msg) __attribute__((__deprecated__(msg)))
+#define __enable_if(cond, msg) __attribute__((__enable_if__(cond, msg)))
+#define __clang_error_if(cond, msg) __attribute__((__diagnose_if__(cond, msg, "error")))
+#define __clang_warning_if(cond, msg) __attribute__((__diagnose_if__(cond, msg, "warning")))
#if defined(ANDROID_STRICT)
/*
@@ -248,7 +251,7 @@
#if defined(__BIONIC_FORTIFY)
# define __bos0(s) __bosn((s), 0)
-# define __pass_object_size_n(n) __attribute__((pass_object_size(n)))
+# define __pass_object_size_n(n) __attribute__((__pass_object_size__(n)))
/*
* FORTIFY'ed functions all have either enable_if or pass_object_size, which
* makes taking their address impossible. Saying (&read)(foo, bar, baz); will
@@ -260,7 +263,7 @@
* them available externally. FORTIFY'ed functions try to be as close to possible as 'invisible';
* having stack protectors detracts from that (b/182948263).
*/
-# define __BIONIC_FORTIFY_INLINE static inline __attribute__((no_stack_protector)) \
+# define __BIONIC_FORTIFY_INLINE static __inline __attribute__((__no_stack_protector__)) \
__always_inline __VERSIONER_FORTIFY_INLINE
/*
* We should use __BIONIC_FORTIFY_VARIADIC instead of __BIONIC_FORTIFY_INLINE
@@ -268,9 +271,9 @@
* The __always_inline attribute is useless, misleading, and could trigger
* clang compiler bug to incorrectly inline variadic functions.
*/
-# define __BIONIC_FORTIFY_VARIADIC static inline
+# define __BIONIC_FORTIFY_VARIADIC static __inline
/* Error functions don't have bodies, so they can just be static. */
-# define __BIONIC_ERROR_FUNCTION_VISIBILITY static __attribute__((unused))
+# define __BIONIC_ERROR_FUNCTION_VISIBILITY static __unused
#else
/* Further increase sharing for some inline functions */
# define __pass_object_size_n(n)
@@ -300,21 +303,21 @@
# define __BIONIC_INCLUDE_FORTIFY_HEADERS 1
#endif
-#define __overloadable __attribute__((overloadable))
+#define __overloadable __attribute__((__overloadable__))
-#define __diagnose_as_builtin(...) __attribute__((diagnose_as_builtin(__VA_ARGS__)))
+#define __diagnose_as_builtin(...) __attribute__((__diagnose_as_builtin__(__VA_ARGS__)))
/* Used to tag non-static symbols that are private and never exposed by the shared library. */
-#define __LIBC_HIDDEN__ __attribute__((visibility("hidden")))
+#define __LIBC_HIDDEN__ __attribute__((__visibility__("hidden")))
/*
* Used to tag symbols that should be hidden for 64-bit,
* but visible to preserve binary compatibility for LP32.
*/
#ifdef __LP64__
-#define __LIBC32_LEGACY_PUBLIC__ __attribute__((visibility("hidden")))
+#define __LIBC32_LEGACY_PUBLIC__ __attribute__((__visibility__("hidden")))
#else
-#define __LIBC32_LEGACY_PUBLIC__ __attribute__((visibility("default")))
+#define __LIBC32_LEGACY_PUBLIC__ __attribute__((__visibility__("default")))
#endif
/* Used to rename functions so that the compiler emits a call to 'x' rather than the function this was applied to. */
diff --git a/libc/include/sys/epoll.h b/libc/include/sys/epoll.h
index 2bad655..a5e3c14 100644
--- a/libc/include/sys/epoll.h
+++ b/libc/include/sys/epoll.h
@@ -42,8 +42,8 @@
__BEGIN_DECLS
/**
- * [epoll_create(2)](http://man7.org/linux/man-pages/man2/epoll_create.2.html)
- * creates a new [epoll](http://man7.org/linux/man-pages/man7/epoll.7.html)
+ * [epoll_create(2)](https://man7.org/linux/man-pages/man2/epoll_create.2.html)
+ * creates a new [epoll](https://man7.org/linux/man-pages/man7/epoll.7.html)
* file descriptor.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
@@ -52,8 +52,8 @@
int epoll_create(int __size);
/**
- * [epoll_create1(2)](http://man7.org/linux/man-pages/man2/epoll_create1.2.html)
- * creates a new [epoll](http://man7.org/linux/man-pages/man7/epoll.7.html)
+ * [epoll_create1(2)](https://man7.org/linux/man-pages/man2/epoll_create1.2.html)
+ * creates a new [epoll](https://man7.org/linux/man-pages/man7/epoll.7.html)
* file descriptor with the given flags.
*
* Returns a new file descriptor on success and returns -1 and sets `errno` on
@@ -62,7 +62,7 @@
int epoll_create1(int __flags);
/**
- * [epoll_ctl(2)](http://man7.org/linux/man-pages/man2/epoll_ctl.2.html)
+ * [epoll_ctl(2)](https://man7.org/linux/man-pages/man2/epoll_ctl.2.html)
* adds/modifies/removes file descriptors from the given epoll file descriptor.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -70,7 +70,7 @@
int epoll_ctl(int __epoll_fd, int __op, int __fd, struct epoll_event* __BIONIC_COMPLICATED_NULLNESS __event);
/**
- * [epoll_wait(2)](http://man7.org/linux/man-pages/man2/epoll_wait.2.html)
+ * [epoll_wait(2)](https://man7.org/linux/man-pages/man2/epoll_wait.2.html)
* waits for an event on the given epoll file descriptor.
*
* Returns the number of ready file descriptors on success, 0 on timeout,
diff --git a/libc/include/sys/eventfd.h b/libc/include/sys/eventfd.h
index 1ad11e3..3000737 100644
--- a/libc/include/sys/eventfd.h
+++ b/libc/include/sys/eventfd.h
@@ -35,18 +35,22 @@
#include <sys/cdefs.h>
#include <fcntl.h>
+#include <linux/eventfd.h>
__BEGIN_DECLS
-/** The eventfd() flag to provide semaphore-like semantics for reads. */
-#define EFD_SEMAPHORE (1 << 0)
-/** The eventfd() flag for a close-on-exec file descriptor. */
-#define EFD_CLOEXEC O_CLOEXEC
-/** The eventfd() flag for a non-blocking file descriptor. */
-#define EFD_NONBLOCK O_NONBLOCK
+/*! \macro EFD_SEMAPHORE
+ * The eventfd() flag to provide semaphore-like semantics for reads.
+ */
+/*! \macro EFD_CLOEXEC
+ * The eventfd() flag for a close-on-exec file descriptor.
+ */
+/*! \macro EFD_NONBLOCK
+ * The eventfd() flag for a non-blocking file descriptor.
+ */
/**
- * [eventfd(2)](http://man7.org/linux/man-pages/man2/eventfd.2.html) creates a file descriptor
+ * [eventfd(2)](https://man7.org/linux/man-pages/man2/eventfd.2.html) creates a file descriptor
* for event notification.
*
* Returns a new file descriptor on success, and returns -1 and sets `errno` on failure.
@@ -57,7 +61,7 @@
typedef uint64_t eventfd_t;
/**
- * [eventfd_read(3)](http://man7.org/linux/man-pages/man2/eventfd.2.html) is a convenience
+ * [eventfd_read(3)](https://man7.org/linux/man-pages/man2/eventfd.2.html) is a convenience
* wrapper to read an `eventfd_t` from an eventfd file descriptor.
*
* Returns 0 on success, or returns -1 otherwise.
@@ -65,7 +69,7 @@
int eventfd_read(int __fd, eventfd_t* _Nonnull __value);
/**
- * [eventfd_write(3)](http://man7.org/linux/man-pages/man2/eventfd.2.html) is a convenience
+ * [eventfd_write(3)](https://man7.org/linux/man-pages/man2/eventfd.2.html) is a convenience
* wrapper to write an `eventfd_t` to an eventfd file descriptor.
*
* Returns 0 on success, or returns -1 otherwise.
diff --git a/libc/include/sys/file.h b/libc/include/sys/file.h
index ccdfeea..45117fa 100644
--- a/libc/include/sys/file.h
+++ b/libc/include/sys/file.h
@@ -41,7 +41,7 @@
__BEGIN_DECLS
/**
- * [flock(2)](http://man7.org/linux/man-pages/man2/flock.2.html) performs
+ * [flock(2)](https://man7.org/linux/man-pages/man2/flock.2.html) performs
* advisory file lock operations.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/fsuid.h b/libc/include/sys/fsuid.h
index 273749f..eeb5783 100644
--- a/libc/include/sys/fsuid.h
+++ b/libc/include/sys/fsuid.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [setfsuid(2)](http://man7.org/linux/man-pages/man2/setfsuid.2.html) sets the UID used for
+ * [setfsuid(2)](https://man7.org/linux/man-pages/man2/setfsuid.2.html) sets the UID used for
* filesystem checks.
*
* Returns the previous UID.
@@ -47,7 +47,7 @@
int setfsuid(uid_t __uid);
/**
- * [setfsgid(2)](http://man7.org/linux/man-pages/man2/setfsgid.2.html) sets the GID used for
+ * [setfsgid(2)](https://man7.org/linux/man-pages/man2/setfsgid.2.html) sets the GID used for
* filesystem checks.
*
* Returns the previous GID.
diff --git a/libc/include/sys/inotify.h b/libc/include/sys/inotify.h
index f070857..75ed542 100644
--- a/libc/include/sys/inotify.h
+++ b/libc/include/sys/inotify.h
@@ -33,13 +33,9 @@
#include <sys/types.h>
#include <stdint.h>
#include <linux/inotify.h>
-#include <asm/fcntl.h> /* For O_CLOEXEC and O_NONBLOCK. */
__BEGIN_DECLS
-#define IN_CLOEXEC O_CLOEXEC
-#define IN_NONBLOCK O_NONBLOCK
-
int inotify_init(void);
int inotify_init1(int __flags);
int inotify_add_watch(int __fd, const char* _Nonnull __path, uint32_t __mask);
diff --git a/libc/include/sys/io.h b/libc/include/sys/io.h
new file mode 100644
index 0000000..11f3f3a
--- /dev/null
+++ b/libc/include/sys/io.h
@@ -0,0 +1,75 @@
+/*
+ * Copyright (C) 2024 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 sys/io.h
+ * @brief The x86/x86-64 I/O port functions iopl() and ioperm().
+ */
+
+#include <sys/cdefs.h>
+
+#include <errno.h>
+#include <sys/syscall.h>
+#include <unistd.h>
+
+__BEGIN_DECLS
+
+/**
+ * [iopl(2)](https://man7.org/linux/man-pages/man2/iopl.2.html) changes the I/O
+ * privilege level for all x86/x8-64 I/O ports, for the calling thread.
+ *
+ * New callers should use ioperm() instead.
+ *
+ * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ *
+ * Only available for x86/x86-64.
+ */
+#if defined(__NR_iopl)
+__attribute__((__deprecated__("use ioperm() instead"))) static __inline int iopl(int __level) {
+ return syscall(__NR_iopl, __level);
+}
+#endif
+
+/**
+ * [ioperm(2)](https://man7.org/linux/man-pages/man2/ioperm.2.html) sets the I/O
+ * permissions for the given number of x86/x86-64 I/O ports, starting at the
+ * given port.
+ *
+ * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ *
+ * Only available for x86/x86-64.
+ */
+#if defined(__NR_iopl)
+static __inline int ioperm(unsigned long __from, unsigned long __n, int __enabled) {
+ return syscall(__NR_ioperm, __from, __n, __enabled);
+}
+#endif
+
+__END_DECLS
diff --git a/libc/include/sys/ipc.h b/libc/include/sys/ipc.h
index 2e2b8cf..f557ce5 100644
--- a/libc/include/sys/ipc.h
+++ b/libc/include/sys/ipc.h
@@ -47,7 +47,7 @@
__BEGIN_DECLS
/**
- * [ftok(3)](http://man7.org/linux/man-pages/man3/ftok.3.html) converts a path and id to a
+ * [ftok(3)](https://man7.org/linux/man-pages/man3/ftok.3.html) converts a path and id to a
* System V IPC key.
*
* Returns a key on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/klog.h b/libc/include/sys/klog.h
index b60c2c4..237d2e2 100644
--- a/libc/include/sys/klog.h
+++ b/libc/include/sys/klog.h
@@ -61,7 +61,7 @@
#define KLOG_SIZE_BUFFER 10
/**
- * [klogctl(2)](http://man7.org/linux/man-pages/man2/syslog.2.html) operates on the kernel log.
+ * [klogctl(2)](https://man7.org/linux/man-pages/man2/syslog.2.html) operates on the kernel log.
*
* This system call is not available to applications.
* Use syslog() or `<android/log.h>` instead.
diff --git a/libc/include/sys/mman.h b/libc/include/sys/mman.h
index 823c9ba..1a0e7f6 100644
--- a/libc/include/sys/mman.h
+++ b/libc/include/sys/mman.h
@@ -43,7 +43,7 @@
#define MAP_FAILED __BIONIC_CAST(reinterpret_cast, void*, -1)
/**
- * [mmap(2)](http://man7.org/linux/man-pages/man2/mmap.2.html)
+ * [mmap(2)](https://man7.org/linux/man-pages/man2/mmap.2.html)
* creates a memory mapping for the given range.
*
* Returns the address of the mapping on success,
@@ -63,7 +63,7 @@
void* _Nonnull mmap64(void* _Nullable __addr, size_t __size, int __prot, int __flags, int __fd, off64_t __offset);
/**
- * [munmap(2)](http://man7.org/linux/man-pages/man2/munmap.2.html)
+ * [munmap(2)](https://man7.org/linux/man-pages/man2/munmap.2.html)
* deletes a memory mapping for the given range.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -71,7 +71,7 @@
int munmap(void* _Nonnull __addr, size_t __size);
/**
- * [msync(2)](http://man7.org/linux/man-pages/man2/msync.2.html)
+ * [msync(2)](https://man7.org/linux/man-pages/man2/msync.2.html)
* flushes changes to a memory-mapped file to disk.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -79,7 +79,7 @@
int msync(void* _Nonnull __addr, size_t __size, int __flags);
/**
- * [mprotect(2)](http://man7.org/linux/man-pages/man2/mprotect.2.html)
+ * [mprotect(2)](https://man7.org/linux/man-pages/man2/mprotect.2.html)
* sets the protection on a memory region.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -93,7 +93,7 @@
#define MREMAP_FIXED 2
/**
- * [mremap(2)](http://man7.org/linux/man-pages/man2/mremap.2.html)
+ * [mremap(2)](https://man7.org/linux/man-pages/man2/mremap.2.html)
* expands or shrinks an existing memory mapping.
*
* Returns the address of the mapping on success,
@@ -102,7 +102,7 @@
void* _Nonnull mremap(void* _Nonnull __old_addr, size_t __old_size, size_t __new_size, int __flags, ...);
/**
- * [mlockall(2)](http://man7.org/linux/man-pages/man2/mlockall.2.html)
+ * [mlockall(2)](https://man7.org/linux/man-pages/man2/mlockall.2.html)
* locks pages (preventing swapping).
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -110,7 +110,7 @@
int mlockall(int __flags);
/**
- * [munlockall(2)](http://man7.org/linux/man-pages/man2/munlockall.2.html)
+ * [munlockall(2)](https://man7.org/linux/man-pages/man2/munlockall.2.html)
* unlocks pages (allowing swapping).
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -118,7 +118,7 @@
int munlockall(void);
/**
- * [mlock(2)](http://man7.org/linux/man-pages/man2/mlock.2.html)
+ * [mlock(2)](https://man7.org/linux/man-pages/man2/mlock.2.html)
* locks pages (preventing swapping).
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -126,7 +126,7 @@
int mlock(const void* _Nonnull __addr, size_t __size);
/**
- * [mlock2(2)](http://man7.org/linux/man-pages/man2/mlock.2.html)
+ * [mlock2(2)](https://man7.org/linux/man-pages/man2/mlock.2.html)
* locks pages (preventing swapping), with optional flags.
*
* Available since API level 30.
@@ -136,7 +136,7 @@
int mlock2(const void* _Nonnull __addr, size_t __size, int __flags) __INTRODUCED_IN(30);
/**
- * [munlock(2)](http://man7.org/linux/man-pages/man2/munlock.2.html)
+ * [munlock(2)](https://man7.org/linux/man-pages/man2/munlock.2.html)
* unlocks pages (allowing swapping).
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -144,7 +144,7 @@
int munlock(const void* _Nonnull __addr, size_t __size);
/**
- * [mincore(2)](http://man7.org/linux/man-pages/man2/mincore.2.html)
+ * [mincore(2)](https://man7.org/linux/man-pages/man2/mincore.2.html)
* tests whether pages are resident in memory.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -152,7 +152,7 @@
int mincore(void* _Nonnull __addr, size_t __size, unsigned char* _Nonnull __vector);
/**
- * [madvise(2)](http://man7.org/linux/man-pages/man2/madvise.2.html)
+ * [madvise(2)](https://man7.org/linux/man-pages/man2/madvise.2.html)
* gives the kernel advice about future usage patterns.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -160,7 +160,7 @@
int madvise(void* _Nonnull __addr, size_t __size, int __advice);
/**
- * [process_madvise(2)](http://man7.org/linux/man-pages/man2/process_madvise.2.html)
+ * [process_madvise(2)](https://man7.org/linux/man-pages/man2/process_madvise.2.html)
* works just like madvise(2) but applies to the process specified by the given
* PID file descriptor.
*
@@ -176,7 +176,7 @@
#if defined(__USE_GNU)
/**
- * [memfd_create(2)](http://man7.org/linux/man-pages/man2/memfd_create.2.html)
+ * [memfd_create(2)](https://man7.org/linux/man-pages/man2/memfd_create.2.html)
* creates an anonymous file.
*
* Available since API level 30.
@@ -212,7 +212,7 @@
#endif
/**
- * [posix_madvise(3)](http://man7.org/linux/man-pages/man3/posix_madvise.3.html)
+ * [posix_madvise(3)](https://man7.org/linux/man-pages/man3/posix_madvise.3.html)
* gives the kernel advice about future usage patterns.
*
* Available since API level 23.
@@ -222,4 +222,16 @@
*/
int posix_madvise(void* _Nonnull __addr, size_t __size, int __advice) __INTRODUCED_IN(23);
+/**
+ * [mseal(2)](https://man7.org/linux/man-pages/man2/mseal.2.html)
+ * seals the given range to prevent modifications such as mprotect() calls.
+ *
+ * Available since API level 36.
+ * Requires a Linux 6.10 or newer kernel.
+ * Always fails for 32-bit processes.
+ *
+ * Returns 0 on success, and returns -1 and sets `errno` on failure.
+ */
+int mseal(void* _Nonnull __addr, size_t __size, unsigned long __flags) __INTRODUCED_IN(36);
+
__END_DECLS
diff --git a/libc/include/sys/mount.h b/libc/include/sys/mount.h
index aace205..0880c98 100644
--- a/libc/include/sys/mount.h
+++ b/libc/include/sys/mount.h
@@ -50,7 +50,7 @@
#define UMOUNT_NOFOLLOW 8
/**
- * [mount(2)](http://man7.org/linux/man-pages/man2/mount.2.html) mounts the filesystem `source` at
+ * [mount(2)](https://man7.org/linux/man-pages/man2/mount.2.html) mounts the filesystem `source` at
* the mount point `target`.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -58,7 +58,7 @@
int mount(const char* __BIONIC_COMPLICATED_NULLNESS __source, const char* _Nonnull __target, const char* __BIONIC_COMPLICATED_NULLNESS __fs_type, unsigned long __flags, const void* _Nullable __data);
/**
- * [umount(2)](http://man7.org/linux/man-pages/man2/umount.2.html) unmounts the filesystem at
+ * [umount(2)](https://man7.org/linux/man-pages/man2/umount.2.html) unmounts the filesystem at
* the given mount point.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -66,7 +66,7 @@
int umount(const char* _Nonnull __target);
/**
- * [umount2(2)](http://man7.org/linux/man-pages/man2/umount2.2.html) unmounts the filesystem at
+ * [umount2(2)](https://man7.org/linux/man-pages/man2/umount2.2.html) unmounts the filesystem at
* the given mount point, according to the supplied flags.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/personality.h b/libc/include/sys/personality.h
index 9eb992f..34d1a1a 100644
--- a/libc/include/sys/personality.h
+++ b/libc/include/sys/personality.h
@@ -39,7 +39,7 @@
__BEGIN_DECLS
/**
- * [personality(2)](http://man7.org/linux/man-pages/man2/personality.2.html) sets the calling
+ * [personality(2)](https://man7.org/linux/man-pages/man2/personality.2.html) sets the calling
* process' personality.
*
* Returns the previous persona on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/prctl.h b/libc/include/sys/prctl.h
index 1c80415..4e0b4b5 100644
--- a/libc/include/sys/prctl.h
+++ b/libc/include/sys/prctl.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [prctl(2)](http://man7.org/linux/man-pages/man2/prctl.2.html) performs a variety of
+ * [prctl(2)](https://man7.org/linux/man-pages/man2/prctl.2.html) performs a variety of
* operations based on the `PR_` constant passed as the first argument.
*
* Returns -1 and sets `errno` on failure; success values vary by option.
diff --git a/libc/include/sys/quota.h b/libc/include/sys/quota.h
index 37f8925..6e32705 100644
--- a/libc/include/sys/quota.h
+++ b/libc/include/sys/quota.h
@@ -45,7 +45,7 @@
__BEGIN_DECLS
/**
- * [quotactl(2)](http://man7.org/linux/man-pages/man2/quotactl.2.html) manipulates disk quotas.
+ * [quotactl(2)](https://man7.org/linux/man-pages/man2/quotactl.2.html) manipulates disk quotas.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*
diff --git a/libc/include/sys/random.h b/libc/include/sys/random.h
index 2ff5349..6aba1fc 100644
--- a/libc/include/sys/random.h
+++ b/libc/include/sys/random.h
@@ -43,7 +43,7 @@
__BEGIN_DECLS
/**
- * [getrandom(2)](http://man7.org/linux/man-pages/man2/getrandom.2.html) fills the given buffer
+ * [getrandom(2)](https://man7.org/linux/man-pages/man2/getrandom.2.html) fills the given buffer
* with random bytes.
*
* Returns the number of bytes copied on success, and returns -1 and sets `errno` on failure.
@@ -52,6 +52,6 @@
*
* See also arc4random_buf() which is available in all API levels.
*/
-ssize_t getrandom(void* _Nonnull __buffer, size_t __buffer_size, unsigned int __flags) __wur __INTRODUCED_IN(28);
+__wur ssize_t getrandom(void* _Nonnull __buffer, size_t __buffer_size, unsigned int __flags) __INTRODUCED_IN(28);
__END_DECLS
diff --git a/libc/include/sys/reboot.h b/libc/include/sys/reboot.h
index 5d9e1a7..f4bc861 100644
--- a/libc/include/sys/reboot.h
+++ b/libc/include/sys/reboot.h
@@ -50,7 +50,7 @@
#define RB_POWER_OFF LINUX_REBOOT_CMD_POWER_OFF
/**
- * [reboot(2)](http://man7.org/linux/man-pages/man2/reboot.2.html) reboots the device.
+ * [reboot(2)](https://man7.org/linux/man-pages/man2/reboot.2.html) reboots the device.
*
* Does not return on successful reboot, returns 0 if CAD was successfully enabled/disabled,
* and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/select.h b/libc/include/sys/select.h
index 84c2621..d5b3495 100644
--- a/libc/include/sys/select.h
+++ b/libc/include/sys/select.h
@@ -44,7 +44,7 @@
typedef unsigned long fd_mask;
/**
- * The limit on the largest fd that can be used with this API.
+ * The limit on the largest fd that can be used with fd_set.
* Use <poll.h> instead.
*/
#define FD_SETSIZE 1024
@@ -52,6 +52,9 @@
/**
* The type of a file descriptor set. Limited to 1024 fds.
+ * The underlying system calls do not have this limit,
+ * and callers can allocate their own sets with calloc().
+ *
* Use <poll.h> instead.
*/
typedef struct {
@@ -60,34 +63,31 @@
#define __FDELT(fd) ((fd) / NFDBITS)
#define __FDMASK(fd) (1UL << ((fd) % NFDBITS))
-#define __FDS_BITS(type,set) (__BIONIC_CAST(static_cast, type, set)->fds_bits)
-
-/* Inline loop so we don't have to declare memset. */
-#define FD_ZERO(set) \
- do { \
- size_t __i; \
- for (__i = 0; __i < sizeof(fd_set)/sizeof(fd_mask); ++__i) { \
- (set)->fds_bits[__i] = 0; \
- } \
- } while (0)
+#define __FDS_BITS(type, set) (__BIONIC_CAST(static_cast, type, set)->fds_bits)
void __FD_CLR_chk(int, fd_set* _Nonnull , size_t);
void __FD_SET_chk(int, fd_set* _Nonnull, size_t);
int __FD_ISSET_chk(int, const fd_set* _Nonnull, size_t);
-#define __FD_CLR(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] &= ~__FDMASK(fd))
-#define __FD_SET(fd, set) (__FDS_BITS(fd_set*,set)[__FDELT(fd)] |= __FDMASK(fd))
-#define __FD_ISSET(fd, set) ((__FDS_BITS(const fd_set*,set)[__FDELT(fd)] & __FDMASK(fd)) != 0)
+/** FD_CLR() with no bounds checking for users that allocated their own set. */
+#define __FD_CLR(fd, set) (__FDS_BITS(fd_set*, set)[__FDELT(fd)] &= ~__FDMASK(fd))
+/** FD_SET() with no bounds checking for users that allocated their own set. */
+#define __FD_SET(fd, set) (__FDS_BITS(fd_set*, set)[__FDELT(fd)] |= __FDMASK(fd))
+/** FD_ISSET() with no bounds checking for users that allocated their own set. */
+#define __FD_ISSET(fd, set) ((__FDS_BITS(const fd_set*, set)[__FDELT(fd)] & __FDMASK(fd)) != 0)
-/** Removes `fd` from the given set. Use <poll.h> instead. */
+/** Removes all 1024 fds from the given set. Use <poll.h> instead. */
+#define FD_ZERO(set) __builtin_memset(set, 0, sizeof(*__BIONIC_CAST(static_cast, const fd_set*, set)))
+
+/** Removes `fd` from the given set. Limited to fds under 1024. Use <poll.h> instead. */
#define FD_CLR(fd, set) __FD_CLR_chk(fd, set, __bos(set))
-/** Adds `fd` to the given set. Use <poll.h> instead. */
+/** Adds `fd` to the given set. Limited to fds under 1024. Use <poll.h> instead. */
#define FD_SET(fd, set) __FD_SET_chk(fd, set, __bos(set))
-/** Tests whether `fd` is in the given set. Use <poll.h> instead. */
+/** Tests whether `fd` is in the given set. Limited to fds under 1024. Use <poll.h> instead. */
#define FD_ISSET(fd, set) __FD_ISSET_chk(fd, set, __bos(set))
/**
- * [select(2)](http://man7.org/linux/man-pages/man2/select.2.html) waits on a
+ * [select(2)](https://man7.org/linux/man-pages/man2/select.2.html) waits on a
* set of file descriptors.
*
* Use poll() instead.
@@ -98,7 +98,7 @@
int select(int __max_fd_plus_one, fd_set* _Nullable __read_fds, fd_set* _Nullable __write_fds, fd_set* _Nullable __exception_fds, struct timeval* _Nullable __timeout);
/**
- * [pselect(2)](http://man7.org/linux/man-pages/man2/select.2.html) waits on a
+ * [pselect(2)](https://man7.org/linux/man-pages/man2/select.2.html) waits on a
* set of file descriptors.
*
* Use ppoll() instead.
@@ -109,7 +109,7 @@
int pselect(int __max_fd_plus_one, fd_set* _Nullable __read_fds, fd_set* _Nullable __write_fds, fd_set* _Nullable __exception_fds, const struct timespec* _Nullable __timeout, const sigset_t* _Nullable __mask);
/**
- * [pselect64(2)](http://man7.org/linux/man-pages/man2/select.2.html) waits on a
+ * [pselect64(2)](https://man7.org/linux/man-pages/man2/select.2.html) waits on a
* set of file descriptors.
*
* Use ppoll64() instead.
diff --git a/libc/include/sys/sendfile.h b/libc/include/sys/sendfile.h
index 26522a6..ac623e7 100644
--- a/libc/include/sys/sendfile.h
+++ b/libc/include/sys/sendfile.h
@@ -43,7 +43,7 @@
ssize_t sendfile(int __out_fd, int __in_fd, off_t* _Nullable __offset, size_t __count) __RENAME(sendfile64);
#else
/**
- * [sendfile(2)](http://man7.org/linux/man-pages/man2/sendfile.2.html) copies data directly
+ * [sendfile(2)](https://man7.org/linux/man-pages/man2/sendfile.2.html) copies data directly
* between two file descriptors.
*
* Returns the number of bytes copied on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/signalfd.h b/libc/include/sys/signalfd.h
index 2be9bdc..5568b7d 100644
--- a/libc/include/sys/signalfd.h
+++ b/libc/include/sys/signalfd.h
@@ -41,7 +41,7 @@
__BEGIN_DECLS
/**
- * [signalfd(2)](http://man7.org/linux/man-pages/man2/signalfd.2.html) creates/manipulates a
+ * [signalfd(2)](https://man7.org/linux/man-pages/man2/signalfd.2.html) creates/manipulates a
* file descriptor for reading signal events.
*
* Returns the file descriptor on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/socket.h b/libc/include/sys/socket.h
index 9402e70..47ddce0 100644
--- a/libc/include/sys/socket.h
+++ b/libc/include/sys/socket.h
@@ -277,41 +277,33 @@
#define IPX_TYPE 1
-#ifdef __i386__
-# define __socketcall extern __attribute__((__cdecl__))
-#else
-# define __socketcall extern
-#endif
-
-__socketcall int accept(int __fd, struct sockaddr* _Nullable __addr, socklen_t* _Nullable __addr_length);
-__socketcall int accept4(int __fd, struct sockaddr* _Nullable __addr, socklen_t* _Nullable __addr_length, int __flags);
-__socketcall int bind(int __fd, const struct sockaddr* _Nonnull __addr, socklen_t __addr_length);
-__socketcall int connect(int __fd, const struct sockaddr* _Nonnull __addr, socklen_t __addr_length);
-__socketcall int getpeername(int __fd, struct sockaddr* _Nonnull __addr, socklen_t* _Nonnull __addr_length);
-__socketcall int getsockname(int __fd, struct sockaddr* _Nonnull __addr, socklen_t* _Nonnull __addr_length);
-__socketcall int getsockopt(int __fd, int __level, int __option, void* _Nullable __value, socklen_t* _Nonnull __value_length);
-__socketcall int listen(int __fd, int __backlog);
-__socketcall int recvmmsg(int __fd, struct mmsghdr* _Nonnull __msgs, unsigned int __msg_count, int __flags, const struct timespec* _Nullable __timeout);
-__socketcall ssize_t recvmsg(int __fd, struct msghdr* _Nonnull __msg, int __flags);
-__socketcall int sendmmsg(int __fd, const struct mmsghdr* _Nonnull __msgs, unsigned int __msg_count, int __flags);
-__socketcall ssize_t sendmsg(int __fd, const struct msghdr* _Nonnull __msg, int __flags);
-__socketcall int setsockopt(int __fd, int __level, int __option, const void* _Nullable __value, socklen_t __value_length);
-__socketcall int shutdown(int __fd, int __how);
-__socketcall int socket(int __af, int __type, int __protocol);
-__socketcall int socketpair(int __af, int __type, int __protocol, int __fds[_Nonnull 2]);
+int accept(int __fd, struct sockaddr* _Nullable __addr, socklen_t* _Nullable __addr_length);
+int accept4(int __fd, struct sockaddr* _Nullable __addr, socklen_t* _Nullable __addr_length, int __flags);
+int bind(int __fd, const struct sockaddr* _Nonnull __addr, socklen_t __addr_length);
+int connect(int __fd, const struct sockaddr* _Nonnull __addr, socklen_t __addr_length);
+int getpeername(int __fd, struct sockaddr* _Nonnull __addr, socklen_t* _Nonnull __addr_length);
+int getsockname(int __fd, struct sockaddr* _Nonnull __addr, socklen_t* _Nonnull __addr_length);
+int getsockopt(int __fd, int __level, int __option, void* _Nullable __value, socklen_t* _Nonnull __value_length);
+int listen(int __fd, int __backlog);
+int recvmmsg(int __fd, struct mmsghdr* _Nonnull __msgs, unsigned int __msg_count, int __flags, const struct timespec* _Nullable __timeout);
+ssize_t recvmsg(int __fd, struct msghdr* _Nonnull __msg, int __flags);
+int sendmmsg(int __fd, const struct mmsghdr* _Nonnull __msgs, unsigned int __msg_count, int __flags);
+ssize_t sendmsg(int __fd, const struct msghdr* _Nonnull __msg, int __flags);
+int setsockopt(int __fd, int __level, int __option, const void* _Nullable __value, socklen_t __value_length);
+int shutdown(int __fd, int __how);
+int socket(int __af, int __type, int __protocol);
+int socketpair(int __af, int __type, int __protocol, int __fds[_Nonnull 2]);
ssize_t recv(int __fd, void* _Nullable __buf, size_t __n, int __flags);
ssize_t send(int __fd, const void* _Nonnull __buf, size_t __n, int __flags);
-__socketcall ssize_t sendto(int __fd, const void* _Nonnull __buf, size_t __n, int __flags, const struct sockaddr* _Nullable __dst_addr, socklen_t __dst_addr_length);
-__socketcall ssize_t recvfrom(int __fd, void* _Nullable __buf, size_t __n, int __flags, struct sockaddr* _Nullable __src_addr, socklen_t* _Nullable __src_addr_length);
+ssize_t sendto(int __fd, const void* _Nonnull __buf, size_t __n, int __flags, const struct sockaddr* _Nullable __dst_addr, socklen_t __dst_addr_length);
+ssize_t recvfrom(int __fd, void* _Nullable __buf, size_t __n, int __flags, struct sockaddr* _Nullable __src_addr, socklen_t* _Nullable __src_addr_length);
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
#include <bits/fortify/socket.h>
#endif
-#undef __socketcall
-
__END_DECLS
#endif
diff --git a/libc/include/sys/stat.h b/libc/include/sys/stat.h
index f916573..bb188fe 100644
--- a/libc/include/sys/stat.h
+++ b/libc/include/sys/stat.h
@@ -99,7 +99,13 @@
#endif
+/** The file information returned by fstat()/fstatat()/lstat()/stat(). */
struct stat { __STAT64_BODY };
+
+/**
+ * A synonym for `struct stat` on Android,
+ * provided for source compatibility with other systems.
+ */
struct stat64 { __STAT64_BODY };
#undef __STAT64_BODY
@@ -136,32 +142,145 @@
#define S_TYPEISSHM(__sb) 0
#define S_TYPEISTMO(__sb) 0
+/**
+ * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html)
+ * changes the mode of a file given a path.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int chmod(const char* _Nonnull __path, mode_t __mode);
+
+/**
+ * [fchmod(2)](https://man7.org/linux/man-pages/man2/fchmod.2.html)
+ * changes the mode of a file given a file descriptor.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int fchmod(int __fd, mode_t __mode);
+
+/**
+ * [fchmodat(2)](https://man7.org/linux/man-pages/man2/fchmodat.2.html)
+ * changes the mode of a file.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+int fchmodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, int __flags);
+
+/**
+ * [chmod(2)](https://man7.org/linux/man-pages/man2/chmod.2.html)
+ * changes the mode of a file given a path, without following symlinks.
+ *
+ * Equivalent to `fchmodat(AT_FDCWD, path, mode, AT_SYMLINK_NOFOLLOW)`.
+ *
+ * Available since API 36.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+int lchmod(const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(36);
+
+/**
+ * [mkdir(2)](https://man7.org/linux/man-pages/man2/mkdir.2.html)
+ * creates a directory.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int mkdir(const char* _Nonnull __path, mode_t __mode);
+/**
+ * [mkdirat(2)](https://man7.org/linux/man-pages/man2/mkdirat.2.html)
+ * creates a directory.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+int mkdirat(int __dir_fd, const char* _Nonnull __path, mode_t __mode);
+
+/**
+ * [fstat(2)](https://man7.org/linux/man-pages/man2/fstat.2.html)
+ * gets file status given a file descriptor.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int fstat(int __fd, struct stat* _Nonnull __buf);
+
+/** An alias for fstat(). */
int fstat64(int __fd, struct stat64* _Nonnull __buf);
+
+/**
+ * [fstatat(2)](https://man7.org/linux/man-pages/man2/fstatat.2.html)
+ * gets file status.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int fstatat(int __dir_fd, const char* _Nonnull __path, struct stat* _Nonnull __buf, int __flags);
+
+/** An alias for fstatat(). */
int fstatat64(int __dir_fd, const char* _Nonnull __path, struct stat64* _Nonnull __buf, int __flags);
+
+/**
+ * [lstat(2)](https://man7.org/linux/man-pages/man2/lstat.2.html)
+ * gets file status given a path, without following symlinks.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int lstat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
+
+/** An alias for lstat(). */
int lstat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf);
+
+/**
+ * [stat(2)](https://man7.org/linux/man-pages/man2/stat.2.html)
+ * gets file status given a path.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int stat(const char* _Nonnull __path, struct stat* _Nonnull __buf);
+
+/** An alias for stat(). */
int stat64(const char* _Nonnull __path, struct stat64* _Nonnull __buf);
+/**
+ * [mknod(2)](https://man7.org/linux/man-pages/man2/mknod.2.html)
+ * creates a directory, special, or regular file.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int mknod(const char* _Nonnull __path, mode_t __mode, dev_t __dev);
+
+/**
+ * [mknodat(2)](https://man7.org/linux/man-pages/man2/mknodat.2.html)
+ * creates a directory, special, or regular file.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+int mknodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, dev_t __dev);
+
+/**
+ * [umask(2)](https://man7.org/linux/man-pages/man2/umask.2.html)
+ * gets and sets the process-wide file mode creation mask.
+ *
+ * Returns the previous file mode creation mask.
+ */
mode_t umask(mode_t __mask);
#if defined(__BIONIC_INCLUDE_FORTIFY_HEADERS)
#include <bits/fortify/stat.h>
#endif
+/**
+ * [mkfifo(2)](https://man7.org/linux/man-pages/man2/mkfifo.2.html)
+ * creates a FIFO.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
int mkfifo(const char* _Nonnull __path, mode_t __mode);
-int mkfifoat(int __dir_fd, const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(23);
-int fchmodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, int __flags);
-int mkdirat(int __dir_fd, const char* _Nonnull __path, mode_t __mode);
-int mknodat(int __dir_fd, const char* _Nonnull __path, mode_t __mode, dev_t __dev);
+/**
+ * [mkfifoat(2)](https://man7.org/linux/man-pages/man2/mkfifoat.2.html)
+ * creates a FIFO.
+ *
+ * Returns 0 on success and returns -1 and sets `errno` on failure.
+ */
+int mkfifoat(int __dir_fd, const char* _Nonnull __path, mode_t __mode) __INTRODUCED_IN(23);
/**
* Used in the tv_nsec field of an argument to utimensat()/futimens()
@@ -205,7 +324,7 @@
#if defined(__USE_GNU)
/**
- * [statx(2)](http://man7.org/linux/man-pages/man2/statx.2.html) returns
+ * [statx(2)](https://man7.org/linux/man-pages/man2/statx.2.html) returns
* extended file status information.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/statvfs.h b/libc/include/sys/statvfs.h
index 7bc5e63..2feca81 100644
--- a/libc/include/sys/statvfs.h
+++ b/libc/include/sys/statvfs.h
@@ -92,7 +92,7 @@
#define ST_NOSYMFOLLOW 0x2000
/**
- * [statvfs(3)](http://man7.org/linux/man-pages/man3/statvfs.3.html)
+ * [statvfs(3)](https://man7.org/linux/man-pages/man3/statvfs.3.html)
* queries filesystem statistics for the given path.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -100,7 +100,7 @@
int statvfs(const char* _Nonnull __path, struct statvfs* _Nonnull __buf);
/**
- * [fstatvfs(3)](http://man7.org/linux/man-pages/man3/fstatvfs.3.html)
+ * [fstatvfs(3)](https://man7.org/linux/man-pages/man3/fstatvfs.3.html)
* queries filesystem statistics for the given file descriptor.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/swap.h b/libc/include/sys/swap.h
index 474aed7..2aaf86e 100644
--- a/libc/include/sys/swap.h
+++ b/libc/include/sys/swap.h
@@ -52,14 +52,14 @@
#define SWAP_FLAG_PRIO_SHIFT 0
/**
- * [swapon(2)](http://man7.org/linux/man-pages/man2/swapon.2.html) enables swapping.
+ * [swapon(2)](https://man7.org/linux/man-pages/man2/swapon.2.html) enables swapping.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int swapon(const char* _Nonnull __path, int __flags);
/**
- * [swapoff(2)](http://man7.org/linux/man-pages/man2/swapoff.2.html) disables swapping.
+ * [swapoff(2)](https://man7.org/linux/man-pages/man2/swapoff.2.html) disables swapping.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
diff --git a/libc/include/sys/sysinfo.h b/libc/include/sys/sysinfo.h
index cae5c49..5956feb 100644
--- a/libc/include/sys/sysinfo.h
+++ b/libc/include/sys/sysinfo.h
@@ -39,14 +39,14 @@
__BEGIN_DECLS
/**
- * [sysinfo(2)](http://man7.org/linux/man-pages/man2/sysinfo.2.html) queries system information.
+ * [sysinfo(2)](https://man7.org/linux/man-pages/man2/sysinfo.2.html) queries system information.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
*/
int sysinfo(struct sysinfo* _Nonnull __info);
/**
- * [get_nprocs_conf(3)](http://man7.org/linux/man-pages/man3/get_nprocs_conf.3.html) returns
+ * [get_nprocs_conf(3)](https://man7.org/linux/man-pages/man3/get_nprocs_conf.3.html) returns
* the total number of processors in the system.
*
* Available since API level 23.
@@ -56,7 +56,7 @@
int get_nprocs_conf(void) __INTRODUCED_IN(23);
/**
- * [get_nprocs(3)](http://man7.org/linux/man-pages/man3/get_nprocs.3.html) returns
+ * [get_nprocs(3)](https://man7.org/linux/man-pages/man3/get_nprocs.3.html) returns
* the number of processors in the system that are currently on-line.
*
* Available since API level 23.
@@ -66,7 +66,7 @@
int get_nprocs(void) __INTRODUCED_IN(23);
/**
- * [get_phys_pages(3)](http://man7.org/linux/man-pages/man3/get_phys_pages.3.html) returns
+ * [get_phys_pages(3)](https://man7.org/linux/man-pages/man3/get_phys_pages.3.html) returns
* the total number of physical pages in the system.
*
* Available since API level 23.
@@ -76,7 +76,7 @@
long get_phys_pages(void) __INTRODUCED_IN(23);
/**
- * [get_avphys_pages(3)](http://man7.org/linux/man-pages/man3/get_avphys_pages.3.html) returns
+ * [get_avphys_pages(3)](https://man7.org/linux/man-pages/man3/get_avphys_pages.3.html) returns
* the number of physical pages in the system that are currently available.
*
* Available since API level 23.
diff --git a/libc/include/sys/system_properties.h b/libc/include/sys/system_properties.h
index dc869da..e8b6e34 100644
--- a/libc/include/sys/system_properties.h
+++ b/libc/include/sys/system_properties.h
@@ -26,8 +26,12 @@
* SUCH DAMAGE.
*/
-#ifndef _INCLUDE_SYS_SYSTEM_PROPERTIES_H
-#define _INCLUDE_SYS_SYSTEM_PROPERTIES_H
+#pragma once
+
+/**
+ * @file system_properties.h
+ * @brief System properties.
+ */
#include <sys/cdefs.h>
#include <stdbool.h>
@@ -36,39 +40,53 @@
__BEGIN_DECLS
+/** An opaque structure representing a system property. */
typedef struct prop_info prop_info;
+/**
+ * The limit on the length of a property value.
+ * (See PROP_NAME_MAX for property names.)
+ */
#define PROP_VALUE_MAX 92
-/*
+/**
* Sets system property `name` to `value`, creating the system property if it doesn't already exist.
+ *
+ * Returns 0 on success, or -1 on failure.
*/
int __system_property_set(const char* _Nonnull __name, const char* _Nonnull __value);
-/*
+/**
* Returns a `prop_info` corresponding system property `name`, or nullptr if it doesn't exist.
- * Use __system_property_read_callback to query the current value.
+ * Use __system_property_read_callback() to query the current value.
*
- * Property lookup is expensive, so it can be useful to cache the result of this function.
+ * Property lookup is expensive, so it can be useful to cache the result of this
+ * function rather than using __system_property_get().
*/
const prop_info* _Nullable __system_property_find(const char* _Nonnull __name);
-/*
- * Calls `callback` with a consistent trio of name, value, and serial number for property `pi`.
+/**
+ * Calls `callback` with a consistent trio of name, value, and serial number
+ * for property `pi`.
+ *
+ * Available since API level 26.
*/
void __system_property_read_callback(const prop_info* _Nonnull __pi,
void (* _Nonnull __callback)(void* _Nullable __cookie, const char* _Nonnull __name, const char* _Nonnull __value, uint32_t __serial),
void* _Nullable __cookie) __INTRODUCED_IN(26);
-/*
+/**
* Passes a `prop_info` for each system property to the provided
- * callback. Use __system_property_read_callback() to read the value.
+ * callback. Use __system_property_read_callback() to read the value of
+ * any of the properties.
*
* This method is for inspecting and debugging the property system, and not generally useful.
+ *
+ * Returns 0 on success, or -1 on failure.
*/
int __system_property_foreach(void (* _Nonnull __callback)(const prop_info* _Nonnull __pi, void* _Nullable __cookie), void* _Nullable __cookie);
-/*
+/**
* Waits for the specific system property identified by `pi` to be updated
* past `old_serial`. Waits no longer than `relative_timeout`, or forever
* if `relative_timeout` is null.
@@ -79,20 +97,149 @@
*
* Returns true and updates `*new_serial_ptr` on success, or false if the call
* timed out.
+ *
+ * Available since API level 26.
*/
struct timespec;
bool __system_property_wait(const prop_info* _Nullable __pi, uint32_t __old_serial, uint32_t* _Nonnull __new_serial_ptr, const struct timespec* _Nullable __relative_timeout)
__INTRODUCED_IN(26);
-/* Deprecated. In Android O and above, there's no limit on property name length. */
+/**
+ * Deprecated: there's no limit on the length of a property name since
+ * API level 26, though the limit on property values (PROP_VALUE_MAX) remains.
+ */
#define PROP_NAME_MAX 32
-/* Deprecated. Use __system_property_read_callback instead. */
-int __system_property_read(const prop_info* _Nonnull __pi, char* _Nullable __name, char* _Nonnull __value);
-/* Deprecated. Use __system_property_read_callback instead. */
-int __system_property_get(const char* _Nonnull __name, char* _Nonnull __value);
-/* Deprecated. Use __system_property_foreach instead. */
+
+/** Deprecated. Use __system_property_foreach() instead. */
const prop_info* _Nullable __system_property_find_nth(unsigned __n);
+/** Deprecated. Use __system_property_read_callback() instead. */
+int __system_property_read(const prop_info* _Nonnull __pi, char* _Nullable __name, char* _Nonnull __value);
+/** Deprecated. Use __system_property_read_callback() instead. */
+int __system_property_get(const char* _Nonnull __name, char* _Nonnull __value);
+/** Deprecated: use __system_property_wait() instead. */
+uint32_t __system_property_wait_any(uint32_t __old_serial);
+
+/**
+ * Reads the global serial number of the system properties _area_.
+ *
+ * Called to predict if a series of cached __system_property_find()
+ * objects will have seen __system_property_serial() values change.
+ * Also aids the converse, as changes in the global serial can
+ * also be used to predict if a failed __system_property_find()
+ * could in turn now find a new object; thus preventing the
+ * cycles of effort to poll __system_property_find().
+ *
+ * Typically called at beginning of a cache cycle to signal if _any_ possible
+ * changes have occurred since last. If there is, one may check each individual
+ * __system_property_serial() to confirm dirty, or __system_property_find()
+ * to check if the property now exists. If a call to __system_property_add()
+ * or __system_property_update() has completed between two calls to
+ * __system_property_area_serial() then the second call will return a larger
+ * value than the first call. Beware of race conditions as changes to the
+ * properties are not atomic, the main value of this call is to determine
+ * whether the expensive __system_property_find() is worth retrying to see if
+ * a property now exists.
+ *
+ * Returns the serial number on success, -1 on error.
+ */
+uint32_t __system_property_area_serial(void);
+
+/**
+ * Reads the serial number of a specific system property previously returned by
+ * __system_property_find(). This is a cheap way to check whether a system
+ * property has changed or not.
+ *
+ * Returns the serial number on success, -1 on error.
+ */
+uint32_t __system_property_serial(const prop_info* _Nonnull __pi);
+
+//
+// libc implementation detail.
+//
+
+/**
+ * Initializes the system properties area in read-only mode.
+ *
+ * This is called automatically during libc initialization,
+ * so user code should never need to call this.
+ *
+ * Returns 0 on success, -1 otherwise.
+ */
+int __system_properties_init(void);
+
+//
+// init implementation details.
+//
+
+#define PROP_SERVICE_NAME "property_service"
+#define PROP_SERVICE_FOR_SYSTEM_NAME "property_service_for_system"
+#define PROP_DIRNAME "/dev/__properties__"
+
+// Messages sent to init.
+#define PROP_MSG_SETPROP 1
+#define PROP_MSG_SETPROP2 0x00020001
+
+// Status codes returned by init (but not passed from libc to the caller).
+#define PROP_SUCCESS 0
+#define PROP_ERROR_READ_CMD 0x0004
+#define PROP_ERROR_READ_DATA 0x0008
+#define PROP_ERROR_READ_ONLY_PROPERTY 0x000B
+#define PROP_ERROR_INVALID_NAME 0x0010
+#define PROP_ERROR_INVALID_VALUE 0x0014
+#define PROP_ERROR_PERMISSION_DENIED 0x0018
+#define PROP_ERROR_INVALID_CMD 0x001B
+#define PROP_ERROR_HANDLE_CONTROL_MESSAGE 0x0020
+#define PROP_ERROR_SET_FAILED 0x0024
+
+/**
+ * Initializes the area to be used to store properties.
+ *
+ * Can only be done by the process that has write access to the property area,
+ * typically init.
+ *
+ * See __system_properties_init() for the equivalent for all other processes.
+ */
+int __system_property_area_init(void);
+
+/**
+ * Adds a new system property.
+ * Can only be done by the process that has write access to the property area --
+ * typically init -- which must handle sequencing to ensure that only one property is
+ * updated at a time.
+ *
+ * Returns 0 on success, -1 if the property area is full.
+ */
+int __system_property_add(const char* _Nonnull __name, unsigned int __name_length, const char* _Nonnull __value, unsigned int __value_length);
+
+/**
+ * Updates the value of a system property returned by __system_property_find().
+ * Can only be done by the process that has write access to the property area --
+ * typically init -- which must handle sequencing to ensure that only one property is
+ * updated at a time.
+ *
+ * Returns 0 on success, -1 if the parameters are incorrect.
+ */
+int __system_property_update(prop_info* _Nonnull __pi, const char* _Nonnull __value, unsigned int __value_length);
+
+/**
+ * Reloads the system properties from disk.
+ * Not intended for use by any apps except the Zygote.
+ * Should only be called from the main thread.
+ *
+ * Pointers received from functions such as __system_property_find()
+ * may be invalidated by calls to this function.
+ *
+ * Returns 0 on success, -1 otherwise.
+ *
+ * Available since API level 35.
+ */
+int __system_properties_zygote_reload(void) __INTRODUCED_IN(35);
+
+/**
+ * Deprecated: previously for testing, but now that SystemProperties is its own
+ * testable class, there is never a reason to call this function and its
+ * implementation simply returns -1.
+ */
+int __system_property_set_filename(const char* _Nullable __unused __filename);
__END_DECLS
-
-#endif
diff --git a/libc/include/sys/timerfd.h b/libc/include/sys/timerfd.h
index de1f55b..bfa9a55 100644
--- a/libc/include/sys/timerfd.h
+++ b/libc/include/sys/timerfd.h
@@ -33,20 +33,23 @@
* @brief Timer file descriptors.
*/
-#include <fcntl.h> /* For O_CLOEXEC and O_NONBLOCK. */
+#include <fcntl.h>
+#include <linux/timerfd.h>
#include <time.h>
#include <sys/cdefs.h>
#include <sys/types.h>
__BEGIN_DECLS
-/** The timerfd_create() flag for a close-on-exec file descriptor. */
-#define TFD_CLOEXEC O_CLOEXEC
-/** The timerfd_create() flag for a non-blocking file descriptor. */
-#define TFD_NONBLOCK O_NONBLOCK
+/*! \macro TFD_CLOEXEC
+ * The timerfd_create() flag for a close-on-exec file descriptor.
+ */
+/*! \macro TFD_NONBLOCK
+ * The timerfd_create() flag for a non-blocking file descriptor.
+ */
/**
- * [timerfd_create(2)](http://man7.org/linux/man-pages/man2/timerfd_create.2.html) creates a
+ * [timerfd_create(2)](https://man7.org/linux/man-pages/man2/timerfd_create.2.html) creates a
* timer file descriptor.
*
* Returns the new file descriptor on success, and returns -1 and sets `errno` on failure.
@@ -59,7 +62,7 @@
#define TFD_TIMER_CANCEL_ON_SET (1 << 1)
/**
- * [timerfd_settime(2)](http://man7.org/linux/man-pages/man2/timerfd_settime.2.html) starts or
+ * [timerfd_settime(2)](https://man7.org/linux/man-pages/man2/timerfd_settime.2.html) starts or
* stops a timer.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -67,7 +70,7 @@
int timerfd_settime(int __fd, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
/**
- * [timerfd_gettime(2)](http://man7.org/linux/man-pages/man2/timerfd_gettime.2.html) queries the
+ * [timerfd_gettime(2)](https://man7.org/linux/man-pages/man2/timerfd_gettime.2.html) queries the
* current timer settings.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/times.h b/libc/include/sys/times.h
index 8b6e91d..ac6ec18 100644
--- a/libc/include/sys/times.h
+++ b/libc/include/sys/times.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [times(2)](http://man7.org/linux/man-pages/man2/times.2.html) fills a buffer with the
+ * [times(2)](https://man7.org/linux/man-pages/man2/times.2.html) fills a buffer with the
* calling process' CPU usage.
*
* Returns a (possibly overflowed) absolute time on success,
diff --git a/libc/include/sys/timex.h b/libc/include/sys/timex.h
index 4823edf..828eb47 100644
--- a/libc/include/sys/timex.h
+++ b/libc/include/sys/timex.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [adjtimex(2)](http://man7.org/linux/man-pages/man2/adjtimex.2.html) adjusts the kernel clock.
+ * [adjtimex(2)](https://man7.org/linux/man-pages/man2/adjtimex.2.html) adjusts the kernel clock.
*
* Returns the clock state on success, and returns -1 and sets `errno` on failure.
*
diff --git a/libc/include/sys/uio.h b/libc/include/sys/uio.h
index c8c64ae..d3e6561 100644
--- a/libc/include/sys/uio.h
+++ b/libc/include/sys/uio.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [readv(2)](http://man7.org/linux/man-pages/man2/readv.2.html) reads
+ * [readv(2)](https://man7.org/linux/man-pages/man2/readv.2.html) reads
* from an fd into the `__count` buffers described by `__iov`.
*
* Returns the number of bytes read on success,
@@ -49,7 +49,7 @@
ssize_t readv(int __fd, const struct iovec* _Nonnull __iov, int __count);
/**
- * [writev(2)](http://man7.org/linux/man-pages/man2/writev.2.html) writes
+ * [writev(2)](https://man7.org/linux/man-pages/man2/writev.2.html) writes
* to an fd from the `__count` buffers described by `__iov`.
*
* Returns the number of bytes written on success,
@@ -60,7 +60,7 @@
#if defined(__USE_GNU)
/**
- * [preadv(2)](http://man7.org/linux/man-pages/man2/preadv.2.html) reads
+ * [preadv(2)](https://man7.org/linux/man-pages/man2/preadv.2.html) reads
* from an fd into the `__count` buffers described by `__iov`, starting at
* offset `__offset` into the file.
*
@@ -72,7 +72,7 @@
ssize_t preadv(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(preadv64) __INTRODUCED_IN(24);
/**
- * [pwritev(2)](http://man7.org/linux/man-pages/man2/pwritev.2.html) writes
+ * [pwritev(2)](https://man7.org/linux/man-pages/man2/pwritev.2.html) writes
* to an fd from the `__count` buffers described by `__iov`, starting at offset
* `__offset` into the file.
*
@@ -98,7 +98,7 @@
ssize_t pwritev64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24);
/**
- * [preadv2(2)](http://man7.org/linux/man-pages/man2/preadv2.2.html) reads
+ * [preadv2(2)](https://man7.org/linux/man-pages/man2/preadv2.2.html) reads
* from an fd into the `__count` buffers described by `__iov`, starting at
* offset `__offset` into the file, with the given flags.
*
@@ -110,7 +110,7 @@
ssize_t preadv2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(preadv64v2) __INTRODUCED_IN(33);
/**
- * [pwritev2(2)](http://man7.org/linux/man-pages/man2/pwritev2.2.html) writes
+ * [pwritev2(2)](https://man7.org/linux/man-pages/man2/pwritev2.2.html) writes
* to an fd from the `__count` buffers described by `__iov`, starting at offset
* `__offset` into the file, with the given flags.
*
@@ -136,7 +136,7 @@
ssize_t pwritev64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33);
/**
- * [process_vm_readv(2)](http://man7.org/linux/man-pages/man2/process_vm_readv.2.html)
+ * [process_vm_readv(2)](https://man7.org/linux/man-pages/man2/process_vm_readv.2.html)
* reads from the address space of another process.
*
* Returns the number of bytes read on success,
@@ -147,7 +147,7 @@
ssize_t process_vm_readv(pid_t __pid, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __local_iov, unsigned long __local_iov_count, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23);
/**
- * [process_vm_writev(2)](http://man7.org/linux/man-pages/man2/process_vm_writev.2.html)
+ * [process_vm_writev(2)](https://man7.org/linux/man-pages/man2/process_vm_writev.2.html)
* writes to the address space of another process.
*
* Returns the number of bytes read on success,
diff --git a/libc/include/sys/utsname.h b/libc/include/sys/utsname.h
index aa8c1a0..23d1282 100644
--- a/libc/include/sys/utsname.h
+++ b/libc/include/sys/utsname.h
@@ -57,7 +57,7 @@
};
/**
- * [uname(2)](http://man7.org/linux/man-pages/man2/uname.2.html) returns information
+ * [uname(2)](https://man7.org/linux/man-pages/man2/uname.2.html) returns information
* about the kernel.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
diff --git a/libc/include/sys/vfs.h b/libc/include/sys/vfs.h
index 3579799..1a640ba 100644
--- a/libc/include/sys/vfs.h
+++ b/libc/include/sys/vfs.h
@@ -40,6 +40,8 @@
typedef __fsid_t fsid_t;
#if defined(__LP64__)
+/* We can't just use the kernel struct statfs directly here because
+ * it's reused for both struct statfs *and* struct statfs64. */
#define __STATFS64_BODY \
uint64_t f_type; \
uint64_t f_bsize; \
diff --git a/libc/include/sys/xattr.h b/libc/include/sys/xattr.h
index 745f50c..38c11e2 100644
--- a/libc/include/sys/xattr.h
+++ b/libc/include/sys/xattr.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [fsetxattr(2)](http://man7.org/linux/man-pages/man2/fsetxattr.2.html)
+ * [fsetxattr(2)](https://man7.org/linux/man-pages/man2/fsetxattr.2.html)
* sets an extended attribute on the file referred to by the given file
* descriptor.
*
@@ -55,7 +55,7 @@
int fsetxattr(int __fd, const char* _Nonnull __name, const void* _Nullable __value, size_t __size, int __flags);
/**
- * [setxattr(2)](http://man7.org/linux/man-pages/man2/setxattr.2.html)
+ * [setxattr(2)](https://man7.org/linux/man-pages/man2/setxattr.2.html)
* sets an extended attribute on the file referred to by the given path.
*
* A `size` of 0 can be used to set an empty value, in which case `value` is
@@ -69,7 +69,7 @@
int setxattr(const char* _Nonnull __path, const char* _Nonnull __name, const void* _Nullable __value, size_t __size, int __flags);
/**
- * [lsetxattr(2)](http://man7.org/linux/man-pages/man2/lsetxattr.2.html)
+ * [lsetxattr(2)](https://man7.org/linux/man-pages/man2/lsetxattr.2.html)
* sets an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
@@ -84,7 +84,7 @@
int lsetxattr(const char* _Nonnull __path, const char* _Nonnull __name, const void* _Nullable __value, size_t __size, int __flags);
/**
- * [fgetxattr(2)](http://man7.org/linux/man-pages/man2/fgetxattr.2.html)
+ * [fgetxattr(2)](https://man7.org/linux/man-pages/man2/fgetxattr.2.html)
* gets an extended attribute on the file referred to by the given file
* descriptor.
*
@@ -96,7 +96,7 @@
ssize_t fgetxattr(int __fd, const char* _Nonnull __name, void* _Nullable __value, size_t __size);
/**
- * [getxattr(2)](http://man7.org/linux/man-pages/man2/getxattr.2.html)
+ * [getxattr(2)](https://man7.org/linux/man-pages/man2/getxattr.2.html)
* gets an extended attribute on the file referred to by the given path.
*
* A `size` of 0 can be used to query the current length, in which case `value` is ignored and may be null.
@@ -107,7 +107,7 @@
ssize_t getxattr(const char* _Nonnull __path, const char* _Nonnull __name, void* _Nullable __value, size_t __size);
/**
- * [lgetxattr(2)](http://man7.org/linux/man-pages/man2/lgetxattr.2.html)
+ * [lgetxattr(2)](https://man7.org/linux/man-pages/man2/lgetxattr.2.html)
* gets an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
@@ -119,7 +119,7 @@
ssize_t lgetxattr(const char* _Nonnull __path, const char* _Nonnull __name, void* _Nullable __value, size_t __size);
/**
- * [flistxattr(2)](http://man7.org/linux/man-pages/man2/flistxattr.2.html)
+ * [flistxattr(2)](https://man7.org/linux/man-pages/man2/flistxattr.2.html)
* lists the extended attributes on the file referred to by the given file
* descriptor.
*
@@ -131,7 +131,7 @@
ssize_t flistxattr(int __fd, char* _Nullable __list, size_t __size);
/**
- * [listxattr(2)](http://man7.org/linux/man-pages/man2/listxattr.2.html)
+ * [listxattr(2)](https://man7.org/linux/man-pages/man2/listxattr.2.html)
* lists the extended attributes on the file referred to by the given path.
*
* A `size` of 0 can be used to query the current length, in which case `list` is ignored and may be null.
@@ -142,7 +142,7 @@
ssize_t listxattr(const char* _Nonnull __path, char* _Nullable __list, size_t __size);
/**
- * [llistxattr(2)](http://man7.org/linux/man-pages/man2/llistxattr.2.html)
+ * [llistxattr(2)](https://man7.org/linux/man-pages/man2/llistxattr.2.html)
* lists the extended attributes on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
@@ -154,7 +154,7 @@
ssize_t llistxattr(const char* _Nonnull __path, char* _Nullable __list, size_t __size);
/**
- * [fremovexattr(2)](http://man7.org/linux/man-pages/man2/fremovexattr.2.html)
+ * [fremovexattr(2)](https://man7.org/linux/man-pages/man2/fremovexattr.2.html)
* removes an extended attribute on the file referred to by the given file
* descriptor.
*
@@ -163,7 +163,7 @@
int fremovexattr(int __fd, const char* _Nonnull __name);
/**
- * [lremovexattr(2)](http://man7.org/linux/man-pages/man2/lremovexattr.2.html)
+ * [lremovexattr(2)](https://man7.org/linux/man-pages/man2/lremovexattr.2.html)
* removes an extended attribute on the file referred to by the given path, which
* is the link itself rather than its target in the case of a symbolic link.
*
@@ -172,7 +172,7 @@
int lremovexattr(const char* _Nonnull __path, const char* _Nonnull __name);
/**
- * [removexattr(2)](http://man7.org/linux/man-pages/man2/removexattr.2.html)
+ * [removexattr(2)](https://man7.org/linux/man-pages/man2/removexattr.2.html)
* removes an extended attribute on the file referred to by the given path.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
diff --git a/libc/include/syslog.h b/libc/include/syslog.h
index 1e2fcc4..33979f0 100644
--- a/libc/include/syslog.h
+++ b/libc/include/syslog.h
@@ -212,34 +212,34 @@
#endif
/**
- * [closelog(3)](http://man7.org/linux/man-pages/man3/closelog.3.html) does
+ * [closelog(3)](https://man7.org/linux/man-pages/man3/closelog.3.html) does
* nothing on Android.
*/
void closelog(void);
/**
- * [openlog(3)](http://man7.org/linux/man-pages/man3/openlog.3.html) sets
+ * [openlog(3)](https://man7.org/linux/man-pages/man3/openlog.3.html) sets
* the log tag to `__prefix`, which can be NULL to return to the default of
* getprogname(). On Android, the other two arguments are ignored.
*/
void openlog(const char* _Nullable __prefix, int __option, int __facility);
/**
- * [setlogmask(3)](http://man7.org/linux/man-pages/man3/setlogmask.3.html)
+ * [setlogmask(3)](https://man7.org/linux/man-pages/man3/setlogmask.3.html)
* sets which log priorities will actually be logged. See `LOG_MASK` and
* `LOG_UPTO`.
*/
int setlogmask(int __mask);
/**
- * [syslog(3)](http://man7.org/linux/man-pages/man3/syslog.3.html) formats
+ * [syslog(3)](https://man7.org/linux/man-pages/man3/syslog.3.html) formats
* the printf()-like message and logs it with the given priority, unless
* suppressed by setlogmask(). On Android, the output goes to logcat.
*/
void syslog(int __priority, const char* _Nonnull __fmt, ...) __printflike(2, 3);
/**
- * [vsyslog(3)](http://man7.org/linux/man-pages/man3/vsyslog.3.html) formats
+ * [vsyslog(3)](https://man7.org/linux/man-pages/man3/vsyslog.3.html) formats
* the vprintf()-like message and logs it with the given priority, unless
* suppressed by setlogmask(). On Android, the output goes to logcat.
*/
diff --git a/libc/include/termios.h b/libc/include/termios.h
index 7abff5d..5eecfcd 100644
--- a/libc/include/termios.h
+++ b/libc/include/termios.h
@@ -46,25 +46,25 @@
// in cfmakeraw() and cfsetspeed() until 28.
/**
- * [cfgetispeed(3)](http://man7.org/linux/man-pages/man3/cfgetispeed.3.html)
+ * [cfgetispeed(3)](https://man7.org/linux/man-pages/man3/cfgetispeed.3.html)
* returns the terminal input baud rate.
*/
speed_t cfgetispeed(const struct termios* _Nonnull __t);
/**
- * [cfgetospeed(3)](http://man7.org/linux/man-pages/man3/cfgetospeed.3.html)
+ * [cfgetospeed(3)](https://man7.org/linux/man-pages/man3/cfgetospeed.3.html)
* returns the terminal output baud rate.
*/
speed_t cfgetospeed(const struct termios* _Nonnull __t);
/**
- * [cfmakeraw(3)](http://man7.org/linux/man-pages/man3/cfmakeraw.3.html)
+ * [cfmakeraw(3)](https://man7.org/linux/man-pages/man3/cfmakeraw.3.html)
* configures the terminal for "raw" mode.
*/
void cfmakeraw(struct termios* _Nonnull __t);
/**
- * [cfsetspeed(3)](http://man7.org/linux/man-pages/man3/cfsetspeed.3.html)
+ * [cfsetspeed(3)](https://man7.org/linux/man-pages/man3/cfsetspeed.3.html)
* sets the terminal input and output baud rate.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -72,7 +72,7 @@
int cfsetspeed(struct termios* _Nonnull __t, speed_t __speed);
/**
- * [cfsetispeed(3)](http://man7.org/linux/man-pages/man3/cfsetispeed.3.html)
+ * [cfsetispeed(3)](https://man7.org/linux/man-pages/man3/cfsetispeed.3.html)
* sets the terminal input baud rate.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -80,7 +80,7 @@
int cfsetispeed(struct termios* _Nonnull _t, speed_t __speed);
/**
- * [cfsetospeed(3)](http://man7.org/linux/man-pages/man3/cfsetospeed.3.html)
+ * [cfsetospeed(3)](https://man7.org/linux/man-pages/man3/cfsetospeed.3.html)
* sets the terminal output baud rate.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -88,7 +88,7 @@
int cfsetospeed(struct termios* _Nonnull __t, speed_t __speed);
/**
- * [tcdrain(3)](http://man7.org/linux/man-pages/man3/tcdrain.3.html)
+ * [tcdrain(3)](https://man7.org/linux/man-pages/man3/tcdrain.3.html)
* waits until all output has been written.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -96,7 +96,7 @@
int tcdrain(int __fd);
/**
- * [tcflow(3)](http://man7.org/linux/man-pages/man3/tcflow.3.html)
+ * [tcflow(3)](https://man7.org/linux/man-pages/man3/tcflow.3.html)
* suspends (`TCOOFF`) or resumes (`TCOON`) output, or transmits a
* stop (`TCIOFF`) or start (`TCION`) to suspend or resume input.
*
@@ -105,7 +105,7 @@
int tcflow(int __fd, int __action);
/**
- * [tcflush(3)](http://man7.org/linux/man-pages/man3/tcflush.3.html)
+ * [tcflush(3)](https://man7.org/linux/man-pages/man3/tcflush.3.html)
* discards pending input (`TCIFLUSH`), output (`TCOFLUSH`), or
* both (`TCIOFLUSH`). (In `<stdio.h>` terminology, this is a purge rather
* than a flush.)
@@ -115,7 +115,7 @@
int tcflush(int __fd, int __queue);
/**
- * [tcgetattr(3)](http://man7.org/linux/man-pages/man3/tcgetattr.3.html)
+ * [tcgetattr(3)](https://man7.org/linux/man-pages/man3/tcgetattr.3.html)
* reads the configuration of the given terminal.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -123,7 +123,7 @@
int tcgetattr(int __fd, struct termios* _Nonnull __t);
/**
- * [tcgetsid(3)](http://man7.org/linux/man-pages/man3/tcgetsid.3.html)
+ * [tcgetsid(3)](https://man7.org/linux/man-pages/man3/tcgetsid.3.html)
* returns the session id corresponding to the given fd.
*
* Returns a non-negative session id on success and
@@ -132,7 +132,7 @@
pid_t tcgetsid(int __fd);
/**
- * [tcsendbreak(3)](http://man7.org/linux/man-pages/man3/tcsendbreak.3.html)
+ * [tcsendbreak(3)](https://man7.org/linux/man-pages/man3/tcsendbreak.3.html)
* sends a break.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
@@ -140,7 +140,7 @@
int tcsendbreak(int __fd, int __duration);
/**
- * [tcsetattr(3)](http://man7.org/linux/man-pages/man3/tcsetattr.3.html)
+ * [tcsetattr(3)](https://man7.org/linux/man-pages/man3/tcsetattr.3.html)
* writes the configuration of the given terminal.
*
* Returns 0 on success and returns -1 and sets `errno` on failure.
diff --git a/libc/include/time.h b/libc/include/time.h
index f448851..e9d6569 100644
--- a/libc/include/time.h
+++ b/libc/include/time.h
@@ -100,7 +100,7 @@
#define TM_ZONE tm_zone
/**
- * [time(2)](http://man7.org/linux/man-pages/man2/time.2.html) returns
+ * [time(2)](https://man7.org/linux/man-pages/man2/time.2.html) returns
* the number of seconds since the Unix epoch (1970-01-01 00:00:00 +0000).
*
* Returns the time in seconds on success, and returns -1 and sets `errno` on failure.
@@ -108,7 +108,7 @@
time_t time(time_t* _Nullable __t);
/**
- * [nanosleep(2)](http://man7.org/linux/man-pages/man2/nanosleep.2.html) sleeps
+ * [nanosleep(2)](https://man7.org/linux/man-pages/man2/nanosleep.2.html) sleeps
* for at least the given time (or until a signal arrives).
*
* Returns 0 on success, and returns -1 and sets `errno` on failure. If the sleep
@@ -118,7 +118,7 @@
int nanosleep(const struct timespec* _Nonnull __duration, struct timespec* _Nullable __remainder);
/**
- * [asctime(3)](http://man7.org/linux/man-pages/man3/asctime.3p.html) formats
+ * [asctime(3)](https://man7.org/linux/man-pages/man3/asctime.3p.html) formats
* the time `tm` as a string.
*
* Returns a pointer to a string on success, and returns NULL on failure.
@@ -130,7 +130,7 @@
char* _Nullable asctime(const struct tm* _Nonnull __tm);
/**
- * [asctime_r(3)](http://man7.org/linux/man-pages/man3/asctime_r.3p.html) formats
+ * [asctime_r(3)](https://man7.org/linux/man-pages/man3/asctime_r.3p.html) formats
* the time `tm` as a string in the given buffer `buf`.
*
* Returns a pointer to a string on success, and returns NULL on failure.
@@ -140,7 +140,7 @@
char* _Nullable asctime_r(const struct tm* _Nonnull __tm, char* _Nonnull __buf);
/**
- * [difftime(3)](http://man7.org/linux/man-pages/man3/difftime.3.html) returns
+ * [difftime(3)](https://man7.org/linux/man-pages/man3/difftime.3.html) returns
* the difference between two times.
*
* Returns the difference in seconds.
@@ -148,7 +148,7 @@
double difftime(time_t __lhs, time_t __rhs);
/**
- * [mktime(3)](http://man7.org/linux/man-pages/man3/mktime.3p.html) converts
+ * [mktime(3)](https://man7.org/linux/man-pages/man3/mktime.3p.html) converts
* broken-down time `tm` into the number of seconds since the Unix epoch.
*
* See tzset() for details of how the timezone is set, and mktime_rz()
@@ -169,7 +169,7 @@
time_t mktime_z(timezone_t _Nonnull __tz, struct tm* _Nonnull __tm) __INTRODUCED_IN(35);
/**
- * [localtime(3)](http://man7.org/linux/man-pages/man3/localtime.3p.html) converts
+ * [localtime(3)](https://man7.org/linux/man-pages/man3/localtime.3p.html) converts
* the number of seconds since the Unix epoch in `t` to a broken-down time, taking
* the device's timezone into account.
*
@@ -180,7 +180,7 @@
struct tm* _Nullable localtime(const time_t* _Nonnull __t);
/**
- * [localtime_r(3)](http://man7.org/linux/man-pages/man3/localtime_r.3p.html) converts
+ * [localtime_r(3)](https://man7.org/linux/man-pages/man3/localtime_r.3p.html) converts
* the number of seconds since the Unix epoch in `t` to a broken-down time.
* That broken-down time will be written to the given struct `tm`.
*
@@ -208,7 +208,7 @@
time_t timelocal(struct tm* _Nonnull __tm);
/**
- * [gmtime(3)](http://man7.org/linux/man-pages/man3/gmtime.3p.html) converts
+ * [gmtime(3)](https://man7.org/linux/man-pages/man3/gmtime.3p.html) converts
* the number of seconds since the Unix epoch in `t` to a broken-down time, using
* UTC (historically also known as GMT).
*
@@ -219,7 +219,7 @@
struct tm* _Nullable gmtime(const time_t* _Nonnull __t);
/**
- * [gmtime_r(3)](http://man7.org/linux/man-pages/man3/gmtime_r.3p.html) converts
+ * [gmtime_r(3)](https://man7.org/linux/man-pages/man3/gmtime_r.3p.html) converts
* the number of seconds since the Unix epoch in `t` to a broken-down time, using
* UTC (historically also known as GMT).
*
@@ -235,7 +235,7 @@
time_t timegm(struct tm* _Nonnull __tm);
/**
- * [strptime(3)](http://man7.org/linux/man-pages/man3/strptime.3.html) parses
+ * [strptime(3)](https://man7.org/linux/man-pages/man3/strptime.3.html) parses
* a string `s` assuming format `fmt` into broken-down time `tm`.
*
* Returns a pointer to the first character _not_ parsed, or null if no characters were parsed.
@@ -245,10 +245,10 @@
/**
* Equivalent to strptime() on Android where only C/POSIX locales are available.
*/
-char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __INTRODUCED_IN(28);
+char* _Nullable strptime_l(const char* _Nonnull __s, const char* _Nonnull __fmt, struct tm* _Nonnull __tm, locale_t _Nonnull __l) __strftimelike(2) __RENAME(strptime);
/**
- * [strftime(3)](http://man7.org/linux/man-pages/man3/strftime.3.html) formats
+ * [strftime(3)](https://man7.org/linux/man-pages/man3/strftime.3.html) formats
* a broken-down time `tm` into the buffer `buf` using format `fmt`.
*
* Returns a pointer to the first character _not_ parsed, or null if no characters were parsed.
@@ -261,7 +261,7 @@
size_t strftime_l(char* _Nonnull __buf, size_t __n, const char* _Nonnull __fmt, const struct tm* _Nullable __tm, locale_t _Nonnull __l) __strftimelike(3);
/**
- * [ctime(3)](http://man7.org/linux/man-pages/man3/ctime.3p.html) formats
+ * [ctime(3)](https://man7.org/linux/man-pages/man3/ctime.3p.html) formats
* the time `tm` as a string.
*
* Returns a pointer to a string on success, and returns NULL on failure.
@@ -273,7 +273,7 @@
char* _Nullable ctime(const time_t* _Nonnull __t);
/**
- * [ctime_r(3)](http://man7.org/linux/man-pages/man3/ctime.3p.html) formats
+ * [ctime_r(3)](https://man7.org/linux/man-pages/man3/ctime.3p.html) formats
* the time `tm` as a string in the given buffer `buf`.
*
* Returns a pointer to a string on success, and returns NULL on failure.
@@ -283,7 +283,7 @@
char* _Nullable ctime_r(const time_t* _Nonnull __t, char* _Nonnull __buf);
/**
- * [tzset(3)](http://man7.org/linux/man-pages/man3/tzset.3.html) tells
+ * [tzset(3)](https://man7.org/linux/man-pages/man3/tzset.3.html) tells
* libc that the timezone has changed.
*
* tzset() on Android looks at both the system property
@@ -328,7 +328,7 @@
void tzfree(timezone_t _Nullable __tz) __INTRODUCED_IN(35);
/**
- * [clock(3)](http://man7.org/linux/man-pages/man3/clock.3.html)
+ * [clock(3)](https://man7.org/linux/man-pages/man3/clock.3.html)
* returns an approximation of CPU time used, equivalent to
* `clock_gettime(CLOCK_PROCESS_CPUTIME_ID)` but with more confusing
* units. Use `CLOCKS_PER_SEC` to convert the result to seconds.
@@ -340,7 +340,7 @@
clock_t clock(void);
/**
- * [clock_getcpuclockid(3)](http://man7.org/linux/man-pages/man3/clock_getcpuclockid.3.html)
+ * [clock_getcpuclockid(3)](https://man7.org/linux/man-pages/man3/clock_getcpuclockid.3.html)
* gets the clock ID of the cpu-time clock for the given `pid`.
*
* Returns 0 on success, and returns -1 and returns an error number on failure.
@@ -348,7 +348,7 @@
int clock_getcpuclockid(pid_t __pid, clockid_t* _Nonnull __clock) __INTRODUCED_IN(23);
/**
- * [clock_getres(2)](http://man7.org/linux/man-pages/man2/clock_getres.2.html)
+ * [clock_getres(2)](https://man7.org/linux/man-pages/man2/clock_getres.2.html)
* gets the resolution of the given clock.
*
* Returns 0 on success, and returns -1 and returns an error number on failure.
@@ -356,7 +356,7 @@
int clock_getres(clockid_t __clock, struct timespec* _Nullable __resolution);
/**
- * [clock_gettime(2)](http://man7.org/linux/man-pages/man2/clock_gettime.2.html)
+ * [clock_gettime(2)](https://man7.org/linux/man-pages/man2/clock_gettime.2.html)
* gets the time according to the given clock.
*
* Returns 0 on success, and returns -1 and returns an error number on failure.
@@ -364,7 +364,7 @@
int clock_gettime(clockid_t __clock, struct timespec* _Nonnull __ts);
/**
- * [clock_nanosleep(2)](http://man7.org/linux/man-pages/man2/clock_nanosleep.2.html)
+ * [clock_nanosleep(2)](https://man7.org/linux/man-pages/man2/clock_nanosleep.2.html)
* sleeps for the given time (or until the given time if the TIMER_ABSTIME flag
* is used), as measured by the given clock.
*
@@ -375,7 +375,7 @@
int clock_nanosleep(clockid_t __clock, int __flags, const struct timespec* _Nonnull __time, struct timespec* _Nullable __remainder);
/**
- * [clock_settime(2)](http://man7.org/linux/man-pages/man2/clock_settime.2.html)
+ * [clock_settime(2)](https://man7.org/linux/man-pages/man2/clock_settime.2.html)
* sets the time for the given clock.
*
* Returns 0 on success, and returns -1 and returns an error number on failure.
@@ -383,7 +383,7 @@
int clock_settime(clockid_t __clock, const struct timespec* _Nonnull __ts);
/**
- * [timer_create(2)](http://man7.org/linux/man-pages/man2/timer_create.2.html)
+ * [timer_create(2)](https://man7.org/linux/man-pages/man2/timer_create.2.html)
* creates a POSIX timer.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -391,7 +391,7 @@
int timer_create(clockid_t __clock, struct sigevent* _Nullable __event, timer_t _Nonnull * _Nonnull __timer_ptr);
/**
- * [timer_delete(2)](http://man7.org/linux/man-pages/man2/timer_delete.2.html)
+ * [timer_delete(2)](https://man7.org/linux/man-pages/man2/timer_delete.2.html)
* destroys a POSIX timer.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -399,7 +399,7 @@
int timer_delete(timer_t _Nonnull __timer);
/**
- * [timer_settime(2)](http://man7.org/linux/man-pages/man2/timer_settime.2.html)
+ * [timer_settime(2)](https://man7.org/linux/man-pages/man2/timer_settime.2.html)
* starts or stops a POSIX timer.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -407,7 +407,7 @@
int timer_settime(timer_t _Nonnull __timer, int __flags, const struct itimerspec* _Nonnull __new_value, struct itimerspec* _Nullable __old_value);
/**
- * [timer_gettime(2)](http://man7.org/linux/man-pages/man2/timer_gettime.2.html)
+ * [timer_gettime(2)](https://man7.org/linux/man-pages/man2/timer_gettime.2.html)
* gets the time until the given timer next fires.
*
* Returns 0 on success, and returns -1 and sets `errno` on failure.
@@ -415,7 +415,7 @@
int timer_gettime(timer_t _Nonnull _timer, struct itimerspec* _Nonnull __ts);
/**
- * [timer_getoverrun(2)](http://man7.org/linux/man-pages/man2/timer_getoverrun.2.html)
+ * [timer_getoverrun(2)](https://man7.org/linux/man-pages/man2/timer_getoverrun.2.html)
* gets the overrun count (the number of times the timer should have fired, but
* didn't) for the last time the timer fired.
*
diff --git a/libc/include/uchar.h b/libc/include/uchar.h
index 626372a..55a36e7 100644
--- a/libc/include/uchar.h
+++ b/libc/include/uchar.h
@@ -55,7 +55,7 @@
#define __STD_UTF_32__ 1
/**
- * [c16rtomb(3)](http://man7.org/linux/man-pages/man3/c16rtomb.3.html) converts a single UTF-16
+ * [c16rtomb(3)](https://man7.org/linux/man-pages/man3/c16rtomb.3.html) converts a single UTF-16
* character to UTF-8.
*
* Returns the number of bytes written to `__buf` on success, and returns -1 and sets `errno`
@@ -64,7 +64,7 @@
size_t c16rtomb(char* _Nullable __buf, char16_t __ch16, mbstate_t* _Nullable __ps);
/**
- * [c32rtomb(3)](http://man7.org/linux/man-pages/man3/c32rtomb.3.html) converts a single UTF-32
+ * [c32rtomb(3)](https://man7.org/linux/man-pages/man3/c32rtomb.3.html) converts a single UTF-32
* character to UTF-8.
*
* Returns the number of bytes written to `__buf` on success, and returns -1 and sets `errno`
@@ -73,13 +73,13 @@
size_t c32rtomb(char* _Nullable __buf, char32_t __ch32, mbstate_t* _Nullable __ps);
/**
- * [mbrtoc16(3)](http://man7.org/linux/man-pages/man3/mbrtoc16.3.html) converts the next UTF-8
+ * [mbrtoc16(3)](https://man7.org/linux/man-pages/man3/mbrtoc16.3.html) converts the next UTF-8
* sequence to a UTF-16 code point.
*/
size_t mbrtoc16(char16_t* _Nullable __ch16, const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
/**
- * [mbrtoc32(3)](http://man7.org/linux/man-pages/man3/mbrtoc32.3.html) converts the next UTF-8
+ * [mbrtoc32(3)](https://man7.org/linux/man-pages/man3/mbrtoc32.3.html) converts the next UTF-8
* sequence to a UTF-32 code point.
*/
size_t mbrtoc32(char32_t* _Nullable __ch32, const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
diff --git a/libc/include/unistd.h b/libc/include/unistd.h
index c69db61..e1c268f 100644
--- a/libc/include/unistd.h
+++ b/libc/include/unistd.h
@@ -79,7 +79,7 @@
__noreturn void _exit(int __status);
/**
- * [fork(2)](http://man7.org/linux/man-pages/man2/fork.2.html) creates a new
+ * [fork(2)](https://man7.org/linux/man-pages/man2/fork.2.html) creates a new
* process. fork() runs any handlers set by pthread_atfork().
*
* Returns 0 in the child, the pid of the child in the parent,
@@ -103,7 +103,7 @@
pid_t _Fork(void) __INTRODUCED_IN(35);
/**
- * [vfork(2)](http://man7.org/linux/man-pages/man2/vfork.2.html) creates a new
+ * [vfork(2)](https://man7.org/linux/man-pages/man2/vfork.2.html) creates a new
* process. vfork() differs from fork() in that it does not run any handlers
* set by pthread_atfork(), and the parent is suspended until the child calls
* exec() or exits.
@@ -113,8 +113,22 @@
*/
pid_t vfork(void) __returns_twice;
+/**
+ * [getpid(2)](https://man7.org/linux/man-pages/man2/getpid.2.html) returns
+ * the caller's process ID.
+ *
+ * Returns the caller's process ID.
+ */
pid_t getpid(void);
-pid_t gettid(void) __attribute_const__;
+
+/**
+ * [gettid(2)](https://man7.org/linux/man-pages/man2/gettid.2.html) returns
+ * the caller's thread ID.
+ *
+ * Returns the caller's thread ID.
+ */
+pid_t gettid(void);
+
pid_t getpgid(pid_t __pid);
int setpgid(pid_t __pid, pid_t __pgid);
pid_t getppid(void);
@@ -136,7 +150,7 @@
int nice(int __incr);
/**
- * [setegid(2)](http://man7.org/linux/man-pages/man2/setegid.2.html) sets
+ * [setegid(2)](https://man7.org/linux/man-pages/man2/setegid.2.html) sets
* the effective group ID.
*
* On Android, this function only affects the calling thread, not all threads
@@ -147,7 +161,7 @@
int setegid(gid_t __gid);
/**
- * [seteuid(2)](http://man7.org/linux/man-pages/man2/seteuid.2.html) sets
+ * [seteuid(2)](https://man7.org/linux/man-pages/man2/seteuid.2.html) sets
* the effective user ID.
*
* On Android, this function only affects the calling thread, not all threads
@@ -158,7 +172,7 @@
int seteuid(uid_t __uid);
/**
- * [setgid(2)](http://man7.org/linux/man-pages/man2/setgid.2.html) sets
+ * [setgid(2)](https://man7.org/linux/man-pages/man2/setgid.2.html) sets
* the group ID.
*
* On Android, this function only affects the calling thread, not all threads
@@ -169,7 +183,7 @@
int setgid(gid_t __gid);
/**
- * [setregid(2)](http://man7.org/linux/man-pages/man2/setregid.2.html) sets
+ * [setregid(2)](https://man7.org/linux/man-pages/man2/setregid.2.html) sets
* the real and effective group IDs (use -1 to leave an ID unchanged).
*
* On Android, this function only affects the calling thread, not all threads
@@ -180,7 +194,7 @@
int setregid(gid_t __rgid, gid_t __egid);
/**
- * [setresgid(2)](http://man7.org/linux/man-pages/man2/setresgid.2.html) sets
+ * [setresgid(2)](https://man7.org/linux/man-pages/man2/setresgid.2.html) sets
* the real, effective, and saved group IDs (use -1 to leave an ID unchanged).
*
* On Android, this function only affects the calling thread, not all threads
@@ -191,7 +205,7 @@
int setresgid(gid_t __rgid, gid_t __egid, gid_t __sgid);
/**
- * [setresuid(2)](http://man7.org/linux/man-pages/man2/setresuid.2.html) sets
+ * [setresuid(2)](https://man7.org/linux/man-pages/man2/setresuid.2.html) sets
* the real, effective, and saved user IDs (use -1 to leave an ID unchanged).
*
* On Android, this function only affects the calling thread, not all threads
@@ -202,7 +216,7 @@
int setresuid(uid_t __ruid, uid_t __euid, uid_t __suid);
/**
- * [setreuid(2)](http://man7.org/linux/man-pages/man2/setreuid.2.html) sets
+ * [setreuid(2)](https://man7.org/linux/man-pages/man2/setreuid.2.html) sets
* the real and effective group IDs (use -1 to leave an ID unchanged).
*
* On Android, this function only affects the calling thread, not all threads
@@ -213,7 +227,7 @@
int setreuid(uid_t __ruid, uid_t __euid);
/**
- * [setuid(2)](http://man7.org/linux/man-pages/man2/setuid.2.html) sets
+ * [setuid(2)](https://man7.org/linux/man-pages/man2/setuid.2.html) sets
* the user ID.
*
* On Android, this function only affects the calling thread, not all threads
@@ -339,7 +353,7 @@
/**
* [getpagesize(2)](https://man7.org/linux/man-pages/man2/getpagesize.2.html)
* returns the system's page size. This is slightly faster than going via
- * sysconf().
+ * sysconf(), and avoids the linear search in getauxval().
*
* Returns the system's page size in bytes.
*/
@@ -350,8 +364,11 @@
int daemon(int __no_chdir, int __no_close);
#if defined(__arm__)
+/**
+ * New code should use __builtin___clear_cache() instead, which works on
+ * all architectures.
+ */
int cacheflush(long __addr, long __nbytes, long __cache);
- /* __attribute__((deprecated("use __builtin___clear_cache instead"))); */
#endif
pid_t tcgetpgrp(int __fd);
diff --git a/libc/include/utime.h b/libc/include/utime.h
index 4d181a8..f06a028 100644
--- a/libc/include/utime.h
+++ b/libc/include/utime.h
@@ -40,7 +40,7 @@
__BEGIN_DECLS
/**
- * [utime(2)](http://man7.org/linux/man-pages/man2/utime.2.html) changes the access and
+ * [utime(2)](https://man7.org/linux/man-pages/man2/utime.2.html) changes the access and
* modification time of `__filename`. If `__times` is null, the current time is used.
*
* New code should prefer utimensat().
diff --git a/libc/include/wchar.h b/libc/include/wchar.h
index c4e9679..e86f94d 100644
--- a/libc/include/wchar.h
+++ b/libc/include/wchar.h
@@ -58,7 +58,7 @@
size_t mbrlen(const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
size_t mbrtowc(wchar_t* _Nullable __buf, const char* _Nullable __s, size_t __n, mbstate_t* _Nullable __ps);
size_t mbsrtowcs(wchar_t* _Nullable __dst, const char* _Nullable * _Nonnull __src, size_t __dst_n, mbstate_t* _Nullable __ps);
-size_t mbsrtowcs_l(wchar_t* _Nullable __dst, const char* _Nullable * _Nonnull __src, size_t __dst_n, mbstate_t* _Nullable __ps, locale_t _Nonnull __l) __INTRODUCED_IN(35);
+size_t mbsrtowcs_l(wchar_t* _Nullable __dst, const char* _Nullable * _Nonnull __src, size_t __dst_n, mbstate_t* _Nullable __ps, locale_t _Nonnull __l) __RENAME(mbsrtowcs);
size_t mbsnrtowcs(wchar_t* _Nullable __dst, const char* _Nullable * _Nullable __src, size_t __src_n, size_t __dst_n, mbstate_t* _Nullable __ps);
wint_t putwc(wchar_t __wc, FILE* _Nonnull __fp);
wint_t putwchar(wchar_t __wc);
@@ -94,20 +94,20 @@
wchar_t* _Nullable wcspbrk(const wchar_t* _Nonnull __s, const wchar_t* _Nonnull __accept);
wchar_t* _Nullable wcsrchr(const wchar_t* _Nonnull __s, wchar_t __wc);
size_t wcsrtombs(char* _Nullable __dst, const wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __src, size_t __dst_n, mbstate_t* _Nullable __ps);
-size_t wcsrtombs_l(char* _Nullable __dst, const wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __src, size_t __dst_n, mbstate_t* _Nullable __ps, locale_t _Nonnull __l) __INTRODUCED_IN(35);
+size_t wcsrtombs_l(char* _Nullable __dst, const wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __src, size_t __dst_n, mbstate_t* _Nullable __ps, locale_t _Nonnull __l) __RENAME(wcsrtombs);
size_t wcsspn(const wchar_t* _Nonnull __s, const wchar_t* _Nonnull __accept);
wchar_t* _Nullable wcsstr(const wchar_t* _Nonnull __haystack, const wchar_t* _Nonnull __needle);
double wcstod(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr);
-double wcstod_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, locale_t _Nonnull __l) __INTRODUCED_IN(28);
+double wcstod_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, locale_t _Nonnull __l) __RENAME(wcstod);
float wcstof(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr);
-float wcstof_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, locale_t _Nonnull __l) __INTRODUCED_IN(28);
+float wcstof_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, locale_t _Nonnull __l) __RENAME(wcstof);
wchar_t* _Nullable wcstok(wchar_t* _Nullable __s, const wchar_t* _Nonnull __delimiter, wchar_t* _Nonnull * _Nonnull __ptr);
long wcstol(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base);
-long wcstol_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __INTRODUCED_IN(28);
+long wcstol_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __RENAME(wcstol);
long long wcstoll(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base);
long double wcstold(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr);
unsigned long wcstoul(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base);
-unsigned long wcstoul_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __INTRODUCED_IN(28);
+unsigned long wcstoul_l(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base, locale_t _Nonnull __l) __RENAME(wcstoul);
unsigned long long wcstoull(const wchar_t* _Nonnull __s, wchar_t* __BIONIC_COMPLICATED_NULLNESS * _Nullable __end_ptr, int __base);
int wcswidth(const wchar_t* _Nonnull __s, size_t __n);
size_t wcsxfrm(wchar_t* __BIONIC_COMPLICATED_NULLNESS __dst, const wchar_t* _Nonnull __src, size_t __n);
diff --git a/libc/kernel/android/scsi/scsi/scsi.h b/libc/kernel/android/scsi/scsi/scsi.h
index 3559028..4efeada 100644
--- a/libc/kernel/android/scsi/scsi/scsi.h
+++ b/libc/kernel/android/scsi/scsi/scsi.h
@@ -7,6 +7,7 @@
#ifndef _SCSI_SCSI_H
#define _SCSI_SCSI_H
#include <linux/types.h>
+#include <asm/param.h>
#include <scsi/scsi_proto.h>
#include <scsi/scsi_status.h>
struct ccs_modesel_head {
diff --git a/libc/kernel/tools/cpp.py b/libc/kernel/tools/cpp.py
index 0fd6e46..08b786a 100755
--- a/libc/kernel/tools/cpp.py
+++ b/libc/kernel/tools/cpp.py
@@ -2345,11 +2345,11 @@
def test_function_keep_attribute_structs(self):
text = """\
-static inline struct some_struct1 * function(struct some_struct2 * e) {
+static __inline__ struct some_struct1 * function(struct some_struct2 * e) {
}
"""
expected = """\
-static inline struct some_struct1 * function(struct some_struct2 * e) {
+static __inline__ struct some_struct1 * function(struct some_struct2 * e) {
}
"""
self.assertEqual(self.parse(text, set(["function"])), expected)
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h b/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
index 1032131..9c4e459 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd-eabi.h
@@ -420,4 +420,5 @@
#define __NR_lsm_get_self_attr (__NR_SYSCALL_BASE + 459)
#define __NR_lsm_set_self_attr (__NR_SYSCALL_BASE + 460)
#define __NR_lsm_list_modules (__NR_SYSCALL_BASE + 461)
+#define __NR_mseal (__NR_SYSCALL_BASE + 462)
#endif
diff --git a/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h b/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
index 1f57604..5060c2f 100644
--- a/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
+++ b/libc/kernel/uapi/asm-arm/asm/unistd-oabi.h
@@ -432,4 +432,5 @@
#define __NR_lsm_get_self_attr (__NR_SYSCALL_BASE + 459)
#define __NR_lsm_set_self_attr (__NR_SYSCALL_BASE + 460)
#define __NR_lsm_list_modules (__NR_SYSCALL_BASE + 461)
+#define __NR_mseal (__NR_SYSCALL_BASE + 462)
#endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/hwcap.h b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
index 5abff63..f5c720a 100644
--- a/libc/kernel/uapi/asm-arm64/asm/hwcap.h
+++ b/libc/kernel/uapi/asm-arm64/asm/hwcap.h
@@ -86,4 +86,19 @@
#define HWCAP2_SVE_B16B16 (1UL << 45)
#define HWCAP2_LRCPC3 (1UL << 46)
#define HWCAP2_LSE128 (1UL << 47)
+#define HWCAP2_FPMR (1UL << 48)
+#define HWCAP2_LUT (1UL << 49)
+#define HWCAP2_FAMINMAX (1UL << 50)
+#define HWCAP2_F8CVT (1UL << 51)
+#define HWCAP2_F8FMA (1UL << 52)
+#define HWCAP2_F8DP4 (1UL << 53)
+#define HWCAP2_F8DP2 (1UL << 54)
+#define HWCAP2_F8E4M3 (1UL << 55)
+#define HWCAP2_F8E5M2 (1UL << 56)
+#define HWCAP2_SME_LUTV2 (1UL << 57)
+#define HWCAP2_SME_F8F16 (1UL << 58)
+#define HWCAP2_SME_F8F32 (1UL << 59)
+#define HWCAP2_SME_SF8FMA (1UL << 60)
+#define HWCAP2_SME_SF8DP4 (1UL << 61)
+#define HWCAP2_SME_SF8DP2 (1UL << 62)
#endif
diff --git a/libc/kernel/uapi/asm-arm64/asm/kvm.h b/libc/kernel/uapi/asm-arm64/asm/kvm.h
index 5ad9021..1818c5f 100644
--- a/libc/kernel/uapi/asm-arm64/asm/kvm.h
+++ b/libc/kernel/uapi/asm-arm64/asm/kvm.h
@@ -18,9 +18,7 @@
#include <linux/types.h>
#include <asm/ptrace.h>
#include <asm/sve_context.h>
-#define __KVM_HAVE_GUEST_DEBUG
#define __KVM_HAVE_IRQ_LINE
-#define __KVM_HAVE_READONLY_MEM
#define __KVM_HAVE_VCPU_EVENTS
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
#define KVM_DIRTY_LOG_PAGE_OFFSET 64
@@ -40,9 +38,9 @@
#define KVM_ARM_TARGET_GENERIC_V8 5
#define KVM_ARM_NUM_TARGETS 6
#define KVM_ARM_DEVICE_TYPE_SHIFT 0
-#define KVM_ARM_DEVICE_TYPE_MASK GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, KVM_ARM_DEVICE_TYPE_SHIFT)
+#define KVM_ARM_DEVICE_TYPE_MASK __GENMASK(KVM_ARM_DEVICE_TYPE_SHIFT + 15, KVM_ARM_DEVICE_TYPE_SHIFT)
#define KVM_ARM_DEVICE_ID_SHIFT 16
-#define KVM_ARM_DEVICE_ID_MASK GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, KVM_ARM_DEVICE_ID_SHIFT)
+#define KVM_ARM_DEVICE_ID_MASK __GENMASK(KVM_ARM_DEVICE_ID_SHIFT + 15, KVM_ARM_DEVICE_ID_SHIFT)
#define KVM_ARM_DEVICE_VGIC_V2 0
#define KVM_VGIC_V2_ADDR_TYPE_DIST 0
#define KVM_VGIC_V2_ADDR_TYPE_CPU 1
@@ -89,6 +87,9 @@
struct kvm_sync_regs {
__u64 device_irq_level;
};
+#define KVM_ARM_DEV_EL1_VTIMER (1 << 0)
+#define KVM_ARM_DEV_EL1_PTIMER (1 << 1)
+#define KVM_ARM_DEV_PMU (1 << 2)
struct kvm_pmu_event_filter {
__u16 base_event;
__u16 nevents;
diff --git a/libc/kernel/uapi/asm-arm64/asm/sigcontext.h b/libc/kernel/uapi/asm-arm64/asm/sigcontext.h
index 6098fc7..8e48d55 100644
--- a/libc/kernel/uapi/asm-arm64/asm/sigcontext.h
+++ b/libc/kernel/uapi/asm-arm64/asm/sigcontext.h
@@ -52,6 +52,11 @@
struct _aarch64_ctx head;
__u64 tpidr2;
};
+#define FPMR_MAGIC 0x46504d52
+struct fpmr_context {
+ struct _aarch64_ctx head;
+ __u64 fpmr;
+};
#define ZA_MAGIC 0x54366345
struct za_context {
struct _aarch64_ctx head;
diff --git a/libc/kernel/uapi/asm-generic/bitsperlong.h b/libc/kernel/uapi/asm-generic/bitsperlong.h
index 969913b..11dcc1a 100644
--- a/libc/kernel/uapi/asm-generic/bitsperlong.h
+++ b/libc/kernel/uapi/asm-generic/bitsperlong.h
@@ -13,4 +13,7 @@
#define __BITS_PER_LONG 32
#endif
#endif
+#ifndef __BITS_PER_LONG_LONG
+#define __BITS_PER_LONG_LONG 64
+#endif
#endif
diff --git a/libc/kernel/uapi/asm-generic/unistd.h b/libc/kernel/uapi/asm-generic/unistd.h
index c882751..7eaa89a 100644
--- a/libc/kernel/uapi/asm-generic/unistd.h
+++ b/libc/kernel/uapi/asm-generic/unistd.h
@@ -412,8 +412,9 @@
#define __NR_lsm_get_self_attr 459
#define __NR_lsm_set_self_attr 460
#define __NR_lsm_list_modules 461
+#define __NR_mseal 462
#undef __NR_syscalls
-#define __NR_syscalls 462
+#define __NR_syscalls 463
#if __BITS_PER_LONG == 64 && !defined(__SYSCALL_COMPAT)
#define __NR_fcntl __NR3264_fcntl
#define __NR_statfs __NR3264_statfs
diff --git a/libc/kernel/uapi/asm-riscv/asm/auxvec.h b/libc/kernel/uapi/asm-riscv/asm/auxvec.h
index 446fc54..755f4e9 100644
--- a/libc/kernel/uapi/asm-riscv/asm/auxvec.h
+++ b/libc/kernel/uapi/asm-riscv/asm/auxvec.h
@@ -15,6 +15,6 @@
#define AT_L2_CACHEGEOMETRY 45
#define AT_L3_CACHESIZE 46
#define AT_L3_CACHEGEOMETRY 47
-#define AT_VECTOR_SIZE_ARCH 9
+#define AT_VECTOR_SIZE_ARCH 10
#define AT_MINSIGSTKSZ 51
#endif
diff --git a/libc/kernel/uapi/asm-riscv/asm/hwprobe.h b/libc/kernel/uapi/asm-riscv/asm/hwprobe.h
index 6f8d8f5..3f30c88 100644
--- a/libc/kernel/uapi/asm-riscv/asm/hwprobe.h
+++ b/libc/kernel/uapi/asm-riscv/asm/hwprobe.h
@@ -48,11 +48,12 @@
#define RISCV_HWPROBE_EXT_ZFHMIN (1 << 28)
#define RISCV_HWPROBE_EXT_ZIHINTNTL (1 << 29)
#define RISCV_HWPROBE_EXT_ZVFH (1 << 30)
-#define RISCV_HWPROBE_EXT_ZVFHMIN (1 << 31)
+#define RISCV_HWPROBE_EXT_ZVFHMIN (1ULL << 31)
#define RISCV_HWPROBE_EXT_ZFA (1ULL << 32)
#define RISCV_HWPROBE_EXT_ZTSO (1ULL << 33)
#define RISCV_HWPROBE_EXT_ZACAS (1ULL << 34)
#define RISCV_HWPROBE_EXT_ZICOND (1ULL << 35)
+#define RISCV_HWPROBE_EXT_ZIHINTPAUSE (1ULL << 36)
#define RISCV_HWPROBE_KEY_CPUPERF_0 5
#define RISCV_HWPROBE_MISALIGNED_UNKNOWN (0 << 0)
#define RISCV_HWPROBE_MISALIGNED_EMULATED (1 << 0)
diff --git a/libc/kernel/uapi/asm-riscv/asm/kvm.h b/libc/kernel/uapi/asm-riscv/asm/kvm.h
index 054e1a1..12d8f61 100644
--- a/libc/kernel/uapi/asm-riscv/asm/kvm.h
+++ b/libc/kernel/uapi/asm-riscv/asm/kvm.h
@@ -11,7 +11,6 @@
#include <asm/bitsperlong.h>
#include <asm/ptrace.h>
#define __KVM_HAVE_IRQ_LINE
-#define __KVM_HAVE_READONLY_MEM
#define KVM_COALESCED_MMIO_PAGE_OFFSET 1
#define KVM_INTERRUPT_SET - 1U
#define KVM_INTERRUPT_UNSET - 2U
@@ -126,6 +125,9 @@
KVM_RISCV_ISA_EXT_ZVFH,
KVM_RISCV_ISA_EXT_ZVFHMIN,
KVM_RISCV_ISA_EXT_ZFA,
+ KVM_RISCV_ISA_EXT_ZTSO,
+ KVM_RISCV_ISA_EXT_ZACAS,
+ KVM_RISCV_ISA_EXT_SSCOFPMF,
KVM_RISCV_ISA_EXT_MAX,
};
enum KVM_RISCV_SBI_EXT_ID {
diff --git a/libc/kernel/uapi/asm-x86/asm/bootparam.h b/libc/kernel/uapi/asm-x86/asm/bootparam.h
index c87a8af..6a4b59c 100644
--- a/libc/kernel/uapi/asm-x86/asm/bootparam.h
+++ b/libc/kernel/uapi/asm-x86/asm/bootparam.h
@@ -6,19 +6,7 @@
*/
#ifndef _ASM_X86_BOOTPARAM_H
#define _ASM_X86_BOOTPARAM_H
-#define SETUP_NONE 0
-#define SETUP_E820_EXT 1
-#define SETUP_DTB 2
-#define SETUP_PCI 3
-#define SETUP_EFI 4
-#define SETUP_APPLE_PROPERTIES 5
-#define SETUP_JAILHOUSE 6
-#define SETUP_CC_BLOB 7
-#define SETUP_IMA 8
-#define SETUP_RNG_SEED 9
-#define SETUP_ENUM_MAX SETUP_RNG_SEED
-#define SETUP_INDIRECT (1 << 31)
-#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT)
+#include <asm/setup_data.h>
#define RAMDISK_IMAGE_START_MASK 0x07FF
#define RAMDISK_PROMPT_FLAG 0x8000
#define RAMDISK_LOAD_FLAG 0x4000
@@ -34,6 +22,7 @@
#define XLF_EFI_KEXEC (1 << 4)
#define XLF_5LEVEL (1 << 5)
#define XLF_5LEVEL_ENABLED (1 << 6)
+#define XLF_MEM_ENCRYPTION (1 << 7)
#ifndef __ASSEMBLY__
#include <linux/types.h>
#include <linux/screen_info.h>
@@ -41,18 +30,6 @@
#include <linux/edd.h>
#include <asm/ist.h>
#include <video/edid.h>
-struct setup_data {
- __u64 next;
- __u32 type;
- __u32 len;
- __u8 data[];
-};
-struct setup_indirect {
- __u32 type;
- __u32 reserved;
- __u64 len;
- __u64 addr;
-};
struct setup_header {
__u8 setup_sects;
__u16 root_flags;
@@ -115,34 +92,7 @@
__u32 efi_memmap_hi;
};
#define E820_MAX_ENTRIES_ZEROPAGE 128
-struct boot_e820_entry {
- __u64 addr;
- __u64 size;
- __u32 type;
-} __attribute__((packed));
#define JAILHOUSE_SETUP_REQUIRED_VERSION 1
-struct jailhouse_setup_data {
- struct {
- __u16 version;
- __u16 compatible_version;
- } __attribute__((packed)) hdr;
- struct {
- __u16 pm_timer_address;
- __u16 num_cpus;
- __u64 pci_mmconfig_base;
- __u32 tsc_khz;
- __u32 apic_khz;
- __u8 standard_ioapic;
- __u8 cpu_ids[255];
- } __attribute__((packed)) v1;
- struct {
- __u32 flags;
- } __attribute__((packed)) v2;
-} __attribute__((packed));
-struct ima_setup_data {
- __u64 addr;
- __u64 size;
-} __attribute__((packed));
struct boot_params {
struct screen_info screen_info;
struct apm_bios_info apm_bios_info;
diff --git a/libc/kernel/uapi/asm-x86/asm/kvm.h b/libc/kernel/uapi/asm-x86/asm/kvm.h
index 1dd057a..17b1c5d 100644
--- a/libc/kernel/uapi/asm-x86/asm/kvm.h
+++ b/libc/kernel/uapi/asm-x86/asm/kvm.h
@@ -6,6 +6,8 @@
*/
#ifndef _ASM_X86_KVM_H
#define _ASM_X86_KVM_H
+#include <linux/const.h>
+#include <linux/bits.h>
#include <linux/types.h>
#include <linux/ioctl.h>
#include <linux/stddef.h>
@@ -35,7 +37,6 @@
#define __KVM_HAVE_IRQ_LINE
#define __KVM_HAVE_MSI
#define __KVM_HAVE_USER_NMI
-#define __KVM_HAVE_GUEST_DEBUG
#define __KVM_HAVE_MSIX
#define __KVM_HAVE_MCE
#define __KVM_HAVE_PIT_STATE2
@@ -44,7 +45,6 @@
#define __KVM_HAVE_DEBUGREGS
#define __KVM_HAVE_XSAVE
#define __KVM_HAVE_XCRS
-#define __KVM_HAVE_READONLY_MEM
#define KVM_NR_INTERRUPTS 256
struct kvm_pic_state {
__u8 last_irr;
@@ -353,7 +353,10 @@
#define KVM_STATE_NESTED_VMX_VMCS_SIZE 0x1000
#define KVM_STATE_NESTED_SVM_VMCB_SIZE 0x1000
#define KVM_STATE_VMX_PREEMPTION_TIMER_DEADLINE 0x00000001
+#define KVM_X86_GRP_SYSTEM 0
#define KVM_X86_XCOMP_GUEST_SUPP 0
+#define KVM_X86_GRP_SEV 1
+#define KVM_X86_SEV_VMSA_FEATURES 0
struct kvm_vmx_nested_state_data {
__u8 vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
__u8 shadow_vmcs12[KVM_STATE_NESTED_VMX_VMCS_SIZE];
@@ -398,17 +401,270 @@
};
#define KVM_PMU_EVENT_ALLOW 0
#define KVM_PMU_EVENT_DENY 1
-#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS BIT(0)
+#define KVM_PMU_EVENT_FLAG_MASKED_EVENTS _BITUL(0)
#define KVM_PMU_EVENT_FLAGS_VALID_MASK (KVM_PMU_EVENT_FLAG_MASKED_EVENTS)
+struct kvm_x86_mce {
+ __u64 status;
+ __u64 addr;
+ __u64 misc;
+ __u64 mcg_status;
+ __u8 bank;
+ __u8 pad1[7];
+ __u64 pad2[3];
+};
+#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
+#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
+#define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
+#define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
+#define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
+#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
+#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
+#define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7)
+#define KVM_XEN_HVM_CONFIG_SHARED_INFO_HVA (1 << 8)
+struct kvm_xen_hvm_config {
+ __u32 flags;
+ __u32 msr;
+ __u64 blob_addr_32;
+ __u64 blob_addr_64;
+ __u8 blob_size_32;
+ __u8 blob_size_64;
+ __u8 pad2[30];
+};
+struct kvm_xen_hvm_attr {
+ __u16 type;
+ __u16 pad[3];
+ union {
+ __u8 long_mode;
+ __u8 vector;
+ __u8 runstate_update_flag;
+ union {
+ __u64 gfn;
+#define KVM_XEN_INVALID_GFN ((__u64) - 1)
+ __u64 hva;
+ } shared_info;
+ struct {
+ __u32 send_port;
+ __u32 type;
+ __u32 flags;
+#define KVM_XEN_EVTCHN_DEASSIGN (1 << 0)
+#define KVM_XEN_EVTCHN_UPDATE (1 << 1)
+#define KVM_XEN_EVTCHN_RESET (1 << 2)
+ union {
+ struct {
+ __u32 port;
+ __u32 vcpu;
+ __u32 priority;
+ } port;
+ struct {
+ __u32 port;
+ __s32 fd;
+ } eventfd;
+ __u32 padding[4];
+ } deliver;
+ } evtchn;
+ __u32 xen_version;
+ __u64 pad[8];
+ } u;
+};
+#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
+#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
+#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2
+#define KVM_XEN_ATTR_TYPE_EVTCHN 0x3
+#define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4
+#define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5
+#define KVM_XEN_ATTR_TYPE_SHARED_INFO_HVA 0x6
+struct kvm_xen_vcpu_attr {
+ __u16 type;
+ __u16 pad[3];
+ union {
+ __u64 gpa;
+#define KVM_XEN_INVALID_GPA ((__u64) - 1)
+ __u64 hva;
+ __u64 pad[8];
+ struct {
+ __u64 state;
+ __u64 state_entry_time;
+ __u64 time_running;
+ __u64 time_runnable;
+ __u64 time_blocked;
+ __u64 time_offline;
+ } runstate;
+ __u32 vcpu_id;
+ struct {
+ __u32 port;
+ __u32 priority;
+ __u64 expires_ns;
+ } timer;
+ __u8 vector;
+ } u;
+};
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4
+#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6
+#define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7
+#define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8
+#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO_HVA 0x9
+enum sev_cmd_id {
+ KVM_SEV_INIT = 0,
+ KVM_SEV_ES_INIT,
+ KVM_SEV_LAUNCH_START,
+ KVM_SEV_LAUNCH_UPDATE_DATA,
+ KVM_SEV_LAUNCH_UPDATE_VMSA,
+ KVM_SEV_LAUNCH_SECRET,
+ KVM_SEV_LAUNCH_MEASURE,
+ KVM_SEV_LAUNCH_FINISH,
+ KVM_SEV_SEND_START,
+ KVM_SEV_SEND_UPDATE_DATA,
+ KVM_SEV_SEND_UPDATE_VMSA,
+ KVM_SEV_SEND_FINISH,
+ KVM_SEV_RECEIVE_START,
+ KVM_SEV_RECEIVE_UPDATE_DATA,
+ KVM_SEV_RECEIVE_UPDATE_VMSA,
+ KVM_SEV_RECEIVE_FINISH,
+ KVM_SEV_GUEST_STATUS,
+ KVM_SEV_DBG_DECRYPT,
+ KVM_SEV_DBG_ENCRYPT,
+ KVM_SEV_CERT_EXPORT,
+ KVM_SEV_GET_ATTESTATION_REPORT,
+ KVM_SEV_SEND_CANCEL,
+ KVM_SEV_INIT2,
+ KVM_SEV_NR_MAX,
+};
+struct kvm_sev_cmd {
+ __u32 id;
+ __u32 pad0;
+ __u64 data;
+ __u32 error;
+ __u32 sev_fd;
+};
+struct kvm_sev_init {
+ __u64 vmsa_features;
+ __u32 flags;
+ __u16 ghcb_version;
+ __u16 pad1;
+ __u32 pad2[8];
+};
+struct kvm_sev_launch_start {
+ __u32 handle;
+ __u32 policy;
+ __u64 dh_uaddr;
+ __u32 dh_len;
+ __u32 pad0;
+ __u64 session_uaddr;
+ __u32 session_len;
+ __u32 pad1;
+};
+struct kvm_sev_launch_update_data {
+ __u64 uaddr;
+ __u32 len;
+ __u32 pad0;
+};
+struct kvm_sev_launch_secret {
+ __u64 hdr_uaddr;
+ __u32 hdr_len;
+ __u32 pad0;
+ __u64 guest_uaddr;
+ __u32 guest_len;
+ __u32 pad1;
+ __u64 trans_uaddr;
+ __u32 trans_len;
+ __u32 pad2;
+};
+struct kvm_sev_launch_measure {
+ __u64 uaddr;
+ __u32 len;
+ __u32 pad0;
+};
+struct kvm_sev_guest_status {
+ __u32 handle;
+ __u32 policy;
+ __u32 state;
+};
+struct kvm_sev_dbg {
+ __u64 src_uaddr;
+ __u64 dst_uaddr;
+ __u32 len;
+ __u32 pad0;
+};
+struct kvm_sev_attestation_report {
+ __u8 mnonce[16];
+ __u64 uaddr;
+ __u32 len;
+ __u32 pad0;
+};
+struct kvm_sev_send_start {
+ __u32 policy;
+ __u32 pad0;
+ __u64 pdh_cert_uaddr;
+ __u32 pdh_cert_len;
+ __u32 pad1;
+ __u64 plat_certs_uaddr;
+ __u32 plat_certs_len;
+ __u32 pad2;
+ __u64 amd_certs_uaddr;
+ __u32 amd_certs_len;
+ __u32 pad3;
+ __u64 session_uaddr;
+ __u32 session_len;
+ __u32 pad4;
+};
+struct kvm_sev_send_update_data {
+ __u64 hdr_uaddr;
+ __u32 hdr_len;
+ __u32 pad0;
+ __u64 guest_uaddr;
+ __u32 guest_len;
+ __u32 pad1;
+ __u64 trans_uaddr;
+ __u32 trans_len;
+ __u32 pad2;
+};
+struct kvm_sev_receive_start {
+ __u32 handle;
+ __u32 policy;
+ __u64 pdh_uaddr;
+ __u32 pdh_len;
+ __u32 pad0;
+ __u64 session_uaddr;
+ __u32 session_len;
+ __u32 pad1;
+};
+struct kvm_sev_receive_update_data {
+ __u64 hdr_uaddr;
+ __u32 hdr_len;
+ __u32 pad0;
+ __u64 guest_uaddr;
+ __u32 guest_len;
+ __u32 pad1;
+ __u64 trans_uaddr;
+ __u32 trans_len;
+ __u32 pad2;
+};
+#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
+#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
+struct kvm_hyperv_eventfd {
+ __u32 conn_id;
+ __s32 fd;
+ __u32 flags;
+ __u32 padding[3];
+};
+#define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
+#define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
#define KVM_PMU_ENCODE_MASKED_ENTRY(event_select,mask,match,exclude) (((event_select) & 0xFFULL) | (((event_select) & 0XF00ULL) << 24) | (((mask) & 0xFFULL) << 56) | (((match) & 0xFFULL) << 8) | ((__u64) (! ! (exclude)) << 55))
-#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT (GENMASK_ULL(7, 0) | GENMASK_ULL(35, 32))
-#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (GENMASK_ULL(63, 56))
-#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (GENMASK_ULL(15, 8))
-#define KVM_PMU_MASKED_ENTRY_EXCLUDE (BIT_ULL(55))
+#define KVM_PMU_MASKED_ENTRY_EVENT_SELECT (__GENMASK_ULL(7, 0) | __GENMASK_ULL(35, 32))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MASK (__GENMASK_ULL(63, 56))
+#define KVM_PMU_MASKED_ENTRY_UMASK_MATCH (__GENMASK_ULL(15, 8))
+#define KVM_PMU_MASKED_ENTRY_EXCLUDE (_BITULL(55))
#define KVM_PMU_MASKED_ENTRY_UMASK_MASK_SHIFT (56)
#define KVM_VCPU_TSC_CTRL 0
#define KVM_VCPU_TSC_OFFSET 0
-#define KVM_EXIT_HYPERCALL_LONG_MODE BIT(0)
+#define KVM_EXIT_HYPERCALL_LONG_MODE _BITULL(0)
#define KVM_X86_DEFAULT_VM 0
#define KVM_X86_SW_PROTECTED_VM 1
+#define KVM_X86_SEV_VM 2
+#define KVM_X86_SEV_ES_VM 3
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/kvm_para.h b/libc/kernel/uapi/asm-x86/asm/kvm_para.h
index 03421ed..3395a15 100644
--- a/libc/kernel/uapi/asm-x86/asm/kvm_para.h
+++ b/libc/kernel/uapi/asm-x86/asm/kvm_para.h
@@ -67,7 +67,7 @@
#define KVM_ASYNC_PF_SEND_ALWAYS (1 << 1)
#define KVM_ASYNC_PF_DELIVERY_AS_PF_VMEXIT (1 << 2)
#define KVM_ASYNC_PF_DELIVERY_AS_INT (1 << 3)
-#define KVM_ASYNC_PF_VEC_MASK GENMASK(7, 0)
+#define KVM_ASYNC_PF_VEC_MASK __GENMASK(7, 0)
#define KVM_MIGRATION_READY (1 << 0)
#define KVM_MAP_GPA_RANGE_PAGE_SZ_4K 0
#define KVM_MAP_GPA_RANGE_PAGE_SZ_2M (1 << 0)
@@ -100,7 +100,6 @@
__u32 flags;
__u32 token;
__u8 pad[56];
- __u32 enabled;
};
#define KVM_PV_EOI_BIT 0
#define KVM_PV_EOI_MASK (0x1 << KVM_PV_EOI_BIT)
diff --git a/libc/kernel/uapi/asm-x86/asm/processor-flags.h b/libc/kernel/uapi/asm-x86/asm/processor-flags.h
index f06fdda..9842847 100644
--- a/libc/kernel/uapi/asm-x86/asm/processor-flags.h
+++ b/libc/kernel/uapi/asm-x86/asm/processor-flags.h
@@ -123,6 +123,12 @@
#define X86_CR4_CET _BITUL(X86_CR4_CET_BIT)
#define X86_CR4_LAM_SUP_BIT 28
#define X86_CR4_LAM_SUP _BITUL(X86_CR4_LAM_SUP_BIT)
+#ifdef __x86_64__
+#define X86_CR4_FRED_BIT 32
+#define X86_CR4_FRED _BITUL(X86_CR4_FRED_BIT)
+#else
+#define X86_CR4_FRED (0)
+#endif
#define X86_CR8_TPR _AC(0x0000000f, UL)
#define CX86_PCR0 0x20
#define CX86_GCR 0xb8
diff --git a/libc/kernel/uapi/asm-x86/asm/setup_data.h b/libc/kernel/uapi/asm-x86/asm/setup_data.h
new file mode 100644
index 0000000..d00a554
--- /dev/null
+++ b/libc/kernel/uapi/asm-x86/asm/setup_data.h
@@ -0,0 +1,64 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _UAPI_ASM_X86_SETUP_DATA_H
+#define _UAPI_ASM_X86_SETUP_DATA_H
+#define SETUP_NONE 0
+#define SETUP_E820_EXT 1
+#define SETUP_DTB 2
+#define SETUP_PCI 3
+#define SETUP_EFI 4
+#define SETUP_APPLE_PROPERTIES 5
+#define SETUP_JAILHOUSE 6
+#define SETUP_CC_BLOB 7
+#define SETUP_IMA 8
+#define SETUP_RNG_SEED 9
+#define SETUP_ENUM_MAX SETUP_RNG_SEED
+#define SETUP_INDIRECT (1 << 31)
+#define SETUP_TYPE_MAX (SETUP_ENUM_MAX | SETUP_INDIRECT)
+#ifndef __ASSEMBLY__
+#include <linux/types.h>
+struct setup_data {
+ __u64 next;
+ __u32 type;
+ __u32 len;
+ __u8 data[];
+};
+struct setup_indirect {
+ __u32 type;
+ __u32 reserved;
+ __u64 len;
+ __u64 addr;
+};
+struct boot_e820_entry {
+ __u64 addr;
+ __u64 size;
+ __u32 type;
+} __attribute__((packed));
+struct jailhouse_setup_data {
+ struct {
+ __u16 version;
+ __u16 compatible_version;
+ } __attribute__((packed)) hdr;
+ struct {
+ __u16 pm_timer_address;
+ __u16 num_cpus;
+ __u64 pci_mmconfig_base;
+ __u32 tsc_khz;
+ __u32 apic_khz;
+ __u8 standard_ioapic;
+ __u8 cpu_ids[255];
+ } __attribute__((packed)) v1;
+ struct {
+ __u32 flags;
+ } __attribute__((packed)) v2;
+} __attribute__((packed));
+struct ima_setup_data {
+ __u64 addr;
+ __u64 size;
+} __attribute__((packed));
+#endif
+#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_32.h b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
index 72076fd..59c693d 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_32.h
@@ -457,4 +457,5 @@
#define __NR_lsm_get_self_attr 459
#define __NR_lsm_set_self_attr 460
#define __NR_lsm_list_modules 461
+#define __NR_mseal 462
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_64.h b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
index 8c4f76e..5dd666c 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_64.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_64.h
@@ -379,4 +379,5 @@
#define __NR_lsm_get_self_attr 459
#define __NR_lsm_set_self_attr 460
#define __NR_lsm_list_modules 461
+#define __NR_mseal 462
#endif
diff --git a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
index 984cfca..a2ff6f4 100644
--- a/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
+++ b/libc/kernel/uapi/asm-x86/asm/unistd_x32.h
@@ -323,6 +323,7 @@
#define __NR_set_mempolicy_home_node (__X32_SYSCALL_BIT + 450)
#define __NR_cachestat (__X32_SYSCALL_BIT + 451)
#define __NR_fchmodat2 (__X32_SYSCALL_BIT + 452)
+#define __NR_map_shadow_stack (__X32_SYSCALL_BIT + 453)
#define __NR_futex_wake (__X32_SYSCALL_BIT + 454)
#define __NR_futex_wait (__X32_SYSCALL_BIT + 455)
#define __NR_futex_requeue (__X32_SYSCALL_BIT + 456)
@@ -331,6 +332,7 @@
#define __NR_lsm_get_self_attr (__X32_SYSCALL_BIT + 459)
#define __NR_lsm_set_self_attr (__X32_SYSCALL_BIT + 460)
#define __NR_lsm_list_modules (__X32_SYSCALL_BIT + 461)
+#define __NR_mseal (__X32_SYSCALL_BIT + 462)
#define __NR_rt_sigaction (__X32_SYSCALL_BIT + 512)
#define __NR_rt_sigreturn (__X32_SYSCALL_BIT + 513)
#define __NR_ioctl (__X32_SYSCALL_BIT + 514)
diff --git a/libc/kernel/uapi/drm/amdgpu_drm.h b/libc/kernel/uapi/drm/amdgpu_drm.h
index 1e5b8e3..0ad0bc2 100644
--- a/libc/kernel/uapi/drm/amdgpu_drm.h
+++ b/libc/kernel/uapi/drm/amdgpu_drm.h
@@ -490,6 +490,7 @@
#define AMDGPU_INFO_SENSOR_STABLE_PSTATE_GFX_MCLK 0x9
#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_SCLK 0xa
#define AMDGPU_INFO_SENSOR_PEAK_PSTATE_GFX_MCLK 0xb
+#define AMDGPU_INFO_SENSOR_GPU_INPUT_POWER 0xc
#define AMDGPU_INFO_NUM_VRAM_CPU_PAGE_FAULTS 0x1E
#define AMDGPU_INFO_VRAM_LOST_COUNTER 0x1F
#define AMDGPU_INFO_RAS_ENABLED_FEATURES 0x20
diff --git a/libc/kernel/uapi/drm/drm_mode.h b/libc/kernel/uapi/drm/drm_mode.h
index 9e6296c..8fccdaf 100644
--- a/libc/kernel/uapi/drm/drm_mode.h
+++ b/libc/kernel/uapi/drm/drm_mode.h
@@ -366,6 +366,10 @@
__u16 blue;
__u16 reserved;
};
+struct drm_plane_size_hint {
+ __u16 width;
+ __u16 height;
+};
struct hdr_metadata_infoframe {
__u8 eotf;
__u8 metadata_type;
diff --git a/libc/kernel/uapi/drm/i915_drm.h b/libc/kernel/uapi/drm/i915_drm.h
index ccb8278..13eda7c 100644
--- a/libc/kernel/uapi/drm/i915_drm.h
+++ b/libc/kernel/uapi/drm/i915_drm.h
@@ -365,6 +365,7 @@
#define I915_PARAM_HAS_USERPTR_PROBE 56
#define I915_PARAM_OA_TIMESTAMP_FREQUENCY 57
#define I915_PARAM_PXP_STATUS 58
+#define I915_PARAM_HAS_CONTEXT_FREQ_HINT 59
struct drm_i915_getparam {
__s32 param;
int * value;
@@ -743,6 +744,7 @@
#define I915_CONTEXT_PARAM_PERSISTENCE 0xb
#define I915_CONTEXT_PARAM_RINGSIZE 0xc
#define I915_CONTEXT_PARAM_PROTECTED_CONTENT 0xd
+#define I915_CONTEXT_PARAM_LOW_LATENCY 0xe
__u64 value;
};
struct drm_i915_gem_context_param_sseu {
@@ -901,6 +903,7 @@
#define DRM_I915_QUERY_MEMORY_REGIONS 4
#define DRM_I915_QUERY_HWCONFIG_BLOB 5
#define DRM_I915_QUERY_GEOMETRY_SUBSLICES 6
+#define DRM_I915_QUERY_GUC_SUBMISSION_VERSION 7
__s32 length;
__u32 flags;
#define DRM_I915_QUERY_PERF_CONFIG_LIST 1
@@ -976,6 +979,12 @@
__u32 rsvd[3];
struct drm_i915_memory_region_info regions[];
};
+struct drm_i915_query_guc_submission_version {
+ __u32 branch;
+ __u32 major;
+ __u32 minor;
+ __u32 patch;
+};
struct drm_i915_gem_create_ext {
__u64 size;
__u32 handle;
diff --git a/libc/kernel/uapi/drm/nouveau_drm.h b/libc/kernel/uapi/drm/nouveau_drm.h
index f7d870e..01897af 100644
--- a/libc/kernel/uapi/drm/nouveau_drm.h
+++ b/libc/kernel/uapi/drm/nouveau_drm.h
@@ -25,10 +25,16 @@
#define NOUVEAU_GETPARAM_EXEC_PUSH_MAX 17
#define NOUVEAU_GETPARAM_VRAM_BAR_SIZE 18
#define NOUVEAU_GETPARAM_VRAM_USED 19
+#define NOUVEAU_GETPARAM_HAS_VMA_TILEMODE 20
struct drm_nouveau_getparam {
__u64 param;
__u64 value;
};
+#define NOUVEAU_FIFO_ENGINE_GR 0x01
+#define NOUVEAU_FIFO_ENGINE_VP 0x02
+#define NOUVEAU_FIFO_ENGINE_PPP 0x04
+#define NOUVEAU_FIFO_ENGINE_BSP 0x08
+#define NOUVEAU_FIFO_ENGINE_CE 0x30
struct drm_nouveau_channel_alloc {
__u32 fb_ctxdma_handle;
__u32 tt_ctxdma_handle;
@@ -44,6 +50,16 @@
struct drm_nouveau_channel_free {
__s32 channel;
};
+struct drm_nouveau_notifierobj_alloc {
+ __u32 channel;
+ __u32 handle;
+ __u32 size;
+ __u32 offset;
+};
+struct drm_nouveau_gpuobj_free {
+ __s32 channel;
+ __u32 handle;
+};
#define NOUVEAU_GEM_DOMAIN_CPU (1 << 0)
#define NOUVEAU_GEM_DOMAIN_VRAM (1 << 1)
#define NOUVEAU_GEM_DOMAIN_GART (1 << 2)
diff --git a/libc/kernel/uapi/drm/panthor_drm.h b/libc/kernel/uapi/drm/panthor_drm.h
new file mode 100644
index 0000000..b45c1dc
--- /dev/null
+++ b/libc/kernel/uapi/drm/panthor_drm.h
@@ -0,0 +1,240 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _PANTHOR_DRM_H_
+#define _PANTHOR_DRM_H_
+#include "drm.h"
+#ifdef __cplusplus
+extern "C" {
+#endif
+#define DRM_PANTHOR_USER_MMIO_OFFSET_32BIT (1ull << 43)
+#define DRM_PANTHOR_USER_MMIO_OFFSET_64BIT (1ull << 56)
+#define DRM_PANTHOR_USER_MMIO_OFFSET (sizeof(unsigned long) < 8 ? DRM_PANTHOR_USER_MMIO_OFFSET_32BIT : DRM_PANTHOR_USER_MMIO_OFFSET_64BIT)
+#define DRM_PANTHOR_USER_FLUSH_ID_MMIO_OFFSET (DRM_PANTHOR_USER_MMIO_OFFSET | 0)
+enum drm_panthor_ioctl_id {
+ DRM_PANTHOR_DEV_QUERY = 0,
+ DRM_PANTHOR_VM_CREATE,
+ DRM_PANTHOR_VM_DESTROY,
+ DRM_PANTHOR_VM_BIND,
+ DRM_PANTHOR_VM_GET_STATE,
+ DRM_PANTHOR_BO_CREATE,
+ DRM_PANTHOR_BO_MMAP_OFFSET,
+ DRM_PANTHOR_GROUP_CREATE,
+ DRM_PANTHOR_GROUP_DESTROY,
+ DRM_PANTHOR_GROUP_SUBMIT,
+ DRM_PANTHOR_GROUP_GET_STATE,
+ DRM_PANTHOR_TILER_HEAP_CREATE,
+ DRM_PANTHOR_TILER_HEAP_DESTROY,
+};
+#define DRM_IOCTL_PANTHOR(__access,__id,__type) DRM_IO ##__access(DRM_COMMAND_BASE + DRM_PANTHOR_ ##__id, struct drm_panthor_ ##__type)
+#define DRM_IOCTL_PANTHOR_DEV_QUERY DRM_IOCTL_PANTHOR(WR, DEV_QUERY, dev_query)
+#define DRM_IOCTL_PANTHOR_VM_CREATE DRM_IOCTL_PANTHOR(WR, VM_CREATE, vm_create)
+#define DRM_IOCTL_PANTHOR_VM_DESTROY DRM_IOCTL_PANTHOR(WR, VM_DESTROY, vm_destroy)
+#define DRM_IOCTL_PANTHOR_VM_BIND DRM_IOCTL_PANTHOR(WR, VM_BIND, vm_bind)
+#define DRM_IOCTL_PANTHOR_VM_GET_STATE DRM_IOCTL_PANTHOR(WR, VM_GET_STATE, vm_get_state)
+#define DRM_IOCTL_PANTHOR_BO_CREATE DRM_IOCTL_PANTHOR(WR, BO_CREATE, bo_create)
+#define DRM_IOCTL_PANTHOR_BO_MMAP_OFFSET DRM_IOCTL_PANTHOR(WR, BO_MMAP_OFFSET, bo_mmap_offset)
+#define DRM_IOCTL_PANTHOR_GROUP_CREATE DRM_IOCTL_PANTHOR(WR, GROUP_CREATE, group_create)
+#define DRM_IOCTL_PANTHOR_GROUP_DESTROY DRM_IOCTL_PANTHOR(WR, GROUP_DESTROY, group_destroy)
+#define DRM_IOCTL_PANTHOR_GROUP_SUBMIT DRM_IOCTL_PANTHOR(WR, GROUP_SUBMIT, group_submit)
+#define DRM_IOCTL_PANTHOR_GROUP_GET_STATE DRM_IOCTL_PANTHOR(WR, GROUP_GET_STATE, group_get_state)
+#define DRM_IOCTL_PANTHOR_TILER_HEAP_CREATE DRM_IOCTL_PANTHOR(WR, TILER_HEAP_CREATE, tiler_heap_create)
+#define DRM_IOCTL_PANTHOR_TILER_HEAP_DESTROY DRM_IOCTL_PANTHOR(WR, TILER_HEAP_DESTROY, tiler_heap_destroy)
+struct drm_panthor_obj_array {
+ __u32 stride;
+ __u32 count;
+ __u64 array;
+};
+#define DRM_PANTHOR_OBJ_ARRAY(cnt,ptr) {.stride = sizeof((ptr)[0]),.count = (cnt),.array = (__u64) (uintptr_t) (ptr) }
+enum drm_panthor_sync_op_flags {
+ DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_MASK = 0xff,
+ DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_SYNCOBJ = 0,
+ DRM_PANTHOR_SYNC_OP_HANDLE_TYPE_TIMELINE_SYNCOBJ = 1,
+ DRM_PANTHOR_SYNC_OP_WAIT = 0 << 31,
+ DRM_PANTHOR_SYNC_OP_SIGNAL = (int) (1u << 31),
+};
+struct drm_panthor_sync_op {
+ __u32 flags;
+ __u32 handle;
+ __u64 timeline_value;
+};
+enum drm_panthor_dev_query_type {
+ DRM_PANTHOR_DEV_QUERY_GPU_INFO = 0,
+ DRM_PANTHOR_DEV_QUERY_CSIF_INFO,
+};
+struct drm_panthor_gpu_info {
+ __u32 gpu_id;
+#define DRM_PANTHOR_ARCH_MAJOR(x) ((x) >> 28)
+#define DRM_PANTHOR_ARCH_MINOR(x) (((x) >> 24) & 0xf)
+#define DRM_PANTHOR_ARCH_REV(x) (((x) >> 20) & 0xf)
+#define DRM_PANTHOR_PRODUCT_MAJOR(x) (((x) >> 16) & 0xf)
+#define DRM_PANTHOR_VERSION_MAJOR(x) (((x) >> 12) & 0xf)
+#define DRM_PANTHOR_VERSION_MINOR(x) (((x) >> 4) & 0xff)
+#define DRM_PANTHOR_VERSION_STATUS(x) ((x) & 0xf)
+ __u32 gpu_rev;
+ __u32 csf_id;
+#define DRM_PANTHOR_CSHW_MAJOR(x) (((x) >> 26) & 0x3f)
+#define DRM_PANTHOR_CSHW_MINOR(x) (((x) >> 20) & 0x3f)
+#define DRM_PANTHOR_CSHW_REV(x) (((x) >> 16) & 0xf)
+#define DRM_PANTHOR_MCU_MAJOR(x) (((x) >> 10) & 0x3f)
+#define DRM_PANTHOR_MCU_MINOR(x) (((x) >> 4) & 0x3f)
+#define DRM_PANTHOR_MCU_REV(x) ((x) & 0xf)
+ __u32 l2_features;
+ __u32 tiler_features;
+ __u32 mem_features;
+ __u32 mmu_features;
+#define DRM_PANTHOR_MMU_VA_BITS(x) ((x) & 0xff)
+ __u32 thread_features;
+ __u32 max_threads;
+ __u32 thread_max_workgroup_size;
+ __u32 thread_max_barrier_size;
+ __u32 coherency_features;
+ __u32 texture_features[4];
+ __u32 as_present;
+ __u64 shader_present;
+ __u64 l2_present;
+ __u64 tiler_present;
+ __u32 core_features;
+ __u32 pad;
+};
+struct drm_panthor_csif_info {
+ __u32 csg_slot_count;
+ __u32 cs_slot_count;
+ __u32 cs_reg_count;
+ __u32 scoreboard_slot_count;
+ __u32 unpreserved_cs_reg_count;
+ __u32 pad;
+};
+struct drm_panthor_dev_query {
+ __u32 type;
+ __u32 size;
+ __u64 pointer;
+};
+struct drm_panthor_vm_create {
+ __u32 flags;
+ __u32 id;
+ __u64 user_va_range;
+};
+struct drm_panthor_vm_destroy {
+ __u32 id;
+ __u32 pad;
+};
+enum drm_panthor_vm_bind_op_flags {
+ DRM_PANTHOR_VM_BIND_OP_MAP_READONLY = 1 << 0,
+ DRM_PANTHOR_VM_BIND_OP_MAP_NOEXEC = 1 << 1,
+ DRM_PANTHOR_VM_BIND_OP_MAP_UNCACHED = 1 << 2,
+ DRM_PANTHOR_VM_BIND_OP_TYPE_MASK = (int) (0xfu << 28),
+ DRM_PANTHOR_VM_BIND_OP_TYPE_MAP = 0 << 28,
+ DRM_PANTHOR_VM_BIND_OP_TYPE_UNMAP = 1 << 28,
+ DRM_PANTHOR_VM_BIND_OP_TYPE_SYNC_ONLY = 2 << 28,
+};
+struct drm_panthor_vm_bind_op {
+ __u32 flags;
+ __u32 bo_handle;
+ __u64 bo_offset;
+ __u64 va;
+ __u64 size;
+ struct drm_panthor_obj_array syncs;
+};
+enum drm_panthor_vm_bind_flags {
+ DRM_PANTHOR_VM_BIND_ASYNC = 1 << 0,
+};
+struct drm_panthor_vm_bind {
+ __u32 vm_id;
+ __u32 flags;
+ struct drm_panthor_obj_array ops;
+};
+enum drm_panthor_vm_state {
+ DRM_PANTHOR_VM_STATE_USABLE,
+ DRM_PANTHOR_VM_STATE_UNUSABLE,
+};
+struct drm_panthor_vm_get_state {
+ __u32 vm_id;
+ __u32 state;
+};
+enum drm_panthor_bo_flags {
+ DRM_PANTHOR_BO_NO_MMAP = (1 << 0),
+};
+struct drm_panthor_bo_create {
+ __u64 size;
+ __u32 flags;
+ __u32 exclusive_vm_id;
+ __u32 handle;
+ __u32 pad;
+};
+struct drm_panthor_bo_mmap_offset {
+ __u32 handle;
+ __u32 pad;
+ __u64 offset;
+};
+struct drm_panthor_queue_create {
+ __u8 priority;
+ __u8 pad[3];
+ __u32 ringbuf_size;
+};
+enum drm_panthor_group_priority {
+ PANTHOR_GROUP_PRIORITY_LOW = 0,
+ PANTHOR_GROUP_PRIORITY_MEDIUM,
+ PANTHOR_GROUP_PRIORITY_HIGH,
+};
+struct drm_panthor_group_create {
+ struct drm_panthor_obj_array queues;
+ __u8 max_compute_cores;
+ __u8 max_fragment_cores;
+ __u8 max_tiler_cores;
+ __u8 priority;
+ __u32 pad;
+ __u64 compute_core_mask;
+ __u64 fragment_core_mask;
+ __u64 tiler_core_mask;
+ __u32 vm_id;
+ __u32 group_handle;
+};
+struct drm_panthor_group_destroy {
+ __u32 group_handle;
+ __u32 pad;
+};
+struct drm_panthor_queue_submit {
+ __u32 queue_index;
+ __u32 stream_size;
+ __u64 stream_addr;
+ __u32 latest_flush;
+ __u32 pad;
+ struct drm_panthor_obj_array syncs;
+};
+struct drm_panthor_group_submit {
+ __u32 group_handle;
+ __u32 pad;
+ struct drm_panthor_obj_array queue_submits;
+};
+enum drm_panthor_group_state_flags {
+ DRM_PANTHOR_GROUP_STATE_TIMEDOUT = 1 << 0,
+ DRM_PANTHOR_GROUP_STATE_FATAL_FAULT = 1 << 1,
+};
+struct drm_panthor_group_get_state {
+ __u32 group_handle;
+ __u32 state;
+ __u32 fatal_queues;
+ __u32 pad;
+};
+struct drm_panthor_tiler_heap_create {
+ __u32 vm_id;
+ __u32 initial_chunk_count;
+ __u32 chunk_size;
+ __u32 max_chunks;
+ __u32 target_in_flight;
+ __u32 handle;
+ __u64 tiler_heap_ctx_gpu_va;
+ __u64 first_heap_chunk_gpu_va;
+};
+struct drm_panthor_tiler_heap_destroy {
+ __u32 handle;
+ __u32 pad;
+};
+#ifdef __cplusplus
+}
+#endif
+#endif
diff --git a/libc/kernel/uapi/drm/xe_drm.h b/libc/kernel/uapi/drm/xe_drm.h
index 1e9f128..d1b6dad 100644
--- a/libc/kernel/uapi/drm/xe_drm.h
+++ b/libc/kernel/uapi/drm/xe_drm.h
@@ -105,7 +105,11 @@
__u32 reference_clock;
__u64 near_mem_regions;
__u64 far_mem_regions;
- __u64 reserved[8];
+ __u16 ip_ver_major;
+ __u16 ip_ver_minor;
+ __u16 ip_ver_rev;
+ __u16 pad2;
+ __u64 reserved[7];
};
struct drm_xe_query_gt_list {
__u32 num_gt;
@@ -114,9 +118,9 @@
};
struct drm_xe_query_topology_mask {
__u16 gt_id;
-#define DRM_XE_TOPO_DSS_GEOMETRY (1 << 0)
-#define DRM_XE_TOPO_DSS_COMPUTE (1 << 1)
-#define DRM_XE_TOPO_EU_PER_DSS (1 << 2)
+#define DRM_XE_TOPO_DSS_GEOMETRY 1
+#define DRM_XE_TOPO_DSS_COMPUTE 2
+#define DRM_XE_TOPO_EU_PER_DSS 4
__u16 type;
__u32 num_bytes;
__u8 mask[];
@@ -129,6 +133,18 @@
__u64 cpu_timestamp;
__u64 cpu_delta;
};
+struct drm_xe_query_uc_fw_version {
+#define XE_QUERY_UC_TYPE_GUC_SUBMISSION 0
+#define XE_QUERY_UC_TYPE_HUC 1
+ __u16 uc_type;
+ __u16 pad;
+ __u32 branch_ver;
+ __u32 major_ver;
+ __u32 minor_ver;
+ __u32 patch_ver;
+ __u32 pad2;
+ __u64 reserved;
+};
struct drm_xe_device_query {
__u64 extensions;
#define DRM_XE_DEVICE_QUERY_ENGINES 0
@@ -138,6 +154,7 @@
#define DRM_XE_DEVICE_QUERY_HWCONFIG 4
#define DRM_XE_DEVICE_QUERY_GT_TOPOLOGY 5
#define DRM_XE_DEVICE_QUERY_ENGINE_CYCLES 6
+#define DRM_XE_DEVICE_QUERY_UC_FW_VERSION 7
__u32 query;
__u32 size;
__u64 data;
@@ -197,6 +214,8 @@
#define DRM_XE_VM_BIND_OP_UNMAP_ALL 0x3
#define DRM_XE_VM_BIND_OP_PREFETCH 0x4
__u32 op;
+#define DRM_XE_VM_BIND_FLAG_READONLY (1 << 0)
+#define DRM_XE_VM_BIND_FLAG_IMMEDIATE (1 << 1)
#define DRM_XE_VM_BIND_FLAG_NULL (1 << 2)
#define DRM_XE_VM_BIND_FLAG_DUMPABLE (1 << 3)
__u32 flags;
diff --git a/libc/kernel/uapi/linux/auxvec.h b/libc/kernel/uapi/linux/auxvec.h
index ce02287..6dbdc75 100644
--- a/libc/kernel/uapi/linux/auxvec.h
+++ b/libc/kernel/uapi/linux/auxvec.h
@@ -31,6 +31,8 @@
#define AT_HWCAP2 26
#define AT_RSEQ_FEATURE_SIZE 27
#define AT_RSEQ_ALIGN 28
+#define AT_HWCAP3 29
+#define AT_HWCAP4 30
#define AT_EXECFN 31
#ifndef AT_MINSIGSTKSZ
#define AT_MINSIGSTKSZ 51
diff --git a/libc/kernel/uapi/linux/bits.h b/libc/kernel/uapi/linux/bits.h
new file mode 100644
index 0000000..d747e24
--- /dev/null
+++ b/libc/kernel/uapi/linux/bits.h
@@ -0,0 +1,11 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _UAPI_LINUX_BITS_H
+#define _UAPI_LINUX_BITS_H
+#define __GENMASK(h,l) (((~_UL(0)) - (_UL(1) << (l)) + 1) & (~_UL(0) >> (__BITS_PER_LONG - 1 - (h))))
+#define __GENMASK_ULL(h,l) (((~_ULL(0)) - (_ULL(1) << (l)) + 1) & (~_ULL(0) >> (__BITS_PER_LONG_LONG - 1 - (h))))
+#endif
diff --git a/libc/kernel/uapi/linux/bpf.h b/libc/kernel/uapi/linux/bpf.h
index 8f82b71..c732920 100644
--- a/libc/kernel/uapi/linux/bpf.h
+++ b/libc/kernel/uapi/linux/bpf.h
@@ -28,11 +28,15 @@
#define BPF_JSGE 0x70
#define BPF_JSLT 0xc0
#define BPF_JSLE 0xd0
+#define BPF_JCOND 0xe0
#define BPF_CALL 0x80
#define BPF_EXIT 0x90
#define BPF_FETCH 0x01
#define BPF_XCHG (0xe0 | BPF_FETCH)
#define BPF_CMPXCHG (0xf0 | BPF_FETCH)
+enum bpf_cond_pseudo_jmp {
+ BPF_MAY_GOTO = 0,
+};
enum {
BPF_REG_0 = 0,
BPF_REG_1,
@@ -59,6 +63,16 @@
__u32 prefixlen;
__u8 data[0];
};
+struct bpf_lpm_trie_key_hdr {
+ __u32 prefixlen;
+};
+struct bpf_lpm_trie_key_u8 {
+ union {
+ struct bpf_lpm_trie_key_hdr hdr;
+ __u32 prefixlen;
+ };
+ __u8 data[];
+};
struct bpf_cgroup_storage_key {
__u64 cgroup_inode_id;
__u32 attach_type;
@@ -123,6 +137,8 @@
BPF_ITER_CREATE,
BPF_LINK_DETACH,
BPF_PROG_BIND_MAP,
+ BPF_TOKEN_CREATE,
+ __MAX_BPF_CMD,
};
enum bpf_map_type {
BPF_MAP_TYPE_UNSPEC,
@@ -160,6 +176,8 @@
BPF_MAP_TYPE_BLOOM_FILTER,
BPF_MAP_TYPE_USER_RINGBUF,
BPF_MAP_TYPE_CGRP_STORAGE,
+ BPF_MAP_TYPE_ARENA,
+ __MAX_BPF_MAP_TYPE
};
enum bpf_prog_type {
BPF_PROG_TYPE_UNSPEC,
@@ -195,6 +213,7 @@
BPF_PROG_TYPE_SK_LOOKUP,
BPF_PROG_TYPE_SYSCALL,
BPF_PROG_TYPE_NETFILTER,
+ __MAX_BPF_PROG_TYPE
};
enum bpf_attach_type {
BPF_CGROUP_INET_INGRESS,
@@ -253,6 +272,7 @@
BPF_CGROUP_UNIX_GETSOCKNAME,
BPF_NETKIT_PRIMARY,
BPF_NETKIT_PEER,
+ BPF_TRACE_KPROBE_SESSION,
__MAX_BPF_ATTACH_TYPE
};
#define MAX_BPF_ATTACH_TYPE __MAX_BPF_ATTACH_TYPE
@@ -271,6 +291,7 @@
BPF_LINK_TYPE_TCX = 11,
BPF_LINK_TYPE_UPROBE_MULTI = 12,
BPF_LINK_TYPE_NETKIT = 13,
+ BPF_LINK_TYPE_SOCKMAP = 14,
__MAX_BPF_LINK_TYPE,
};
#define MAX_BPF_LINK_TYPE __MAX_BPF_LINK_TYPE
@@ -313,6 +334,9 @@
#define BPF_PSEUDO_FUNC 4
#define BPF_PSEUDO_CALL 1
#define BPF_PSEUDO_KFUNC_CALL 2
+enum bpf_addr_space_cast {
+ BPF_ADDR_SPACE_CAST = 1,
+};
enum {
BPF_ANY = 0,
BPF_NOEXIST = 1,
@@ -335,6 +359,10 @@
BPF_F_INNER_MAP = (1U << 12),
BPF_F_LINK = (1U << 13),
BPF_F_PATH_FD = (1U << 14),
+ BPF_F_VTYPE_BTF_OBJ_FD = (1U << 15),
+ BPF_F_TOKEN_FD = (1U << 16),
+ BPF_F_SEGV_ON_FAULT = (1U << 17),
+ BPF_F_NO_USER_CONV = (1U << 18),
};
#define BPF_F_QUERY_EFFECTIVE (1U << 0)
#define BPF_F_TEST_RUN_ON_CPU (1U << 0)
@@ -373,6 +401,8 @@
__u32 btf_value_type_id;
__u32 btf_vmlinux_value_type_id;
__u64 map_extra;
+ __s32 value_type_btf_obj_fd;
+ __s32 map_token_fd;
};
struct {
__u32 map_fd;
@@ -423,6 +453,7 @@
__aligned_u64 core_relos;
__u32 core_relo_rec_size;
__u32 log_true_size;
+ __s32 prog_token_fd;
};
struct {
__aligned_u64 pathname;
@@ -500,6 +531,8 @@
struct {
__u64 name;
__u32 prog_fd;
+ __u32 : 32;
+ __aligned_u64 cookie;
} raw_tracepoint;
struct {
__aligned_u64 btf;
@@ -508,6 +541,8 @@
__u32 btf_log_size;
__u32 btf_log_level;
__u32 btf_log_true_size;
+ __u32 btf_flags;
+ __s32 btf_token_fd;
};
struct {
__u32 pid;
@@ -609,6 +644,10 @@
__u32 map_fd;
__u32 flags;
} prog_bind_map;
+ struct {
+ __u32 flags;
+ __u32 bpffs_fd;
+ } token_create;
} __attribute__((aligned(8)));
#define ___BPF_FUNC_MAPPER(FN,ctx...) FN(unspec, 0, ##ctx) FN(map_lookup_elem, 1, ##ctx) FN(map_update_elem, 2, ##ctx) FN(map_delete_elem, 3, ##ctx) FN(probe_read, 4, ##ctx) FN(ktime_get_ns, 5, ##ctx) FN(trace_printk, 6, ##ctx) FN(get_prandom_u32, 7, ##ctx) FN(get_smp_processor_id, 8, ##ctx) FN(skb_store_bytes, 9, ##ctx) FN(l3_csum_replace, 10, ##ctx) FN(l4_csum_replace, 11, ##ctx) FN(tail_call, 12, ##ctx) FN(clone_redirect, 13, ##ctx) FN(get_current_pid_tgid, 14, ##ctx) FN(get_current_uid_gid, 15, ##ctx) FN(get_current_comm, 16, ##ctx) FN(get_cgroup_classid, 17, ##ctx) FN(skb_vlan_push, 18, ##ctx) FN(skb_vlan_pop, 19, ##ctx) FN(skb_get_tunnel_key, 20, ##ctx) FN(skb_set_tunnel_key, 21, ##ctx) FN(perf_event_read, 22, ##ctx) FN(redirect, 23, ##ctx) FN(get_route_realm, 24, ##ctx) FN(perf_event_output, 25, ##ctx) FN(skb_load_bytes, 26, ##ctx) FN(get_stackid, 27, ##ctx) FN(csum_diff, 28, ##ctx) FN(skb_get_tunnel_opt, 29, ##ctx) FN(skb_set_tunnel_opt, 30, ##ctx) FN(skb_change_proto, 31, ##ctx) FN(skb_change_type, 32, ##ctx) FN(skb_under_cgroup, 33, ##ctx) FN(get_hash_recalc, 34, ##ctx) FN(get_current_task, 35, ##ctx) FN(probe_write_user, 36, ##ctx) FN(current_task_under_cgroup, 37, ##ctx) FN(skb_change_tail, 38, ##ctx) FN(skb_pull_data, 39, ##ctx) FN(csum_update, 40, ##ctx) FN(set_hash_invalid, 41, ##ctx) FN(get_numa_node_id, 42, ##ctx) FN(skb_change_head, 43, ##ctx) FN(xdp_adjust_head, 44, ##ctx) FN(probe_read_str, 45, ##ctx) FN(get_socket_cookie, 46, ##ctx) FN(get_socket_uid, 47, ##ctx) FN(set_hash, 48, ##ctx) FN(setsockopt, 49, ##ctx) FN(skb_adjust_room, 50, ##ctx) FN(redirect_map, 51, ##ctx) FN(sk_redirect_map, 52, ##ctx) FN(sock_map_update, 53, ##ctx) FN(xdp_adjust_meta, 54, ##ctx) FN(perf_event_read_value, 55, ##ctx) FN(perf_prog_read_value, 56, ##ctx) FN(getsockopt, 57, ##ctx) FN(override_return, 58, ##ctx) FN(sock_ops_cb_flags_set, 59, ##ctx) FN(msg_redirect_map, 60, ##ctx) FN(msg_apply_bytes, 61, ##ctx) FN(msg_cork_bytes, 62, ##ctx) FN(msg_pull_data, 63, ##ctx) FN(bind, 64, ##ctx) FN(xdp_adjust_tail, 65, ##ctx) FN(skb_get_xfrm_state, 66, ##ctx) FN(get_stack, 67, ##ctx) FN(skb_load_bytes_relative, 68, ##ctx) FN(fib_lookup, 69, ##ctx) FN(sock_hash_update, 70, ##ctx) FN(msg_redirect_hash, 71, ##ctx) FN(sk_redirect_hash, 72, ##ctx) FN(lwt_push_encap, 73, ##ctx) FN(lwt_seg6_store_bytes, 74, ##ctx) FN(lwt_seg6_adjust_srh, 75, ##ctx) FN(lwt_seg6_action, 76, ##ctx) FN(rc_repeat, 77, ##ctx) FN(rc_keydown, 78, ##ctx) FN(skb_cgroup_id, 79, ##ctx) FN(get_current_cgroup_id, 80, ##ctx) FN(get_local_storage, 81, ##ctx) FN(sk_select_reuseport, 82, ##ctx) FN(skb_ancestor_cgroup_id, 83, ##ctx) FN(sk_lookup_tcp, 84, ##ctx) FN(sk_lookup_udp, 85, ##ctx) FN(sk_release, 86, ##ctx) FN(map_push_elem, 87, ##ctx) FN(map_pop_elem, 88, ##ctx) FN(map_peek_elem, 89, ##ctx) FN(msg_push_data, 90, ##ctx) FN(msg_pop_data, 91, ##ctx) FN(rc_pointer_rel, 92, ##ctx) FN(spin_lock, 93, ##ctx) FN(spin_unlock, 94, ##ctx) FN(sk_fullsock, 95, ##ctx) FN(tcp_sock, 96, ##ctx) FN(skb_ecn_set_ce, 97, ##ctx) FN(get_listener_sock, 98, ##ctx) FN(skc_lookup_tcp, 99, ##ctx) FN(tcp_check_syncookie, 100, ##ctx) FN(sysctl_get_name, 101, ##ctx) FN(sysctl_get_current_value, 102, ##ctx) FN(sysctl_get_new_value, 103, ##ctx) FN(sysctl_set_new_value, 104, ##ctx) FN(strtol, 105, ##ctx) FN(strtoul, 106, ##ctx) FN(sk_storage_get, 107, ##ctx) FN(sk_storage_delete, 108, ##ctx) FN(send_signal, 109, ##ctx) FN(tcp_gen_syncookie, 110, ##ctx) FN(skb_output, 111, ##ctx) FN(probe_read_user, 112, ##ctx) FN(probe_read_kernel, 113, ##ctx) FN(probe_read_user_str, 114, ##ctx) FN(probe_read_kernel_str, 115, ##ctx) FN(tcp_send_ack, 116, ##ctx) FN(send_signal_thread, 117, ##ctx) FN(jiffies64, 118, ##ctx) FN(read_branch_records, 119, ##ctx) FN(get_ns_current_pid_tgid, 120, ##ctx) FN(xdp_output, 121, ##ctx) FN(get_netns_cookie, 122, ##ctx) FN(get_current_ancestor_cgroup_id, 123, ##ctx) FN(sk_assign, 124, ##ctx) FN(ktime_get_boot_ns, 125, ##ctx) FN(seq_printf, 126, ##ctx) FN(seq_write, 127, ##ctx) FN(sk_cgroup_id, 128, ##ctx) FN(sk_ancestor_cgroup_id, 129, ##ctx) FN(ringbuf_output, 130, ##ctx) FN(ringbuf_reserve, 131, ##ctx) FN(ringbuf_submit, 132, ##ctx) FN(ringbuf_discard, 133, ##ctx) FN(ringbuf_query, 134, ##ctx) FN(csum_level, 135, ##ctx) FN(skc_to_tcp6_sock, 136, ##ctx) FN(skc_to_tcp_sock, 137, ##ctx) FN(skc_to_tcp_timewait_sock, 138, ##ctx) FN(skc_to_tcp_request_sock, 139, ##ctx) FN(skc_to_udp6_sock, 140, ##ctx) FN(get_task_stack, 141, ##ctx) FN(load_hdr_opt, 142, ##ctx) FN(store_hdr_opt, 143, ##ctx) FN(reserve_hdr_opt, 144, ##ctx) FN(inode_storage_get, 145, ##ctx) FN(inode_storage_delete, 146, ##ctx) FN(d_path, 147, ##ctx) FN(copy_from_user, 148, ##ctx) FN(snprintf_btf, 149, ##ctx) FN(seq_printf_btf, 150, ##ctx) FN(skb_cgroup_classid, 151, ##ctx) FN(redirect_neigh, 152, ##ctx) FN(per_cpu_ptr, 153, ##ctx) FN(this_cpu_ptr, 154, ##ctx) FN(redirect_peer, 155, ##ctx) FN(task_storage_get, 156, ##ctx) FN(task_storage_delete, 157, ##ctx) FN(get_current_task_btf, 158, ##ctx) FN(bprm_opts_set, 159, ##ctx) FN(ktime_get_coarse_ns, 160, ##ctx) FN(ima_inode_hash, 161, ##ctx) FN(sock_from_file, 162, ##ctx) FN(check_mtu, 163, ##ctx) FN(for_each_map_elem, 164, ##ctx) FN(snprintf, 165, ##ctx) FN(sys_bpf, 166, ##ctx) FN(btf_find_by_name_kind, 167, ##ctx) FN(sys_close, 168, ##ctx) FN(timer_init, 169, ##ctx) FN(timer_set_callback, 170, ##ctx) FN(timer_start, 171, ##ctx) FN(timer_cancel, 172, ##ctx) FN(get_func_ip, 173, ##ctx) FN(get_attach_cookie, 174, ##ctx) FN(task_pt_regs, 175, ##ctx) FN(get_branch_snapshot, 176, ##ctx) FN(trace_vprintk, 177, ##ctx) FN(skc_to_unix_sock, 178, ##ctx) FN(kallsyms_lookup_name, 179, ##ctx) FN(find_vma, 180, ##ctx) FN(loop, 181, ##ctx) FN(strncmp, 182, ##ctx) FN(get_func_arg, 183, ##ctx) FN(get_func_ret, 184, ##ctx) FN(get_func_arg_cnt, 185, ##ctx) FN(get_retval, 186, ##ctx) FN(set_retval, 187, ##ctx) FN(xdp_get_buff_len, 188, ##ctx) FN(xdp_load_bytes, 189, ##ctx) FN(xdp_store_bytes, 190, ##ctx) FN(copy_from_user_task, 191, ##ctx) FN(skb_set_tstamp, 192, ##ctx) FN(ima_file_hash, 193, ##ctx) FN(kptr_xchg, 194, ##ctx) FN(map_lookup_percpu_elem, 195, ##ctx) FN(skc_to_mptcp_sock, 196, ##ctx) FN(dynptr_from_mem, 197, ##ctx) FN(ringbuf_reserve_dynptr, 198, ##ctx) FN(ringbuf_submit_dynptr, 199, ##ctx) FN(ringbuf_discard_dynptr, 200, ##ctx) FN(dynptr_read, 201, ##ctx) FN(dynptr_write, 202, ##ctx) FN(dynptr_data, 203, ##ctx) FN(tcp_raw_gen_syncookie_ipv4, 204, ##ctx) FN(tcp_raw_gen_syncookie_ipv6, 205, ##ctx) FN(tcp_raw_check_syncookie_ipv4, 206, ##ctx) FN(tcp_raw_check_syncookie_ipv6, 207, ##ctx) FN(ktime_get_tai_ns, 208, ##ctx) FN(user_ringbuf_drain, 209, ##ctx) FN(cgrp_storage_get, 210, ##ctx) FN(cgrp_storage_delete, 211, ##ctx)
#define __BPF_FUNC_MAPPER_APPLY(name,value,FN) FN(name),
@@ -994,7 +1033,7 @@
__u32 btf_id;
__u32 btf_key_type_id;
__u32 btf_value_type_id;
- __u32 : 32;
+ __u32 btf_vmlinux_id;
__u64 map_extra;
} __attribute__((aligned(8)));
struct bpf_btf_info {
@@ -1063,6 +1102,7 @@
__u32 count;
__u32 flags;
__u64 missed;
+ __aligned_u64 cookies;
} kprobe_multi;
struct {
__aligned_u64 path;
@@ -1082,6 +1122,7 @@
__aligned_u64 file_name;
__u32 name_len;
__u32 offset;
+ __u64 cookie;
} uprobe;
struct {
__aligned_u64 func_name;
@@ -1089,14 +1130,19 @@
__u32 offset;
__u64 addr;
__u64 missed;
+ __u64 cookie;
} kprobe;
struct {
__aligned_u64 tp_name;
__u32 name_len;
+ __u32 : 32;
+ __u64 cookie;
} tracepoint;
struct {
__u64 config;
__u32 type;
+ __u32 : 32;
+ __u64 cookie;
} event;
};
} perf_event;
@@ -1108,6 +1154,10 @@
__u32 ifindex;
__u32 attach_type;
} netkit;
+ struct {
+ __u32 map_id;
+ __u32 attach_type;
+ } sockmap;
};
} __attribute__((aligned(8)));
struct bpf_sock_addr {
@@ -1257,6 +1307,7 @@
BPF_FIB_LOOKUP_SKIP_NEIGH = (1U << 2),
BPF_FIB_LOOKUP_TBID = (1U << 3),
BPF_FIB_LOOKUP_SRC = (1U << 4),
+ BPF_FIB_LOOKUP_MARK = (1U << 5),
};
enum {
BPF_FIB_LKUP_RET_SUCCESS,
@@ -1278,7 +1329,7 @@
union {
__u16 tot_len;
__u16 mtu_result;
- };
+ } __attribute__((packed, aligned(2)));
__u32 ifindex;
union {
__u8 tos;
@@ -1300,8 +1351,15 @@
};
__u32 tbid;
};
- __u8 smac[6];
- __u8 dmac[6];
+ union {
+ struct {
+ __u32 mark;
+ };
+ struct {
+ __u8 smac[6];
+ __u8 dmac[6];
+ };
+ };
};
struct bpf_redir_neigh {
__u32 nh_family;
@@ -1373,6 +1431,9 @@
struct bpf_timer {
__u64 __opaque[2];
} __attribute__((aligned(8)));
+struct bpf_wq {
+ __u64 __opaque[2];
+} __attribute__((aligned(8)));
struct bpf_dynptr {
__u64 __opaque[2];
} __attribute__((aligned(8)));
diff --git a/libc/kernel/uapi/linux/btrfs.h b/libc/kernel/uapi/linux/btrfs.h
index 5d449f8..a3ebc4f 100644
--- a/libc/kernel/uapi/linux/btrfs.h
+++ b/libc/kernel/uapi/linux/btrfs.h
@@ -45,6 +45,7 @@
__u64 rsv_excl;
};
#define BTRFS_QGROUP_INHERIT_SET_LIMITS (1ULL << 0)
+#define BTRFS_QGROUP_INHERIT_FLAGS_SUPP (BTRFS_QGROUP_INHERIT_SET_LIMITS)
struct btrfs_qgroup_inherit {
__u64 flags;
__u64 num_qgroups;
diff --git a/libc/kernel/uapi/linux/can.h b/libc/kernel/uapi/linux/can.h
index 0fc98ae..a913d73 100644
--- a/libc/kernel/uapi/linux/can.h
+++ b/libc/kernel/uapi/linux/can.h
@@ -55,6 +55,9 @@
};
#define CANXL_XLF 0x80
#define CANXL_SEC 0x01
+#define CANXL_VCID_OFFSET 16
+#define CANXL_VCID_VAL_MASK 0xFFUL
+#define CANXL_VCID_MASK (CANXL_VCID_VAL_MASK << CANXL_VCID_OFFSET)
struct canxl_frame {
canid_t prio;
__u8 flags;
diff --git a/libc/kernel/uapi/linux/can/isotp.h b/libc/kernel/uapi/linux/can/isotp.h
index cff12d6..407f6ca 100644
--- a/libc/kernel/uapi/linux/can/isotp.h
+++ b/libc/kernel/uapi/linux/can/isotp.h
@@ -45,6 +45,7 @@
#define CAN_ISOTP_WAIT_TX_DONE 0x0400
#define CAN_ISOTP_SF_BROADCAST 0x0800
#define CAN_ISOTP_CF_BROADCAST 0x1000
+#define CAN_ISOTP_DYN_FC_PARMS 0x2000
#define CAN_ISOTP_DEFAULT_FLAGS 0
#define CAN_ISOTP_DEFAULT_EXT_ADDRESS 0x00
#define CAN_ISOTP_DEFAULT_PAD_CONTENT 0xCC
diff --git a/libc/kernel/uapi/linux/can/raw.h b/libc/kernel/uapi/linux/can/raw.h
index 940a852..8e47899 100644
--- a/libc/kernel/uapi/linux/can/raw.h
+++ b/libc/kernel/uapi/linux/can/raw.h
@@ -20,5 +20,15 @@
CAN_RAW_FD_FRAMES,
CAN_RAW_JOIN_FILTERS,
CAN_RAW_XL_FRAMES,
+ CAN_RAW_XL_VCID_OPTS,
};
+struct can_raw_vcid_options {
+ __u8 flags;
+ __u8 tx_vcid;
+ __u8 rx_vcid;
+ __u8 rx_vcid_mask;
+};
+#define CAN_RAW_XL_VCID_TX_SET 0x01
+#define CAN_RAW_XL_VCID_TX_PASS 0x02
+#define CAN_RAW_XL_VCID_RX_FILTER 0x04
#endif
diff --git a/libc/kernel/uapi/linux/cxl_mem.h b/libc/kernel/uapi/linux/cxl_mem.h
index 942e817..abe6573 100644
--- a/libc/kernel/uapi/linux/cxl_mem.h
+++ b/libc/kernel/uapi/linux/cxl_mem.h
@@ -9,7 +9,7 @@
#include <linux/types.h>
#define CXL_MEM_QUERY_COMMANDS _IOR(0xCE, 1, struct cxl_mem_query_commands)
#define CXL_MEM_SEND_COMMAND _IOWR(0xCE, 2, struct cxl_send_command)
-#define CXL_CMDS ___C(INVALID, "Invalid Command"), ___C(IDENTIFY, "Identify Command"), ___C(RAW, "Raw device command"), ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), ___C(GET_FW_INFO, "Get FW Info"), ___C(GET_PARTITION_INFO, "Get Partition Information"), ___C(GET_LSA, "Get Label Storage Area"), ___C(GET_HEALTH_INFO, "Get Health Info"), ___C(GET_LOG, "Get Log"), ___C(SET_PARTITION_INFO, "Set Partition Information"), ___C(SET_LSA, "Set Label Storage Area"), ___C(GET_ALERT_CONFIG, "Get Alert Configuration"), ___C(SET_ALERT_CONFIG, "Set Alert Configuration"), ___C(GET_SHUTDOWN_STATE, "Get Shutdown State"), ___C(SET_SHUTDOWN_STATE, "Set Shutdown State"), ___DEPRECATED(GET_POISON, "Get Poison List"), ___DEPRECATED(INJECT_POISON, "Inject Poison"), ___DEPRECATED(CLEAR_POISON, "Clear Poison"), ___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"), ___DEPRECATED(SCAN_MEDIA, "Scan Media"), ___DEPRECATED(GET_SCAN_MEDIA, "Get Scan Media Results"), ___C(GET_TIMESTAMP, "Get Timestamp"), ___C(MAX, "invalid / last command")
+#define CXL_CMDS ___C(INVALID, "Invalid Command"), ___C(IDENTIFY, "Identify Command"), ___C(RAW, "Raw device command"), ___C(GET_SUPPORTED_LOGS, "Get Supported Logs"), ___C(GET_FW_INFO, "Get FW Info"), ___C(GET_PARTITION_INFO, "Get Partition Information"), ___C(GET_LSA, "Get Label Storage Area"), ___C(GET_HEALTH_INFO, "Get Health Info"), ___C(GET_LOG, "Get Log"), ___C(SET_PARTITION_INFO, "Set Partition Information"), ___C(SET_LSA, "Set Label Storage Area"), ___C(GET_ALERT_CONFIG, "Get Alert Configuration"), ___C(SET_ALERT_CONFIG, "Set Alert Configuration"), ___C(GET_SHUTDOWN_STATE, "Get Shutdown State"), ___C(SET_SHUTDOWN_STATE, "Set Shutdown State"), ___DEPRECATED(GET_POISON, "Get Poison List"), ___DEPRECATED(INJECT_POISON, "Inject Poison"), ___DEPRECATED(CLEAR_POISON, "Clear Poison"), ___C(GET_SCAN_MEDIA_CAPS, "Get Scan Media Capabilities"), ___DEPRECATED(SCAN_MEDIA, "Scan Media"), ___DEPRECATED(GET_SCAN_MEDIA, "Get Scan Media Results"), ___C(GET_TIMESTAMP, "Get Timestamp"), ___C(GET_LOG_CAPS, "Get Log Capabilities"), ___C(CLEAR_LOG, "Clear Log"), ___C(GET_SUP_LOG_SUBLIST, "Get Supported Logs Sub-List"), ___C(MAX, "invalid / last command")
#define ___C(a,b) CXL_MEM_COMMAND_ID_ ##a
#define ___DEPRECATED(a,b) CXL_MEM_DEPRECATED_ID_ ##a
enum {
diff --git a/libc/kernel/uapi/linux/devlink.h b/libc/kernel/uapi/linux/devlink.h
index 968d6be..d87c189 100644
--- a/libc/kernel/uapi/linux/devlink.h
+++ b/libc/kernel/uapi/linux/devlink.h
@@ -466,6 +466,7 @@
DEVLINK_PORT_FN_ATTR_OPSTATE,
DEVLINK_PORT_FN_ATTR_CAPS,
DEVLINK_PORT_FN_ATTR_DEVLINK,
+ DEVLINK_PORT_FN_ATTR_MAX_IO_EQS,
__DEVLINK_PORT_FUNCTION_ATTR_MAX,
DEVLINK_PORT_FUNCTION_ATTR_MAX = __DEVLINK_PORT_FUNCTION_ATTR_MAX - 1
};
diff --git a/libc/kernel/uapi/linux/dpll.h b/libc/kernel/uapi/linux/dpll.h
index cbefd15..dd692f6 100644
--- a/libc/kernel/uapi/linux/dpll.h
+++ b/libc/kernel/uapi/linux/dpll.h
@@ -22,6 +22,14 @@
__DPLL_LOCK_STATUS_MAX,
DPLL_LOCK_STATUS_MAX = (__DPLL_LOCK_STATUS_MAX - 1)
};
+enum dpll_lock_status_error {
+ DPLL_LOCK_STATUS_ERROR_NONE = 1,
+ DPLL_LOCK_STATUS_ERROR_UNDEFINED,
+ DPLL_LOCK_STATUS_ERROR_MEDIA_DOWN,
+ DPLL_LOCK_STATUS_ERROR_FRACTIONAL_FREQUENCY_OFFSET_TOO_HIGH,
+ __DPLL_LOCK_STATUS_ERROR_MAX,
+ DPLL_LOCK_STATUS_ERROR_MAX = (__DPLL_LOCK_STATUS_ERROR_MAX - 1)
+};
#define DPLL_TEMP_DIVIDER 1000
enum dpll_type {
DPLL_TYPE_PPS = 1,
@@ -71,6 +79,7 @@
DPLL_A_LOCK_STATUS,
DPLL_A_TEMP,
DPLL_A_TYPE,
+ DPLL_A_LOCK_STATUS_ERROR,
__DPLL_A_MAX,
DPLL_A_MAX = (__DPLL_A_MAX - 1)
};
diff --git a/libc/kernel/uapi/linux/dvb/frontend.h b/libc/kernel/uapi/linux/dvb/frontend.h
index 64e2cae..9428cc0 100644
--- a/libc/kernel/uapi/linux/dvb/frontend.h
+++ b/libc/kernel/uapi/linux/dvb/frontend.h
@@ -341,7 +341,7 @@
union {
__u64 uvalue;
__s64 svalue;
- };
+ } __attribute__((packed));
} __attribute__((packed));
#define MAX_DTV_STATS 4
struct dtv_fe_stats {
diff --git a/libc/kernel/uapi/linux/elf.h b/libc/kernel/uapi/linux/elf.h
index c545fdf..f1cf522 100644
--- a/libc/kernel/uapi/linux/elf.h
+++ b/libc/kernel/uapi/linux/elf.h
@@ -358,6 +358,7 @@
#define NT_ARM_SSVE 0x40b
#define NT_ARM_ZA 0x40c
#define NT_ARM_ZT 0x40d
+#define NT_ARM_FPMR 0x40e
#define NT_ARC_V2 0x600
#define NT_VMCOREDD 0x700
#define NT_MIPS_DSP 0x800
diff --git a/libc/kernel/uapi/linux/ethtool.h b/libc/kernel/uapi/linux/ethtool.h
index e3466cf..334c788 100644
--- a/libc/kernel/uapi/linux/ethtool.h
+++ b/libc/kernel/uapi/linux/ethtool.h
@@ -270,6 +270,25 @@
ETHTOOL_MODULE_POWER_MODE_LOW = 1,
ETHTOOL_MODULE_POWER_MODE_HIGH,
};
+enum ethtool_pse_types {
+ ETHTOOL_PSE_UNKNOWN = 1 << 0,
+ ETHTOOL_PSE_PODL = 1 << 1,
+ ETHTOOL_PSE_C33 = 1 << 2,
+};
+enum ethtool_c33_pse_admin_state {
+ ETHTOOL_C33_PSE_ADMIN_STATE_UNKNOWN = 1,
+ ETHTOOL_C33_PSE_ADMIN_STATE_DISABLED,
+ ETHTOOL_C33_PSE_ADMIN_STATE_ENABLED,
+};
+enum ethtool_c33_pse_pw_d_status {
+ ETHTOOL_C33_PSE_PW_D_STATUS_UNKNOWN = 1,
+ ETHTOOL_C33_PSE_PW_D_STATUS_DISABLED,
+ ETHTOOL_C33_PSE_PW_D_STATUS_SEARCHING,
+ ETHTOOL_C33_PSE_PW_D_STATUS_DELIVERING,
+ ETHTOOL_C33_PSE_PW_D_STATUS_TEST,
+ ETHTOOL_C33_PSE_PW_D_STATUS_FAULT,
+ ETHTOOL_C33_PSE_PW_D_STATUS_OTHERFAULT,
+};
enum ethtool_podl_pse_admin_state {
ETHTOOL_PODL_PSE_ADMIN_STATE_UNKNOWN = 1,
ETHTOOL_PODL_PSE_ADMIN_STATE_DISABLED,
@@ -878,6 +897,18 @@
#define IPV4_FLOW 0x10
#define IPV6_FLOW 0x11
#define ETHER_FLOW 0x12
+#define GTPU_V4_FLOW 0x13
+#define GTPU_V6_FLOW 0x14
+#define GTPC_V4_FLOW 0x15
+#define GTPC_V6_FLOW 0x16
+#define GTPC_TEID_V4_FLOW 0x17
+#define GTPC_TEID_V6_FLOW 0x18
+#define GTPU_EH_V4_FLOW 0x19
+#define GTPU_EH_V6_FLOW 0x1a
+#define GTPU_UL_V4_FLOW 0x1b
+#define GTPU_UL_V6_FLOW 0x1c
+#define GTPU_DL_V4_FLOW 0x1d
+#define GTPU_DL_V6_FLOW 0x1e
#define FLOW_EXT 0x80000000
#define FLOW_MAC_EXT 0x40000000
#define FLOW_RSS 0x20000000
@@ -888,6 +919,7 @@
#define RXH_IP_DST (1 << 5)
#define RXH_L4_B_0_1 (1 << 6)
#define RXH_L4_B_2_3 (1 << 7)
+#define RXH_GTP_TEID (1 << 8)
#define RXH_DISCARD (1 << 31)
#define RX_CLS_FLOW_DISC 0xffffffffffffffffULL
#define RX_CLS_FLOW_WAKE 0xfffffffffffffffeULL
diff --git a/libc/kernel/uapi/linux/ethtool_netlink.h b/libc/kernel/uapi/linux/ethtool_netlink.h
index e4fc40e..6757ef5 100644
--- a/libc/kernel/uapi/linux/ethtool_netlink.h
+++ b/libc/kernel/uapi/linux/ethtool_netlink.h
@@ -103,9 +103,11 @@
__ETHTOOL_MSG_KERNEL_CNT,
ETHTOOL_MSG_KERNEL_MAX = __ETHTOOL_MSG_KERNEL_CNT - 1
};
-#define ETHTOOL_FLAG_COMPACT_BITSETS (1 << 0)
-#define ETHTOOL_FLAG_OMIT_REPLY (1 << 1)
-#define ETHTOOL_FLAG_STATS (1 << 2)
+enum ethtool_header_flags {
+ ETHTOOL_FLAG_COMPACT_BITSETS = 1 << 0,
+ ETHTOOL_FLAG_OMIT_REPLY = 1 << 1,
+ ETHTOOL_FLAG_STATS = 1 << 2,
+};
#define ETHTOOL_FLAG_ALL (ETHTOOL_FLAG_COMPACT_BITSETS | ETHTOOL_FLAG_OMIT_REPLY | ETHTOOL_FLAG_STATS)
enum {
ETHTOOL_A_HEADER_UNSPEC,
@@ -355,10 +357,19 @@
ETHTOOL_A_TSINFO_TX_TYPES,
ETHTOOL_A_TSINFO_RX_FILTERS,
ETHTOOL_A_TSINFO_PHC_INDEX,
+ ETHTOOL_A_TSINFO_STATS,
__ETHTOOL_A_TSINFO_CNT,
ETHTOOL_A_TSINFO_MAX = (__ETHTOOL_A_TSINFO_CNT - 1)
};
enum {
+ ETHTOOL_A_TS_STAT_UNSPEC,
+ ETHTOOL_A_TS_STAT_TX_PKTS,
+ ETHTOOL_A_TS_STAT_TX_LOST,
+ ETHTOOL_A_TS_STAT_TX_ERR,
+ __ETHTOOL_A_TS_STAT_CNT,
+ ETHTOOL_A_TS_STAT_MAX = (__ETHTOOL_A_TS_STAT_CNT - 1)
+};
+enum {
ETHTOOL_A_PHC_VCLOCKS_UNSPEC,
ETHTOOL_A_PHC_VCLOCKS_HEADER,
ETHTOOL_A_PHC_VCLOCKS_NUM,
@@ -378,6 +389,7 @@
ETHTOOL_A_CABLE_RESULT_CODE_OPEN,
ETHTOOL_A_CABLE_RESULT_CODE_SAME_SHORT,
ETHTOOL_A_CABLE_RESULT_CODE_CROSS_SHORT,
+ ETHTOOL_A_CABLE_RESULT_CODE_IMPEDANCE_MISMATCH,
};
enum {
ETHTOOL_A_CABLE_PAIR_A,
@@ -628,6 +640,9 @@
ETHTOOL_A_PODL_PSE_ADMIN_STATE,
ETHTOOL_A_PODL_PSE_ADMIN_CONTROL,
ETHTOOL_A_PODL_PSE_PW_D_STATUS,
+ ETHTOOL_A_C33_PSE_ADMIN_STATE,
+ ETHTOOL_A_C33_PSE_ADMIN_CONTROL,
+ ETHTOOL_A_C33_PSE_PW_D_STATUS,
__ETHTOOL_A_PSE_CNT,
ETHTOOL_A_PSE_MAX = (__ETHTOOL_A_PSE_CNT - 1)
};
diff --git a/libc/kernel/uapi/linux/eventpoll.h b/libc/kernel/uapi/linux/eventpoll.h
index 3468658..7704cb3 100644
--- a/libc/kernel/uapi/linux/eventpoll.h
+++ b/libc/kernel/uapi/linux/eventpoll.h
@@ -35,4 +35,13 @@
#else
#define EPOLL_PACKED
#endif
+struct epoll_params {
+ __u32 busy_poll_usecs;
+ __u16 busy_poll_budget;
+ __u8 prefer_busy_poll;
+ __u8 __pad;
+};
+#define EPOLL_IOC_TYPE 0x8A
+#define EPIOCSPARAMS _IOW(EPOLL_IOC_TYPE, 0x01, struct epoll_params)
+#define EPIOCGPARAMS _IOR(EPOLL_IOC_TYPE, 0x02, struct epoll_params)
#endif
diff --git a/libc/kernel/uapi/linux/fb.h b/libc/kernel/uapi/linux/fb.h
index fda2b05..82f35e7 100644
--- a/libc/kernel/uapi/linux/fb.h
+++ b/libc/kernel/uapi/linux/fb.h
@@ -8,6 +8,7 @@
#define _UAPI_LINUX_FB_H
#include <linux/types.h>
#include <linux/i2c.h>
+#include <linux/vesa.h>
#define FB_MAX 32
#define FBIOGET_VSCREENINFO 0x4600
#define FBIOPUT_VSCREENINFO 0x4601
@@ -235,10 +236,6 @@
__u32 console;
__u32 framebuffer;
};
-#define VESA_NO_BLANKING 0
-#define VESA_VSYNC_SUSPEND 1
-#define VESA_HSYNC_SUSPEND 2
-#define VESA_POWERDOWN 3
enum {
FB_BLANK_UNBLANK = VESA_NO_BLANKING,
FB_BLANK_NORMAL = VESA_NO_BLANKING + 1,
diff --git a/libc/kernel/uapi/linux/fcntl.h b/libc/kernel/uapi/linux/fcntl.h
index 0e5c84d..9f32f9f 100644
--- a/libc/kernel/uapi/linux/fcntl.h
+++ b/libc/kernel/uapi/linux/fcntl.h
@@ -10,9 +10,10 @@
#include <linux/openat2.h>
#define F_SETLEASE (F_LINUX_SPECIFIC_BASE + 0)
#define F_GETLEASE (F_LINUX_SPECIFIC_BASE + 1)
+#define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2)
+#define F_DUPFD_QUERY (F_LINUX_SPECIFIC_BASE + 3)
#define F_CANCELLK (F_LINUX_SPECIFIC_BASE + 5)
#define F_DUPFD_CLOEXEC (F_LINUX_SPECIFIC_BASE + 6)
-#define F_NOTIFY (F_LINUX_SPECIFIC_BASE + 2)
#define F_SETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 7)
#define F_GETPIPE_SZ (F_LINUX_SPECIFIC_BASE + 8)
#define F_ADD_SEALS (F_LINUX_SPECIFIC_BASE + 9)
diff --git a/libc/kernel/uapi/linux/fs.h b/libc/kernel/uapi/linux/fs.h
index f1a8eac..38a2d9e 100644
--- a/libc/kernel/uapi/linux/fs.h
+++ b/libc/kernel/uapi/linux/fs.h
@@ -36,6 +36,14 @@
__u64 len;
__u64 minlen;
};
+struct fsuuid2 {
+ __u8 len;
+ __u8 uuid[16];
+};
+struct fs_sysfs_path {
+ __u8 len;
+ __u8 name[128];
+};
#define FILE_DEDUPE_RANGE_SAME 0
#define FILE_DEDUPE_RANGE_DIFFERS 1
struct file_dedupe_range_info {
@@ -141,6 +149,8 @@
#define FS_IOC_FSSETXATTR _IOW('X', 32, struct fsxattr)
#define FS_IOC_GETFSLABEL _IOR(0x94, 49, char[FSLABEL_MAX])
#define FS_IOC_SETFSLABEL _IOW(0x94, 50, char[FSLABEL_MAX])
+#define FS_IOC_GETFSUUID _IOR(0x15, 0, struct fsuuid2)
+#define FS_IOC_GETFSSYSFSPATH _IOR(0x15, 1, struct fs_sysfs_path)
#define FS_SECRM_FL 0x00000001
#define FS_UNRM_FL 0x00000002
#define FS_COMPR_FL 0x00000004
@@ -183,7 +193,8 @@
#define RWF_SYNC (( __kernel_rwf_t) 0x00000004)
#define RWF_NOWAIT (( __kernel_rwf_t) 0x00000008)
#define RWF_APPEND (( __kernel_rwf_t) 0x00000010)
-#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT | RWF_APPEND)
+#define RWF_NOAPPEND (( __kernel_rwf_t) 0x00000020)
+#define RWF_SUPPORTED (RWF_HIPRI | RWF_DSYNC | RWF_SYNC | RWF_NOWAIT | RWF_APPEND | RWF_NOAPPEND)
#define PAGEMAP_SCAN _IOWR('f', 16, struct pm_scan_arg)
#define PAGE_IS_WPALLOWED (1 << 0)
#define PAGE_IS_WRITTEN (1 << 1)
diff --git a/libc/kernel/uapi/linux/fuse.h b/libc/kernel/uapi/linux/fuse.h
index 8a7d37f..4ac2d2c 100644
--- a/libc/kernel/uapi/linux/fuse.h
+++ b/libc/kernel/uapi/linux/fuse.h
@@ -8,7 +8,7 @@
#define _LINUX_FUSE_H
#include <stdint.h>
#define FUSE_KERNEL_VERSION 7
-#define FUSE_KERNEL_MINOR_VERSION 39
+#define FUSE_KERNEL_MINOR_VERSION 40
#define FUSE_ROOT_ID 1
struct fuse_attr {
uint64_t ino;
@@ -93,6 +93,7 @@
#define FOPEN_STREAM (1 << 4)
#define FOPEN_NOFLUSH (1 << 5)
#define FOPEN_PARALLEL_DIRECT_WRITES (1 << 6)
+#define FOPEN_PASSTHROUGH (1 << 7)
#define FUSE_ASYNC_READ (1 << 0)
#define FUSE_POSIX_LOCKS (1 << 1)
#define FUSE_FILE_OPS (1 << 2)
@@ -130,12 +131,10 @@
#define FUSE_CREATE_SUPP_GROUP (1ULL << 34)
#define FUSE_HAS_EXPIRE_ONLY (1ULL << 35)
#define FUSE_DIRECT_IO_ALLOW_MMAP (1ULL << 36)
+#define FUSE_PASSTHROUGH (1ULL << 37)
+#define FUSE_NO_EXPORT_SUPPORT (1ULL << 38)
+#define FUSE_HAS_RESEND (1ULL << 39)
#define FUSE_DIRECT_IO_RELAX FUSE_DIRECT_IO_ALLOW_MMAP
-#if FUSE_KERNEL_VERSION > 7 || FUSE_KERNEL_VERSION == 7 && FUSE_KERNEL_MINOR_VERSION >= 36
-#define FUSE_PASSTHROUGH (1ULL << 63)
-#else
-#define FUSE_PASSTHROUGH (1 << 31)
-#endif
#define CUSE_UNRESTRICTED_IOCTL (1 << 0)
#define FUSE_RELEASE_FLUSH (1 << 0)
#define FUSE_RELEASE_FLOCK_UNLOCK (1 << 1)
@@ -215,7 +214,6 @@
FUSE_SYNCFS = 50,
FUSE_TMPFILE = 51,
FUSE_STATX = 52,
- FUSE_CANONICAL_PATH = 2016,
CUSE_INIT = 4096,
CUSE_INIT_BSWAP_RESERVED = 1048576,
FUSE_INIT_BSWAP_RESERVED = 436207616,
@@ -227,6 +225,7 @@
FUSE_NOTIFY_STORE = 4,
FUSE_NOTIFY_RETRIEVE = 5,
FUSE_NOTIFY_DELETE = 6,
+ FUSE_NOTIFY_RESEND = 7,
FUSE_NOTIFY_CODE_MAX,
};
#define FUSE_MIN_READ_BUFFER 8192
@@ -330,7 +329,7 @@
struct fuse_open_out {
uint64_t fh;
uint32_t open_flags;
- uint32_t passthrough_fh;
+ int32_t backing_id;
};
struct fuse_release_in {
uint64_t fh;
@@ -427,7 +426,8 @@
uint16_t max_pages;
uint16_t map_alignment;
uint32_t flags2;
- uint32_t unused[7];
+ uint32_t max_stack_depth;
+ uint32_t unused[6];
};
#define CUSE_INIT_INFO_MAX 4096
struct cuse_init_in {
@@ -496,6 +496,7 @@
uint32_t mode;
uint32_t padding;
};
+#define FUSE_UNIQUE_RESEND (1ULL << 63)
struct fuse_in_header {
uint32_t len;
uint32_t opcode;
@@ -566,9 +567,15 @@
uint64_t dummy3;
uint64_t dummy4;
};
+struct fuse_backing_map {
+ int32_t fd;
+ uint32_t flags;
+ uint64_t padding;
+};
#define FUSE_DEV_IOC_MAGIC 229
#define FUSE_DEV_IOC_CLONE _IOR(FUSE_DEV_IOC_MAGIC, 0, uint32_t)
-#define FUSE_DEV_IOC_PASSTHROUGH_OPEN _IOW(FUSE_DEV_IOC_MAGIC, 126, uint32_t)
+#define FUSE_DEV_IOC_BACKING_OPEN _IOW(FUSE_DEV_IOC_MAGIC, 1, struct fuse_backing_map)
+#define FUSE_DEV_IOC_BACKING_CLOSE _IOW(FUSE_DEV_IOC_MAGIC, 2, uint32_t)
struct fuse_lseek_in {
uint64_t fh;
uint64_t offset;
diff --git a/libc/kernel/uapi/linux/gtp.h b/libc/kernel/uapi/linux/gtp.h
index c828470..5a8cdde 100644
--- a/libc/kernel/uapi/linux/gtp.h
+++ b/libc/kernel/uapi/linux/gtp.h
@@ -31,6 +31,9 @@
GTPA_I_TEI,
GTPA_O_TEI,
GTPA_PAD,
+ GTPA_PEER_ADDR6,
+ GTPA_MS_ADDR6,
+ GTPA_FAMILY,
__GTPA_MAX,
};
#define GTPA_MAX (__GTPA_MAX - 1)
diff --git a/libc/kernel/uapi/linux/icmpv6.h b/libc/kernel/uapi/linux/icmpv6.h
index 9df18ad..a2ca922 100644
--- a/libc/kernel/uapi/linux/icmpv6.h
+++ b/libc/kernel/uapi/linux/icmpv6.h
@@ -81,6 +81,7 @@
#define ICMPV6_MOBILE_PREFIX_SOL 146
#define ICMPV6_MOBILE_PREFIX_ADV 147
#define ICMPV6_MRDISC_ADV 151
+#define ICMPV6_MRDISC_SOL 152
#define ICMPV6_MSG_MAX 255
#define ICMPV6_NOROUTE 0
#define ICMPV6_ADM_PROHIBITED 1
diff --git a/libc/kernel/uapi/linux/if_link.h b/libc/kernel/uapi/linux/if_link.h
index 19bbfa1..c2483a2 100644
--- a/libc/kernel/uapi/linux/if_link.h
+++ b/libc/kernel/uapi/linux/if_link.h
@@ -610,6 +610,8 @@
IFLA_GTP_ROLE,
IFLA_GTP_CREATE_SOCKETS,
IFLA_GTP_RESTART_COUNT,
+ IFLA_GTP_LOCAL,
+ IFLA_GTP_LOCAL6,
__IFLA_GTP_MAX,
};
#define IFLA_GTP_MAX (__IFLA_GTP_MAX - 1)
@@ -646,6 +648,7 @@
IFLA_BOND_AD_LACP_ACTIVE,
IFLA_BOND_MISSED_MAX,
IFLA_BOND_NS_IP6_TARGET,
+ IFLA_BOND_COUPLED_CONTROL,
__IFLA_BOND_MAX,
};
#define IFLA_BOND_MAX (__IFLA_BOND_MAX - 1)
@@ -844,6 +847,7 @@
IFLA_HSR_SEQ_NR,
IFLA_HSR_VERSION,
IFLA_HSR_PROTOCOL,
+ IFLA_HSR_INTERLINK,
__IFLA_HSR_MAX,
};
#define IFLA_HSR_MAX (__IFLA_HSR_MAX - 1)
diff --git a/libc/kernel/uapi/linux/if_team.h b/libc/kernel/uapi/linux/if_team.h
index b22be7e..9985f63 100644
--- a/libc/kernel/uapi/linux/if_team.h
+++ b/libc/kernel/uapi/linux/if_team.h
@@ -4,30 +4,25 @@
* See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
* for more information.
*/
-#ifndef _UAPI_LINUX_IF_TEAM_H_
-#define _UAPI_LINUX_IF_TEAM_H_
+#ifndef _UAPI_LINUX_IF_TEAM_H
+#define _UAPI_LINUX_IF_TEAM_H
+#define TEAM_GENL_NAME "team"
+#define TEAM_GENL_VERSION 1
#define TEAM_STRING_MAX_LEN 32
-enum {
- TEAM_CMD_NOOP,
- TEAM_CMD_OPTIONS_SET,
- TEAM_CMD_OPTIONS_GET,
- TEAM_CMD_PORT_LIST_GET,
- __TEAM_CMD_MAX,
- TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1),
-};
+#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event"
enum {
TEAM_ATTR_UNSPEC,
TEAM_ATTR_TEAM_IFINDEX,
TEAM_ATTR_LIST_OPTION,
TEAM_ATTR_LIST_PORT,
__TEAM_ATTR_MAX,
- TEAM_ATTR_MAX = __TEAM_ATTR_MAX - 1,
+ TEAM_ATTR_MAX = (__TEAM_ATTR_MAX - 1)
};
enum {
TEAM_ATTR_ITEM_OPTION_UNSPEC,
TEAM_ATTR_ITEM_OPTION,
__TEAM_ATTR_ITEM_OPTION_MAX,
- TEAM_ATTR_ITEM_OPTION_MAX = __TEAM_ATTR_ITEM_OPTION_MAX - 1,
+ TEAM_ATTR_ITEM_OPTION_MAX = (__TEAM_ATTR_ITEM_OPTION_MAX - 1)
};
enum {
TEAM_ATTR_OPTION_UNSPEC,
@@ -39,13 +34,13 @@
TEAM_ATTR_OPTION_PORT_IFINDEX,
TEAM_ATTR_OPTION_ARRAY_INDEX,
__TEAM_ATTR_OPTION_MAX,
- TEAM_ATTR_OPTION_MAX = __TEAM_ATTR_OPTION_MAX - 1,
+ TEAM_ATTR_OPTION_MAX = (__TEAM_ATTR_OPTION_MAX - 1)
};
enum {
TEAM_ATTR_ITEM_PORT_UNSPEC,
TEAM_ATTR_ITEM_PORT,
__TEAM_ATTR_ITEM_PORT_MAX,
- TEAM_ATTR_ITEM_PORT_MAX = __TEAM_ATTR_ITEM_PORT_MAX - 1,
+ TEAM_ATTR_ITEM_PORT_MAX = (__TEAM_ATTR_ITEM_PORT_MAX - 1)
};
enum {
TEAM_ATTR_PORT_UNSPEC,
@@ -56,9 +51,14 @@
TEAM_ATTR_PORT_DUPLEX,
TEAM_ATTR_PORT_REMOVED,
__TEAM_ATTR_PORT_MAX,
- TEAM_ATTR_PORT_MAX = __TEAM_ATTR_PORT_MAX - 1,
+ TEAM_ATTR_PORT_MAX = (__TEAM_ATTR_PORT_MAX - 1)
};
-#define TEAM_GENL_NAME "team"
-#define TEAM_GENL_VERSION 0x1
-#define TEAM_GENL_CHANGE_EVENT_MC_GRP_NAME "change_event"
+enum {
+ TEAM_CMD_NOOP,
+ TEAM_CMD_OPTIONS_SET,
+ TEAM_CMD_OPTIONS_GET,
+ TEAM_CMD_PORT_LIST_GET,
+ __TEAM_CMD_MAX,
+ TEAM_CMD_MAX = (__TEAM_CMD_MAX - 1)
+};
#endif
diff --git a/libc/kernel/uapi/linux/if_tunnel.h b/libc/kernel/uapi/linux/if_tunnel.h
index e87daf2..fa6825a 100644
--- a/libc/kernel/uapi/linux/if_tunnel.h
+++ b/libc/kernel/uapi/linux/if_tunnel.h
@@ -159,4 +159,26 @@
#define TUNNEL_ERSPAN_OPT __cpu_to_be16(0x4000)
#define TUNNEL_GTP_OPT __cpu_to_be16(0x8000)
#define TUNNEL_OPTIONS_PRESENT (TUNNEL_GENEVE_OPT | TUNNEL_VXLAN_OPT | TUNNEL_ERSPAN_OPT | TUNNEL_GTP_OPT)
+enum {
+ IP_TUNNEL_CSUM_BIT = 0U,
+ IP_TUNNEL_ROUTING_BIT,
+ IP_TUNNEL_KEY_BIT,
+ IP_TUNNEL_SEQ_BIT,
+ IP_TUNNEL_STRICT_BIT,
+ IP_TUNNEL_REC_BIT,
+ IP_TUNNEL_VERSION_BIT,
+ IP_TUNNEL_NO_KEY_BIT,
+ IP_TUNNEL_DONT_FRAGMENT_BIT,
+ IP_TUNNEL_OAM_BIT,
+ IP_TUNNEL_CRIT_OPT_BIT,
+ IP_TUNNEL_GENEVE_OPT_BIT,
+ IP_TUNNEL_VXLAN_OPT_BIT,
+ IP_TUNNEL_NOCACHE_BIT,
+ IP_TUNNEL_ERSPAN_OPT_BIT,
+ IP_TUNNEL_GTP_OPT_BIT,
+ IP_TUNNEL_VTI_BIT,
+ IP_TUNNEL_SIT_ISATAP_BIT = IP_TUNNEL_VTI_BIT,
+ IP_TUNNEL_PFCP_OPT_BIT,
+ __IP_TUNNEL_FLAG_NUM,
+};
#endif
diff --git a/libc/kernel/uapi/linux/input-event-codes.h b/libc/kernel/uapi/linux/input-event-codes.h
index 96f285b..4f93d5e 100644
--- a/libc/kernel/uapi/linux/input-event-codes.h
+++ b/libc/kernel/uapi/linux/input-event-codes.h
@@ -528,6 +528,7 @@
#define BTN_DPAD_RIGHT 0x223
#define KEY_ALS_TOGGLE 0x230
#define KEY_ROTATE_LOCK_TOGGLE 0x231
+#define KEY_REFRESH_RATE_TOGGLE 0x232
#define KEY_BUTTONCONFIG 0x240
#define KEY_TASKMANAGER 0x241
#define KEY_JOURNAL 0x242
@@ -542,6 +543,8 @@
#define KEY_CAMERA_ACCESS_ENABLE 0x24b
#define KEY_CAMERA_ACCESS_DISABLE 0x24c
#define KEY_CAMERA_ACCESS_TOGGLE 0x24d
+#define KEY_ACCESSIBILITY 0x24e
+#define KEY_DO_NOT_DISTURB 0x24f
#define KEY_BRIGHTNESS_MIN 0x250
#define KEY_BRIGHTNESS_MAX 0x251
#define KEY_KBDINPUTASSIST_PREV 0x260
diff --git a/libc/kernel/uapi/linux/io_uring.h b/libc/kernel/uapi/linux/io_uring.h
index 27675d5..5505963 100644
--- a/libc/kernel/uapi/linux/io_uring.h
+++ b/libc/kernel/uapi/linux/io_uring.h
@@ -59,6 +59,7 @@
__u32 waitid_flags;
__u32 futex_flags;
__u32 install_fd_flags;
+ __u32 nop_flags;
};
__u64 user_data;
union {
@@ -85,7 +86,7 @@
};
};
#define IORING_FILE_INDEX_ALLOC (~0U)
-enum {
+enum io_uring_sqe_flags_bit {
IOSQE_FIXED_FILE_BIT,
IOSQE_IO_DRAIN_BIT,
IOSQE_IO_LINK_BIT,
@@ -174,6 +175,7 @@
IORING_OP_FUTEX_WAKE,
IORING_OP_FUTEX_WAITV,
IORING_OP_FIXED_FD_INSTALL,
+ IORING_OP_FTRUNCATE,
IORING_OP_LAST,
};
#define IORING_URING_CMD_FIXED (1U << 0)
@@ -203,15 +205,19 @@
#define IORING_RECV_MULTISHOT (1U << 1)
#define IORING_RECVSEND_FIXED_BUF (1U << 2)
#define IORING_SEND_ZC_REPORT_USAGE (1U << 3)
+#define IORING_RECVSEND_BUNDLE (1U << 4)
#define IORING_NOTIF_USAGE_ZC_COPIED (1U << 31)
#define IORING_ACCEPT_MULTISHOT (1U << 0)
-enum {
+#define IORING_ACCEPT_DONTWAIT (1U << 1)
+#define IORING_ACCEPT_POLL_FIRST (1U << 2)
+enum io_uring_msg_ring_flags {
IORING_MSG_DATA,
IORING_MSG_SEND_FD,
};
#define IORING_MSG_RING_CQE_SKIP (1U << 0)
#define IORING_MSG_RING_FLAGS_PASS (1U << 1)
#define IORING_FIXED_FD_NO_CLOEXEC (1U << 0)
+#define IORING_NOP_INJECT_RESULT (1U << 0)
struct io_uring_cqe {
__u64 user_data;
__s32 res;
@@ -222,9 +228,7 @@
#define IORING_CQE_F_MORE (1U << 1)
#define IORING_CQE_F_SOCK_NONEMPTY (1U << 2)
#define IORING_CQE_F_NOTIF (1U << 3)
-enum {
- IORING_CQE_BUFFER_SHIFT = 16,
-};
+#define IORING_CQE_BUFFER_SHIFT 16
#define IORING_OFF_SQ_RING 0ULL
#define IORING_OFF_CQ_RING 0x8000000ULL
#define IORING_OFF_SQES 0x10000000ULL
@@ -288,7 +292,8 @@
#define IORING_FEAT_CQE_SKIP (1U << 11)
#define IORING_FEAT_LINKED_FILE (1U << 12)
#define IORING_FEAT_REG_REG_RING (1U << 13)
-enum {
+#define IORING_FEAT_RECVSEND_BUNDLE (1U << 14)
+enum io_uring_register_op {
IORING_REGISTER_BUFFERS = 0,
IORING_UNREGISTER_BUFFERS = 1,
IORING_REGISTER_FILES = 2,
@@ -316,10 +321,12 @@
IORING_REGISTER_SYNC_CANCEL = 24,
IORING_REGISTER_FILE_ALLOC_RANGE = 25,
IORING_REGISTER_PBUF_STATUS = 26,
+ IORING_REGISTER_NAPI = 27,
+ IORING_UNREGISTER_NAPI = 28,
IORING_REGISTER_LAST,
IORING_REGISTER_USE_REGISTERED_RING = 1U << 31
};
-enum {
+enum io_wq_type {
IO_WQ_BOUND,
IO_WQ_UNBOUND,
};
@@ -391,7 +398,7 @@
__DECLARE_FLEX_ARRAY(struct io_uring_buf, bufs);
};
};
-enum {
+enum io_uring_register_pbuf_ring_flags {
IOU_PBUF_RING_MMAP = 1,
};
struct io_uring_buf_reg {
@@ -406,7 +413,13 @@
__u32 head;
__u32 resv[8];
};
-enum {
+struct io_uring_napi {
+ __u32 busy_poll_to;
+ __u8 prefer_busy_poll;
+ __u8 pad[3];
+ __u64 resv;
+};
+enum io_uring_register_restriction_op {
IORING_RESTRICTION_REGISTER_OP = 0,
IORING_RESTRICTION_SQE_OP = 1,
IORING_RESTRICTION_SQE_FLAGS_ALLOWED = 2,
@@ -439,7 +452,7 @@
__u32 payloadlen;
__u32 flags;
};
-enum {
+enum io_uring_socket_op {
SOCKET_URING_OP_SIOCINQ = 0,
SOCKET_URING_OP_SIOCOUTQ,
SOCKET_URING_OP_GETSOCKOPT,
diff --git a/libc/kernel/uapi/linux/ioam6_genl.h b/libc/kernel/uapi/linux/ioam6_genl.h
index 8201bb5..216cd31 100644
--- a/libc/kernel/uapi/linux/ioam6_genl.h
+++ b/libc/kernel/uapi/linux/ioam6_genl.h
@@ -33,4 +33,18 @@
__IOAM6_CMD_MAX,
};
#define IOAM6_CMD_MAX (__IOAM6_CMD_MAX - 1)
+#define IOAM6_GENL_EV_GRP_NAME "ioam6_events"
+enum ioam6_event_type {
+ IOAM6_EVENT_UNSPEC,
+ IOAM6_EVENT_TRACE,
+};
+enum ioam6_event_attr {
+ IOAM6_EVENT_ATTR_UNSPEC,
+ IOAM6_EVENT_ATTR_TRACE_NAMESPACE,
+ IOAM6_EVENT_ATTR_TRACE_NODELEN,
+ IOAM6_EVENT_ATTR_TRACE_TYPE,
+ IOAM6_EVENT_ATTR_TRACE_DATA,
+ __IOAM6_EVENT_ATTR_MAX
+};
+#define IOAM6_EVENT_ATTR_MAX (__IOAM6_EVENT_ATTR_MAX - 1)
#endif
diff --git a/libc/kernel/uapi/linux/iommu.h b/libc/kernel/uapi/linux/iommu.h
deleted file mode 100644
index 3a7bf82..0000000
--- a/libc/kernel/uapi/linux/iommu.h
+++ /dev/null
@@ -1,76 +0,0 @@
-/*
- * This file is auto-generated. Modifications will be lost.
- *
- * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
- * for more information.
- */
-#ifndef _UAPI_IOMMU_H
-#define _UAPI_IOMMU_H
-#include <linux/types.h>
-#define IOMMU_FAULT_PERM_READ (1 << 0)
-#define IOMMU_FAULT_PERM_WRITE (1 << 1)
-#define IOMMU_FAULT_PERM_EXEC (1 << 2)
-#define IOMMU_FAULT_PERM_PRIV (1 << 3)
-enum iommu_fault_type {
- IOMMU_FAULT_DMA_UNRECOV = 1,
- IOMMU_FAULT_PAGE_REQ,
-};
-enum iommu_fault_reason {
- IOMMU_FAULT_REASON_UNKNOWN = 0,
- IOMMU_FAULT_REASON_PASID_FETCH,
- IOMMU_FAULT_REASON_BAD_PASID_ENTRY,
- IOMMU_FAULT_REASON_PASID_INVALID,
- IOMMU_FAULT_REASON_WALK_EABT,
- IOMMU_FAULT_REASON_PTE_FETCH,
- IOMMU_FAULT_REASON_PERMISSION,
- IOMMU_FAULT_REASON_ACCESS,
- IOMMU_FAULT_REASON_OOR_ADDRESS,
-};
-struct iommu_fault_unrecoverable {
- __u32 reason;
-#define IOMMU_FAULT_UNRECOV_PASID_VALID (1 << 0)
-#define IOMMU_FAULT_UNRECOV_ADDR_VALID (1 << 1)
-#define IOMMU_FAULT_UNRECOV_FETCH_ADDR_VALID (1 << 2)
- __u32 flags;
- __u32 pasid;
- __u32 perm;
- __u64 addr;
- __u64 fetch_addr;
-};
-struct iommu_fault_page_request {
-#define IOMMU_FAULT_PAGE_REQUEST_PASID_VALID (1 << 0)
-#define IOMMU_FAULT_PAGE_REQUEST_LAST_PAGE (1 << 1)
-#define IOMMU_FAULT_PAGE_REQUEST_PRIV_DATA (1 << 2)
-#define IOMMU_FAULT_PAGE_RESPONSE_NEEDS_PASID (1 << 3)
- __u32 flags;
- __u32 pasid;
- __u32 grpid;
- __u32 perm;
- __u64 addr;
- __u64 private_data[2];
-};
-struct iommu_fault {
- __u32 type;
- __u32 padding;
- union {
- struct iommu_fault_unrecoverable event;
- struct iommu_fault_page_request prm;
- __u8 padding2[56];
- };
-};
-enum iommu_page_response_code {
- IOMMU_PAGE_RESP_SUCCESS = 0,
- IOMMU_PAGE_RESP_INVALID,
- IOMMU_PAGE_RESP_FAILURE,
-};
-struct iommu_page_response {
- __u32 argsz;
-#define IOMMU_PAGE_RESP_VERSION_1 1
- __u32 version;
-#define IOMMU_PAGE_RESP_PASID_VALID (1 << 0)
- __u32 flags;
- __u32 pasid;
- __u32 grpid;
- __u32 code;
-};
-#endif
diff --git a/libc/kernel/uapi/linux/kexec.h b/libc/kernel/uapi/linux/kexec.h
index c5c8623..d34f065 100644
--- a/libc/kernel/uapi/linux/kexec.h
+++ b/libc/kernel/uapi/linux/kexec.h
@@ -10,6 +10,7 @@
#define KEXEC_ON_CRASH 0x00000001
#define KEXEC_PRESERVE_CONTEXT 0x00000002
#define KEXEC_UPDATE_ELFCOREHDR 0x00000004
+#define KEXEC_CRASH_HOTPLUG_SUPPORT 0x00000008
#define KEXEC_ARCH_MASK 0xffff0000
#define KEXEC_FILE_UNLOAD 0x00000001
#define KEXEC_FILE_ON_CRASH 0x00000002
diff --git a/libc/kernel/uapi/linux/kfd_ioctl.h b/libc/kernel/uapi/linux/kfd_ioctl.h
index 0dc806f..62c9872 100644
--- a/libc/kernel/uapi/linux/kfd_ioctl.h
+++ b/libc/kernel/uapi/linux/kfd_ioctl.h
@@ -9,7 +9,7 @@
#include <drm/drm.h>
#include <linux/ioctl.h>
#define KFD_IOCTL_MAJOR_VERSION 1
-#define KFD_IOCTL_MINOR_VERSION 14
+#define KFD_IOCTL_MINOR_VERSION 15
struct kfd_ioctl_get_version_args {
__u32 major_version;
__u32 minor_version;
@@ -497,9 +497,12 @@
#define KFD_EC_MASK_QUEUE (KFD_EC_MASK(EC_QUEUE_WAVE_ABORT) | KFD_EC_MASK(EC_QUEUE_WAVE_TRAP) | KFD_EC_MASK(EC_QUEUE_WAVE_MATH_ERROR) | KFD_EC_MASK(EC_QUEUE_WAVE_ILLEGAL_INSTRUCTION) | KFD_EC_MASK(EC_QUEUE_WAVE_MEMORY_VIOLATION) | KFD_EC_MASK(EC_QUEUE_WAVE_APERTURE_VIOLATION) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED) | KFD_EC_MASK(EC_QUEUE_PREEMPTION_ERROR) | KFD_EC_MASK(EC_QUEUE_NEW))
#define KFD_EC_MASK_DEVICE (KFD_EC_MASK(EC_DEVICE_QUEUE_DELETE) | KFD_EC_MASK(EC_DEVICE_RAS_ERROR) | KFD_EC_MASK(EC_DEVICE_FATAL_HALT) | KFD_EC_MASK(EC_DEVICE_MEMORY_VIOLATION) | KFD_EC_MASK(EC_DEVICE_NEW))
#define KFD_EC_MASK_PROCESS (KFD_EC_MASK(EC_PROCESS_RUNTIME) | KFD_EC_MASK(EC_PROCESS_DEVICE_REMOVE))
-#define KFD_DBG_EC_TYPE_IS_QUEUE(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
-#define KFD_DBG_EC_TYPE_IS_DEVICE(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
-#define KFD_DBG_EC_TYPE_IS_PROCESS(ecode) (! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
+#define KFD_EC_MASK_PACKET (KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_DIM_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_GROUP_SEGMENT_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_CODE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_RESERVED) | KFD_EC_MASK(EC_QUEUE_PACKET_UNSUPPORTED) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_WORK_GROUP_SIZE_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_DISPATCH_REGISTER_INVALID) | KFD_EC_MASK(EC_QUEUE_PACKET_VENDOR_UNSUPPORTED))
+#define KFD_DBG_EC_IS_VALID(ecode) (ecode > EC_NONE && ecode < EC_MAX)
+#define KFD_DBG_EC_TYPE_IS_QUEUE(ecode) (KFD_DBG_EC_IS_VALID(ecode) && ! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_QUEUE))
+#define KFD_DBG_EC_TYPE_IS_DEVICE(ecode) (KFD_DBG_EC_IS_VALID(ecode) && ! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_DEVICE))
+#define KFD_DBG_EC_TYPE_IS_PROCESS(ecode) (KFD_DBG_EC_IS_VALID(ecode) && ! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_PROCESS))
+#define KFD_DBG_EC_TYPE_IS_PACKET(ecode) (KFD_DBG_EC_IS_VALID(ecode) && ! ! (KFD_EC_MASK(ecode) & KFD_EC_MASK_PACKET))
enum kfd_dbg_runtime_state {
DEBUG_RUNTIME_STATE_DISABLED = 0,
DEBUG_RUNTIME_STATE_ENABLED = 1,
diff --git a/libc/kernel/uapi/linux/kvm.h b/libc/kernel/uapi/linux/kvm.h
index ea4f769..ffaf5e6 100644
--- a/libc/kernel/uapi/linux/kvm.h
+++ b/libc/kernel/uapi/linux/kvm.h
@@ -12,6 +12,7 @@
#include <linux/ioctl.h>
#include <asm/kvm.h>
#define KVM_API_VERSION 12
+#define __KVM_HAVE_GUEST_DEBUG
struct kvm_userspace_memory_region {
__u32 slot;
__u32 flags;
@@ -58,24 +59,6 @@
__u32 pad[15];
};
#define KVM_PIT_SPEAKER_DUMMY 1
-struct kvm_s390_skeys {
- __u64 start_gfn;
- __u64 count;
- __u64 skeydata_addr;
- __u32 flags;
- __u32 reserved[9];
-};
-#define KVM_S390_CMMA_PEEK (1 << 0)
-struct kvm_s390_cmma_log {
- __u64 start_gfn;
- __u32 count;
- __u32 flags;
- union {
- __u64 remaining;
- __u64 mask;
- };
- __u64 values;
-};
struct kvm_hyperv_exit {
#define KVM_EXIT_HYPERV_SYNIC 1
#define KVM_EXIT_HYPERV_HCALL 2
@@ -235,11 +218,6 @@
__u16 ipa;
__u32 ipb;
} s390_sieic;
-#define KVM_S390_RESET_POR 1
-#define KVM_S390_RESET_CLEAR 2
-#define KVM_S390_RESET_SUBSYSTEM 4
-#define KVM_S390_RESET_CPU_INIT 8
-#define KVM_S390_RESET_IPL 16
__u64 s390_reset_flags;
struct {
__u64 trans_exc_code;
@@ -389,35 +367,6 @@
__u8 usermode;
__u8 pad[5];
};
-struct kvm_s390_mem_op {
- __u64 gaddr;
- __u64 flags;
- __u32 size;
- __u32 op;
- __u64 buf;
- union {
- struct {
- __u8 ar;
- __u8 key;
- __u8 pad1[6];
- __u64 old_addr;
- };
- __u32 sida_offset;
- __u8 reserved[32];
- };
-};
-#define KVM_S390_MEMOP_LOGICAL_READ 0
-#define KVM_S390_MEMOP_LOGICAL_WRITE 1
-#define KVM_S390_MEMOP_SIDA_READ 2
-#define KVM_S390_MEMOP_SIDA_WRITE 3
-#define KVM_S390_MEMOP_ABSOLUTE_READ 4
-#define KVM_S390_MEMOP_ABSOLUTE_WRITE 5
-#define KVM_S390_MEMOP_ABSOLUTE_CMPXCHG 6
-#define KVM_S390_MEMOP_F_CHECK_ONLY (1ULL << 0)
-#define KVM_S390_MEMOP_F_INJECT_EXCEPTION (1ULL << 1)
-#define KVM_S390_MEMOP_F_SKEY_PROTECTION (1ULL << 2)
-#define KVM_S390_MEMOP_EXTENSION_CAP_BASE (1 << 0)
-#define KVM_S390_MEMOP_EXTENSION_CAP_CMPXCHG (1 << 1)
struct kvm_interrupt {
__u32 irq;
};
@@ -464,104 +413,6 @@
struct kvm_mp_state {
__u32 mp_state;
};
-struct kvm_s390_psw {
- __u64 mask;
- __u64 addr;
-};
-#define KVM_S390_SIGP_STOP 0xfffe0000u
-#define KVM_S390_PROGRAM_INT 0xfffe0001u
-#define KVM_S390_SIGP_SET_PREFIX 0xfffe0002u
-#define KVM_S390_RESTART 0xfffe0003u
-#define KVM_S390_INT_PFAULT_INIT 0xfffe0004u
-#define KVM_S390_INT_PFAULT_DONE 0xfffe0005u
-#define KVM_S390_MCHK 0xfffe1000u
-#define KVM_S390_INT_CLOCK_COMP 0xffff1004u
-#define KVM_S390_INT_CPU_TIMER 0xffff1005u
-#define KVM_S390_INT_VIRTIO 0xffff2603u
-#define KVM_S390_INT_SERVICE 0xffff2401u
-#define KVM_S390_INT_EMERGENCY 0xffff1201u
-#define KVM_S390_INT_EXTERNAL_CALL 0xffff1202u
-#define KVM_S390_INT_IO(ai,cssid,ssid,schid) (((schid)) | ((ssid) << 16) | ((cssid) << 18) | ((ai) << 26))
-#define KVM_S390_INT_IO_MIN 0x00000000u
-#define KVM_S390_INT_IO_MAX 0xfffdffffu
-#define KVM_S390_INT_IO_AI_MASK 0x04000000u
-struct kvm_s390_interrupt {
- __u32 type;
- __u32 parm;
- __u64 parm64;
-};
-struct kvm_s390_io_info {
- __u16 subchannel_id;
- __u16 subchannel_nr;
- __u32 io_int_parm;
- __u32 io_int_word;
-};
-struct kvm_s390_ext_info {
- __u32 ext_params;
- __u32 pad;
- __u64 ext_params2;
-};
-struct kvm_s390_pgm_info {
- __u64 trans_exc_code;
- __u64 mon_code;
- __u64 per_address;
- __u32 data_exc_code;
- __u16 code;
- __u16 mon_class_nr;
- __u8 per_code;
- __u8 per_atmid;
- __u8 exc_access_id;
- __u8 per_access_id;
- __u8 op_access_id;
-#define KVM_S390_PGM_FLAGS_ILC_VALID 0x01
-#define KVM_S390_PGM_FLAGS_ILC_0 0x02
-#define KVM_S390_PGM_FLAGS_ILC_1 0x04
-#define KVM_S390_PGM_FLAGS_ILC_MASK 0x06
-#define KVM_S390_PGM_FLAGS_NO_REWIND 0x08
- __u8 flags;
- __u8 pad[2];
-};
-struct kvm_s390_prefix_info {
- __u32 address;
-};
-struct kvm_s390_extcall_info {
- __u16 code;
-};
-struct kvm_s390_emerg_info {
- __u16 code;
-};
-#define KVM_S390_STOP_FLAG_STORE_STATUS 0x01
-struct kvm_s390_stop_info {
- __u32 flags;
-};
-struct kvm_s390_mchk_info {
- __u64 cr14;
- __u64 mcic;
- __u64 failing_storage_address;
- __u32 ext_damage_code;
- __u32 pad;
- __u8 fixed_logout[16];
-};
-struct kvm_s390_irq {
- __u64 type;
- union {
- struct kvm_s390_io_info io;
- struct kvm_s390_ext_info ext;
- struct kvm_s390_pgm_info pgm;
- struct kvm_s390_emerg_info emerg;
- struct kvm_s390_extcall_info extcall;
- struct kvm_s390_prefix_info prefix;
- struct kvm_s390_stop_info stop;
- struct kvm_s390_mchk_info mchk;
- char reserved[64];
- } u;
-};
-struct kvm_s390_irq_state {
- __u64 buf;
- __u32 flags;
- __u32 len;
- __u32 reserved[4];
-};
#define KVM_GUESTDBG_ENABLE 0x00000001
#define KVM_GUESTDBG_SINGLESTEP 0x00000002
struct kvm_guest_debug {
@@ -601,37 +452,6 @@
__u64 args[4];
__u8 pad[64];
};
-#define KVM_PPC_PVINFO_FLAGS_EV_IDLE (1 << 0)
-struct kvm_ppc_pvinfo {
- __u32 flags;
- __u32 hcall[4];
- __u8 pad[108];
-};
-#define KVM_PPC_PAGE_SIZES_MAX_SZ 8
-struct kvm_ppc_one_page_size {
- __u32 page_shift;
- __u32 pte_enc;
-};
-struct kvm_ppc_one_seg_page_size {
- __u32 page_shift;
- __u32 slb_enc;
- struct kvm_ppc_one_page_size enc[KVM_PPC_PAGE_SIZES_MAX_SZ];
-};
-#define KVM_PPC_PAGE_SIZES_REAL 0x00000001
-#define KVM_PPC_1T_SEGMENTS 0x00000002
-#define KVM_PPC_NO_HASH 0x00000004
-struct kvm_ppc_smmu_info {
- __u64 flags;
- __u32 slb_size;
- __u16 data_keys;
- __u16 instr_keys;
- struct kvm_ppc_one_seg_page_size sps[KVM_PPC_PAGE_SIZES_MAX_SZ];
-};
-struct kvm_ppc_resize_hpt {
- __u64 flags;
- __u32 shift;
- __u32 pad;
-};
#define KVMIO 0xAE
#define KVM_VM_S390_UCONTROL 1
#define KVM_VM_PPC_HV 1
@@ -670,9 +490,7 @@
#define KVM_CAP_IOMMU 18
#define KVM_CAP_DESTROY_MEMORY_REGION_WORKS 21
#define KVM_CAP_USER_NMI 22
-#ifdef __KVM_HAVE_GUEST_DEBUG
#define KVM_CAP_SET_GUEST_DEBUG 23
-#endif
#ifdef __KVM_HAVE_PIT
#define KVM_CAP_REINJECT_CONTROL 24
#endif
@@ -901,7 +719,6 @@
#define KVM_CAP_MEMORY_ATTRIBUTES 233
#define KVM_CAP_GUEST_MEMFD 234
#define KVM_CAP_VM_TYPES 235
-#ifdef KVM_CAP_IRQ_ROUTING
struct kvm_irq_routing_irqchip {
__u32 irqchip;
__u32 pin;
@@ -956,37 +773,6 @@
__u32 flags;
struct kvm_irq_routing_entry entries[];
};
-#endif
-#ifdef KVM_CAP_MCE
-struct kvm_x86_mce {
- __u64 status;
- __u64 addr;
- __u64 misc;
- __u64 mcg_status;
- __u8 bank;
- __u8 pad1[7];
- __u64 pad2[3];
-};
-#endif
-#ifdef KVM_CAP_XEN_HVM
-#define KVM_XEN_HVM_CONFIG_HYPERCALL_MSR (1 << 0)
-#define KVM_XEN_HVM_CONFIG_INTERCEPT_HCALL (1 << 1)
-#define KVM_XEN_HVM_CONFIG_SHARED_INFO (1 << 2)
-#define KVM_XEN_HVM_CONFIG_RUNSTATE (1 << 3)
-#define KVM_XEN_HVM_CONFIG_EVTCHN_2LEVEL (1 << 4)
-#define KVM_XEN_HVM_CONFIG_EVTCHN_SEND (1 << 5)
-#define KVM_XEN_HVM_CONFIG_RUNSTATE_UPDATE_FLAG (1 << 6)
-#define KVM_XEN_HVM_CONFIG_PVCLOCK_TSC_UNSTABLE (1 << 7)
-struct kvm_xen_hvm_config {
- __u32 flags;
- __u32 msr;
- __u64 blob_addr_32;
- __u64 blob_addr_64;
- __u8 blob_size_32;
- __u8 blob_size_64;
- __u8 pad2[30];
-};
-#endif
#define KVM_IRQFD_FLAG_DEASSIGN (1 << 0)
#define KVM_IRQFD_FLAG_RESAMPLE (1 << 1)
struct kvm_irqfd {
@@ -1118,11 +904,6 @@
#define KVM_SET_TSS_ADDR _IO(KVMIO, 0x47)
#define KVM_SET_IDENTITY_MAP_ADDR _IOW(KVMIO, 0x48, __u64)
#define KVM_SET_USER_MEMORY_REGION2 _IOW(KVMIO, 0x49, struct kvm_userspace_memory_region2)
-struct kvm_s390_ucas_mapping {
- __u64 user_addr;
- __u64 vcpu_addr;
- __u64 length;
-};
#define KVM_S390_UCAS_MAP _IOW(KVMIO, 0x50, struct kvm_s390_ucas_mapping)
#define KVM_S390_UCAS_UNMAP _IOW(KVMIO, 0x51, struct kvm_s390_ucas_mapping)
#define KVM_S390_VCPU_FAULT _IOW(KVMIO, 0x52, unsigned long)
@@ -1245,322 +1026,16 @@
#define KVM_ARM_VCPU_FINALIZE _IOW(KVMIO, 0xc2, int)
#define KVM_S390_NORMAL_RESET _IO(KVMIO, 0xc3)
#define KVM_S390_CLEAR_RESET _IO(KVMIO, 0xc4)
-struct kvm_s390_pv_sec_parm {
- __u64 origin;
- __u64 length;
-};
-struct kvm_s390_pv_unp {
- __u64 addr;
- __u64 size;
- __u64 tweak;
-};
-enum pv_cmd_dmp_id {
- KVM_PV_DUMP_INIT,
- KVM_PV_DUMP_CONFIG_STOR_STATE,
- KVM_PV_DUMP_COMPLETE,
- KVM_PV_DUMP_CPU,
-};
-struct kvm_s390_pv_dmp {
- __u64 subcmd;
- __u64 buff_addr;
- __u64 buff_len;
- __u64 gaddr;
- __u64 reserved[4];
-};
-enum pv_cmd_info_id {
- KVM_PV_INFO_VM,
- KVM_PV_INFO_DUMP,
-};
-struct kvm_s390_pv_info_dump {
- __u64 dump_cpu_buffer_len;
- __u64 dump_config_mem_buffer_per_1m;
- __u64 dump_config_finalize_len;
-};
-struct kvm_s390_pv_info_vm {
- __u64 inst_calls_list[4];
- __u64 max_cpus;
- __u64 max_guests;
- __u64 max_guest_addr;
- __u64 feature_indication;
-};
-struct kvm_s390_pv_info_header {
- __u32 id;
- __u32 len_max;
- __u32 len_written;
- __u32 reserved;
-};
-struct kvm_s390_pv_info {
- struct kvm_s390_pv_info_header header;
- union {
- struct kvm_s390_pv_info_dump dump;
- struct kvm_s390_pv_info_vm vm;
- };
-};
-enum pv_cmd_id {
- KVM_PV_ENABLE,
- KVM_PV_DISABLE,
- KVM_PV_SET_SEC_PARMS,
- KVM_PV_UNPACK,
- KVM_PV_VERIFY,
- KVM_PV_PREP_RESET,
- KVM_PV_UNSHARE_ALL,
- KVM_PV_INFO,
- KVM_PV_DUMP,
- KVM_PV_ASYNC_CLEANUP_PREPARE,
- KVM_PV_ASYNC_CLEANUP_PERFORM,
-};
-struct kvm_pv_cmd {
- __u32 cmd;
- __u16 rc;
- __u16 rrc;
- __u64 data;
- __u32 flags;
- __u32 reserved[3];
-};
#define KVM_S390_PV_COMMAND _IOWR(KVMIO, 0xc5, struct kvm_pv_cmd)
#define KVM_X86_SET_MSR_FILTER _IOW(KVMIO, 0xc6, struct kvm_msr_filter)
#define KVM_RESET_DIRTY_RINGS _IO(KVMIO, 0xc7)
#define KVM_XEN_HVM_GET_ATTR _IOWR(KVMIO, 0xc8, struct kvm_xen_hvm_attr)
#define KVM_XEN_HVM_SET_ATTR _IOW(KVMIO, 0xc9, struct kvm_xen_hvm_attr)
-struct kvm_xen_hvm_attr {
- __u16 type;
- __u16 pad[3];
- union {
- __u8 long_mode;
- __u8 vector;
- __u8 runstate_update_flag;
- struct {
- __u64 gfn;
-#define KVM_XEN_INVALID_GFN ((__u64) - 1)
- } shared_info;
- struct {
- __u32 send_port;
- __u32 type;
- __u32 flags;
-#define KVM_XEN_EVTCHN_DEASSIGN (1 << 0)
-#define KVM_XEN_EVTCHN_UPDATE (1 << 1)
-#define KVM_XEN_EVTCHN_RESET (1 << 2)
- union {
- struct {
- __u32 port;
- __u32 vcpu;
- __u32 priority;
- } port;
- struct {
- __u32 port;
- __s32 fd;
- } eventfd;
- __u32 padding[4];
- } deliver;
- } evtchn;
- __u32 xen_version;
- __u64 pad[8];
- } u;
-};
-#define KVM_XEN_ATTR_TYPE_LONG_MODE 0x0
-#define KVM_XEN_ATTR_TYPE_SHARED_INFO 0x1
-#define KVM_XEN_ATTR_TYPE_UPCALL_VECTOR 0x2
-#define KVM_XEN_ATTR_TYPE_EVTCHN 0x3
-#define KVM_XEN_ATTR_TYPE_XEN_VERSION 0x4
-#define KVM_XEN_ATTR_TYPE_RUNSTATE_UPDATE_FLAG 0x5
#define KVM_XEN_VCPU_GET_ATTR _IOWR(KVMIO, 0xca, struct kvm_xen_vcpu_attr)
#define KVM_XEN_VCPU_SET_ATTR _IOW(KVMIO, 0xcb, struct kvm_xen_vcpu_attr)
#define KVM_XEN_HVM_EVTCHN_SEND _IOW(KVMIO, 0xd0, struct kvm_irq_routing_xen_evtchn)
#define KVM_GET_SREGS2 _IOR(KVMIO, 0xcc, struct kvm_sregs2)
#define KVM_SET_SREGS2 _IOW(KVMIO, 0xcd, struct kvm_sregs2)
-struct kvm_xen_vcpu_attr {
- __u16 type;
- __u16 pad[3];
- union {
- __u64 gpa;
-#define KVM_XEN_INVALID_GPA ((__u64) - 1)
- __u64 pad[8];
- struct {
- __u64 state;
- __u64 state_entry_time;
- __u64 time_running;
- __u64 time_runnable;
- __u64 time_blocked;
- __u64 time_offline;
- } runstate;
- __u32 vcpu_id;
- struct {
- __u32 port;
- __u32 priority;
- __u64 expires_ns;
- } timer;
- __u8 vector;
- } u;
-};
-#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_INFO 0x0
-#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_TIME_INFO 0x1
-#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADDR 0x2
-#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_CURRENT 0x3
-#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_DATA 0x4
-#define KVM_XEN_VCPU_ATTR_TYPE_RUNSTATE_ADJUST 0x5
-#define KVM_XEN_VCPU_ATTR_TYPE_VCPU_ID 0x6
-#define KVM_XEN_VCPU_ATTR_TYPE_TIMER 0x7
-#define KVM_XEN_VCPU_ATTR_TYPE_UPCALL_VECTOR 0x8
-enum sev_cmd_id {
- KVM_SEV_INIT = 0,
- KVM_SEV_ES_INIT,
- KVM_SEV_LAUNCH_START,
- KVM_SEV_LAUNCH_UPDATE_DATA,
- KVM_SEV_LAUNCH_UPDATE_VMSA,
- KVM_SEV_LAUNCH_SECRET,
- KVM_SEV_LAUNCH_MEASURE,
- KVM_SEV_LAUNCH_FINISH,
- KVM_SEV_SEND_START,
- KVM_SEV_SEND_UPDATE_DATA,
- KVM_SEV_SEND_UPDATE_VMSA,
- KVM_SEV_SEND_FINISH,
- KVM_SEV_RECEIVE_START,
- KVM_SEV_RECEIVE_UPDATE_DATA,
- KVM_SEV_RECEIVE_UPDATE_VMSA,
- KVM_SEV_RECEIVE_FINISH,
- KVM_SEV_GUEST_STATUS,
- KVM_SEV_DBG_DECRYPT,
- KVM_SEV_DBG_ENCRYPT,
- KVM_SEV_CERT_EXPORT,
- KVM_SEV_GET_ATTESTATION_REPORT,
- KVM_SEV_SEND_CANCEL,
- KVM_SEV_NR_MAX,
-};
-struct kvm_sev_cmd {
- __u32 id;
- __u64 data;
- __u32 error;
- __u32 sev_fd;
-};
-struct kvm_sev_launch_start {
- __u32 handle;
- __u32 policy;
- __u64 dh_uaddr;
- __u32 dh_len;
- __u64 session_uaddr;
- __u32 session_len;
-};
-struct kvm_sev_launch_update_data {
- __u64 uaddr;
- __u32 len;
-};
-struct kvm_sev_launch_secret {
- __u64 hdr_uaddr;
- __u32 hdr_len;
- __u64 guest_uaddr;
- __u32 guest_len;
- __u64 trans_uaddr;
- __u32 trans_len;
-};
-struct kvm_sev_launch_measure {
- __u64 uaddr;
- __u32 len;
-};
-struct kvm_sev_guest_status {
- __u32 handle;
- __u32 policy;
- __u32 state;
-};
-struct kvm_sev_dbg {
- __u64 src_uaddr;
- __u64 dst_uaddr;
- __u32 len;
-};
-struct kvm_sev_attestation_report {
- __u8 mnonce[16];
- __u64 uaddr;
- __u32 len;
-};
-struct kvm_sev_send_start {
- __u32 policy;
- __u64 pdh_cert_uaddr;
- __u32 pdh_cert_len;
- __u64 plat_certs_uaddr;
- __u32 plat_certs_len;
- __u64 amd_certs_uaddr;
- __u32 amd_certs_len;
- __u64 session_uaddr;
- __u32 session_len;
-};
-struct kvm_sev_send_update_data {
- __u64 hdr_uaddr;
- __u32 hdr_len;
- __u64 guest_uaddr;
- __u32 guest_len;
- __u64 trans_uaddr;
- __u32 trans_len;
-};
-struct kvm_sev_receive_start {
- __u32 handle;
- __u32 policy;
- __u64 pdh_uaddr;
- __u32 pdh_len;
- __u64 session_uaddr;
- __u32 session_len;
-};
-struct kvm_sev_receive_update_data {
- __u64 hdr_uaddr;
- __u32 hdr_len;
- __u64 guest_uaddr;
- __u32 guest_len;
- __u64 trans_uaddr;
- __u32 trans_len;
-};
-#define KVM_DEV_ASSIGN_ENABLE_IOMMU (1 << 0)
-#define KVM_DEV_ASSIGN_PCI_2_3 (1 << 1)
-#define KVM_DEV_ASSIGN_MASK_INTX (1 << 2)
-struct kvm_assigned_pci_dev {
- __u32 assigned_dev_id;
- __u32 busnr;
- __u32 devfn;
- __u32 flags;
- __u32 segnr;
- union {
- __u32 reserved[11];
- };
-};
-#define KVM_DEV_IRQ_HOST_INTX (1 << 0)
-#define KVM_DEV_IRQ_HOST_MSI (1 << 1)
-#define KVM_DEV_IRQ_HOST_MSIX (1 << 2)
-#define KVM_DEV_IRQ_GUEST_INTX (1 << 8)
-#define KVM_DEV_IRQ_GUEST_MSI (1 << 9)
-#define KVM_DEV_IRQ_GUEST_MSIX (1 << 10)
-#define KVM_DEV_IRQ_HOST_MASK 0x00ff
-#define KVM_DEV_IRQ_GUEST_MASK 0xff00
-struct kvm_assigned_irq {
- __u32 assigned_dev_id;
- __u32 host_irq;
- __u32 guest_irq;
- __u32 flags;
- union {
- __u32 reserved[12];
- };
-};
-struct kvm_assigned_msix_nr {
- __u32 assigned_dev_id;
- __u16 entry_nr;
- __u16 padding;
-};
-#define KVM_MAX_MSIX_PER_DEV 256
-struct kvm_assigned_msix_entry {
- __u32 assigned_dev_id;
- __u32 gsi;
- __u16 entry;
- __u16 padding[3];
-};
-#define KVM_X2APIC_API_USE_32BIT_IDS (1ULL << 0)
-#define KVM_X2APIC_API_DISABLE_BROADCAST_QUIRK (1ULL << 1)
-#define KVM_ARM_DEV_EL1_VTIMER (1 << 0)
-#define KVM_ARM_DEV_EL1_PTIMER (1 << 1)
-#define KVM_ARM_DEV_PMU (1 << 2)
-struct kvm_hyperv_eventfd {
- __u32 conn_id;
- __s32 fd;
- __u32 flags;
- __u32 padding[3];
-};
-#define KVM_HYPERV_CONN_ID_MASK 0x00ffffff
-#define KVM_HYPERV_EVENTFD_DEASSIGN (1 << 0)
#define KVM_DIRTY_LOG_MANUAL_PROTECT_ENABLE (1 << 0)
#define KVM_DIRTY_LOG_INITIALLY_SET (1 << 1)
#ifndef KVM_DIRTY_LOG_PAGE_OFFSET
@@ -1620,26 +1095,6 @@
#define KVM_X86_NOTIFY_VMEXIT_ENABLED (1ULL << 0)
#define KVM_X86_NOTIFY_VMEXIT_USER (1ULL << 1)
#define KVM_S390_ZPCI_OP _IOW(KVMIO, 0xd1, struct kvm_s390_zpci_op)
-struct kvm_s390_zpci_op {
- __u32 fh;
- __u8 op;
- __u8 pad[3];
- union {
- struct {
- __u64 ibv;
- __u64 sb;
- __u32 flags;
- __u32 noi;
- __u8 isc;
- __u8 sbo;
- __u16 pad;
- } reg_aen;
- __u64 reserved[8];
- } u;
-};
-#define KVM_S390_ZPCIOP_REG_AEN 0
-#define KVM_S390_ZPCIOP_DEREG_AEN 1
-#define KVM_S390_ZPCIOP_REGAEN_HOST (1 << 0)
#define KVM_SET_MEMORY_ATTRIBUTES _IOW(KVMIO, 0xd2, struct kvm_memory_attributes)
struct kvm_memory_attributes {
__u64 address;
diff --git a/libc/kernel/uapi/linux/landlock.h b/libc/kernel/uapi/linux/landlock.h
index 75d3037..f903ae6 100644
--- a/libc/kernel/uapi/linux/landlock.h
+++ b/libc/kernel/uapi/linux/landlock.h
@@ -39,6 +39,7 @@
#define LANDLOCK_ACCESS_FS_MAKE_SYM (1ULL << 12)
#define LANDLOCK_ACCESS_FS_REFER (1ULL << 13)
#define LANDLOCK_ACCESS_FS_TRUNCATE (1ULL << 14)
+#define LANDLOCK_ACCESS_FS_IOCTL_DEV (1ULL << 15)
#define LANDLOCK_ACCESS_NET_BIND_TCP (1ULL << 0)
#define LANDLOCK_ACCESS_NET_CONNECT_TCP (1ULL << 1)
#endif
diff --git a/libc/kernel/uapi/linux/lsm.h b/libc/kernel/uapi/linux/lsm.h
index 9d538ee..3a3f152 100644
--- a/libc/kernel/uapi/linux/lsm.h
+++ b/libc/kernel/uapi/linux/lsm.h
@@ -28,6 +28,8 @@
#define LSM_ID_LOCKDOWN 108
#define LSM_ID_BPF 109
#define LSM_ID_LANDLOCK 110
+#define LSM_ID_IMA 111
+#define LSM_ID_EVM 112
#define LSM_ATTR_UNDEF 0
#define LSM_ATTR_CURRENT 100
#define LSM_ATTR_EXEC 101
diff --git a/libc/kernel/uapi/linux/magic.h b/libc/kernel/uapi/linux/magic.h
index c4d698e..5f2a2a2 100644
--- a/libc/kernel/uapi/linux/magic.h
+++ b/libc/kernel/uapi/linux/magic.h
@@ -41,6 +41,7 @@
#define HOSTFS_SUPER_MAGIC 0x00c0ffee
#define OVERLAYFS_SUPER_MAGIC 0x794c7630
#define FUSE_SUPER_MAGIC 0x65735546
+#define BCACHEFS_SUPER_MAGIC 0xca451a4e
#define MINIX_SUPER_MAGIC 0x137F
#define MINIX_SUPER_MAGIC2 0x138F
#define MINIX2_SUPER_MAGIC 0x2468
@@ -90,4 +91,5 @@
#define DMA_BUF_MAGIC 0x444d4142
#define DEVMEM_MAGIC 0x454d444d
#define SECRETMEM_MAGIC 0x5345434d
+#define PID_FS_MAGIC 0x50494446
#endif
diff --git a/libc/kernel/uapi/linux/mctp.h b/libc/kernel/uapi/linux/mctp.h
index 8920339..0057842 100644
--- a/libc/kernel/uapi/linux/mctp.h
+++ b/libc/kernel/uapi/linux/mctp.h
@@ -38,9 +38,18 @@
#define MCTP_OPT_ADDR_EXT 1
#define SIOCMCTPALLOCTAG (SIOCPROTOPRIVATE + 0)
#define SIOCMCTPDROPTAG (SIOCPROTOPRIVATE + 1)
+#define SIOCMCTPALLOCTAG2 (SIOCPROTOPRIVATE + 2)
+#define SIOCMCTPDROPTAG2 (SIOCPROTOPRIVATE + 3)
struct mctp_ioc_tag_ctl {
mctp_eid_t peer_addr;
__u8 tag;
__u16 flags;
};
+struct mctp_ioc_tag_ctl2 {
+ unsigned int net;
+ mctp_eid_t peer_addr;
+ mctp_eid_t local_addr;
+ __u16 flags;
+ __u8 tag;
+};
#endif
diff --git a/libc/kernel/uapi/linux/mdio.h b/libc/kernel/uapi/linux/mdio.h
index 7ea6a72..7b51b73 100644
--- a/libc/kernel/uapi/linux/mdio.h
+++ b/libc/kernel/uapi/linux/mdio.h
@@ -110,6 +110,8 @@
#define MDIO_PMA_SPEED_1000 0x0010
#define MDIO_PMA_SPEED_100 0x0020
#define MDIO_PMA_SPEED_10 0x0040
+#define MDIO_PMA_SPEED_2_5G 0x2000
+#define MDIO_PMA_SPEED_5G 0x4000
#define MDIO_PCS_SPEED_10P2B 0x0002
#define MDIO_PCS_SPEED_2_5G 0x0040
#define MDIO_PCS_SPEED_5G 0x0080
@@ -273,6 +275,8 @@
#define MDIO_AN_T1_ADV_L_ACK ADVERTISE_LPACK
#define MDIO_AN_T1_ADV_L_NEXT_PAGE_REQ ADVERTISE_NPAGE
#define MDIO_AN_T1_ADV_M_B10L 0x4000
+#define MDIO_AN_T1_ADV_M_1000BT1 0x0080
+#define MDIO_AN_T1_ADV_M_100BT1 0x0020
#define MDIO_AN_T1_ADV_M_MST 0x0010
#define MDIO_AN_T1_ADV_H_10L_TX_HI_REQ 0x1000
#define MDIO_AN_T1_ADV_H_10L_TX_HI 0x2000
diff --git a/libc/kernel/uapi/linux/media-bus-format.h b/libc/kernel/uapi/linux/media-bus-format.h
index 230bfbb..cb36554 100644
--- a/libc/kernel/uapi/linux/media-bus-format.h
+++ b/libc/kernel/uapi/linux/media-bus-format.h
@@ -126,4 +126,11 @@
#define MEDIA_BUS_FMT_S5C_UYVY_JPEG_1X8 0x5001
#define MEDIA_BUS_FMT_AHSV8888_1X32 0x6001
#define MEDIA_BUS_FMT_METADATA_FIXED 0x7001
+#define MEDIA_BUS_FMT_META_8 0x8001
+#define MEDIA_BUS_FMT_META_10 0x8002
+#define MEDIA_BUS_FMT_META_12 0x8003
+#define MEDIA_BUS_FMT_META_14 0x8004
+#define MEDIA_BUS_FMT_META_16 0x8005
+#define MEDIA_BUS_FMT_META_20 0x8006
+#define MEDIA_BUS_FMT_META_24 0x8007
#endif
diff --git a/libc/kernel/uapi/linux/mempolicy.h b/libc/kernel/uapi/linux/mempolicy.h
index 6cd8fd1..09ce41e 100644
--- a/libc/kernel/uapi/linux/mempolicy.h
+++ b/libc/kernel/uapi/linux/mempolicy.h
@@ -14,6 +14,7 @@
MPOL_INTERLEAVE,
MPOL_LOCAL,
MPOL_PREFERRED_MANY,
+ MPOL_WEIGHTED_INTERLEAVE,
MPOL_MAX,
};
#define MPOL_F_STATIC_NODES (1 << 15)
diff --git a/libc/kernel/uapi/linux/mptcp.h b/libc/kernel/uapi/linux/mptcp.h
index 3c9ba5e..03d3691 100644
--- a/libc/kernel/uapi/linux/mptcp.h
+++ b/libc/kernel/uapi/linux/mptcp.h
@@ -53,6 +53,10 @@
__u64 mptcpi_bytes_received;
__u64 mptcpi_bytes_acked;
__u8 mptcpi_subflows_total;
+ __u8 reserved[3];
+ __u32 mptcpi_last_data_sent;
+ __u32 mptcpi_last_data_recv;
+ __u32 mptcpi_last_ack_recv;
};
#define MPTCP_RST_EUNSPEC 0
#define MPTCP_RST_EMPTCP 1
diff --git a/libc/kernel/uapi/linux/netdev.h b/libc/kernel/uapi/linux/netdev.h
index 6d90ae4..b084297 100644
--- a/libc/kernel/uapi/linux/netdev.h
+++ b/libc/kernel/uapi/linux/netdev.h
@@ -31,6 +31,9 @@
NETDEV_QUEUE_TYPE_RX,
NETDEV_QUEUE_TYPE_TX,
};
+enum netdev_qstats_scope {
+ NETDEV_QSTATS_SCOPE_QUEUE = 1,
+};
enum {
NETDEV_A_DEV_IFINDEX = 1,
NETDEV_A_DEV_PAD,
@@ -84,6 +87,41 @@
NETDEV_A_QUEUE_MAX = (__NETDEV_A_QUEUE_MAX - 1)
};
enum {
+ NETDEV_A_QSTATS_IFINDEX = 1,
+ NETDEV_A_QSTATS_QUEUE_TYPE,
+ NETDEV_A_QSTATS_QUEUE_ID,
+ NETDEV_A_QSTATS_SCOPE,
+ NETDEV_A_QSTATS_RX_PACKETS = 8,
+ NETDEV_A_QSTATS_RX_BYTES,
+ NETDEV_A_QSTATS_TX_PACKETS,
+ NETDEV_A_QSTATS_TX_BYTES,
+ NETDEV_A_QSTATS_RX_ALLOC_FAIL,
+ NETDEV_A_QSTATS_RX_HW_DROPS,
+ NETDEV_A_QSTATS_RX_HW_DROP_OVERRUNS,
+ NETDEV_A_QSTATS_RX_CSUM_COMPLETE,
+ NETDEV_A_QSTATS_RX_CSUM_UNNECESSARY,
+ NETDEV_A_QSTATS_RX_CSUM_NONE,
+ NETDEV_A_QSTATS_RX_CSUM_BAD,
+ NETDEV_A_QSTATS_RX_HW_GRO_PACKETS,
+ NETDEV_A_QSTATS_RX_HW_GRO_BYTES,
+ NETDEV_A_QSTATS_RX_HW_GRO_WIRE_PACKETS,
+ NETDEV_A_QSTATS_RX_HW_GRO_WIRE_BYTES,
+ NETDEV_A_QSTATS_RX_HW_DROP_RATELIMITS,
+ NETDEV_A_QSTATS_TX_HW_DROPS,
+ NETDEV_A_QSTATS_TX_HW_DROP_ERRORS,
+ NETDEV_A_QSTATS_TX_CSUM_NONE,
+ NETDEV_A_QSTATS_TX_NEEDS_CSUM,
+ NETDEV_A_QSTATS_TX_HW_GSO_PACKETS,
+ NETDEV_A_QSTATS_TX_HW_GSO_BYTES,
+ NETDEV_A_QSTATS_TX_HW_GSO_WIRE_PACKETS,
+ NETDEV_A_QSTATS_TX_HW_GSO_WIRE_BYTES,
+ NETDEV_A_QSTATS_TX_HW_DROP_RATELIMITS,
+ NETDEV_A_QSTATS_TX_STOP,
+ NETDEV_A_QSTATS_TX_WAKE,
+ __NETDEV_A_QSTATS_MAX,
+ NETDEV_A_QSTATS_MAX = (__NETDEV_A_QSTATS_MAX - 1)
+};
+enum {
NETDEV_CMD_DEV_GET = 1,
NETDEV_CMD_DEV_ADD_NTF,
NETDEV_CMD_DEV_DEL_NTF,
@@ -95,6 +133,7 @@
NETDEV_CMD_PAGE_POOL_STATS_GET,
NETDEV_CMD_QUEUE_GET,
NETDEV_CMD_NAPI_GET,
+ NETDEV_CMD_QSTATS_GET,
__NETDEV_CMD_MAX,
NETDEV_CMD_MAX = (__NETDEV_CMD_MAX - 1)
};
diff --git a/libc/kernel/uapi/linux/netfilter/nf_tables.h b/libc/kernel/uapi/linux/netfilter/nf_tables.h
index 2216fa8..7922147 100644
--- a/libc/kernel/uapi/linux/netfilter/nf_tables.h
+++ b/libc/kernel/uapi/linux/netfilter/nf_tables.h
@@ -103,8 +103,9 @@
enum nft_table_flags {
NFT_TABLE_F_DORMANT = 0x1,
NFT_TABLE_F_OWNER = 0x2,
+ NFT_TABLE_F_PERSIST = 0x4,
};
-#define NFT_TABLE_F_MASK (NFT_TABLE_F_DORMANT | NFT_TABLE_F_OWNER)
+#define NFT_TABLE_F_MASK (NFT_TABLE_F_DORMANT | NFT_TABLE_F_OWNER | NFT_TABLE_F_PERSIST)
enum nft_table_attributes {
NFTA_TABLE_UNSPEC,
NFTA_TABLE_NAME,
diff --git a/libc/kernel/uapi/linux/nexthop.h b/libc/kernel/uapi/linux/nexthop.h
index ea68f62..5726a66 100644
--- a/libc/kernel/uapi/linux/nexthop.h
+++ b/libc/kernel/uapi/linux/nexthop.h
@@ -26,6 +26,8 @@
__NEXTHOP_GRP_TYPE_MAX,
};
#define NEXTHOP_GRP_TYPE_MAX (__NEXTHOP_GRP_TYPE_MAX - 1)
+#define NHA_OP_FLAG_DUMP_STATS BIT(0)
+#define NHA_OP_FLAG_DUMP_HW_STATS BIT(1)
enum {
NHA_UNSPEC,
NHA_ID,
@@ -41,6 +43,10 @@
NHA_FDB,
NHA_RES_GROUP,
NHA_RES_BUCKET,
+ NHA_OP_FLAGS,
+ NHA_GROUP_STATS,
+ NHA_HW_STATS_ENABLE,
+ NHA_HW_STATS_USED,
__NHA_MAX,
};
#define NHA_MAX (__NHA_MAX - 1)
@@ -63,4 +69,18 @@
__NHA_RES_BUCKET_MAX,
};
#define NHA_RES_BUCKET_MAX (__NHA_RES_BUCKET_MAX - 1)
+enum {
+ NHA_GROUP_STATS_UNSPEC,
+ NHA_GROUP_STATS_ENTRY,
+ __NHA_GROUP_STATS_MAX,
+};
+#define NHA_GROUP_STATS_MAX (__NHA_GROUP_STATS_MAX - 1)
+enum {
+ NHA_GROUP_STATS_ENTRY_UNSPEC,
+ NHA_GROUP_STATS_ENTRY_ID,
+ NHA_GROUP_STATS_ENTRY_PACKETS,
+ NHA_GROUP_STATS_ENTRY_PACKETS_HW,
+ __NHA_GROUP_STATS_ENTRY_MAX,
+};
+#define NHA_GROUP_STATS_ENTRY_MAX (__NHA_GROUP_STATS_ENTRY_MAX - 1)
#endif
diff --git a/libc/kernel/uapi/linux/nfs.h b/libc/kernel/uapi/linux/nfs.h
index 710e8ca..7b18f1f 100644
--- a/libc/kernel/uapi/linux/nfs.h
+++ b/libc/kernel/uapi/linux/nfs.h
@@ -47,7 +47,6 @@
NFSERR_NOSPC = 28,
NFSERR_ROFS = 30,
NFSERR_MLINK = 31,
- NFSERR_OPNOTSUPP = 45,
NFSERR_NAMETOOLONG = 63,
NFSERR_NOTEMPTY = 66,
NFSERR_DQUOT = 69,
diff --git a/libc/kernel/uapi/linux/nfsd_netlink.h b/libc/kernel/uapi/linux/nfsd_netlink.h
index dd3d570..45cb504 100644
--- a/libc/kernel/uapi/linux/nfsd_netlink.h
+++ b/libc/kernel/uapi/linux/nfsd_netlink.h
@@ -27,7 +27,44 @@
NFSD_A_RPC_STATUS_MAX = (__NFSD_A_RPC_STATUS_MAX - 1)
};
enum {
+ NFSD_A_SERVER_THREADS = 1,
+ NFSD_A_SERVER_GRACETIME,
+ NFSD_A_SERVER_LEASETIME,
+ NFSD_A_SERVER_SCOPE,
+ __NFSD_A_SERVER_MAX,
+ NFSD_A_SERVER_MAX = (__NFSD_A_SERVER_MAX - 1)
+};
+enum {
+ NFSD_A_VERSION_MAJOR = 1,
+ NFSD_A_VERSION_MINOR,
+ NFSD_A_VERSION_ENABLED,
+ __NFSD_A_VERSION_MAX,
+ NFSD_A_VERSION_MAX = (__NFSD_A_VERSION_MAX - 1)
+};
+enum {
+ NFSD_A_SERVER_PROTO_VERSION = 1,
+ __NFSD_A_SERVER_PROTO_MAX,
+ NFSD_A_SERVER_PROTO_MAX = (__NFSD_A_SERVER_PROTO_MAX - 1)
+};
+enum {
+ NFSD_A_SOCK_ADDR = 1,
+ NFSD_A_SOCK_TRANSPORT_NAME,
+ __NFSD_A_SOCK_MAX,
+ NFSD_A_SOCK_MAX = (__NFSD_A_SOCK_MAX - 1)
+};
+enum {
+ NFSD_A_SERVER_SOCK_ADDR = 1,
+ __NFSD_A_SERVER_SOCK_MAX,
+ NFSD_A_SERVER_SOCK_MAX = (__NFSD_A_SERVER_SOCK_MAX - 1)
+};
+enum {
NFSD_CMD_RPC_STATUS_GET = 1,
+ NFSD_CMD_THREADS_SET,
+ NFSD_CMD_THREADS_GET,
+ NFSD_CMD_VERSION_SET,
+ NFSD_CMD_VERSION_GET,
+ NFSD_CMD_LISTENER_SET,
+ NFSD_CMD_LISTENER_GET,
__NFSD_CMD_MAX,
NFSD_CMD_MAX = (__NFSD_CMD_MAX - 1)
};
diff --git a/libc/kernel/uapi/linux/nl80211.h b/libc/kernel/uapi/linux/nl80211.h
index 3286d9b..98180c2 100644
--- a/libc/kernel/uapi/linux/nl80211.h
+++ b/libc/kernel/uapi/linux/nl80211.h
@@ -527,6 +527,7 @@
NL80211_ATTR_BSS_DUMP_INCLUDE_USE_DATA,
NL80211_ATTR_MLO_TTLM_DLINK,
NL80211_ATTR_MLO_TTLM_ULINK,
+ NL80211_ATTR_ASSOC_SPP_AMSDU,
__NL80211_ATTR_AFTER_LAST,
NUM_NL80211_ATTR = __NL80211_ATTR_AFTER_LAST,
NL80211_ATTR_MAX = __NL80211_ATTR_AFTER_LAST - 1
@@ -602,6 +603,7 @@
NL80211_STA_FLAG_AUTHENTICATED,
NL80211_STA_FLAG_TDLS_PEER,
NL80211_STA_FLAG_ASSOCIATED,
+ NL80211_STA_FLAG_SPP_AMSDU,
__NL80211_STA_FLAG_AFTER_LAST,
NL80211_STA_FLAG_MAX = __NL80211_STA_FLAG_AFTER_LAST - 1
};
@@ -873,8 +875,9 @@
NL80211_FREQUENCY_ATTR_NO_EHT,
NL80211_FREQUENCY_ATTR_PSD,
NL80211_FREQUENCY_ATTR_DFS_CONCURRENT,
- NL80211_FREQUENCY_ATTR_NO_UHB_VLP_CLIENT,
- NL80211_FREQUENCY_ATTR_NO_UHB_AFC_CLIENT,
+ NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT,
+ NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT,
+ NL80211_FREQUENCY_ATTR_CAN_MONITOR,
__NL80211_FREQUENCY_ATTR_AFTER_LAST,
NL80211_FREQUENCY_ATTR_MAX = __NL80211_FREQUENCY_ATTR_AFTER_LAST - 1
};
@@ -883,6 +886,8 @@
#define NL80211_FREQUENCY_ATTR_NO_IBSS NL80211_FREQUENCY_ATTR_NO_IR
#define NL80211_FREQUENCY_ATTR_NO_IR NL80211_FREQUENCY_ATTR_NO_IR
#define NL80211_FREQUENCY_ATTR_GO_CONCURRENT NL80211_FREQUENCY_ATTR_IR_CONCURRENT
+#define NL80211_FREQUENCY_ATTR_NO_UHB_VLP_CLIENT NL80211_FREQUENCY_ATTR_NO_6GHZ_VLP_CLIENT
+#define NL80211_FREQUENCY_ATTR_NO_UHB_AFC_CLIENT NL80211_FREQUENCY_ATTR_NO_6GHZ_AFC_CLIENT
enum nl80211_bitrate_attr {
__NL80211_BITRATE_ATTR_INVALID,
NL80211_BITRATE_ATTR_RATE,
@@ -948,14 +953,16 @@
NL80211_RRF_NO_EHT = 1 << 19,
NL80211_RRF_PSD = 1 << 20,
NL80211_RRF_DFS_CONCURRENT = 1 << 21,
- NL80211_RRF_NO_UHB_VLP_CLIENT = 1 << 22,
- NL80211_RRF_NO_UHB_AFC_CLIENT = 1 << 23,
+ NL80211_RRF_NO_6GHZ_VLP_CLIENT = 1 << 22,
+ NL80211_RRF_NO_6GHZ_AFC_CLIENT = 1 << 23,
};
#define NL80211_RRF_PASSIVE_SCAN NL80211_RRF_NO_IR
#define NL80211_RRF_NO_IBSS NL80211_RRF_NO_IR
#define NL80211_RRF_NO_IR NL80211_RRF_NO_IR
#define NL80211_RRF_NO_HT40 (NL80211_RRF_NO_HT40MINUS | NL80211_RRF_NO_HT40PLUS)
#define NL80211_RRF_GO_CONCURRENT NL80211_RRF_IR_CONCURRENT
+#define NL80211_RRF_NO_UHB_VLP_CLIENT NL80211_RRF_NO_6GHZ_VLP_CLIENT
+#define NL80211_RRF_NO_UHB_AFC_CLIENT NL80211_RRF_NO_6GHZ_AFC_CLIENT
#define NL80211_RRF_NO_IR_ALL (NL80211_RRF_NO_IR | __NL80211_RRF_NO_IBSS)
enum nl80211_dfs_regions {
NL80211_DFS_UNSET = 0,
@@ -1120,8 +1127,9 @@
};
enum nl80211_bss_cannot_use_reasons {
NL80211_BSS_CANNOT_USE_NSTR_NONPRIMARY = 1 << 0,
- NL80211_BSS_CANNOT_USE_UHB_PWR_MISMATCH = 1 << 1,
+ NL80211_BSS_CANNOT_USE_6GHZ_PWR_MISMATCH = 1 << 1,
};
+#define NL80211_BSS_CANNOT_USE_UHB_PWR_MISMATCH NL80211_BSS_CANNOT_USE_6GHZ_PWR_MISMATCH
enum nl80211_bss {
__NL80211_BSS_INVALID,
NL80211_BSS_BSSID,
@@ -1338,6 +1346,7 @@
NL80211_WOWLAN_TRIG_WAKEUP_TCP_NOMORETOKENS,
NL80211_WOWLAN_TRIG_NET_DETECT,
NL80211_WOWLAN_TRIG_NET_DETECT_RESULTS,
+ NL80211_WOWLAN_TRIG_UNPROTECTED_DEAUTH_DISASSOC,
NUM_NL80211_WOWLAN_TRIG,
MAX_NL80211_WOWLAN_TRIG = NUM_NL80211_WOWLAN_TRIG - 1
};
@@ -1414,7 +1423,7 @@
NUM_NL80211_PLINK_STATES,
MAX_NL80211_PLINK_STATES = NUM_NL80211_PLINK_STATES - 1
};
-enum plink_actions {
+enum nl80211_plink_action {
NL80211_PLINK_ACTION_NO_ACTION,
NL80211_PLINK_ACTION_OPEN,
NL80211_PLINK_ACTION_BLOCK,
@@ -1568,6 +1577,7 @@
NL80211_EXT_FEATURE_OWE_OFFLOAD,
NL80211_EXT_FEATURE_OWE_OFFLOAD_AP,
NL80211_EXT_FEATURE_DFS_CONCURRENT,
+ NL80211_EXT_FEATURE_SPP_AMSDU_SUPPORT,
NUM_NL80211_EXT_FEATURES,
MAX_NL80211_EXT_FEATURES = NUM_NL80211_EXT_FEATURES - 1
};
diff --git a/libc/kernel/uapi/linux/ntsync.h b/libc/kernel/uapi/linux/ntsync.h
new file mode 100644
index 0000000..857b31b
--- /dev/null
+++ b/libc/kernel/uapi/linux/ntsync.h
@@ -0,0 +1,17 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef __LINUX_NTSYNC_H
+#define __LINUX_NTSYNC_H
+#include <linux/types.h>
+struct ntsync_sem_args {
+ __u32 sem;
+ __u32 count;
+ __u32 max;
+};
+#define NTSYNC_IOC_CREATE_SEM _IOWR('N', 0x80, struct ntsync_sem_args)
+#define NTSYNC_IOC_SEM_POST _IOWR('N', 0x81, __u32)
+#endif
diff --git a/libc/kernel/uapi/linux/papr_pdsm.h b/libc/kernel/uapi/linux/papr_pdsm.h
new file mode 100644
index 0000000..f466caa
--- /dev/null
+++ b/libc/kernel/uapi/linux/papr_pdsm.h
@@ -0,0 +1,64 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _UAPI_ASM_POWERPC_PAPR_PDSM_H_
+#define _UAPI_ASM_POWERPC_PAPR_PDSM_H_
+#include <linux/types.h>
+#include <linux/ndctl.h>
+#define ND_PDSM_PAYLOAD_MAX_SIZE 184
+#define ND_PDSM_HDR_SIZE (sizeof(struct nd_pkg_pdsm) - ND_PDSM_PAYLOAD_MAX_SIZE)
+#define PAPR_PDSM_DIMM_HEALTHY 0
+#define PAPR_PDSM_DIMM_UNHEALTHY 1
+#define PAPR_PDSM_DIMM_CRITICAL 2
+#define PAPR_PDSM_DIMM_FATAL 3
+#define PDSM_DIMM_HEALTH_RUN_GAUGE_VALID 1
+#define PDSM_DIMM_DSC_VALID 2
+struct nd_papr_pdsm_health {
+ union {
+ struct {
+ __u32 extension_flags;
+ __u8 dimm_unarmed;
+ __u8 dimm_bad_shutdown;
+ __u8 dimm_bad_restore;
+ __u8 dimm_scrubbed;
+ __u8 dimm_locked;
+ __u8 dimm_encrypted;
+ __u16 dimm_health;
+ __u16 dimm_fuel_gauge;
+ __u64 dimm_dsc;
+ };
+ __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
+ };
+};
+#define PDSM_SMART_INJECT_HEALTH_FATAL (1 << 0)
+#define PDSM_SMART_INJECT_BAD_SHUTDOWN (1 << 1)
+struct nd_papr_pdsm_smart_inject {
+ union {
+ struct {
+ __u32 flags;
+ __u8 fatal_enable;
+ __u8 unsafe_shutdown_enable;
+ };
+ __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
+ };
+};
+enum papr_pdsm {
+ PAPR_PDSM_MIN = 0x0,
+ PAPR_PDSM_HEALTH,
+ PAPR_PDSM_SMART_INJECT,
+ PAPR_PDSM_MAX,
+};
+union nd_pdsm_payload {
+ struct nd_papr_pdsm_health health;
+ struct nd_papr_pdsm_smart_inject smart_inject;
+ __u8 buf[ND_PDSM_PAYLOAD_MAX_SIZE];
+} __attribute__((__packed__));
+struct nd_pkg_pdsm {
+ __s32 cmd_status;
+ __u16 reserved[2];
+ union nd_pdsm_payload payload;
+} __attribute__((__packed__));
+#endif
diff --git a/libc/kernel/uapi/linux/pci_regs.h b/libc/kernel/uapi/linux/pci_regs.h
index e26392b..703d398 100644
--- a/libc/kernel/uapi/linux/pci_regs.h
+++ b/libc/kernel/uapi/linux/pci_regs.h
@@ -963,7 +963,11 @@
#define PCI_DOE_DATA_OBJECT_HEADER_1_TYPE 0x00ff0000
#define PCI_DOE_DATA_OBJECT_HEADER_2_LENGTH 0x0003ffff
#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_INDEX 0x000000ff
+#define PCI_DOE_DATA_OBJECT_DISC_REQ_3_VER 0x0000ff00
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_VID 0x0000ffff
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_PROTOCOL 0x00ff0000
#define PCI_DOE_DATA_OBJECT_DISC_RSP_3_NEXT_INDEX 0xff000000
+#define PCI_DVSEC_CXL_PORT 3
+#define PCI_DVSEC_CXL_PORT_CTL 0x0c
+#define PCI_DVSEC_CXL_PORT_CTL_UNMASK_SBR 0x00000001
#endif
diff --git a/libc/kernel/uapi/linux/pidfd.h b/libc/kernel/uapi/linux/pidfd.h
index 9a49e6a..082b4a0 100644
--- a/libc/kernel/uapi/linux/pidfd.h
+++ b/libc/kernel/uapi/linux/pidfd.h
@@ -9,4 +9,8 @@
#include <linux/types.h>
#include <linux/fcntl.h>
#define PIDFD_NONBLOCK O_NONBLOCK
+#define PIDFD_THREAD O_EXCL
+#define PIDFD_SIGNAL_THREAD (1UL << 0)
+#define PIDFD_SIGNAL_THREAD_GROUP (1UL << 1)
+#define PIDFD_SIGNAL_PROCESS_GROUP (1UL << 2)
#endif
diff --git a/libc/kernel/uapi/linux/pkt_cls.h b/libc/kernel/uapi/linux/pkt_cls.h
index b402fa6..6b5143c 100644
--- a/libc/kernel/uapi/linux/pkt_cls.h
+++ b/libc/kernel/uapi/linux/pkt_cls.h
@@ -437,6 +437,7 @@
TCA_FLOWER_KEY_ENC_OPTS_VXLAN,
TCA_FLOWER_KEY_ENC_OPTS_ERSPAN,
TCA_FLOWER_KEY_ENC_OPTS_GTP,
+ TCA_FLOWER_KEY_ENC_OPTS_PFCP,
__TCA_FLOWER_KEY_ENC_OPTS_MAX,
};
#define TCA_FLOWER_KEY_ENC_OPTS_MAX (__TCA_FLOWER_KEY_ENC_OPTS_MAX - 1)
@@ -471,6 +472,13 @@
};
#define TCA_FLOWER_KEY_ENC_OPT_GTP_MAX (__TCA_FLOWER_KEY_ENC_OPT_GTP_MAX - 1)
enum {
+ TCA_FLOWER_KEY_ENC_OPT_PFCP_UNSPEC,
+ TCA_FLOWER_KEY_ENC_OPT_PFCP_TYPE,
+ TCA_FLOWER_KEY_ENC_OPT_PFCP_SEID,
+ __TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX,
+};
+#define TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX (__TCA_FLOWER_KEY_ENC_OPT_PFCP_MAX - 1)
+enum {
TCA_FLOWER_KEY_MPLS_OPTS_UNSPEC,
TCA_FLOWER_KEY_MPLS_OPTS_LSE,
__TCA_FLOWER_KEY_MPLS_OPTS_MAX,
diff --git a/libc/kernel/uapi/linux/prctl.h b/libc/kernel/uapi/linux/prctl.h
index 48e100b..136a10f 100644
--- a/libc/kernel/uapi/linux/prctl.h
+++ b/libc/kernel/uapi/linux/prctl.h
@@ -190,4 +190,21 @@
#define PR_RISCV_V_VSTATE_CTRL_CUR_MASK 0x3
#define PR_RISCV_V_VSTATE_CTRL_NEXT_MASK 0xc
#define PR_RISCV_V_VSTATE_CTRL_MASK 0x1f
+#define PR_RISCV_SET_ICACHE_FLUSH_CTX 71
+#define PR_RISCV_CTX_SW_FENCEI_ON 0
+#define PR_RISCV_CTX_SW_FENCEI_OFF 1
+#define PR_RISCV_SCOPE_PER_PROCESS 0
+#define PR_RISCV_SCOPE_PER_THREAD 1
+#define PR_PPC_GET_DEXCR 72
+#define PR_PPC_SET_DEXCR 73
+#define PR_PPC_DEXCR_SBHE 0
+#define PR_PPC_DEXCR_IBRTPD 1
+#define PR_PPC_DEXCR_SRAPD 2
+#define PR_PPC_DEXCR_NPHIE 3
+#define PR_PPC_DEXCR_CTRL_EDITABLE 0x1
+#define PR_PPC_DEXCR_CTRL_SET 0x2
+#define PR_PPC_DEXCR_CTRL_CLEAR 0x4
+#define PR_PPC_DEXCR_CTRL_SET_ONEXEC 0x8
+#define PR_PPC_DEXCR_CTRL_CLEAR_ONEXEC 0x10
+#define PR_PPC_DEXCR_CTRL_MASK 0x1f
#endif
diff --git a/libc/kernel/uapi/linux/psp-sev.h b/libc/kernel/uapi/linux/psp-sev.h
index ffbcf82..82fcbf1 100644
--- a/libc/kernel/uapi/linux/psp-sev.h
+++ b/libc/kernel/uapi/linux/psp-sev.h
@@ -17,6 +17,9 @@
SEV_PEK_CERT_IMPORT,
SEV_GET_ID,
SEV_GET_ID2,
+ SNP_PLATFORM_STATUS,
+ SNP_COMMIT,
+ SNP_SET_CONFIG,
SEV_MAX,
};
typedef enum {
@@ -47,6 +50,12 @@
SEV_RET_RESOURCE_LIMIT,
SEV_RET_SECURE_DATA_INVALID,
SEV_RET_INVALID_KEY = 0x27,
+ SEV_RET_INVALID_PAGE_SIZE,
+ SEV_RET_INVALID_PAGE_STATE,
+ SEV_RET_INVALID_MDATA_ENTRY,
+ SEV_RET_INVALID_PAGE_OWNER,
+ SEV_RET_INVALID_PAGE_AEAD_OFLOW,
+ SEV_RET_RMP_INIT_REQUIRED,
SEV_RET_MAX,
} sev_ret_code;
struct sev_user_data_status {
@@ -82,6 +91,28 @@
__u64 address;
__u32 length;
} __attribute__((__packed__));
+struct sev_user_data_snp_status {
+ __u8 api_major;
+ __u8 api_minor;
+ __u8 state;
+ __u8 is_rmp_initialized : 1;
+ __u8 rsvd : 7;
+ __u32 build_id;
+ __u32 mask_chip_id : 1;
+ __u32 mask_chip_key : 1;
+ __u32 vlek_en : 1;
+ __u32 rsvd1 : 29;
+ __u32 guest_count;
+ __u64 current_tcb_version;
+ __u64 reported_tcb_version;
+} __attribute__((__packed__));
+struct sev_user_data_snp_config {
+ __u64 reported_tcb;
+ __u32 mask_chip_id : 1;
+ __u32 mask_chip_key : 1;
+ __u32 rsvd : 30;
+ __u8 rsvd1[52];
+} __attribute__((__packed__));
struct sev_issue_cmd {
__u32 cmd;
__u64 data;
diff --git a/libc/kernel/uapi/linux/ptp_clock.h b/libc/kernel/uapi/linux/ptp_clock.h
index ca4447e..5014936 100644
--- a/libc/kernel/uapi/linux/ptp_clock.h
+++ b/libc/kernel/uapi/linux/ptp_clock.h
@@ -12,9 +12,11 @@
#define PTP_RISING_EDGE (1 << 1)
#define PTP_FALLING_EDGE (1 << 2)
#define PTP_STRICT_FLAGS (1 << 3)
+#define PTP_EXT_OFFSET (1 << 4)
#define PTP_EXTTS_EDGES (PTP_RISING_EDGE | PTP_FALLING_EDGE)
-#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE | PTP_STRICT_FLAGS)
+#define PTP_EXTTS_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE | PTP_STRICT_FLAGS | PTP_EXT_OFFSET)
#define PTP_EXTTS_V1_VALID_FLAGS (PTP_ENABLE_FEATURE | PTP_RISING_EDGE | PTP_FALLING_EDGE)
+#define PTP_EXTTS_EVENT_VALID (PTP_ENABLE_FEATURE)
#define PTP_PEROUT_ONE_SHOT (1 << 0)
#define PTP_PEROUT_DUTY_CYCLE (1 << 1)
#define PTP_PEROUT_PHASE (1 << 2)
diff --git a/libc/kernel/uapi/linux/rkisp1-config.h b/libc/kernel/uapi/linux/rkisp1-config.h
index ac0b5eb..d4206a0 100644
--- a/libc/kernel/uapi/linux/rkisp1-config.h
+++ b/libc/kernel/uapi/linux/rkisp1-config.h
@@ -97,6 +97,7 @@
RKISP1_V11,
RKISP1_V12,
RKISP1_V13,
+ RKISP1_V_IMX8MP,
};
enum rkisp1_cif_isp_histogram_mode {
RKISP1_CIF_ISP_HISTOGRAM_MODE_DISABLE,
diff --git a/libc/kernel/uapi/linux/snmp.h b/libc/kernel/uapi/linux/snmp.h
index 2f4c65c..0f72302 100644
--- a/libc/kernel/uapi/linux/snmp.h
+++ b/libc/kernel/uapi/linux/snmp.h
@@ -289,6 +289,8 @@
LINUX_MIB_XFRMFWDHDRERROR,
LINUX_MIB_XFRMOUTSTATEINVALID,
LINUX_MIB_XFRMACQUIREERROR,
+ LINUX_MIB_XFRMOUTSTATEDIRERROR,
+ LINUX_MIB_XFRMINSTATEDIRERROR,
__LINUX_MIB_XFRMMAX
};
enum {
diff --git a/libc/kernel/uapi/linux/stat.h b/libc/kernel/uapi/linux/stat.h
index 9974f3e..ff98fd2 100644
--- a/libc/kernel/uapi/linux/stat.h
+++ b/libc/kernel/uapi/linux/stat.h
@@ -68,7 +68,8 @@
__u64 stx_mnt_id;
__u32 stx_dio_mem_align;
__u32 stx_dio_offset_align;
- __u64 __spare3[12];
+ __u64 stx_subvol;
+ __u64 __spare3[11];
};
#define STATX_TYPE 0x00000001U
#define STATX_MODE 0x00000002U
@@ -86,6 +87,7 @@
#define STATX_MNT_ID 0x00001000U
#define STATX_DIOALIGN 0x00002000U
#define STATX_MNT_ID_UNIQUE 0x00004000U
+#define STATX_SUBVOL 0x00008000U
#define STATX__RESERVED 0x80000000U
#define STATX_ALL 0x00000fffU
#define STATX_ATTR_COMPRESSED 0x00000004
diff --git a/libc/kernel/uapi/linux/stddef.h b/libc/kernel/uapi/linux/stddef.h
index aa3a694..dc37c6f 100644
--- a/libc/kernel/uapi/linux/stddef.h
+++ b/libc/kernel/uapi/linux/stddef.h
@@ -19,4 +19,10 @@
#ifndef __counted_by
#define __counted_by(m)
#endif
+#ifndef __counted_by_le
+#define __counted_by_le(m)
+#endif
+#ifndef __counted_by_be
+#define __counted_by_be(m)
+#endif
#endif
diff --git a/libc/kernel/uapi/linux/tc_act/tc_pedit.h b/libc/kernel/uapi/linux/tc_act/tc_pedit.h
index bc7cc06..9635370 100644
--- a/libc/kernel/uapi/linux/tc_act/tc_pedit.h
+++ b/libc/kernel/uapi/linux/tc_act/tc_pedit.h
@@ -53,7 +53,7 @@
tc_gen;
unsigned char nkeys;
unsigned char flags;
- struct tc_pedit_key keys[0];
+ struct tc_pedit_key keys[] __counted_by(nkeys);
};
#define tc_pedit tc_pedit_sel
#endif
diff --git a/libc/kernel/uapi/linux/tcp.h b/libc/kernel/uapi/linux/tcp.h
index cb26f97..c71715c 100644
--- a/libc/kernel/uapi/linux/tcp.h
+++ b/libc/kernel/uapi/linux/tcp.h
@@ -71,6 +71,7 @@
#define TCP_AO_INFO 40
#define TCP_AO_GET_KEYS 41
#define TCP_AO_REPAIR 42
+#define TCP_IS_MPTCP 43
#define TCP_REPAIR_ON 1
#define TCP_REPAIR_OFF 0
#define TCP_REPAIR_OFF_NO_WP - 1
diff --git a/libc/kernel/uapi/linux/tee.h b/libc/kernel/uapi/linux/tee.h
index d4772ee..6e4cff3 100644
--- a/libc/kernel/uapi/linux/tee.h
+++ b/libc/kernel/uapi/linux/tee.h
@@ -18,6 +18,7 @@
#define TEE_MEMREF_NULL (__u64) (- 1)
#define TEE_IMPL_ID_OPTEE 1
#define TEE_IMPL_ID_AMDTEE 2
+#define TEE_IMPL_ID_TSTEE 3
#define TEE_OPTEE_CAP_TZ (1 << 0)
struct tee_ioctl_version_data {
__u32 impl_id;
diff --git a/libc/kernel/uapi/linux/trace_mmap.h b/libc/kernel/uapi/linux/trace_mmap.h
new file mode 100644
index 0000000..e891a7e
--- /dev/null
+++ b/libc/kernel/uapi/linux/trace_mmap.h
@@ -0,0 +1,28 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _TRACE_MMAP_H_
+#define _TRACE_MMAP_H_
+#include <linux/types.h>
+struct trace_buffer_meta {
+ __u32 meta_page_size;
+ __u32 meta_struct_len;
+ __u32 subbuf_size;
+ __u32 nr_subbufs;
+ struct {
+ __u64 lost_events;
+ __u32 id;
+ __u32 read;
+ } reader;
+ __u64 flags;
+ __u64 entries;
+ __u64 overrun;
+ __u64 read;
+ __u64 Reserved1;
+ __u64 Reserved2;
+};
+#define TRACE_MMAP_IOCTL_GET_READER _IO('R', 0x20)
+#endif
diff --git a/libc/kernel/uapi/linux/ublk_cmd.h b/libc/kernel/uapi/linux/ublk_cmd.h
index d05c7c4..8e7732b 100644
--- a/libc/kernel/uapi/linux/ublk_cmd.h
+++ b/libc/kernel/uapi/linux/ublk_cmd.h
@@ -30,6 +30,7 @@
#define UBLK_U_CMD_END_USER_RECOVERY _IOWR('u', UBLK_CMD_END_USER_RECOVERY, struct ublksrv_ctrl_cmd)
#define UBLK_U_CMD_GET_DEV_INFO2 _IOR('u', UBLK_CMD_GET_DEV_INFO2, struct ublksrv_ctrl_cmd)
#define UBLK_U_CMD_GET_FEATURES _IOR('u', 0x13, struct ublksrv_ctrl_cmd)
+#define UBLK_U_CMD_DEL_DEV_ASYNC _IOR('u', 0x14, struct ublksrv_ctrl_cmd)
#define UBLK_FEATURES_LEN 8
#define UBLK_IO_FETCH_REQ 0x20
#define UBLK_IO_COMMIT_AND_FETCH_REQ 0x21
diff --git a/libc/kernel/uapi/linux/usb/ch9.h b/libc/kernel/uapi/linux/usb/ch9.h
index b858bac..6762773 100644
--- a/libc/kernel/uapi/linux/usb/ch9.h
+++ b/libc/kernel/uapi/linux/usb/ch9.h
@@ -286,6 +286,7 @@
#define USB_OTG_SRP (1 << 0)
#define USB_OTG_HNP (1 << 1)
#define USB_OTG_ADP (1 << 2)
+#define USB_OTG_RSP (1 << 3)
#define OTG_STS_SELECTOR 0xF000
struct usb_debug_descriptor {
__u8 bLength;
diff --git a/libc/kernel/uapi/linux/usb/functionfs.h b/libc/kernel/uapi/linux/usb/functionfs.h
index 417093e..095e937 100644
--- a/libc/kernel/uapi/linux/usb/functionfs.h
+++ b/libc/kernel/uapi/linux/usb/functionfs.h
@@ -69,6 +69,12 @@
__le32 dwPropertyDataType;
__le16 wPropertyNameLength;
} __attribute__((packed));
+#define USB_FFS_DMABUF_TRANSFER_MASK 0x0
+struct usb_ffs_dmabuf_transfer_req {
+ int fd;
+ __u32 flags;
+ __u64 length;
+} __attribute__((packed));
struct usb_functionfs_strings_head {
__le32 magic;
__le32 length;
@@ -97,4 +103,7 @@
#define FUNCTIONFS_INTERFACE_REVMAP _IO('g', 128)
#define FUNCTIONFS_ENDPOINT_REVMAP _IO('g', 129)
#define FUNCTIONFS_ENDPOINT_DESC _IOR('g', 130, struct usb_endpoint_descriptor)
+#define FUNCTIONFS_DMABUF_ATTACH _IOW('g', 131, int)
+#define FUNCTIONFS_DMABUF_DETACH _IOW('g', 132, int)
+#define FUNCTIONFS_DMABUF_TRANSFER _IOW('g', 133, struct usb_ffs_dmabuf_transfer_req)
#endif
diff --git a/libc/kernel/uapi/linux/user_events.h b/libc/kernel/uapi/linux/user_events.h
index 7bff0b0..37bf66b 100644
--- a/libc/kernel/uapi/linux/user_events.h
+++ b/libc/kernel/uapi/linux/user_events.h
@@ -9,11 +9,13 @@
#include <linux/types.h>
#include <linux/ioctl.h>
#define USER_EVENTS_SYSTEM "user_events"
+#define USER_EVENTS_MULTI_SYSTEM "user_events_multi"
#define USER_EVENTS_PREFIX "u:"
#define DYN_LOC(offset,size) ((size) << 16 | (offset))
enum user_reg_flag {
USER_EVENT_REG_PERSIST = 1U << 0,
- USER_EVENT_REG_MAX = 1U << 1,
+ USER_EVENT_REG_MULTI_FORMAT = 1U << 1,
+ USER_EVENT_REG_MAX = 1U << 2,
};
struct user_reg {
__u32 size;
diff --git a/libc/kernel/uapi/linux/v4l2-subdev.h b/libc/kernel/uapi/linux/v4l2-subdev.h
index 9caaa47..b5a0c87 100644
--- a/libc/kernel/uapi/linux/v4l2-subdev.h
+++ b/libc/kernel/uapi/linux/v4l2-subdev.h
@@ -100,9 +100,10 @@
};
struct v4l2_subdev_routing {
__u32 which;
- __u32 num_routes;
+ __u32 len_routes;
__u64 routes;
- __u32 reserved[6];
+ __u32 num_routes;
+ __u32 reserved[11];
};
#define V4L2_SUBDEV_CLIENT_CAP_STREAMS (1ULL << 0)
#define V4L2_SUBDEV_CLIENT_CAP_INTERVAL_USES_WHICH (1ULL << 1)
diff --git a/libc/kernel/uapi/linux/vdpa.h b/libc/kernel/uapi/linux/vdpa.h
index a8a9515..462d579 100644
--- a/libc/kernel/uapi/linux/vdpa.h
+++ b/libc/kernel/uapi/linux/vdpa.h
@@ -41,6 +41,22 @@
VDPA_ATTR_DEV_VENDOR_ATTR_NAME,
VDPA_ATTR_DEV_VENDOR_ATTR_VALUE,
VDPA_ATTR_DEV_FEATURES,
+ VDPA_ATTR_DEV_BLK_CFG_CAPACITY,
+ VDPA_ATTR_DEV_BLK_CFG_SIZE_MAX,
+ VDPA_ATTR_DEV_BLK_CFG_BLK_SIZE,
+ VDPA_ATTR_DEV_BLK_CFG_SEG_MAX,
+ VDPA_ATTR_DEV_BLK_CFG_NUM_QUEUES,
+ VDPA_ATTR_DEV_BLK_CFG_PHY_BLK_EXP,
+ VDPA_ATTR_DEV_BLK_CFG_ALIGN_OFFSET,
+ VDPA_ATTR_DEV_BLK_CFG_MIN_IO_SIZE,
+ VDPA_ATTR_DEV_BLK_CFG_OPT_IO_SIZE,
+ VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEC,
+ VDPA_ATTR_DEV_BLK_CFG_MAX_DISCARD_SEG,
+ VDPA_ATTR_DEV_BLK_CFG_DISCARD_SEC_ALIGN,
+ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEC,
+ VDPA_ATTR_DEV_BLK_CFG_MAX_WRITE_ZEROES_SEG,
+ VDPA_ATTR_DEV_BLK_READ_ONLY,
+ VDPA_ATTR_DEV_BLK_FLUSH,
VDPA_ATTR_MAX,
};
#endif
diff --git a/libc/kernel/uapi/linux/version.h b/libc/kernel/uapi/linux/version.h
index 549c079..7faa30f 100644
--- a/libc/kernel/uapi/linux/version.h
+++ b/libc/kernel/uapi/linux/version.h
@@ -4,8 +4,8 @@
* See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
* for more information.
*/
-#define LINUX_VERSION_CODE 395264
+#define LINUX_VERSION_CODE 395776
#define KERNEL_VERSION(a,b,c) (((a) << 16) + ((b) << 8) + ((c) > 255 ? 255 : (c)))
#define LINUX_VERSION_MAJOR 6
-#define LINUX_VERSION_PATCHLEVEL 8
+#define LINUX_VERSION_PATCHLEVEL 10
#define LINUX_VERSION_SUBLEVEL 0
diff --git a/libc/kernel/uapi/linux/vesa.h b/libc/kernel/uapi/linux/vesa.h
new file mode 100644
index 0000000..1bf9946
--- /dev/null
+++ b/libc/kernel/uapi/linux/vesa.h
@@ -0,0 +1,20 @@
+/*
+ * This file is auto-generated. Modifications will be lost.
+ *
+ * See https://android.googlesource.com/platform/bionic/+/master/libc/kernel/
+ * for more information.
+ */
+#ifndef _UAPI_LINUX_VESA_H
+#define _UAPI_LINUX_VESA_H
+enum vesa_blank_mode {
+ VESA_NO_BLANKING = 0,
+#define VESA_NO_BLANKING VESA_NO_BLANKING
+ VESA_VSYNC_SUSPEND = 1,
+#define VESA_VSYNC_SUSPEND VESA_VSYNC_SUSPEND
+ VESA_HSYNC_SUSPEND = 2,
+#define VESA_HSYNC_SUSPEND VESA_HSYNC_SUSPEND
+ VESA_POWERDOWN = VESA_VSYNC_SUSPEND | VESA_HSYNC_SUSPEND,
+#define VESA_POWERDOWN VESA_POWERDOWN
+ VESA_BLANK_MAX = VESA_POWERDOWN,
+};
+#endif
diff --git a/libc/kernel/uapi/linux/vhost.h b/libc/kernel/uapi/linux/vhost.h
index adf0af7..a93212e 100644
--- a/libc/kernel/uapi/linux/vhost.h
+++ b/libc/kernel/uapi/linux/vhost.h
@@ -55,12 +55,13 @@
#define VHOST_VDPA_SET_CONFIG_CALL _IOW(VHOST_VIRTIO, 0x77, int)
#define VHOST_VDPA_GET_IOVA_RANGE _IOR(VHOST_VIRTIO, 0x78, struct vhost_vdpa_iova_range)
#define VHOST_VDPA_GET_CONFIG_SIZE _IOR(VHOST_VIRTIO, 0x79, __u32)
-#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
-#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32)
#define VHOST_VDPA_GET_AS_NUM _IOR(VHOST_VIRTIO, 0x7A, unsigned int)
#define VHOST_VDPA_GET_VRING_GROUP _IOWR(VHOST_VIRTIO, 0x7B, struct vhost_vring_state)
#define VHOST_VDPA_SET_GROUP_ASID _IOW(VHOST_VIRTIO, 0x7C, struct vhost_vring_state)
#define VHOST_VDPA_SUSPEND _IO(VHOST_VIRTIO, 0x7D)
#define VHOST_VDPA_RESUME _IO(VHOST_VIRTIO, 0x7E)
#define VHOST_VDPA_GET_VRING_DESC_GROUP _IOWR(VHOST_VIRTIO, 0x7F, struct vhost_vring_state)
+#define VHOST_VDPA_GET_VQS_COUNT _IOR(VHOST_VIRTIO, 0x80, __u32)
+#define VHOST_VDPA_GET_GROUP_NUM _IOR(VHOST_VIRTIO, 0x81, __u32)
+#define VHOST_VDPA_GET_VRING_SIZE _IOWR(VHOST_VIRTIO, 0x82, struct vhost_vring_state)
#endif
diff --git a/libc/kernel/uapi/linux/videodev2.h b/libc/kernel/uapi/linux/videodev2.h
index ed91484..3905949 100644
--- a/libc/kernel/uapi/linux/videodev2.h
+++ b/libc/kernel/uapi/linux/videodev2.h
@@ -249,6 +249,8 @@
#define V4L2_PIX_FMT_Y10BPACK v4l2_fourcc('Y', '1', '0', 'B')
#define V4L2_PIX_FMT_Y10P v4l2_fourcc('Y', '1', '0', 'P')
#define V4L2_PIX_FMT_IPU3_Y10 v4l2_fourcc('i', 'p', '3', 'y')
+#define V4L2_PIX_FMT_Y12P v4l2_fourcc('Y', '1', '2', 'P')
+#define V4L2_PIX_FMT_Y14P v4l2_fourcc('Y', '1', '4', 'P')
#define V4L2_PIX_FMT_PAL8 v4l2_fourcc('P', 'A', 'L', '8')
#define V4L2_PIX_FMT_UV8 v4l2_fourcc('U', 'V', '8', ' ')
#define V4L2_PIX_FMT_YUYV v4l2_fourcc('Y', 'U', 'Y', 'V')
@@ -464,6 +466,7 @@
#define V4L2_FMT_FLAG_CSC_YCBCR_ENC 0x0080
#define V4L2_FMT_FLAG_CSC_HSV_ENC V4L2_FMT_FLAG_CSC_YCBCR_ENC
#define V4L2_FMT_FLAG_CSC_QUANTIZATION 0x0100
+#define V4L2_FMT_FLAG_META_LINE_BASED 0x0200
enum v4l2_frmsizetypes {
V4L2_FRMSIZE_TYPE_DISCRETE = 1,
V4L2_FRMSIZE_TYPE_CONTINUOUS = 2,
@@ -563,6 +566,7 @@
#define V4L2_BUF_CAP_SUPPORTS_M2M_HOLD_CAPTURE_BUF (1 << 5)
#define V4L2_BUF_CAP_SUPPORTS_MMAP_CACHE_HINTS (1 << 6)
#define V4L2_BUF_CAP_SUPPORTS_MAX_NUM_BUFFERS (1 << 7)
+#define V4L2_BUF_CAP_SUPPORTS_REMOVE_BUFS (1 << 8)
struct v4l2_plane {
__u32 bytesused;
__u32 length;
@@ -936,7 +940,7 @@
struct v4l2_ctrl_hdr10_cll_info * p_hdr10_cll_info;
struct v4l2_ctrl_hdr10_mastering_display * p_hdr10_mastering_display;
void * ptr;
- };
+ } __attribute__((packed));
} __attribute__((packed));
struct v4l2_ext_controls {
union {
@@ -1311,6 +1315,9 @@
struct v4l2_meta_format {
__u32 dataformat;
__u32 buffersize;
+ __u32 width;
+ __u32 height;
+ __u32 bytesperline;
} __attribute__((packed));
struct v4l2_format {
__u32 type;
@@ -1435,6 +1442,12 @@
__u32 max_num_buffers;
__u32 reserved[5];
};
+struct v4l2_remove_buffers {
+ __u32 index;
+ __u32 count;
+ __u32 type;
+ __u32 reserved[13];
+};
#define VIDIOC_QUERYCAP _IOR('V', 0, struct v4l2_capability)
#define VIDIOC_ENUM_FMT _IOWR('V', 2, struct v4l2_fmtdesc)
#define VIDIOC_G_FMT _IOWR('V', 4, struct v4l2_format)
@@ -1517,6 +1530,7 @@
#define VIDIOC_ENUM_FREQ_BANDS _IOWR('V', 101, struct v4l2_frequency_band)
#define VIDIOC_DBG_G_CHIP_INFO _IOWR('V', 102, struct v4l2_dbg_chip_info)
#define VIDIOC_QUERY_EXT_CTRL _IOWR('V', 103, struct v4l2_query_ext_ctrl)
+#define VIDIOC_REMOVE_BUFS _IOWR('V', 104, struct v4l2_remove_buffers)
#define BASE_VIDIOC_PRIVATE 192
#define V4L2_PIX_FMT_HM12 V4L2_PIX_FMT_NV12_16L16
#define V4L2_PIX_FMT_SUNXI_TILED_NV12 V4L2_PIX_FMT_NV12_32L32
diff --git a/libc/kernel/uapi/linux/virtio_bt.h b/libc/kernel/uapi/linux/virtio_bt.h
index 2b790ea..8799b66 100644
--- a/libc/kernel/uapi/linux/virtio_bt.h
+++ b/libc/kernel/uapi/linux/virtio_bt.h
@@ -13,7 +13,6 @@
#define VIRTIO_BT_F_CONFIG_V2 3
enum virtio_bt_config_type {
VIRTIO_BT_CONFIG_TYPE_PRIMARY = 0,
- VIRTIO_BT_CONFIG_TYPE_AMP = 1,
};
enum virtio_bt_config_vendor {
VIRTIO_BT_CONFIG_VENDOR_NONE = 0,
diff --git a/libc/kernel/uapi/linux/virtio_gpu.h b/libc/kernel/uapi/linux/virtio_gpu.h
index 7162226..c3f0fcc 100644
--- a/libc/kernel/uapi/linux/virtio_gpu.h
+++ b/libc/kernel/uapi/linux/virtio_gpu.h
@@ -194,6 +194,7 @@
};
#define VIRTIO_GPU_CAPSET_VIRGL 1
#define VIRTIO_GPU_CAPSET_VIRGL2 2
+#define VIRTIO_GPU_CAPSET_VENUS 4
struct virtio_gpu_get_capset_info {
struct virtio_gpu_ctrl_hdr hdr;
__le32 capset_index;
diff --git a/libc/kernel/uapi/linux/virtio_mem.h b/libc/kernel/uapi/linux/virtio_mem.h
index e90853e..770623a 100644
--- a/libc/kernel/uapi/linux/virtio_mem.h
+++ b/libc/kernel/uapi/linux/virtio_mem.h
@@ -12,6 +12,7 @@
#include <linux/virtio_config.h>
#define VIRTIO_MEM_F_ACPI_PXM 0
#define VIRTIO_MEM_F_UNPLUGGED_INACCESSIBLE 1
+#define VIRTIO_MEM_F_PERSISTENT_SUSPEND 2
#define VIRTIO_MEM_REQ_PLUG 0
#define VIRTIO_MEM_REQ_UNPLUG 1
#define VIRTIO_MEM_REQ_UNPLUG_ALL 2
diff --git a/libc/kernel/uapi/linux/virtio_net.h b/libc/kernel/uapi/linux/virtio_net.h
index 7573209..26ff301 100644
--- a/libc/kernel/uapi/linux/virtio_net.h
+++ b/libc/kernel/uapi/linux/virtio_net.h
@@ -33,6 +33,7 @@
#define VIRTIO_NET_F_GUEST_ANNOUNCE 21
#define VIRTIO_NET_F_MQ 22
#define VIRTIO_NET_F_CTRL_MAC_ADDR 23
+#define VIRTIO_NET_F_DEVICE_STATS 50
#define VIRTIO_NET_F_VQ_NOTF_COAL 52
#define VIRTIO_NET_F_NOTF_COAL 53
#define VIRTIO_NET_F_GUEST_USO4 54
@@ -203,4 +204,103 @@
__le16 reserved;
struct virtio_net_ctrl_coal coal;
};
+#define VIRTIO_NET_CTRL_STATS 8
+#define VIRTIO_NET_CTRL_STATS_QUERY 0
+#define VIRTIO_NET_CTRL_STATS_GET 1
+struct virtio_net_stats_capabilities {
+#define VIRTIO_NET_STATS_TYPE_CVQ (1ULL << 32)
+#define VIRTIO_NET_STATS_TYPE_RX_BASIC (1ULL << 0)
+#define VIRTIO_NET_STATS_TYPE_RX_CSUM (1ULL << 1)
+#define VIRTIO_NET_STATS_TYPE_RX_GSO (1ULL << 2)
+#define VIRTIO_NET_STATS_TYPE_RX_SPEED (1ULL << 3)
+#define VIRTIO_NET_STATS_TYPE_TX_BASIC (1ULL << 16)
+#define VIRTIO_NET_STATS_TYPE_TX_CSUM (1ULL << 17)
+#define VIRTIO_NET_STATS_TYPE_TX_GSO (1ULL << 18)
+#define VIRTIO_NET_STATS_TYPE_TX_SPEED (1ULL << 19)
+ __le64 supported_stats_types[1];
+};
+struct virtio_net_ctrl_queue_stats {
+ struct {
+ __le16 vq_index;
+ __le16 reserved[3];
+ __le64 types_bitmap[1];
+ } stats[1];
+};
+struct virtio_net_stats_reply_hdr {
+#define VIRTIO_NET_STATS_TYPE_REPLY_CVQ 32
+#define VIRTIO_NET_STATS_TYPE_REPLY_RX_BASIC 0
+#define VIRTIO_NET_STATS_TYPE_REPLY_RX_CSUM 1
+#define VIRTIO_NET_STATS_TYPE_REPLY_RX_GSO 2
+#define VIRTIO_NET_STATS_TYPE_REPLY_RX_SPEED 3
+#define VIRTIO_NET_STATS_TYPE_REPLY_TX_BASIC 16
+#define VIRTIO_NET_STATS_TYPE_REPLY_TX_CSUM 17
+#define VIRTIO_NET_STATS_TYPE_REPLY_TX_GSO 18
+#define VIRTIO_NET_STATS_TYPE_REPLY_TX_SPEED 19
+ __u8 type;
+ __u8 reserved;
+ __le16 vq_index;
+ __le16 reserved1;
+ __le16 size;
+};
+struct virtio_net_stats_cvq {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 command_num;
+ __le64 ok_num;
+};
+struct virtio_net_stats_rx_basic {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 rx_notifications;
+ __le64 rx_packets;
+ __le64 rx_bytes;
+ __le64 rx_interrupts;
+ __le64 rx_drops;
+ __le64 rx_drop_overruns;
+};
+struct virtio_net_stats_tx_basic {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 tx_notifications;
+ __le64 tx_packets;
+ __le64 tx_bytes;
+ __le64 tx_interrupts;
+ __le64 tx_drops;
+ __le64 tx_drop_malformed;
+};
+struct virtio_net_stats_rx_csum {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 rx_csum_valid;
+ __le64 rx_needs_csum;
+ __le64 rx_csum_none;
+ __le64 rx_csum_bad;
+};
+struct virtio_net_stats_tx_csum {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 tx_csum_none;
+ __le64 tx_needs_csum;
+};
+struct virtio_net_stats_rx_gso {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 rx_gso_packets;
+ __le64 rx_gso_bytes;
+ __le64 rx_gso_packets_coalesced;
+ __le64 rx_gso_bytes_coalesced;
+};
+struct virtio_net_stats_tx_gso {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 tx_gso_packets;
+ __le64 tx_gso_bytes;
+ __le64 tx_gso_segments;
+ __le64 tx_gso_segments_bytes;
+ __le64 tx_gso_packets_noseg;
+ __le64 tx_gso_bytes_noseg;
+};
+struct virtio_net_stats_rx_speed {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 rx_ratelimit_packets;
+ __le64 rx_ratelimit_bytes;
+};
+struct virtio_net_stats_tx_speed {
+ struct virtio_net_stats_reply_hdr hdr;
+ __le64 tx_ratelimit_packets;
+ __le64 tx_ratelimit_bytes;
+};
#endif
diff --git a/libc/kernel/uapi/linux/virtio_pci.h b/libc/kernel/uapi/linux/virtio_pci.h
index 013548c..8921155 100644
--- a/libc/kernel/uapi/linux/virtio_pci.h
+++ b/libc/kernel/uapi/linux/virtio_pci.h
@@ -126,30 +126,30 @@
#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_WRITE 0x4
#define VIRTIO_ADMIN_CMD_LEGACY_DEV_CFG_READ 0x5
#define VIRTIO_ADMIN_CMD_LEGACY_NOTIFY_INFO 0x6
-struct __attribute__((__packed__)) virtio_admin_cmd_hdr {
+struct virtio_admin_cmd_hdr {
__le16 opcode;
__le16 group_type;
__u8 reserved1[12];
__le64 group_member_id;
};
-struct __attribute__((__packed__)) virtio_admin_cmd_status {
+struct virtio_admin_cmd_status {
__le16 status;
__le16 status_qualifier;
__u8 reserved2[4];
};
-struct __attribute__((__packed__)) virtio_admin_cmd_legacy_wr_data {
+struct virtio_admin_cmd_legacy_wr_data {
__u8 offset;
__u8 reserved[7];
__u8 registers[];
};
-struct __attribute__((__packed__)) virtio_admin_cmd_legacy_rd_data {
+struct virtio_admin_cmd_legacy_rd_data {
__u8 offset;
};
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_END 0
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_DEV 0x1
#define VIRTIO_ADMIN_CMD_NOTIFY_INFO_FLAGS_OWNER_MEM 0x2
#define VIRTIO_ADMIN_CMD_MAX_NOTIFY_INFO 4
-struct __attribute__((__packed__)) virtio_admin_cmd_notify_info_data {
+struct virtio_admin_cmd_notify_info_data {
__u8 flags;
__u8 bar;
__u8 padding[6];
diff --git a/libc/kernel/uapi/linux/virtio_snd.h b/libc/kernel/uapi/linux/virtio_snd.h
index e4ec8cd..7318e29 100644
--- a/libc/kernel/uapi/linux/virtio_snd.h
+++ b/libc/kernel/uapi/linux/virtio_snd.h
@@ -7,10 +7,14 @@
#ifndef VIRTIO_SND_IF_H
#define VIRTIO_SND_IF_H
#include <linux/virtio_types.h>
+enum {
+ VIRTIO_SND_F_CTLS = 0
+};
struct virtio_snd_config {
__le32 jacks;
__le32 streams;
__le32 chmaps;
+ __le32 controls;
};
enum {
VIRTIO_SND_VQ_CONTROL = 0,
@@ -33,10 +37,18 @@
VIRTIO_SND_R_PCM_START,
VIRTIO_SND_R_PCM_STOP,
VIRTIO_SND_R_CHMAP_INFO = 0x0200,
+ VIRTIO_SND_R_CTL_INFO = 0x0300,
+ VIRTIO_SND_R_CTL_ENUM_ITEMS,
+ VIRTIO_SND_R_CTL_READ,
+ VIRTIO_SND_R_CTL_WRITE,
+ VIRTIO_SND_R_CTL_TLV_READ,
+ VIRTIO_SND_R_CTL_TLV_WRITE,
+ VIRTIO_SND_R_CTL_TLV_COMMAND,
VIRTIO_SND_EVT_JACK_CONNECTED = 0x1000,
VIRTIO_SND_EVT_JACK_DISCONNECTED,
VIRTIO_SND_EVT_PCM_PERIOD_ELAPSED = 0x1100,
VIRTIO_SND_EVT_PCM_XRUN,
+ VIRTIO_SND_EVT_CTL_NOTIFY = 0x1200,
VIRTIO_SND_S_OK = 0x8000,
VIRTIO_SND_S_BAD_MSG,
VIRTIO_SND_S_NOT_SUPP,
@@ -209,4 +221,83 @@
__u8 channels;
__u8 positions[VIRTIO_SND_CHMAP_MAX_SIZE];
};
+struct virtio_snd_ctl_hdr {
+ struct virtio_snd_hdr hdr;
+ __le32 control_id;
+};
+enum {
+ VIRTIO_SND_CTL_ROLE_UNDEFINED = 0,
+ VIRTIO_SND_CTL_ROLE_VOLUME,
+ VIRTIO_SND_CTL_ROLE_MUTE,
+ VIRTIO_SND_CTL_ROLE_GAIN
+};
+enum {
+ VIRTIO_SND_CTL_TYPE_BOOLEAN = 0,
+ VIRTIO_SND_CTL_TYPE_INTEGER,
+ VIRTIO_SND_CTL_TYPE_INTEGER64,
+ VIRTIO_SND_CTL_TYPE_ENUMERATED,
+ VIRTIO_SND_CTL_TYPE_BYTES,
+ VIRTIO_SND_CTL_TYPE_IEC958
+};
+enum {
+ VIRTIO_SND_CTL_ACCESS_READ = 0,
+ VIRTIO_SND_CTL_ACCESS_WRITE,
+ VIRTIO_SND_CTL_ACCESS_VOLATILE,
+ VIRTIO_SND_CTL_ACCESS_INACTIVE,
+ VIRTIO_SND_CTL_ACCESS_TLV_READ,
+ VIRTIO_SND_CTL_ACCESS_TLV_WRITE,
+ VIRTIO_SND_CTL_ACCESS_TLV_COMMAND
+};
+struct virtio_snd_ctl_info {
+ struct virtio_snd_info hdr;
+ __le32 role;
+ __le32 type;
+ __le32 access;
+ __le32 count;
+ __le32 index;
+ __u8 name[44];
+ union {
+ struct {
+ __le32 min;
+ __le32 max;
+ __le32 step;
+ } integer;
+ struct {
+ __le64 min;
+ __le64 max;
+ __le64 step;
+ } integer64;
+ struct {
+ __le32 items;
+ } enumerated;
+ } value;
+};
+struct virtio_snd_ctl_enum_item {
+ __u8 item[64];
+};
+struct virtio_snd_ctl_iec958 {
+ __u8 status[24];
+ __u8 subcode[147];
+ __u8 pad;
+ __u8 dig_subframe[4];
+};
+struct virtio_snd_ctl_value {
+ union {
+ __le32 integer[128];
+ __le64 integer64[64];
+ __le32 enumerated[128];
+ __u8 bytes[512];
+ struct virtio_snd_ctl_iec958 iec958;
+ } value;
+};
+enum {
+ VIRTIO_SND_CTL_EVT_MASK_VALUE = 0,
+ VIRTIO_SND_CTL_EVT_MASK_INFO,
+ VIRTIO_SND_CTL_EVT_MASK_TLV
+};
+struct virtio_snd_ctl_event {
+ struct virtio_snd_hdr hdr;
+ __le16 control_id;
+ __le16 mask;
+};
#endif
diff --git a/libc/kernel/uapi/linux/xfrm.h b/libc/kernel/uapi/linux/xfrm.h
index e2f168d..b8e79e8 100644
--- a/libc/kernel/uapi/linux/xfrm.h
+++ b/libc/kernel/uapi/linux/xfrm.h
@@ -111,6 +111,10 @@
XFRM_POLICY_MASK = 3,
XFRM_POLICY_MAX = 3
};
+enum xfrm_sa_dir {
+ XFRM_SA_DIR_IN = 1,
+ XFRM_SA_DIR_OUT = 2
+};
enum {
XFRM_SHARE_ANY,
XFRM_SHARE_SESSION,
@@ -255,6 +259,7 @@
XFRMA_SET_MARK_MASK,
XFRMA_IF_ID,
XFRMA_MTIMER_THRESH,
+ XFRMA_SA_DIR,
__XFRMA_MAX
#define XFRMA_OUTPUT_MARK XFRMA_SET_MARK
#define XFRMA_MAX (__XFRMA_MAX - 1)
diff --git a/libc/kernel/uapi/misc/pvpanic.h b/libc/kernel/uapi/misc/pvpanic.h
index bc421ae..8e1be62 100644
--- a/libc/kernel/uapi/misc/pvpanic.h
+++ b/libc/kernel/uapi/misc/pvpanic.h
@@ -6,6 +6,8 @@
*/
#ifndef __PVPANIC_H__
#define __PVPANIC_H__
-#define PVPANIC_PANICKED (1 << 0)
-#define PVPANIC_CRASH_LOADED (1 << 1)
+#include <linux/const.h>
+#define PVPANIC_PANICKED _BITUL(0)
+#define PVPANIC_CRASH_LOADED _BITUL(1)
+#define PVPANIC_SHUTDOWN _BITUL(2)
#endif
diff --git a/libc/kernel/uapi/rdma/efa-abi.h b/libc/kernel/uapi/rdma/efa-abi.h
index 2b30941..d4a9089 100644
--- a/libc/kernel/uapi/rdma/efa-abi.h
+++ b/libc/kernel/uapi/rdma/efa-abi.h
@@ -63,11 +63,16 @@
enum {
EFA_QP_DRIVER_TYPE_SRD = 0,
};
+enum {
+ EFA_CREATE_QP_WITH_UNSOLICITED_WRITE_RECV = 1 << 0,
+};
struct efa_ibv_create_qp {
__u32 comp_mask;
__u32 rq_ring_size;
__u32 sq_ring_size;
__u32 driver_qp_type;
+ __u16 flags;
+ __u8 reserved_90[6];
};
struct efa_ibv_create_qp_resp {
__u32 comp_mask;
@@ -95,6 +100,7 @@
EFA_QUERY_DEVICE_CAPS_CQ_WITH_SGID = 1 << 3,
EFA_QUERY_DEVICE_CAPS_DATA_POLLING_128 = 1 << 4,
EFA_QUERY_DEVICE_CAPS_RDMA_WRITE = 1 << 5,
+ EFA_QUERY_DEVICE_CAPS_UNSOLICITED_WRITE_RECV = 1 << 6,
};
struct efa_ibv_ex_query_device_resp {
__u32 comp_mask;
diff --git a/libc/kernel/uapi/rdma/hns-abi.h b/libc/kernel/uapi/rdma/hns-abi.h
index 54a5672..b76e45c 100644
--- a/libc/kernel/uapi/rdma/hns-abi.h
+++ b/libc/kernel/uapi/rdma/hns-abi.h
@@ -37,6 +37,15 @@
__u32 srqn;
__u32 cap_flags;
};
+enum hns_roce_congest_type_flags {
+ HNS_ROCE_CREATE_QP_FLAGS_DCQCN,
+ HNS_ROCE_CREATE_QP_FLAGS_LDCP,
+ HNS_ROCE_CREATE_QP_FLAGS_HC3,
+ HNS_ROCE_CREATE_QP_FLAGS_DIP,
+};
+enum hns_roce_create_qp_comp_mask {
+ HNS_ROCE_CREATE_QP_MASK_CONGEST_TYPE = 1 << 0,
+};
struct hns_roce_ib_create_qp {
__aligned_u64 buf_addr;
__aligned_u64 db_addr;
@@ -45,6 +54,9 @@
__u8 sq_no_prefetch;
__u8 reserved[5];
__aligned_u64 sdb_addr;
+ __aligned_u64 comp_mask;
+ __aligned_u64 create_flags;
+ __aligned_u64 cong_type_flags;
};
enum hns_roce_qp_cap_flags {
HNS_ROCE_QP_CAP_RQ_RECORD_DB = 1 << 0,
@@ -56,6 +68,11 @@
__aligned_u64 cap_flags;
__aligned_u64 dwqe_mmap_key;
};
+struct hns_roce_ib_modify_qp_resp {
+ __u8 tc_mode;
+ __u8 priority;
+ __u8 reserved[6];
+};
enum {
HNS_ROCE_EXSGE_FLAGS = 1 << 0,
HNS_ROCE_RQ_INLINE_FLAGS = 1 << 1,
@@ -73,6 +90,8 @@
__u32 reserved;
__u32 config;
__u32 max_inline_data;
+ __u8 congest_type;
+ __u8 reserved0[7];
};
struct hns_roce_ib_alloc_ucontext {
__u32 config;
@@ -83,6 +102,7 @@
};
struct hns_roce_ib_create_ah_resp {
__u8 dmac[6];
- __u8 reserved[2];
+ __u8 priority;
+ __u8 tc_mode;
};
#endif
diff --git a/libc/kernel/uapi/rdma/mana-abi.h b/libc/kernel/uapi/rdma/mana-abi.h
index 73967b4..7347175 100644
--- a/libc/kernel/uapi/rdma/mana-abi.h
+++ b/libc/kernel/uapi/rdma/mana-abi.h
@@ -9,8 +9,18 @@
#include <linux/types.h>
#include <rdma/ib_user_ioctl_verbs.h>
#define MANA_IB_UVERBS_ABI_VERSION 1
+enum mana_ib_create_cq_flags {
+ MANA_IB_CREATE_RNIC_CQ = 1 << 0,
+};
struct mana_ib_create_cq {
__aligned_u64 buf_addr;
+ __u16 flags;
+ __u16 reserved0;
+ __u32 reserved1;
+};
+struct mana_ib_create_cq_resp {
+ __u32 cqid;
+ __u32 reserved;
};
struct mana_ib_create_qp {
__aligned_u64 sq_buf_addr;
diff --git a/libc/kernel/uapi/rdma/rdma_netlink.h b/libc/kernel/uapi/rdma/rdma_netlink.h
index 2fe8c30..912a3c0 100644
--- a/libc/kernel/uapi/rdma/rdma_netlink.h
+++ b/libc/kernel/uapi/rdma/rdma_netlink.h
@@ -304,6 +304,8 @@
RDMA_NLDEV_ATTR_STAT_HWCOUNTER_INDEX,
RDMA_NLDEV_ATTR_STAT_HWCOUNTER_DYNAMIC,
RDMA_NLDEV_SYS_ATTR_PRIVILEGED_QKEY_MODE,
+ RDMA_NLDEV_ATTR_DRIVER_DETAILS,
+ RDMA_NLDEV_ATTR_RES_SUBTYPE,
RDMA_NLDEV_ATTR_MAX
};
enum rdma_nl_counter_mode {
diff --git a/libc/kernel/uapi/scsi/scsi_bsg_mpi3mr.h b/libc/kernel/uapi/scsi/scsi_bsg_mpi3mr.h
index bac5017..d98e8fa 100644
--- a/libc/kernel/uapi/scsi/scsi_bsg_mpi3mr.h
+++ b/libc/kernel/uapi/scsi/scsi_bsg_mpi3mr.h
@@ -176,7 +176,7 @@
__u8 mpi_reply_type;
__u8 rsvd1;
__u16 rsvd2;
- __u8 reply_buf[1];
+ __u8 reply_buf[];
};
struct mpi3mr_buf_entry {
__u8 buf_type;
diff --git a/libc/kernel/uapi/sound/asoc.h b/libc/kernel/uapi/sound/asoc.h
index 8718b46..f7992cb 100644
--- a/libc/kernel/uapi/sound/asoc.h
+++ b/libc/kernel/uapi/sound/asoc.h
@@ -336,48 +336,4 @@
__le32 flags;
struct snd_soc_tplg_private priv;
} __attribute__((packed));
-struct snd_soc_tplg_manifest_v4 {
- __le32 size;
- __le32 control_elems;
- __le32 widget_elems;
- __le32 graph_elems;
- __le32 pcm_elems;
- __le32 dai_link_elems;
- struct snd_soc_tplg_private priv;
-} __attribute__((__packed__));
-struct snd_soc_tplg_stream_caps_v4 {
- __le32 size;
- char name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- __le64 formats;
- __le32 rates;
- __le32 rate_min;
- __le32 rate_max;
- __le32 channels_min;
- __le32 channels_max;
- __le32 periods_min;
- __le32 periods_max;
- __le32 period_size_min;
- __le32 period_size_max;
- __le32 buffer_size_min;
- __le32 buffer_size_max;
-} __attribute__((__packed__));
-struct snd_soc_tplg_pcm_v4 {
- __le32 size;
- char pcm_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- char dai_name[SNDRV_CTL_ELEM_ID_NAME_MAXLEN];
- __le32 pcm_id;
- __le32 dai_id;
- __le32 playback;
- __le32 capture;
- __le32 compress;
- struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
- __le32 num_streams;
- struct snd_soc_tplg_stream_caps_v4 caps[2];
-} __attribute__((__packed__));
-struct snd_soc_tplg_link_config_v4 {
- __le32 size;
- __le32 id;
- struct snd_soc_tplg_stream stream[SND_SOC_TPLG_STREAM_CONFIG_MAX];
- __le32 num_streams;
-} __attribute__((__packed__));
#endif
diff --git a/libc/kernel/uapi/sound/intel/avs/tokens.h b/libc/kernel/uapi/sound/intel/avs/tokens.h
index 6a8ed8a..01b20a5 100644
--- a/libc/kernel/uapi/sound/intel/avs/tokens.h
+++ b/libc/kernel/uapi/sound/intel/avs/tokens.h
@@ -15,6 +15,8 @@
AVS_TKN_MANIFEST_NUM_MODCFGS_EXT_U32 = 6,
AVS_TKN_MANIFEST_NUM_PPLCFGS_U32 = 7,
AVS_TKN_MANIFEST_NUM_BINDINGS_U32 = 8,
+ AVS_TKN_MANIFEST_NUM_CONDPATH_TMPLS_U32 = 9,
+ AVS_TKN_MANIFEST_NUM_INIT_CONFIGS_U32 = 10,
AVS_TKN_LIBRARY_ID_U32 = 101,
AVS_TKN_LIBRARY_NAME_STRING = 102,
AVS_TKN_AFMT_ID_U32 = 201,
@@ -89,6 +91,8 @@
AVS_TKN_MOD_PROC_DOMAIN_U8 = 1705,
AVS_TKN_MOD_MODCFG_EXT_ID_U32 = 1706,
AVS_TKN_MOD_KCONTROL_ID_U32 = 1707,
+ AVS_TKN_MOD_INIT_CONFIG_NUM_IDS_U32 = 1708,
+ AVS_TKN_MOD_INIT_CONFIG_ID_U32 = 1709,
AVS_TKN_PATH_TMPL_ID_U32 = 1801,
AVS_TKN_PATH_ID_U32 = 1901,
AVS_TKN_PATH_FE_FMT_ID_U32 = 1902,
@@ -97,5 +101,8 @@
AVS_TKN_PIN_FMT_IOBS_U32 = 2202,
AVS_TKN_PIN_FMT_AFMT_ID_U32 = 2203,
AVS_TKN_KCONTROL_ID_U32 = 2301,
+ AVS_TKN_INIT_CONFIG_ID_U32 = 2401,
+ AVS_TKN_INIT_CONFIG_PARAM_U8 = 2402,
+ AVS_TKN_INIT_CONFIG_LENGTH_U32 = 2403,
};
#endif
diff --git a/libc/kernel/uapi/sound/skl-tplg-interface.h b/libc/kernel/uapi/sound/skl-tplg-interface.h
index c620295..d613c7f 100644
--- a/libc/kernel/uapi/sound/skl-tplg-interface.h
+++ b/libc/kernel/uapi/sound/skl-tplg-interface.h
@@ -109,66 +109,4 @@
SKL_TYPE_TUPLE,
SKL_TYPE_DATA
};
-struct skl_dfw_v4_module_pin {
- __u16 module_id;
- __u16 instance_id;
-} __attribute__((__packed__));
-struct skl_dfw_v4_module_fmt {
- __u32 channels;
- __u32 freq;
- __u32 bit_depth;
- __u32 valid_bit_depth;
- __u32 ch_cfg;
- __u32 interleaving_style;
- __u32 sample_type;
- __u32 ch_map;
-} __attribute__((__packed__));
-struct skl_dfw_v4_module_caps {
- __u32 set_params : 2;
- __u32 rsvd : 30;
- __u32 param_id;
- __u32 caps_size;
- __u32 caps[HDA_SST_CFG_MAX];
-} __attribute__((__packed__));
-struct skl_dfw_v4_pipe {
- __u8 pipe_id;
- __u8 pipe_priority;
- __u16 conn_type : 4;
- __u16 rsvd : 4;
- __u16 memory_pages : 8;
-} __attribute__((__packed__));
-struct skl_dfw_v4_module {
- char uuid[SKL_UUID_STR_SZ];
- __u16 module_id;
- __u16 instance_id;
- __u32 max_mcps;
- __u32 mem_pages;
- __u32 obs;
- __u32 ibs;
- __u32 vbus_id;
- __u32 max_in_queue : 8;
- __u32 max_out_queue : 8;
- __u32 time_slot : 8;
- __u32 core_id : 4;
- __u32 rsvd1 : 4;
- __u32 module_type : 8;
- __u32 conn_type : 4;
- __u32 dev_type : 4;
- __u32 hw_conn_type : 4;
- __u32 rsvd2 : 12;
- __u32 params_fixup : 8;
- __u32 converter : 8;
- __u32 input_pin_type : 1;
- __u32 output_pin_type : 1;
- __u32 is_dynamic_in_pin : 1;
- __u32 is_dynamic_out_pin : 1;
- __u32 is_loadable : 1;
- __u32 rsvd3 : 11;
- struct skl_dfw_v4_pipe pipe;
- struct skl_dfw_v4_module_fmt in_fmt[MAX_IN_QUEUE];
- struct skl_dfw_v4_module_fmt out_fmt[MAX_OUT_QUEUE];
- struct skl_dfw_v4_module_pin in_pin[MAX_IN_QUEUE];
- struct skl_dfw_v4_module_pin out_pin[MAX_OUT_QUEUE];
- struct skl_dfw_v4_module_caps caps;
-} __attribute__((__packed__));
#endif
diff --git a/libc/kernel/uapi/sound/sof/tokens.h b/libc/kernel/uapi/sound/sof/tokens.h
index b55a895..c4257d9 100644
--- a/libc/kernel/uapi/sound/sof/tokens.h
+++ b/libc/kernel/uapi/sound/sof/tokens.h
@@ -128,4 +128,6 @@
#define SOF_TKN_AMD_ACPI2S_TDM_MODE 1702
#define SOF_TKN_IMX_MICFIL_RATE 2000
#define SOF_TKN_IMX_MICFIL_CH 2001
+#define SOF_TKN_AMD_ACP_SDW_RATE 2100
+#define SOF_TKN_AMD_ACP_SDW_CH 2101
#endif
diff --git a/libc/libc.map.txt b/libc/libc.map.txt
index 2c8ec07..0d2e42f 100644
--- a/libc/libc.map.txt
+++ b/libc/libc.map.txt
@@ -8,29 +8,29 @@
__atomic_swap; # arm
__b64_ntop;
__b64_pton;
- __cmsg_nxthdr; # introduced=21
- __connect; # arm x86 introduced=21
- __ctype_get_mb_cur_max; # introduced=21
+ __cmsg_nxthdr;
+ __connect; # arm x86
+ __ctype_get_mb_cur_max;
__cxa_atexit;
__cxa_finalize;
__cxa_thread_atexit_impl; # introduced=23
__dn_comp;
__dn_count_labels;
__dn_skipname;
- __epoll_pwait; # arm x86 introduced=21
+ __epoll_pwait; # arm x86
__errno;
- __exit; # arm x86 introduced=21
- __fadvise64; # x86 introduced=21
+ __exit; # arm x86
+ __fadvise64; # x86
__fbufsize; # introduced=23
__fcntl64; # arm x86
- __FD_CLR_chk; # introduced=21
- __FD_ISSET_chk; # introduced=21
- __FD_SET_chk; # introduced=21
- __fgets_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __FD_CLR_chk;
+ __FD_ISSET_chk;
+ __FD_SET_chk;
+ __fgets_chk;
__flbf; # introduced=23
__fp_nquery;
__fp_query;
- __fpclassify; # introduced=21
+ __fpclassify;
__fpclassifyd;
__fpclassifyf;
__fpclassifyl;
@@ -41,9 +41,9 @@
__fstatfs64; # arm x86
__fwritable; # introduced=23
__get_h_errno;
- __getcpu; # arm x86 introduced-arm=12 introduced-x86=12
+ __getcpu; # arm x86
__getcwd; # arm x86
- __getpid; # arm x86 introduced=21
+ __getpid; # arm x86
__getpriority; # arm x86
__gnu_basename; # introduced=23
__gnu_strerror_r; # introduced=23
@@ -55,24 +55,24 @@
__isinf;
__isinff;
__isinfl;
- __isnan; # introduced=21
- __isnanf; # introduced=21
+ __isnan;
+ __isnanf;
__isnanl;
__isnormal;
__isnormalf;
__isnormall;
__isthreaded; # arm x86 var
- __libc_current_sigrtmax; # introduced=21
- __libc_current_sigrtmin; # introduced=21
+ __libc_current_sigrtmax;
+ __libc_current_sigrtmin;
__libc_init;
__llseek; # arm x86
__loc_aton;
__loc_ntoa;
__memchr_chk; # introduced=23
- __memcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __memmove_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __memcpy_chk;
+ __memmove_chk;
__memrchr_chk; # introduced=23
- __memset_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __memset_chk;
__mmap2; # arm x86
__ns_format_ttl; # arm x86 introduced=22
__ns_get16; # arm x86 introduced=22
@@ -96,9 +96,9 @@
__ns_skiprr; # arm x86 introduced=22
__ns_sprintrr; # arm x86 introduced=22
__ns_sprintrrf; # arm x86 introduced=22
- __open_2; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __open_2;
__openat; # arm x86
- __openat_2; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __openat_2;
__p_cdname;
__p_cdnname;
__p_class;
@@ -113,23 +113,23 @@
__p_type;
__p_type_syms; # var
__poll_chk; # introduced=23
- __ppoll; # arm x86 introduced=21
+ __ppoll; # arm x86
__ppoll_chk; # introduced=23
__ppoll64_chk; # introduced=28
__pread64_chk; # introduced=23
__pread_chk; # introduced=23
__progname; # var
- __pselect6; # arm x86 introduced=21
+ __pselect6; # arm x86
__pthread_cleanup_pop;
__pthread_cleanup_push;
__ptrace; # arm x86
__putlong;
__putshort;
- __read_chk; # introduced=21
+ __read_chk;
__readlink_chk; # introduced=23
__readlinkat_chk; # introduced=23
__reboot; # arm x86
- __recvfrom_chk; # introduced=21
+ __recvfrom_chk;
__register_atfork; # introduced=23
__res_close;
__res_dnok;
@@ -152,83 +152,83 @@
__res_send_setqhook;
__res_send_setrhook;
__rt_sigaction; # arm x86
- __rt_sigpending; # arm x86 introduced=21
+ __rt_sigpending; # arm x86
__rt_sigprocmask; # arm x86
- __rt_sigsuspend; # arm x86 introduced=21
+ __rt_sigsuspend; # arm x86
__rt_sigtimedwait; # arm x86
- __sched_cpualloc; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- __sched_cpucount; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- __sched_cpufree; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- __sched_getaffinity; # arm x86 introduced=12
+ __sched_cpualloc;
+ __sched_cpucount;
+ __sched_cpufree;
+ __sched_getaffinity; # arm x86
__set_thread_area; # x86
- __set_tid_address; # arm x86 introduced=21
+ __set_tid_address; # arm x86
__set_tls; # arm
__sF; # var
- __sigaction; # arm x86 introduced=21
- __snprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __socket; # arm x86 introduced=21
- __sprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __sigaction; # arm x86
+ __snprintf_chk;
+ __socket; # arm x86
+ __sprintf_chk;
__stack_chk_fail;
__stack_chk_guard; # var
__statfs64; # arm x86
- __stpcpy_chk; # introduced=21
- __stpncpy_chk; # introduced=21
- __stpncpy_chk2; # introduced=21
- __strcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- __strcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strlcat_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strlcpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strlen_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strncat_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strncpy_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __strncpy_chk2; # introduced=21
- __strrchr_chk; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ __stpcpy_chk;
+ __stpncpy_chk;
+ __stpncpy_chk2;
+ __strcat_chk;
+ __strchr_chk;
+ __strcpy_chk;
+ __strlcat_chk;
+ __strlcpy_chk;
+ __strlen_chk;
+ __strncat_chk;
+ __strncpy_chk;
+ __strncpy_chk2;
+ __strrchr_chk;
__sym_ntop;
__sym_ntos;
__sym_ston;
__system_property_area_serial; # introduced=23
__system_property_find;
__system_property_find_nth;
- __system_property_foreach; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ __system_property_foreach;
__system_property_get;
__system_property_read;
- __system_property_serial; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- __system_property_set; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ __system_property_serial;
+ __system_property_set;
__timer_create; # arm x86
__timer_delete; # arm x86
__timer_getoverrun; # arm x86
__timer_gettime; # arm x86
__timer_settime; # arm x86
- __umask_chk; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- __vsnprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- __vsprintf_chk; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ __umask_chk;
+ __vsnprintf_chk;
+ __vsprintf_chk;
__waitid; # arm x86
_ctype_; # var
- _Exit; # introduced=21
+ _Exit;
_exit;
_flushlbf; # introduced=23
_getlong;
_getshort;
_longjmp;
- _resolv_delete_cache_for_net; # introduced=21
- _resolv_flush_cache_for_net; # introduced=21
- _resolv_set_nameservers_for_net; # introduced=21
+ _resolv_delete_cache_for_net;
+ _resolv_flush_cache_for_net;
+ _resolv_set_nameservers_for_net;
_setjmp;
- _tolower; # introduced=21
+ _tolower;
_tolower_tab_; # arm x86 var
- _toupper; # introduced=21
+ _toupper;
_toupper_tab_; # arm x86 var
abort;
- abs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ abs;
accept;
- accept4; # introduced=21
+ accept4;
access;
acct;
alarm;
alphasort;
- alphasort64; # introduced=21
- android_set_abort_message; # introduced=21
+ alphasort64;
+ android_set_abort_message;
arc4random;
arc4random_buf;
arc4random_uniform;
@@ -237,8 +237,8 @@
asctime64_r; # arm x86
asctime_r;
asprintf;
- at_quick_exit; # introduced=21
- atof; # introduced=21
+ at_quick_exit;
+ atof;
atoi;
atol;
atoll;
@@ -249,18 +249,18 @@
brk;
bsearch;
btowc;
- c16rtomb; # introduced=21
- c32rtomb; # introduced=21
+ c16rtomb;
+ c32rtomb;
cacheflush; # arm
calloc;
capget;
capset;
- cfgetispeed; # introduced=21
- cfgetospeed; # introduced=21
- cfmakeraw; # introduced=21
- cfsetispeed; # introduced=21
- cfsetospeed; # introduced=21
- cfsetspeed; # introduced=21
+ cfgetispeed;
+ cfgetospeed;
+ cfmakeraw;
+ cfsetispeed;
+ cfsetospeed;
+ cfsetspeed;
chdir;
chmod;
chown;
@@ -274,13 +274,13 @@
clock_gettime;
clock_nanosleep;
clock_settime;
- clone; # introduced-arm=9 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ clone;
close;
closedir;
closelog;
connect;
creat;
- creat64; # introduced=21
+ creat64;
ctime;
ctime64; # arm x86
ctime64_r; # arm x86
@@ -294,20 +294,20 @@
dirname_r; # arm x86
div;
dn_expand;
- dprintf; # introduced=21
+ dprintf;
drand48;
dup;
dup2;
- dup3; # introduced=21
- duplocale; # introduced=21
- endmntent; # introduced=21
+ dup3;
+ duplocale;
+ endmntent;
endservent;
endutent;
environ; # var
epoll_create;
- epoll_create1; # introduced=21
+ epoll_create1;
epoll_ctl;
- epoll_pwait; # introduced=21
+ epoll_pwait;
epoll_wait;
erand48;
err;
@@ -317,10 +317,10 @@
error_one_per_line; # var introduced=23
error_print_progname; # var introduced=23
errx;
- ether_aton; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- ether_aton_r; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- ether_ntoa; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- ether_ntoa_r; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ ether_aton;
+ ether_aton_r;
+ ether_ntoa;
+ ether_ntoa_r;
eventfd;
eventfd_read;
eventfd_write;
@@ -330,11 +330,11 @@
execv;
execve;
execvp;
- execvpe; # introduced=21
+ execvpe;
exit;
faccessat;
- fallocate; # introduced=21
- fallocate64; # introduced=21
+ fallocate;
+ fallocate64;
fchdir;
fchmod;
fchmodat;
@@ -351,7 +351,7 @@
ferror;
ferror_unlocked; # introduced=23
fflush;
- ffs; # introduced-arm=9 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ ffs;
fgetc;
fgetln;
fgetpos;
@@ -378,7 +378,7 @@
fread;
free;
freeaddrinfo;
- freelocale; # introduced=21
+ freelocale;
fremovexattr;
freopen;
fscanf;
@@ -387,30 +387,30 @@
fsetpos;
fsetxattr;
fstat;
- fstat64; # introduced=21
+ fstat64;
fstatat;
- fstatat64; # introduced=21
+ fstatat64;
fstatfs;
- fstatfs64; # introduced=21
- fstatvfs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- fstatvfs64; # introduced=21
+ fstatfs64;
+ fstatvfs;
+ fstatvfs64;
fsync;
ftell;
ftello;
ftok;
ftruncate;
- ftruncate64; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ ftruncate64;
ftrylockfile;
- fts_children; # introduced=21
- fts_close; # introduced=21
- fts_open; # introduced=21
- fts_read; # introduced=21
- fts_set; # introduced=21
- ftw; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- ftw64; # introduced=21
+ fts_children;
+ fts_close;
+ fts_open;
+ fts_read;
+ fts_set;
+ ftw;
+ ftw64;
funlockfile;
funopen;
- futimens; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ futimens;
fwide;
fwprintf;
fwrite;
@@ -421,13 +421,13 @@
get_nprocs_conf; # introduced=23
get_phys_pages; # introduced=23
getaddrinfo;
- getauxval; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ getauxval;
getc;
getc_unlocked;
getchar;
getchar_unlocked;
getcwd;
- getdelim; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ getdelim;
getegid;
getenv;
geteuid;
@@ -445,41 +445,41 @@
gethostent;
gethostname;
getitimer;
- getline; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ getline;
getlogin;
getmntent;
- getmntent_r; # introduced=21
+ getmntent_r;
getnameinfo;
getnetbyaddr;
getnetbyname;
getopt;
getopt_long;
getopt_long_only;
- getpagesize; # introduced=21
+ getpagesize;
getpeername;
getpgid;
getpgrp;
getpid;
getppid;
getpriority;
- getprogname; # introduced=21
+ getprogname;
getprotobyname;
getprotobynumber;
getpt;
getpwnam;
- getpwnam_r; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ getpwnam_r;
getpwuid;
- getpwuid_r; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ getpwuid_r;
getresgid;
getresuid;
getrlimit;
- getrlimit64; # introduced=21
+ getrlimit64;
getrusage;
gets;
getservbyname;
getservbyport;
getservent;
- getsid; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ getsid;
getsockname;
getsockopt;
gettid;
@@ -493,21 +493,21 @@
gmtime64; # arm x86
gmtime64_r; # arm x86
gmtime_r;
- grantpt; # introduced=21
+ grantpt;
herror;
hstrerror;
- htonl; # introduced=21
- htons; # introduced=21
+ htonl;
+ htons;
if_indextoname;
if_nametoindex;
- imaxabs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- imaxdiv; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ imaxabs;
+ imaxdiv;
inet_addr;
inet_aton;
- inet_lnaof; # introduced=21
- inet_makeaddr; # introduced=21
- inet_netof; # introduced=21
- inet_network; # introduced=21
+ inet_lnaof;
+ inet_makeaddr;
+ inet_netof;
+ inet_network;
inet_nsap_addr;
inet_nsap_ntoa;
inet_ntoa;
@@ -515,96 +515,97 @@
inet_pton;
init_module;
initgroups;
- initstate; # introduced=21
+ initstate;
inotify_add_watch;
inotify_init;
- inotify_init1; # introduced=21
+ inotify_init1;
inotify_rm_watch;
- insque; # introduced=21
+ insque;
ioctl;
isalnum;
- isalnum_l; # introduced=21
+ isalnum_l;
isalpha;
- isalpha_l; # introduced=21
+ isalpha_l;
isascii;
isatty;
isblank;
- isblank_l; # introduced=21
+ isblank_l;
iscntrl;
- iscntrl_l; # introduced=21
+ iscntrl_l;
isdigit;
- isdigit_l; # introduced=21
- isfinite; # introduced=21
- isfinitef; # introduced=21
- isfinitel; # introduced=21
+ isdigit_l;
+ isfinite;
+ isfinitef;
+ isfinitel;
isgraph;
- isgraph_l; # introduced=21
- isinf; # introduced=21
- isinff; # introduced=21
- isinfl; # introduced=21
+ isgraph_l;
+ isinf;
+ isinff;
+ isinfl;
islower;
- islower_l; # introduced=21
+ islower_l;
isnan;
isnanf;
- isnanl; # introduced=21
- isnormal; # introduced=21
- isnormalf; # introduced=21
- isnormall; # introduced=21
+ isnanl;
+ isnormal;
+ isnormalf;
+ isnormall;
isprint;
- isprint_l; # introduced=21
+ isprint_l;
ispunct;
- ispunct_l; # introduced=21
+ ispunct_l;
isspace;
- isspace_l; # introduced=21
+ isspace_l;
isupper;
- isupper_l; # introduced=21
+ isupper_l;
iswalnum;
- iswalnum_l; # introduced=21
+ iswalnum_l;
iswalpha;
- iswalpha_l; # introduced=21
- iswblank; # introduced=21
- iswblank_l; # introduced=21
+ iswalpha_l;
+ iswblank;
+ iswblank_l;
iswcntrl;
- iswcntrl_l; # introduced=21
+ iswcntrl_l;
iswctype;
- iswctype_l; # introduced=21
+ iswctype_l;
iswdigit;
- iswdigit_l; # introduced=21
+ iswdigit_l;
iswgraph;
- iswgraph_l; # introduced=21
+ iswgraph_l;
iswlower;
- iswlower_l; # introduced=21
+ iswlower_l;
iswprint;
- iswprint_l; # introduced=21
+ iswprint_l;
iswpunct;
- iswpunct_l; # introduced=21
+ iswpunct_l;
iswspace;
- iswspace_l; # introduced=21
+ iswspace_l;
iswupper;
- iswupper_l; # introduced=21
+ iswupper_l;
iswxdigit;
- iswxdigit_l; # introduced=21
+ iswxdigit_l;
isxdigit;
- isxdigit_l; # introduced=21
+ isxdigit_l;
jrand48;
kill;
killpg;
klogctl;
- labs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ labs;
+ lchmod; # introduced=36
lchown;
lcong48; # introduced=23
ldexp;
ldiv;
- lfind; # introduced=21
+ lfind;
lgetxattr;
link;
- linkat; # introduced=21
+ linkat;
listen;
listxattr;
- llabs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ llabs;
lldiv;
llistxattr;
- localeconv; # introduced=21
+ localeconv;
localtime;
localtime64; # arm x86
localtime64_r; # arm x86
@@ -613,26 +614,26 @@
longjmp;
lrand48;
lremovexattr;
- lsearch; # introduced=21
+ lsearch;
lseek;
lseek64;
lsetxattr;
lstat;
- lstat64; # introduced=21
+ lstat64;
madvise;
mallinfo;
malloc;
malloc_info; # introduced=23
- malloc_usable_size; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ malloc_usable_size;
mbrlen;
- mbrtoc16; # introduced=21
- mbrtoc32; # introduced=21
+ mbrtoc16;
+ mbrtoc32;
mbrtowc;
mbsinit;
- mbsnrtowcs; # introduced=21
+ mbsnrtowcs;
mbsrtowcs;
- mbstowcs; # introduced=21
- mbtowc; # introduced=21
+ mbstowcs;
+ mbtowc;
memalign;
memccpy;
memchr;
@@ -647,37 +648,38 @@
mkdir;
mkdirat;
mkdtemp;
- mkfifo; # introduced=21
+ mkfifo;
mkfifoat; # introduced=23
mknod;
- mknodat; # introduced=21
+ mknodat;
mkostemp; # introduced=23
mkostemp64; # introduced=23
mkostemps; # introduced=23
mkostemps64; # introduced=23
mkstemp;
- mkstemp64; # introduced=21
+ mkstemp64;
mkstemps;
mkstemps64; # introduced=23
mktemp;
mktime;
mktime64; # arm x86
mlock;
- mlockall; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ mlockall;
mmap;
- mmap64; # introduced=21
+ mmap64;
mount;
mprotect;
mrand48;
mremap;
+ mseal; # introduced=36
msync;
munlock;
- munlockall; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
+ munlockall;
munmap;
nanosleep;
- newlocale; # introduced=21
- nftw; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- nftw64; # introduced=21
+ newlocale;
+ nftw;
+ nftw64;
nice;
nrand48;
ns_format_ttl; # arm64 x86_64 riscv64 introduced=22
@@ -703,14 +705,14 @@
ns_sprintrr; # arm64 x86_64 riscv64 introduced=22
ns_sprintrrf; # arm64 x86_64 riscv64 introduced=22
nsdispatch;
- ntohl; # introduced=21
- ntohs; # introduced=21
+ ntohl;
+ ntohs;
open;
- open64; # introduced=21
+ open64;
open_memstream; # introduced=23
open_wmemstream; # introduced=23
openat;
- openat64; # introduced=21
+ openat64;
opendir;
openlog;
openpty; # introduced=23
@@ -728,26 +730,26 @@
pipe2;
poll;
popen;
- posix_fadvise; # introduced=21
- posix_fadvise64; # introduced=21
- posix_fallocate; # introduced=21
- posix_fallocate64; # introduced=21
+ posix_fadvise;
+ posix_fadvise64;
+ posix_fallocate;
+ posix_fallocate64;
posix_madvise; # introduced=23
- posix_memalign; # introduced=17
- posix_openpt; # introduced=21
- ppoll; # introduced=21
+ posix_memalign;
+ posix_openpt;
+ ppoll;
prctl;
pread;
- pread64; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ pread64;
printf;
prlimit; # arm64 x86_64 riscv64
- prlimit64; # introduced=21
+ prlimit64;
process_vm_readv; # introduced=23
process_vm_writev; # introduced=23
pselect;
- psiginfo; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- psignal; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- pthread_atfork; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ psiginfo;
+ psignal;
+ pthread_atfork;
pthread_attr_destroy;
pthread_attr_getdetachstate;
pthread_attr_getguardsize;
@@ -770,15 +772,15 @@
pthread_cond_signal;
pthread_cond_timedwait;
pthread_cond_timedwait_monotonic; # arm x86
- pthread_cond_timedwait_monotonic_np; # introduced-arm=9 introduced-x86=9 introduced-arm64=28 introduced-x64_64=28
+ pthread_cond_timedwait_monotonic_np; # introduced-arm=9 introduced-x86=9 introduced-arm64=28 introduced-x64_64=28 introduced-riscv64=28
pthread_cond_timedwait_relative_np; # arm x86
pthread_cond_timeout_np; # arm x86
pthread_cond_wait;
pthread_condattr_destroy;
- pthread_condattr_getclock; # introduced=21
+ pthread_condattr_getclock;
pthread_condattr_getpshared;
pthread_condattr_init;
- pthread_condattr_setclock; # introduced=21
+ pthread_condattr_setclock;
pthread_condattr_setpshared;
pthread_create;
pthread_detach;
@@ -788,7 +790,7 @@
pthread_getcpuclockid;
pthread_getschedparam;
pthread_getspecific;
- pthread_gettid_np; # introduced=21
+ pthread_gettid_np;
pthread_join;
pthread_key_create;
pthread_key_delete;
@@ -797,7 +799,7 @@
pthread_mutex_init;
pthread_mutex_lock;
pthread_mutex_lock_timeout_np; # arm x86
- pthread_mutex_timedlock; # introduced=21
+ pthread_mutex_timedlock;
pthread_mutex_trylock;
pthread_mutex_unlock;
pthread_mutexattr_destroy;
@@ -840,30 +842,31 @@
putw; # arm x86
putwc;
putwchar;
- pvalloc; # arm x86 introduced=17
+ pvalloc; # arm x86
pwrite;
- pwrite64; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ pwrite64;
qsort;
- quick_exit; # introduced=21
+ qsort_r; # introduced=36
+ quick_exit;
raise;
- rand; # introduced=21
- rand_r; # introduced=21
- random; # introduced=21
+ rand;
+ rand_r;
+ random;
read;
readahead;
readdir;
- readdir64; # introduced=21
- readdir64_r; # introduced=21
+ readdir64;
+ readdir64_r;
readdir_r;
readlink;
- readlinkat; # introduced=21
+ readlinkat;
readv;
realloc;
realpath;
reboot;
recv;
recvfrom;
- recvmmsg; # introduced=21
+ recvmmsg;
recvmsg;
regcomp;
regerror;
@@ -871,7 +874,7 @@
regfree;
remove;
removexattr;
- remque; # introduced=21
+ remque;
rename;
renameat;
res_init;
@@ -883,16 +886,16 @@
rmdir;
sbrk;
scandir;
- scandir64; # introduced=21
+ scandir64;
scanf;
sched_get_priority_max;
sched_get_priority_min;
- sched_getaffinity; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- sched_getcpu; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ sched_getaffinity;
+ sched_getcpu;
sched_getparam;
sched_getscheduler;
sched_rr_get_interval;
- sched_setaffinity; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ sched_setaffinity;
sched_setparam;
sched_setscheduler;
sched_yield;
@@ -911,8 +914,8 @@
sem_wait;
send;
sendfile;
- sendfile64; # introduced=21
- sendmmsg; # introduced=21
+ sendfile64;
+ sendmmsg;
sendmsg;
sendto;
setbuf;
@@ -920,8 +923,8 @@
setegid;
setenv;
seteuid;
- setfsgid; # introduced=21
- setfsuid; # introduced=21
+ setfsgid;
+ setfsuid;
setgid;
setgroups;
sethostname; # introduced=23
@@ -930,45 +933,46 @@
setlinebuf;
setlocale;
setlogmask;
- setmntent; # introduced=21
- setns; # introduced=21
+ setmntent;
+ setns;
setpgid;
setpgrp;
setpriority;
- setprogname; # introduced=21
+ setprogname;
setregid;
setresgid;
setresuid;
setreuid;
setrlimit;
- setrlimit64; # introduced=21
+ setrlimit64;
setservent;
setsid;
setsockopt;
- setstate; # introduced=21
+ setstate;
settimeofday;
setuid;
setutent;
setvbuf;
setxattr;
shutdown;
+ sig2str; # introduced=36
sigaction;
- sigaddset; # introduced=21
+ sigaddset;
sigaltstack;
- sigblock; # arm x86 arm64 x86_64
- sigdelset; # introduced=21
- sigemptyset; # introduced=21
- sigfillset; # introduced=21
+ sigblock;
+ sigdelset;
+ sigemptyset;
+ sigfillset;
siginterrupt;
- sigismember; # introduced=21
- siglongjmp; # introduced-arm=9 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- signal; # introduced=21
- signalfd; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ sigismember;
+ siglongjmp;
+ signal;
+ signalfd;
sigpending;
sigprocmask;
sigqueue; # introduced=23
- sigsetjmp; # introduced-arm=9 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
- sigsetmask; # arm x86 arm64 x86_64
+ sigsetjmp;
+ sigsetmask;
sigsuspend;
sigtimedwait; # introduced=23
sigwait;
@@ -977,23 +981,24 @@
snprintf;
socket;
socketpair;
- splice; # introduced=21
+ splice;
sprintf;
- srand; # introduced=21
+ srand;
srand48;
- srandom; # introduced=21
+ srandom;
sscanf;
stat;
- stat64; # introduced=21
+ stat64;
statfs;
- statfs64; # introduced=21
- statvfs; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- statvfs64; # introduced=21
+ statfs64;
+ statvfs;
+ statvfs64;
stderr; # var introduced=23
stdin; # var introduced=23
stdout; # var introduced=23
- stpcpy; # introduced=21
- stpncpy; # introduced=21
+ stpcpy;
+ stpncpy;
+ str2sig; # introduced=36
strcasecmp;
strcasecmp_l; # introduced=23
strcasestr;
@@ -1001,7 +1006,7 @@
strchr;
strcmp;
strcoll;
- strcoll_l; # introduced=21
+ strcoll_l;
strcpy;
strcspn;
strdup;
@@ -1009,7 +1014,7 @@
strerror_l; # introduced=23
strerror_r;
strftime;
- strftime_l; # introduced=21
+ strftime_l;
strlcat;
strlcpy;
strlen;
@@ -1028,27 +1033,27 @@
strspn;
strstr;
strtod;
- strtof; # introduced=21
+ strtof;
strtoimax;
strtok;
strtok_r;
strtol;
- strtold; # introduced=21
- strtold_l; # introduced=21
+ strtold;
+ strtold_l;
strtoll;
- strtoll_l; # introduced=21
+ strtoll_l;
strtoul;
strtoull;
- strtoull_l; # introduced=21
+ strtoull_l;
strtoumax;
strxfrm;
- strxfrm_l; # introduced=21
- swapoff; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- swapon; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ strxfrm_l;
+ swapoff;
+ swapon;
swprintf;
swscanf;
symlink;
- symlinkat; # introduced=21
+ symlinkat;
sync;
sys_siglist; # var
sys_signame; # var
@@ -1057,54 +1062,54 @@
sysinfo;
syslog;
system;
- tcdrain; # introduced=21
- tcflow; # introduced=21
- tcflush; # introduced=21
- tcgetattr; # introduced=21
+ tcdrain;
+ tcflow;
+ tcflush;
+ tcgetattr;
tcgetpgrp;
- tcgetsid; # introduced=21
- tcsendbreak; # introduced=21
- tcsetattr; # introduced=21
+ tcgetsid;
+ tcsendbreak;
+ tcsetattr;
tcsetpgrp;
tdelete;
tdestroy;
- tee; # introduced=21
+ tee;
telldir; # introduced=23
tempnam;
tfind;
tgkill;
time;
- timegm; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ timegm;
timegm64; # arm x86
- timelocal; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ timelocal;
timelocal64; # arm x86
timer_create;
timer_delete;
timer_getoverrun;
timer_gettime;
timer_settime;
- timerfd_create; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- timerfd_gettime; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
- timerfd_settime; # introduced-arm=19 introduced-arm64=21 introduced-x86=19 introduced-x86_64=21
+ timerfd_create;
+ timerfd_gettime;
+ timerfd_settime;
times;
timezone; # var
tmpfile;
tmpnam;
toascii;
tolower;
- tolower_l; # introduced=21
+ tolower_l;
toupper;
- toupper_l; # introduced=21
+ toupper_l;
towlower;
- towlower_l; # introduced=21
+ towlower_l;
towupper;
- towupper_l; # introduced=21
+ towupper_l;
truncate;
- truncate64; # introduced=21
+ truncate64;
tsearch;
ttyname;
ttyname_r;
- twalk; # introduced=21
+ twalk;
tzname; # var
tzset;
umask;
@@ -1117,16 +1122,16 @@
unlinkat;
unlockpt;
unsetenv;
- unshare; # introduced-arm=17 introduced-arm64=21 introduced-x86=17 introduced-x86_64=21
- uselocale; # introduced=21
+ unshare;
+ uselocale;
usleep;
utime;
- utimensat; # introduced-arm=12 introduced-arm64=21 introduced-x86=12 introduced-x86_64=21
+ utimensat;
utimes;
utmpname;
valloc; # arm x86
vasprintf;
- vdprintf; # introduced=21
+ vdprintf;
verr;
verrx;
vfdprintf; # arm x86 versioned=28
@@ -1134,22 +1139,22 @@
vfprintf;
vfscanf;
vfwprintf;
- vfwscanf; # introduced=21
- vmsplice; # introduced=21
+ vfwscanf;
+ vmsplice;
vprintf;
vscanf;
vsnprintf;
vsprintf;
vsscanf;
vswprintf;
- vswscanf; # introduced=21
+ vswscanf;
vsyslog;
vwarn;
vwarnx;
vwprintf;
- vwscanf; # introduced=21
+ vwscanf;
wait;
- wait4; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ wait4;
waitid;
waitpid;
warn;
@@ -1163,7 +1168,7 @@
wcschr;
wcscmp;
wcscoll;
- wcscoll_l; # introduced=21
+ wcscoll_l;
wcscpy;
wcscspn;
wcsdup;
@@ -1177,33 +1182,33 @@
wcsncmp;
wcsncpy;
wcsnlen;
- wcsnrtombs; # introduced=21
+ wcsnrtombs;
wcspbrk;
wcsrchr;
wcsrtombs;
wcsspn;
wcsstr;
wcstod;
- wcstof; # introduced=21
- wcstoimax; # introduced=21
+ wcstof;
+ wcstoimax;
wcstok;
wcstol;
- wcstold; # introduced=21
- wcstold_l; # introduced=21
- wcstoll; # introduced=21
- wcstoll_l; # introduced=21
- wcstombs; # introduced=21
+ wcstold;
+ wcstold_l;
+ wcstoll;
+ wcstoll_l;
+ wcstombs;
wcstoul;
- wcstoull; # introduced=21
- wcstoull_l; # introduced=21
- wcstoumax; # introduced=21
+ wcstoull;
+ wcstoull_l;
+ wcstoumax;
wcswidth;
wcsxfrm;
- wcsxfrm_l; # introduced=21
+ wcsxfrm_l;
wctob;
- wctomb; # introduced=21
+ wctomb;
wctype;
- wctype_l; # introduced=21
+ wctype_l;
wcwidth;
wmemchr;
wmemcmp;
@@ -1341,7 +1346,7 @@
wctrans_l; # introduced=26
} LIBC_N;
-LIBC_P { # introduced=P
+LIBC_P { # introduced=28
global:
__freading;
__free_hook;
@@ -1442,7 +1447,7 @@
wcstoul_l;
} LIBC_O;
-LIBC_Q { # introduced=Q
+LIBC_Q { # introduced=29
global:
___tls_get_addr; # x86
__aeabi_read_tp; # arm
@@ -1478,7 +1483,7 @@
android_mallopt; # apex llndk
} LIBC_P;
-LIBC_R { # introduced=R
+LIBC_R { # introduced=30
global:
__mempcpy_chk;
__tls_get_addr; # arm64
@@ -1548,7 +1553,7 @@
_Unwind_VRS_Set; # arm
} LIBC_Q;
-LIBC_S { # introduced=S
+LIBC_S { # introduced=31
global:
__libc_get_static_tls_bounds;
__libc_register_thread_exit_callback;
@@ -1563,7 +1568,7 @@
process_madvise;
} LIBC_R;
-LIBC_T { # introduced=Tiramisu
+LIBC_T { # introduced=33
global:
backtrace;
backtrace_symbols;
@@ -1574,7 +1579,7 @@
pwritev64v2;
} LIBC_S;
-LIBC_U { # introduced=UpsideDownCake
+LIBC_U { # introduced=34
global:
__freadahead;
close_range;
@@ -1584,7 +1589,7 @@
posix_spawn_file_actions_addfchdir_np;
} LIBC_T;
-LIBC_V { # introduced=VanillaIceCream
+LIBC_V { # introduced=35
global:
android_crash_detail_register;
android_crash_detail_unregister;
diff --git a/libc/malloc_debug/Config.cpp b/libc/malloc_debug/Config.cpp
index 89a7ce7..6be899d 100644
--- a/libc/malloc_debug/Config.cpp
+++ b/libc/malloc_debug/Config.cpp
@@ -187,6 +187,10 @@
"record_allocs_file",
{0, &Config::SetRecordAllocsFile},
},
+ {
+ "record_allocs_on_exit",
+ {0, &Config::SetRecordAllocsOnExit},
+ },
{
"verify_pointers",
@@ -208,6 +212,10 @@
"log_allocator_stats_on_signal",
{LOG_ALLOCATOR_STATS_ON_SIGNAL, &Config::VerifyValueEmpty},
},
+ {
+ "log_allocator_stats_on_exit",
+ {LOG_ALLOCATOR_STATS_ON_EXIT, &Config::VerifyValueEmpty},
+ },
};
bool Config::ParseValue(const std::string& option, const std::string& value, size_t min_value,
@@ -401,6 +409,14 @@
return true;
}
+bool Config::SetRecordAllocsOnExit(const std::string& option, const std::string& value) {
+ if (Config::VerifyValueEmpty(option, value)) {
+ record_allocs_on_exit_ = true;
+ return true;
+ }
+ return false;
+}
+
bool Config::VerifyValueEmpty(const std::string& option, const std::string& value) {
if (!value.empty()) {
// This is not valid.
diff --git a/libc/malloc_debug/Config.h b/libc/malloc_debug/Config.h
index 754970f..4840d43 100644
--- a/libc/malloc_debug/Config.h
+++ b/libc/malloc_debug/Config.h
@@ -49,6 +49,7 @@
constexpr uint64_t CHECK_UNREACHABLE_ON_SIGNAL = 0x2000;
constexpr uint64_t BACKTRACE_SPECIFIC_SIZES = 0x4000;
constexpr uint64_t LOG_ALLOCATOR_STATS_ON_SIGNAL = 0x8000;
+constexpr uint64_t LOG_ALLOCATOR_STATS_ON_EXIT = 0x10000;
// In order to guarantee posix compliance, set the minimum alignment
// to 8 bytes for 32 bit systems and 16 bytes for 64 bit systems.
@@ -98,6 +99,7 @@
int record_allocs_signal() const { return record_allocs_signal_; }
size_t record_allocs_num_entries() const { return record_allocs_num_entries_; }
const std::string& record_allocs_file() const { return record_allocs_file_; }
+ bool record_allocs_on_exit() const { return record_allocs_on_exit_; }
int check_unreachable_signal() const { return check_unreachable_signal_; }
@@ -139,6 +141,7 @@
bool SetRecordAllocs(const std::string& option, const std::string& value);
bool SetRecordAllocsFile(const std::string& option, const std::string& value);
+ bool SetRecordAllocsOnExit(const std::string& option, const std::string& value);
bool VerifyValueEmpty(const std::string& option, const std::string& value);
@@ -170,6 +173,7 @@
int record_allocs_signal_ = 0;
size_t record_allocs_num_entries_ = 0;
std::string record_allocs_file_;
+ bool record_allocs_on_exit_ = false;
uint64_t options_ = 0;
uint8_t fill_alloc_value_;
diff --git a/libc/malloc_debug/LogAllocatorStats.cpp b/libc/malloc_debug/LogAllocatorStats.cpp
index 6d1434e..ee6bfdf 100644
--- a/libc/malloc_debug/LogAllocatorStats.cpp
+++ b/libc/malloc_debug/LogAllocatorStats.cpp
@@ -43,13 +43,17 @@
g_call_mallopt = true;
}
+void Log() {
+ info_log("Logging allocator stats...");
+ if (mallopt(M_LOG_STATS, 0) == 0) {
+ error_log("mallopt(M_LOG_STATS, 0) call failed.");
+ }
+}
+
void CheckIfShouldLog() {
bool expected = true;
if (g_call_mallopt.compare_exchange_strong(expected, false)) {
- info_log("Logging allocator stats...");
- if (mallopt(M_LOG_STATS, 0) == 0) {
- error_log("mallopt(M_LOG_STATS, 0) call failed.");
- }
+ Log();
}
}
diff --git a/libc/malloc_debug/LogAllocatorStats.h b/libc/malloc_debug/LogAllocatorStats.h
index 99e0738..ded4f94 100644
--- a/libc/malloc_debug/LogAllocatorStats.h
+++ b/libc/malloc_debug/LogAllocatorStats.h
@@ -35,6 +35,8 @@
bool Initialize(const Config& config);
+void Log();
+
void CheckIfShouldLog();
} // namespace LogAllocatorStats
diff --git a/libc/malloc_debug/MapData.cpp b/libc/malloc_debug/MapData.cpp
index b22c109..c58882a 100644
--- a/libc/malloc_debug/MapData.cpp
+++ b/libc/malloc_debug/MapData.cpp
@@ -34,6 +34,8 @@
#include <stdlib.h>
#include <string.h>
#include <sys/mman.h>
+#include <sys/uio.h>
+#include <unistd.h>
#include <vector>
@@ -69,148 +71,132 @@
MapEntry* entry = new MapEntry(start, end, offset, name, name_len, flags);
if (!(flags & PROT_READ)) {
- // Any unreadable map will just get a zero load bias.
- entry->load_bias = 0;
- entry->init = true;
- entry->valid = false;
+ // This will make sure that an unreadable map will prevent attempts to read
+ // elf data from the map.
+ entry->SetInvalid();
}
return entry;
}
-template <typename T>
-static inline bool get_val(MapEntry* entry, uintptr_t addr, T* store) {
- if (!(entry->flags & PROT_READ) || addr < entry->start || addr + sizeof(T) > entry->end) {
- return false;
+void MapEntry::Init() {
+ if (init_) {
+ return;
}
- // Make sure the address is aligned properly.
- if (addr & (sizeof(T) - 1)) {
- return false;
- }
- *store = *reinterpret_cast<T*>(addr);
- return true;
-}
+ init_ = true;
-static bool valid_elf(MapEntry* entry) {
- uintptr_t addr = entry->start;
- uintptr_t end;
- if (__builtin_add_overflow(addr, SELFMAG, &end) || end >= entry->end) {
- return false;
+ uintptr_t end_addr;
+ if (__builtin_add_overflow(start_, SELFMAG, &end_addr) || end_addr >= end_) {
+ return;
}
- return memcmp(reinterpret_cast<void*>(addr), ELFMAG, SELFMAG) == 0;
-}
-
-static void read_loadbias(MapEntry* entry) {
- entry->load_bias = 0;
- uintptr_t addr = entry->start;
ElfW(Ehdr) ehdr;
- if (!get_val<ElfW(Half)>(entry, addr + offsetof(ElfW(Ehdr), e_phnum), &ehdr.e_phnum)) {
- return;
+ struct iovec src_io = {.iov_base = reinterpret_cast<void*>(start_), .iov_len = SELFMAG};
+ struct iovec dst_io = {.iov_base = ehdr.e_ident, .iov_len = SELFMAG};
+ ssize_t rc = process_vm_readv(getpid(), &dst_io, 1, &src_io, 1, 0);
+ valid_ = rc == SELFMAG && IS_ELF(ehdr);
+}
+
+uintptr_t MapEntry::GetLoadBias() {
+ if (!valid_) {
+ return 0;
}
- if (!get_val<ElfW(Off)>(entry, addr + offsetof(ElfW(Ehdr), e_phoff), &ehdr.e_phoff)) {
- return;
+
+ if (load_bias_read_) {
+ return load_bias_;
}
- addr += ehdr.e_phoff;
+
+ load_bias_read_ = true;
+
+ ElfW(Ehdr) ehdr;
+ struct iovec src_io = {.iov_base = reinterpret_cast<void*>(start_), .iov_len = sizeof(ehdr)};
+ struct iovec dst_io = {.iov_base = &ehdr, .iov_len = sizeof(ehdr)};
+ ssize_t rc = process_vm_readv(getpid(), &dst_io, 1, &src_io, 1, 0);
+ if (rc != sizeof(ehdr)) {
+ return 0;
+ }
+
+ uintptr_t addr = start_ + ehdr.e_phoff;
for (size_t i = 0; i < ehdr.e_phnum; i++) {
ElfW(Phdr) phdr;
- if (!get_val<ElfW(Word)>(entry, addr + offsetof(ElfW(Phdr), p_type), &phdr.p_type)) {
- return;
- }
- if (!get_val<ElfW(Word)>(entry, addr + offsetof(ElfW(Phdr), p_flags), &phdr.p_flags)) {
- return;
- }
- if (!get_val<ElfW(Off)>(entry, addr + offsetof(ElfW(Phdr), p_offset), &phdr.p_offset)) {
- return;
+
+ src_io.iov_base = reinterpret_cast<void*>(addr);
+ src_io.iov_len = sizeof(phdr);
+ dst_io.iov_base = &phdr;
+ dst_io.iov_len = sizeof(phdr);
+ rc = process_vm_readv(getpid(), &dst_io, 1, &src_io, 1, 0);
+ if (rc != sizeof(phdr)) {
+ return 0;
}
if ((phdr.p_type == PT_LOAD) && (phdr.p_flags & PF_X) ) {
- if (!get_val<ElfW(Addr)>(entry, addr + offsetof(ElfW(Phdr), p_vaddr), &phdr.p_vaddr)) {
- return;
- }
- entry->load_bias = phdr.p_vaddr - phdr.p_offset;
- return;
+ load_bias_ = phdr.p_vaddr - phdr.p_offset;
+ return load_bias_;
}
addr += sizeof(phdr);
}
+ return 0;
}
-static void inline init(MapEntry* entry) {
- if (entry->init) {
- return;
- }
- entry->init = true;
- if (valid_elf(entry)) {
- entry->valid = true;
- read_loadbias(entry);
- }
-}
-
-bool MapData::ReadMaps() {
+void MapData::ReadMaps() {
+ std::lock_guard<std::mutex> lock(m_);
FILE* fp = fopen("/proc/self/maps", "re");
if (fp == nullptr) {
- return false;
+ return;
}
+ ClearEntries();
+
std::vector<char> buffer(1024);
while (fgets(buffer.data(), buffer.size(), fp) != nullptr) {
MapEntry* entry = parse_line(buffer.data());
if (entry == nullptr) {
- fclose(fp);
- return false;
+ break;
}
-
- auto it = entries_.find(entry);
- if (it == entries_.end()) {
- entries_.insert(entry);
- } else {
- delete entry;
- }
+ entries_.insert(entry);
}
fclose(fp);
- return true;
}
-MapData::~MapData() {
+void MapData::ClearEntries() {
for (auto* entry : entries_) {
delete entry;
}
entries_.clear();
}
+MapData::~MapData() {
+ ClearEntries();
+}
+
// Find the containing map info for the PC.
const MapEntry* MapData::find(uintptr_t pc, uintptr_t* rel_pc) {
MapEntry pc_entry(pc);
std::lock_guard<std::mutex> lock(m_);
-
auto it = entries_.find(&pc_entry);
if (it == entries_.end()) {
- ReadMaps();
- }
- it = entries_.find(&pc_entry);
- if (it == entries_.end()) {
return nullptr;
}
MapEntry* entry = *it;
- init(entry);
+ entry->Init();
if (rel_pc != nullptr) {
// Need to check to see if this is a read-execute map and the read-only
// map is the previous one.
- if (!entry->valid && it != entries_.begin()) {
+ if (!entry->valid() && it != entries_.begin()) {
MapEntry* prev_entry = *--it;
- if (prev_entry->flags == PROT_READ && prev_entry->offset < entry->offset &&
- prev_entry->name == entry->name) {
- init(prev_entry);
+ if (prev_entry->flags() == PROT_READ && prev_entry->offset() < entry->offset() &&
+ prev_entry->name() == entry->name()) {
+ prev_entry->Init();
- if (prev_entry->valid) {
- entry->elf_start_offset = prev_entry->offset;
- *rel_pc = pc - entry->start + entry->offset + prev_entry->load_bias;
+ if (prev_entry->valid()) {
+ entry->set_elf_start_offset(prev_entry->offset());
+ *rel_pc = pc - entry->start() + entry->offset() + prev_entry->GetLoadBias();
return entry;
}
}
}
- *rel_pc = pc - entry->start + entry->offset + entry->load_bias;
+ *rel_pc = pc - entry->start() + entry->offset() + entry->GetLoadBias();
}
return entry;
}
diff --git a/libc/malloc_debug/MapData.h b/libc/malloc_debug/MapData.h
index f2b3c1c..13bf9cb 100644
--- a/libc/malloc_debug/MapData.h
+++ b/libc/malloc_debug/MapData.h
@@ -36,26 +36,50 @@
#include <platform/bionic/macros.h>
-struct MapEntry {
- MapEntry(uintptr_t start, uintptr_t end, uintptr_t offset, const char* name, size_t name_len, int flags)
- : start(start), end(end), offset(offset), name(name, name_len), flags(flags) {}
+class MapEntry {
+ public:
+ MapEntry() = default;
+ MapEntry(uintptr_t start, uintptr_t end, uintptr_t offset, const char* name, size_t name_len,
+ int flags)
+ : start_(start), end_(end), offset_(offset), name_(name, name_len), flags_(flags) {}
- explicit MapEntry(uintptr_t pc) : start(pc), end(pc) {}
+ explicit MapEntry(uintptr_t pc) : start_(pc), end_(pc) {}
- uintptr_t start;
- uintptr_t end;
- uintptr_t offset;
- uintptr_t load_bias;
- uintptr_t elf_start_offset = 0;
- std::string name;
- int flags;
- bool init = false;
- bool valid = false;
+ void Init();
+
+ uintptr_t GetLoadBias();
+
+ void SetInvalid() {
+ valid_ = false;
+ init_ = true;
+ load_bias_read_ = true;
+ }
+
+ bool valid() { return valid_; }
+ uintptr_t start() const { return start_; }
+ uintptr_t end() const { return end_; }
+ uintptr_t offset() const { return offset_; }
+ uintptr_t elf_start_offset() const { return elf_start_offset_; }
+ void set_elf_start_offset(uintptr_t elf_start_offset) { elf_start_offset_ = elf_start_offset; }
+ const std::string& name() const { return name_; }
+ int flags() const { return flags_; }
+
+ private:
+ uintptr_t start_;
+ uintptr_t end_;
+ uintptr_t offset_;
+ uintptr_t load_bias_ = 0;
+ uintptr_t elf_start_offset_ = 0;
+ std::string name_;
+ int flags_;
+ bool init_ = false;
+ bool valid_ = false;
+ bool load_bias_read_ = false;
};
// Ordering comparator that returns equivalence for overlapping entries
struct compare_entries {
- bool operator()(const MapEntry* a, const MapEntry* b) const { return a->end <= b->start; }
+ bool operator()(const MapEntry* a, const MapEntry* b) const { return a->end() <= b->start(); }
};
class MapData {
@@ -65,11 +89,15 @@
const MapEntry* find(uintptr_t pc, uintptr_t* rel_pc = nullptr);
- private:
- bool ReadMaps();
+ size_t NumMaps() { return entries_.size(); }
+ void ReadMaps();
+
+ private:
std::mutex m_;
std::set<MapEntry*, compare_entries> entries_;
+ void ClearEntries();
+
BIONIC_DISALLOW_COPY_AND_ASSIGN(MapData);
};
diff --git a/libc/malloc_debug/README.md b/libc/malloc_debug/README.md
index 4e39bed..750a469 100644
--- a/libc/malloc_debug/README.md
+++ b/libc/malloc_debug/README.md
@@ -456,6 +456,19 @@
**NOTE**: This option is not available until the O release of Android.
+### record\_allocs\_on\_exit
+This option only has meaning if record\_allocs is set. It indicates that
+when the process terminates, the record file should be created
+automatically.
+
+The only caveat to this option is that when the process terminates,
+the file that will contain the records will be the normal file name
+with **.PID** appended. Where PID is the pid of the process that has
+terminated. This is to avoid cases where a number of processes exit
+at the same time and attempt to write to the same file.
+
+**NOTE**: This option is not available until the V release of Android.
+
### verify\_pointers
Track all live allocations to determine if a pointer is used that does not
exist. This option is a lightweight way to verify that all
diff --git a/libc/malloc_debug/RecordData.cpp b/libc/malloc_debug/RecordData.cpp
index 8a77170..79e051b 100644
--- a/libc/malloc_debug/RecordData.cpp
+++ b/libc/malloc_debug/RecordData.cpp
@@ -131,17 +131,30 @@
record_obj_->WriteEntries();
}
+void RecordData::WriteEntriesOnExit() {
+ if (record_obj_ == nullptr) return;
+
+ // Append the current pid to the file name to avoid multiple processes
+ // writing to the same file.
+ std::string file(record_obj_->file());
+ file += "." + std::to_string(getpid());
+ record_obj_->WriteEntries(file);
+}
+
void RecordData::WriteEntries() {
+ WriteEntries(file_);
+}
+
+void RecordData::WriteEntries(const std::string& file) {
std::lock_guard<std::mutex> entries_lock(entries_lock_);
if (cur_index_ == 0) {
info_log("No alloc entries to write.");
return;
}
- int dump_fd =
- open(dump_file_.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0755);
+ int dump_fd = open(file.c_str(), O_WRONLY | O_CREAT | O_TRUNC | O_CLOEXEC | O_NOFOLLOW, 0755);
if (dump_fd == -1) {
- error_log("Cannot create record alloc file %s: %s", dump_file_.c_str(), strerror(errno));
+ error_log("Cannot create record alloc file %s: %s", file.c_str(), strerror(errno));
return;
}
@@ -179,7 +192,7 @@
entries_.resize(config.record_allocs_num_entries());
cur_index_ = 0U;
- dump_file_ = config.record_allocs_file();
+ file_ = config.record_allocs_file();
return true;
}
diff --git a/libc/malloc_debug/RecordData.h b/libc/malloc_debug/RecordData.h
index a02c956..7efa1f7 100644
--- a/libc/malloc_debug/RecordData.h
+++ b/libc/malloc_debug/RecordData.h
@@ -162,19 +162,23 @@
void AddEntry(const RecordEntry* entry);
void AddEntryOnly(const RecordEntry* entry);
+ const std::string& file() { return file_; }
pthread_key_t key() { return key_; }
+ static void WriteEntriesOnExit();
+
private:
static void WriteData(int, siginfo_t*, void*);
static RecordData* record_obj_;
void WriteEntries();
+ void WriteEntries(const std::string& file);
std::mutex entries_lock_;
pthread_key_t key_;
std::vector<std::unique_ptr<const RecordEntry>> entries_;
size_t cur_index_;
- std::string dump_file_;
+ std::string file_;
BIONIC_DISALLOW_COPY_AND_ASSIGN(RecordData);
};
diff --git a/libc/malloc_debug/backtrace.cpp b/libc/malloc_debug/backtrace.cpp
index ecb3a80..6a32fca 100644
--- a/libc/malloc_debug/backtrace.cpp
+++ b/libc/malloc_debug/backtrace.cpp
@@ -50,7 +50,7 @@
typedef struct _Unwind_Context __unwind_context;
static MapData g_map_data;
-static const MapEntry* g_current_code_map = nullptr;
+static MapEntry g_current_code_map;
static _Unwind_Reason_Code find_current_map(__unwind_context* context, void*) {
uintptr_t ip = _Unwind_GetIP(context);
@@ -58,11 +58,15 @@
if (ip == 0) {
return _URC_END_OF_STACK;
}
- g_current_code_map = g_map_data.find(ip);
+ auto map = g_map_data.find(ip);
+ if (map != nullptr) {
+ g_current_code_map = *map;
+ }
return _URC_END_OF_STACK;
}
void backtrace_startup() {
+ g_map_data.ReadMaps();
_Unwind_Backtrace(find_current_map, nullptr);
}
@@ -98,7 +102,8 @@
}
// Do not record the frames that fall in our own shared library.
- if (g_current_code_map && (ip >= g_current_code_map->start) && ip < g_current_code_map->end) {
+ if (g_current_code_map.start() != 0 && (ip >= g_current_code_map.start()) &&
+ ip < g_current_code_map.end()) {
return _URC_NO_REASON;
}
@@ -113,6 +118,10 @@
}
std::string backtrace_string(const uintptr_t* frames, size_t frame_count) {
+ if (g_map_data.NumMaps() == 0) {
+ g_map_data.ReadMaps();
+ }
+
std::string str;
for (size_t frame_num = 0; frame_num < frame_count; frame_num++) {
@@ -130,14 +139,15 @@
uintptr_t rel_pc = offset;
const MapEntry* entry = g_map_data.find(frames[frame_num], &rel_pc);
- const char* soname = (entry != nullptr) ? entry->name.c_str() : info.dli_fname;
+ const char* soname = (entry != nullptr) ? entry->name().c_str() : info.dli_fname;
if (soname == nullptr) {
soname = "<unknown>";
}
char offset_buf[128];
- if (entry != nullptr && entry->elf_start_offset != 0) {
- snprintf(offset_buf, sizeof(offset_buf), " (offset 0x%" PRIxPTR ")", entry->elf_start_offset);
+ if (entry != nullptr && entry->elf_start_offset() != 0) {
+ snprintf(offset_buf, sizeof(offset_buf), " (offset 0x%" PRIxPTR ")",
+ entry->elf_start_offset());
} else {
offset_buf[0] = '\0';
}
@@ -167,5 +177,6 @@
}
void backtrace_log(const uintptr_t* frames, size_t frame_count) {
+ g_map_data.ReadMaps();
error_log_string(backtrace_string(frames, frame_count).c_str());
}
diff --git a/libc/malloc_debug/malloc_debug.cpp b/libc/malloc_debug/malloc_debug.cpp
index b66b8e2..3743852 100644
--- a/libc/malloc_debug/malloc_debug.cpp
+++ b/libc/malloc_debug/malloc_debug.cpp
@@ -451,12 +451,20 @@
PointerData::LogLeaks();
}
+ if ((g_debug->config().options() & RECORD_ALLOCS) && g_debug->config().record_allocs_on_exit()) {
+ RecordData::WriteEntriesOnExit();
+ }
+
if ((g_debug->config().options() & BACKTRACE) && g_debug->config().backtrace_dump_on_exit()) {
debug_dump_heap(android::base::StringPrintf("%s.%d.exit.txt",
g_debug->config().backtrace_dump_prefix().c_str(),
getpid()).c_str());
}
+ if (g_debug->config().options() & LOG_ALLOCATOR_STATS_ON_EXIT) {
+ LogAllocatorStats::Log();
+ }
+
backtrace_shutdown();
// In order to prevent any issues of threads freeing previous pointers
diff --git a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
index 84c9145..d33f9cd 100644
--- a/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_config_tests.cpp
@@ -571,6 +571,25 @@
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugConfigTest, record_allocs_on_exit) {
+ ASSERT_TRUE(InitConfig("record_allocs_on_exit")) << getFakeLogPrint();
+ ASSERT_EQ(0U, config->options());
+ ASSERT_TRUE(config->record_allocs_on_exit());
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
+TEST_F(MallocDebugConfigTest, record_allocs_on_exit_error) {
+ ASSERT_FALSE(InitConfig("record_allocs_on_exit=something")) << getFakeLogPrint();
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ std::string log_msg(
+ "6 malloc_debug malloc_testing: value set for option 'record_allocs_on_exit' "
+ "which does not take a value\n");
+ ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugConfigTest, guard_min_error) {
ASSERT_FALSE(InitConfig("guard=0"));
@@ -842,6 +861,24 @@
ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugConfigTest, log_allocator_stats_on_exit) {
+ ASSERT_TRUE(InitConfig("log_allocator_stats_on_exit")) << getFakeLogPrint();
+ ASSERT_EQ(LOG_ALLOCATOR_STATS_ON_EXIT, config->options());
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
+TEST_F(MallocDebugConfigTest, trigger_log_allocator_stats_on_exit_fail) {
+ ASSERT_FALSE(InitConfig("log_allocator_stats_on_exit=200")) << getFakeLogPrint();
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ std::string log_msg(
+ "6 malloc_debug malloc_testing: value set for option 'log_allocator_stats_on_exit' "
+ "which does not take a value\n");
+ ASSERT_STREQ((log_msg + usage_string).c_str(), getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugConfigTest, size) {
ASSERT_TRUE(InitConfig("backtrace_size=37")) << getFakeLogPrint();
ASSERT_EQ(BACKTRACE_SPECIFIC_SIZES, config->options());
diff --git a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
index aee2572..d7a7a4f 100644
--- a/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_system_tests.cpp
@@ -77,7 +77,7 @@
// This avoids accidentally grabbing data from a previous process with
// the same pid.
log_start_time_ = {};
- logger_list* list = android_logger_list_open(LOG_ID_MAIN, ANDROID_LOG_NONBLOCK, 1000, 0);
+ logger_list* list = android_logger_list_open(LOG_ID_MAIN, ANDROID_LOG_NONBLOCK, INT_MAX, 0);
if (list == nullptr) {
return;
}
@@ -111,7 +111,7 @@
while (true) {
// Do not use non-blocking mode so that the two threads
// are essentially asleep and not consuming any cpu.
- list = android_logger_list_open(log, 0, 1000, pid);
+ list = android_logger_list_open(log, 0, INT_MAX, pid);
if (list != nullptr) {
break;
}
diff --git a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
index 334dada..c808dc0 100644
--- a/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
+++ b/libc/malloc_debug/tests/malloc_debug_unit_tests.cpp
@@ -185,6 +185,7 @@
}
static void VerifyRecords(std::vector<std::string>& expected, std::string& actual) {
+ ASSERT_TRUE(expected.size() != 0);
size_t offset = 0;
for (std::string& str : expected) {
ASSERT_STREQ(str.c_str(), actual.substr(offset, str.size()).c_str());
@@ -425,7 +426,7 @@
Init(
"guard backtrace backtrace_enable_on_signal fill expand_alloc free_track leak_track "
"record_allocs verify_pointers abort_on_error verbose check_unreachable_on_signal "
- "log_allocator_stats_on_signal");
+ "log_allocator_stats_on_signal log_allocator_stats_on_exit");
VerifyAllocCalls(true);
}
@@ -1512,7 +1513,7 @@
// Call the exit function manually.
debug_finalize();
- exit(0);
+ _exit(0);
}
ASSERT_NE(-1, pid);
ASSERT_EQ(pid, TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0)));
@@ -1561,7 +1562,7 @@
// Call the exit function manually.
debug_finalize();
- exit(0);
+ _exit(0);
}
ASSERT_NE(-1, pid);
ASSERT_EQ(pid, TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0)));
@@ -1619,7 +1620,7 @@
// Call the exit function manually.
debug_finalize();
- exit(0);
+ _exit(0);
}
ASSERT_NE(-1, pid);
ASSERT_EQ(pid, TEMP_FAILURE_RETRY(waitpid(pid, nullptr, 0)));
@@ -2429,6 +2430,33 @@
ASSERT_STREQ("", getFakeLogPrint().c_str());
}
+TEST_F(MallocDebugTest, record_allocs_on_exit) {
+ InitRecordAllocs("record_allocs record_allocs_on_exit");
+
+ // The filename created on exit always appends the pid.
+ // Modify the variable so the file is deleted at the end of the test.
+ record_filename += '.' + std::to_string(getpid());
+
+ std::vector<std::string> expected;
+ void* ptr = debug_malloc(100);
+ expected.push_back(android::base::StringPrintf("%d: malloc %p 100", getpid(), ptr));
+ ptr = debug_malloc(200);
+ expected.push_back(android::base::StringPrintf("%d: malloc %p 200", getpid(), ptr));
+ ptr = debug_malloc(400);
+ expected.push_back(android::base::StringPrintf("%d: malloc %p 400", getpid(), ptr));
+
+ // Call the exit function manually.
+ debug_finalize();
+
+ // Read all of the contents.
+ std::string actual;
+ ASSERT_TRUE(android::base::ReadFileToString(record_filename, &actual));
+ VerifyRecords(expected, actual);
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ ASSERT_STREQ("", getFakeLogPrint().c_str());
+}
+
TEST_F(MallocDebugTest, verify_pointers) {
Init("verify_pointers");
@@ -2816,6 +2844,25 @@
}
}
+TEST_F(MallocDebugTest, log_allocator_stats_on_exit) {
+ Init("log_allocator_stats_on_exit");
+
+ void* pointer = debug_malloc(110);
+ ASSERT_TRUE(pointer != nullptr);
+ debug_free(pointer);
+
+ debug_finalize();
+
+ ASSERT_STREQ("", getFakeLogBuf().c_str());
+ if (!running_with_hwasan()) {
+ // Do an exact match because the mallopt should not fail in normal operation.
+ ASSERT_STREQ("4 malloc_debug Logging allocator stats...\n", getFakeLogPrint().c_str());
+ } else {
+ // mallopt fails with hwasan, so just verify that the message is present.
+ ASSERT_MATCH(getFakeLogPrint(), "4 malloc_debug Logging allocator stats...\\n");
+ }
+}
+
TEST_F(MallocDebugTest, backtrace_only_some_sizes_with_backtrace_size) {
Init("leak_track backtrace backtrace_size=120");
diff --git a/libc/platform/bionic/malloc.h b/libc/platform/bionic/malloc.h
index ffc6d4a..da85cf5 100644
--- a/libc/platform/bionic/malloc.h
+++ b/libc/platform/bionic/malloc.h
@@ -130,36 +130,55 @@
// Worth noting, the "libc.debug.gwp_asan.*.app_default" sysprops *do not*
// apply to system apps. They use the "libc.debug.gwp_asan.*.system_default"
// sysprops.
- enum Action {
- // Enable GWP-ASan. This is used by apps that have `gwpAsanMode=always` in
- // the manifest.
- TURN_ON_FOR_APP,
- // Enable GWP-ASan, but only a small percentage of the time. This is used by
- // system processes and system apps, and we use a lottery to determine which
- // processes have GWP-ASan enabled. This allows us to mitigate system-wide
- // memory overhead concerns, as each GWP-ASan enabled process uses ~70KiB of
- // extra memory.
- TURN_ON_WITH_SAMPLING,
- // Don't enable GWP-ASan, unless overwritten by a system property or
- // environment variable. This is used by apps that have `gwpAsanMode=never`
- // in the manifest. Prior to Android 14, this also was used by non-system
- // apps that didn't specify a `gwpAsanMode` in their manifest.
- DONT_TURN_ON_UNLESS_OVERRIDDEN,
- // Enable GWP-ASan, but only a small percentage of the time, and enable it
- // in the non-crashing ("recoverable") mode. In Android 14, this is used by
- // apps that don't specify `gwpAsanMode` (or use `gwpAsanMode=default`) in
- // their manifest. GWP-ASan will detect heap memory safety bugs in this
- // mode, and bug reports will be created by debuggerd, however the process
- // will recover and continue to function as if the memory safety bug wasn't
- // detected.
+ //
+ // In recoverable mode, GWP-ASan will detect heap memory safety bugs, and bug
+ // reports will be created by debuggerd, however the process will recover and
+ // continue to function as if the memory safety bug wasn't detected. This
+ // prevents any user-visible impact as apps and processes don't crash, and
+ // probably saves us some CPU time in restarting the process.
+ //
+ // Process sampling enables GWP-ASan, but only a small percentage of the time
+ // (~1%). This helps mitigate any recurring high-frequency problems in certain
+ // processes, as it's highly likely the next restart of said process won't
+ // have GWP-ASan. In addition, for system processes and system apps, this
+ // allows us to mitigate system-wide memory overhead concerns, as each
+ // GWP-ASan enabled process uses ~70KiB of extra memory.
+ enum Mode {
+ // Used by default for apps, or by those that have an explicit
+ // `gwpAsanMode=default` in the manifest.
//
- // In Android 15, this is the same as TURN_ON_WITH_SAMPLING, as GWP-ASan is
- // only ever used in non-crashing mode (even for platform executables and
- // system apps).
- TURN_ON_FOR_APP_SAMPLED_NON_CRASHING,
+ // Result:
+ // - Android 13 and before: GWP-ASan is not enabled.
+ // - Android 14 and after: Enables GWP-ASan with process sampling in
+ // recoverable mode.
+ APP_MANIFEST_DEFAULT = 3,
+ // This is used by apps that have `gwpAsanMode=always` in the manifest.
+ //
+ // Result:
+ // - Android 14 and before: Enables GWP-ASan in non-recoverable mode,
+ // without process sampling.
+ // - Android 15 and after: Enables GWP-ASan in recoverable mode, without
+ // process sampling.
+ APP_MANIFEST_ALWAYS = 0,
+ // This is used by apps that have `gwpAsanMode=never` in the manifest.
+ //
+ // Result:
+ // - GWP-ASan is not enabled, unless it's force-enabled by a system
+ // property or environment variable.
+ APP_MANIFEST_NEVER = 2,
+ // Used by system processes and system apps.
+ //
+ // Result:
+ // - Android 14 and before: Enables GWP-ASan with process sampling in
+ // non-recoverable mode.
+ // - Android 15 and after: Enables GWP-ASan with process sampling in
+ // recoverable mode.
+ SYSTEM_PROCESS_OR_SYSTEM_APP = 1,
+ // Next enum value = 4. Numbered non-sequentially above to preserve ABI
+ // stability, but now ordered more logically.
};
- Action desire = DONT_TURN_ON_UNLESS_OVERRIDDEN;
+ Mode mode = APP_MANIFEST_NEVER;
} android_mallopt_gwp_asan_options_t;
#pragma clang diagnostic pop
// Manipulates bionic-specific handling of memory allocation APIs such as
diff --git a/libc/platform/bionic/mte.h b/libc/platform/bionic/mte.h
index 73cd821..98b3d27 100644
--- a/libc/platform/bionic/mte.h
+++ b/libc/platform/bionic/mte.h
@@ -29,8 +29,11 @@
#pragma once
#include <sys/auxv.h>
+#include <sys/mman.h>
#include <sys/prctl.h>
+#include "page.h"
+
// Note: Most PR_MTE_* constants come from the upstream kernel. This tag mask
// allows for the hardware to provision any nonzero tag. Zero tags are reserved
// for scudo to use for the chunk headers in order to prevent linear heap
@@ -63,6 +66,65 @@
}
}
};
+
+// N.B. that this is NOT the pagesize, but 4096. This is hardcoded in the codegen.
+// See
+// https://github.com/search?q=repo%3Allvm/llvm-project%20AArch64StackTagging%3A%3AinsertBaseTaggedPointer&type=code
+constexpr size_t kStackMteRingbufferSizeMultiplier = 4096;
+
+inline size_t stack_mte_ringbuffer_size(uintptr_t size_cls) {
+ return kStackMteRingbufferSizeMultiplier * (1 << size_cls);
+}
+
+inline size_t stack_mte_ringbuffer_size_from_pointer(uintptr_t ptr) {
+ // The size in the top byte is not the size_cls, but the number of "pages" (not OS pages, but
+ // kStackMteRingbufferSizeMultiplier).
+ return kStackMteRingbufferSizeMultiplier * (ptr >> 56ULL);
+}
+
+inline uintptr_t stack_mte_ringbuffer_size_add_to_pointer(uintptr_t ptr, uintptr_t size_cls) {
+ return ptr | ((1ULL << size_cls) << 56ULL);
+}
+
+inline void* stack_mte_ringbuffer_allocate(size_t n, const char* name) {
+ if (n > 7) return nullptr;
+ // Allocation needs to be aligned to 2*size to make the fancy code-gen work.
+ // So we allocate 3*size - pagesz bytes, which will always contain size bytes
+ // aligned to 2*size, and unmap the unneeded part.
+ // See
+ // https://github.com/search?q=repo%3Allvm/llvm-project%20AArch64StackTagging%3A%3AinsertBaseTaggedPointer&type=code
+ //
+ // In the worst case, we get an allocation that is one page past the properly
+ // aligned address, in which case we have to unmap the previous
+ // 2*size - pagesz bytes. In that case, we still have size properly aligned
+ // bytes left.
+ size_t size = stack_mte_ringbuffer_size(n);
+ size_t pgsize = page_size();
+
+ size_t alloc_size = __BIONIC_ALIGN(3 * size - pgsize, pgsize);
+ void* allocation_ptr =
+ mmap(nullptr, alloc_size, PROT_READ | PROT_WRITE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ if (allocation_ptr == MAP_FAILED)
+ return nullptr;
+ uintptr_t allocation = reinterpret_cast<uintptr_t>(allocation_ptr);
+
+ size_t alignment = 2 * size;
+ uintptr_t aligned_allocation = __BIONIC_ALIGN(allocation, alignment);
+ if (allocation != aligned_allocation) {
+ munmap(reinterpret_cast<void*>(allocation), aligned_allocation - allocation);
+ }
+ if (aligned_allocation + size != allocation + alloc_size) {
+ munmap(reinterpret_cast<void*>(aligned_allocation + size),
+ (allocation + alloc_size) - (aligned_allocation + size));
+ }
+
+ if (name) {
+ prctl(PR_SET_VMA, PR_SET_VMA_ANON_NAME, reinterpret_cast<void*>(aligned_allocation), size, name);
+ }
+
+ // We store the size in the top byte of the pointer (which is ignored)
+ return reinterpret_cast<void*>(stack_mte_ringbuffer_size_add_to_pointer(aligned_allocation, n));
+}
#else
struct ScopedDisableMTE {
// Silence unused variable warnings in non-aarch64 builds.
diff --git a/libc/platform/bionic/page.h b/libc/platform/bionic/page.h
index 65faba4..4dbe4ba 100644
--- a/libc/platform/bionic/page.h
+++ b/libc/platform/bionic/page.h
@@ -32,11 +32,13 @@
#endif
}
-constexpr size_t max_page_size() {
+// The maximum page size supported on any Android device. As
+// of API level 35, this is limited by ART.
+constexpr size_t max_android_page_size() {
#if defined(PAGE_SIZE)
return PAGE_SIZE;
#else
- return 65536;
+ return 16384;
#endif
}
diff --git a/libc/platform/bionic/reserved_signals.h b/libc/platform/bionic/reserved_signals.h
index dab58af..eb423f6 100644
--- a/libc/platform/bionic/reserved_signals.h
+++ b/libc/platform/bionic/reserved_signals.h
@@ -44,6 +44,7 @@
// 38 (__SIGRTMIN + 6) heapprofd ART managed heap dumps
// 39 (__SIGRTMIN + 7) fdtrack
// 40 (__SIGRTMIN + 8) android_run_on_all_threads (bionic/pthread_internal.cpp)
+// 41 (__SIGRTMIN + 9) re-enable MTE on thread
#define BIONIC_SIGNAL_POSIX_TIMERS (__SIGRTMIN + 0)
#define BIONIC_SIGNAL_BACKTRACE (__SIGRTMIN + 1)
@@ -52,8 +53,9 @@
#define BIONIC_SIGNAL_ART_PROFILER (__SIGRTMIN + 6)
#define BIONIC_SIGNAL_FDTRACK (__SIGRTMIN + 7)
#define BIONIC_SIGNAL_RUN_ON_ALL_THREADS (__SIGRTMIN + 8)
+#define BIONIC_ENABLE_MTE (__SIGRTMIN + 9)
-#define __SIGRT_RESERVED 9
+#define __SIGRT_RESERVED 10
static inline __always_inline sigset64_t filter_reserved_signals(sigset64_t sigset, int how) {
int (*block)(sigset64_t*, int);
int (*unblock)(sigset64_t*, int);
@@ -83,5 +85,6 @@
unblock(&sigset, __SIGRTMIN + 6);
unblock(&sigset, __SIGRTMIN + 7);
unblock(&sigset, __SIGRTMIN + 8);
+ unblock(&sigset, __SIGRTMIN + 9);
return sigset;
}
diff --git a/libc/platform/bionic/tls_defines.h b/libc/platform/bionic/tls_defines.h
index 8fe8701..06c6617 100644
--- a/libc/platform/bionic/tls_defines.h
+++ b/libc/platform/bionic/tls_defines.h
@@ -85,7 +85,8 @@
// [1] "Addenda to, and Errata in, the ABI for the ARM Architecture". Section 3.
// http://infocenter.arm.com/help/topic/com.arm.doc.ihi0045e/IHI0045E_ABI_addenda.pdf
-#define MIN_TLS_SLOT (-2) // update this value when reserving a slot
+#define MIN_TLS_SLOT (-3) // update this value when reserving a slot
+#define TLS_SLOT_STACK_MTE (-3)
#define TLS_SLOT_NATIVE_BRIDGE_GUEST_STATE (-2)
#define TLS_SLOT_BIONIC_TLS (-1)
#define TLS_SLOT_DTV 0
diff --git a/libc/private/CachedProperty.h b/libc/private/CachedProperty.h
index bd67d74..7accdb3 100644
--- a/libc/private/CachedProperty.h
+++ b/libc/private/CachedProperty.h
@@ -29,9 +29,7 @@
#pragma once
#include <string.h>
-
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
+#include <sys/system_properties.h>
// Cached system property lookup. For code that needs to read the same property multiple times,
// this class helps optimize those lookups.
diff --git a/libc/private/WriteProtected.h b/libc/private/WriteProtected.h
index bbe35e5..f269125 100644
--- a/libc/private/WriteProtected.h
+++ b/libc/private/WriteProtected.h
@@ -30,11 +30,11 @@
template <typename T>
union WriteProtectedContents {
T value;
- char padding[max_page_size()];
+ char padding[max_android_page_size()];
WriteProtectedContents() = default;
BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtectedContents);
-} __attribute__((aligned(max_page_size())));
+} __attribute__((aligned(max_android_page_size())));
// Write protected wrapper class that aligns its contents to a page boundary,
// and sets the memory protection to be non-writable, except when being modified
@@ -42,8 +42,8 @@
template <typename T>
class WriteProtected {
public:
- static_assert(sizeof(T) < max_page_size(),
- "WriteProtected only supports contents up to max_page_size()");
+ static_assert(sizeof(T) < max_android_page_size(),
+ "WriteProtected only supports contents up to max_android_page_size()");
WriteProtected() = default;
BIONIC_DISALLOW_COPY_AND_ASSIGN(WriteProtected);
@@ -89,7 +89,7 @@
// ourselves.
addr = untag_address(addr);
#endif
- if (mprotect(reinterpret_cast<void*>(addr), max_page_size(), prot) == -1) {
+ if (mprotect(reinterpret_cast<void*>(addr), max_android_page_size(), prot) == -1) {
async_safe_fatal("WriteProtected mprotect %x failed: %s", prot, strerror(errno));
}
}
diff --git a/libc/private/bionic_allocator.h b/libc/private/bionic_allocator.h
index 342fd51..9872669 100644
--- a/libc/private/bionic_allocator.h
+++ b/libc/private/bionic_allocator.h
@@ -28,13 +28,9 @@
#pragma once
-#include <errno.h>
-#include <stdlib.h>
#include <sys/cdefs.h>
-#include <sys/mman.h>
-#include <sys/prctl.h>
#include <stddef.h>
-#include <unistd.h>
+#include <stdint.h>
const uint32_t kSmallObjectMaxSizeLog2 = 10;
const uint32_t kSmallObjectMinSizeLog2 = 4;
@@ -120,7 +116,8 @@
inline void* alloc_impl(size_t align, size_t size);
inline page_info* get_page_info_unchecked(void* ptr);
inline page_info* get_page_info(void* ptr);
- BionicSmallObjectAllocator* get_small_object_allocator(uint32_t type);
+ BionicSmallObjectAllocator* get_small_object_allocator_unchecked(uint32_t type);
+ BionicSmallObjectAllocator* get_small_object_allocator(page_info* pi, void* ptr);
void initialize_allocators();
BionicSmallObjectAllocator* allocators_;
diff --git a/libm/fenv-access.h b/libc/private/bionic_elf_dtv_offset.h
similarity index 66%
copy from libm/fenv-access.h
copy to libc/private/bionic_elf_dtv_offset.h
index 7acb34d..8d9f3b9 100644
--- a/libm/fenv-access.h
+++ b/libc/private/bionic_elf_dtv_offset.h
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2021 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -28,6 +28,17 @@
#pragma once
-#if defined(__x86_64__) || defined(__i386__)
-#pragma STDC FENV_ACCESS ON
+#if defined(__riscv)
+// TLS_DTV_OFFSET is a constant used in relocation fields, defined in RISC-V ELF Specification[1]
+// The front of the TCB contains a pointer to the DTV, and each pointer in DTV
+// points to 0x800 past the start of a TLS block to make full use of the range
+// of load/store instructions, refer to [2].
+//
+// [1]: RISC-V ELF Specification.
+// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#constants
+// [2]: Documentation of TLS data structures
+// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/53
+#define TLS_DTV_OFFSET 0x800
+#else
+#define TLS_DTV_OFFSET 0
#endif
diff --git a/libc/private/bionic_elf_tls.h b/libc/private/bionic_elf_tls.h
index 3a7b381..04297ad 100644
--- a/libc/private/bionic_elf_tls.h
+++ b/libc/private/bionic_elf_tls.h
@@ -34,6 +34,8 @@
#include <stdint.h>
#include <sys/cdefs.h>
+#include "bionic_elf_dtv_offset.h"
+
__LIBC_HIDDEN__ extern _Atomic(size_t) __libc_tls_generation_copy;
struct TlsAlign {
@@ -214,30 +216,16 @@
};
#if defined(__i386__)
-#define TLS_GET_ADDR_CCONV __attribute__((regparm(1)))
+#define TLS_GET_ADDR_CALLING_CONVENTION __attribute__((regparm(1)))
#define TLS_GET_ADDR ___tls_get_addr
#else
-#define TLS_GET_ADDR_CCONV
+#define TLS_GET_ADDR_CALLING_CONVENTION
#define TLS_GET_ADDR __tls_get_addr
#endif
-extern "C" void* TLS_GET_ADDR(const TlsIndex* ti) TLS_GET_ADDR_CCONV;
+extern "C" void* TLS_GET_ADDR(const TlsIndex* ti) TLS_GET_ADDR_CALLING_CONVENTION;
struct bionic_tcb;
void __free_dynamic_tls(bionic_tcb* tcb);
void __notify_thread_exit_callbacks();
-#if defined(__riscv)
-// TLS_DTV_OFFSET is a constant used in relocation fields, defined in RISC-V ELF Specification[1]
-// The front of the TCB contains a pointer to the DTV, and each pointer in DTV
-// points to 0x800 past the start of a TLS block to make full use of the range
-// of load/store instructions, refer to [2].
-//
-// [1]: RISC-V ELF Specification.
-// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/blob/master/riscv-elf.adoc#constants
-// [2]: Documentation of TLS data structures
-// https://github.com/riscv-non-isa/riscv-elf-psabi-doc/issues/53
-#define TLS_DTV_OFFSET 0x800
-#else
-#define TLS_DTV_OFFSET 0
-#endif
diff --git a/libc/private/bionic_globals.h b/libc/private/bionic_globals.h
index 0949056..a1bebda 100644
--- a/libc/private/bionic_globals.h
+++ b/libc/private/bionic_globals.h
@@ -76,10 +76,23 @@
};
__LIBC_HIDDEN__ extern WriteProtected<libc_globals> __libc_globals;
-// This cannot be in __libc_globals, because we cannot access the
+// These cannot be in __libc_globals, because we cannot access the
// WriteProtected in a thread-safe way.
// See b/328256432.
+//
+// __libc_memtag_stack says whether stack MTE is enabled on the process, i.e.
+// whether the stack pages are mapped with PROT_MTE. This is always false if
+// MTE is disabled for the process (i.e. libc_globals.memtag is false).
__LIBC_HIDDEN__ extern _Atomic(bool) __libc_memtag_stack;
+// __libc_memtag_stack_abi says whether the process contains any code that was
+// compiled with memtag-stack. This is true even if the process does not have
+// MTE enabled (e.g. because it was overridden using MEMTAG_OPTIONS, or because
+// MTE is disabled for the device).
+// Code compiled with memtag-stack needs a stack history buffer in
+// TLS_SLOT_STACK_MTE, because the codegen will emit an unconditional
+// (to keep the code branchless) write to it.
+// Protected by g_heap_creation_lock.
+__LIBC_HIDDEN__ extern bool __libc_memtag_stack_abi;
struct abort_msg_t;
struct crash_detail_page_t;
@@ -133,7 +146,9 @@
size_t scudo_stack_depot_size = 0;
HeapTaggingLevel initial_heap_tagging_level = M_HEAP_TAGGING_LEVEL_NONE;
+ // See comments for __libc_memtag_stack / __libc_memtag_stack_abi above.
bool initial_memtag_stack = false;
+ bool initial_memtag_stack_abi = false;
int64_t heap_tagging_upgrade_timer_sec = 0;
void (*memtag_stack_dlopen_callback)() = nullptr;
diff --git a/libc/private/bionic_ifuncs.h b/libc/private/bionic_ifuncs.h
index e6b349a..b31c903 100644
--- a/libc/private/bionic_ifuncs.h
+++ b/libc/private/bionic_ifuncs.h
@@ -31,6 +31,8 @@
#include <stdint.h>
#include <sys/ifunc.h>
+#include <private/bionic_call_ifunc_resolver.h>
+
#if defined(__aarch64__)
#define IFUNC_ARGS (uint64_t hwcap __attribute__((unused)), \
__ifunc_arg_t* arg __attribute__((unused)))
@@ -40,14 +42,6 @@
#define IFUNC_ARGS ()
#endif
-// We can't have HWASAN enabled in resolvers because they may be called before HWASAN is
-// initialized.
-#define DEFINE_IFUNC_FOR(name) \
- name##_func name __attribute__((ifunc(#name "_resolver"))); \
- __attribute__((visibility("hidden"))) \
- __attribute__((no_sanitize("hwaddress"))) \
- name##_func* name##_resolver IFUNC_ARGS
-
#define DECLARE_FUNC(type, name) \
__attribute__((visibility("hidden"))) \
type name
@@ -56,3 +50,137 @@
DECLARE_FUNC(type, name); \
return name; \
}
+
+#if defined(BIONIC_DYNAMIC_DISPATCH)
+
+// We can't have HWASAN enabled in resolvers because they may be called before
+// HWASAN is initialized.
+#define DEFINE_IFUNC_FOR(name) \
+ name##_func_t name __attribute__((ifunc(#name "_resolver"))); \
+ __attribute__((visibility("hidden"))) \
+ __attribute__((no_sanitize("hwaddress"))) name##_func_t* name##_resolver IFUNC_ARGS
+
+#define DEFINE_STATIC_SHIM(x)
+
+#elif defined(BIONIC_STATIC_DISPATCH)
+
+#define DEFINE_IFUNC_FOR(name) \
+ name##_func_t* name##_resolver IFUNC_ARGS; \
+ __attribute__((visibility("hidden"))) \
+ __attribute__((no_sanitize("hwaddress"))) name##_func_t* name##_resolver IFUNC_ARGS
+
+#define DEFINE_STATIC_SHIM(x) x
+
+#define FORWARD(name) \
+ static name##_func_t* fn = reinterpret_cast<name##_func_t*>( \
+ __bionic_call_ifunc_resolver(reinterpret_cast<ElfW(Addr)>(name##_resolver))); \
+ return fn
+
+#else
+#error neither dynamic nor static dispatch?!
+#endif
+
+typedef void* memchr_func_t(const void*, int, size_t);
+#define MEMCHR_SHIM() \
+ DEFINE_STATIC_SHIM(void* memchr(const void* src, int ch, size_t n) { \
+ FORWARD(memchr)(src, ch, n); \
+ })
+
+typedef int memcmp_func_t(const void*, const void*, size_t);
+#define MEMCMP_SHIM() \
+ DEFINE_STATIC_SHIM(int memcmp(const void* lhs, const void* rhs, size_t n) { \
+ FORWARD(memcmp)(lhs, rhs, n); \
+ })
+
+typedef void* memcpy_func_t(void*, const void*, size_t);
+#define MEMCPY_SHIM() \
+ DEFINE_STATIC_SHIM(void* memcpy(void* dst, const void* src, size_t n) { \
+ FORWARD(memcpy)(dst, src, n); \
+ })
+
+typedef void* memmove_func_t(void*, const void*, size_t);
+#define MEMMOVE_SHIM() \
+ DEFINE_STATIC_SHIM(void* memmove(void* dst, const void* src, size_t n) { \
+ FORWARD(memmove)(dst, src, n); \
+ })
+
+typedef int memrchr_func_t(const void*, int, size_t);
+#define MEMRCHR_SHIM() \
+ DEFINE_STATIC_SHIM(int memrchr(const void* src, int ch, size_t n) { \
+ FORWARD(memrchr)(src, ch, n); \
+ })
+
+typedef void* memset_func_t(void*, int, size_t);
+#define MEMSET_SHIM() \
+ DEFINE_STATIC_SHIM(void* memset(void* dst, int ch, size_t n) { FORWARD(memset)(dst, ch, n); })
+
+typedef void* __memset_chk_func_t(void*, int, size_t, size_t);
+#define __MEMSET_CHK_SHIM() \
+ DEFINE_STATIC_SHIM(void* __memset_chk(void* dst, int ch, size_t n, size_t n2) { \
+ FORWARD(__memset_chk)(dst, ch, n, n2); \
+ })
+
+typedef char* stpcpy_func_t(char*, const char*);
+#define STPCPY_SHIM() \
+ DEFINE_STATIC_SHIM(char* stpcpy(char* dst, const char* src) { FORWARD(stpcpy)(dst, src); })
+
+typedef char* strcat_func_t(char*, const char*);
+#define STRCAT_SHIM() \
+ DEFINE_STATIC_SHIM(char* strcat(char* dst, const char* src) { FORWARD(strcat)(dst, src); })
+
+typedef char* __strcat_chk_func_t(char*, const char*, size_t);
+#define __STRCAT_CHK_SHIM() \
+ DEFINE_STATIC_SHIM(char* __strcat_chk(char* dst, const char* src, size_t dst_buf_size) { \
+ FORWARD(__strcat_chk)(dst, src, dst_buf_size); \
+ })
+
+typedef char* strchr_func_t(const char*, int);
+#define STRCHR_SHIM() \
+ DEFINE_STATIC_SHIM(char* strchr(const char* src, int ch) { FORWARD(strchr)(src, ch); })
+
+typedef char* strchrnul_func_t(const char*, int);
+#define STRCHRNUL_SHIM() \
+ DEFINE_STATIC_SHIM(char* strchrnul(const char* src, int ch) { FORWARD(strchrnul)(src, ch); })
+
+typedef int strcmp_func_t(const char*, const char*);
+#define STRCMP_SHIM() \
+ DEFINE_STATIC_SHIM(int strcmp(char* lhs, const char* rhs) { FORWARD(strcmp)(lhs, rhs); })
+
+typedef char* strcpy_func_t(char*, const char*);
+#define STRCPY_SHIM() \
+ DEFINE_STATIC_SHIM(char* strcpy(char* dst, const char* src) { FORWARD(strcpy)(dst, src); })
+
+typedef char* __strcpy_chk_func_t(char*, const char*, size_t);
+#define __STRCPY_CHK_SHIM() \
+ DEFINE_STATIC_SHIM(char* __strcpy_chk(char* dst, const char* src, size_t dst_len) { \
+ FORWARD(__strcpy_chk)(dst, src, dst_len); \
+ })
+
+typedef size_t strlen_func_t(const char*);
+#define STRLEN_SHIM() DEFINE_STATIC_SHIM(size_t strlen(const char* s) { FORWARD(strlen)(s); })
+
+typedef char* strncat_func_t(char*, const char*, size_t);
+#define STRNCAT_SHIM() \
+ DEFINE_STATIC_SHIM(char* strncat(char* dst, const char* src, size_t n) { \
+ FORWARD(strncat)(dst, src, n); \
+ })
+
+typedef int strncmp_func_t(const char*, const char*, size_t);
+#define STRNCMP_SHIM() \
+ DEFINE_STATIC_SHIM(int strncmp(const char* lhs, const char* rhs, size_t n) { \
+ FORWARD(strncmp)(lhs, rhs, n); \
+ })
+
+typedef char* strncpy_func_t(char*, const char*, size_t);
+#define STRNCPY_SHIM() \
+ DEFINE_STATIC_SHIM(char* strncpy(char* dst, const char* src, size_t n) { \
+ FORWARD(strncpy)(dst, src, n); \
+ })
+
+typedef size_t strnlen_func_t(const char*, size_t);
+#define STRNLEN_SHIM() \
+ DEFINE_STATIC_SHIM(size_t strnlen(const char* s, size_t n) { FORWARD(strnlen)(s, n); })
+
+typedef char* strrchr_func_t(const char*, int);
+#define STRRCHR_SHIM() \
+ DEFINE_STATIC_SHIM(char* strrchr(const char* src, int ch) { FORWARD(strrchr)(src, ch); })
diff --git a/libc/private/icu.h b/libc/private/icu.h
index a671e98..8e4aa80 100644
--- a/libc/private/icu.h
+++ b/libc/private/icu.h
@@ -80,7 +80,8 @@
int8_t __icu_charType(wint_t wc);
int32_t __icu_getIntPropertyValue(wint_t wc, UProperty property);
-bool __icu_hasBinaryProperty(wint_t wc, UProperty property, int (*fallback)(int));
+
+typedef UBool (*u_hasBinaryProperty_t)(UChar32, UProperty);
void* __find_icu_symbol(const char* symbol_name);
diff --git a/libc/stdio/fmemopen.cpp b/libc/stdio/fmemopen.cpp
index 6e333ba..f069da4 100644
--- a/libc/stdio/fmemopen.cpp
+++ b/libc/stdio/fmemopen.cpp
@@ -33,8 +33,8 @@
#include "local.h"
-// See http://pubs.opengroup.org/onlinepubs/9699919799/functions/fmemopen.html
-// and http://man7.org/linux/man-pages/man3/fmemopen.3.html for documentation.
+// See https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/fmemopen.html
+// and https://man7.org/linux/man-pages/man3/fmemopen.3.html for documentation.
struct fmemopen_cookie {
char* buf;
diff --git a/libc/stdio/local.h b/libc/stdio/local.h
index 62efea1..a60468e 100644
--- a/libc/stdio/local.h
+++ b/libc/stdio/local.h
@@ -51,11 +51,7 @@
struct __sbuf {
unsigned char* _base;
-#if defined(__LP64__)
size_t _size;
-#else
- int _size;
-#endif
};
struct __sFILE {
diff --git a/libc/stdio/printf_common.h b/libc/stdio/printf_common.h
index 702f8d3..653bba2 100644
--- a/libc/stdio/printf_common.h
+++ b/libc/stdio/printf_common.h
@@ -85,6 +85,10 @@
// Helper function for `fprintf to unbuffered unix file': creates a
// temporary buffer. We only work on write-only files; this avoids
// worries about ungetc buffers and so forth.
+//
+// We prevent inlining because this massively increases the printf()
+// family's stack usage to support a rare case.
+__attribute__((__noinline__))
static int __sbprintf(FILE* fp, const CHAR_TYPE* fmt, va_list ap) {
FILE fake;
struct __sfileext fakeext;
diff --git a/libc/stdio/stdio.cpp b/libc/stdio/stdio.cpp
index f18cd81..37b9665 100644
--- a/libc/stdio/stdio.cpp
+++ b/libc/stdio/stdio.cpp
@@ -1079,6 +1079,26 @@
return __sflush(fp);
}
+int fpurge(FILE* fp) {
+ CHECK_FP(fp);
+
+ ScopedFileLock sfl(fp);
+
+ if (fp->_flags == 0) {
+ // Already freed!
+ errno = EBADF;
+ return EOF;
+ }
+
+ if (HASUB(fp)) FREEUB(fp);
+ WCIO_FREE(fp);
+ fp->_p = fp->_bf._base;
+ fp->_r = 0;
+ fp->_w = fp->_flags & (__SLBF | __SNBF) ? 0 : fp->_bf._size;
+ return 0;
+}
+__strong_alias(__fpurge, fpurge);
+
size_t fread(void* buf, size_t size, size_t count, FILE* fp) {
CHECK_FP(fp);
ScopedFileLock sfl(fp);
diff --git a/libc/stdio/stdio_ext.cpp b/libc/stdio/stdio_ext.cpp
index 99a8af7..3eb2f33 100644
--- a/libc/stdio/stdio_ext.cpp
+++ b/libc/stdio/stdio_ext.cpp
@@ -59,10 +59,6 @@
return (fp->_flags & __SLBF) != 0;
}
-void __fpurge(FILE* fp) {
- fpurge(fp);
-}
-
size_t __fpending(FILE* fp) {
return fp->_p - fp->_bf._base;
}
diff --git a/libc/stdio/vfprintf.cpp b/libc/stdio/vfprintf.cpp
index e0509aa..354317c 100644
--- a/libc/stdio/vfprintf.cpp
+++ b/libc/stdio/vfprintf.cpp
@@ -43,7 +43,7 @@
#define PRINT(ptr, len) \
do { \
- iovp->iov_base = (ptr); \
+ iovp->iov_base = (void*)(ptr); \
iovp->iov_len = (len); \
uio.uio_resid += (len); \
iovp++; \
@@ -125,10 +125,10 @@
* below longer.
*/
#define PADSIZE 16 /* pad chunk size */
- static CHAR_TYPE blanks[PADSIZE] = {
+ static const CHAR_TYPE blanks[PADSIZE] = {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
};
- static CHAR_TYPE zeroes[PADSIZE] = {
+ static const CHAR_TYPE zeroes[PADSIZE] = {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
};
diff --git a/libc/stdio/vfwprintf.cpp b/libc/stdio/vfwprintf.cpp
index 72f973c..89e889e 100644
--- a/libc/stdio/vfwprintf.cpp
+++ b/libc/stdio/vfwprintf.cpp
@@ -128,10 +128,10 @@
* below longer.
*/
#define PADSIZE 16 /* pad chunk size */
- static CHAR_TYPE blanks[PADSIZE] = {
+ static const CHAR_TYPE blanks[PADSIZE] = {
' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' ', ' '
};
- static CHAR_TYPE zeroes[PADSIZE] = {
+ static const CHAR_TYPE zeroes[PADSIZE] = {
'0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0', '0'
};
diff --git a/libc/system_properties/Android.bp b/libc/system_properties/Android.bp
index d45a2e3..e2fce34 100644
--- a/libc/system_properties/Android.bp
+++ b/libc/system_properties/Android.bp
@@ -11,7 +11,10 @@
cc_library_static {
name: "libsystemproperties",
- defaults: ["libc_defaults"],
+ defaults: [
+ "libc_defaults",
+ "large_system_property_node_defaults",
+ ],
native_bridge_supported: true,
srcs: [
"context_node.cpp",
@@ -54,3 +57,11 @@
"libasync_safe",
],
}
+
+cc_defaults {
+ name: "large_system_property_node_defaults",
+ cflags: select(release_flag("RELEASE_LARGE_SYSTEM_PROPERTY_NODE"), {
+ true: ["-DLARGE_SYSTEM_PROPERTY_NODE=1"],
+ default: [],
+ }),
+}
diff --git a/libc/system_properties/include/system_properties/properties_filename.h b/libc/system_properties/include/system_properties/properties_filename.h
index d686f20..743d291 100644
--- a/libc/system_properties/include/system_properties/properties_filename.h
+++ b/libc/system_properties/include/system_properties/properties_filename.h
@@ -46,6 +46,8 @@
const char* c_str() { return filename_; }
private:
- // Typically something like "/dev/__properties__/properties_serial".
- char filename_[128];
+ // Typically something like "/dev/__properties__/properties_serial", but can be as long as
+ // "/data/local/tmp/TemporaryDir-fntJb8/appcompat_override/u:object_r:PROPERTY_NAME_prop:s0"
+ // when running CTS.
+ char filename_[256];
};
diff --git a/libc/system_properties/prop_area.cpp b/libc/system_properties/prop_area.cpp
index 4668eed..9b153ca 100644
--- a/libc/system_properties/prop_area.cpp
+++ b/libc/system_properties/prop_area.cpp
@@ -41,7 +41,11 @@
#include <async_safe/log.h>
+#ifdef LARGE_SYSTEM_PROPERTY_NODE
+constexpr size_t PA_SIZE = 1024 * 1024;
+#else
constexpr size_t PA_SIZE = 128 * 1024;
+#endif
constexpr uint32_t PROP_AREA_MAGIC = 0x504f5250;
constexpr uint32_t PROP_AREA_VERSION = 0xfc6ed0ab;
@@ -335,8 +339,7 @@
uint_least32_t left_offset = atomic_load_explicit(&trie->left, memory_order_relaxed);
if (left_offset != 0) {
- const int err = foreach_property(to_prop_trie_node(&trie->left), propfn, cookie);
- if (err < 0) return false;
+ if (!foreach_property(to_prop_trie_node(&trie->left), propfn, cookie)) return false;
}
uint_least32_t prop_offset = atomic_load_explicit(&trie->prop, memory_order_relaxed);
if (prop_offset != 0) {
@@ -346,13 +349,11 @@
}
uint_least32_t children_offset = atomic_load_explicit(&trie->children, memory_order_relaxed);
if (children_offset != 0) {
- const int err = foreach_property(to_prop_trie_node(&trie->children), propfn, cookie);
- if (err < 0) return false;
+ if (!foreach_property(to_prop_trie_node(&trie->children), propfn, cookie)) return false;
}
uint_least32_t right_offset = atomic_load_explicit(&trie->right, memory_order_relaxed);
if (right_offset != 0) {
- const int err = foreach_property(to_prop_trie_node(&trie->right), propfn, cookie);
- if (err < 0) return false;
+ if (!foreach_property(to_prop_trie_node(&trie->right), propfn, cookie)) return false;
}
return true;
@@ -367,6 +368,6 @@
return find_property(root_node(), name, namelen, value, valuelen, true);
}
-bool prop_area::foreach (void (*propfn)(const prop_info* pi, void* cookie), void* cookie) {
+bool prop_area::foreach(void (*propfn)(const prop_info* pi, void* cookie), void* cookie) {
return foreach_property(root_node(), propfn, cookie);
}
diff --git a/libc/system_properties/system_properties.cpp b/libc/system_properties/system_properties.cpp
index 9dd5e35..e0d38a8 100644
--- a/libc/system_properties/system_properties.cpp
+++ b/libc/system_properties/system_properties.cpp
@@ -120,14 +120,18 @@
return false;
}
- auto* appcompat_contexts = new (appcompat_override_contexts_data_) ContextsSerialized();
appcompat_filename_ = PropertiesFilename(properties_filename_.c_str(), "appcompat_override");
- if (!appcompat_contexts->Initialize(true, appcompat_filename_.c_str(), fsetxattr_failed,
- load_default_path)) {
- appcompat_override_contexts_ = nullptr;
- return false;
+ appcompat_override_contexts_ = nullptr;
+ if (access(appcompat_filename_.c_str(), F_OK) != -1) {
+ auto* appcompat_contexts = new (appcompat_override_contexts_data_) ContextsSerialized();
+ if (!appcompat_contexts->Initialize(true, appcompat_filename_.c_str(), fsetxattr_failed,
+ load_default_path)) {
+ // The appcompat folder exists, but initializing it failed
+ return false;
+ } else {
+ appcompat_override_contexts_ = appcompat_contexts;
+ }
}
- appcompat_override_contexts_ = appcompat_contexts;
initialized_ = true;
return true;
@@ -333,31 +337,42 @@
int SystemProperties::Add(const char* name, unsigned int namelen, const char* value,
unsigned int valuelen) {
- if (valuelen >= PROP_VALUE_MAX && !is_read_only(name)) {
+ if (namelen < 1) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: name length 0");
return -1;
}
- if (namelen < 1) {
+ if (valuelen >= PROP_VALUE_MAX && !is_read_only(name)) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: \"%s\" value too long: %d >= PROP_VALUE_MAX",
+ name, valuelen);
return -1;
}
if (!initialized_) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: properties not initialized");
return -1;
}
prop_area* serial_pa = contexts_->GetSerialPropArea();
if (serial_pa == nullptr) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: property area not found");
return -1;
}
prop_area* pa = contexts_->GetPropAreaForName(name);
if (!pa) {
- async_safe_format_log(ANDROID_LOG_ERROR, "libc", "Access denied adding property \"%s\"", name);
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: access denied for \"%s\"", name);
return -1;
}
- bool ret = pa->add(name, namelen, value, valuelen);
- if (!ret) {
+ if (!pa->add(name, namelen, value, valuelen)) {
+ async_safe_format_log(ANDROID_LOG_ERROR, "libc",
+ "__system_property_add failed: add failed for \"%s\"", name);
return -1;
}
diff --git a/libc/tools/gensyscalls.py b/libc/tools/gensyscalls.py
index 8c457c8..d7afe2a 100755
--- a/libc/tools/gensyscalls.py
+++ b/libc/tools/gensyscalls.py
@@ -27,7 +27,7 @@
# ARM assembler templates for each syscall stub
#
-arm_eabi_call_default = syscall_stub_header + """\
+arm_call_default = syscall_stub_header + """\
mov ip, r7
.cfi_register r7, ip
ldr r7, =%(__NR_name)s
@@ -41,7 +41,7 @@
END(%(func)s)
"""
-arm_eabi_call_long = syscall_stub_header + """\
+arm_call_long = syscall_stub_header + """\
mov ip, sp
stmfd sp!, {r4, r5, r6, r7}
.cfi_def_cfa_offset 16
@@ -230,11 +230,11 @@
return stub
-def arm_eabi_genstub(syscall):
+def arm_genstub(syscall):
num_regs = count_arm_param_registers(syscall["params"])
if num_regs > 4:
- return arm_eabi_call_long % syscall
- return arm_eabi_call_default % syscall
+ return arm_call_long % syscall
+ return arm_call_default % syscall
def arm64_genstub(syscall):
@@ -456,7 +456,7 @@
syscall["__NR_name"] = make__NR_name(syscall["name"])
if "arm" in syscall:
- syscall["asm-arm"] = add_footer(32, arm_eabi_genstub(syscall), syscall)
+ syscall["asm-arm"] = add_footer(32, arm_genstub(syscall), syscall)
if "arm64" in syscall:
syscall["asm-arm64"] = add_footer(64, arm64_genstub(syscall), syscall)
diff --git a/libc/tzcode/strptime.c b/libc/tzcode/strptime.c
index ae7881e..20160c9 100644
--- a/libc/tzcode/strptime.c
+++ b/libc/tzcode/strptime.c
@@ -68,8 +68,8 @@
#define FIELD_TM_YDAY (1 << 3)
#define FIELD_TM_YEAR (1 << 4)
-static char gmt[] = { "GMT" };
-static char utc[] = { "UTC" };
+static const char gmt[] = { "GMT" };
+static const char utc[] = { "UTC" };
/* RFC-822/RFC-2822 */
static const char * const nast[5] = {
"EST", "CST", "MST", "PST", "\0\0\0"
@@ -97,6 +97,7 @@
return(_strptime(buf, fmt, tm, 1));
}
DEF_WEAK(strptime);
+__strong_alias(strptime_l, strptime);
static char *
_strptime(const char *buf, const char *fmt, struct tm *tm, int initialize)
diff --git a/libc/upstream-freebsd/lib/libc/stdlib/qsort_r.c b/libc/upstream-freebsd/lib/libc/stdlib/qsort_r.c
new file mode 100644
index 0000000..b382b40
--- /dev/null
+++ b/libc/upstream-freebsd/lib/libc/stdlib/qsort_r.c
@@ -0,0 +1,6 @@
+/*
+ * This file is in the public domain. Originally written by Garrett
+ * A. Wollman.
+ */
+#define I_AM_QSORT_R
+#include "qsort.c"
diff --git a/libc/upstream-openbsd/android/include/openbsd-compat.h b/libc/upstream-openbsd/android/include/openbsd-compat.h
index 8e6f87d..cbc52b5 100644
--- a/libc/upstream-openbsd/android/include/openbsd-compat.h
+++ b/libc/upstream-openbsd/android/include/openbsd-compat.h
@@ -42,23 +42,8 @@
#define PROTO_NORMAL(x)
-/* OpenBSD's <ctype.h> uses these names, which conflicted with stlport.
- * Additionally, we changed the numeric/digit type from N to D for libcxx.
- */
-#define _U _CTYPE_U
-#define _L _CTYPE_L
-#define _N _CTYPE_D
-#define _S _CTYPE_S
-#define _P _CTYPE_P
-#define _C _CTYPE_C
-#define _X _CTYPE_X
-#define _B _CTYPE_B
-
-/* OpenBSD has this, but we can't really implement it correctly on Linux. */
-#define issetugid() 0
-
#if !defined(ANDROID_HOST_MUSL)
-#define explicit_bzero(p, s) memset(p, 0, s)
+#define explicit_bzero(p, s) memset_explicit(p, 0, s)
#endif
#if defined(ANDROID_HOST_MUSL)
diff --git a/libc/upstream-openbsd/lib/libc/crypt/arc4random.c b/libc/upstream-openbsd/lib/libc/crypt/arc4random.c
index 8a4ecc9..0737cf3 100644
--- a/libc/upstream-openbsd/lib/libc/crypt/arc4random.c
+++ b/libc/upstream-openbsd/lib/libc/crypt/arc4random.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: arc4random.c,v 1.54 2015/09/13 08:31:47 guenther Exp $ */
+/* $OpenBSD: arc4random.c,v 1.58 2022/07/31 13:41:45 tb Exp $ */
/*
* Copyright (c) 1996, David Mazieres <dm@uun.org>
@@ -49,6 +49,8 @@
#define BLOCKSZ 64
#define RSBUFSZ (16*BLOCKSZ)
+#define REKEY_BASE (1024*1024) /* NB. should be a power of 2 */
+
/* Marked MAP_INHERIT_ZERO, so zero'd out in fork children. */
static struct _rs {
size_t rs_have; /* valid bytes at end of rs_buf */
@@ -78,7 +80,7 @@
abort();
}
- chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8, 0);
+ chacha_keysetup(&rsx->rs_chacha, buf, KEYSZ * 8);
chacha_ivsetup(&rsx->rs_chacha, buf + KEYSZ);
}
@@ -86,6 +88,7 @@
_rs_stir(void)
{
u_char rnd[KEYSZ + IVSZ];
+ uint32_t rekey_fuzz = 0;
if (getentropy(rnd, sizeof rnd) == -1)
_getentropy_fail();
@@ -100,7 +103,10 @@
rs->rs_have = 0;
memset(rsx->rs_buf, 0, sizeof(rsx->rs_buf));
- rs->rs_count = 1600000;
+ /* rekey interval should not be predictable */
+ chacha_encrypt_bytes(&rsx->rs_chacha, (uint8_t *)&rekey_fuzz,
+ (uint8_t *)&rekey_fuzz, sizeof(rekey_fuzz));
+ rs->rs_count = REKEY_BASE + (rekey_fuzz % REKEY_BASE);
}
static inline void
diff --git a/libc/upstream-openbsd/lib/libc/crypt/chacha_private.h b/libc/upstream-openbsd/lib/libc/crypt/chacha_private.h
index 7c3680f..b0427b6 100644
--- a/libc/upstream-openbsd/lib/libc/crypt/chacha_private.h
+++ b/libc/upstream-openbsd/lib/libc/crypt/chacha_private.h
@@ -4,7 +4,7 @@
Public domain.
*/
-/* $OpenBSD: chacha_private.h,v 1.2 2013/10/04 07:02:27 djm Exp $ */
+/* $OpenBSD: chacha_private.h,v 1.3 2022/02/28 21:56:29 dtucker Exp $ */
typedef unsigned char u8;
typedef unsigned int u32;
@@ -52,7 +52,7 @@
static const char tau[16] = "expand 16-byte k";
static void
-chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits,u32 ivbits)
+chacha_keysetup(chacha_ctx *x,const u8 *k,u32 kbits)
{
const char *constants;
diff --git a/libc/upstream-openbsd/lib/libc/gen/ctype_.c b/libc/upstream-openbsd/lib/libc/gen/ctype_.c
index 8972244..9742c9f 100644
--- a/libc/upstream-openbsd/lib/libc/gen/ctype_.c
+++ b/libc/upstream-openbsd/lib/libc/gen/ctype_.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ctype_.c,v 1.12 2015/09/19 04:02:21 guenther Exp $ */
+/* $OpenBSD: ctype_.c,v 1.13 2024/02/04 13:03:18 jca Exp $ */
/*
* Copyright (c) 1989 The Regents of the University of California.
* All rights reserved.
@@ -36,6 +36,16 @@
#include <ctype.h>
#include "ctype_private.h"
+/* Shorter names for the defines provided by <ctype.h> */
+#define _U _CTYPE_U
+#define _L _CTYPE_L
+#define _N _CTYPE_N
+#define _S _CTYPE_S
+#define _P _CTYPE_P
+#define _C _CTYPE_C
+#define _X _CTYPE_X
+#define _B _CTYPE_B
+
const char _C_ctype_[1 + CTYPE_NUM_CHARS] = {
0,
_C, _C, _C, _C, _C, _C, _C, _C,
diff --git a/libc/upstream-openbsd/lib/libc/gen/fnmatch.c b/libc/upstream-openbsd/lib/libc/gen/fnmatch.c
index ff6b26e..3ec0222 100644
--- a/libc/upstream-openbsd/lib/libc/gen/fnmatch.c
+++ b/libc/upstream-openbsd/lib/libc/gen/fnmatch.c
@@ -46,11 +46,11 @@
*
* Derived from The Open Group Base Specifications Issue 7, IEEE Std 1003.1-2008
* as described in;
- * http://pubs.opengroup.org/onlinepubs/9699919799/functions/fnmatch.html
+ * https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/fnmatch.html
*
* Filename pattern matches defined in section 2.13, "Pattern Matching Notation"
* from chapter 2. "Shell Command Language"
- * http://pubs.opengroup.org/onlinepubs/9699919799/utilities/V3_chap02.html#tag_18_13
+ * https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/utilities/V3_chap02.html#tag_18_13
* where; 1. A bracket expression starting with an unquoted <circumflex> '^'
* character CONTINUES to specify a non-matching list; 2. an explicit <period> '.'
* in a bracket expression matching list, e.g. "[.abc]" does NOT match a leading
@@ -61,7 +61,7 @@
*
* Bracket expansion defined in section 9.3.5, "RE Bracket Expression",
* from chapter 9, "Regular Expressions"
- * http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/V1_chap09.html#tag_09_03_05
+ * https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/basedefs/V1_chap09.html#tag_09_03_05
* with no support for collating symbols, equivalence class expressions or
* character class expressions. A partial range expression with a leading
* hyphen following a valid range expression will match only the ordinary
diff --git a/libc/upstream-openbsd/lib/libc/net/htonl.c b/libc/upstream-openbsd/lib/libc/net/htonl.c
index 6ee6e7e..58bfb46 100644
--- a/libc/upstream-openbsd/lib/libc/net/htonl.c
+++ b/libc/upstream-openbsd/lib/libc/net/htonl.c
@@ -1,6 +1,5 @@
-/* $OpenBSD: htonl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */
+/* $OpenBSD: htonl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */
/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
@@ -9,13 +8,8 @@
#undef htonl
-u_int32_t
-htonl(u_int32_t x)
+uint32_t
+htonl(uint32_t x)
{
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *)&x;
- return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
-#else
- return x;
-#endif
+ return htobe32(x);
}
diff --git a/libc/upstream-openbsd/lib/libc/net/htons.c b/libc/upstream-openbsd/lib/libc/net/htons.c
index f48d91e..28b13ce 100644
--- a/libc/upstream-openbsd/lib/libc/net/htons.c
+++ b/libc/upstream-openbsd/lib/libc/net/htons.c
@@ -1,6 +1,5 @@
-/* $OpenBSD: htons.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */
+/* $OpenBSD: htons.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */
/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
@@ -9,13 +8,8 @@
#undef htons
-u_int16_t
-htons(u_int16_t x)
+uint16_t
+htons(uint16_t x)
{
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *) &x;
- return (u_int16_t)(s[0] << 8 | s[1]);
-#else
- return x;
-#endif
+ return htobe16(x);
}
diff --git a/libc/upstream-openbsd/lib/libc/net/ntohl.c b/libc/upstream-openbsd/lib/libc/net/ntohl.c
index 0d05bac..7592398 100644
--- a/libc/upstream-openbsd/lib/libc/net/ntohl.c
+++ b/libc/upstream-openbsd/lib/libc/net/ntohl.c
@@ -1,6 +1,5 @@
-/* $OpenBSD: ntohl.c,v 1.7 2014/07/21 01:51:10 guenther Exp $ */
+/* $OpenBSD: ntohl.c,v 1.8 2024/04/15 14:30:48 naddy Exp $ */
/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
@@ -9,13 +8,8 @@
#undef ntohl
-u_int32_t
-ntohl(u_int32_t x)
+uint32_t
+ntohl(uint32_t x)
{
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *)&x;
- return (u_int32_t)(s[0] << 24 | s[1] << 16 | s[2] << 8 | s[3]);
-#else
- return x;
-#endif
+ return be32toh(x);
}
diff --git a/libc/upstream-openbsd/lib/libc/net/ntohs.c b/libc/upstream-openbsd/lib/libc/net/ntohs.c
index b5ea361..ef22ea3 100644
--- a/libc/upstream-openbsd/lib/libc/net/ntohs.c
+++ b/libc/upstream-openbsd/lib/libc/net/ntohs.c
@@ -1,6 +1,5 @@
-/* $OpenBSD: ntohs.c,v 1.9 2014/07/21 01:51:10 guenther Exp $ */
+/* $OpenBSD: ntohs.c,v 1.10 2024/04/15 14:30:48 naddy Exp $ */
/*
- * Written by J.T. Conklin <jtc@netbsd.org>.
* Public domain.
*/
@@ -9,13 +8,8 @@
#undef ntohs
-u_int16_t
-ntohs(u_int16_t x)
+uint16_t
+ntohs(uint16_t x)
{
-#if BYTE_ORDER == LITTLE_ENDIAN
- u_char *s = (u_char *) &x;
- return (u_int16_t)(s[0] << 8 | s[1]);
-#else
- return x;
-#endif
+ return be16toh(x);
}
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fpurge.c b/libc/upstream-openbsd/lib/libc/stdio/fpurge.c
deleted file mode 100644
index 8dd8a91..0000000
--- a/libc/upstream-openbsd/lib/libc/stdio/fpurge.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/* $OpenBSD: fpurge.c,v 1.10 2015/08/31 02:53:57 guenther Exp $ */
-/*-
- * Copyright (c) 1990, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Chris Torek.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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.
- * 3. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS 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 REGENTS 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.
- */
-
-#include <errno.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include "local.h"
-
-/*
- * fpurge: like fflush, but without writing anything: leave the
- * given FILE's buffer empty.
- */
-int
-fpurge(FILE *fp)
-{
- FLOCKFILE(fp);
- if (!fp->_flags) {
- FUNLOCKFILE(fp);
- errno = EBADF;
- return(EOF);
- }
-
- if (HASUB(fp))
- FREEUB(fp);
- WCIO_FREE(fp);
- fp->_p = fp->_bf._base;
- fp->_r = 0;
- fp->_w = fp->_flags & (__SLBF|__SNBF) ? 0 : fp->_bf._size;
- FUNLOCKFILE(fp);
- return (0);
-}
-DEF_WEAK(fpurge);
diff --git a/libc/upstream-openbsd/lib/libc/stdio/fvwrite.c b/libc/upstream-openbsd/lib/libc/stdio/fvwrite.c
index d83de88..d615245 100644
--- a/libc/upstream-openbsd/lib/libc/stdio/fvwrite.c
+++ b/libc/upstream-openbsd/lib/libc/stdio/fvwrite.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: fvwrite.c,v 1.21 2023/10/06 16:41:02 millert Exp $ */
+/* $OpenBSD: fvwrite.c,v 1.22 2024/04/28 14:28:02 millert Exp $ */
/*-
* Copyright (c) 1990, 1993
* The Regents of the University of California. All rights reserved.
@@ -31,6 +31,7 @@
* SUCH DAMAGE.
*/
+#include <limits.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -76,11 +77,12 @@
}
if (fp->_flags & __SNBF) {
/*
- * Unbuffered: write up to BUFSIZ bytes at a time.
+ * Unbuffered: write up to INT_MAX bytes at a time, to not
+ * truncate the value of len if it is greater than 2^31 bytes.
*/
do {
GETIOV(;);
- w = (*fp->_write)(fp->_cookie, p, MIN(len, BUFSIZ));
+ w = (*fp->_write)(fp->_cookie, p, MIN(len, INT_MAX));
if (w <= 0)
goto err;
p += w;
@@ -90,7 +92,8 @@
/*
* Fully buffered: fill partially full buffer, if any,
* and then flush. If there is no partial buffer, write
- * one _bf._size byte chunk directly (without copying).
+ * entire payload directly (without copying) up to a
+ * multiple of the buffer size.
*
* String output is a special case: write as many bytes
* as fit, but pretend we wrote everything. This makes
@@ -134,7 +137,15 @@
if (__sflush(fp))
goto err;
} else if (len >= (w = fp->_bf._size)) {
- /* write directly */
+ /*
+ * Write directly up to INT_MAX or greatest
+ * multiple of buffer size (whichever is
+ * smaller), keeping in the memory buffer the
+ * remaining part of payload that is smaller
+ * than buffer size.
+ */
+ if (w != 0)
+ w = MIN(w * (len / w), INT_MAX);
w = (*fp->_write)(fp->_cookie, p, w);
if (w <= 0)
goto err;
diff --git a/libdl/Android.bp b/libdl/Android.bp
index 95b412b..87db4b1 100644
--- a/libdl/Android.bp
+++ b/libdl/Android.bp
@@ -60,33 +60,14 @@
native_bridge_supported: true,
static_ndk_lib: true,
- defaults: ["linux_bionic_supported"],
-
- // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
- // libgcc.a are made static to libdl.so. This in turn ensures that libraries that
- // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
- // to provide those symbols, but will instead pull them from libgcc.a. Specifically,
- // we use this property to make sure libc.so has its own copy of the code from
- // libgcc.a it uses.
- //
- // DO NOT REMOVE --exclude-libs!
-
- ldflags: [
- "-Wl,--exclude-libs=libgcc.a",
- "-Wl,--exclude-libs=libgcc_stripped.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-riscv64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
+ defaults: [
+ "linux_bionic_supported",
+ "bug_24465209_workaround",
],
- // for x86, exclude libgcc_eh.a for the same reasons as above
arch: {
arm: {
version_script: ":libdl.arm.map",
- pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
},
arm64: {
version_script: ":libdl.arm64.map",
@@ -95,15 +76,9 @@
version_script: ":libdl.riscv64.map",
},
x86: {
- pack_relocations: false,
- ldflags: [
- "-Wl,--exclude-libs=libgcc_eh.a",
- "-Wl,--hash-style=both",
- ],
version_script: ":libdl.x86.map",
},
x86_64: {
- ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
version_script: ":libdl.x86_64.map",
},
},
@@ -148,7 +123,6 @@
},
apex_available: [
- "//apex_available:platform",
"com.android.runtime",
],
}
@@ -162,37 +136,6 @@
recovery_available: true,
native_bridge_supported: true,
- // NOTE: --exclude-libs=libgcc.a makes sure that any symbols libdl.so pulls from
- // libgcc.a are made static to libdl.so. This in turn ensures that libraries that
- // a) pull symbols from libgcc.a and b) depend on libdl.so will not rely on libdl.so
- // to provide those symbols, but will instead pull them from libgcc.a. Specifically,
- // we use this property to make sure libc.so has its own copy of the code from
- // libgcc.a it uses.
- //
- // DO NOT REMOVE --exclude-libs!
-
- ldflags: [
- "-Wl,--exclude-libs=libgcc.a",
- "-Wl,--exclude-libs=libgcc_stripped.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-riscv64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
- ],
-
- // for x86, exclude libgcc_eh.a for the same reasons as above
- arch: {
- x86: {
- ldflags: [
- "-Wl,--exclude-libs=libgcc_eh.a",
- ],
- },
- x86_64: {
- ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
- },
- },
-
srcs: ["libdl_android.cpp"],
version_script: "libdl_android.map.txt",
@@ -226,7 +169,6 @@
},
apex_available: [
- "//apex_available:platform",
"com.android.runtime",
],
}
diff --git a/libdl/libdl_cfi.cpp b/libdl/libdl_cfi.cpp
index 23cd7f5..8adc342 100644
--- a/libdl/libdl_cfi.cpp
+++ b/libdl/libdl_cfi.cpp
@@ -26,15 +26,15 @@
// dlopen/dlclose.
static struct {
uintptr_t v;
- char padding[max_page_size() - sizeof(v)];
-} shadow_base_storage alignas(max_page_size());
+ char padding[max_android_page_size() - sizeof(v)];
+} shadow_base_storage alignas(max_android_page_size());
// __cfi_init is called by the loader as soon as the shadow is mapped. This may happen very early
// during startup, before libdl.so global constructors, and, on i386, even before __libc_sysinfo is
// initialized. This function should not do any system calls.
extern "C" uintptr_t* __cfi_init(uintptr_t shadow_base) {
shadow_base_storage.v = shadow_base;
- static_assert(sizeof(shadow_base_storage) == max_page_size(), "");
+ static_assert(sizeof(shadow_base_storage) == max_android_page_size(), "");
return &shadow_base_storage.v;
}
diff --git a/libfdtrack/Android.bp b/libfdtrack/Android.bp
index c19d8b2..644d46d 100644
--- a/libfdtrack/Android.bp
+++ b/libfdtrack/Android.bp
@@ -27,6 +27,7 @@
"libunwindstack",
"liblzma",
"liblog",
+ "libz",
],
target: {
recovery: {
diff --git a/libfdtrack/fdtrack.cpp b/libfdtrack/fdtrack.cpp
index 57b9d37..e446f56 100644
--- a/libfdtrack/fdtrack.cpp
+++ b/libfdtrack/fdtrack.cpp
@@ -269,8 +269,10 @@
if (fatal) {
// Find the most common stack.
size_t max = 0;
+ size_t total = 0;
StackInfo* stack = nullptr;
for (size_t i = 0; i < stacks.count; ++i) {
+ total += stacks.data[i].count;
if (stacks.data[i].count > max) {
stack = &stacks.data[i];
max = stack->count;
@@ -281,11 +283,13 @@
if (!stack) {
async_safe_format_buffer(buf, sizeof(buf),
- "aborting due to fd leak: failed to find most common stack");
+ "aborting due to fd leak: see \"open files\" in the tombstone; "
+ "no stacks?!");
} else {
char* p = buf;
p += async_safe_format_buffer(buf, sizeof(buf),
- "aborting due to fd leak: most common stack =\n");
+ "aborting due to fd leak: see \"open files\" in the tombstone; "
+ "most common stack (%zu/%zu) is\n", max, total);
for (size_t i = 0; i < stack->stack_depth; ++i) {
ssize_t bytes_left = buf + sizeof(buf) - p;
diff --git a/libm/Android.bp b/libm/Android.bp
index cc37fb7..ee86959 100644
--- a/libm/Android.bp
+++ b/libm/Android.bp
@@ -21,7 +21,10 @@
cc_library {
name: "libm",
- defaults: ["linux_bionic_supported"],
+ defaults: [
+ "linux_bionic_supported",
+ "bug_24465209_workaround",
+ ],
ramdisk_available: true,
vendor_ramdisk_available: true,
recovery_available: true,
@@ -158,8 +161,6 @@
"upstream-freebsd/lib/msun/src/s_nextafterf.c",
"upstream-freebsd/lib/msun/src/s_remquo.c",
"upstream-freebsd/lib/msun/src/s_remquof.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
"upstream-freebsd/lib/msun/src/s_scalbln.c",
@@ -176,17 +177,15 @@
"upstream-freebsd/lib/msun/src/s_tanh.c",
"upstream-freebsd/lib/msun/src/s_tanhf.c",
"upstream-freebsd/lib/msun/src/s_tgammaf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
"upstream-freebsd/lib/msun/src/w_cabs.c",
"upstream-freebsd/lib/msun/src/w_cabsf.c",
"upstream-freebsd/lib/msun/src/w_cabsl.c",
"upstream-freebsd/lib/msun/src/w_drem.c",
"upstream-freebsd/lib/msun/src/w_dremf.c",
- // The FreeBSD complex functions appear to be better, but they're incomplete.
- // We take the FreeBSD implementations when they exist, but fill out the rest
- // of <complex.h> from NetBSD...
+ // The FreeBSD complex function implementations appear to be better
+ // than the other BSDs', but they're incomplete. We take the FreeBSD
+ // implementations when they exist, but fill out the rest from NetBSD...
"upstream-netbsd/lib/libm/complex/ccoshl.c",
"upstream-netbsd/lib/libm/complex/ccosl.c",
"upstream-netbsd/lib/libm/complex/cephes_subrl.c",
@@ -196,11 +195,6 @@
"upstream-netbsd/lib/libm/complex/ctanhl.c",
"upstream-netbsd/lib/libm/complex/ctanl.c",
- // TODO: this comes from from upstream's libc, not libm, but it's an
- // implementation detail that should have hidden visibility, so it needs
- // to be in whatever library the math code is in.
- "digittoint.c",
-
// Functionality not in the BSDs.
"significandl.c",
"fake_long_double.c",
@@ -277,13 +271,24 @@
arch: {
arm: {
srcs: [
- "arm/fenv.c",
- "upstream-freebsd/lib/msun/src/s_ceil.c",
- "upstream-freebsd/lib/msun/src/s_ceilf.c",
+ "fenv-arm.c",
],
+ armv7_a_neon: {
+ // armv7 arm32 has no instructions to implement these as
+ // builtins, so we build the portable implementations for armv7,
+ // because the NDK still supports armv7.
+ srcs: [
+ "upstream-freebsd/lib/msun/src/s_ceil.c",
+ "upstream-freebsd/lib/msun/src/s_ceilf.c",
+ "upstream-freebsd/lib/msun/src/s_floor.c",
+ "upstream-freebsd/lib/msun/src/s_floorf.c",
+ "upstream-freebsd/lib/msun/src/s_rint.c",
+ "upstream-freebsd/lib/msun/src/s_rintf.c",
+ "upstream-freebsd/lib/msun/src/s_trunc.c",
+ "upstream-freebsd/lib/msun/src/s_truncf.c",
+ ],
+ },
instruction_set: "arm",
- pack_relocations: false,
- ldflags: ["-Wl,--hash-style=both"],
version_script: ":libm.arm.map",
no_libcrt: true,
shared: {
@@ -296,7 +301,7 @@
arm64: {
srcs: [
- "arm64/fenv.c",
+ "fenv-arm64.c",
],
exclude_srcs: [
"upstream-freebsd/lib/msun/src/s_fma.c",
@@ -313,19 +318,15 @@
"upstream-freebsd/lib/msun/src/s_lrintf.c",
"upstream-freebsd/lib/msun/src/s_lround.c",
"upstream-freebsd/lib/msun/src/s_lroundf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
version_script: ":libm.arm64.map",
},
riscv64: {
srcs: [
- "riscv64/fenv.c",
+ "fenv-riscv64.c",
],
exclude_srcs: [
@@ -343,54 +344,37 @@
"upstream-freebsd/lib/msun/src/s_lrintf.c",
"upstream-freebsd/lib/msun/src/s_lround.c",
"upstream-freebsd/lib/msun/src/s_lroundf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
"upstream-freebsd/lib/msun/src/s_round.c",
"upstream-freebsd/lib/msun/src/s_roundf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
],
version_script: ":libm.riscv64.map",
},
x86: {
srcs: [
- "i387/fenv.c",
- "x86/lrint.S",
- "x86/lrintf.S",
- ],
- exclude_srcs: [
- "upstream-freebsd/lib/msun/src/s_lrint.c",
- "upstream-freebsd/lib/msun/src/s_lrintf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
- ],
- local_include_dirs: ["i387"],
- pack_relocations: false,
- // The x86 ABI doesn't include this, which is needed for the
- // roundss/roundsd instructions that we've used since Android M.
- cflags: ["-msse4.1"],
- ldflags: ["-Wl,--hash-style=both"],
- version_script: ":libm.x86.map",
- },
-
- x86_64: {
- srcs: [
- "amd64/fenv.c",
- "x86_64/lrint.S",
- "x86_64/lrintf.S",
+ "fenv-x86.c",
],
exclude_srcs: [
"upstream-freebsd/lib/msun/src/s_llrint.c",
"upstream-freebsd/lib/msun/src/s_llrintf.c",
"upstream-freebsd/lib/msun/src/s_lrint.c",
"upstream-freebsd/lib/msun/src/s_lrintf.c",
- "upstream-freebsd/lib/msun/src/s_rint.c",
- "upstream-freebsd/lib/msun/src/s_rintf.c",
- "upstream-freebsd/lib/msun/src/s_trunc.c",
- "upstream-freebsd/lib/msun/src/s_truncf.c",
+ ],
+ // The x86 ABI doesn't include this, which is needed for the
+ // roundss/roundsd instructions that we've used since Android M.
+ cflags: ["-msse4.1"],
+ version_script: ":libm.x86.map",
+ },
+
+ x86_64: {
+ srcs: [
+ "fenv-x86_64.c",
+ ],
+ exclude_srcs: [
+ "upstream-freebsd/lib/msun/src/s_llrint.c",
+ "upstream-freebsd/lib/msun/src/s_llrintf.c",
+ "upstream-freebsd/lib/msun/src/s_lrint.c",
+ "upstream-freebsd/lib/msun/src/s_lrintf.c",
],
version_script: ":libm.x86_64.map",
},
@@ -402,10 +386,7 @@
],
cflags: [
- "-D_BSD_SOURCE",
- "-DFLT_EVAL_METHOD=0",
"-include freebsd-compat.h",
- "-include fenv-access.h",
"-fno-builtin",
"-fno-math-errno",
"-Wall",
@@ -454,7 +435,6 @@
},
apex_available: [
- "//apex_available:platform",
"com.android.runtime",
],
@@ -509,6 +489,8 @@
cmd: "$(location generate-version-script) x86_64 $(in) $(out)",
}
+// Because of a historical accidnt, ldexp() is in libc,
+// even though ldexpf() and ldexpl() are in libm.
filegroup {
name: "libc_ldexp_srcs",
srcs: ["upstream-freebsd/lib/msun/src/s_scalbn.c"],
diff --git a/libm/NOTICE b/libm/NOTICE
index 424725e..bcdce54 100644
--- a/libm/NOTICE
+++ b/libm/NOTICE
@@ -140,15 +140,6 @@
-------------------------------------------------------------------
====================================================
-Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
-
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
-====================================================
Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
Permission to use, copy, modify, and distribute this
@@ -253,34 +244,6 @@
-------------------------------------------------------------------
-Copyright (C) 2021 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.
-
--------------------------------------------------------------------
-
Copyright (C) 2022 The Android Open Source Project
All rights reserved.
@@ -423,32 +386,6 @@
-------------------------------------------------------------------
-Copyright (c) 2007 David Schultz
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
-2. 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 AUTHOR 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 AUTHOR 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.
-
--------------------------------------------------------------------
-
Copyright (c) 2007 The NetBSD Foundation, Inc.
All rights reserved.
@@ -575,36 +512,6 @@
-------------------------------------------------------------------
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-
--------------------------------------------------------------------
-
Copyright (c) 2017 Steven G. Kargl
All rights reserved.
@@ -657,17 +564,6 @@
-------------------------------------------------------------------
-From: @(#)s_ilogb.c 5.1 93/09/24
-====================================================
-Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
-
-Developed at SunPro, a Sun Microsystems, Inc. business.
-Permission to use, copy, modify, and distribute this
-software is freely granted, provided that this notice
-is preserved.
-
--------------------------------------------------------------------
-
SPDX-License-Identifier: BSD-2-Clause
Copyright (c) 2003, Steven G. Kargl
@@ -1273,33 +1169,3 @@
-------------------------------------------------------------------
-SPDX-License-Identifier: BSD-3-Clause
-
-Copyright (c) 2003 Dag-Erling Smørgrav
-All rights reserved.
-
-Redistribution and use in source and binary forms, with or without
-modification, are permitted provided that the following conditions
-are met:
-1. Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer
- in this position and unchanged.
-2. 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.
-3. The name of the author may not be used to endorse or promote products
- derived from this software without specific prior written permission.
-
-THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
-
--------------------------------------------------------------------
-
diff --git a/libm/builtins.cpp b/libm/builtins.cpp
index 41e145b..97db425 100644
--- a/libm/builtins.cpp
+++ b/libm/builtins.cpp
@@ -18,13 +18,12 @@
#include "fpmath.h"
-double fabs(double x) { return __builtin_fabs(x); }
-float fabsf(float x) { return __builtin_fabsf(x); }
-long double fabsl(long double x) { return __builtin_fabsl(x); }
-
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float ceilf(float x) { return __builtin_ceilf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double ceil(double x) { return __builtin_ceil(x); }
+float ceilf(float x) { return __builtin_ceilf(x); }
#if defined(__ILP32__)
__weak_reference(ceil, ceill);
#endif
@@ -34,21 +33,16 @@
float copysignf(float x, float y) { return __builtin_copysignf(x, y); }
long double copysignl(long double x, long double y) { return __builtin_copysignl(x, y); }
-#if defined(__arm__) && (__ARM_ARCH < 8)
-// armv8 arm32 has a single-instruction implementation for these, but
-// armv7 arm32 doesn't, so __builtin_ doesn't work for arm32.
-#include "math_private.h"
-namespace s_floor {
-#include "upstream-freebsd/lib/msun/src/s_floor.c"
-}
-namespace s_floorf {
-#include "upstream-freebsd/lib/msun/src/s_floorf.c"
-}
-float floorf(float x) { return s_floorf::floorf(x); }
-double floor(double x) { return s_floor::floor(x); }
+double fabs(double x) { return __builtin_fabs(x); }
+float fabsf(float x) { return __builtin_fabsf(x); }
+long double fabsl(long double x) { return __builtin_fabsl(x); }
+
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
#else
-float floorf(float x) { return __builtin_floorf(x); }
double floor(double x) { return __builtin_floor(x); }
+float floorf(float x) { return __builtin_floorf(x); }
#if defined(__ILP32__)
__weak_reference(floor, floorl);
#endif
@@ -65,7 +59,7 @@
double fmin(double x, double y) { return __builtin_fmin(x, y); }
#endif
-#if defined(__aarch64__) || defined(__riscv)
+#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
long lrint(double x) { return __builtin_lrint(x); }
long lrintf(float x) { return __builtin_lrintf(x); }
long long llrint(double x) { return __builtin_llrint(x); }
@@ -79,28 +73,34 @@
long long llroundf(float x) { return __builtin_llroundf(x); }
#endif
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float rintf(float x) { return __builtin_rintf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double rint(double x) { return __builtin_rint(x); }
+float rintf(float x) { return __builtin_rintf(x); }
#if defined(__ILP32__)
__weak_reference(rint, rintl);
#endif
#endif
#if defined(__aarch64__) || defined(__riscv)
-float roundf(float x) { return __builtin_roundf(x); }
double round(double x) { return __builtin_round(x); }
+float roundf(float x) { return __builtin_roundf(x); }
#endif
-float sqrtf(float x) { return __builtin_sqrtf(x); }
double sqrt(double x) { return __builtin_sqrt(x); }
+float sqrtf(float x) { return __builtin_sqrtf(x); }
#if defined(__ILP32__)
__weak_reference(sqrt, sqrtl);
#endif
-#if defined(__aarch64__) || defined(__riscv) || defined(__i386__) || defined(__x86_64__)
-float truncf(float x) { return __builtin_truncf(x); }
+#if defined(__arm__) && (__ARM_ARCH <= 7)
+// armv7 arm32 has no instructions to implement these builtins,
+// so we include the msun source in the .bp file instead.
+#else
double trunc(double x) { return __builtin_trunc(x); }
+float truncf(float x) { return __builtin_truncf(x); }
#if defined(__ILP32__)
__weak_reference(trunc, truncl);
#endif
diff --git a/libm/digittoint.c b/libm/digittoint.c
deleted file mode 100644
index 1824788..0000000
--- a/libm/digittoint.c
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2007 David Schultz
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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 AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <sys/cdefs.h>
-
-/* digittoint is in the FreeBSD C library, but implemented in terms of locale stuff. */
-__LIBC_HIDDEN__ int digittoint(char ch) {
- int d = ch - '0';
- if ((unsigned) d < 10) {
- return d;
- }
- d = ch - 'a';
- if ((unsigned) d < 6) {
- return d + 10;
- }
- d = ch - 'A';
- if ((unsigned) d < 6) {
- return d + 10;
- }
- return -1;
-}
diff --git a/libm/fake_long_double.c b/libm/fake_long_double.c
index 5f9b980..68492bc 100644
--- a/libm/fake_long_double.c
+++ b/libm/fake_long_double.c
@@ -29,9 +29,7 @@
long double fminl(long double a1, long double a2) { return fmin(a1, a2); }
int ilogbl(long double a1) { return ilogb(a1); }
long long llrintl(long double a1) { return llrint(a1); }
-#if !defined(__i386__) // x86 has an assembler lrint/lrintl.
long lrintl(long double a1) { return lrint(a1); }
-#endif
long long llroundl(long double a1) { return llround(a1); }
long lroundl(long double a1) { return lround(a1); }
long double modfl(long double a1, long double* a2) { double i; double f = modf(a1, &i); *a2 = i; return f; }
diff --git a/libm/arm/fenv.c b/libm/fenv-arm.c
similarity index 100%
rename from libm/arm/fenv.c
rename to libm/fenv-arm.c
diff --git a/libm/arm64/fenv.c b/libm/fenv-arm64.c
similarity index 100%
rename from libm/arm64/fenv.c
rename to libm/fenv-arm64.c
diff --git a/libm/riscv64/fenv.c b/libm/fenv-riscv64.c
similarity index 100%
rename from libm/riscv64/fenv.c
rename to libm/fenv-riscv64.c
diff --git a/libm/i387/fenv.c b/libm/fenv-x86.c
similarity index 100%
rename from libm/i387/fenv.c
rename to libm/fenv-x86.c
diff --git a/libm/amd64/fenv.c b/libm/fenv-x86_64.c
similarity index 100%
rename from libm/amd64/fenv.c
rename to libm/fenv-x86_64.c
diff --git a/libm/freebsd-compat.h b/libm/freebsd-compat.h
index 7accc55..9555ff9 100644
--- a/libm/freebsd-compat.h
+++ b/libm/freebsd-compat.h
@@ -16,9 +16,12 @@
#pragma once
+// Since we're implementing all the extensions,
+// we need to make sure we get all their declarations when we include <math.h>.
+#define _BSD_SOURCE
+
// Some FreeBSD source includes <complex.h> and assumes <math.h> from that.
#include <math.h>
-#include <float.h>
#define __weak_reference(sym,alias) \
__asm__(".weak " #alias); \
@@ -27,18 +30,12 @@
#define __strong_reference(sym,aliassym) \
extern __typeof (sym) aliassym __attribute__ ((__alias__ (#sym)))
-#define __warn_references(sym,msg) /* ignored */
-
-// digittoint is in BSD's <ctype.h>, but not ours, so we have a secret
-// implementation in libm. We reuse parts of libm in the NDK's
-// libandroid_support, where it's a static library, so we want all our
-// "hidden" functions start with a double underscore --- being HIDDEN
-// in the ELF sense is not sufficient.
-#define digittoint __libm_digittoint
-int digittoint(char ch);
-
-// Similarly rename _scan_nan.
-#define _scan_nan __libm_scan_nan
+// digittoint is in BSD's <ctype.h> but not ours.
+#include <ctype.h>
+static inline int digittoint(char ch) {
+ if (!isxdigit(ch)) return -1;
+ return isdigit(ch) ? (ch - '0') : (_tolower(ch) - 'a');
+}
// FreeBSD exports these in <math.h> but we don't.
double cospi(double);
diff --git a/libm/libm.map.txt b/libm/libm.map.txt
index a931b93..b9a0db2 100644
--- a/libm/libm.map.txt
+++ b/libm/libm.map.txt
@@ -8,23 +8,23 @@
acosf;
acosh;
acoshf;
- acoshl; # introduced=21
- acosl; # introduced=21
+ acoshl;
+ acosl;
asin;
asinf;
asinh;
asinhf;
- asinhl; # introduced=21
- asinl; # introduced=21
+ asinhl;
+ asinl;
atan;
atan2;
atan2f;
- atan2l; # introduced=21
+ atan2l;
atanf;
atanh;
atanhf;
- atanhl; # introduced=21
- atanl; # introduced=21
+ atanhl;
+ atanl;
cabs; # introduced=23
cabsf; # introduced=23
cabsl; # introduced-arm=21 introduced-arm64=23 introduced-x86=21 introduced-x86_64=23
@@ -45,7 +45,7 @@
catanhf; # introduced=23
cbrt;
cbrtf;
- cbrtl; # introduced=21
+ cbrtl;
ccos; # introduced=23
ccosf; # introduced=23
ccosh; # introduced=23
@@ -68,8 +68,8 @@
cosf;
cosh;
coshf;
- coshl; # introduced=21
- cosl; # introduced=21
+ coshl;
+ cosl;
cproj; # introduced=23
cprojf; # introduced=23
cprojl; # introduced-arm=21 introduced-arm64=23 introduced-x86=21 introduced-x86_64=23
@@ -92,38 +92,38 @@
erf;
erfc;
erfcf;
- erfcl; # introduced=21
+ erfcl;
erff;
- erfl; # introduced=21
+ erfl;
exp;
exp2;
exp2f;
- exp2l; # introduced=21
+ exp2l;
expf;
- expl; # introduced=21
+ expl;
expm1;
expm1f;
- expm1l; # introduced=21
+ expm1l;
fabs;
fabsf;
fabsl;
fdim;
fdimf;
fdiml;
- feclearexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fedisableexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- feenableexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fegetenv; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fegetexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fegetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fegetround; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- feholdexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- feraiseexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fesetenv; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fesetexceptflag; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fesetround; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- fetestexcept; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- feupdateenv; # introduced-arm=21 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
+ feclearexcept;
+ fedisableexcept;
+ feenableexcept;
+ fegetenv;
+ fegetexcept;
+ fegetexceptflag;
+ fegetround;
+ feholdexcept;
+ feraiseexcept;
+ fesetenv;
+ fesetexceptflag;
+ fesetround;
+ fetestexcept;
+ feupdateenv;
finite;
finitef;
floor;
@@ -131,7 +131,7 @@
floorl;
fma;
fmaf;
- fmal; # introduced=21
+ fmal;
fmax;
fmaxf;
fmaxl;
@@ -140,17 +140,17 @@
fminl;
fmod;
fmodf;
- fmodl; # introduced=21
+ fmodl;
frexp;
frexpf;
- frexpl; # introduced=21
+ frexpl;
gamma;
gamma_r;
gammaf;
gammaf_r;
hypot;
hypotf;
- hypotl; # introduced=21
+ hypotl;
ilogb;
ilogbf;
ilogbl;
@@ -166,77 +166,77 @@
lgamma_r;
lgammaf;
lgammaf_r;
- lgammal; # introduced=21
+ lgammal;
lgammal_r; # introduced=23
llrint;
llrintf;
- llrintl; # introduced=21
+ llrintl;
llround;
llroundf;
llroundl;
log;
log10;
log10f;
- log10l; # introduced=21
+ log10l;
log1p;
log1pf;
- log1pl; # introduced=21
- log2; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- log2f; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- log2l; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ log1pl;
+ log2;
+ log2f;
+ log2l;
logb;
logbf;
- logbl; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ logbl;
logf;
- logl; # introduced=21
+ logl;
lrint;
lrintf;
- lrintl; # introduced=21
+ lrintl;
lround;
lroundf;
lroundl;
modf;
modff;
- modfl; # introduced=21
- nan; # introduced-arm=13 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- nanf; # introduced-arm=13 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- nanl; # introduced-arm=13 introduced-arm64=21 introduced-x86=13 introduced-x86_64=21
+ modfl;
+ nan;
+ nanf;
+ nanl;
nearbyint;
nearbyintf;
- nearbyintl; # introduced=21
+ nearbyintl;
nextafter;
nextafterf;
- nextafterl; # introduced=21
- nexttoward; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ nextafterl;
+ nexttoward;
nexttowardf;
- nexttowardl; # introduced-arm=18 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ nexttowardl;
pow;
powf;
- powl; # introduced=21
+ powl;
remainder;
remainderf;
- remainderl; # introduced=21
+ remainderl;
remquo;
remquof;
- remquol; # introduced=21
+ remquol;
rint;
rintf;
- rintl; # introduced=21
+ rintl;
round;
roundf;
roundl;
scalb;
scalbf;
- scalbln; # introduced-arm=9 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- scalblnf; # introduced-arm=9 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
- scalblnl; # introduced-arm=9 introduced-arm64=21 introduced-x86=18 introduced-x86_64=21
+ scalbln;
+ scalblnf;
+ scalblnl;
scalbn;
scalbnf;
scalbnl;
signgam; # var
significand;
significandf;
- significandl; # introduced=21
+ significandl;
sin;
sincos;
sincosf;
@@ -244,20 +244,20 @@
sinf;
sinh;
sinhf;
- sinhl; # introduced=21
- sinl; # introduced=21
+ sinhl;
+ sinl;
sqrt;
sqrtf;
- sqrtl; # introduced=21
+ sqrtl;
tan;
tanf;
tanh;
tanhf;
- tanhl; # introduced=21
- tanl; # introduced=21
+ tanhl;
+ tanl;
tgamma;
- tgammaf; # introduced-arm=13 introduced-arm64=21 introduced-x86=9 introduced-x86_64=21
- tgammal; # introduced=21
+ tgammaf;
+ tgammal;
trunc;
truncf;
truncl;
@@ -271,7 +271,7 @@
*;
};
-LIBC_O { # introduced=O
+LIBC_O { # introduced=26
global:
cacoshl;
cacosl;
diff --git a/libm/significandl.c b/libm/significandl.c
index c5d7dd4..b672110 100644
--- a/libm/significandl.c
+++ b/libm/significandl.c
@@ -22,11 +22,13 @@
* 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.
- *
*/
#include <math.h>
+// This function is only in glibc.
+// musl and NetBSD/OpenBSD just have the double and float variants,
+// while FreeBSD and iOS/macOS have none.
long double significandl(long double x) {
return scalbnl(x, -ilogbl(x));
}
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c
index c667293..44cd519 100644
--- a/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_exp.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-/* @(#)exp.c 8.1 (Berkeley) 6/4/93 */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* EXP(X)
* RETURN THE EXPONENTIAL OF X
* DOUBLE PRECISION (IEEE 53 bits, VAX D FORMAT 56 BITS)
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c
index 9d09ac7..a82140b 100644
--- a/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_log.c
@@ -29,10 +29,6 @@
* SUCH DAMAGE.
*/
-/* @(#)log.c 8.2 (Berkeley) 11/30/93 */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Table-driven natural logarithm.
*
* This code was derived, with minor modifications, from:
diff --git a/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c b/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c
index 493ced3..8369477 100644
--- a/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c
+++ b/libm/upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c
@@ -42,10 +42,6 @@
* porting to other precisions.
*/
-/* @(#)gamma.c 8.1 (Berkeley) 6/4/93 */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/ld128/e_lgammal_r.c b/libm/upstream-freebsd/lib/msun/ld128/e_lgammal_r.c
index 53d3af1..f8079b7 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/e_lgammal_r.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/e_lgammal_r.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_lgamma_r.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/ld128/e_powl.c b/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
index 12b92a1..f5a993c 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/e_powl.c
@@ -59,9 +59,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h b/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
index fcef399..0ea1a70 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/e_rem_pio2l.h
@@ -1,4 +1,3 @@
-/* From: @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,9 +12,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* ld128 version of __ieee754_rem_pio2l(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -58,7 +54,7 @@
pio2_3 = 2.0670321098263988236499468110329591e-43L, /* 0x127044533e63a0105e00000000000.0p-254 */
pio2_3t = -2.5650587247459238361625433492959285e-65L; /* -0x159c4ec64ddaeb5f78671cbfb2210.0p-327 */
-static inline __always_inline int
+static __always_inline int
__ieee754_rem_pio2l(long double x, long double *y)
{
union IEEEl2bits u,u1;
diff --git a/libm/upstream-freebsd/lib/msun/ld128/invtrig.c b/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
index 3ba767b..75aef7b 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/invtrig.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "invtrig.h"
/*
diff --git a/libm/upstream-freebsd/lib/msun/ld128/invtrig.h b/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
index 3f505c5..4876be8 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/invtrig.h
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_cosl.c b/libm/upstream-freebsd/lib/msun/ld128/k_cosl.c
index 422357b..c756266 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_cosl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_cosl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ld128 version of k_cos.c. See ../src/k_cos.c for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
index 3faf7a7..86811dd 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_expl.h
@@ -30,9 +30,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ld128 version of k_expl.h. See ../ld80/s_expl.c for most comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_sinl.c b/libm/upstream-freebsd/lib/msun/ld128/k_sinl.c
index 09472d6..f2b17ba 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_sinl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_sinl.c
@@ -1,4 +1,3 @@
-/* From: @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ld128 version of k_sin.c. See ../src/k_sin.c for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/ld128/k_tanl.c b/libm/upstream-freebsd/lib/msun/ld128/k_tanl.c
index d7ec0b9..8aff0d1 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/k_tanl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/k_tanl.c
@@ -1,5 +1,3 @@
-/* From: @(#)k_tan.c 1.5 04/04/22 SMI */
-
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
@@ -11,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ld128 version of k_tan.c. See ../src/k_tan.c for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_erfl.c b/libm/upstream-freebsd/lib/msun/ld128/s_erfl.c
index e29c969..227c31f 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_erfl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_erfl.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See s_erf.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c b/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
index bcbdc5f..249cb4c 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_exp2l.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <stdint.h>
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_expl.c b/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
index 0274a8f..e1358e2 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_expl.c
@@ -28,9 +28,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ld128 version of s_expl.c. See ../ld80/s_expl.c for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_logl.c b/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
index bc53884..e9133ec 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_logl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/**
* Implementation of the natural logarithm of x for 128-bit format.
*
@@ -447,7 +444,7 @@
#endif
#ifdef STRUCT_RETURN
-static inline __always_inline void
+static __always_inline void
k_logl(long double x, struct ld *rp)
#else
long double
diff --git a/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c b/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
index cde3f18..b90d024 100644
--- a/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
+++ b/libm/upstream-freebsd/lib/msun/ld128/s_nanl.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/catrig.c b/libm/upstream-freebsd/lib/msun/src/catrig.c
index 82061b5..45af164 100644
--- a/libm/upstream-freebsd/lib/msun/src/catrig.c
+++ b/libm/upstream-freebsd/lib/msun/src/catrig.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/catrigf.c b/libm/upstream-freebsd/lib/msun/src/catrigf.c
index fb4a6bf..da90629 100644
--- a/libm/upstream-freebsd/lib/msun/src/catrigf.c
+++ b/libm/upstream-freebsd/lib/msun/src/catrigf.c
@@ -40,9 +40,6 @@
* a few comments on the right of declarations remain.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/catrigl.c b/libm/upstream-freebsd/lib/msun/src/catrigl.c
index e66f87a..faf9d29 100644
--- a/libm/upstream-freebsd/lib/msun/src/catrigl.c
+++ b/libm/upstream-freebsd/lib/msun/src/catrigl.c
@@ -39,9 +39,6 @@
* a few comments on the right of declarations remain.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acos.c b/libm/upstream-freebsd/lib/msun/src/e_acos.c
index 6623355..af51fe1 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acos.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acos.c
@@ -1,5 +1,4 @@
-/* @(#)e_acos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* acos(x)
* Method :
* acos(x) = pi/2 - asin(x)
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosf.c b/libm/upstream-freebsd/lib/msun/src/e_acosf.c
index 64f1c5a..ede552e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acosf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
@@ -25,11 +22,17 @@
pio2_hi = 1.5707962513e+00; /* 0x3fc90fda */
static volatile float
pio2_lo = 7.5497894159e-08; /* 0x33a22168 */
+
+/*
+ * The coefficients for the rational approximation were generated over
+ * 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
+ */
static const float
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
+pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
+pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
+pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
+qS1 = -1.16706085e+00f, /* 0xbf956240 */
+qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
float
acosf(float x)
@@ -49,13 +52,13 @@
if(ix<=0x32800000) return pio2_hi+pio2_lo;/*if|x|<2**-26*/
z = x*x;
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
r = p/q;
return pio2_hi - (x - (pio2_lo-x*r));
} else if (hx<0) { /* x < -0.5 */
z = (one+x)*(float)0.5;
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
s = sqrtf(z);
r = p/q;
w = r*s-pio2_lo;
@@ -69,7 +72,7 @@
SET_FLOAT_WORD(df,idf&0xfffff000);
c = (z-df*df)/(s+df);
p = z*(pS0+z*(pS1+z*pS2));
- q = one+z*qS1;
+ q = one+z*(qS1+z*qS2);
r = p/q;
w = r*s+c;
return (float)2.0*(df+w);
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosh.c b/libm/upstream-freebsd/lib/msun/src/e_acosh.c
index 7947995..0e5640b 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acosh.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosh.c
@@ -1,5 +1,4 @@
-/* @(#)e_acosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* acosh(x)
* Method :
* Based on
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acoshf.c b/libm/upstream-freebsd/lib/msun/src/e_acoshf.c
index 781ccf2..b6fbd2c 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acoshf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acoshf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acoshl.c b/libm/upstream-freebsd/lib/msun/src/e_acoshl.c
index b9f3aed..6bfa624 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acoshl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acoshl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)e_acosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,9 +12,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_acosh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_acosl.c b/libm/upstream-freebsd/lib/msun/src/e_acosl.c
index d33c8fe..2098143 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_acosl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_acosl.c
@@ -1,5 +1,4 @@
-/* @(#)e_acos.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_acos.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -12,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See comments in e_acos.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asin.c b/libm/upstream-freebsd/lib/msun/src/e_asin.c
index fa180ab..530bf79 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_asin.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_asin.c
@@ -1,5 +1,4 @@
-/* @(#)e_asin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* asin(x)
* Method :
* Since asin(x) = x + x^3/6 + x^5*3/40 + x^7*15/336 + ...
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asinf.c b/libm/upstream-freebsd/lib/msun/src/e_asinf.c
index db4b9b6..8d1aca2 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_asinf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_asinf.c
@@ -13,20 +13,23 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
static const float
one = 1.0000000000e+00, /* 0x3F800000 */
-huge = 1.000e+30,
- /* coefficient for R(x^2) */
-pS0 = 1.6666586697e-01,
-pS1 = -4.2743422091e-02,
-pS2 = -8.6563630030e-03,
-qS1 = -7.0662963390e-01;
+huge = 1.000e+30;
+
+/*
+ * The coefficients for the rational approximation were generated over
+ * 0x1p-12f <= x <= 0.5f. The maximum error satisfies log2(e) < -30.084.
+ */
+static const float
+pS0 = 1.66666672e-01f, /* 0x3e2aaaab */
+pS1 = -1.19510300e-01f, /* 0xbdf4c1d1 */
+pS2 = 5.47002675e-03f, /* 0x3bb33de9 */
+qS1 = -1.16706085e+00f, /* 0xbf956240 */
+qS2 = 2.90115148e-01f; /* 0x3e9489f9 */
static const double
pio2 = 1.570796326794896558e+00;
@@ -49,7 +52,7 @@
}
t = x*x;
p = t*(pS0+t*(pS1+t*pS2));
- q = one+t*qS1;
+ q = one+t*(qS1+t*qS2);
w = p/q;
return x+x*w;
}
@@ -57,7 +60,7 @@
w = one-fabsf(x);
t = w*(float)0.5;
p = t*(pS0+t*(pS1+t*pS2));
- q = one+t*qS1;
+ q = one+t*(qS1+t*qS2);
s = sqrt(t);
w = p/q;
t = pio2-2.0*(s+s*w);
diff --git a/libm/upstream-freebsd/lib/msun/src/e_asinl.c b/libm/upstream-freebsd/lib/msun/src/e_asinl.c
index a85765f..bb2320e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_asinl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_asinl.c
@@ -1,5 +1,4 @@
-/* @(#)e_asin.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_asin.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -12,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See comments in e_asin.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2.c b/libm/upstream-freebsd/lib/msun/src/e_atan2.c
index 0b2e721..ab5fc72 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atan2.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2.c
@@ -1,5 +1,4 @@
-/* @(#)e_atan2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* atan2(y,x)
* Method :
* 1. Reduce y to positive by atan2(y,x)=-atan2(-y,x).
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2f.c b/libm/upstream-freebsd/lib/msun/src/e_atan2f.c
index 4ea001d..408f364 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atan2f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2f.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atan2l.c b/libm/upstream-freebsd/lib/msun/src/e_atan2l.c
index 94ebdec..a27fd3e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atan2l.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atan2l.c
@@ -1,5 +1,4 @@
-/* @(#)e_atan2.c 1.3 95/01/18 */
/* FreeBSD: head/lib/msun/src/e_atan2.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -13,9 +12,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See comments in e_atan2.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atanh.c b/libm/upstream-freebsd/lib/msun/src/e_atanh.c
index 41f3bca..0cc0b92 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atanh.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atanh.c
@@ -1,5 +1,4 @@
-/* @(#)e_atanh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* atanh(x)
* Method :
* 1.Reduced x to positive by atanh(-x) = -atanh(x)
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atanhf.c b/libm/upstream-freebsd/lib/msun/src/e_atanhf.c
index 46643be..a2d6b69 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atanhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atanhf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_atanhl.c b/libm/upstream-freebsd/lib/msun/src/e_atanhl.c
index 11d56ea..cb70727 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_atanhl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_atanhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_atanh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)e_atanh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,9 +12,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_atanh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_cosh.c b/libm/upstream-freebsd/lib/msun/src/e_cosh.c
index 071663e..5c3614e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_cosh.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_cosh.c
@@ -1,5 +1,4 @@
-/* @(#)e_cosh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* cosh(x)
* Method :
* mathematically cosh(x) if defined to be (exp(x)+exp(-x))/2
diff --git a/libm/upstream-freebsd/lib/msun/src/e_coshf.c b/libm/upstream-freebsd/lib/msun/src/e_coshf.c
index 1673315..40443b8 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_coshf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_coshf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_coshl.c b/libm/upstream-freebsd/lib/msun/src/e_coshl.c
index 4e3b283..efb5094 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_coshl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_coshl.c
@@ -11,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_cosh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_exp.c b/libm/upstream-freebsd/lib/msun/src/e_exp.c
deleted file mode 100644
index 59da392..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_exp.c
+++ /dev/null
@@ -1,164 +0,0 @@
-
-/* @(#)e_exp.c 1.6 04/04/22 */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* exp(x)
- * Returns the exponential of x.
- *
- * Method
- * 1. Argument reduction:
- * Reduce x to an r so that |r| <= 0.5*ln2 ~ 0.34658.
- * Given x, find r and integer k such that
- *
- * x = k*ln2 + r, |r| <= 0.5*ln2.
- *
- * Here r will be represented as r = hi-lo for better
- * accuracy.
- *
- * 2. Approximation of exp(r) by a special rational function on
- * the interval [0,0.34658]:
- * Write
- * R(r**2) = r*(exp(r)+1)/(exp(r)-1) = 2 + r*r/6 - r**4/360 + ...
- * We use a special Remes algorithm on [0,0.34658] to generate
- * a polynomial of degree 5 to approximate R. The maximum error
- * of this polynomial approximation is bounded by 2**-59. In
- * other words,
- * R(z) ~ 2.0 + P1*z + P2*z**2 + P3*z**3 + P4*z**4 + P5*z**5
- * (where z=r*r, and the values of P1 to P5 are listed below)
- * and
- * | 5 | -59
- * | 2.0+P1*z+...+P5*z - R(z) | <= 2
- * | |
- * The computation of exp(r) thus becomes
- * 2*r
- * exp(r) = 1 + -------
- * R - r
- * r*R1(r)
- * = 1 + r + ----------- (for better accuracy)
- * 2 - R1(r)
- * where
- * 2 4 10
- * R1(r) = r - (P1*r + P2*r + ... + P5*r ).
- *
- * 3. Scale back to obtain exp(x):
- * From step 1, we have
- * exp(x) = 2^k * exp(r)
- *
- * Special cases:
- * exp(INF) is INF, exp(NaN) is NaN;
- * exp(-INF) is 0, and
- * for finite argument, only exp(0)=1 is exact.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Misc. info.
- * For IEEE double
- * if x > 7.09782712893383973096e+02 then exp(x) overflow
- * if x < -7.45133219101941108420e+02 then exp(x) underflow
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-one = 1.0,
-halF[2] = {0.5,-0.5,},
-o_threshold= 7.09782712893383973096e+02, /* 0x40862E42, 0xFEFA39EF */
-u_threshold= -7.45133219101941108420e+02, /* 0xc0874910, 0xD52D3051 */
-ln2HI[2] ={ 6.93147180369123816490e-01, /* 0x3fe62e42, 0xfee00000 */
- -6.93147180369123816490e-01,},/* 0xbfe62e42, 0xfee00000 */
-ln2LO[2] ={ 1.90821492927058770002e-10, /* 0x3dea39ef, 0x35793c76 */
- -1.90821492927058770002e-10,},/* 0xbdea39ef, 0x35793c76 */
-invln2 = 1.44269504088896338700e+00, /* 0x3ff71547, 0x652b82fe */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08; /* 0x3E663769, 0x72BEA4D0 */
-
-static volatile double
-huge = 1.0e+300,
-twom1000= 9.33263618503218878990e-302; /* 2**-1000=0x01700000,0*/
-
-double
-exp(double x) /* default IEEE double exp */
-{
- double y,hi=0.0,lo=0.0,c,t,twopk;
- int32_t k=0,xsb;
- u_int32_t hx;
-
- GET_HIGH_WORD(hx,x);
- xsb = (hx>>31)&1; /* sign bit of x */
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* filter out non-finite argument */
- if(hx >= 0x40862E42) { /* if |x|>=709.78... */
- if(hx>=0x7ff00000) {
- u_int32_t lx;
- GET_LOW_WORD(lx,x);
- if(((hx&0xfffff)|lx)!=0)
- return x+x; /* NaN */
- else return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
- }
- if(x > o_threshold) return huge*huge; /* overflow */
- if(x < u_threshold) return twom1000*twom1000; /* underflow */
- }
-
- /* argument reduction */
- if(hx > 0x3fd62e42) { /* if |x| > 0.5 ln2 */
- if(hx < 0x3FF0A2B2) { /* and |x| < 1.5 ln2 */
- hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
- } else {
- k = (int)(invln2*x+halF[xsb]);
- t = k;
- hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
- lo = t*ln2LO[0];
- }
- STRICT_ASSIGN(double, x, hi - lo);
- }
- else if(hx < 0x3e300000) { /* when |x|<2**-28 */
- if(huge+x>one) return one+x;/* trigger inexact */
- }
- else k = 0;
-
- /* x is now in primary range */
- t = x*x;
- if(k >= -1021)
- INSERT_WORDS(twopk,((u_int32_t)(0x3ff+k))<<20, 0);
- else
- INSERT_WORDS(twopk,((u_int32_t)(0x3ff+(k+1000)))<<20, 0);
- c = x - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- if(k==0) return one-((x*c)/(c-2.0)-x);
- else y = one-((lo-(x*c)/(2.0-c))-hi);
- if(k >= -1021) {
- if (k==1024) return y*2.0*0x1p1023;
- return y*twopk;
- } else {
- return y*twopk*twom1000;
- }
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(exp, expl);
-#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_expf.c b/libm/upstream-freebsd/lib/msun/src/e_expf.c
deleted file mode 100644
index 620d341..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_expf.c
+++ /dev/null
@@ -1,98 +0,0 @@
-/* e_expf.c -- float version of e_exp.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-one = 1.0,
-halF[2] = {0.5,-0.5,},
-o_threshold= 8.8721679688e+01, /* 0x42b17180 */
-u_threshold= -1.0397208405e+02, /* 0xc2cff1b5 */
-ln2HI[2] ={ 6.9314575195e-01, /* 0x3f317200 */
- -6.9314575195e-01,}, /* 0xbf317200 */
-ln2LO[2] ={ 1.4286067653e-06, /* 0x35bfbe8e */
- -1.4286067653e-06,}, /* 0xb5bfbe8e */
-invln2 = 1.4426950216e+00, /* 0x3fb8aa3b */
-/*
- * Domain [-0.34568, 0.34568], range ~[-4.278e-9, 4.447e-9]:
- * |x*(exp(x)+1)/(exp(x)-1) - p(x)| < 2**-27.74
- */
-P1 = 1.6666625440e-1, /* 0xaaaa8f.0p-26 */
-P2 = -2.7667332906e-3; /* -0xb55215.0p-32 */
-
-static volatile float
-huge = 1.0e+30,
-twom100 = 7.8886090522e-31; /* 2**-100=0x0d800000 */
-
-float
-expf(float x)
-{
- float y,hi=0.0,lo=0.0,c,t,twopk;
- int32_t k=0,xsb;
- u_int32_t hx;
-
- GET_FLOAT_WORD(hx,x);
- xsb = (hx>>31)&1; /* sign bit of x */
- hx &= 0x7fffffff; /* high word of |x| */
-
- /* filter out non-finite argument */
- if(hx >= 0x42b17218) { /* if |x|>=88.721... */
- if(hx>0x7f800000)
- return x+x; /* NaN */
- if(hx==0x7f800000)
- return (xsb==0)? x:0.0; /* exp(+-inf)={inf,0} */
- if(x > o_threshold) return huge*huge; /* overflow */
- if(x < u_threshold) return twom100*twom100; /* underflow */
- }
-
- /* argument reduction */
- if(hx > 0x3eb17218) { /* if |x| > 0.5 ln2 */
- if(hx < 0x3F851592) { /* and |x| < 1.5 ln2 */
- hi = x-ln2HI[xsb]; lo=ln2LO[xsb]; k = 1-xsb-xsb;
- } else {
- k = invln2*x+halF[xsb];
- t = k;
- hi = x - t*ln2HI[0]; /* t*ln2HI is exact here */
- lo = t*ln2LO[0];
- }
- STRICT_ASSIGN(float, x, hi - lo);
- }
- else if(hx < 0x39000000) { /* when |x|<2**-14 */
- if(huge+x>one) return one+x;/* trigger inexact */
- }
- else k = 0;
-
- /* x is now in primary range */
- t = x*x;
- if(k >= -125)
- SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+k))<<23);
- else
- SET_FLOAT_WORD(twopk,((u_int32_t)(0x7f+(k+100)))<<23);
- c = x - t*(P1+t*P2);
- if(k==0) return one-((x*c)/(c-(float)2.0)-x);
- else y = one-((lo-(x*c)/((float)2.0-c))-hi);
- if(k >= -125) {
- if(k==128) return y*2.0F*0x1p127F;
- return y*twopk;
- } else {
- return y*twopk*twom100;
- }
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmod.c b/libm/upstream-freebsd/lib/msun/src/e_fmod.c
index 6d5f533..77afd11 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_fmod.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmod.c
@@ -1,5 +1,4 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* fmod(x,y)
* Return x mod y in exact arithmetic
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmodf.c b/libm/upstream-freebsd/lib/msun/src/e_fmodf.c
index 3cef921..a7d1a0c 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_fmodf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmodf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* fmodf(x,y)
* Return x mod y in exact arithmetic
diff --git a/libm/upstream-freebsd/lib/msun/src/e_fmodl.c b/libm/upstream-freebsd/lib/msun/src/e_fmodl.c
index ad3bcc3..d5997e1 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_fmodl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_fmodl.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <stdint.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gamma.c b/libm/upstream-freebsd/lib/msun/src/e_gamma.c
index a13f3e2..43541ad 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_gamma.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_gamma.c
@@ -1,5 +1,4 @@
-/* @(#)e_gamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* gamma(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c b/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c
index 2d996ca..f317ae4 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_gamma_r.c
@@ -1,5 +1,4 @@
-/* @(#)e_gamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* gamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gammaf.c b/libm/upstream-freebsd/lib/msun/src/e_gammaf.c
index 563c148..98da571 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_gammaf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_gammaf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* gammaf(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c b/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c
index d7fc2db..ae80c1b 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_gammaf_r.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* gammaf_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypot.c b/libm/upstream-freebsd/lib/msun/src/e_hypot.c
index 8e3f931..a291af5 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_hypot.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypot.c
@@ -1,5 +1,4 @@
-/* @(#)e_hypot.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* hypot(x,y)
*
* Method :
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypotf.c b/libm/upstream-freebsd/lib/msun/src/e_hypotf.c
index a3b8c86..e45486e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_hypotf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypotf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_hypotl.c b/libm/upstream-freebsd/lib/msun/src/e_hypotl.c
index fc43538..d8e060a 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_hypotl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_hypotl.c
@@ -1,4 +1,3 @@
-/* From: @(#)e_hypot.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* long double version of hypot(). See e_hypot.c for most comments. */
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0.c b/libm/upstream-freebsd/lib/msun/src/e_j0.c
index c43ab69..b19661c 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_j0.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_j0.c
@@ -1,4 +1,3 @@
-/* @(#)e_j0.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* j0(x), y0(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j0(x):
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j0f.c b/libm/upstream-freebsd/lib/msun/src/e_j0f.c
index 290be04..de04a9f 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_j0f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_j0f.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_j0.c for complete comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1.c b/libm/upstream-freebsd/lib/msun/src/e_j1.c
index ee3f6fc..06a74b0 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_j1.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_j1.c
@@ -1,4 +1,3 @@
-/* @(#)e_j1.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* j1(x), y1(x)
* Bessel function of the first and second kinds of order zero.
* Method -- j1(x):
diff --git a/libm/upstream-freebsd/lib/msun/src/e_j1f.c b/libm/upstream-freebsd/lib/msun/src/e_j1f.c
index e1f4498..28cee8e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_j1f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_j1f.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_j1.c for complete comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/src/e_jn.c b/libm/upstream-freebsd/lib/msun/src/e_jn.c
index 6b876ce..0a71566 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_jn.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_jn.c
@@ -1,4 +1,3 @@
-/* @(#)e_jn.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* jn(n, x), yn(n, x)
* floating point Bessel's function of the 1st and 2nd kind
diff --git a/libm/upstream-freebsd/lib/msun/src/e_jnf.c b/libm/upstream-freebsd/lib/msun/src/e_jnf.c
index ba58622..b55eaf5 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_jnf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_jnf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_jn.c for complete comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgamma.c b/libm/upstream-freebsd/lib/msun/src/e_lgamma.c
index 9c4a30e..46e7c25 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_lgamma.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgamma.c
@@ -1,5 +1,4 @@
-/* @(#)e_lgamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* lgamma(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c b/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c
index c020b63..30edd65 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgamma_r.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma_r.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* lgamma_r(x, signgamp)
* Reentrant version of the logarithm of the Gamma function
* with user provide pointer for the sign of Gamma(x).
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c b/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c
index 00a816c..cc34e44 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgammaf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* lgammaf(x)
* Return the logarithm of the Gamma function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c b/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c
index fdd2321..3f863ce 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgammaf_r.c
@@ -14,9 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_lgammal.c b/libm/upstream-freebsd/lib/msun/src/e_lgammal.c
index ebc2fc7..51e3216 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_lgammal.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_lgammal.c
@@ -1,4 +1,3 @@
-/* @(#)e_lgamma.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log.c b/libm/upstream-freebsd/lib/msun/src/e_log.c
deleted file mode 100644
index 03ce820..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_log.c
+++ /dev/null
@@ -1,147 +0,0 @@
-
-/* @(#)e_log.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* log(x)
- * Return the logrithm of x
- *
- * Method :
- * 1. Argument Reduction: find k and f such that
- * x = 2^k * (1+f),
- * where sqrt(2)/2 < 1+f < sqrt(2) .
- *
- * 2. Approximation of log(1+f).
- * Let s = f/(2+f) ; based on log(1+f) = log(1+s) - log(1-s)
- * = 2s + 2/3 s**3 + 2/5 s**5 + .....,
- * = 2s + s*R
- * We use a special Reme algorithm on [0,0.1716] to generate
- * a polynomial of degree 14 to approximate R The maximum error
- * of this polynomial approximation is bounded by 2**-58.45. In
- * other words,
- * 2 4 6 8 10 12 14
- * R(z) ~ Lg1*s +Lg2*s +Lg3*s +Lg4*s +Lg5*s +Lg6*s +Lg7*s
- * (the values of Lg1 to Lg7 are listed in the program)
- * and
- * | 2 14 | -58.45
- * | Lg1*s +...+Lg7*s - R(z) | <= 2
- * | |
- * Note that 2s = f - s*f = f - hfsq + s*hfsq, where hfsq = f*f/2.
- * In order to guarantee error in log below 1ulp, we compute log
- * by
- * log(1+f) = f - s*(f - R) (if f is not too large)
- * log(1+f) = f - (hfsq - s*(hfsq+R)). (better accuracy)
- *
- * 3. Finally, log(x) = k*ln2 + log(1+f).
- * = k*ln2_hi+(f-(hfsq-(s*(hfsq+R)+k*ln2_lo)))
- * Here ln2 is split into two floating point number:
- * ln2_hi + ln2_lo,
- * where n*ln2_hi is always exact for |n| < 2000.
- *
- * Special cases:
- * log(x) is NaN with signal if x < 0 (including -INF) ;
- * log(+INF) is +INF; log(0) is -INF with signal;
- * log(NaN) is that NaN with no signal.
- *
- * Accuracy:
- * according to an error analysis, the error is always less than
- * 1 ulp (unit in the last place).
- *
- * Constants:
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-static const double
-ln2_hi = 6.93147180369123816490e-01, /* 3fe62e42 fee00000 */
-ln2_lo = 1.90821492927058770002e-10, /* 3dea39ef 35793c76 */
-two54 = 1.80143985094819840000e+16, /* 43500000 00000000 */
-Lg1 = 6.666666666666735130e-01, /* 3FE55555 55555593 */
-Lg2 = 3.999999999940941908e-01, /* 3FD99999 9997FA04 */
-Lg3 = 2.857142874366239149e-01, /* 3FD24924 94229359 */
-Lg4 = 2.222219843214978396e-01, /* 3FCC71C5 1D8E78AF */
-Lg5 = 1.818357216161805012e-01, /* 3FC74664 96CB03DE */
-Lg6 = 1.531383769920937332e-01, /* 3FC39A09 D078C69F */
-Lg7 = 1.479819860511658591e-01; /* 3FC2F112 DF3E5244 */
-
-static const double zero = 0.0;
-static volatile double vzero = 0.0;
-
-double
-log(double x)
-{
- double hfsq,f,s,z,R,w,t1,t2,dk;
- int32_t k,hx,i,j;
- u_int32_t lx;
-
- EXTRACT_WORDS(hx,lx,x);
-
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/vzero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
- GET_HIGH_WORD(hx,x);
- }
- if (hx >= 0x7ff00000) return x+x;
- k += (hx>>20)-1023;
- hx &= 0x000fffff;
- i = (hx+0x95f64)&0x100000;
- SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
- k += (i>>20);
- f = x-1.0;
- if((0x000fffff&(2+hx))<3) { /* -2**-20 <= f < 2**-20 */
- if(f==zero) {
- if(k==0) {
- return zero;
- } else {
- dk=(double)k;
- return dk*ln2_hi+dk*ln2_lo;
- }
- }
- R = f*f*(0.5-0.33333333333333333*f);
- if(k==0) return f-R; else {dk=(double)k;
- return dk*ln2_hi-((R-dk*ln2_lo)-f);}
- }
- s = f/(2.0+f);
- dk = (double)k;
- z = s*s;
- i = hx-0x6147a;
- w = z*z;
- j = 0x6b851-hx;
- t1= w*(Lg2+w*(Lg4+w*Lg6));
- t2= z*(Lg1+w*(Lg3+w*(Lg5+w*Lg7)));
- i |= j;
- R = t2+t1;
- if(i>0) {
- hfsq=0.5*f*f;
- if(k==0) return f-(hfsq-s*(hfsq+R)); else
- return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
- } else {
- if(k==0) return f-s*(f-R); else
- return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
- }
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(log, logl);
-#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log10.c b/libm/upstream-freebsd/lib/msun/src/e_log10.c
index 595c238..3647fb0 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_log10.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_log10.c
@@ -1,5 +1,4 @@
-/* @(#)e_log10.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Return the base 10 logarithm of x. See e_log.c and k_log.h for most
* comments.
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log10f.c b/libm/upstream-freebsd/lib/msun/src/e_log10f.c
index d0c3a53..ee01d6f 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_log10f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_log10f.c
@@ -9,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Float version of e_log10.c. See the latter for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log2.c b/libm/upstream-freebsd/lib/msun/src/e_log2.c
deleted file mode 100644
index 10b1c00..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_log2.c
+++ /dev/null
@@ -1,117 +0,0 @@
-
-/* @(#)e_log10.c 1.3 95/01/18 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunSoft, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Return the base 2 logarithm of x. See e_log.c and k_log.h for most
- * comments.
- *
- * This reduces x to {k, 1+f} exactly as in e_log.c, then calls the kernel,
- * then does the combining and scaling steps
- * log2(x) = (f - 0.5*f*f + k_log1p(f)) / ln2 + k
- * in not-quite-routine extra precision.
- */
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-#include "k_log.h"
-
-static const double
-two54 = 1.80143985094819840000e+16, /* 0x43500000, 0x00000000 */
-ivln2hi = 1.44269504072144627571e+00, /* 0x3ff71547, 0x65200000 */
-ivln2lo = 1.67517131648865118353e-10; /* 0x3de705fc, 0x2eefa200 */
-
-static const double zero = 0.0;
-static volatile double vzero = 0.0;
-
-double
-log2(double x)
-{
- double f,hfsq,hi,lo,r,val_hi,val_lo,w,y;
- int32_t i,k,hx;
- u_int32_t lx;
-
- EXTRACT_WORDS(hx,lx,x);
-
- k=0;
- if (hx < 0x00100000) { /* x < 2**-1022 */
- if (((hx&0x7fffffff)|lx)==0)
- return -two54/vzero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 54; x *= two54; /* subnormal number, scale up x */
- GET_HIGH_WORD(hx,x);
- }
- if (hx >= 0x7ff00000) return x+x;
- if (hx == 0x3ff00000 && lx == 0)
- return zero; /* log(1) = +0 */
- k += (hx>>20)-1023;
- hx &= 0x000fffff;
- i = (hx+0x95f64)&0x100000;
- SET_HIGH_WORD(x,hx|(i^0x3ff00000)); /* normalize x or x/2 */
- k += (i>>20);
- y = (double)k;
- f = x - 1.0;
- hfsq = 0.5*f*f;
- r = k_log1p(f);
-
- /*
- * f-hfsq must (for args near 1) be evaluated in extra precision
- * to avoid a large cancellation when x is near sqrt(2) or 1/sqrt(2).
- * This is fairly efficient since f-hfsq only depends on f, so can
- * be evaluated in parallel with R. Not combining hfsq with R also
- * keeps R small (though not as small as a true `lo' term would be),
- * so that extra precision is not needed for terms involving R.
- *
- * Compiler bugs involving extra precision used to break Dekker's
- * theorem for spitting f-hfsq as hi+lo, unless double_t was used
- * or the multi-precision calculations were avoided when double_t
- * has extra precision. These problems are now automatically
- * avoided as a side effect of the optimization of combining the
- * Dekker splitting step with the clear-low-bits step.
- *
- * y must (for args near sqrt(2) and 1/sqrt(2)) be added in extra
- * precision to avoid a very large cancellation when x is very near
- * these values. Unlike the above cancellations, this problem is
- * specific to base 2. It is strange that adding +-1 is so much
- * harder than adding +-ln2 or +-log10_2.
- *
- * This uses Dekker's theorem to normalize y+val_hi, so the
- * compiler bugs are back in some configurations, sigh. And I
- * don't want to used double_t to avoid them, since that gives a
- * pessimization and the support for avoiding the pessimization
- * is not yet available.
- *
- * The multi-precision calculations for the multiplications are
- * routine.
- */
- hi = f - hfsq;
- SET_LOW_WORD(hi,0);
- lo = (f - hi) - hfsq + r;
- val_hi = hi*ivln2hi;
- val_lo = (lo+hi)*ivln2lo + lo*ivln2hi;
-
- /* spadd(val_hi, val_lo, y), except for not using double_t: */
- w = y + val_hi;
- val_lo += (y - w) + val_hi;
- val_hi = w;
-
- return val_lo + val_hi;
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(log2, log2l);
-#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_log2f.c b/libm/upstream-freebsd/lib/msun/src/e_log2f.c
deleted file mode 100644
index 956f33a..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_log2f.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * Float version of e_log2.c. See the latter for most comments.
- */
-
-#include "math.h"
-#include "math_private.h"
-#include "k_logf.h"
-
-static const float
-two25 = 3.3554432000e+07, /* 0x4c000000 */
-ivln2hi = 1.4428710938e+00, /* 0x3fb8b000 */
-ivln2lo = -1.7605285393e-04; /* 0xb9389ad4 */
-
-static const float zero = 0.0;
-static volatile float vzero = 0.0;
-
-float
-log2f(float x)
-{
- float f,hfsq,hi,lo,r,y;
- int32_t i,k,hx;
-
- GET_FLOAT_WORD(hx,x);
-
- k=0;
- if (hx < 0x00800000) { /* x < 2**-126 */
- if ((hx&0x7fffffff)==0)
- return -two25/vzero; /* log(+-0)=-inf */
- if (hx<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
- GET_FLOAT_WORD(hx,x);
- }
- if (hx >= 0x7f800000) return x+x;
- if (hx == 0x3f800000)
- return zero; /* log(1) = +0 */
- k += (hx>>23)-127;
- hx &= 0x007fffff;
- i = (hx+(0x4afb0d))&0x800000;
- SET_FLOAT_WORD(x,hx|(i^0x3f800000)); /* normalize x or x/2 */
- k += (i>>23);
- y = (float)k;
- f = x - (float)1.0;
- hfsq = (float)0.5*f*f;
- r = k_log1pf(f);
-
- /*
- * We no longer need to avoid falling into the multi-precision
- * calculations due to compiler bugs breaking Dekker's theorem.
- * Keep avoiding this as an optimization. See e_log2.c for more
- * details (some details are here only because the optimization
- * is not yet available in double precision).
- *
- * Another compiler bug turned up. With gcc on i386,
- * (ivln2lo + ivln2hi) would be evaluated in float precision
- * despite runtime evaluations using double precision. So we
- * must cast one of its terms to float_t. This makes the whole
- * expression have type float_t, so return is forced to waste
- * time clobbering its extra precision.
- */
- if (sizeof(float_t) > sizeof(float))
- return (r - hfsq + f) * ((float_t)ivln2lo + ivln2hi) + y;
-
- hi = f - hfsq;
- GET_FLOAT_WORD(hx,hi);
- SET_FLOAT_WORD(hi,hx&0xfffff000);
- lo = (f - hi) - hfsq + r;
- return (lo+hi)*ivln2lo + lo*ivln2hi + hi*ivln2hi + y;
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_logf.c b/libm/upstream-freebsd/lib/msun/src/e_logf.c
deleted file mode 100644
index 68a4d5d..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_logf.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* e_logf.c -- float version of e_log.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-ln2_hi = 6.9313812256e-01, /* 0x3f317180 */
-ln2_lo = 9.0580006145e-06, /* 0x3717f7d1 */
-two25 = 3.355443200e+07, /* 0x4c000000 */
-/* |(log(1+s)-log(1-s))/s - Lg(s)| < 2**-34.24 (~[-4.95e-11, 4.97e-11]). */
-Lg1 = 0xaaaaaa.0p-24, /* 0.66666662693 */
-Lg2 = 0xccce13.0p-25, /* 0.40000972152 */
-Lg3 = 0x91e9ee.0p-25, /* 0.28498786688 */
-Lg4 = 0xf89e26.0p-26; /* 0.24279078841 */
-
-static const float zero = 0.0;
-static volatile float vzero = 0.0;
-
-float
-logf(float x)
-{
- float hfsq,f,s,z,R,w,t1,t2,dk;
- int32_t k,ix,i,j;
-
- GET_FLOAT_WORD(ix,x);
-
- k=0;
- if (ix < 0x00800000) { /* x < 2**-126 */
- if ((ix&0x7fffffff)==0)
- return -two25/vzero; /* log(+-0)=-inf */
- if (ix<0) return (x-x)/zero; /* log(-#) = NaN */
- k -= 25; x *= two25; /* subnormal number, scale up x */
- GET_FLOAT_WORD(ix,x);
- }
- if (ix >= 0x7f800000) return x+x;
- k += (ix>>23)-127;
- ix &= 0x007fffff;
- i = (ix+(0x95f64<<3))&0x800000;
- SET_FLOAT_WORD(x,ix|(i^0x3f800000)); /* normalize x or x/2 */
- k += (i>>23);
- f = x-(float)1.0;
- if((0x007fffff&(0x8000+ix))<0xc000) { /* -2**-9 <= f < 2**-9 */
- if(f==zero) {
- if(k==0) {
- return zero;
- } else {
- dk=(float)k;
- return dk*ln2_hi+dk*ln2_lo;
- }
- }
- R = f*f*((float)0.5-(float)0.33333333333333333*f);
- if(k==0) return f-R; else {dk=(float)k;
- return dk*ln2_hi-((R-dk*ln2_lo)-f);}
- }
- s = f/((float)2.0+f);
- dk = (float)k;
- z = s*s;
- i = ix-(0x6147a<<3);
- w = z*z;
- j = (0x6b851<<3)-ix;
- t1= w*(Lg2+w*Lg4);
- t2= z*(Lg1+w*Lg3);
- i |= j;
- R = t2+t1;
- if(i>0) {
- hfsq=(float)0.5*f*f;
- if(k==0) return f-(hfsq-s*(hfsq+R)); else
- return dk*ln2_hi-((hfsq-(s*(hfsq+R)+dk*ln2_lo))-f);
- } else {
- if(k==0) return f-s*(f-R); else
- return dk*ln2_hi-((s*(f-R)-dk*ln2_lo)-f);
- }
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_pow.c b/libm/upstream-freebsd/lib/msun/src/e_pow.c
deleted file mode 100644
index adc64c9..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_pow.c
+++ /dev/null
@@ -1,314 +0,0 @@
-/* @(#)e_pow.c 1.5 04/04/22 SMI */
-/*
- * ====================================================
- * Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
- *
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/* pow(x,y) return x**y
- *
- * n
- * Method: Let x = 2 * (1+f)
- * 1. Compute and return log2(x) in two pieces:
- * log2(x) = w1 + w2,
- * where w1 has 53-24 = 29 bit trailing zeros.
- * 2. Perform y*log2(x) = n+y' by simulating multi-precision
- * arithmetic, where |y'|<=0.5.
- * 3. Return x**y = 2**n*exp(y'*log2)
- *
- * Special cases:
- * 1. (anything) ** 0 is 1
- * 2. (anything) ** 1 is itself
- * 3. (anything) ** NAN is NAN except 1 ** NAN = 1
- * 4. NAN ** (anything except 0) is NAN
- * 5. +-(|x| > 1) ** +INF is +INF
- * 6. +-(|x| > 1) ** -INF is +0
- * 7. +-(|x| < 1) ** +INF is +0
- * 8. +-(|x| < 1) ** -INF is +INF
- * 9. +-1 ** +-INF is 1
- * 10. +0 ** (+anything except 0, NAN) is +0
- * 11. -0 ** (+anything except 0, NAN, odd integer) is +0
- * 12. +0 ** (-anything except 0, NAN) is +INF
- * 13. -0 ** (-anything except 0, NAN, odd integer) is +INF
- * 14. -0 ** (odd integer) = -( +0 ** (odd integer) )
- * 15. +INF ** (+anything except 0,NAN) is +INF
- * 16. +INF ** (-anything except 0,NAN) is +0
- * 17. -INF ** (anything) = -0 ** (-anything)
- * 18. (-anything) ** (integer) is (-1)**(integer)*(+anything**integer)
- * 19. (-anything except 0 and inf) ** (non-integer) is NAN
- *
- * Accuracy:
- * pow(x,y) returns x**y nearly rounded. In particular
- * pow(integer,integer)
- * always returns the correct integer provided it is
- * representable.
- *
- * Constants :
- * The hexadecimal values are the intended ones for the following
- * constants. The decimal values may be used, provided that the
- * compiler will convert from decimal to binary accurately enough
- * to produce the hexadecimal values shown.
- */
-
-#include <float.h>
-#include "math.h"
-#include "math_private.h"
-
-static const double
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84962487220764160156e-01,}, /* 0x3FE2B803, 0x40000000 */
-dp_l[] = { 0.0, 1.35003920212974897128e-08,}, /* 0x3E4CFDEB, 0x43CFD006 */
-zero = 0.0,
-half = 0.5,
-qrtr = 0.25,
-thrd = 3.3333333333333331e-01, /* 0x3fd55555, 0x55555555 */
-one = 1.0,
-two = 2.0,
-two53 = 9007199254740992.0, /* 0x43400000, 0x00000000 */
-huge = 1.0e300,
-tiny = 1.0e-300,
- /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 5.99999999999994648725e-01, /* 0x3FE33333, 0x33333303 */
-L2 = 4.28571428578550184252e-01, /* 0x3FDB6DB6, 0xDB6FABFF */
-L3 = 3.33333329818377432918e-01, /* 0x3FD55555, 0x518F264D */
-L4 = 2.72728123808534006489e-01, /* 0x3FD17460, 0xA91D4101 */
-L5 = 2.30660745775561754067e-01, /* 0x3FCD864A, 0x93C9DB65 */
-L6 = 2.06975017800338417784e-01, /* 0x3FCA7E28, 0x4A454EEF */
-P1 = 1.66666666666666019037e-01, /* 0x3FC55555, 0x5555553E */
-P2 = -2.77777777770155933842e-03, /* 0xBF66C16C, 0x16BEBD93 */
-P3 = 6.61375632143793436117e-05, /* 0x3F11566A, 0xAF25DE2C */
-P4 = -1.65339022054652515390e-06, /* 0xBEBBBD41, 0xC5D26BF1 */
-P5 = 4.13813679705723846039e-08, /* 0x3E663769, 0x72BEA4D0 */
-lg2 = 6.93147180559945286227e-01, /* 0x3FE62E42, 0xFEFA39EF */
-lg2_h = 6.93147182464599609375e-01, /* 0x3FE62E43, 0x00000000 */
-lg2_l = -1.90465429995776804525e-09, /* 0xBE205C61, 0x0CA86C39 */
-ovt = 8.0085662595372944372e-0017, /* -(1024-log2(ovfl+.5ulp)) */
-cp = 9.61796693925975554329e-01, /* 0x3FEEC709, 0xDC3A03FD =2/(3ln2) */
-cp_h = 9.61796700954437255859e-01, /* 0x3FEEC709, 0xE0000000 =(float)cp */
-cp_l = -7.02846165095275826516e-09, /* 0xBE3E2FE0, 0x145B01F5 =tail of cp_h*/
-ivln2 = 1.44269504088896338700e+00, /* 0x3FF71547, 0x652B82FE =1/ln2 */
-ivln2_h = 1.44269502162933349609e+00, /* 0x3FF71547, 0x60000000 =24b 1/ln2*/
-ivln2_l = 1.92596299112661746887e-08; /* 0x3E54AE0B, 0xF85DDF44 =1/ln2 tail*/
-
-double
-pow(double x, double y)
-{
- double z,ax,z_h,z_l,p_h,p_l;
- double y1,t1,t2,r,s,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy;
- u_int32_t lx,ly;
-
- EXTRACT_WORDS(hx,lx,x);
- EXTRACT_WORDS(hy,ly,y);
- ix = hx&0x7fffffff; iy = hy&0x7fffffff;
-
- /* y==zero: x**0 = 1 */
- if((iy|ly)==0) return one;
-
- /* x==1: 1**y = 1, even if y is NaN */
- if (hx==0x3ff00000 && lx == 0) return one;
-
- /* y!=zero: result is NaN if either arg is NaN */
- if(ix > 0x7ff00000 || ((ix==0x7ff00000)&&(lx!=0)) ||
- iy > 0x7ff00000 || ((iy==0x7ff00000)&&(ly!=0)))
- return nan_mix(x, y);
-
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if(hx<0) {
- if(iy>=0x43400000) yisint = 2; /* even integer y */
- else if(iy>=0x3ff00000) {
- k = (iy>>20)-0x3ff; /* exponent */
- if(k>20) {
- j = ly>>(52-k);
- if(((u_int32_t)j<<(52-k))==ly) yisint = 2-(j&1);
- } else if(ly==0) {
- j = iy>>(20-k);
- if((j<<(20-k))==iy) yisint = 2-(j&1);
- }
- }
- }
-
- /* special value of y */
- if(ly==0) {
- if (iy==0x7ff00000) { /* y is +-inf */
- if(((ix-0x3ff00000)|lx)==0)
- return one; /* (-1)**+-inf is 1 */
- else if (ix >= 0x3ff00000)/* (|x|>1)**+-inf = inf,0 */
- return (hy>=0)? y: zero;
- else /* (|x|<1)**-,+inf = inf,0 */
- return (hy<0)?-y: zero;
- }
- if(iy==0x3ff00000) { /* y is +-1 */
- if(hy<0) return one/x; else return x;
- }
- if(hy==0x40000000) return x*x; /* y is 2 */
- if(hy==0x3fe00000) { /* y is 0.5 */
- if(hx>=0) /* x >= +0 */
- return sqrt(x);
- }
- }
-
- ax = fabs(x);
- /* special value of x */
- if(lx==0) {
- if(ix==0x7ff00000||ix==0||ix==0x3ff00000){
- z = ax; /*x is +-0,+-inf,+-1*/
- if(hy<0) z = one/z; /* z = (1/|x|) */
- if(hx<0) {
- if(((ix-0x3ff00000)|yisint)==0) {
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if(yisint==1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
- }
-
- /* CYGNUS LOCAL + fdlibm-5.3 fix: This used to be
- n = (hx>>31)+1;
- but ANSI C says a right shift of a signed negative quantity is
- implementation defined. */
- n = ((u_int32_t)hx>>31)-1;
-
- /* (x<0)**(non-int) is NaN */
- if((n|yisint)==0) return (x-x)/(x-x);
-
- s = one; /* s (sign of result -ve**odd) = -1 else = 1 */
- if((n|(yisint-1))==0) s = -one;/* (-ve)**(odd int) */
-
- /* |y| is huge */
- if(iy>0x41e00000) { /* if |y| > 2**31 */
- if(iy>0x43f00000){ /* if |y| > 2**64, must o/uflow */
- if(ix<=0x3fefffff) return (hy<0)? huge*huge:tiny*tiny;
- if(ix>=0x3ff00000) return (hy>0)? huge*huge:tiny*tiny;
- }
- /* over/underflow if x is not close to one */
- if(ix<0x3fefffff) return (hy<0)? s*huge*huge:s*tiny*tiny;
- if(ix>0x3ff00000) return (hy>0)? s*huge*huge:s*tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = ax-one; /* t has 20 trailing zeros */
- w = (t*t)*(half-t*(thrd-t*qrtr));
- u = ivln2_h*t; /* ivln2_h has 21 sig. bits */
- v = t*ivln2_l-w*ivln2;
- t1 = u+v;
- SET_LOW_WORD(t1,0);
- t2 = v-(t1-u);
- } else {
- double ss,s2,s_h,s_l,t_h,t_l;
- n = 0;
- /* take care subnormal number */
- if(ix<0x00100000)
- {ax *= two53; n -= 53; GET_HIGH_WORD(ix,ax); }
- n += ((ix)>>20)-0x3ff;
- j = ix&0x000fffff;
- /* determine interval */
- ix = j|0x3ff00000; /* normalize ix */
- if(j<=0x3988E) k=0; /* |x|<sqrt(3/2) */
- else if(j<0xBB67A) k=1; /* |x|<sqrt(3) */
- else {k=0;n+=1;ix -= 0x00100000;}
- SET_HIGH_WORD(ax,ix);
-
- /* compute ss = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = one/(ax+bp[k]);
- ss = u*v;
- s_h = ss;
- SET_LOW_WORD(s_h,0);
- /* t_h=ax+bp[k] High */
- t_h = zero;
- SET_HIGH_WORD(t_h,((ix>>1)|0x20000000)+0x00080000+(k<<18));
- t_l = ax - (t_h-bp[k]);
- s_l = v*((u-s_h*t_h)-s_h*t_l);
- /* compute log(ax) */
- s2 = ss*ss;
- r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+ss);
- s2 = s_h*s_h;
- t_h = 3+s2+r;
- SET_LOW_WORD(t_h,0);
- t_l = r-((t_h-3)-s2);
- /* u+v = ss*(1+...) */
- u = s_h*t_h;
- v = s_l*t_h+t_l*ss;
- /* 2/(3log2)*(ss+...) */
- p_h = u+v;
- SET_LOW_WORD(p_h,0);
- p_l = v-(p_h-u);
- z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l*p_h+p_l*cp+dp_l[k];
- /* log2(ax) = (ss+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = n;
- t1 = (((z_h+z_l)+dp_h[k])+t);
- SET_LOW_WORD(t1,0);
- t2 = z_l-(((t1-t)-dp_h[k])-z_h);
- }
-
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- y1 = y;
- SET_LOW_WORD(y1,0);
- p_l = (y-y1)*t1+y*t2;
- p_h = y1*t1;
- z = p_l+p_h;
- EXTRACT_WORDS(j,i,z);
- if (j>=0x40900000) { /* z >= 1024 */
- if(((j-0x40900000)|i)!=0) /* if z > 1024 */
- return s*huge*huge; /* overflow */
- else {
- if(p_l+ovt>z-p_h) return s*huge*huge; /* overflow */
- }
- } else if((j&0x7fffffff)>=0x4090cc00 ) { /* z <= -1075 */
- if(((j-0xc090cc00)|i)!=0) /* z < -1075 */
- return s*tiny*tiny; /* underflow */
- else {
- if(p_l<=z-p_h) return s*tiny*tiny; /* underflow */
- }
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j&0x7fffffff;
- k = (i>>20)-0x3ff;
- n = 0;
- if(i>0x3fe00000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j+(0x00100000>>(k+1));
- k = ((n&0x7fffffff)>>20)-0x3ff; /* new k for n */
- t = zero;
- SET_HIGH_WORD(t,n&~(0x000fffff>>k));
- n = ((n&0x000fffff)|0x00100000)>>(20-k);
- if(j<0) n = -n;
- p_h -= t;
- }
- t = p_l+p_h;
- SET_LOW_WORD(t,0);
- u = t*lg2_h;
- v = (p_l-(t-p_h))*lg2+t*lg2_l;
- z = u+v;
- w = v-(z-u);
- t = z*z;
- t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- r = (z*t1)/(t1-two)-(w+z*w);
- z = one-(r-z);
- GET_HIGH_WORD(j,z);
- j += (n<<20);
- if((j>>20)<=0) z = scalbn(z,n); /* subnormal output */
- else SET_HIGH_WORD(z,j);
- return s*z;
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(pow, powl);
-#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/e_powf.c b/libm/upstream-freebsd/lib/msun/src/e_powf.c
deleted file mode 100644
index f5a2c70..0000000
--- a/libm/upstream-freebsd/lib/msun/src/e_powf.c
+++ /dev/null
@@ -1,252 +0,0 @@
-/* e_powf.c -- float version of e_pow.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include "math.h"
-#include "math_private.h"
-
-static const float
-bp[] = {1.0, 1.5,},
-dp_h[] = { 0.0, 5.84960938e-01,}, /* 0x3f15c000 */
-dp_l[] = { 0.0, 1.56322085e-06,}, /* 0x35d1cfdc */
-zero = 0.0,
-half = 0.5,
-qrtr = 0.25,
-thrd = 3.33333343e-01, /* 0x3eaaaaab */
-one = 1.0,
-two = 2.0,
-two24 = 16777216.0, /* 0x4b800000 */
-huge = 1.0e30,
-tiny = 1.0e-30,
- /* poly coefs for (3/2)*(log(x)-2s-2/3*s**3 */
-L1 = 6.0000002384e-01, /* 0x3f19999a */
-L2 = 4.2857143283e-01, /* 0x3edb6db7 */
-L3 = 3.3333334327e-01, /* 0x3eaaaaab */
-L4 = 2.7272811532e-01, /* 0x3e8ba305 */
-L5 = 2.3066075146e-01, /* 0x3e6c3255 */
-L6 = 2.0697501302e-01, /* 0x3e53f142 */
-P1 = 1.6666667163e-01, /* 0x3e2aaaab */
-P2 = -2.7777778450e-03, /* 0xbb360b61 */
-P3 = 6.6137559770e-05, /* 0x388ab355 */
-P4 = -1.6533901999e-06, /* 0xb5ddea0e */
-P5 = 4.1381369442e-08, /* 0x3331bb4c */
-lg2 = 6.9314718246e-01, /* 0x3f317218 */
-lg2_h = 6.93145752e-01, /* 0x3f317200 */
-lg2_l = 1.42860654e-06, /* 0x35bfbe8c */
-ovt = 4.2995665694e-08, /* -(128-log2(ovfl+.5ulp)) */
-cp = 9.6179670095e-01, /* 0x3f76384f =2/(3ln2) */
-cp_h = 9.6191406250e-01, /* 0x3f764000 =12b cp */
-cp_l = -1.1736857402e-04, /* 0xb8f623c6 =tail of cp_h */
-ivln2 = 1.4426950216e+00, /* 0x3fb8aa3b =1/ln2 */
-ivln2_h = 1.4426879883e+00, /* 0x3fb8aa00 =16b 1/ln2*/
-ivln2_l = 7.0526075433e-06; /* 0x36eca570 =1/ln2 tail*/
-
-float
-powf(float x, float y)
-{
- float z,ax,z_h,z_l,p_h,p_l;
- float y1,t1,t2,r,s,sn,t,u,v,w;
- int32_t i,j,k,yisint,n;
- int32_t hx,hy,ix,iy,is;
-
- GET_FLOAT_WORD(hx,x);
- GET_FLOAT_WORD(hy,y);
- ix = hx&0x7fffffff; iy = hy&0x7fffffff;
-
- /* y==zero: x**0 = 1 */
- if(iy==0) return one;
-
- /* x==1: 1**y = 1, even if y is NaN */
- if (hx==0x3f800000) return one;
-
- /* y!=zero: result is NaN if either arg is NaN */
- if(ix > 0x7f800000 ||
- iy > 0x7f800000)
- return nan_mix(x, y);
-
- /* determine if y is an odd int when x < 0
- * yisint = 0 ... y is not an integer
- * yisint = 1 ... y is an odd int
- * yisint = 2 ... y is an even int
- */
- yisint = 0;
- if(hx<0) {
- if(iy>=0x4b800000) yisint = 2; /* even integer y */
- else if(iy>=0x3f800000) {
- k = (iy>>23)-0x7f; /* exponent */
- j = iy>>(23-k);
- if((j<<(23-k))==iy) yisint = 2-(j&1);
- }
- }
-
- /* special value of y */
- if (iy==0x7f800000) { /* y is +-inf */
- if (ix==0x3f800000)
- return one; /* (-1)**+-inf is NaN */
- else if (ix > 0x3f800000)/* (|x|>1)**+-inf = inf,0 */
- return (hy>=0)? y: zero;
- else /* (|x|<1)**-,+inf = inf,0 */
- return (hy<0)?-y: zero;
- }
- if(iy==0x3f800000) { /* y is +-1 */
- if(hy<0) return one/x; else return x;
- }
- if(hy==0x40000000) return x*x; /* y is 2 */
- if(hy==0x3f000000) { /* y is 0.5 */
- if(hx>=0) /* x >= +0 */
- return sqrtf(x);
- }
-
- ax = fabsf(x);
- /* special value of x */
- if(ix==0x7f800000||ix==0||ix==0x3f800000){
- z = ax; /*x is +-0,+-inf,+-1*/
- if(hy<0) z = one/z; /* z = (1/|x|) */
- if(hx<0) {
- if(((ix-0x3f800000)|yisint)==0) {
- z = (z-z)/(z-z); /* (-1)**non-int is NaN */
- } else if(yisint==1)
- z = -z; /* (x<0)**odd = -(|x|**odd) */
- }
- return z;
- }
-
- n = ((u_int32_t)hx>>31)-1;
-
- /* (x<0)**(non-int) is NaN */
- if((n|yisint)==0) return (x-x)/(x-x);
-
- sn = one; /* s (sign of result -ve**odd) = -1 else = 1 */
- if((n|(yisint-1))==0) sn = -one;/* (-ve)**(odd int) */
-
- /* |y| is huge */
- if(iy>0x4d000000) { /* if |y| > 2**27 */
- /* over/underflow if x is not close to one */
- if(ix<0x3f7ffff6) return (hy<0)? sn*huge*huge:sn*tiny*tiny;
- if(ix>0x3f800007) return (hy>0)? sn*huge*huge:sn*tiny*tiny;
- /* now |1-x| is tiny <= 2**-20, suffice to compute
- log(x) by x-x^2/2+x^3/3-x^4/4 */
- t = ax-1; /* t has 20 trailing zeros */
- w = (t*t)*(half-t*(thrd-t*qrtr));
- u = ivln2_h*t; /* ivln2_h has 16 sig. bits */
- v = t*ivln2_l-w*ivln2;
- t1 = u+v;
- GET_FLOAT_WORD(is,t1);
- SET_FLOAT_WORD(t1,is&0xfffff000);
- t2 = v-(t1-u);
- } else {
- float s2,s_h,s_l,t_h,t_l;
- n = 0;
- /* take care subnormal number */
- if(ix<0x00800000)
- {ax *= two24; n -= 24; GET_FLOAT_WORD(ix,ax); }
- n += ((ix)>>23)-0x7f;
- j = ix&0x007fffff;
- /* determine interval */
- ix = j|0x3f800000; /* normalize ix */
- if(j<=0x1cc471) k=0; /* |x|<sqrt(3/2) */
- else if(j<0x5db3d7) k=1; /* |x|<sqrt(3) */
- else {k=0;n+=1;ix -= 0x00800000;}
- SET_FLOAT_WORD(ax,ix);
-
- /* compute s = s_h+s_l = (x-1)/(x+1) or (x-1.5)/(x+1.5) */
- u = ax-bp[k]; /* bp[0]=1.0, bp[1]=1.5 */
- v = one/(ax+bp[k]);
- s = u*v;
- s_h = s;
- GET_FLOAT_WORD(is,s_h);
- SET_FLOAT_WORD(s_h,is&0xfffff000);
- /* t_h=ax+bp[k] High */
- is = ((ix>>1)&0xfffff000)|0x20000000;
- SET_FLOAT_WORD(t_h,is+0x00400000+(k<<21));
- t_l = ax - (t_h-bp[k]);
- s_l = v*((u-s_h*t_h)-s_h*t_l);
- /* compute log(ax) */
- s2 = s*s;
- r = s2*s2*(L1+s2*(L2+s2*(L3+s2*(L4+s2*(L5+s2*L6)))));
- r += s_l*(s_h+s);
- s2 = s_h*s_h;
- t_h = 3+s2+r;
- GET_FLOAT_WORD(is,t_h);
- SET_FLOAT_WORD(t_h,is&0xfffff000);
- t_l = r-((t_h-3)-s2);
- /* u+v = s*(1+...) */
- u = s_h*t_h;
- v = s_l*t_h+t_l*s;
- /* 2/(3log2)*(s+...) */
- p_h = u+v;
- GET_FLOAT_WORD(is,p_h);
- SET_FLOAT_WORD(p_h,is&0xfffff000);
- p_l = v-(p_h-u);
- z_h = cp_h*p_h; /* cp_h+cp_l = 2/(3*log2) */
- z_l = cp_l*p_h+p_l*cp+dp_l[k];
- /* log2(ax) = (s+..)*2/(3*log2) = n + dp_h + z_h + z_l */
- t = n;
- t1 = (((z_h+z_l)+dp_h[k])+t);
- GET_FLOAT_WORD(is,t1);
- SET_FLOAT_WORD(t1,is&0xfffff000);
- t2 = z_l-(((t1-t)-dp_h[k])-z_h);
- }
-
- /* split up y into y1+y2 and compute (y1+y2)*(t1+t2) */
- GET_FLOAT_WORD(is,y);
- SET_FLOAT_WORD(y1,is&0xfffff000);
- p_l = (y-y1)*t1+y*t2;
- p_h = y1*t1;
- z = p_l+p_h;
- GET_FLOAT_WORD(j,z);
- if (j>0x43000000) /* if z > 128 */
- return sn*huge*huge; /* overflow */
- else if (j==0x43000000) { /* if z == 128 */
- if(p_l+ovt>z-p_h) return sn*huge*huge; /* overflow */
- }
- else if ((j&0x7fffffff)>0x43160000) /* z <= -150 */
- return sn*tiny*tiny; /* underflow */
- else if (j==0xc3160000){ /* z == -150 */
- if(p_l<=z-p_h) return sn*tiny*tiny; /* underflow */
- }
- /*
- * compute 2**(p_h+p_l)
- */
- i = j&0x7fffffff;
- k = (i>>23)-0x7f;
- n = 0;
- if(i>0x3f000000) { /* if |z| > 0.5, set n = [z+0.5] */
- n = j+(0x00800000>>(k+1));
- k = ((n&0x7fffffff)>>23)-0x7f; /* new k for n */
- SET_FLOAT_WORD(t,n&~(0x007fffff>>k));
- n = ((n&0x007fffff)|0x00800000)>>(23-k);
- if(j<0) n = -n;
- p_h -= t;
- }
- t = p_l+p_h;
- GET_FLOAT_WORD(is,t);
- SET_FLOAT_WORD(t,is&0xffff8000);
- u = t*lg2_h;
- v = (p_l-(t-p_h))*lg2+t*lg2_l;
- z = u+v;
- w = v-(z-u);
- t = z*z;
- t1 = z - t*(P1+t*(P2+t*(P3+t*(P4+t*P5))));
- r = (z*t1)/(t1-two)-(w+z*w);
- z = one-(r-z);
- GET_FLOAT_WORD(j,z);
- j += (n<<23);
- if((j>>23)<=0) z = scalbnf(z,n); /* subnormal output */
- else SET_FLOAT_WORD(z,j);
- return sn*z;
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
index 47b6513..16a57a0 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2.c
@@ -1,5 +1,4 @@
-/* @(#)e_rem_pio2.c 1.4 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -13,9 +12,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* __ieee754_rem_pio2(x,y)
*
* return the remainder of x rem pi/2 in y[0]+y[1]
@@ -49,7 +45,7 @@
pio2_3t = 8.47842766036889956997e-32; /* 0x397B839A, 0x252049C1 */
#ifdef INLINE_REM_PIO2
-static __inline __always_inline
+static __always_inline
#endif
int
__ieee754_rem_pio2(double x, double *y)
@@ -166,7 +162,7 @@
/* set z = scalbn(|x|,ilogb(x)-23) */
GET_LOW_WORD(low,x);
e0 = (ix>>20)-1046; /* e0 = ilogb(z)-23; */
- INSERT_WORDS(z, ix - ((int32_t)(e0<<20)), low);
+ INSERT_WORDS(z, ix - ((int32_t)((u_int32_t)e0<<20)), low);
for(i=0;i<2;i++) {
tx[i] = (double)((int32_t)(z));
z = (z-tx[i])*two24;
diff --git a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
index 597f613..84cd9bf 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_rem_pio2f.c
@@ -14,9 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* __ieee754_rem_pio2f(x,y)
*
* return the remainder of x rem pi/2 in *y
@@ -41,7 +38,7 @@
pio2_1t = 1.58932547735281966916e-08; /* 0x3E5110b4, 0x611A6263 */
#ifdef INLINE_REM_PIO2F
-static __inline __always_inline
+static __always_inline
#endif
int
__ieee754_rem_pio2f(float x, double *y)
@@ -70,7 +67,7 @@
}
/* set z = scalbn(|x|,ilogb(|x|)-23) */
e0 = (ix>>23)-150; /* e0 = ilogb(|x|)-23; */
- SET_FLOAT_WORD(z, ix - ((int32_t)(e0<<23)));
+ SET_FLOAT_WORD(z, ix - ((int32_t)((u_int32_t)e0<<23)));
tx[0] = z;
n = __kernel_rem_pio2(tx,ty,e0,1,0);
if(hx<0) {*y = -ty[0]; return -n;}
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainder.c b/libm/upstream-freebsd/lib/msun/src/e_remainder.c
index 13156d8..a5fb714 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_remainder.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainder.c
@@ -1,5 +1,4 @@
-/* @(#)e_remainder.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* remainder(x,p)
* Return :
* returns x REM p = x - [x/p]*p as if in infinite
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainderf.c b/libm/upstream-freebsd/lib/msun/src/e_remainderf.c
index e0dcfd1..4a6ff63 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_remainderf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainderf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_remainderl.c b/libm/upstream-freebsd/lib/msun/src/e_remainderl.c
index 2295673..7a681cd 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_remainderl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_remainderl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
long double
diff --git a/libm/upstream-freebsd/lib/msun/src/e_scalb.c b/libm/upstream-freebsd/lib/msun/src/e_scalb.c
index 84a6893..28d2ae6 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_scalb.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_scalb.c
@@ -1,5 +1,4 @@
-/* @(#)e_scalb.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* scalb(x, fn) is provide for
* passing various standard test suite. One
diff --git a/libm/upstream-freebsd/lib/msun/src/e_scalbf.c b/libm/upstream-freebsd/lib/msun/src/e_scalbf.c
index 28483a5..557a5a0 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_scalbf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_scalbf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sinh.c b/libm/upstream-freebsd/lib/msun/src/e_sinh.c
index 9fe8999..5eec75e 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_sinh.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_sinh.c
@@ -1,5 +1,4 @@
-/* @(#)e_sinh.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* sinh(x)
* Method :
* mathematically sinh(x) if defined to be (exp(x)-exp(-x))/2
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sinhf.c b/libm/upstream-freebsd/lib/msun/src/e_sinhf.c
index 082beb1..e9fe732 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_sinhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_sinhf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sinhl.c b/libm/upstream-freebsd/lib/msun/src/e_sinhl.c
index 38d3df1..cf481b2 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_sinhl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_sinhl.c
@@ -11,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See e_sinh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c b/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c
index 67c777f..a785536 100644
--- a/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c
+++ b/libm/upstream-freebsd/lib/msun/src/e_sqrtl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fenv.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/k_cos.c b/libm/upstream-freebsd/lib/msun/src/k_cos.c
index c4702e6..2eb5e04 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_cos.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_cos.c
@@ -1,5 +1,4 @@
-/* @(#)k_cos.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* __kernel_cos( x, y )
* kernel cos function on [-pi/4, pi/4], pi/4 ~ 0.785398164
diff --git a/libm/upstream-freebsd/lib/msun/src/k_cosf.c b/libm/upstream-freebsd/lib/msun/src/k_cosf.c
index f7a2c0a..934c1c7 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_cosf.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_cosf.c
@@ -14,11 +14,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_COSDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/k_exp.c b/libm/upstream-freebsd/lib/msun/src/k_exp.c
index 1b86cd6..383616d 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_exp.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_exp.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/k_expf.c b/libm/upstream-freebsd/lib/msun/src/k_expf.c
index 7071632..2af0c6d 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_expf.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_expf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/k_log.h b/libm/upstream-freebsd/lib/msun/src/k_log.h
index aaff8bd..da8f008 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_log.h
+++ b/libm/upstream-freebsd/lib/msun/src/k_log.h
@@ -1,5 +1,4 @@
-/* @(#)e_log.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* k_log1p(f):
* Return log(1+f) - f for 1+f in ~[sqrt(2)/2, sqrt(2)].
diff --git a/libm/upstream-freebsd/lib/msun/src/k_logf.h b/libm/upstream-freebsd/lib/msun/src/k_logf.h
index 71c547e..72b6751 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_logf.h
+++ b/libm/upstream-freebsd/lib/msun/src/k_logf.h
@@ -9,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Float version of k_log.h. See the latter for most comments.
*/
diff --git a/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
index 0a717f7..3d49d14 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_rem_pio2.c
@@ -1,5 +1,4 @@
-/* @(#)k_rem_pio2.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* __kernel_rem_pio2(x,y,e0,nx,prec)
* double x[],y[]; int e0,nx,prec;
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sin.c b/libm/upstream-freebsd/lib/msun/src/k_sin.c
index 12ee8c1..5b97d86 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_sin.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_sin.c
@@ -1,5 +1,4 @@
-/* @(#)k_sin.c 1.3 95/01/18 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* __kernel_sin( x, y, iy)
* kernel sin function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sincos.h b/libm/upstream-freebsd/lib/msun/src/k_sincos.h
index 6f03be2..796e72a 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_sincos.h
+++ b/libm/upstream-freebsd/lib/msun/src/k_sincos.h
@@ -11,9 +11,6 @@
* k_sin.c and k_cos.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
static const double
S1 = -1.66666666666666324348e-01, /* 0xBFC55555, 0x55555549 */
S2 = 8.33333333332248946124e-03, /* 0x3F811111, 0x1110F8A6 */
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sincosf.h b/libm/upstream-freebsd/lib/msun/src/k_sincosf.h
index 073986d..f031016 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_sincosf.h
+++ b/libm/upstream-freebsd/lib/msun/src/k_sincosf.h
@@ -11,9 +11,6 @@
* k_sinf.c and k_cosf.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* |sin(x)/x - s(x)| < 2**-37.5 (~[-4.89e-12, 4.824e-12]). */
static const double
S1 = -0x15555554cbac77.0p-55, /* -0.166666666416265235595 */
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sincosl.h b/libm/upstream-freebsd/lib/msun/src/k_sincosl.h
index 6425f14..cf8536c 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_sincosl.h
+++ b/libm/upstream-freebsd/lib/msun/src/k_sincosl.h
@@ -12,9 +12,6 @@
* k_sinl.c and k_cosl.c merged by Steven G. Kargl
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#if LDBL_MANT_DIG == 64 /* ld80 version of k_sincosl.c. */
#if defined(__amd64__) || defined(__i386__)
diff --git a/libm/upstream-freebsd/lib/msun/src/k_sinf.c b/libm/upstream-freebsd/lib/msun/src/k_sinf.c
index 0841759..ebebd96 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_sinf.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_sinf.c
@@ -14,11 +14,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_SINDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/k_tan.c b/libm/upstream-freebsd/lib/msun/src/k_tan.c
index 2e86c3b..92f30a6 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_tan.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_tan.c
@@ -1,5 +1,3 @@
-/* @(#)k_tan.c 1.5 04/04/22 SMI */
-
/*
* ====================================================
* Copyright 2004 Sun Microsystems, Inc. All Rights Reserved.
@@ -10,10 +8,6 @@
* ====================================================
*/
-/* INDENT OFF */
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* __kernel_tan( x, y, k )
* kernel tan function on ~[-pi/4, pi/4] (except on -0), pi/4 ~ 0.7854
* Input x is assumed to be bounded by ~pi/4 in magnitude.
diff --git a/libm/upstream-freebsd/lib/msun/src/k_tanf.c b/libm/upstream-freebsd/lib/msun/src/k_tanf.c
index 5be1445..83bfad9 100644
--- a/libm/upstream-freebsd/lib/msun/src/k_tanf.c
+++ b/libm/upstream-freebsd/lib/msun/src/k_tanf.c
@@ -13,11 +13,6 @@
* ====================================================
*/
-#ifndef INLINE_KERNEL_TANDF
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-#endif
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/math_private.h b/libm/upstream-freebsd/lib/msun/src/math_private.h
index a55d97a..1595f90 100644
--- a/libm/upstream-freebsd/lib/msun/src/math_private.h
+++ b/libm/upstream-freebsd/lib/msun/src/math_private.h
@@ -10,8 +10,6 @@
*/
/*
- * from: @(#)fdlibm.h 5.1 93/09/24
- * $FreeBSD$
*/
#ifndef _MATH_PRIVATE_H_
@@ -407,7 +405,7 @@
* any extra precision into the type of 'a' -- 'a' should have type float_t,
* double_t or long double. b's type should be no larger than 'a's type.
* Callers should use these types with scopes as large as possible, to
- * reduce their own extra-precision and efficiciency problems. In
+ * reduce their own extra-precision and efficiency problems. In
* particular, they shouldn't convert back and forth just to call here.
*/
#ifdef DEBUG
diff --git a/libm/upstream-freebsd/lib/msun/src/s_asinh.c b/libm/upstream-freebsd/lib/msun/src/s_asinh.c
index a1b9169..daebf21 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_asinh.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_asinh.c
@@ -1,4 +1,3 @@
-/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* asinh(x)
* Method :
* Based on
diff --git a/libm/upstream-freebsd/lib/msun/src/s_asinhf.c b/libm/upstream-freebsd/lib/msun/src/s_asinhf.c
index 72bcefe..4e622d5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_asinhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_asinhf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_asinhl.c b/libm/upstream-freebsd/lib/msun/src/s_asinhl.c
index ba28f59..b939fae 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_asinhl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_asinhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/e_acosh.c 176451 2008-02-22 02:30:36Z das */
-/* @(#)s_asinh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See s_asinh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atan.c b/libm/upstream-freebsd/lib/msun/src/s_atan.c
index 566f5dc..bff8b5c 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_atan.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_atan.c
@@ -1,4 +1,3 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* atan(x)
* Method
* 1. Reduce x to positive by atan(x) = -atan(-x).
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atanf.c b/libm/upstream-freebsd/lib/msun/src/s_atanf.c
index b3a371f..2c38014 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_atanf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_atanf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_atanl.c b/libm/upstream-freebsd/lib/msun/src/s_atanl.c
index ff29c3c..d9e6174 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_atanl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_atanl.c
@@ -1,4 +1,3 @@
-/* @(#)s_atan.c 5.1 93/09/24 */
/* FreeBSD: head/lib/msun/src/s_atan.c 176451 2008-02-22 02:30:36Z das */
/*
* ====================================================
@@ -11,9 +10,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See comments in s_atan.c.
* Converted to long double by David Schultz <das@FreeBSD.ORG>.
diff --git a/libm/upstream-freebsd/lib/msun/src/s_carg.c b/libm/upstream-freebsd/lib/msun/src/s_carg.c
index f203198..ea7edfd 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_carg.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_carg.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cargf.c b/libm/upstream-freebsd/lib/msun/src/s_cargf.c
index 6ea487c..25ab65e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cargf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cargf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cargl.c b/libm/upstream-freebsd/lib/msun/src/s_cargl.c
index ba39438..8a1a108 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cargl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cargl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrt.c b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
index 4353d34..6bf8424 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrt.c
@@ -1,4 +1,3 @@
-/* @(#)s_cbrt.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
* Optimized by Bruce D. Evans.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c b/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c
index 454f974..a225d3e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrtf.c
@@ -14,9 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c b/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c
index b15c96e..f1950e2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cbrtl.c
@@ -14,9 +14,6 @@
* and David A. Schultz.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ccosh.c b/libm/upstream-freebsd/lib/msun/src/s_ccosh.c
index 0fd9206..3d46c99 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ccosh.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ccosh.c
@@ -38,9 +38,6 @@
* must satisfy both cosh(conj(z)) == conj(cosh(z)) and cosh(-z) == cosh(z).
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c b/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c
index 2db8403..aeb2dec 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ccoshf.c
@@ -30,9 +30,6 @@
* Float version of ccosh(). See s_ccosh.c for details.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceil.c b/libm/upstream-freebsd/lib/msun/src/s_ceil.c
index 929f813..e6699bc 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ceil.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceil.c
@@ -1,4 +1,3 @@
-/* @(#)s_ceil.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ceil(x)
* Return x rounded toward -inf to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceilf.c b/libm/upstream-freebsd/lib/msun/src/s_ceilf.c
index 23bfe04..cc19afa 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ceilf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceilf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ceill.c b/libm/upstream-freebsd/lib/msun/src/s_ceill.c
index 2d1045f..ded36c1 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ceill.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ceill.c
@@ -7,13 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_ceil.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* ceill(x)
* Return x rounded toward -inf to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cexp.c b/libm/upstream-freebsd/lib/msun/src/s_cexp.c
index 8db763d..0151768 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cexp.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cexp.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cexpf.c b/libm/upstream-freebsd/lib/msun/src/s_cexpf.c
index 7247301..a6c0c99 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cexpf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cexpf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimag.c b/libm/upstream-freebsd/lib/msun/src/s_cimag.c
index 0b14fd7..5779b2a 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cimag.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimag.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimagf.c b/libm/upstream-freebsd/lib/msun/src/s_cimagf.c
index 42a1efd..ca2bdf2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cimagf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimagf.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cimagl.c b/libm/upstream-freebsd/lib/msun/src/s_cimagl.c
index 9707bc3..3986430 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cimagl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cimagl.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_clog.c b/libm/upstream-freebsd/lib/msun/src/s_clog.c
index 8150fa7..2129890 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_clog.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_clog.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_clogf.c b/libm/upstream-freebsd/lib/msun/src/s_clogf.c
index 19a9445..2204e1e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_clogf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_clogf.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_clogl.c b/libm/upstream-freebsd/lib/msun/src/s_clogl.c
index e59a137..075bdb4 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_clogl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_clogl.c
@@ -24,9 +24,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#ifdef __i386__
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conj.c b/libm/upstream-freebsd/lib/msun/src/s_conj.c
index a83abd8..1203ba6 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_conj.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_conj.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conjf.c b/libm/upstream-freebsd/lib/msun/src/s_conjf.c
index f9eb146..9720998 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_conjf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_conjf.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_conjl.c b/libm/upstream-freebsd/lib/msun/src/s_conjl.c
index 4b86f2e..ef084f4 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_conjl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_conjl.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysign.c b/libm/upstream-freebsd/lib/msun/src/s_copysign.c
deleted file mode 100644
index a5f3870..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_copysign.c
+++ /dev/null
@@ -1,33 +0,0 @@
-/* @(#)s_copysign.c 5.1 93/09/24 */
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * copysign(double x, double y)
- * copysign(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-double
-copysign(double x, double y)
-{
- u_int32_t hx,hy;
- GET_HIGH_WORD(hx,x);
- GET_HIGH_WORD(hy,y);
- SET_HIGH_WORD(x,(hx&0x7fffffff)|(hy&0x80000000));
- return x;
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysignf.c b/libm/upstream-freebsd/lib/msun/src/s_copysignf.c
deleted file mode 100644
index 05ca1e3..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_copysignf.c
+++ /dev/null
@@ -1,36 +0,0 @@
-/* s_copysignf.c -- float version of s_copysign.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-/*
- * copysignf(float x, float y)
- * copysignf(x,y) returns a value with the magnitude of x and
- * with the sign bit of y.
- */
-
-#include "math.h"
-#include "math_private.h"
-
-float
-copysignf(float x, float y)
-{
- u_int32_t ix,iy;
- GET_FLOAT_WORD(ix,x);
- GET_FLOAT_WORD(iy,y);
- SET_FLOAT_WORD(x,(ix&0x7fffffff)|(iy&0x80000000));
- return x;
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_copysignl.c b/libm/upstream-freebsd/lib/msun/src/s_copysignl.c
deleted file mode 100644
index 666a2ba..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_copysignl.c
+++ /dev/null
@@ -1,44 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2004 Stefan Farfeleder
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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 AUTHOR 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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-long double
-copysignl(long double x, long double y)
-{
- union IEEEl2bits ux, uy;
-
- ux.e = x;
- uy.e = y;
- ux.bits.sign = uy.bits.sign;
- return (ux.e);
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cos.c b/libm/upstream-freebsd/lib/msun/src/s_cos.c
index 29804f4..44ecad9 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cos.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cos.c
@@ -1,4 +1,3 @@
-/* @(#)s_cos.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* cos(x)
* Return cosine function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cosf.c b/libm/upstream-freebsd/lib/msun/src/s_cosf.c
deleted file mode 100644
index b701fd2..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_cosf.c
+++ /dev/null
@@ -1,87 +0,0 @@
-/* s_cosf.c -- float version of s_cos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#define INLINE_KERNEL_COSDF
-#define INLINE_KERNEL_SINDF
-#define INLINE_REM_PIO2F
-#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_cosf.c"
-#include "k_sinf.c"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-c1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-c2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-c3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-c4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-float
-cosf(float x)
-{
- double y;
- int32_t n, hx, ix;
-
- GET_FLOAT_WORD(hx,x);
- ix = hx & 0x7fffffff;
-
- if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if(ix<0x39800000) /* |x| < 2**-12 */
- if(((int)x)==0) return 1.0; /* 1 with inexact if x != 0 */
- return __kernel_cosdf(x);
- }
- if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if(ix>0x4016cbe3) /* |x| ~> 3*pi/4 */
- return -__kernel_cosdf(x + (hx > 0 ? -c2pio2 : c2pio2));
- else {
- if(hx>0)
- return __kernel_sindf(c1pio2 - x);
- else
- return __kernel_sindf(x + c1pio2);
- }
- }
- if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if(ix>0x40afeddf) /* |x| ~> 7*pi/4 */
- return __kernel_cosdf(x + (hx > 0 ? -c4pio2 : c4pio2));
- else {
- if(hx>0)
- return __kernel_sindf(x - c3pio2);
- else
- return __kernel_sindf(-c3pio2 - x);
- }
- }
-
- /* cos(Inf or NaN) is NaN */
- else if (ix>=0x7f800000) return x-x;
-
- /* general argument reduction needed */
- else {
- n = __ieee754_rem_pio2f(x,&y);
- switch(n&3) {
- case 0: return __kernel_cosdf(y);
- case 1: return __kernel_sindf(-y);
- case 2: return -__kernel_cosdf(y);
- default:
- return __kernel_sindf(y);
- }
- }
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cosl.c b/libm/upstream-freebsd/lib/msun/src/s_cosl.c
index 6f0b36f..32fc8b2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cosl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cosl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Limited testing on pseudorandom numbers drawn within [-2e8:4e8] shows
* an accuracy of <= 0.7412 ULP.
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpow.c b/libm/upstream-freebsd/lib/msun/src/s_cpow.c
index cdc57bd..b887db5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpow.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpow.c
@@ -43,9 +43,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpowf.c b/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
index aeb773b..1442910 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpowf.c
@@ -43,9 +43,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cpowl.c b/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
index 5d43b55..39797ca 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cpowl.c
@@ -43,9 +43,6 @@
*
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cproj.c b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
index 5b0d4ed..9eebb45 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cproj.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cproj.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cprojf.c b/libm/upstream-freebsd/lib/msun/src/s_cprojf.c
index 0d76e75..13d90ba 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cprojf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cprojf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_cprojl.c b/libm/upstream-freebsd/lib/msun/src/s_cprojl.c
index 7fc35d2..083b5fa 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_cprojl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_cprojl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_creal.c b/libm/upstream-freebsd/lib/msun/src/s_creal.c
index 5c8734e..b3a82f0 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_creal.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_creal.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_crealf.c b/libm/upstream-freebsd/lib/msun/src/s_crealf.c
index a93421f..36fc115 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_crealf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_crealf.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_creall.c b/libm/upstream-freebsd/lib/msun/src/s_creall.c
index b4eb9ef..b56143a 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_creall.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_creall.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <complex.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csinh.c b/libm/upstream-freebsd/lib/msun/src/s_csinh.c
index b3928ce..e7ed10e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_csinh.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_csinh.c
@@ -38,9 +38,6 @@
* must satisfy both sinh(conj(z)) == conj(sinh(z)) and sinh(-z) == -sinh(z).
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csinhf.c b/libm/upstream-freebsd/lib/msun/src/s_csinhf.c
index a8d6f2d..c439275 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_csinhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_csinhf.c
@@ -30,9 +30,6 @@
* Float version of csinh(). See s_csinh.c for details.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrt.c b/libm/upstream-freebsd/lib/msun/src/s_csqrt.c
index d96c344..c40b5a6 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_csqrt.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrt.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c b/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c
index e3ef4d0..b572451 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrtf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c b/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c
index d564133..0f375f3 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_csqrtl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ctanh.c b/libm/upstream-freebsd/lib/msun/src/s_ctanh.c
index aa4e10c..6904363 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ctanh.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ctanh.c
@@ -65,9 +65,6 @@
* precision. I also handle large x differently.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c b/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c
index e9ebe4f..551e143 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ctanhf.c
@@ -30,9 +30,6 @@
* Hyperbolic tangent of a complex argument z. See s_ctanh.c for details.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_erf.c b/libm/upstream-freebsd/lib/msun/src/s_erf.c
index ab2dc19..a9de122 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_erf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_erf.c
@@ -1,4 +1,3 @@
-/* @(#)s_erf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* double erf(double x)
* double erfc(double x)
* x
diff --git a/libm/upstream-freebsd/lib/msun/src/s_erff.c b/libm/upstream-freebsd/lib/msun/src/s_erff.c
index d6cfbd2..6c8f406 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_erff.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_erff.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_exp2.c b/libm/upstream-freebsd/lib/msun/src/s_exp2.c
deleted file mode 100644
index 1dd9673..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_exp2.c
+++ /dev/null
@@ -1,399 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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 AUTHOR 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-#define TBLBITS 8
-#define TBLSIZE (1 << TBLBITS)
-
-static const double
- redux = 0x1.8p52 / TBLSIZE,
- P1 = 0x1.62e42fefa39efp-1,
- P2 = 0x1.ebfbdff82c575p-3,
- P3 = 0x1.c6b08d704a0a6p-5,
- P4 = 0x1.3b2ab88f70400p-7,
- P5 = 0x1.5d88003875c74p-10;
-
-static volatile double
- huge = 0x1p1000,
- twom1000 = 0x1p-1000;
-
-static const double tbl[TBLSIZE * 2] = {
-/* exp2(z + eps) eps */
- 0x1.6a09e667f3d5dp-1, 0x1.9880p-44,
- 0x1.6b052fa751744p-1, 0x1.8000p-50,
- 0x1.6c012750bd9fep-1, -0x1.8780p-45,
- 0x1.6cfdcddd476bfp-1, 0x1.ec00p-46,
- 0x1.6dfb23c651a29p-1, -0x1.8000p-50,
- 0x1.6ef9298593ae3p-1, -0x1.c000p-52,
- 0x1.6ff7df9519386p-1, -0x1.fd80p-45,
- 0x1.70f7466f42da3p-1, -0x1.c880p-45,
- 0x1.71f75e8ec5fc3p-1, 0x1.3c00p-46,
- 0x1.72f8286eacf05p-1, -0x1.8300p-44,
- 0x1.73f9a48a58152p-1, -0x1.0c00p-47,
- 0x1.74fbd35d7ccfcp-1, 0x1.f880p-45,
- 0x1.75feb564267f1p-1, 0x1.3e00p-47,
- 0x1.77024b1ab6d48p-1, -0x1.7d00p-45,
- 0x1.780694fde5d38p-1, -0x1.d000p-50,
- 0x1.790b938ac1d00p-1, 0x1.3000p-49,
- 0x1.7a11473eb0178p-1, -0x1.d000p-49,
- 0x1.7b17b0976d060p-1, 0x1.0400p-45,
- 0x1.7c1ed0130c133p-1, 0x1.0000p-53,
- 0x1.7d26a62ff8636p-1, -0x1.6900p-45,
- 0x1.7e2f336cf4e3bp-1, -0x1.2e00p-47,
- 0x1.7f3878491c3e8p-1, -0x1.4580p-45,
- 0x1.80427543e1b4ep-1, 0x1.3000p-44,
- 0x1.814d2add1071ap-1, 0x1.f000p-47,
- 0x1.82589994ccd7ep-1, -0x1.1c00p-45,
- 0x1.8364c1eb942d0p-1, 0x1.9d00p-45,
- 0x1.8471a4623cab5p-1, 0x1.7100p-43,
- 0x1.857f4179f5bbcp-1, 0x1.2600p-45,
- 0x1.868d99b4491afp-1, -0x1.2c40p-44,
- 0x1.879cad931a395p-1, -0x1.3000p-45,
- 0x1.88ac7d98a65b8p-1, -0x1.a800p-45,
- 0x1.89bd0a4785800p-1, -0x1.d000p-49,
- 0x1.8ace5422aa223p-1, 0x1.3280p-44,
- 0x1.8be05bad619fap-1, 0x1.2b40p-43,
- 0x1.8cf3216b54383p-1, -0x1.ed00p-45,
- 0x1.8e06a5e08664cp-1, -0x1.0500p-45,
- 0x1.8f1ae99157807p-1, 0x1.8280p-45,
- 0x1.902fed0282c0ep-1, -0x1.cb00p-46,
- 0x1.9145b0b91ff96p-1, -0x1.5e00p-47,
- 0x1.925c353aa2ff9p-1, 0x1.5400p-48,
- 0x1.93737b0cdc64ap-1, 0x1.7200p-46,
- 0x1.948b82b5f98aep-1, -0x1.9000p-47,
- 0x1.95a44cbc852cbp-1, 0x1.5680p-45,
- 0x1.96bdd9a766f21p-1, -0x1.6d00p-44,
- 0x1.97d829fde4e2ap-1, -0x1.1000p-47,
- 0x1.98f33e47a23a3p-1, 0x1.d000p-45,
- 0x1.9a0f170ca0604p-1, -0x1.8a40p-44,
- 0x1.9b2bb4d53ff89p-1, 0x1.55c0p-44,
- 0x1.9c49182a3f15bp-1, 0x1.6b80p-45,
- 0x1.9d674194bb8c5p-1, -0x1.c000p-49,
- 0x1.9e86319e3238ep-1, 0x1.7d00p-46,
- 0x1.9fa5e8d07f302p-1, 0x1.6400p-46,
- 0x1.a0c667b5de54dp-1, -0x1.5000p-48,
- 0x1.a1e7aed8eb8f6p-1, 0x1.9e00p-47,
- 0x1.a309bec4a2e27p-1, 0x1.ad80p-45,
- 0x1.a42c980460a5dp-1, -0x1.af00p-46,
- 0x1.a5503b23e259bp-1, 0x1.b600p-47,
- 0x1.a674a8af46213p-1, 0x1.8880p-44,
- 0x1.a799e1330b3a7p-1, 0x1.1200p-46,
- 0x1.a8bfe53c12e8dp-1, 0x1.6c00p-47,
- 0x1.a9e6b5579fcd2p-1, -0x1.9b80p-45,
- 0x1.ab0e521356fb8p-1, 0x1.b700p-45,
- 0x1.ac36bbfd3f381p-1, 0x1.9000p-50,
- 0x1.ad5ff3a3c2780p-1, 0x1.4000p-49,
- 0x1.ae89f995ad2a3p-1, -0x1.c900p-45,
- 0x1.afb4ce622f367p-1, 0x1.6500p-46,
- 0x1.b0e07298db790p-1, 0x1.fd40p-45,
- 0x1.b20ce6c9a89a9p-1, 0x1.2700p-46,
- 0x1.b33a2b84f1a4bp-1, 0x1.d470p-43,
- 0x1.b468415b747e7p-1, -0x1.8380p-44,
- 0x1.b59728de5593ap-1, 0x1.8000p-54,
- 0x1.b6c6e29f1c56ap-1, 0x1.ad00p-47,
- 0x1.b7f76f2fb5e50p-1, 0x1.e800p-50,
- 0x1.b928cf22749b2p-1, -0x1.4c00p-47,
- 0x1.ba5b030a10603p-1, -0x1.d700p-47,
- 0x1.bb8e0b79a6f66p-1, 0x1.d900p-47,
- 0x1.bcc1e904bc1ffp-1, 0x1.2a00p-47,
- 0x1.bdf69c3f3a16fp-1, -0x1.f780p-46,
- 0x1.bf2c25bd71db8p-1, -0x1.0a00p-46,
- 0x1.c06286141b2e9p-1, -0x1.1400p-46,
- 0x1.c199bdd8552e0p-1, 0x1.be00p-47,
- 0x1.c2d1cd9fa64eep-1, -0x1.9400p-47,
- 0x1.c40ab5fffd02fp-1, -0x1.ed00p-47,
- 0x1.c544778fafd15p-1, 0x1.9660p-44,
- 0x1.c67f12e57d0cbp-1, -0x1.a100p-46,
- 0x1.c7ba88988c1b6p-1, -0x1.8458p-42,
- 0x1.c8f6d9406e733p-1, -0x1.a480p-46,
- 0x1.ca3405751c4dfp-1, 0x1.b000p-51,
- 0x1.cb720dcef9094p-1, 0x1.1400p-47,
- 0x1.ccb0f2e6d1689p-1, 0x1.0200p-48,
- 0x1.cdf0b555dc412p-1, 0x1.3600p-48,
- 0x1.cf3155b5bab3bp-1, -0x1.6900p-47,
- 0x1.d072d4a0789bcp-1, 0x1.9a00p-47,
- 0x1.d1b532b08c8fap-1, -0x1.5e00p-46,
- 0x1.d2f87080d8a85p-1, 0x1.d280p-46,
- 0x1.d43c8eacaa203p-1, 0x1.1a00p-47,
- 0x1.d5818dcfba491p-1, 0x1.f000p-50,
- 0x1.d6c76e862e6a1p-1, -0x1.3a00p-47,
- 0x1.d80e316c9834ep-1, -0x1.cd80p-47,
- 0x1.d955d71ff6090p-1, 0x1.4c00p-48,
- 0x1.da9e603db32aep-1, 0x1.f900p-48,
- 0x1.dbe7cd63a8325p-1, 0x1.9800p-49,
- 0x1.dd321f301b445p-1, -0x1.5200p-48,
- 0x1.de7d5641c05bfp-1, -0x1.d700p-46,
- 0x1.dfc97337b9aecp-1, -0x1.6140p-46,
- 0x1.e11676b197d5ep-1, 0x1.b480p-47,
- 0x1.e264614f5a3e7p-1, 0x1.0ce0p-43,
- 0x1.e3b333b16ee5cp-1, 0x1.c680p-47,
- 0x1.e502ee78b3fb4p-1, -0x1.9300p-47,
- 0x1.e653924676d68p-1, -0x1.5000p-49,
- 0x1.e7a51fbc74c44p-1, -0x1.7f80p-47,
- 0x1.e8f7977cdb726p-1, -0x1.3700p-48,
- 0x1.ea4afa2a490e8p-1, 0x1.5d00p-49,
- 0x1.eb9f4867ccae4p-1, 0x1.61a0p-46,
- 0x1.ecf482d8e680dp-1, 0x1.5500p-48,
- 0x1.ee4aaa2188514p-1, 0x1.6400p-51,
- 0x1.efa1bee615a13p-1, -0x1.e800p-49,
- 0x1.f0f9c1cb64106p-1, -0x1.a880p-48,
- 0x1.f252b376bb963p-1, -0x1.c900p-45,
- 0x1.f3ac948dd7275p-1, 0x1.a000p-53,
- 0x1.f50765b6e4524p-1, -0x1.4f00p-48,
- 0x1.f6632798844fdp-1, 0x1.a800p-51,
- 0x1.f7bfdad9cbe38p-1, 0x1.abc0p-48,
- 0x1.f91d802243c82p-1, -0x1.4600p-50,
- 0x1.fa7c1819e908ep-1, -0x1.b0c0p-47,
- 0x1.fbdba3692d511p-1, -0x1.0e00p-51,
- 0x1.fd3c22b8f7194p-1, -0x1.0de8p-46,
- 0x1.fe9d96b2a23eep-1, 0x1.e430p-49,
- 0x1.0000000000000p+0, 0x0.0000p+0,
- 0x1.00b1afa5abcbep+0, -0x1.3400p-52,
- 0x1.0163da9fb3303p+0, -0x1.2170p-46,
- 0x1.02168143b0282p+0, 0x1.a400p-52,
- 0x1.02c9a3e77806cp+0, 0x1.f980p-49,
- 0x1.037d42e11bbcap+0, -0x1.7400p-51,
- 0x1.04315e86e7f89p+0, 0x1.8300p-50,
- 0x1.04e5f72f65467p+0, -0x1.a3f0p-46,
- 0x1.059b0d315855ap+0, -0x1.2840p-47,
- 0x1.0650a0e3c1f95p+0, 0x1.1600p-48,
- 0x1.0706b29ddf71ap+0, 0x1.5240p-46,
- 0x1.07bd42b72a82dp+0, -0x1.9a00p-49,
- 0x1.0874518759bd0p+0, 0x1.6400p-49,
- 0x1.092bdf66607c8p+0, -0x1.0780p-47,
- 0x1.09e3ecac6f383p+0, -0x1.8000p-54,
- 0x1.0a9c79b1f3930p+0, 0x1.fa00p-48,
- 0x1.0b5586cf988fcp+0, -0x1.ac80p-48,
- 0x1.0c0f145e46c8ap+0, 0x1.9c00p-50,
- 0x1.0cc922b724816p+0, 0x1.5200p-47,
- 0x1.0d83b23395dd8p+0, -0x1.ad00p-48,
- 0x1.0e3ec32d3d1f3p+0, 0x1.bac0p-46,
- 0x1.0efa55fdfa9a6p+0, -0x1.4e80p-47,
- 0x1.0fb66affed2f0p+0, -0x1.d300p-47,
- 0x1.1073028d7234bp+0, 0x1.1500p-48,
- 0x1.11301d0125b5bp+0, 0x1.c000p-49,
- 0x1.11edbab5e2af9p+0, 0x1.6bc0p-46,
- 0x1.12abdc06c31d5p+0, 0x1.8400p-49,
- 0x1.136a814f2047dp+0, -0x1.ed00p-47,
- 0x1.1429aaea92de9p+0, 0x1.8e00p-49,
- 0x1.14e95934f3138p+0, 0x1.b400p-49,
- 0x1.15a98c8a58e71p+0, 0x1.5300p-47,
- 0x1.166a45471c3dfp+0, 0x1.3380p-47,
- 0x1.172b83c7d5211p+0, 0x1.8d40p-45,
- 0x1.17ed48695bb9fp+0, -0x1.5d00p-47,
- 0x1.18af9388c8d93p+0, -0x1.c880p-46,
- 0x1.1972658375d66p+0, 0x1.1f00p-46,
- 0x1.1a35beb6fcba7p+0, 0x1.0480p-46,
- 0x1.1af99f81387e3p+0, -0x1.7390p-43,
- 0x1.1bbe084045d54p+0, 0x1.4e40p-45,
- 0x1.1c82f95281c43p+0, -0x1.a200p-47,
- 0x1.1d4873168b9b2p+0, 0x1.3800p-49,
- 0x1.1e0e75eb44031p+0, 0x1.ac00p-49,
- 0x1.1ed5022fcd938p+0, 0x1.1900p-47,
- 0x1.1f9c18438cdf7p+0, -0x1.b780p-46,
- 0x1.2063b88628d8fp+0, 0x1.d940p-45,
- 0x1.212be3578a81ep+0, 0x1.8000p-50,
- 0x1.21f49917ddd41p+0, 0x1.b340p-45,
- 0x1.22bdda2791323p+0, 0x1.9f80p-46,
- 0x1.2387a6e7561e7p+0, -0x1.9c80p-46,
- 0x1.2451ffb821427p+0, 0x1.2300p-47,
- 0x1.251ce4fb2a602p+0, -0x1.3480p-46,
- 0x1.25e85711eceb0p+0, 0x1.2700p-46,
- 0x1.26b4565e27d16p+0, 0x1.1d00p-46,
- 0x1.2780e341de00fp+0, 0x1.1ee0p-44,
- 0x1.284dfe1f5633ep+0, -0x1.4c00p-46,
- 0x1.291ba7591bb30p+0, -0x1.3d80p-46,
- 0x1.29e9df51fdf09p+0, 0x1.8b00p-47,
- 0x1.2ab8a66d10e9bp+0, -0x1.27c0p-45,
- 0x1.2b87fd0dada3ap+0, 0x1.a340p-45,
- 0x1.2c57e39771af9p+0, -0x1.0800p-46,
- 0x1.2d285a6e402d9p+0, -0x1.ed00p-47,
- 0x1.2df961f641579p+0, -0x1.4200p-48,
- 0x1.2ecafa93e2ecfp+0, -0x1.4980p-45,
- 0x1.2f9d24abd8822p+0, -0x1.6300p-46,
- 0x1.306fe0a31b625p+0, -0x1.2360p-44,
- 0x1.31432edeea50bp+0, -0x1.0df8p-40,
- 0x1.32170fc4cd7b8p+0, -0x1.2480p-45,
- 0x1.32eb83ba8e9a2p+0, -0x1.5980p-45,
- 0x1.33c08b2641766p+0, 0x1.ed00p-46,
- 0x1.3496266e3fa27p+0, -0x1.c000p-50,
- 0x1.356c55f929f0fp+0, -0x1.0d80p-44,
- 0x1.36431a2de88b9p+0, 0x1.2c80p-45,
- 0x1.371a7373aaa39p+0, 0x1.0600p-45,
- 0x1.37f26231e74fep+0, -0x1.6600p-46,
- 0x1.38cae6d05d838p+0, -0x1.ae00p-47,
- 0x1.39a401b713ec3p+0, -0x1.4720p-43,
- 0x1.3a7db34e5a020p+0, 0x1.8200p-47,
- 0x1.3b57fbfec6e95p+0, 0x1.e800p-44,
- 0x1.3c32dc313a8f2p+0, 0x1.f800p-49,
- 0x1.3d0e544ede122p+0, -0x1.7a00p-46,
- 0x1.3dea64c1234bbp+0, 0x1.6300p-45,
- 0x1.3ec70df1c4eccp+0, -0x1.8a60p-43,
- 0x1.3fa4504ac7e8cp+0, -0x1.cdc0p-44,
- 0x1.40822c367a0bbp+0, 0x1.5b80p-45,
- 0x1.4160a21f72e95p+0, 0x1.ec00p-46,
- 0x1.423fb27094646p+0, -0x1.3600p-46,
- 0x1.431f5d950a920p+0, 0x1.3980p-45,
- 0x1.43ffa3f84b9ebp+0, 0x1.a000p-48,
- 0x1.44e0860618919p+0, -0x1.6c00p-48,
- 0x1.45c2042a7d201p+0, -0x1.bc00p-47,
- 0x1.46a41ed1d0016p+0, -0x1.2800p-46,
- 0x1.4786d668b3326p+0, 0x1.0e00p-44,
- 0x1.486a2b5c13c00p+0, -0x1.d400p-45,
- 0x1.494e1e192af04p+0, 0x1.c200p-47,
- 0x1.4a32af0d7d372p+0, -0x1.e500p-46,
- 0x1.4b17dea6db801p+0, 0x1.7800p-47,
- 0x1.4bfdad53629e1p+0, -0x1.3800p-46,
- 0x1.4ce41b817c132p+0, 0x1.0800p-47,
- 0x1.4dcb299fddddbp+0, 0x1.c700p-45,
- 0x1.4eb2d81d8ab96p+0, -0x1.ce00p-46,
- 0x1.4f9b2769d2d02p+0, 0x1.9200p-46,
- 0x1.508417f4531c1p+0, -0x1.8c00p-47,
- 0x1.516daa2cf662ap+0, -0x1.a000p-48,
- 0x1.5257de83f51eap+0, 0x1.a080p-43,
- 0x1.5342b569d4edap+0, -0x1.6d80p-45,
- 0x1.542e2f4f6ac1ap+0, -0x1.2440p-44,
- 0x1.551a4ca5d94dbp+0, 0x1.83c0p-43,
- 0x1.56070dde9116bp+0, 0x1.4b00p-45,
- 0x1.56f4736b529dep+0, 0x1.15a0p-43,
- 0x1.57e27dbe2c40ep+0, -0x1.9e00p-45,
- 0x1.58d12d497c76fp+0, -0x1.3080p-45,
- 0x1.59c0827ff0b4cp+0, 0x1.dec0p-43,
- 0x1.5ab07dd485427p+0, -0x1.4000p-51,
- 0x1.5ba11fba87af4p+0, 0x1.0080p-44,
- 0x1.5c9268a59460bp+0, -0x1.6c80p-45,
- 0x1.5d84590998e3fp+0, 0x1.69a0p-43,
- 0x1.5e76f15ad20e1p+0, -0x1.b400p-46,
- 0x1.5f6a320dcebcap+0, 0x1.7700p-46,
- 0x1.605e1b976dcb8p+0, 0x1.6f80p-45,
- 0x1.6152ae6cdf715p+0, 0x1.1000p-47,
- 0x1.6247eb03a5531p+0, -0x1.5d00p-46,
- 0x1.633dd1d1929b5p+0, -0x1.2d00p-46,
- 0x1.6434634ccc313p+0, -0x1.a800p-49,
- 0x1.652b9febc8efap+0, -0x1.8600p-45,
- 0x1.6623882553397p+0, 0x1.1fe0p-40,
- 0x1.671c1c708328ep+0, -0x1.7200p-44,
- 0x1.68155d44ca97ep+0, 0x1.6800p-49,
- 0x1.690f4b19e9471p+0, -0x1.9780p-45,
-};
-
-/*
- * exp2(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.503 ulp for normalized results.
- *
- * Method: (accurate tables)
- *
- * Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z - eps[i] for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z - eps[i]),
- * with |z - eps[i]| <= 2**-9 + 2**-39 for the table used.
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z - eps[i]) via
- * a degree-5 minimax polynomial with maximum error under 1.3 * 2**-61.
- * The values in exp2t[] and eps[] are chosen such that
- * exp2t[i] = exp2(i/TBLSIZE + eps[i]), and eps[i] is a small offset such
- * that exp2t[i] is accurate to 2**-64.
- *
- * Note that the range of i is +-TBLSIZE/2, so we actually index the tables
- * by i0 = i + TBLSIZE/2. For cache efficiency, exp2t[] and eps[] are
- * virtual tables, interleaved in the real table tbl[].
- *
- * This method is due to Gal, with many details due to Gal and Bachelis:
- *
- * Gal, S. and Bachelis, B. An Accurate Elementary Mathematical Library
- * for the IEEE Floating Point Standard. TOMS 17(1), 26-46 (1991).
- */
-double
-exp2(double x)
-{
- double r, t, twopk, twopkp1000, z;
- uint32_t hx, ix, lx, i0;
- int k;
-
- /* Filter out exceptional cases. */
- GET_HIGH_WORD(hx,x);
- ix = hx & 0x7fffffff; /* high word of |x| */
- if(ix >= 0x40900000) { /* |x| >= 1024 */
- if(ix >= 0x7ff00000) {
- GET_LOW_WORD(lx,x);
- if(((ix & 0xfffff) | lx) != 0 || (hx & 0x80000000) == 0)
- return (x + x); /* x is NaN or +Inf */
- else
- return (0.0); /* x is -Inf */
- }
- if(x >= 0x1.0p10)
- return (huge * huge); /* overflow */
- if(x <= -0x1.0ccp10)
- return (twom1000 * twom1000); /* underflow */
- } else if (ix < 0x3c900000) { /* |x| < 0x1p-54 */
- return (1.0 + x);
- }
-
- /* Reduce x, computing z, i0, and k. */
- STRICT_ASSIGN(double, t, x + redux);
- GET_LOW_WORD(i0, t);
- i0 += TBLSIZE / 2;
- k = (i0 >> TBLBITS) << 20;
- i0 = (i0 & (TBLSIZE - 1)) << 1;
- t -= redux;
- z = x - t;
-
- /* Compute r = exp2(y) = exp2t[i0] * p(z - eps[i]). */
- t = tbl[i0]; /* exp2t[i0] */
- z -= tbl[i0 + 1]; /* eps[i0] */
- if (k >= -(1021 << 20))
- INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
- else
- INSERT_WORDS(twopkp1000, 0x3ff00000 + k + (1000 << 20), 0);
- r = t + t * z * (P1 + z * (P2 + z * (P3 + z * (P4 + z * P5))));
-
- /* Scale by 2**(k>>20). */
- if(k >= -(1021 << 20)) {
- if (k == 1024 << 20)
- return (r * 2.0 * 0x1p1023);
- return (r * twopk);
- } else {
- return (r * twopkp1000 * twom1000);
- }
-}
-
-#if (LDBL_MANT_DIG == 53)
-__weak_reference(exp2, exp2l);
-#endif
diff --git a/libm/upstream-freebsd/lib/msun/src/s_exp2f.c b/libm/upstream-freebsd/lib/msun/src/s_exp2f.c
deleted file mode 100644
index c5b4c8e..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_exp2f.c
+++ /dev/null
@@ -1,139 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-2-Clause
- *
- * Copyright (c) 2005 David Schultz <das@FreeBSD.ORG>
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. 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 AUTHOR 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 AUTHOR 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.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#include "math_private.h"
-
-#define TBLBITS 4
-#define TBLSIZE (1 << TBLBITS)
-
-static const float
- redux = 0x1.8p23f / TBLSIZE,
- P1 = 0x1.62e430p-1f,
- P2 = 0x1.ebfbe0p-3f,
- P3 = 0x1.c6b348p-5f,
- P4 = 0x1.3b2c9cp-7f;
-
-static volatile float
- huge = 0x1p100f,
- twom100 = 0x1p-100f;
-
-static const double exp2ft[TBLSIZE] = {
- 0x1.6a09e667f3bcdp-1,
- 0x1.7a11473eb0187p-1,
- 0x1.8ace5422aa0dbp-1,
- 0x1.9c49182a3f090p-1,
- 0x1.ae89f995ad3adp-1,
- 0x1.c199bdd85529cp-1,
- 0x1.d5818dcfba487p-1,
- 0x1.ea4afa2a490dap-1,
- 0x1.0000000000000p+0,
- 0x1.0b5586cf9890fp+0,
- 0x1.172b83c7d517bp+0,
- 0x1.2387a6e756238p+0,
- 0x1.306fe0a31b715p+0,
- 0x1.3dea64c123422p+0,
- 0x1.4bfdad5362a27p+0,
- 0x1.5ab07dd485429p+0,
-};
-
-/*
- * exp2f(x): compute the base 2 exponential of x
- *
- * Accuracy: Peak error < 0.501 ulp; location of peak: -0.030110927.
- *
- * Method: (equally-spaced tables)
- *
- * Reduce x:
- * x = 2**k + y, for integer k and |y| <= 1/2.
- * Thus we have exp2f(x) = 2**k * exp2(y).
- *
- * Reduce y:
- * y = i/TBLSIZE + z for integer i near y * TBLSIZE.
- * Thus we have exp2(y) = exp2(i/TBLSIZE) * exp2(z),
- * with |z| <= 2**-(TBLSIZE+1).
- *
- * We compute exp2(i/TBLSIZE) via table lookup and exp2(z) via a
- * degree-4 minimax polynomial with maximum error under 1.4 * 2**-33.
- * Using double precision for everything except the reduction makes
- * roundoff error insignificant and simplifies the scaling step.
- *
- * This method is due to Tang, but I do not use his suggested parameters:
- *
- * Tang, P. Table-driven Implementation of the Exponential Function
- * in IEEE Floating-Point Arithmetic. TOMS 15(2), 144-157 (1989).
- */
-float
-exp2f(float x)
-{
- double tv, twopk, u, z;
- float t;
- uint32_t hx, ix, i0;
- int32_t k;
-
- /* Filter out exceptional cases. */
- GET_FLOAT_WORD(hx, x);
- ix = hx & 0x7fffffff; /* high word of |x| */
- if(ix >= 0x43000000) { /* |x| >= 128 */
- if(ix >= 0x7f800000) {
- if ((ix & 0x7fffff) != 0 || (hx & 0x80000000) == 0)
- return (x + x); /* x is NaN or +Inf */
- else
- return (0.0); /* x is -Inf */
- }
- if(x >= 0x1.0p7f)
- return (huge * huge); /* overflow */
- if(x <= -0x1.2cp7f)
- return (twom100 * twom100); /* underflow */
- } else if (ix <= 0x33000000) { /* |x| <= 0x1p-25 */
- return (1.0f + x);
- }
-
- /* Reduce x, computing z, i0, and k. */
- STRICT_ASSIGN(float, t, x + redux);
- GET_FLOAT_WORD(i0, t);
- i0 += TBLSIZE / 2;
- k = (i0 >> TBLBITS) << 20;
- i0 &= TBLSIZE - 1;
- t -= redux;
- z = x - t;
- INSERT_WORDS(twopk, 0x3ff00000 + k, 0);
-
- /* Compute r = exp2(y) = exp2ft[i0] * p(z). */
- tv = exp2ft[i0];
- u = tv * z;
- tv = tv + u * (P1 + z * P2) + u * (z * z) * (P3 + z * P4);
-
- /* Scale by 2**(k>>20). */
- return (tv * twopk);
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1.c b/libm/upstream-freebsd/lib/msun/src/s_expm1.c
index 844f103..cdc225e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_expm1.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_expm1.c
@@ -1,4 +1,3 @@
-/* @(#)s_expm1.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* expm1(x)
* Returns exp(x)-1, the exponential of x minus 1.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_expm1f.c b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c
index b47daac..6887bf2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_expm1f.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_expm1f.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fabsl.c b/libm/upstream-freebsd/lib/msun/src/s_fabsl.c
deleted file mode 100644
index 5076d8a..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_fabsl.c
+++ /dev/null
@@ -1,45 +0,0 @@
-/*-
- * SPDX-License-Identifier: BSD-3-Clause
- *
- * Copyright (c) 2003 Dag-Erling Smørgrav
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer
- * in this position and unchanged.
- * 2. 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.
- * 3. The name of the author may not be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``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 AUTHOR 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.
- *
- * $FreeBSD$
- */
-
-#include <math.h>
-
-#include "fpmath.h"
-
-long double
-fabsl(long double x)
-{
- union IEEEl2bits u;
-
- u.e = x;
- u.bits.sign = 0;
- return (u.e);
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fdim.c b/libm/upstream-freebsd/lib/msun/src/s_fdim.c
index b81dbac..4f56ee4 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fdim.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fdim.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#define DECL(type, fn) \
diff --git a/libm/upstream-freebsd/lib/msun/src/s_finite.c b/libm/upstream-freebsd/lib/msun/src/s_finite.c
index 4c51352..a3fd599 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_finite.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_finite.c
@@ -1,4 +1,3 @@
-/* @(#)s_finite.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* finite(x) returns 1 is x is finite, else 0;
* no branching!
diff --git a/libm/upstream-freebsd/lib/msun/src/s_finitef.c b/libm/upstream-freebsd/lib/msun/src/s_finitef.c
index c62239e..9a4a876 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_finitef.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_finitef.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* finitef(x) returns 1 is x is finite, else 0;
* no branching!
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floor.c b/libm/upstream-freebsd/lib/msun/src/s_floor.c
index 65f696a..7ca65b1 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_floor.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_floor.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* floor(x)
* Return x rounded toward -inf to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floorf.c b/libm/upstream-freebsd/lib/msun/src/s_floorf.c
index 6b510de..d497157 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_floorf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_floorf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* floorf(x)
* Return x rounded toward -inf to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_floorl.c b/libm/upstream-freebsd/lib/msun/src/s_floorl.c
index 6cec3e7..3b54cab 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_floorl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_floorl.c
@@ -7,13 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* floorl(x)
* Return x rounded toward -inf to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fma.c b/libm/upstream-freebsd/lib/msun/src/s_fma.c
index 2fd7075..23a8449 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fma.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fma.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fenv.h>
#include <float.h>
#include <math.h>
@@ -225,17 +222,17 @@
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+ if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0))
return (z);
else
return (nextafter(z, 0));
case FE_DOWNWARD:
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (z);
else
return (nextafter(z, -INFINITY));
default: /* FE_UPWARD */
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (nextafter(z, INFINITY));
else
return (z);
@@ -247,7 +244,7 @@
zs = copysign(DBL_MIN, zs);
fesetround(FE_TONEAREST);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile double vxs = xs;
/*
@@ -263,14 +260,14 @@
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexp(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {
@@ -279,7 +276,7 @@
* rounding modes.
*/
fesetround(oround);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile double vrlo = r.lo;
adj = vrlo + xy.lo;
return (ldexp(r.hi + adj, spread));
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaf.c b/libm/upstream-freebsd/lib/msun/src/s_fmaf.c
index ae979cb..5f3d5d1 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmaf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fenv.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmal.c b/libm/upstream-freebsd/lib/msun/src/s_fmal.c
index a0622a2..2fca206 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmal.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmal.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fenv.h>
#include <float.h>
#include <math.h>
@@ -206,17 +203,17 @@
case FE_TONEAREST:
return (z);
case FE_TOWARDZERO:
- if (x > 0.0 ^ y < 0.0 ^ z < 0.0)
+ if ((x > 0.0) ^ (y < 0.0) ^ (z < 0.0))
return (z);
else
return (nextafterl(z, 0));
case FE_DOWNWARD:
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (z);
else
return (nextafterl(z, -INFINITY));
default: /* FE_UPWARD */
- if (x > 0.0 ^ y < 0.0)
+ if ((x > 0.0) ^ (y < 0.0))
return (nextafterl(z, INFINITY));
else
return (z);
@@ -228,7 +225,7 @@
zs = copysignl(LDBL_MIN, zs);
fesetround(FE_TONEAREST);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile long double vxs = xs;
/*
@@ -244,14 +241,14 @@
spread = ex + ey;
- if (r.hi == 0.0) {
+ if (r.hi == 0.0 && xy.lo == 0) {
/*
* When the addends cancel to 0, ensure that the result has
* the correct sign.
*/
fesetround(oround);
volatile long double vzs = zs; /* XXX gcc CSE bug workaround */
- return (xy.hi + vzs + ldexpl(xy.lo, spread));
+ return (xy.hi + vzs);
}
if (oround != FE_TONEAREST) {
@@ -260,7 +257,7 @@
* rounding modes.
*/
fesetround(oround);
- /* work around clang bug 8100 */
+ /* work around clang issue #8472 */
volatile long double vrlo = r.lo;
adj = vrlo + xy.lo;
return (ldexpl(r.hi + adj, spread));
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmax.c b/libm/upstream-freebsd/lib/msun/src/s_fmax.c
index 42bd11c..5d437fc 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmax.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmax.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c b/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c
index 10667d3..1572572 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaxf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#include "fpmath.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c b/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c
index bf42587..73e2a4b 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmaxl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#include "fpmath.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fmin.c b/libm/upstream-freebsd/lib/msun/src/s_fmin.c
index e79071d..a349e5d 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fmin.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fmin.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fminf.c b/libm/upstream-freebsd/lib/msun/src/s_fminf.c
index 19ffd42..5c2537e 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fminf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fminf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#include "fpmath.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_fminl.c b/libm/upstream-freebsd/lib/msun/src/s_fminl.c
index c906f1d..7ac17e3 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_fminl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_fminl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#include "fpmath.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexp.c b/libm/upstream-freebsd/lib/msun/src/s_frexp.c
index 318a991..90aea67 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_frexp.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexp.c
@@ -1,4 +1,3 @@
-/* @(#)s_frexp.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* for non-zero x
* x = frexp(arg,&exp);
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexpf.c b/libm/upstream-freebsd/lib/msun/src/s_frexpf.c
index 5a7c486..bca27b5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_frexpf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexpf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_frexpl.c b/libm/upstream-freebsd/lib/msun/src/s_frexpl.c
index 7101615..32f1264 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_frexpl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_frexpl.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogb.c b/libm/upstream-freebsd/lib/msun/src/s_ilogb.c
index a930bc9..27e0bbb 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ilogb.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogb.c
@@ -1,4 +1,3 @@
-/* @(#)s_ilogb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* ilogb(double x)
* return the binary exponent of non-zero x
* ilogb(0) = FP_ILOGB0
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c b/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c
index 93fe295..e0f8fee 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogbf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <limits.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c b/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c
index 3211f44..4d8fb8f 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_ilogbl.c
@@ -1,5 +1,4 @@
/*
- * From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrint.c b/libm/upstream-freebsd/lib/msun/src/s_llrint.c
index 7c959ec..5e27603 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llrint.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrint.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type double
#define roundit rint
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrintf.c b/libm/upstream-freebsd/lib/msun/src/s_llrintf.c
index 7ec6015..b117f7c 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llrintf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrintf.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type float
#define roundit rintf
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llrintl.c b/libm/upstream-freebsd/lib/msun/src/s_llrintl.c
index 6ef8375..82f4529 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llrintl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llrintl.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type long double
#define roundit rintl
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llround.c b/libm/upstream-freebsd/lib/msun/src/s_llround.c
index 827dfc1..3983ce1 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llround.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llround.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type double
#define roundit round
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llroundf.c b/libm/upstream-freebsd/lib/msun/src/s_llroundf.c
index c037a18..827d915 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llroundf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llroundf.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type float
#define roundit roundf
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_llroundl.c b/libm/upstream-freebsd/lib/msun/src/s_llroundl.c
index 02c44eb..40cad84 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_llroundl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_llroundl.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type long double
#define roundit roundl
#define dtype long long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_log1p.c b/libm/upstream-freebsd/lib/msun/src/s_log1p.c
index 3cc77bd..7131bea 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_log1p.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_log1p.c
@@ -1,4 +1,3 @@
-/* @(#)s_log1p.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* double log1p(double x)
*
* Method :
diff --git a/libm/upstream-freebsd/lib/msun/src/s_log1pf.c b/libm/upstream-freebsd/lib/msun/src/s_log1pf.c
index df04c67..dad567b 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_log1pf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_log1pf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logb.c b/libm/upstream-freebsd/lib/msun/src/s_logb.c
index a47e354..ec777fd 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_logb.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_logb.c
@@ -1,4 +1,3 @@
-/* @(#)s_logb.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* double logb(x)
* IEEE 754 logb. Included to pass IEEE test suite. Not recommend.
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logbf.c b/libm/upstream-freebsd/lib/msun/src/s_logbf.c
index 3ab190d..0416a9c 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_logbf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_logbf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_logbl.c b/libm/upstream-freebsd/lib/msun/src/s_logbl.c
index ee1a91f..1641dfb 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_logbl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_logbl.c
@@ -1,5 +1,4 @@
/*
- * From: @(#)s_ilogb.c 5.1 93/09/24
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
*
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <limits.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrint.c b/libm/upstream-freebsd/lib/msun/src/s_lrint.c
index be00cbb..b1e9654 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lrint.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrint.c
@@ -26,12 +26,10 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <fenv.h>
#include <math.h>
#ifndef type
-__FBSDID("$FreeBSD$");
#define type double
#define roundit rint
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrintf.c b/libm/upstream-freebsd/lib/msun/src/s_lrintf.c
index a757ded..1c040e8 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lrintf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrintf.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type float
#define roundit rintf
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lrintl.c b/libm/upstream-freebsd/lib/msun/src/s_lrintl.c
index 497b442..91614e8 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lrintl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lrintl.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type long double
#define roundit rintl
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lround.c b/libm/upstream-freebsd/lib/msun/src/s_lround.c
index 00f4b95..ae2f5ce 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lround.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lround.c
@@ -26,13 +26,11 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
#include <sys/limits.h>
#include <fenv.h>
#include <math.h>
#ifndef type
-__FBSDID("$FreeBSD$");
#define type double
#define roundit round
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lroundf.c b/libm/upstream-freebsd/lib/msun/src/s_lroundf.c
index e24fe7f..86e63cc 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lroundf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lroundf.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type float
#define roundit roundf
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_lroundl.c b/libm/upstream-freebsd/lib/msun/src/s_lroundl.c
index e410827..57a2e90 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_lroundl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_lroundl.c
@@ -1,6 +1,3 @@
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#define type long double
#define roundit roundl
#define dtype long
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modf.c b/libm/upstream-freebsd/lib/msun/src/s_modf.c
index ab13191..6ee2d5a 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_modf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_modf.c
@@ -1,4 +1,3 @@
-/* @(#)s_modf.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,10 +9,6 @@
* ====================================================
*/
-#ifndef lint
-static char rcsid[] = "$FreeBSD$";
-#endif
-
/*
* modf(double x, double *iptr)
* return fraction part of x, and return x's integral part in *iptr.
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modff.c b/libm/upstream-freebsd/lib/msun/src/s_modff.c
index 062259c..39f6c1c 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_modff.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_modff.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_modfl.c b/libm/upstream-freebsd/lib/msun/src/s_modfl.c
index 8e5c4d3..32470eb 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_modfl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_modfl.c
@@ -34,8 +34,6 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * $FreeBSD$
*/
#include <float.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nan.c b/libm/upstream-freebsd/lib/msun/src/s_nan.c
index 1345f22..d129a55 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nan.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nan.c
@@ -24,8 +24,6 @@
* 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.
- *
- * $FreeBSD$
*/
#include <sys/endian.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c b/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c
index ae6ffde..3dcaf98 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nearbyint.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <fenv.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafter.c b/libm/upstream-freebsd/lib/msun/src/s_nextafter.c
index 52dd21c..1b394e5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nextafter.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafter.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c b/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c
index 96e21ef..418b126 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafterf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c b/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c
index 9c61a43..fe5a010 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nextafterl.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* IEEE functions
* nextafter(x,y)
* return the next machine floating-point number of x in the
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c b/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c
index b2a50d3..5482dc2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nexttoward.c
@@ -1,4 +1,3 @@
-/* @(#)s_nextafter.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* We assume that a long double has a 15-bit exponent. On systems
* where long double is the same as double, nexttoward() is an alias
diff --git a/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c b/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c
index 9ddfff9..05c89f4 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_nexttowardf.c
@@ -9,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "fpmath.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquo.c b/libm/upstream-freebsd/lib/msun/src/s_remquo.c
index 6a111df..206d290 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_remquo.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquo.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquof.c b/libm/upstream-freebsd/lib/msun/src/s_remquof.c
index f4c1016..9cd1485 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_remquof.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquof.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_remquol.c b/libm/upstream-freebsd/lib/msun/src/s_remquol.c
index a9f5813..0dadcea 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_remquol.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_remquol.c
@@ -1,4 +1,3 @@
-/* @(#)e_fmod.c 1.3 95/01/18 */
/*-
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <stdint.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rint.c b/libm/upstream-freebsd/lib/msun/src/s_rint.c
index c56f8fb..d82a9d0 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_rint.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_rint.c
@@ -1,4 +1,3 @@
-/* @(#)s_rint.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* rint(x)
* Return x rounded to integral value according to the prevailing
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rintf.c b/libm/upstream-freebsd/lib/msun/src/s_rintf.c
index f8743a4..3f0cb90 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_rintf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_rintf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <stdint.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_rintl.c b/libm/upstream-freebsd/lib/msun/src/s_rintl.c
index 790edbc..72c9cab 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_rintl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_rintl.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_round.c b/libm/upstream-freebsd/lib/msun/src/s_round.c
index a112bc5..c1b55f5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_round.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_round.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_roundf.c b/libm/upstream-freebsd/lib/msun/src/s_roundf.c
index bb6f77c..7c09e09 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_roundf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_roundf.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_roundl.c b/libm/upstream-freebsd/lib/msun/src/s_roundl.c
index 9e85423..bc5dfe5 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_roundl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_roundl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_scalbln.c b/libm/upstream-freebsd/lib/msun/src/s_scalbln.c
index e8c6377..42e4669 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_scalbln.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_scalbln.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
#define NMAX 65536
diff --git a/libm/upstream-freebsd/lib/msun/src/s_significand.c b/libm/upstream-freebsd/lib/msun/src/s_significand.c
index eed80ec..62571bb 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_significand.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_significand.c
@@ -1,4 +1,3 @@
-/* @(#)s_signif.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* significand(x) computes just
* scalb(x, (double) -ilogb(x)),
diff --git a/libm/upstream-freebsd/lib/msun/src/s_significandf.c b/libm/upstream-freebsd/lib/msun/src/s_significandf.c
index b33ab7b..3cdaa4d 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_significandf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_significandf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sin.c b/libm/upstream-freebsd/lib/msun/src/s_sin.c
index 17ea846..614bcc2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_sin.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_sin.c
@@ -1,4 +1,3 @@
-/* @(#)s_sin.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* sin(x)
* Return sine function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sincos.c b/libm/upstream-freebsd/lib/msun/src/s_sincos.c
index 85e8d74..4e819ea 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_sincos.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_sincos.c
@@ -12,9 +12,6 @@
* algorithms are contained in the original files.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sincosf.c b/libm/upstream-freebsd/lib/msun/src/s_sincosf.c
deleted file mode 100644
index 755ff05..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_sincosf.c
+++ /dev/null
@@ -1,126 +0,0 @@
-/*-
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-/* s_sincosf.c -- float version of s_sincos.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- * Merged s_sinf.c and s_cosf.c by Steven G. Kargl.
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#define INLINE_REM_PIO2F
-#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_sincosf.h"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-p1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-p2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-p3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-p4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-void
-sincosf(float x, float *sn, float *cs)
-{
- float c, s;
- double y;
- int32_t n, hx, ix;
-
- GET_FLOAT_WORD(hx, x);
- ix = hx & 0x7fffffff;
-
- if (ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if (ix < 0x39800000) { /* |x| < 2**-12 */
- if ((int)x == 0) {
- *sn = x; /* x with inexact if x != 0 */
- *cs = 1;
- return;
- }
- }
- __kernel_sincosdf(x, sn, cs);
- return;
- }
-
- if (ix <= 0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if (ix <= 0x4016cbe3) { /* |x| ~<= 3pi/4 */
- if (hx > 0) {
- __kernel_sincosdf(x - p1pio2, cs, sn);
- *cs = -*cs;
- } else {
- __kernel_sincosdf(x + p1pio2, cs, sn);
- *sn = -*sn;
- }
- } else {
- if (hx > 0)
- __kernel_sincosdf(x - p2pio2, sn, cs);
- else
- __kernel_sincosdf(x + p2pio2, sn, cs);
- *sn = -*sn;
- *cs = -*cs;
- }
- return;
- }
-
- if (ix <= 0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if (ix <= 0x40afeddf) { /* |x| ~<= 7*pi/4 */
- if (hx > 0) {
- __kernel_sincosdf(x - p3pio2, cs, sn);
- *sn = -*sn;
- } else {
- __kernel_sincosdf(x + p3pio2, cs, sn);
- *cs = -*cs;
- }
- } else {
- if (hx > 0)
- __kernel_sincosdf(x - p4pio2, sn, cs);
- else
- __kernel_sincosdf(x + p4pio2, sn, cs);
- }
- return;
- }
-
- /* If x = Inf or NaN, then sin(x) = NaN and cos(x) = NaN. */
- if (ix >= 0x7f800000) {
- *sn = x - x;
- *cs = x - x;
- return;
- }
-
- /* Argument reduction. */
- n = __ieee754_rem_pio2f(x, &y);
- __kernel_sincosdf(y, &s, &c);
-
- switch(n & 3) {
- case 0:
- *sn = s;
- *cs = c;
- break;
- case 1:
- *sn = c;
- *cs = -s;
- break;
- case 2:
- *sn = -s;
- *cs = -c;
- break;
- default:
- *sn = -c;
- *cs = s;
- }
-}
-
-
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sincosl.c b/libm/upstream-freebsd/lib/msun/src/s_sincosl.c
index 3dd3457..7fb69aa 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_sincosl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_sincosl.c
@@ -26,9 +26,6 @@
* s_sinl.c and s_cosl.c merged by Steven G. Kargl.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sinf.c b/libm/upstream-freebsd/lib/msun/src/s_sinf.c
deleted file mode 100644
index 41b5dc1..0000000
--- a/libm/upstream-freebsd/lib/msun/src/s_sinf.c
+++ /dev/null
@@ -1,85 +0,0 @@
-/* s_sinf.c -- float version of s_sin.c.
- * Conversion to float by Ian Lance Taylor, Cygnus Support, ian@cygnus.com.
- * Optimized by Bruce D. Evans.
- */
-
-/*
- * ====================================================
- * Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
- *
- * Developed at SunPro, a Sun Microsystems, Inc. business.
- * Permission to use, copy, modify, and distribute this
- * software is freely granted, provided that this notice
- * is preserved.
- * ====================================================
- */
-
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
-#include <float.h>
-
-#include "math.h"
-#define INLINE_KERNEL_COSDF
-#define INLINE_KERNEL_SINDF
-#define INLINE_REM_PIO2F
-#include "math_private.h"
-#include "e_rem_pio2f.c"
-#include "k_cosf.c"
-#include "k_sinf.c"
-
-/* Small multiples of pi/2 rounded to double precision. */
-static const double
-s1pio2 = 1*M_PI_2, /* 0x3FF921FB, 0x54442D18 */
-s2pio2 = 2*M_PI_2, /* 0x400921FB, 0x54442D18 */
-s3pio2 = 3*M_PI_2, /* 0x4012D97C, 0x7F3321D2 */
-s4pio2 = 4*M_PI_2; /* 0x401921FB, 0x54442D18 */
-
-float
-sinf(float x)
-{
- double y;
- int32_t n, hx, ix;
-
- GET_FLOAT_WORD(hx,x);
- ix = hx & 0x7fffffff;
-
- if(ix <= 0x3f490fda) { /* |x| ~<= pi/4 */
- if(ix<0x39800000) /* |x| < 2**-12 */
- if(((int)x)==0) return x; /* x with inexact if x != 0 */
- return __kernel_sindf(x);
- }
- if(ix<=0x407b53d1) { /* |x| ~<= 5*pi/4 */
- if(ix<=0x4016cbe3) { /* |x| ~<= 3pi/4 */
- if(hx>0)
- return __kernel_cosdf(x - s1pio2);
- else
- return -__kernel_cosdf(x + s1pio2);
- } else
- return __kernel_sindf((hx > 0 ? s2pio2 : -s2pio2) - x);
- }
- if(ix<=0x40e231d5) { /* |x| ~<= 9*pi/4 */
- if(ix<=0x40afeddf) { /* |x| ~<= 7*pi/4 */
- if(hx>0)
- return -__kernel_cosdf(x - s3pio2);
- else
- return __kernel_cosdf(x + s3pio2);
- } else
- return __kernel_sindf(x + (hx > 0 ? -s4pio2 : s4pio2));
- }
-
- /* sin(Inf or NaN) is NaN */
- else if (ix>=0x7f800000) return x-x;
-
- /* general argument reduction needed */
- else {
- n = __ieee754_rem_pio2f(x,&y);
- switch(n&3) {
- case 0: return __kernel_sindf(y);
- case 1: return __kernel_cosdf(y);
- case 2: return __kernel_sindf(-y);
- default:
- return -__kernel_cosdf(y);
- }
- }
-}
diff --git a/libm/upstream-freebsd/lib/msun/src/s_sinl.c b/libm/upstream-freebsd/lib/msun/src/s_sinl.c
index c5ee106..d0b7b34 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_sinl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_sinl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#ifdef __i386__
#include <ieeefp.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tan.c b/libm/upstream-freebsd/lib/msun/src/s_tan.c
index 196c27e..20b9516 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tan.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tan.c
@@ -1,4 +1,3 @@
-/* @(#)s_tan.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* tan(x)
* Return tangent function of x.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanf.c b/libm/upstream-freebsd/lib/msun/src/s_tanf.c
index 4fe8c17..2462f96 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tanf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanf.c
@@ -14,9 +14,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <float.h>
#include "math.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanh.c b/libm/upstream-freebsd/lib/msun/src/s_tanh.c
index 6d26c69..cc8daed 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tanh.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanh.c
@@ -1,4 +1,3 @@
-/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/* Tanh(x)
* Return the Hyperbolic Tangent of x
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanhf.c b/libm/upstream-freebsd/lib/msun/src/s_tanhf.c
index f537be4..e56813a 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tanhf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanhf.c
@@ -13,9 +13,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include "math.h"
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanhl.c b/libm/upstream-freebsd/lib/msun/src/s_tanhl.c
index b753186..3285b9a 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tanhl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanhl.c
@@ -1,6 +1,5 @@
/* from: FreeBSD: head/lib/msun/src/s_tanhl.c XXX */
-/* @(#)s_tanh.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -12,9 +11,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* See s_tanh.c for complete comments.
*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tanl.c b/libm/upstream-freebsd/lib/msun/src/s_tanl.c
index c21e38d..3736477 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tanl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tanl.c
@@ -26,9 +26,6 @@
* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* Limited testing on pseudorandom numbers drawn within [0:4e8] shows
* an accuracy of <= 1.5 ULP where 247024 values of x out of 40 million
diff --git a/libm/upstream-freebsd/lib/msun/src/s_tgammaf.c b/libm/upstream-freebsd/lib/msun/src/s_tgammaf.c
index 6cbd356..9fa9df9 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_tgammaf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_tgammaf.c
@@ -26,9 +26,6 @@
* SUCH DAMAGE.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <math.h>
/*
diff --git a/libm/upstream-freebsd/lib/msun/src/s_trunc.c b/libm/upstream-freebsd/lib/msun/src/s_trunc.c
index 63a6753..3ec59f2 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_trunc.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_trunc.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* trunc(x)
* Return x rounded toward 0 to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_truncf.c b/libm/upstream-freebsd/lib/msun/src/s_truncf.c
index 384eaee..3f4db30 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_truncf.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_truncf.c
@@ -1,4 +1,3 @@
-/* @(#)s_floor.c 5.1 93/09/24 */
/*
* ====================================================
* Copyright (C) 1993 by Sun Microsystems, Inc. All rights reserved.
@@ -10,9 +9,6 @@
* ====================================================
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* truncf(x)
* Return x rounded toward 0 to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/s_truncl.c b/libm/upstream-freebsd/lib/msun/src/s_truncl.c
index 9e2b511..81e794d 100644
--- a/libm/upstream-freebsd/lib/msun/src/s_truncl.c
+++ b/libm/upstream-freebsd/lib/msun/src/s_truncl.c
@@ -7,13 +7,8 @@
* software is freely granted, provided that this notice
* is preserved.
* ====================================================
- *
- * From: @(#)s_floor.c 5.1 93/09/24
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
/*
* truncl(x)
* Return x rounded toward 0 to integral value
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabs.c b/libm/upstream-freebsd/lib/msun/src/w_cabs.c
index 543b858..4986461 100644
--- a/libm/upstream-freebsd/lib/msun/src/w_cabs.c
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabs.c
@@ -5,9 +5,6 @@
* Placed into the Public Domain, 1994.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <float.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabsf.c b/libm/upstream-freebsd/lib/msun/src/w_cabsf.c
index b5065c8..aedbdef 100644
--- a/libm/upstream-freebsd/lib/msun/src/w_cabsf.c
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabsf.c
@@ -5,11 +5,6 @@
* Placed into the Public Domain, 1994.
*/
-#ifndef lint
-static const char rcsid[] =
- "$FreeBSD$";
-#endif /* not lint */
-
#include <complex.h>
#include <math.h>
#include "math_private.h"
diff --git a/libm/upstream-freebsd/lib/msun/src/w_cabsl.c b/libm/upstream-freebsd/lib/msun/src/w_cabsl.c
index b715e0c..1539944 100644
--- a/libm/upstream-freebsd/lib/msun/src/w_cabsl.c
+++ b/libm/upstream-freebsd/lib/msun/src/w_cabsl.c
@@ -7,9 +7,6 @@
* Modified by Steven G. Kargl for the long double type.
*/
-#include <sys/cdefs.h>
-__FBSDID("$FreeBSD$");
-
#include <complex.h>
#include <math.h>
diff --git a/libm/upstream-freebsd/lib/msun/src/w_dremf.c b/libm/upstream-freebsd/lib/msun/src/w_dremf.c
index 4bfcff2..18df078 100644
--- a/libm/upstream-freebsd/lib/msun/src/w_dremf.c
+++ b/libm/upstream-freebsd/lib/msun/src/w_dremf.c
@@ -4,7 +4,6 @@
* Written by J.T. Conklin, <jtc@wimsey.com>
* Placed into the Public Domain, 1994.
*/
-/* $FreeBSD$ */
#include "math.h"
#include "math_private.h"
diff --git a/libm/x86/lrint.S b/libm/x86/lrint.S
deleted file mode 100644
index df26b30..0000000
--- a/libm/x86/lrint.S
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-#include <private/bionic_asm.h>
-
-ENTRY(lrint)
- // LP32 sizeof(long) == 4.
- movsd 0x4(%esp),%xmm0
- cvtsd2si %xmm0, %eax
- ret
-END(lrint)
-
-// LP32 sizeof(long double) == sizeof(double).
-ALIAS_SYMBOL(lrintl, lrint);
diff --git a/libm/x86/lrintf.S b/libm/x86/lrintf.S
deleted file mode 100644
index d2dae03..0000000
--- a/libm/x86/lrintf.S
+++ /dev/null
@@ -1,38 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-#include <private/bionic_asm.h>
-
-ENTRY(lrintf)
- // LP32 sizeof(long) == 4.
- movss 0x4(%esp),%xmm0
- cvtss2si %xmm0, %eax
- ret
-END(lrintf)
diff --git a/libm/x86_64/lrint.S b/libm/x86_64/lrint.S
deleted file mode 100644
index d678761..0000000
--- a/libm/x86_64/lrint.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-#include <private/bionic_asm.h>
-
-ENTRY(lrint)
- // LP64 sizeof(long) == 8.
- cvtsd2si %xmm0, %rax
- ret
-END(lrint)
-
-// LP64 sizeof(long long) == sizeof(long).
-ALIAS_SYMBOL(llrint, lrint);
diff --git a/libm/x86_64/lrintf.S b/libm/x86_64/lrintf.S
deleted file mode 100644
index 3d3acfb..0000000
--- a/libm/x86_64/lrintf.S
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
-Copyright (c) 2014, Intel Corporation
-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.
-
- * Neither the name of Intel Corporation nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
-
-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.
-*/
-
-#include <private/bionic_asm.h>
-
-ENTRY(lrintf)
- // LP64 sizeof(long) == 8.
- cvtss2si %xmm0, %rax
- ret
-END(lrintf)
-
-// LP64 sizeof(long long) == sizeof(long).
-ALIAS_SYMBOL(llrintf, lrintf);
diff --git a/linker/Android.bp b/linker/Android.bp
index e1a5a91..563cf3d 100644
--- a/linker/Android.bp
+++ b/linker/Android.bp
@@ -1,14 +1,3 @@
-// ========================================================
-// linker_wrapper - Linux Bionic (on the host)
-// ========================================================
-
-// This is used for bionic on (host) Linux to bootstrap our linker embedded into
-// a binary.
-//
-// Host bionic binaries do not have a PT_INTERP section, instead this gets
-// embedded as the entry point, and the linker is embedded as ELF sections in
-// each binary. There's a linker script that sets all of that up (generated by
-// extract_linker), and defines the extern symbols used in this file.
package {
default_team: "trendy_team_native_tools_libraries",
default_applicable_licenses: ["bionic_linker_license"],
@@ -25,6 +14,27 @@
],
}
+linker_common_flags = [
+ "-fno-stack-protector",
+ "-Wstrict-overflow=5",
+ "-fvisibility=hidden",
+ "-Wall",
+ "-Wextra",
+ "-Wunused",
+ "-Werror",
+]
+
+// ========================================================
+// linker_wrapper - Linux Bionic (on the host)
+// ========================================================
+
+// This is used for bionic on (host) Linux to bootstrap our linker embedded into
+// a binary.
+//
+// Host bionic binaries do not have a PT_INTERP section, instead this gets
+// embedded as the entry point, and the linker is embedded as ELF sections in
+// each binary. There's a linker script that sets all of that up (generated by
+// extract_linker), and defines the extern symbols used in this file.
cc_object {
name: "linker_wrapper",
host_supported: true,
@@ -36,15 +46,7 @@
},
},
- cflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wno-unused",
- "-Werror",
- ],
+ cflags: linker_common_flags,
srcs: [
"linker_wrapper.cpp",
@@ -83,26 +85,8 @@
},
},
- cflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Werror",
- ],
-
- // TODO: split out the asflags.
- asflags: [
- "-fno-stack-protector",
- "-Wstrict-overflow=5",
- "-fvisibility=hidden",
- "-Wall",
- "-Wextra",
- "-Wunused",
- "-Werror",
- ],
+ cflags: linker_common_flags,
+ asflags: linker_common_flags,
product_variables: {
debuggable: {
@@ -231,6 +215,7 @@
name: "linker_sources_riscv64",
srcs: [
"arch/riscv64/begin.S",
+ "arch/riscv64/tlsdesc_resolver.S",
],
}
@@ -272,62 +257,35 @@
// A template for the linker binary. May be inherited by native bridge implementations.
cc_defaults {
name: "linker_bin_template",
- defaults: ["linker_defaults"],
+ defaults: [
+ "linker_defaults",
+ "keep_symbols",
+ ],
srcs: [":linker_sources"],
arch: {
arm: {
srcs: [":linker_sources_arm"],
-
- // Arm 32 bit does not produce complete exidx unwind information
- // so keep the .debug_frame which is relatively small and does
- // include needed unwind information.
- // See b/242162222 for details.
- strip: {
- keep_symbols_and_debug_frame: true,
- },
},
arm64: {
srcs: [":linker_sources_arm64"],
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
riscv64: {
srcs: [":linker_sources_riscv64"],
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
x86: {
srcs: [":linker_sources_x86"],
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
x86_64: {
srcs: [":linker_sources_x86_64"],
-
- // Leave the symbols in the shared library so that stack unwinders can produce
- // meaningful name resolution.
- strip: {
- keep_symbols: true,
- },
},
},
+ static_executable: true,
+
// -shared is used to overwrite the -Bstatic and -static flags triggered by enabling
- // static_executable. This dynamic linker is actually a shared object linked with static
+ // static_executable. The dynamic linker is actually a shared object linked with static
// libraries.
ldflags: [
"-shared",
@@ -343,48 +301,38 @@
"-Wl,--pack-dyn-relocs=relr",
],
- // we are going to link libc++_static manually because
- // when stl is not set to "none" build system adds libdl
- // to the list of static libraries which needs to be
- // avoided in the case of building loader.
+ // We link libc++_static manually because otherwise the build system will
+ // automatically add libdl to the list of static libraries.
stl: "none",
- // we don't want crtbegin.o (because we have begin.o), so unset it
- // just for this module
+ // We don't want crtbegin.o (because we have our own arch/*/begin.o),
+ // so unset it just for this module.
nocrt: true,
- static_executable: true,
-
// Insert an extra objcopy step to add prefix to symbols. This is needed to prevent gdb
// looking up symbols in the linker by mistake.
prefix_symbols: "__dl_",
sanitize: {
hwaddress: false,
+ memtag_stack: false,
},
static_libs: [
"liblinker_main",
"liblinker_malloc",
- "libc++_static",
+ // We use a version of libc++ built without exceptions,
+ // because accessing EH globals uses ELF TLS,
+ // which is not supported in the loader.
+ "libc++_static_noexcept",
+
"libc_nomalloc",
"libc_dynamic_dispatch",
"libm",
"libunwind",
],
- // Ensure that if the linker needs __gnu_Unwind_Find_exidx, then the linker will have a
- // definition of the symbol. The linker links against libgcc.a, whose arm32 unwinder has a weak
- // reference to __gnu_Unwind_Find_exidx, which isn't sufficient to pull in the strong definition
- // of __gnu_Unwind_Find_exidx from libc. An unresolved weak reference would create a
- // non-relative dynamic relocation in the linker binary, which complicates linker startup.
- //
- // This line should be unnecessary because the linker's dependency on libunwind_llvm.a should
- // override libgcc.a, but this line provides a simpler guarantee. It can be removed once the
- // linker stops linking against libgcc.a's arm32 unwinder.
- whole_static_libs: ["libc_unwind_static"],
-
system_shared_libs: [],
// Opt out of native_coverage when opting out of system_shared_libs
@@ -434,7 +382,7 @@
"linker_debuggerd_android.cpp",
],
static_libs: [
- "libc++demangle",
+ "libc++demangle_noexcept",
"libdebuggerd_handler_fallback",
],
},
@@ -471,35 +419,6 @@
}
cc_library {
- // NOTE: --exclude-libs=libgcc.a makes sure that any symbols ld-android.so pulls from
- // libgcc.a are made static to ld-android.so. This in turn ensures that libraries that
- // a) pull symbols from libgcc.a and b) depend on ld-android.so will not rely on ld-android.so
- // to provide those symbols, but will instead pull them from libgcc.a. Specifically,
- // we use this property to make sure libc.so has its own copy of the code from
- // libgcc.a it uses.
- //
- // DO NOT REMOVE --exclude-libs!
-
- ldflags: [
- "-Wl,--exclude-libs=libgcc.a",
- "-Wl,--exclude-libs=libgcc_stripped.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-arm-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-aarch64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-riscv64-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-i686-android.a",
- "-Wl,--exclude-libs=libclang_rt.builtins-x86_64-android.a",
- ],
-
- // for x86, exclude libgcc_eh.a for the same reasons as above
- arch: {
- x86: {
- ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
- },
- x86_64: {
- ldflags: ["-Wl,--exclude-libs=libgcc_eh.a"],
- },
- },
-
srcs: ["ld_android.cpp"],
cflags: [
"-Wall",
diff --git a/linker/arch/riscv64/tlsdesc_resolver.S b/linker/arch/riscv64/tlsdesc_resolver.S
new file mode 100644
index 0000000..fedc926
--- /dev/null
+++ b/linker/arch/riscv64/tlsdesc_resolver.S
@@ -0,0 +1,201 @@
+/*
+ * Copyright (C) 2024 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.
+ */
+
+#include <platform/bionic/tls_defines.h>
+#include <private/bionic_asm.h>
+#include <private/bionic_elf_dtv_offset.h>
+
+#ifndef TLS_DTV_OFFSET
+ #error "TLS_DTV_OFFSET not defined"
+#endif
+
+.globl __tls_get_addr
+
+// spill a register onto the stack
+.macro spill reg, idx, f=
+ \f\()sd \reg, \idx*8(sp)
+ .cfi_rel_offset \reg, (\idx)*8
+.endm
+
+// reload a value from the stack
+.macro reload reg, idx, f=
+ \f\()ld \reg, \idx*8(sp)
+ .cfi_same_value \reg
+.endm
+
+.macro spill_vector_regs
+ csrr a3, vlenb
+ slli a3, a3, 3
+ sub sp, sp, a3
+ vs8r.v v0, (sp)
+ sub sp, sp, a3
+ vs8r.v v8, (sp)
+ sub sp, sp, a3
+ vs8r.v v16, (sp)
+ sub sp, sp, a3
+ vs8r.v v24, (sp)
+.endm
+
+.macro reload_vector_regs
+ csrr a3, vlenb
+ slli a3, a3, 3
+ vl8r.v v24, (sp)
+ add sp, sp, a3
+ vl8r.v v16, (sp)
+ add sp, sp, a3
+ vl8r.v v8, (sp)
+ add sp, sp, a3
+ vl8r.v v0, (sp)
+ add sp, sp, a3
+.endm
+
+// We save a total of 35 registers
+.macro for_each_saved_reg op max
+ \op ra, 1
+ \op a1, 2
+ \op a2, 3
+ \op a3, 4
+ \op a4, 5
+ \op a5, 6
+ \op a6, 7
+ \op a7, 8
+ \op t0, 9
+ \op t1, 10
+ \op t2, 11
+ \op t3, 12
+ \op t4, 13
+ \op t5, 14
+ \op t6, 15
+ // save floating point regs
+ \op ft0, 16, f
+ \op ft1, 17, f
+ \op ft2, 18, f
+ \op ft3, 19, f
+ \op ft4, 20, f
+ \op ft5, 21, f
+ \op ft6, 22, f
+ \op ft7, 23, f
+ \op ft8, 24, f
+ \op ft9, 25, f
+ \op ft10, 26, f
+ \op ft11, 27, f
+ \op fa0, 28, f
+ \op fa1, 29, f
+ \op fa2, 30, f
+ \op fa3, 31, f
+ \op fa4, 32, f
+ \op fa5, 33, f
+ \op fa6, 34, f
+ \op fa7, 35, f
+.endm
+
+// These resolver functions must preserve every register except a0. They set a0
+// to the offset of the TLS symbol relative to the thread pointer.
+
+ENTRY_PRIVATE(tlsdesc_resolver_static)
+ ld a0, 8(a0)
+ jr t0
+END(tlsdesc_resolver_static)
+
+ENTRY_PRIVATE(tlsdesc_resolver_dynamic)
+ // We only need 3 stack slots, but still require a 4th slot for alignment
+ addi sp, sp, -4*8
+ .cfi_def_cfa_offset 4*8
+ spill a1, 1
+ spill a2, 2
+ spill a3, 3
+
+ ld a2, (TLS_SLOT_DTV * 8)(tp) // a2 = &DTV
+ ld a1, (a2) // a1 = TlsDtv::generation (DTV[0])
+
+ ld a0, 8(a0) // a0 = TlsDynamicResolverArg*
+ ld a3, (a0) // a3 = TlsDynamicResolverArg::generation
+
+ // Fallback if TlsDtv::generation < TlsDynamicResolverArg::generation
+ // since we need to call __tls_get_addr
+ blt a1, a3, L(fallback)
+
+ // We can't modify a0 yet, since tlsdesc_resolver_dynamic_slow_path requires
+ // a pointer to the TlsIndex, which is the second field of the
+ // TlsDynamicResolverArg. As a result, we can't modify a0 until we will no
+ // longer fallback.
+ ld a1, 8(a0) // a1 = TlsIndex::module_id
+ slli a1, a1, 3 // a1 = module_id*8 -- scale the idx
+ add a1, a2, a1 // a1 = &TlsDtv::modules[module_id]
+ ld a1, (a1) // a1 = TlsDtv::modules[module_id]
+ beqz a1, L(fallback)
+ ld a3, 16(a0) // a3 = TlsIndex::offset
+ add a0, a1, a3 // a0 = TlsDtv::modules[module_id] + offset
+ sub a0, a0, tp // a0 = TlsDtv::modules[module_id] + offset - tp
+
+ .cfi_remember_state
+ reload a3, 3
+ reload a2, 2
+ reload a1, 1
+ addi sp, sp, 4*8
+ .cfi_adjust_cfa_offset -4*8
+ jr t0
+
+L(fallback):
+ reload a3, 3
+ reload a2, 2
+ reload a1, 1
+ addi sp, sp, 4*8
+ .cfi_adjust_cfa_offset -4*8
+ j tlsdesc_resolver_dynamic_slow_path
+END(tlsdesc_resolver_dynamic)
+
+// On entry, a0 is the address of a TlsDynamicResolverArg object rather than
+// the TlsDescriptor address passed to the original resolver function.
+ENTRY_PRIVATE(tlsdesc_resolver_dynamic_slow_path)
+ // We save a total of 35 registers, but vector spills require an alignment
+ // of 16, so use an extra slot to align it correctly.
+ addi sp, sp, (-8*36)
+ .cfi_def_cfa_offset (8 * 36)
+ for_each_saved_reg spill, 36
+ spill_vector_regs
+
+ add a0, a0, 8
+ call __tls_get_addr
+ addi a0, a0, (-1 * TLS_DTV_OFFSET) // Correct the address by TLS_DTV_OFFSET
+ sub a0, a0, tp
+
+ reload_vector_regs
+ for_each_saved_reg reload, 36
+ addi sp, sp, 8*36
+ .cfi_def_cfa_offset 0
+ jr t0
+END(tlsdesc_resolver_dynamic_slow_path)
+
+// The address of an unresolved weak TLS symbol evaluates to NULL with TLSDESC.
+// The value returned by this function is added to the thread pointer, so return
+// a negated thread pointer to cancel it out.
+ENTRY_PRIVATE(tlsdesc_resolver_unresolved_weak)
+ sub a0, zero, tp
+ jr t0
+END(tlsdesc_resolver_unresolved_weak)
diff --git a/linker/linker.cpp b/linker/linker.cpp
index 8b467a3..4365ea5 100644
--- a/linker/linker.cpp
+++ b/linker/linker.cpp
@@ -387,7 +387,7 @@
auto length = readlink(proc_self_fd, buf, sizeof(buf));
if (length == -1) {
if (!is_first_stage_init()) {
- PRINT("readlink(\"%s\") failed: %s [fd=%d]", proc_self_fd, strerror(errno), fd);
+ PRINT("readlink(\"%s\" [fd=%d]) failed: %m", proc_self_fd, fd);
}
return false;
}
@@ -1185,7 +1185,7 @@
struct stat file_stat;
if (TEMP_FAILURE_RETRY(fstat(task->get_fd(), &file_stat)) != 0) {
- DL_OPEN_ERR("unable to stat file for the library \"%s\": %s", name, strerror(errno));
+ DL_OPEN_ERR("unable to stat file for the library \"%s\": %m", name);
return false;
}
if (file_offset >= file_stat.st_size) {
@@ -1215,7 +1215,7 @@
struct statfs fs_stat;
if (TEMP_FAILURE_RETRY(fstatfs(task->get_fd(), &fs_stat)) != 0) {
- DL_OPEN_ERR("unable to fstatfs file for the library \"%s\": %s", name, strerror(errno));
+ DL_OPEN_ERR("unable to fstatfs file for the library \"%s\": %m", name);
return false;
}
@@ -3364,13 +3364,13 @@
get_realpath());
add_dlwarning(get_realpath(), "text relocations");
if (phdr_table_unprotect_segments(phdr, phnum, load_bias, should_pad_segments_) < 0) {
- DL_ERR("can't unprotect loadable segments for \"%s\": %s", get_realpath(), strerror(errno));
+ DL_ERR("can't unprotect loadable segments for \"%s\": %m", get_realpath());
return false;
}
}
#endif
- if (!relocate(lookup_list)) {
+ if (this != solist_get_vdso() && !relocate(lookup_list)) {
return false;
}
@@ -3380,8 +3380,7 @@
if (has_text_relocations) {
// All relocations are done, we can protect our segments back to read-only.
if (phdr_table_protect_segments(phdr, phnum, load_bias, should_pad_segments_) < 0) {
- DL_ERR("can't protect segments for \"%s\": %s",
- get_realpath(), strerror(errno));
+ DL_ERR("can't protect segments for \"%s\": %m", get_realpath());
return false;
}
}
@@ -3397,15 +3396,13 @@
if (extinfo && (extinfo->flags & ANDROID_DLEXT_WRITE_RELRO)) {
if (phdr_table_serialize_gnu_relro(phdr, phnum, load_bias,
extinfo->relro_fd, relro_fd_offset) < 0) {
- DL_ERR("failed serializing GNU RELRO section for \"%s\": %s",
- get_realpath(), strerror(errno));
+ DL_ERR("failed serializing GNU RELRO section for \"%s\": %m", get_realpath());
return false;
}
} else if (extinfo && (extinfo->flags & ANDROID_DLEXT_USE_RELRO)) {
if (phdr_table_map_gnu_relro(phdr, phnum, load_bias,
extinfo->relro_fd, relro_fd_offset) < 0) {
- DL_ERR("failed mapping GNU RELRO section for \"%s\": %s",
- get_realpath(), strerror(errno));
+ DL_ERR("failed mapping GNU RELRO section for \"%s\": %m", get_realpath());
return false;
}
}
@@ -3418,8 +3415,7 @@
bool soinfo::protect_relro() {
if (phdr_table_protect_gnu_relro(phdr, phnum, load_bias, should_pad_segments_) < 0) {
- DL_ERR("can't enable GNU RELRO protection for \"%s\": %s",
- get_realpath(), strerror(errno));
+ DL_ERR("can't enable GNU RELRO protection for \"%s\": %m", get_realpath());
return false;
}
return true;
@@ -3595,7 +3591,7 @@
// 2. Initialize other namespaces
for (auto& ns_config : namespace_configs) {
- if (namespaces.find(ns_config->name()) != namespaces.end()) {
+ if (namespaces.contains(ns_config->name())) {
continue;
}
diff --git a/linker/linker_config.cpp b/linker/linker_config.cpp
index ad40c50..73ae2ef 100644
--- a/linker/linker_config.cpp
+++ b/linker/linker_config.cpp
@@ -46,9 +46,6 @@
#include <string>
#include <unordered_map>
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
-#include <sys/_system_properties.h>
-
class ConfigParser {
public:
enum {
@@ -254,11 +251,10 @@
// the failure with INFO rather than DL_WARN. e.g. A binary in
// /data/local/tmp may attempt to stat /postinstall. See
// http://b/120996057.
- INFO("%s:%zd: warning: path \"%s\" couldn't be resolved: %s",
+ INFO("%s:%zd: warning: path \"%s\" couldn't be resolved: %m",
ld_config_file_path,
cp.lineno(),
- value.c_str(),
- strerror(errno));
+ value.c_str());
resolved_path = value;
}
@@ -304,7 +300,7 @@
}
if (result == ConfigParser::kPropertyAssign) {
- if (properties->find(name) != properties->end()) {
+ if (properties->contains(name)) {
DL_WARN("%s:%zd: warning: redefining property \"%s\" (overriding previous value)",
ld_config_file_path,
cp.lineno(),
@@ -313,7 +309,7 @@
(*properties)[name] = PropertyValue(std::move(value), cp.lineno());
} else if (result == ConfigParser::kPropertyAppend) {
- if (properties->find(name) == properties->end()) {
+ if (!properties->contains(name)) {
DL_WARN("%s:%zd: warning: appending to undefined property \"%s\" (treating as assignment)",
ld_config_file_path,
cp.lineno(),
@@ -526,7 +522,7 @@
properties.get_strings(property_name_prefix + ".links", &lineno);
for (const auto& linked_ns_name : linked_namespaces) {
- if (namespace_configs.find(linked_ns_name) == namespace_configs.end()) {
+ if (!namespace_configs.contains(linked_ns_name)) {
*error_msg = create_error_msg(ld_config_file_path,
lineno,
std::string("undefined namespace: ") + linked_ns_name);
diff --git a/linker/linker_crt_pad_segment_test.cpp b/linker/linker_crt_pad_segment_test.cpp
index 5a219f8..c11df50 100644
--- a/linker/linker_crt_pad_segment_test.cpp
+++ b/linker/linker_crt_pad_segment_test.cpp
@@ -72,13 +72,22 @@
}; // anonymous namespace
TEST(crt_pad_segment, note_absent) {
+ if (!page_size_migration_supported()) {
+ GTEST_SKIP() << "Kernel does not support page size migration";
+ }
ASSERT_FALSE(GetPadSegment("no_crt_pad_segment.so"));
}
TEST(crt_pad_segment, note_present_and_enabled) {
+ if (!page_size_migration_supported()) {
+ GTEST_SKIP() << "Kernel does not support page size migration";
+ }
ASSERT_TRUE(GetPadSegment("crt_pad_segment_enabled.so"));
}
TEST(crt_pad_segment, note_present_and_disabled) {
+ if (!page_size_migration_supported()) {
+ GTEST_SKIP() << "Kernel does not support page size migration";
+ }
ASSERT_FALSE(GetPadSegment("crt_pad_segment_disabled.so"));
}
diff --git a/linker/linker_debug.cpp b/linker/linker_debug.cpp
index b0aae79..e6211f7 100644
--- a/linker/linker_debug.cpp
+++ b/linker/linker_debug.cpp
@@ -30,13 +30,14 @@
#include <unistd.h>
-void linker_log_va_list(int prio __unused, const char* fmt, va_list ap) {
-#if LINKER_DEBUG_TO_LOG
- async_safe_format_log_va_list(5 - prio, "linker", fmt, ap);
-#else
- async_safe_format_fd_va_list(STDOUT_FILENO, fmt, ap);
- write(STDOUT_FILENO, "\n", 1);
-#endif
+void linker_log_va_list(int prio, const char* fmt, va_list ap) {
+ va_list ap2;
+ va_copy(ap2, ap);
+ async_safe_format_log_va_list(5 - prio, "linker", fmt, ap2);
+ va_end(ap2);
+
+ async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
+ write(STDERR_FILENO, "\n", 1);
}
void linker_log(int prio, const char* fmt, ...) {
diff --git a/linker/linker_debug.h b/linker/linker_debug.h
index 477b009..3aab185 100644
--- a/linker/linker_debug.h
+++ b/linker/linker_debug.h
@@ -33,11 +33,6 @@
// INFO, TRACE, and DEBUG calls in the source). This will only
// affect new processes being launched.
-// By default, traces are sent to logcat, with the "linker" tag. You can
-// change this to go to stdout instead by setting the definition of
-// LINKER_DEBUG_TO_LOG to 0.
-#define LINKER_DEBUG_TO_LOG 1
-
#define TRACE_DEBUG 1
#define DO_TRACE_LOOKUP 1
#define DO_TRACE_RELO 1
diff --git a/linker/linker_main.cpp b/linker/linker_main.cpp
index 77769f5..86b6509 100644
--- a/linker/linker_main.cpp
+++ b/linker/linker_main.cpp
@@ -29,7 +29,9 @@
#include "linker_main.h"
#include <link.h>
+#include <stdlib.h>
#include <sys/auxv.h>
+#include <sys/prctl.h>
#include "linker.h"
#include "linker_auxv.h"
@@ -71,6 +73,25 @@
void __libc_init_mte(const memtag_dynamic_entries_t* memtag_dynamic_entries, const void* phdr_start,
size_t phdr_count, uintptr_t load_bias, void* stack_top);
+__printflike(1, 2) static void __linker_error(const char* fmt, ...) {
+ va_list ap;
+
+ va_start(ap, fmt);
+ async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
+ write(STDERR_FILENO, "\n", 1);
+ va_end(ap);
+
+ va_start(ap, fmt);
+ async_safe_format_log_va_list(ANDROID_LOG_FATAL, "linker", fmt, ap);
+ va_end(ap);
+
+ _exit(EXIT_FAILURE);
+}
+
+static void __linker_cannot_link(const char* argv0) {
+ __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s", argv0, linker_get_error_buffer());
+}
+
// These should be preserved static to avoid emitting
// RELATIVE relocations for the part of the code running
// before linker links itself.
@@ -165,22 +186,21 @@
return;
}
- soinfo* si = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
+ vdso = soinfo_alloc(&g_default_namespace, "[vdso]", nullptr, 0, 0);
- si->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
- si->phnum = ehdr_vdso->e_phnum;
- si->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
- si->size = phdr_table_get_load_size(si->phdr, si->phnum);
- si->load_bias = get_elf_exec_load_bias(ehdr_vdso);
+ vdso->phdr = reinterpret_cast<ElfW(Phdr)*>(reinterpret_cast<char*>(ehdr_vdso) + ehdr_vdso->e_phoff);
+ vdso->phnum = ehdr_vdso->e_phnum;
+ vdso->base = reinterpret_cast<ElfW(Addr)>(ehdr_vdso);
+ vdso->size = phdr_table_get_load_size(vdso->phdr, vdso->phnum);
+ vdso->load_bias = get_elf_exec_load_bias(ehdr_vdso);
- si->prelink_image();
- si->link_image(SymbolLookupList(si), si, nullptr, nullptr);
- // prevents accidental unloads...
- si->set_dt_flags_1(si->get_dt_flags_1() | DF_1_NODELETE);
- si->set_linked();
- si->call_constructors();
+ if (!vdso->prelink_image() || !vdso->link_image(SymbolLookupList(vdso), vdso, nullptr, nullptr)) {
+ __linker_cannot_link(g_argv[0]);
+ }
- vdso = si;
+ // Prevent accidental unloads...
+ vdso->set_dt_flags_1(vdso->get_dt_flags_1() | DF_1_NODELETE);
+ vdso->set_linked();
}
// Initializes an soinfo's link_map_head field using other fields from the
@@ -214,20 +234,15 @@
if (TEMP_FAILURE_RETRY(stat(exe_path, &result.file_stat) == -1)) {
// Fallback to argv[0] for the case where /proc isn't available
if (TEMP_FAILURE_RETRY(stat(arg_path, &result.file_stat) == -1)) {
- async_safe_fatal("unable to stat either \"/proc/self/exe\" or \"%s\": %s",
- arg_path, strerror(errno));
+ async_safe_fatal("unable to stat either \"/proc/self/exe\" or \"%s\": %m", arg_path);
}
exe_path = arg_path;
}
- // Path might be a symlink
+ // Path might be a symlink; we need the target so that we get the right
+ // linker configuration later.
char sym_path[PATH_MAX];
- ssize_t sym_path_len = readlink(exe_path, sym_path, sizeof(sym_path));
- if (sym_path_len > 0 && sym_path_len < static_cast<ssize_t>(sizeof(sym_path))) {
- result.path = std::string(sym_path, sym_path_len);
- } else {
- result.path = std::string(exe_path, strlen(exe_path));
- }
+ result.path = std::string(realpath(exe_path, sym_path) != nullptr ? sym_path : exe_path);
result.phdr = reinterpret_cast<const ElfW(Phdr)*>(getauxval(AT_PHDR));
result.phdr_count = getauxval(AT_PHNUM);
@@ -235,33 +250,6 @@
return result;
}
-#if defined(__LP64__)
-static char kFallbackLinkerPath[] = "/system/bin/linker64";
-#else
-static char kFallbackLinkerPath[] = "/system/bin/linker";
-#endif
-
-__printflike(1, 2)
-static void __linker_error(const char* fmt, ...) {
- va_list ap;
-
- va_start(ap, fmt);
- async_safe_format_fd_va_list(STDERR_FILENO, fmt, ap);
- va_end(ap);
-
- va_start(ap, fmt);
- async_safe_format_log_va_list(ANDROID_LOG_FATAL, "linker", fmt, ap);
- va_end(ap);
-
- _exit(EXIT_FAILURE);
-}
-
-static void __linker_cannot_link(const char* argv0) {
- __linker_error("CANNOT LINK EXECUTABLE \"%s\": %s\n",
- argv0,
- linker_get_error_buffer());
-}
-
// Load an executable. Normally the kernel has already loaded the executable when the linker
// starts. The linker can be invoked directly on an executable, though, and then the linker must
// load it. This function doesn't load dependencies or resolve relocations.
@@ -269,26 +257,26 @@
ExecutableInfo result = {};
if (orig_path[0] != '/') {
- __linker_error("error: expected absolute path: \"%s\"\n", orig_path);
+ __linker_error("error: expected absolute path: \"%s\"", orig_path);
}
off64_t file_offset;
android::base::unique_fd fd(open_executable(orig_path, &file_offset, &result.path));
if (fd.get() == -1) {
- __linker_error("error: unable to open file \"%s\"\n", orig_path);
+ __linker_error("error: unable to open file \"%s\"", orig_path);
}
if (TEMP_FAILURE_RETRY(fstat(fd.get(), &result.file_stat)) == -1) {
- __linker_error("error: unable to stat \"%s\": %s\n", result.path.c_str(), strerror(errno));
+ __linker_error("error: unable to stat \"%s\": %m", result.path.c_str());
}
ElfReader elf_reader;
if (!elf_reader.Read(result.path.c_str(), fd.get(), file_offset, result.file_stat.st_size)) {
- __linker_error("error: %s\n", linker_get_error_buffer());
+ __linker_error("error: %s", linker_get_error_buffer());
}
address_space_params address_space;
if (!elf_reader.Load(&address_space)) {
- __linker_error("error: %s\n", linker_get_error_buffer());
+ __linker_error("error: %s", linker_get_error_buffer());
}
result.phdr = elf_reader.loaded_phdr();
@@ -335,11 +323,7 @@
if (getenv("LD_SHOW_AUXV") != nullptr) ld_show_auxv(args.auxv);
-#if defined(__LP64__)
- INFO("[ Android dynamic linker (64-bit) ]");
-#else
- INFO("[ Android dynamic linker (32-bit) ]");
-#endif
+ INFO("[ Android dynamic linker (" ABI_STRING ") ]");
// These should have been sanitized by __libc_init_AT_SECURE, but the test
// doesn't cost us anything.
@@ -390,7 +374,12 @@
if (interp == nullptr) {
// This case can happen if the linker attempts to execute itself
// (e.g. "linker64 /system/bin/linker64").
- interp = kFallbackLinkerPath;
+#if defined(__LP64__)
+#define DEFAULT_INTERP "/system/bin/linker64"
+#else
+#define DEFAULT_INTERP "/system/bin/linker"
+#endif
+ interp = DEFAULT_INTERP;
}
solinker->set_realpath(interp);
init_link_map_head(*solinker);
@@ -403,8 +392,7 @@
if (note_gnu_property.IsBTICompatible() &&
(phdr_table_protect_segments(somain->phdr, somain->phnum, somain->load_bias,
somain->should_pad_segments(), ¬e_gnu_property) < 0)) {
- __linker_error("error: can't protect segments for \"%s\": %s", exe_info.path.c_str(),
- strerror(errno));
+ __linker_error("error: can't protect segments for \"%s\": %m", exe_info.path.c_str());
}
}
#endif
@@ -425,20 +413,11 @@
ElfW(Ehdr)* elf_hdr = reinterpret_cast<ElfW(Ehdr)*>(si->base);
- // We haven't supported non-PIE since Lollipop for security reasons.
+ // For security reasons we dropped non-PIE support in API level 21,
+ // and the NDK no longer supports earlier API levels.
if (elf_hdr->e_type != ET_DYN) {
- // We don't use async_safe_fatal here because we don't want a tombstone:
- // even after several years we still find ourselves on app compatibility
- // investigations because some app's trying to launch an executable that
- // hasn't worked in at least three years, and we've "helpfully" dropped a
- // tombstone for them. The tombstone never provided any detail relevant to
- // fixing the problem anyway, and the utility of drawing extra attention
- // to the problem is non-existent at this late date.
- async_safe_format_fd(STDERR_FILENO,
- "\"%s\": error: Android 5.0 and later only support "
- "position-independent executables (-fPIE).\n",
- g_argv[0]);
- _exit(EXIT_FAILURE);
+ __linker_error("error: %s: Android only supports position-independent "
+ "executables (-fPIE)", exe_info.path.c_str());
}
// Use LD_LIBRARY_PATH and LD_PRELOAD (but only if we aren't setuid/setgid).
@@ -706,7 +685,7 @@
// fallback.
__libc_sysinfo = reinterpret_cast<void*>(__libc_int0x80);
#endif
- __linker_error("error: linker cannot load itself\n");
+ __linker_error("error: linker cannot load itself");
}
static ElfW(Addr) __attribute__((noinline))
diff --git a/linker/linker_namespaces.cpp b/linker/linker_namespaces.cpp
index 5182129..eb9dae9 100644
--- a/linker/linker_namespaces.cpp
+++ b/linker/linker_namespaces.cpp
@@ -100,7 +100,7 @@
// be searched.
if (allow_secondary) {
const android_namespace_list_t& secondary_namespaces = si->get_secondary_namespaces();
- if (secondary_namespaces.find(this) != secondary_namespaces.end()) {
+ if (secondary_namespaces.contains(this)) {
return true;
}
}
diff --git a/linker/linker_note_gnu_property_test.cpp b/linker/linker_note_gnu_property_test.cpp
index 41fc47b..960118c 100644
--- a/linker/linker_note_gnu_property_test.cpp
+++ b/linker/linker_note_gnu_property_test.cpp
@@ -137,18 +137,18 @@
dump_member("entries ", entries);
if (entries > 0) {
std::cout << " raw data:";
- const uintptr_t offset = note->nhdr.n_descsz + 16;
- for (uintptr_t offs = 16; offs < offset; ++offs) {
+ const uintptr_t end = note->nhdr.n_descsz + 16;
+ for (uintptr_t offset = 16; offset < end; ++offset) {
std::cout << std::hex;
- if ((offs % 8) == 0) {
+ if ((offset % 8) == 0) {
std::cout << "\n ";
}
- auto value = static_cast<unsigned>(section[offs]);
+ auto value = static_cast<unsigned>(section[offset]);
std::cout << " ";
if (value < 0x10) {
std::cout << "0";
}
- std::cout << static_cast<unsigned>(section[offs]);
+ std::cout << static_cast<unsigned>(section[offset]);
}
std::cout << std::dec << "\n";
}
diff --git a/linker/linker_phdr.cpp b/linker/linker_phdr.cpp
index ef7671c..e89acb5 100644
--- a/linker/linker_phdr.cpp
+++ b/linker/linker_phdr.cpp
@@ -46,6 +46,8 @@
#include "private/CFIShadow.h" // For kLibraryAlignment
#include "private/elf_note.h"
+#include <android-base/file.h>
+
static int GetTargetElfMachine() {
#if defined(__arm__)
return EM_ARM;
@@ -296,7 +298,6 @@
}
if (header_.e_shentsize != sizeof(ElfW(Shdr))) {
- // Fail if app is targeting Android O or above
if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" has unsupported e_shentsize: 0x%x (expected 0x%zx)",
name_.c_str(), header_.e_shentsize, sizeof(ElfW(Shdr)));
@@ -310,12 +311,10 @@
}
if (header_.e_shstrndx == 0) {
- // Fail if app is targeting Android O or above
if (get_application_target_sdk_version() >= 26) {
DL_ERR_AND_LOG("\"%s\" has invalid e_shstrndx", name_.c_str());
return false;
}
-
DL_WARN_documented_change(26,
"invalid-elf-header_section-headers-enforced-for-api-level-26",
"\"%s\" has invalid e_shstrndx", name_.c_str());
@@ -364,7 +363,7 @@
}
if (!phdr_fragment_.Map(fd_, file_offset_, header_.e_phoff, size)) {
- DL_ERR("\"%s\" phdr mmap failed: %s", name_.c_str(), strerror(errno));
+ DL_ERR("\"%s\" phdr mmap failed: %m", name_.c_str());
return false;
}
@@ -390,7 +389,7 @@
}
if (!shdr_fragment_.Map(fd_, file_offset_, header_.e_shoff, size)) {
- DL_ERR("\"%s\" shdr mmap failed: %s", name_.c_str(), strerror(errno));
+ DL_ERR("\"%s\" shdr mmap failed: %m", name_.c_str());
return false;
}
@@ -483,7 +482,7 @@
}
if (!dynamic_fragment_.Map(fd_, file_offset_, dynamic_shdr->sh_offset, dynamic_shdr->sh_size)) {
- DL_ERR("\"%s\" dynamic section mmap failed: %s", name_.c_str(), strerror(errno));
+ DL_ERR("\"%s\" dynamic section mmap failed: %m", name_.c_str());
return false;
}
@@ -496,7 +495,7 @@
}
if (!strtab_fragment_.Map(fd_, file_offset_, strtab_shdr->sh_offset, strtab_shdr->sh_size)) {
- DL_ERR("\"%s\" strtab section mmap failed: %s", name_.c_str(), strerror(errno));
+ DL_ERR("\"%s\" strtab section mmap failed: %m", name_.c_str());
return false;
}
@@ -568,9 +567,7 @@
continue;
}
- if (phdr->p_align > maximum_alignment) {
- maximum_alignment = phdr->p_align;
- }
+ maximum_alignment = std::max(maximum_alignment, static_cast<size_t>(phdr->p_align));
}
#if defined(__LP64__)
@@ -580,6 +577,30 @@
#endif
}
+// Returns the minimum p_align associated with a loadable segment in the ELF
+// program header table. Used to determine if the program alignment is compatible
+// with the page size of this system.
+size_t phdr_table_get_minimum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count) {
+ size_t minimum_alignment = page_size();
+
+ for (size_t i = 0; i < phdr_count; ++i) {
+ const ElfW(Phdr)* phdr = &phdr_table[i];
+
+ // p_align must be 0, 1, or a positive, integral power of two.
+ if (phdr->p_type != PT_LOAD || ((phdr->p_align & (phdr->p_align - 1)) != 0)) {
+ continue;
+ }
+
+ if (phdr->p_align <= 1) {
+ continue;
+ }
+
+ minimum_alignment = std::min(minimum_alignment, static_cast<size_t>(phdr->p_align));
+ }
+
+ return minimum_alignment;
+}
+
// Reserve a virtual address range such that if it's limits were extended to the next 2**align
// boundary, it would not overlap with any existing mappings.
static void* ReserveWithAlignmentPadding(size_t size, size_t mapping_align, size_t start_align,
@@ -707,8 +728,28 @@
return true;
}
+/*
+ * Returns true if the kernel supports page size migration, else false.
+ */
+bool page_size_migration_supported() {
+ static bool pgsize_migration_enabled = []() {
+ std::string enabled;
+ if (!android::base::ReadFileToString("/sys/kernel/mm/pgsize_migration/enabled", &enabled)) {
+ return false;
+ }
+ return enabled.find("1") != std::string::npos;
+ }();
+ return pgsize_migration_enabled;
+}
+
// Find the ELF note of type NT_ANDROID_TYPE_PAD_SEGMENT and check that the desc value is 1.
bool ElfReader::ReadPadSegmentNote() {
+ if (!page_size_migration_supported()) {
+ // Don't attempt to read the note, since segment extension isn't
+ // supported; but return true so that loading can continue normally.
+ return true;
+ }
+
// The ELF can have multiple PT_NOTE's, check them all
for (size_t i = 0; i < phdr_num_; ++i) {
const ElfW(Phdr)* phdr = &phdr_table_[i];
@@ -773,7 +814,16 @@
const ElfW(Phdr)* next = nullptr;
size_t next_idx = phdr_idx + 1;
- if (phdr->p_align == kPageSize || !should_pad_segments) {
+ // Don't do segment extension for p_align > 64KiB, such ELFs already existed in the
+ // field e.g. 2MiB p_align for THPs and are relatively small in number.
+ //
+ // The kernel can only represent padding for p_align up to 64KiB. This is because
+ // the kernel uses 4 available bits in the vm_area_struct to represent padding
+ // extent; and so cannot enable mitigations to avoid breaking app compatibility for
+ // p_aligns > 64KiB.
+ //
+ // Don't perform segment extension on these to avoid app compatibility issues.
+ if (phdr->p_align <= kPageSize || phdr->p_align > 64*1024 || !should_pad_segments) {
return;
}
@@ -802,6 +852,15 @@
}
bool ElfReader::LoadSegments() {
+ size_t min_palign = phdr_table_get_minimum_alignment(phdr_table_, phdr_num_);
+ // Only enforce this on 16 KB systems. Apps may rely on undefined behavior
+ // here on 4 KB systems, which is the norm before this change is introduced.
+ if (kPageSize >= 16384 && min_palign < kPageSize) {
+ DL_ERR("\"%s\" program alignment (%zu) cannot be smaller than system page size (%zu)",
+ name_.c_str(), min_palign, kPageSize);
+ return false;
+ }
+
for (size_t i = 0; i < phdr_num_; ++i) {
const ElfW(Phdr)* phdr = &phdr_table_[i];
@@ -865,7 +924,7 @@
fd_,
file_offset_ + file_page_start);
if (seg_addr == MAP_FAILED) {
- DL_ERR("couldn't map \"%s\" segment %zd: %s", name_.c_str(), i, strerror(errno));
+ DL_ERR("couldn't map \"%s\" segment %zd: %m", name_.c_str(), i);
return false;
}
@@ -887,10 +946,28 @@
// 2) Break the COW backing, faulting in new anon pages for a region
// that will not be used.
- // _seg_file_end = unextended seg_file_end
- uint64_t _seg_file_end = seg_start + phdr->p_filesz;
- if ((phdr->p_flags & PF_W) != 0 && page_offset(_seg_file_end) > 0) {
- memset(reinterpret_cast<void*>(_seg_file_end), 0, kPageSize - page_offset(_seg_file_end));
+ uint64_t unextended_seg_file_end = seg_start + phdr->p_filesz;
+ if ((phdr->p_flags & PF_W) != 0 && page_offset(unextended_seg_file_end) > 0) {
+ memset(reinterpret_cast<void*>(unextended_seg_file_end), 0,
+ kPageSize - page_offset(unextended_seg_file_end));
+ }
+
+ // Pages may be brought in due to readahead.
+ // Drop the padding (zero) pages, to avoid reclaim work later.
+ //
+ // NOTE: The madvise() here is special, as it also serves to hint to the
+ // kernel the portion of the LOAD segment that is padding.
+ //
+ // See: [1] https://android-review.googlesource.com/c/kernel/common/+/3032411
+ // [2] https://android-review.googlesource.com/c/kernel/common/+/3048835
+ uint64_t pad_start = page_end(unextended_seg_file_end);
+ uint64_t pad_end = page_end(seg_file_end);
+ CHECK(pad_start <= pad_end);
+ uint64_t pad_len = pad_end - pad_start;
+ if (page_size_migration_supported() && pad_len > 0 &&
+ madvise(reinterpret_cast<void*>(pad_start), pad_len, MADV_DONTNEED)) {
+ DL_WARN("\"%s\": madvise(0x%" PRIx64 ", 0x%" PRIx64 ", MADV_DONTNEED) failed: %m",
+ name_.c_str(), pad_start, pad_len);
}
seg_file_end = page_end(seg_file_end);
@@ -908,7 +985,7 @@
-1,
0);
if (zeromap == MAP_FAILED) {
- DL_ERR("couldn't zero fill \"%s\" gap: %s", name_.c_str(), strerror(errno));
+ DL_ERR("couldn't zero fill \"%s\" gap: %m", name_.c_str());
return false;
}
diff --git a/linker/linker_phdr.h b/linker/linker_phdr.h
index 61242eb..e865a03 100644
--- a/linker/linker_phdr.h
+++ b/linker/linker_phdr.h
@@ -126,6 +126,7 @@
ElfW(Addr)* min_vaddr = nullptr, ElfW(Addr)* max_vaddr = nullptr);
size_t phdr_table_get_maximum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count);
+size_t phdr_table_get_minimum_alignment(const ElfW(Phdr)* phdr_table, size_t phdr_count);
int phdr_table_protect_segments(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias, bool should_pad_segments,
@@ -154,3 +155,5 @@
const char* phdr_table_get_interpreter_name(const ElfW(Phdr)* phdr_table, size_t phdr_count,
ElfW(Addr) load_bias);
+
+bool page_size_migration_supported();
diff --git a/linker/linker_relocate.cpp b/linker/linker_relocate.cpp
index 85f7b3a..8f85871 100644
--- a/linker/linker_relocate.cpp
+++ b/linker/linker_relocate.cpp
@@ -189,8 +189,7 @@
if (phdr_table_protect_segments(relocator.si->phdr, relocator.si->phnum,
relocator.si->load_bias,
relocator.si->should_pad_segments()) < 0) {
- DL_ERR("can't protect segments for \"%s\": %s",
- relocator.si->get_realpath(), strerror(errno));
+ DL_ERR("can't protect segments for \"%s\": %m", relocator.si->get_realpath());
return false;
}
return true;
@@ -200,8 +199,8 @@
if (phdr_table_unprotect_segments(relocator.si->phdr, relocator.si->phnum,
relocator.si->load_bias,
relocator.si->should_pad_segments()) < 0) {
- DL_ERR("can't unprotect loadable segments for \"%s\": %s",
- relocator.si->get_realpath(), strerror(errno));
+ DL_ERR("can't unprotect loadable segments for \"%s\": %m",
+ relocator.si->get_realpath());
return false;
}
return true;
@@ -438,9 +437,9 @@
}
break;
-#if defined(__aarch64__)
- // Bionic currently only implements TLSDESC for arm64. This implementation should work with
- // other architectures, as long as the resolver functions are implemented.
+#if defined(__aarch64__) || defined(__riscv)
+ // Bionic currently implements TLSDESC for arm64 and riscv64. This implementation should work
+ // with other architectures, as long as the resolver functions are implemented.
case R_GENERIC_TLSDESC:
count_relocation_if<IsGeneral>(kRelocRelative);
{
@@ -482,7 +481,7 @@
}
}
break;
-#endif // defined(__aarch64__)
+#endif // defined(__aarch64__) || defined(__riscv)
#if defined(__x86_64__)
case R_X86_64_32:
@@ -627,7 +626,7 @@
android_relocs_[1] == 'P' &&
android_relocs_[2] == 'S' &&
android_relocs_[3] == '2') {
- DEBUG("[ android relocating %s ]", get_realpath());
+ DEBUG("[ relocating %s android rel/rela ]", get_realpath());
const uint8_t* packed_relocs = android_relocs_ + 4;
const size_t packed_relocs_size = android_relocs_size_ - 4;
@@ -672,14 +671,14 @@
// Once the tlsdesc_args_ vector's size is finalized, we can write the addresses of its elements
// into the TLSDESC relocations.
-#if defined(__aarch64__)
- // Bionic currently only implements TLSDESC for arm64.
+#if defined(__aarch64__) || defined(__riscv)
+ // Bionic currently only implements TLSDESC for arm64 and riscv64.
for (const std::pair<TlsDescriptor*, size_t>& pair : relocator.deferred_tlsdesc_relocs) {
TlsDescriptor* desc = pair.first;
desc->func = tlsdesc_resolver_dynamic;
desc->arg = reinterpret_cast<size_t>(&tlsdesc_args_[pair.second]);
}
-#endif
+#endif // defined(__aarch64__) || defined(__riscv)
return true;
}
diff --git a/linker/linker_soinfo.cpp b/linker/linker_soinfo.cpp
index 802c06a..b2170d8 100644
--- a/linker/linker_soinfo.cpp
+++ b/linker/linker_soinfo.cpp
@@ -159,11 +159,6 @@
break;
}
}
-
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(lib->si_->base));
- }
}
// Search the library's hash table chain.
@@ -186,21 +181,11 @@
memcmp(lib->strtab_ + sym->st_name, name, name_len + 1) == 0 &&
is_symbol_global_and_defined(lib->si_, sym)) {
*si_found_in = lib->si_;
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(sym->st_value),
- static_cast<size_t>(sym->st_size));
- }
return sym;
}
}
++sym_idx;
} while ((chain_value & 1) == 0);
-
- if (IsGeneral) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- name, lib->si_->get_realpath(), reinterpret_cast<void*>(lib->si_->base));
- }
}
}
@@ -338,9 +323,6 @@
// test against bloom filter
if ((1 & (bloom_word >> h1) & (bloom_word >> h2)) == 0) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -348,9 +330,6 @@
uint32_t n = gnu_bucket_[hash % gnu_nbucket_];
if (n == 0) {
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -363,16 +342,10 @@
check_symbol_version(versym, n, verneed) &&
strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
is_symbol_global_and_defined(this, s)) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(s->st_value),
- static_cast<size_t>(s->st_size));
return symtab_ + n;
}
} while ((gnu_chain_[n++] & 1) == 0);
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p",
- symbol_name.get_name(), get_realpath(), reinterpret_cast<void*>(base));
-
return nullptr;
}
@@ -392,18 +365,10 @@
if (check_symbol_version(versym, n, verneed) &&
strcmp(get_string(s->st_name), symbol_name.get_name()) == 0 &&
is_symbol_global_and_defined(this, s)) {
- TRACE_TYPE(LOOKUP, "FOUND %s in %s (%p) %zd",
- symbol_name.get_name(), get_realpath(),
- reinterpret_cast<void*>(s->st_value),
- static_cast<size_t>(s->st_size));
return symtab_ + n;
}
}
- TRACE_TYPE(LOOKUP, "NOT FOUND %s in %s@%p %x %zd",
- symbol_name.get_name(), get_realpath(),
- reinterpret_cast<void*>(base), hash, hash % nbucket_);
-
return nullptr;
}
@@ -887,7 +852,7 @@
handle_ = handle_ | 1;
} while (handle_ == reinterpret_cast<uintptr_t>(RTLD_DEFAULT) ||
handle_ == reinterpret_cast<uintptr_t>(RTLD_NEXT) ||
- g_soinfo_handles_map.find(handle_) != g_soinfo_handles_map.end());
+ g_soinfo_handles_map.contains(handle_));
g_soinfo_handles_map[handle_] = this;
}
diff --git a/linker/linker_utils.cpp b/linker/linker_utils.cpp
index cd03eed..9abe542 100644
--- a/linker/linker_utils.cpp
+++ b/linker/linker_utils.cpp
@@ -207,7 +207,7 @@
if (realpath(original_path, resolved_path) != nullptr) {
struct stat s;
if (stat(resolved_path, &s) == -1) {
- DL_WARN("Warning: cannot stat file \"%s\": %s (ignoring)", resolved_path, strerror(errno));
+ DL_WARN("Warning: cannot stat file \"%s\": %m (ignoring)", resolved_path);
return "";
}
if (!S_ISDIR(s.st_mode)) {
@@ -226,8 +226,7 @@
std::string entry_path;
if (parse_zip_path(normalized_path.c_str(), &zip_path, &entry_path)) {
if (realpath(zip_path.c_str(), resolved_path) == nullptr) {
- DL_WARN("Warning: unable to resolve \"%s\": %s (ignoring)",
- zip_path.c_str(), strerror(errno));
+ DL_WARN("Warning: unable to resolve \"%s\": %m (ignoring)", zip_path.c_str());
return "";
}
diff --git a/tests/Android.bp b/tests/Android.bp
index 528ccb8..deb2843 100644
--- a/tests/Android.bp
+++ b/tests/Android.bp
@@ -361,15 +361,17 @@
cc_test_library {
name: "clang_diagnostic_tests",
cflags: [
- "-Xclang",
- "-verify",
+ "-Xclang -verify",
],
srcs: ["sys_ioctl_diag_test.cpp"],
}
cc_test_library {
name: "libBionicStandardTests",
- defaults: ["bionic_tests_defaults"],
+ defaults: [
+ "bionic_tests_defaults",
+ "large_system_property_node_defaults",
+ ],
tidy_disabled_srcs: [
"malloc_test.cpp", // timed out with clang-tidy, and too many warnings
],
@@ -401,6 +403,7 @@
"_FILE_OFFSET_BITS_test.cpp",
"float_test.cpp",
"fnmatch_test.cpp",
+ "fts_test.cpp",
"ftw_test.cpp",
"getauxval_test.cpp",
"getcwd_test.cpp",
@@ -430,6 +433,7 @@
"netdb_test.cpp",
"net_if_test.cpp",
"netinet_ether_test.cpp",
+ "netinet_igmp_test.cpp",
"netinet_in_test.cpp",
"netinet_ip_icmp_test.cpp",
"netinet_udp_test.cpp",
@@ -474,6 +478,7 @@
"sys_cachectl_test.cpp",
"sys_epoll_test.cpp",
"sys_hwprobe_test.cpp",
+ "sys_io_test.cpp",
"sys_mman_test.cpp",
"sys_msg_test.cpp",
"sys_param_test.cpp",
@@ -561,12 +566,6 @@
},
generated_headers: ["generated_android_ids"],
-
- // Bug: http://b/218788252 IR verifier too strict for ifunc resolver that
- // accept parameters.
- lto: {
- never: true,
- },
}
cc_test_library {
@@ -714,11 +713,6 @@
],
srcs: ["clang_fortify_tests.cpp"],
tidy: false,
- target: {
- host: {
- cflags: ["-D__clang__"],
- },
- },
}
cc_test_library {
@@ -1136,11 +1130,14 @@
shared_libs: [
"libbase",
],
- data_libs: ["libtest_simple_memtag_stack", "libtest_depends_on_simple_memtag_stack"],
+ data_libs: [
+ "libtest_simple_memtag_stack",
+ "libtest_depends_on_simple_memtag_stack",
+ ],
data_bins: [
"testbinary_depends_on_simple_memtag_stack",
"testbinary_depends_on_depends_on_simple_memtag_stack",
- "testbinary_is_stack_mte_after_dlopen"
+ "testbinary_is_stack_mte_after_dlopen",
],
header_libs: ["bionic_libc_platform_headers"],
test_suites: ["device-tests"],
@@ -1315,4 +1312,47 @@
},
}
-subdirs = ["*"]
+cc_defaults {
+ name: "bionic_compile_time_tests_defaults",
+ enabled: false,
+ target: {
+ linux_x86: {
+ enabled: true,
+ },
+ linux_x86_64: {
+ enabled: true,
+ },
+ },
+ tidy: false,
+ clang_verify: true,
+ cflags: [
+ "-Wall",
+ "-Wno-error",
+ "-fno-color-diagnostics",
+ "-ferror-limit=10000",
+ "-DCOMPILATION_TESTS=1",
+ "-Wformat-nonliteral",
+ "-U_FORTIFY_SOURCE",
+ ],
+ srcs: ["clang_fortify_tests.cpp"],
+}
+
+cc_library_static {
+ name: "bionic-compile-time-tests1-clang++",
+ defaults: [
+ "bionic_compile_time_tests_defaults",
+ ],
+ cppflags: [
+ "-D_FORTIFY_SOURCE=1",
+ ],
+}
+
+cc_library_static {
+ name: "bionic-compile-time-tests2-clang++",
+ defaults: [
+ "bionic_compile_time_tests_defaults",
+ ],
+ cppflags: [
+ "-D_FORTIFY_SOURCE=2",
+ ],
+}
diff --git a/tests/Android.mk b/tests/Android.mk
deleted file mode 100644
index 5ad4045..0000000
--- a/tests/Android.mk
+++ /dev/null
@@ -1,33 +0,0 @@
-#
-# Copyright (C) 2012 The Android Open Source Project
-#
-# Licensed under the Apache License, Version 2.0 (the "License");
-# you may not use this file except in compliance with the License.
-# You may obtain a copy of the License at
-#
-# http://www.apache.org/licenses/LICENSE-2.0
-#
-# Unless required by applicable law or agreed to in writing, software
-# distributed under the License is distributed on an "AS IS" BASIS,
-# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
-# See the License for the specific language governing permissions and
-# limitations under the License.
-#
-
-LOCAL_PATH := $(call my-dir)
-
-ifeq ($(HOST_OS)-$(HOST_ARCH),$(filter $(HOST_OS)-$(HOST_ARCH),linux-x86 linux-x86_64))
-
-# -----------------------------------------------------------------------------
-# Compile time tests.
-# -----------------------------------------------------------------------------
-
-FORTIFY_LEVEL := 1
-include $(LOCAL_PATH)/make_fortify_compile_test.mk
-
-FORTIFY_LEVEL := 2
-include $(LOCAL_PATH)/make_fortify_compile_test.mk
-
-endif # linux-x86
-
-include $(call first-makefiles-under,$(LOCAL_PATH))
diff --git a/tests/clang_fortify_tests.cpp b/tests/clang_fortify_tests.cpp
index 544af43..f08fd1f 100644
--- a/tests/clang_fortify_tests.cpp
+++ b/tests/clang_fortify_tests.cpp
@@ -14,10 +14,6 @@
* limitations under the License.
*/
-#ifndef __clang__
-#error "Non-clang isn't supported"
-#endif
-
//
// Clang compile-time and run-time tests for Bionic's FORTIFY.
//
@@ -164,9 +160,7 @@
const char large_string[] = "Hello!!!";
static_assert(sizeof(large_string) > sizeof(small_buffer), "");
-#if __clang_major__ > 13
- // expected-error@+3{{will always overflow}}
-#endif
+ // expected-error@+2{{will always overflow}}
// expected-error@+1{{string bigger than buffer}}
EXPECT_FORTIFY_DEATH(strcpy(small_buffer, large_string));
// expected-error@+1{{string bigger than buffer}}
@@ -204,9 +198,7 @@
static_assert(sizeof(small_string) > sizeof(split.tiny_buffer), "");
#if _FORTIFY_SOURCE > 1
-#if __clang_major__ > 13
- // expected-error@+4{{will always overflow}}
-#endif
+ // expected-error@+3{{will always overflow}}
// expected-error@+2{{string bigger than buffer}}
#endif
EXPECT_FORTIFY_DEATH_STRUCT(strcpy(split.tiny_buffer, small_string));
diff --git a/tests/complex_test.cpp b/tests/complex_test.cpp
index 6a1831f..8fdb2b2 100644
--- a/tests/complex_test.cpp
+++ b/tests/complex_test.cpp
@@ -32,7 +32,11 @@
#include <math.h> // For M_PI_2/M_PI_2l.
// Prettify gtest Complex printing.
+// Macro 'complex' defined in complex.h conflicts with iostream.
+#pragma push_macro("complex")
+#undef complex
#include <iostream>
+#pragma pop_macro("complex")
namespace testing {
namespace internal {
inline void PrintTo(const double _Complex& c, std::ostream* os) {
diff --git a/tests/ctype_test.cpp b/tests/ctype_test.cpp
index 826d39a..18fbfc0 100644
--- a/tests/ctype_test.cpp
+++ b/tests/ctype_test.cpp
@@ -293,40 +293,57 @@
}
TEST(ctype, toascii) {
- EXPECT_EQ('a', toascii('a'));
- EXPECT_EQ('a', toascii(0x80 | 'a'));
+ // POSIX explicitly says that toascii() returns (c & 0x7f),
+ // so there's no EOF-preserving behavior here and we start from 0.
+ for (int i = 0; i < kMax; ++i) {
+ if (i <= 0x7f) {
+ EXPECT_EQ(i, toascii(i));
+ } else {
+ EXPECT_EQ(i & 0x7f, toascii(i));
+ }
+ }
}
TEST(ctype, tolower) {
EXPECT_EQ('!', tolower('!'));
EXPECT_EQ('a', tolower('a'));
EXPECT_EQ('a', tolower('A'));
+ EXPECT_EQ('z', tolower('z'));
+ EXPECT_EQ('z', tolower('Z'));
}
TEST(ctype, tolower_l) {
EXPECT_EQ('!', tolower_l('!', LC_GLOBAL_LOCALE));
EXPECT_EQ('a', tolower_l('a', LC_GLOBAL_LOCALE));
EXPECT_EQ('a', tolower_l('A', LC_GLOBAL_LOCALE));
+ EXPECT_EQ('z', tolower_l('z', LC_GLOBAL_LOCALE));
+ EXPECT_EQ('z', tolower_l('Z', LC_GLOBAL_LOCALE));
}
TEST(ctype, _tolower) {
// _tolower may mangle characters for which isupper is false.
EXPECT_EQ('a', _tolower('A'));
+ EXPECT_EQ('z', _tolower('Z'));
}
TEST(ctype, toupper) {
EXPECT_EQ('!', toupper('!'));
EXPECT_EQ('A', toupper('a'));
EXPECT_EQ('A', toupper('A'));
+ EXPECT_EQ('Z', toupper('z'));
+ EXPECT_EQ('Z', toupper('Z'));
}
TEST(ctype, toupper_l) {
EXPECT_EQ('!', toupper_l('!', LC_GLOBAL_LOCALE));
EXPECT_EQ('A', toupper_l('a', LC_GLOBAL_LOCALE));
EXPECT_EQ('A', toupper_l('A', LC_GLOBAL_LOCALE));
+ EXPECT_EQ('Z', toupper_l('z', LC_GLOBAL_LOCALE));
+ EXPECT_EQ('Z', toupper_l('Z', LC_GLOBAL_LOCALE));
}
TEST(ctype, _toupper) {
// _toupper may mangle characters for which islower is false.
EXPECT_EQ('A', _toupper('a'));
+ EXPECT_EQ('Z', _toupper('z'));
}
diff --git a/tests/dirent_test.cpp b/tests/dirent_test.cpp
index 4d21246..cde2d11 100644
--- a/tests/dirent_test.cpp
+++ b/tests/dirent_test.cpp
@@ -33,11 +33,11 @@
static void CheckProcSelf(std::set<std::string>& names) {
// We have a good idea of what should be in /proc/self.
- ASSERT_TRUE(names.find(".") != names.end());
- ASSERT_TRUE(names.find("..") != names.end());
- ASSERT_TRUE(names.find("cmdline") != names.end());
- ASSERT_TRUE(names.find("fd") != names.end());
- ASSERT_TRUE(names.find("stat") != names.end());
+ ASSERT_TRUE(names.contains("."));
+ ASSERT_TRUE(names.contains(".."));
+ ASSERT_TRUE(names.contains("cmdline"));
+ ASSERT_TRUE(names.contains("fd"));
+ ASSERT_TRUE(names.contains("stat"));
}
template <typename DirEntT>
diff --git a/tests/elftls_dl_test.cpp b/tests/elftls_dl_test.cpp
index e759e15..e409b72 100644
--- a/tests/elftls_dl_test.cpp
+++ b/tests/elftls_dl_test.cpp
@@ -107,6 +107,22 @@
void* lib = dlopen("libtest_elftls_dynamic.so", RTLD_LOCAL | RTLD_NOW);
ASSERT_NE(nullptr, lib);
+ auto get_local_var2 = reinterpret_cast<int(*)()>(dlsym(lib, "get_local_var2"));
+ ASSERT_NE(nullptr, get_local_var2);
+
+ auto get_local_var1 = reinterpret_cast<int(*)()>(dlsym(lib, "get_local_var1"));
+ ASSERT_NE(nullptr, get_local_var1);
+
+ auto get_local_var1_addr = reinterpret_cast<int*(*)()>(dlsym(lib, "get_local_var1_addr"));
+ ASSERT_NE(nullptr, get_local_var1_addr);
+
+ // Make sure subsequent accesses return the same pointer.
+ ASSERT_EQ(get_local_var1_addr(), get_local_var1_addr());
+
+ // Check the initial values are correct.
+ ASSERT_EQ(25, get_local_var2());
+ ASSERT_EQ(15, get_local_var1());
+
auto bump_local_vars = reinterpret_cast<int(*)()>(dlsym(lib, "bump_local_vars"));
ASSERT_NE(nullptr, bump_local_vars);
@@ -135,7 +151,7 @@
// TLSDESC, the result is NULL. With __tls_get_addr, the result is the
// generation count (or maybe undefined behavior)? This test only tests TLSDESC.
TEST(elftls_dl, tlsdesc_missing_weak) {
-#if defined(__aarch64__)
+#if defined(__aarch64__) || defined(__riscv)
void* lib = dlopen("libtest_elftls_dynamic.so", RTLD_LOCAL | RTLD_NOW);
ASSERT_NE(nullptr, lib);
diff --git a/tests/float_test.cpp b/tests/float_test.cpp
index 3ef4593..a2b7ecb 100644
--- a/tests/float_test.cpp
+++ b/tests/float_test.cpp
@@ -122,3 +122,7 @@
#error LDBL_HAS_SUBNORM
#endif
}
+
+TEST(float_h, FLT_EVAL_METHOD_exact) {
+ ASSERT_EQ(0, FLT_EVAL_METHOD);
+}
diff --git a/libc/arch-x86_64/static_function_dispatch.S b/tests/fts_test.cpp
similarity index 71%
rename from libc/arch-x86_64/static_function_dispatch.S
rename to tests/fts_test.cpp
index 93ff5f2..39e570b 100644
--- a/libc/arch-x86_64/static_function_dispatch.S
+++ b/tests/fts_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,12 +26,23 @@
* SUCH DAMAGE.
*/
-#include <private/bionic_asm.h>
+#include <gtest/gtest.h>
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- jmp impl; \
-END(name)
+#if !defined(__GLIBC__)
+#include <fts.h>
+#endif
-FUNCTION_DELEGATE(memset, memset_generic)
-FUNCTION_DELEGATE(__memset_chk, __memset_chk_generic)
+TEST(fts, smoke) {
+#if !defined(__GLIBC__)
+ char* const paths[] = { const_cast<char*>("."), NULL };
+ FTS* fts = fts_open(paths, FTS_PHYSICAL, NULL);
+ ASSERT_TRUE(fts != NULL);
+ FTSENT* e;
+ while ((e = fts_read(fts)) != NULL) {
+ ASSERT_EQ(0, fts_set(fts, e, FTS_SKIP));
+ }
+ ASSERT_EQ(0, fts_close(fts));
+#else
+ GTEST_SKIP() << "no _FILE_OFFSET_BITS=64 <fts.h> in our old glibc";
+#endif
+}
diff --git a/tests/headers/posix/signal_h.c b/tests/headers/posix/signal_h.c
index c2e544e..82751f4 100644
--- a/tests/headers/posix/signal_h.c
+++ b/tests/headers/posix/signal_h.c
@@ -63,6 +63,10 @@
MACRO(SIGEV_SIGNAL);
MACRO(SIGEV_THREAD);
+#if !defined(__GLIBC__) // Our glibc is too old.
+ MACRO(SIG2STR_MAX);
+#endif
+
TYPE(union sigval);
STRUCT_MEMBER(union sigval, int, sival_int);
STRUCT_MEMBER(union sigval, void*, sival_ptr);
@@ -205,6 +209,9 @@
FUNCTION(pthread_kill, int (*f)(pthread_t, int));
FUNCTION(pthread_sigmask, int (*f)(int, const sigset_t*, sigset_t*));
FUNCTION(raise, int (*f)(int));
+#if !defined(__GLIBC__) // Our glibc is too old.
+ FUNCTION(sig2str, int (*f)(int, char*));
+#endif
FUNCTION(sigaction, int (*f)(int, const struct sigaction*, struct sigaction*));
FUNCTION(sigaddset, int (*f)(sigset_t*, int));
FUNCTION(sigaltstack, int (*f)(const stack_t*, stack_t*));
@@ -226,4 +233,7 @@
FUNCTION(sigtimedwait, int (*f)(const sigset_t*, siginfo_t*, const struct timespec*));
FUNCTION(sigwait, int (*f)(const sigset_t*, int*));
FUNCTION(sigwaitinfo, int (*f)(const sigset_t*, siginfo_t*));
+#if !defined(__GLIBC__) // Our glibc is too old.
+ FUNCTION(str2sig, int (*f)(const char*, int*));
+#endif
}
diff --git a/tests/headers/posix/stdlib_h.c b/tests/headers/posix/stdlib_h.c
index 52580cf..95769b4 100644
--- a/tests/headers/posix/stdlib_h.c
+++ b/tests/headers/posix/stdlib_h.c
@@ -112,6 +112,9 @@
FUNCTION(ptsname, char* (*f)(int));
FUNCTION(putenv, int (*f)(char*));
FUNCTION(qsort, void (*f)(void*, size_t, size_t, int (*)(const void*, const void*)));
+#if !defined(__GLIBC__) // Our glibc is too old.
+ FUNCTION(qsort_r, void (*f)(void*, size_t, size_t, int (*)(const void*, const void*, void*), void*));
+#endif
FUNCTION(rand, int (*f)(void));
FUNCTION(rand_r, int (*f)(unsigned*));
FUNCTION(random, long (*f)(void));
diff --git a/tests/headers/posix/unistd_h.c b/tests/headers/posix/unistd_h.c
index 0b2cee5..f66609d 100644
--- a/tests/headers/posix/unistd_h.c
+++ b/tests/headers/posix/unistd_h.c
@@ -331,6 +331,9 @@
FUNCTION(fdatasync, int (*f)(int));
FUNCTION(fexecve, int (*f)(int, char* const[], char* const[]));
FUNCTION(fork, pid_t (*f)(void));
+#if !defined(__GLIBC__) // Our glibc is too old.
+ FUNCTION(_Fork, pid_t (*f)(void));
+#endif
FUNCTION(fpathconf, long (*f)(int, int));
FUNCTION(fsync, int (*f)(int));
FUNCTION(ftruncate, int (*f)(int, off_t));
diff --git a/tests/ifaddrs_test.cpp b/tests/ifaddrs_test.cpp
index b3ab94d..da64770 100644
--- a/tests/ifaddrs_test.cpp
+++ b/tests/ifaddrs_test.cpp
@@ -137,7 +137,7 @@
sockaddr_in* sock = reinterpret_cast<sockaddr_in*>(&ifr.ifr_addr);
in_addr_t addr = sock->sin_addr.s_addr;
- EXPECT_TRUE(addrs.find(addr) != addrs.end()) << if_name << ' ' << std::hex << ntohl(addr);
+ EXPECT_TRUE(addrs.contains(addr)) << if_name << ' ' << std::hex << ntohl(addr);
}
TEST(ifaddrs, getifaddrs_INET) {
diff --git a/tests/libs/elftls_dtv_resize_helper.cpp b/tests/libs/elftls_dtv_resize_helper.cpp
index 340d5df..7fb6fb5 100644
--- a/tests/libs/elftls_dtv_resize_helper.cpp
+++ b/tests/libs/elftls_dtv_resize_helper.cpp
@@ -180,8 +180,8 @@
// Access a TLS variable from the first filler module.
ASSERT_EQ(102, func1());
ASSERT_EQ(5u, highest_modid_in_dtv());
-#if defined(__aarch64__)
- // The arm64 TLSDESC resolver doesn't update the DTV if it is new enough for
+#if defined(__aarch64__) || defined(__riscv)
+ // The arm64 and riscv64 TLSDESC resolver doesn't update the DTV if it is new enough for
// the given access.
ASSERT_EQ(initial_dtv, dtv());
ASSERT_EQ(5u, dtv()->count);
diff --git a/tests/libs/elftls_dynamic.cpp b/tests/libs/elftls_dynamic.cpp
index 2500484..df3ad75 100644
--- a/tests/libs/elftls_dynamic.cpp
+++ b/tests/libs/elftls_dynamic.cpp
@@ -66,6 +66,18 @@
return ++local_var_1 + ++local_var_2;
}
+extern "C" int get_local_var1() {
+ return local_var_1;
+}
+
+extern "C" int* get_local_var1_addr() {
+ return &local_var_1;
+}
+
+extern "C" int get_local_var2() {
+ return local_var_2;
+}
+
__attribute__((weak)) extern "C" __thread int missing_weak_dyn_tls;
extern "C" int* missing_weak_dyn_tls_addr() {
diff --git a/tests/libs/segment_gap_outer.cpp b/tests/libs/segment_gap_outer.cpp
index 3ba90d0..0328a99 100644
--- a/tests/libs/segment_gap_outer.cpp
+++ b/tests/libs/segment_gap_outer.cpp
@@ -1,6 +1,7 @@
#include <android/dlext.h>
#include <dlfcn.h>
#include <stdlib.h>
+#include <unistd.h>
extern "C" void __attribute__((section(".custom_text"))) text_before_start_of_gap() {}
char __attribute__((section(".custom_bss"))) end_of_gap[0x1000];
@@ -10,8 +11,9 @@
info.flags = ANDROID_DLEXT_RESERVED_ADDRESS;
char* start_of_gap =
- reinterpret_cast<char*>(reinterpret_cast<uintptr_t>(text_before_start_of_gap) & ~0xfffull) +
- 0x1000;
+ reinterpret_cast<char*>(
+ (reinterpret_cast<uintptr_t>(text_before_start_of_gap) &
+ ~(sysconf(_SC_PAGESIZE) - 1)) + sysconf(_SC_PAGESIZE));
info.reserved_addr = start_of_gap;
info.reserved_size = end_of_gap - start_of_gap;
diff --git a/tests/libs/segment_gap_outer.lds b/tests/libs/segment_gap_outer.lds
index 527f29e..758b6bc 100644
--- a/tests/libs/segment_gap_outer.lds
+++ b/tests/libs/segment_gap_outer.lds
@@ -3,17 +3,17 @@
# appropriate alignment between them.
. = SIZEOF_HEADERS;
.rodata : {*(.rodata .rodata.*)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.text : {*(.text .text.*)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.dynamic : {*(.dynamic)}
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.data : {*(.data .data.*)}
.bss : {*(.bss .bss.*)}
# Now create the gap. We need a text segment first to prevent the linker from
# merging .bss with .custom_bss.
- . = ALIGN(0x1000);
+ . = ALIGN(CONSTANT (MAXPAGESIZE));
.custom_text : {
*(.custom_text);
}
diff --git a/tests/libs/testbinary_is_stack_mte.cpp b/tests/libs/testbinary_is_stack_mte.cpp
index d8074d5..0cdc466 100644
--- a/tests/libs/testbinary_is_stack_mte.cpp
+++ b/tests/libs/testbinary_is_stack_mte.cpp
@@ -36,7 +36,9 @@
#if defined(__BIONIC__) && defined(__aarch64__)
extern "C" int main(int, char**) {
- int ret = is_stack_mte_on() ? 0 : 1;
+ void* mte_tls_ptr = mte_tls();
+ *reinterpret_cast<uintptr_t*>(mte_tls_ptr) = 1;
+ int ret = is_stack_mte_on() && mte_tls_ptr != nullptr ? 0 : 1;
printf("RAN\n");
return ret;
}
diff --git a/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp b/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
index 937ac4c..35af8f4 100644
--- a/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
+++ b/tests/libs/testbinary_is_stack_mte_after_dlopen.cpp
@@ -96,6 +96,7 @@
State state = kInit;
bool is_early_thread_mte_on = false;
+ void* early_thread_mte_tls = nullptr;
std::thread early_th([&] {
{
std::lock_guard lk(m);
@@ -107,6 +108,8 @@
cv.wait(lk, [&] { return state == kStackRemapped; });
}
is_early_thread_mte_on = is_stack_mte_on();
+ early_thread_mte_tls = mte_tls();
+ *reinterpret_cast<uintptr_t*>(early_thread_mte_tls) = 1;
});
{
std::unique_lock lk(m);
@@ -120,6 +123,7 @@
cv.notify_one();
CHECK(handle != nullptr);
CHECK(is_stack_mte_on());
+ CHECK(mte_tls() != nullptr);
bool new_stack_page_mte_on = false;
uintptr_t low;
@@ -129,11 +133,18 @@
CHECK(new_stack_page_mte_on);
bool is_late_thread_mte_on = false;
- std::thread late_th([&] { is_late_thread_mte_on = is_stack_mte_on(); });
+ void* late_thread_mte_tls = nullptr;
+ std::thread late_th([&] {
+ is_late_thread_mte_on = is_stack_mte_on();
+ late_thread_mte_tls = mte_tls();
+ *reinterpret_cast<uintptr_t*>(late_thread_mte_tls) = 1;
+ });
late_th.join();
early_th.join();
CHECK(is_late_thread_mte_on);
CHECK(is_early_thread_mte_on);
+ CHECK(late_thread_mte_tls != nullptr);
+ CHECK(early_thread_mte_tls != nullptr);
printf("RAN\n");
return 0;
}
diff --git a/tests/link_test.cpp b/tests/link_test.cpp
index 127a3d9..ae3a1cd 100644
--- a/tests/link_test.cpp
+++ b/tests/link_test.cpp
@@ -195,7 +195,7 @@
}
void AddModule(dl_phdr_info* info, size_t s) {
ASSERT_EQ(sizeof(dl_phdr_info), s);
- ASSERT_TRUE(dl_iter_mods.find(info->dlpi_addr) == dl_iter_mods.end());
+ ASSERT_FALSE(dl_iter_mods.contains(info->dlpi_addr));
ASSERT_TRUE(info->dlpi_name != nullptr);
dl_iter_mods[info->dlpi_addr] = {
.name = info->dlpi_name,
diff --git a/tests/make_fortify_compile_test.mk b/tests/make_fortify_compile_test.mk
deleted file mode 100644
index ec0ba45..0000000
--- a/tests/make_fortify_compile_test.mk
+++ /dev/null
@@ -1,24 +0,0 @@
-include $(CLEAR_VARS)
-
-LOCAL_ADDITIONAL_DEPENDENCIES := \
- $(LOCAL_PATH)/Android.mk \
- $(LOCAL_PATH)/touch-obj-on-success
-
-LOCAL_CXX := $(LOCAL_PATH)/touch-obj-on-success \
- $(LLVM_PREBUILTS_PATH)/clang++ \
-
-LOCAL_CLANG := true
-LOCAL_MODULE := bionic-compile-time-tests$(FORTIFY_LEVEL)-clang++
-LOCAL_LICENSE_KINDS := SPDX-license-identifier-Apache-2.0 SPDX-license-identifier-BSD
-LOCAL_LICENSE_CONDITIONS := notice
-LOCAL_NOTICE_FILE := $(LOCAL_PATH)/NOTICE
-LOCAL_TIDY := false
-LOCAL_CPPFLAGS := -Wall -Wno-error
-LOCAL_CPPFLAGS += -fno-color-diagnostics -ferror-limit=10000 -Xclang -verify
-LOCAL_CPPFLAGS += -DCOMPILATION_TESTS=1 -Wformat-nonliteral
-LOCAL_CPPFLAGS += -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=$(FORTIFY_LEVEL)
-LOCAL_SRC_FILES := clang_fortify_tests.cpp
-
-include $(BUILD_STATIC_LIBRARY)
-
-FORTIFY_LEVEL :=
diff --git a/tests/malloc_test.cpp b/tests/malloc_test.cpp
index 2b48d85..813f348 100644
--- a/tests/malloc_test.cpp
+++ b/tests/malloc_test.cpp
@@ -678,10 +678,12 @@
TEST(malloc, mallopt_decay) {
#if defined(__BIONIC__)
SKIP_WITH_HWASAN << "hwasan does not implement mallopt";
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, -1));
ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
ASSERT_EQ(1, mallopt(M_DECAY_TIME, 1));
ASSERT_EQ(1, mallopt(M_DECAY_TIME, 0));
+ ASSERT_EQ(1, mallopt(M_DECAY_TIME, -1));
#else
GTEST_SKIP() << "bionic-only test";
#endif
@@ -1410,15 +1412,15 @@
}
#if defined(__BIONIC__)
-using Action = android_mallopt_gwp_asan_options_t::Action;
+using Mode = android_mallopt_gwp_asan_options_t::Mode;
TEST(android_mallopt, DISABLED_multiple_enable_gwp_asan) {
android_mallopt_gwp_asan_options_t options;
options.program_name = ""; // Don't infer GWP-ASan options from sysprops.
- options.desire = Action::DONT_TURN_ON_UNLESS_OVERRIDDEN;
+ options.mode = Mode::APP_MANIFEST_NEVER;
// GWP-ASan should already be enabled. Trying to enable or disable it should
// always pass.
ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &options, sizeof(options)));
- options.desire = Action::TURN_ON_WITH_SAMPLING;
+ options.mode = Mode::APP_MANIFEST_DEFAULT;
ASSERT_TRUE(android_mallopt(M_INITIALIZE_GWP_ASAN, &options, sizeof(options)));
}
#endif // defined(__BIONIC__)
@@ -1490,7 +1492,7 @@
// release secondary allocations back to the OS) was modified to 0ms/1ms by
// mallopt_decay. Ensure that we delay for at least a second before releasing
// pages to the OS in order to avoid implicit zeroing by the kernel.
- mallopt(M_DECAY_TIME, 1000);
+ mallopt(M_DECAY_TIME, 1);
TestHeapZeroing(/* num_iterations */ 32, [](int iteration) -> int {
return 1 << (19 + iteration % 4);
});
@@ -1625,6 +1627,7 @@
#if !defined(__BIONIC__)
GTEST_SKIP() << "Only valid on bionic";
#endif
+ SKIP_WITH_HWASAN << "Only test system allocator, not hwasan allocator.";
if (IsLowRamDevice()) {
GTEST_SKIP() << "Skipped on low memory devices.";
@@ -1655,6 +1658,7 @@
#if !defined(__BIONIC__)
GTEST_SKIP() << "Only valid on bionic";
#endif
+ SKIP_WITH_HWASAN << "Only test system allocator, not hwasan allocator.";
if (IsLowRamDevice()) {
GTEST_SKIP() << "Skipped on low memory devices.";
@@ -1685,6 +1689,7 @@
#if !defined(__BIONIC__)
GTEST_SKIP() << "Only valid on bionic";
#endif
+ SKIP_WITH_HWASAN << "Only test system allocator, not hwasan allocator.";
if (IsLowRamDevice()) {
GTEST_SKIP() << "Skipped on low memory devices.";
@@ -1764,6 +1769,10 @@
EXPECT_EQ(1, mallopt(M_DECAY_TIME, 1));
EXPECT_TRUE(android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value)));
EXPECT_TRUE(value);
+
+ EXPECT_EQ(1, mallopt(M_DECAY_TIME, -1));
+ EXPECT_TRUE(android_mallopt(M_GET_DECAY_TIME_ENABLED, &value, sizeof(value)));
+ EXPECT_FALSE(value);
#else
GTEST_SKIP() << "bionic-only test";
#endif
diff --git a/tests/math_test.cpp b/tests/math_test.cpp
index 493f3af..273ef97 100644
--- a/tests/math_test.cpp
+++ b/tests/math_test.cpp
@@ -17,36 +17,37 @@
#define _GNU_SOURCE 1
#include <math.h>
-// This include (and the associated definition of __test_capture_signbit)
-// must be placed before any files that include <cmath> (gtest.h in this case).
+// <math.h> is required to define type-generic macros: fpclassify, signbit,
+// isfinite, isinf, isnan, isnormal, isgreater, isgreaterequal, isless,
+// islessequal, islessgreater, and isunordered.
//
-// <math.h> is required to define generic macros signbit, isfinite and
-// several other such functions.
+// <cmath> is required to #undef these macros and make equivalent sets of
+// _overloaded_ functions available in namespace std. So the isnan() macro,
+// for example, is replaced by std::isnan(float), std::isnan(double),
+// and std::isnan(long double).
//
-// <cmath> is required to undef declarations of these macros in the global
-// namespace and make equivalent functions available in namespace std. Our
-// stlport implementation does this only for signbit, isfinite, isinf and
-// isnan.
-//
-// NOTE: We don't write our test using std::signbit because we want to be
-// sure that we're testing the bionic version of signbit. The C++ libraries
-// are free to reimplement signbit or delegate to compiler builtins if they
-// please.
+// We're trying to test the bionic macros rather than whatever libc++'s
+// implementation happens to be, so we #include <math.h> and "capture" the
+// macros in our own _template_ functions in the global namespace before
+// we #include any files that include <cmath>, such as <gtest.h>.
-namespace {
-template<typename T> inline int test_capture_signbit(const T in) {
- return signbit(in);
-}
-template<typename T> inline int test_capture_isfinite(const T in) {
- return isfinite(in);
-}
-template<typename T> inline int test_capture_isnan(const T in) {
- return isnan(in);
-}
-template<typename T> inline int test_capture_isinf(const T in) {
- return isinf(in);
-}
-}
+#define capture_generic_macro(capture_function_name, generic_macro_name) \
+ template <typename T> inline int capture_function_name(const T in) { \
+ return generic_macro_name(in); \
+ }
+
+capture_generic_macro(test_capture_fpclassify, fpclassify)
+capture_generic_macro(test_capture_signbit, signbit)
+capture_generic_macro(test_capture_isfinite, isfinite)
+capture_generic_macro(test_capture_isinf, isinf)
+capture_generic_macro(test_capture_isnan, isnan)
+capture_generic_macro(test_capture_isnormal, isnormal)
+capture_generic_macro(test_capture_isgreater, isgreater)
+capture_generic_macro(test_capture_isgreaterequal, isgreaterequal)
+capture_generic_macro(test_capture_isless, isless)
+capture_generic_macro(test_capture_islessequal, islessequal)
+capture_generic_macro(test_capture_islessgreater, islessgreater)
+capture_generic_macro(test_capture_isunordered, isunordered)
#include "math_data_test.h"
@@ -60,6 +61,22 @@
#include <android-base/scopeguard.h>
+// Now we've included all the headers we need, we can redefine the generic
+// function-like macros to point to the bionic <math.h> versions we captured
+// earlier.
+#define fpclassify test_capture_fpclassify
+#define signbit test_capture_signbit
+#define isfinite test_capture_isfinite
+#define isinf test_capture_isinf
+#define isnan test_capture_isnan
+#define isnormal test_capture_isnormal
+#define isgreater test_capture_isgreater
+#define isgreaterequal test_capture_isgreaterequal
+#define isless test_capture_isless
+#define islessequal test_capture_islessequal
+#define islessgreater test_capture_islessgreater
+#define isunordered test_capture_isunordered
+
static float float_subnormal() {
union {
float f;
@@ -124,36 +141,36 @@
}
TEST(math_h, isfinite) {
- ASSERT_TRUE(test_capture_isfinite(123.0f));
- ASSERT_TRUE(test_capture_isfinite(123.0));
- ASSERT_TRUE(test_capture_isfinite(123.0L));
- ASSERT_FALSE(test_capture_isfinite(HUGE_VALF));
- ASSERT_FALSE(test_capture_isfinite(-HUGE_VALF));
- ASSERT_FALSE(test_capture_isfinite(HUGE_VAL));
- ASSERT_FALSE(test_capture_isfinite(-HUGE_VAL));
- ASSERT_FALSE(test_capture_isfinite(HUGE_VALL));
- ASSERT_FALSE(test_capture_isfinite(-HUGE_VALL));
+ ASSERT_TRUE(isfinite(123.0f));
+ ASSERT_TRUE(isfinite(123.0));
+ ASSERT_TRUE(isfinite(123.0L));
+ ASSERT_FALSE(isfinite(HUGE_VALF));
+ ASSERT_FALSE(isfinite(-HUGE_VALF));
+ ASSERT_FALSE(isfinite(HUGE_VAL));
+ ASSERT_FALSE(isfinite(-HUGE_VAL));
+ ASSERT_FALSE(isfinite(HUGE_VALL));
+ ASSERT_FALSE(isfinite(-HUGE_VALL));
}
TEST(math_h, isinf) {
- ASSERT_FALSE(test_capture_isinf(123.0f));
- ASSERT_FALSE(test_capture_isinf(123.0));
- ASSERT_FALSE(test_capture_isinf(123.0L));
- ASSERT_TRUE(test_capture_isinf(HUGE_VALF));
- ASSERT_TRUE(test_capture_isinf(-HUGE_VALF));
- ASSERT_TRUE(test_capture_isinf(HUGE_VAL));
- ASSERT_TRUE(test_capture_isinf(-HUGE_VAL));
- ASSERT_TRUE(test_capture_isinf(HUGE_VALL));
- ASSERT_TRUE(test_capture_isinf(-HUGE_VALL));
+ ASSERT_FALSE(isinf(123.0f));
+ ASSERT_FALSE(isinf(123.0));
+ ASSERT_FALSE(isinf(123.0L));
+ ASSERT_TRUE(isinf(HUGE_VALF));
+ ASSERT_TRUE(isinf(-HUGE_VALF));
+ ASSERT_TRUE(isinf(HUGE_VAL));
+ ASSERT_TRUE(isinf(-HUGE_VAL));
+ ASSERT_TRUE(isinf(HUGE_VALL));
+ ASSERT_TRUE(isinf(-HUGE_VALL));
}
TEST(math_h, isnan) {
- ASSERT_FALSE(test_capture_isnan(123.0f));
- ASSERT_FALSE(test_capture_isnan(123.0));
- ASSERT_FALSE(test_capture_isnan(123.0L));
- ASSERT_TRUE(test_capture_isnan(nanf("")));
- ASSERT_TRUE(test_capture_isnan(nan("")));
- ASSERT_TRUE(test_capture_isnan(nanl("")));
+ ASSERT_FALSE(isnan(123.0f));
+ ASSERT_FALSE(isnan(123.0));
+ ASSERT_FALSE(isnan(123.0L));
+ ASSERT_TRUE(isnan(nanf("")));
+ ASSERT_TRUE(isnan(nan("")));
+ ASSERT_TRUE(isnan(nanl("")));
}
TEST(math_h, isnormal) {
@@ -167,17 +184,17 @@
// TODO: isgreater, isgreaterequals, isless, islessequal, islessgreater, isunordered
TEST(math_h, signbit) {
- ASSERT_EQ(0, test_capture_signbit(0.0f));
- ASSERT_EQ(0, test_capture_signbit(0.0));
- ASSERT_EQ(0, test_capture_signbit(0.0L));
+ ASSERT_EQ(0, signbit(0.0f));
+ ASSERT_EQ(0, signbit(0.0));
+ ASSERT_EQ(0, signbit(0.0L));
- ASSERT_EQ(0, test_capture_signbit(1.0f));
- ASSERT_EQ(0, test_capture_signbit(1.0));
- ASSERT_EQ(0, test_capture_signbit(1.0L));
+ ASSERT_EQ(0, signbit(1.0f));
+ ASSERT_EQ(0, signbit(1.0));
+ ASSERT_EQ(0, signbit(1.0L));
- ASSERT_NE(0, test_capture_signbit(-1.0f));
- ASSERT_NE(0, test_capture_signbit(-1.0));
- ASSERT_NE(0, test_capture_signbit(-1.0L));
+ ASSERT_NE(0, signbit(-1.0f));
+ ASSERT_NE(0, signbit(-1.0));
+ ASSERT_NE(0, signbit(-1.0L));
}
// Historical BSD cruft that isn't exposed in <math.h> any more.
@@ -309,9 +326,7 @@
// Historical BSD cruft that isn't exposed in <math.h> any more.
extern "C" int __isinf(double);
extern "C" int __isinff(float);
-extern "C" int isinff(float);
extern "C" int __isinfl(long double);
-extern "C" int isinfl(long double);
TEST(math_h, __isinf) {
#if defined(ANDROID_HOST_MUSL)
@@ -367,9 +382,7 @@
// Historical BSD cruft that isn't exposed in <math.h> any more.
extern "C" int __isnan(double);
extern "C" int __isnanf(float);
-extern "C" int isnanf(float);
extern "C" int __isnanl(long double);
-extern "C" int isnanl(long double);
TEST(math_h, __isnan) {
#if defined(ANDROID_HOST_MUSL)
diff --git a/tests/mntent_test.cpp b/tests/mntent_test.cpp
index 4b8fc9a..fd69ae1 100644
--- a/tests/mntent_test.cpp
+++ b/tests/mntent_test.cpp
@@ -59,9 +59,7 @@
// indices 1 1
// of keys: 0 5 9 1 4
char mnt_opts[]{"aa=b,a=b,b,bb,c=d"};
- struct mntent ent;
- memset(&ent, 0, sizeof(ent));
- ent.mnt_opts = mnt_opts;
+ struct mntent ent = {.mnt_opts = mnt_opts};
EXPECT_EQ(mnt_opts, hasmntopt(&ent, "aa"));
EXPECT_EQ(mnt_opts + 5, hasmntopt(&ent, "a"));
@@ -71,3 +69,9 @@
EXPECT_EQ(nullptr, hasmntopt(&ent, "d"));
EXPECT_EQ(nullptr, hasmntopt(&ent, "e"));
}
+
+TEST(mntent, hasmntopt_no_suffix_match) {
+ char mnt_opts[]{"noatime"};
+ struct mntent ent = {.mnt_opts = mnt_opts};
+ EXPECT_EQ(nullptr, hasmntopt(&ent, "atime"));
+}
diff --git a/tests/mte_utils.h b/tests/mte_utils.h
index 6e8385c..020faec 100644
--- a/tests/mte_utils.h
+++ b/tests/mte_utils.h
@@ -40,4 +40,10 @@
return p == p_cpy;
}
+static void* mte_tls() {
+ void** dst;
+ __asm__("mrs %0, TPIDR_EL0" : "=r"(dst) :);
+ return dst[-3];
+}
+
#endif
diff --git a/libc/bionic/time_l.cpp b/tests/netinet_igmp_test.cpp
similarity index 79%
copy from libc/bionic/time_l.cpp
copy to tests/netinet_igmp_test.cpp
index e5fa9a5..4cf7876 100644
--- a/libc/bionic/time_l.cpp
+++ b/tests/netinet_igmp_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,9 +26,15 @@
* SUCH DAMAGE.
*/
-#include <time.h>
-//#include <xlocale.h>
+#include <gtest/gtest.h>
-char* strptime_l(const char* buf, const char* fmt, struct tm* tm, locale_t) {
- return strptime(buf, fmt, tm);
+#include <netinet/igmp.h>
+
+TEST(netinet_igmp, smoke) {
+ // Just check that the fields exist, so code is likely to compile.
+ struct igmp i;
+ i.igmp_type = IGMP_MEMBERSHIP_QUERY;
+ i.igmp_code = 0;
+ i.igmp_cksum = 0;
+ i.igmp_group.s_addr = htonl(INADDR_ANY);
}
diff --git a/tests/prebuilt-elf-files/arm64/libtest_empty.so b/tests/prebuilt-elf-files/arm64/libtest_empty.so
index d8775b6..76c569b 100755
--- a/tests/prebuilt-elf-files/arm64/libtest_empty.so
+++ b/tests/prebuilt-elf-files/arm64/libtest_empty.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so
index 6463c6b..46af37f 100755
--- a/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so
+++ b/tests/prebuilt-elf-files/arm64/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_empty.so b/tests/prebuilt-elf-files/x86_64/libtest_empty.so
index c3f3638..ce519b2 100755
--- a/tests/prebuilt-elf-files/x86_64/libtest_empty.so
+++ b/tests/prebuilt-elf-files/x86_64/libtest_empty.so
Binary files differ
diff --git a/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so b/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so
index 113e455..9d2c5f1 100755
--- a/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so
+++ b/tests/prebuilt-elf-files/x86_64/libtest_invalid-rw_load_segment.so
Binary files differ
diff --git a/tests/setjmp_test.cpp b/tests/setjmp_test.cpp
index 6ae8bfd..9469285 100644
--- a/tests/setjmp_test.cpp
+++ b/tests/setjmp_test.cpp
@@ -174,38 +174,65 @@
}
}
-#if defined(__aarch64__)
+#if defined(__arm__) || defined(__aarch64__)
+// arm and arm64 have the same callee save fp registers (8-15),
+// but use different instructions for accessing them.
+#if defined(__arm__)
+#define SET_FREG(n, v) asm volatile("vmov.f64 d"#n ", #"#v : : : "d"#n)
+#define GET_FREG(n) ({ double _r; asm volatile("fcpyd %P0, d"#n : "=w"(_r) : :); _r;})
+#define CLEAR_FREG(n) asm volatile("vmov.i64 d"#n ", #0x0" : : : "d"#n)
+#elif defined(__aarch64__)
#define SET_FREG(n, v) asm volatile("fmov d"#n ", "#v : : : "d"#n)
+#define GET_FREG(n) ({ double _r; asm volatile("fmov %0, d"#n : "=r"(_r) : :); _r; })
#define CLEAR_FREG(n) asm volatile("fmov d"#n ", xzr" : : : "d"#n)
+#endif
#define SET_FREGS \
SET_FREG(8, 8.0); SET_FREG(9, 9.0); SET_FREG(10, 10.0); SET_FREG(11, 11.0); \
- SET_FREG(12, 12.0); SET_FREG(13, 13.0); SET_FREG(14, 14.0); SET_FREG(15, 15.0);
+ SET_FREG(12, 12.0); SET_FREG(13, 13.0); SET_FREG(14, 14.0); SET_FREG(15, 15.0)
#define CLEAR_FREGS \
CLEAR_FREG(8); CLEAR_FREG(9); CLEAR_FREG(10); CLEAR_FREG(11); \
- CLEAR_FREG(12); CLEAR_FREG(13); CLEAR_FREG(14); CLEAR_FREG(15);
-#define GET_FREG(n) ({ double _r; asm volatile("fmov %0, d"#n : "=r"(_r) : :); _r; })
+ CLEAR_FREG(12); CLEAR_FREG(13); CLEAR_FREG(14); CLEAR_FREG(15)
#define CHECK_FREGS \
- EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
- EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11)); \
- EXPECT_EQ(12.0, GET_FREG(12)); EXPECT_EQ(13.0, GET_FREG(13)); \
- EXPECT_EQ(14.0, GET_FREG(14)); EXPECT_EQ(15.0, GET_FREG(15));
-#elif defined(__arm__)
-#define SET_FREG(n, v) \
- ({ const double _v{v}; asm volatile("fcpyd d"#n ", %P0" : : "w"(_v) : "d"#n); })
+ EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
+ EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11)); \
+ EXPECT_EQ(12.0, GET_FREG(12)); EXPECT_EQ(13.0, GET_FREG(13)); \
+ EXPECT_EQ(14.0, GET_FREG(14)); EXPECT_EQ(15.0, GET_FREG(15))
+
+#elif defined(__riscv)
+// riscv64 has callee save registers fs0-fs11.
+// TODO: use Zfa to get 1.0 rather than the one_p trick.
#define SET_FREGS \
- SET_FREG(8, 8); SET_FREG(9, 9); SET_FREG(10, 10); SET_FREG(11, 11); \
- SET_FREG(12, 12); SET_FREG(13, 13); SET_FREG(14, 14); SET_FREG(15, 15);
+ double one = 1, *one_p = &one; \
+ asm volatile("fmv.d.x fs0, zero ; fld fs1, (%0) ; \
+ fadd.d fs2, fs1, fs1 ; fadd.d fs3, fs2, fs1 ; \
+ fadd.d fs4, fs3, fs1 ; fadd.d fs5, fs4, fs1 ; \
+ fadd.d fs6, fs5, fs1 ; fadd.d fs7, fs6, fs1 ; \
+ fadd.d fs8, fs7, fs1 ; fadd.d fs9, fs8, fs1 ; \
+ fadd.d fs10, fs9, fs1 ; fadd.d fs11, fs10, fs1" \
+ : \
+ : "r"(one_p) \
+ : "fs0", "fs1", "fs2", "fs3", "fs4", "fs5", \
+ "fs6", "fs7", "fs8", "fs9", "fs10", "fs11")
#define CLEAR_FREGS \
- SET_FREG(8, 0); SET_FREG(9, 0); SET_FREG(10, 0); SET_FREG(11, 0); \
- SET_FREG(12, 0); SET_FREG(13, 0); SET_FREG(14, 0); SET_FREG(15, 0);
-#define GET_FREG(n) ({ double _r; asm volatile("fcpyd %P0, d"#n : "=w"(_r) : :); _r;})
+ asm volatile("fmv.d.x fs0, zero ; fmv.d.x fs1, zero ; \
+ fmv.d.x fs2, zero ; fmv.d.x fs3, zero ; \
+ fmv.d.x fs4, zero ; fmv.d.x fs5, zero ; \
+ fmv.d.x fs6, zero ; fmv.d.x fs7, zero ; \
+ fmv.d.x fs8, zero ; fmv.d.x fs9, zero ; \
+ fmv.d.x fs10, zero ; fmv.d.x fs11, zero" \
+ : : : "fs0", "fs1", "fs2", "fs3", "fs4", "fs5", \
+ "fs6", "fs7", "fs8", "fs9", "fs10", "fs11")
+#define GET_FREG(n) ({ double _r; asm volatile("fmv.d %0, fs"#n : "=f"(_r) : :); _r; })
#define CHECK_FREGS \
- EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
- EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11)); \
- EXPECT_EQ(12.0, GET_FREG(12)); EXPECT_EQ(13.0, GET_FREG(13)); \
- EXPECT_EQ(14.0, GET_FREG(14)); EXPECT_EQ(15.0, GET_FREG(15));
+ EXPECT_EQ(0.0, GET_FREG(0)); EXPECT_EQ(1.0, GET_FREG(1)); \
+ EXPECT_EQ(2.0, GET_FREG(2)); EXPECT_EQ(3.0, GET_FREG(3)); \
+ EXPECT_EQ(4.0, GET_FREG(4)); EXPECT_EQ(5.0, GET_FREG(5)); \
+ EXPECT_EQ(6.0, GET_FREG(6)); EXPECT_EQ(7.0, GET_FREG(7)); \
+ EXPECT_EQ(8.0, GET_FREG(8)); EXPECT_EQ(9.0, GET_FREG(9)); \
+ EXPECT_EQ(10.0, GET_FREG(10)); EXPECT_EQ(11.0, GET_FREG(11))
+
#else
-/* The other architectures don't save/restore fp registers. */
+// x86 and x86-64 don't save/restore fp registers.
#define SET_FREGS
#define CLEAR_FREGS
#define CHECK_FREGS
diff --git a/tests/signal_test.cpp b/tests/signal_test.cpp
index de126da..c1719dc 100644
--- a/tests/signal_test.cpp
+++ b/tests/signal_test.cpp
@@ -982,3 +982,94 @@
ASSERT_EQ(-1, killpg(-1, SIGKILL));
ASSERT_ERRNO(EINVAL);
}
+
+TEST(signal, sig2str) {
+#if defined(__BIONIC__)
+ char str[SIG2STR_MAX];
+
+ // A regular signal.
+ ASSERT_EQ(0, sig2str(SIGHUP, str));
+ ASSERT_STREQ("HUP", str);
+
+ // A real-time signal.
+ ASSERT_EQ(0, sig2str(SIGRTMIN + 4, str));
+ ASSERT_STREQ("RTMIN+4", str);
+ ASSERT_EQ(0, sig2str(SIGRTMAX - 4, str));
+ ASSERT_STREQ("RTMAX-4", str);
+ // Special cases.
+ ASSERT_EQ(0, sig2str(SIGRTMAX, str));
+ ASSERT_STREQ("RTMAX", str);
+ ASSERT_EQ(0, sig2str(SIGRTMIN, str));
+ ASSERT_STREQ("RTMIN", str);
+ // One of the signals the C library keeps to itself.
+ ASSERT_EQ(-1, sig2str(32, str)); // __SIGRTMIN
+
+ // Errors.
+ ASSERT_EQ(-1, sig2str(-1, str)); // Too small.
+ ASSERT_EQ(-1, sig2str(0, str)); // Still too small.
+ ASSERT_EQ(-1, sig2str(1234, str)); // Too large.
+#else
+ GTEST_SKIP() << "our old glibc doesn't have sig2str";
+#endif
+}
+
+TEST(signal, str2sig) {
+#if defined(__BIONIC__)
+ int sig;
+
+ // A regular signal, by number.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("9", &sig));
+ ASSERT_EQ(SIGKILL, sig);
+
+ // A regular signal, by name.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("HUP", &sig));
+ ASSERT_EQ(SIGHUP, sig);
+
+ // A real-time signal, by number.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("64", &sig));
+ ASSERT_EQ(SIGRTMAX, sig);
+
+ // A real-time signal, by name and offset.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMAX-4", &sig));
+ ASSERT_EQ(SIGRTMAX - 4, sig);
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMIN+4", &sig));
+ ASSERT_EQ(SIGRTMIN + 4, sig);
+ // Unspecified by POSIX, but we try to be reasonable.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMAX-0", &sig));
+ ASSERT_EQ(SIGRTMAX, sig);
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMIN+0", &sig));
+ ASSERT_EQ(SIGRTMIN, sig);
+ // One of the signals the C library keeps to itself, numerically.
+ ASSERT_EQ(-1, str2sig("32", &sig)); // __SIGRTMIN
+
+ // Special cases.
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMAX", &sig));
+ ASSERT_EQ(SIGRTMAX, sig);
+ sig = -1;
+ ASSERT_EQ(0, str2sig("RTMIN", &sig));
+ ASSERT_EQ(SIGRTMIN, sig);
+
+ // Errors.
+ ASSERT_EQ(-1, str2sig("SIGHUP", &sig)); // No "SIG" prefix allowed.
+ ASSERT_EQ(-1, str2sig("-1", &sig)); // Too small.
+ ASSERT_EQ(-1, str2sig("0", &sig)); // Still too small.
+ ASSERT_EQ(-1, str2sig("1234", &sig)); // Too large.
+ ASSERT_EQ(-1, str2sig("RTMAX-666", &sig)); // Offset too small.
+ ASSERT_EQ(-1, str2sig("RTMIN+666", &sig)); // Offset too large.
+ ASSERT_EQ(-1, str2sig("RTMAX-+1", &sig)); // Silly.
+ ASSERT_EQ(-1, str2sig("RTMIN+-1", &sig)); // Silly.
+ ASSERT_EQ(-1, str2sig("HUPs", &sig)); // Trailing junk.
+ ASSERT_EQ(-1, str2sig("2b", &sig)); // Trailing junk.
+ ASSERT_EQ(-1, str2sig("RTMIN+2b", &sig)); // Trailing junk.
+#else
+ GTEST_SKIP() << "our old glibc doesn't have str2sig";
+#endif
+}
diff --git a/tests/stack_protector_test.cpp b/tests/stack_protector_test.cpp
index c4be78c..5817a27 100644
--- a/tests/stack_protector_test.cpp
+++ b/tests/stack_protector_test.cpp
@@ -48,7 +48,7 @@
printf("[thread %d] TLS stack guard = %p\n", tid, guard);
// Duplicate tid. gettid(2) bug? Seeing this would be very upsetting.
- ASSERT_TRUE(tids.find(tid) == tids.end());
+ ASSERT_FALSE(tids.contains(tid));
// Uninitialized guard. Our bug. Note this is potentially flaky; we _could_
// get four random zero bytes, but it should be vanishingly unlikely.
@@ -136,7 +136,7 @@
if (stack_mte_enabled()) {
GTEST_SKIP() << "Stack MTE is enabled, stack protector is not available";
} else if (hwasan_enabled()) {
- ASSERT_EXIT(modify_stack_protector_test(), testing::KilledBySignal(SIGABRT), "tag-mismatch");
+ GTEST_SKIP() << "HWASan is enabled, stack protector is not testable";
} else {
ASSERT_EXIT(modify_stack_protector_test(), testing::KilledBySignal(SIGABRT),
"stack corruption detected");
diff --git a/tests/static_tls_layout_test.cpp b/tests/static_tls_layout_test.cpp
index bf508e8..ada29a5 100644
--- a/tests/static_tls_layout_test.cpp
+++ b/tests/static_tls_layout_test.cpp
@@ -35,6 +35,8 @@
#include <gtest/gtest.h>
+#include <android-base/silent_death_test.h>
+
#include "private/bionic_tls.h"
using namespace std::string_literals;
@@ -138,7 +140,9 @@
return i * sizeof(void*);
}
-TEST(static_tls_layout, arm) {
+using static_tls_layout_DeathTest = SilentDeathTest;
+
+TEST_F(static_tls_layout_DeathTest, arm) {
#if !defined(__arm__) && !defined(__aarch64__)
GTEST_SKIP() << "test only applies to arm32/arm64 targets";
#endif
diff --git a/tests/stdio_test.cpp b/tests/stdio_test.cpp
index 5cb634c..7cdfa42 100644
--- a/tests/stdio_test.cpp
+++ b/tests/stdio_test.cpp
@@ -121,9 +121,10 @@
EXPECT_SWPRINTF_N(expected, static_cast<int>(wcslen(expected)), fmt __VA_OPT__(, ) __VA_ARGS__)
TEST(STDIO_TEST, flockfile_18208568_stderr) {
- // Check that we have a _recursive_ mutex for flockfile.
flockfile(stderr);
- feof(stderr); // We don't care about the result, but this needs to take the lock.
+ // Check that we're using a _recursive_ mutex for flockfile() by calling
+ // something that will take the lock.
+ ASSERT_EQ(0, feof(stderr));
funlockfile(stderr);
}
@@ -132,7 +133,9 @@
FILE* fp = fopen("/dev/null", "w");
ASSERT_TRUE(fp != nullptr);
flockfile(fp);
- feof(fp);
+ // Check that we're using a _recursive_ mutex for flockfile() by calling
+ // something that will take the lock.
+ ASSERT_EQ(0, feof(fp));
funlockfile(fp);
fclose(fp);
}
diff --git a/tests/stdlib_test.cpp b/tests/stdlib_test.cpp
index 4793150..fac9b9b 100644
--- a/tests/stdlib_test.cpp
+++ b/tests/stdlib_test.cpp
@@ -29,6 +29,7 @@
#include <limits>
#include <string>
+#include <thread>
#include <android-base/file.h>
#include <android-base/macros.h>
@@ -430,6 +431,31 @@
ASSERT_STREQ("charlie", entries[2].name);
}
+TEST(stdlib, qsort_r) {
+ struct s {
+ char name[16];
+ static int comparator(const void* lhs, const void* rhs, void* context) {
+ int* count_p = reinterpret_cast<int*>(context);
+ *count_p += 1;
+ return strcmp(reinterpret_cast<const s*>(lhs)->name, reinterpret_cast<const s*>(rhs)->name);
+ }
+ };
+ s entries[3];
+ strcpy(entries[0].name, "charlie");
+ strcpy(entries[1].name, "bravo");
+ strcpy(entries[2].name, "alpha");
+
+ int count;
+ void* context = &count;
+
+ count = 0;
+ qsort_r(entries, 3, sizeof(s), s::comparator, context);
+ ASSERT_STREQ("alpha", entries[0].name);
+ ASSERT_STREQ("bravo", entries[1].name);
+ ASSERT_STREQ("charlie", entries[2].name);
+ ASSERT_EQ(count, 3);
+}
+
static void* TestBug57421_child(void* arg) {
pthread_t main_thread = reinterpret_cast<pthread_t>(arg);
pthread_join(main_thread, nullptr);
@@ -493,7 +519,7 @@
TEST(stdlib, system_NULL) {
// "The system() function shall always return non-zero when command is NULL."
- // http://pubs.opengroup.org/onlinepubs/9699919799/functions/system.html
+ // https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/system.html
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wnonnull"
ASSERT_NE(0, system(nullptr));
@@ -650,6 +676,58 @@
AssertChildExited(pid, 99);
}
+static void exit_from_atexit_func4() {
+ std::thread([] { exit(4); }).detach();
+ usleep(1000);
+ fprintf(stderr, "4");
+}
+
+static void exit_from_atexit_func3() {
+ std::thread([] { exit(3); }).detach();
+ fprintf(stderr, "3");
+ usleep(1000);
+ // This should cause us to exit with status 99,
+ // but not before printing "4",
+ // and without re-running the previous atexit handlers.
+ exit(99);
+}
+
+static void exit_from_atexit_func2() {
+ std::thread([] { exit(2); }).detach();
+ fprintf(stderr, "2");
+ usleep(1000);
+ // Register another atexit handler from within an atexit handler.
+ atexit(exit_from_atexit_func3);
+}
+
+static void exit_from_atexit_func1() {
+ // These atexit handlers all spawn another thread that tries to exit,
+ // and sleep to try to lose the race.
+ // The lock in exit() should ensure that only the first thread to call
+ // exit() can ever win (but see exit_from_atexit_func3() for a subtelty).
+ std::thread([] { exit(1); }).detach();
+ usleep(1000);
+ fprintf(stderr, "1");
+}
+
+static void exit_torturer() {
+ atexit(exit_from_atexit_func4);
+ // We deliberately don't register exit_from_atexit_func3() here;
+ // see exit_from_atexit_func2().
+ atexit(exit_from_atexit_func2);
+ atexit(exit_from_atexit_func1);
+ exit(0);
+}
+
+TEST(stdlib, exit_torture) {
+ // Test that the atexit() handlers are run in the defined order (reverse
+ // order of registration), even though one of them is registered by another
+ // when it runs, and that we get the exit code from the last call to exit()
+ // on the first thread to call exit() (rather than one of the other threads
+ // or a deadlock from the second call on the same thread).
+ ASSERT_EXIT(exit_torturer(), testing::ExitedWithCode(99), "1234");
+}
+
TEST(unistd, _Exit) {
pid_t pid = fork();
ASSERT_NE(-1, pid) << strerror(errno);
diff --git a/tests/struct_layout_test.cpp b/tests/struct_layout_test.cpp
index 0123ed9..1f04344 100644
--- a/tests/struct_layout_test.cpp
+++ b/tests/struct_layout_test.cpp
@@ -30,7 +30,7 @@
#define CHECK_OFFSET(name, field, offset) \
check_offset(#name, #field, offsetof(name, field), offset);
#ifdef __LP64__
- CHECK_SIZE(pthread_internal_t, 776);
+ CHECK_SIZE(pthread_internal_t, 816);
CHECK_OFFSET(pthread_internal_t, next, 0);
CHECK_OFFSET(pthread_internal_t, prev, 8);
CHECK_OFFSET(pthread_internal_t, tid, 16);
@@ -55,6 +55,8 @@
CHECK_OFFSET(pthread_internal_t, dlerror_buffer, 248);
CHECK_OFFSET(pthread_internal_t, bionic_tls, 760);
CHECK_OFFSET(pthread_internal_t, errno_value, 768);
+ CHECK_OFFSET(pthread_internal_t, bionic_tcb, 776);
+ CHECK_OFFSET(pthread_internal_t, stack_mte_ringbuffer_vma_name_buffer, 784);
CHECK_SIZE(bionic_tls, 12200);
CHECK_OFFSET(bionic_tls, key_data, 0);
CHECK_OFFSET(bionic_tls, locale, 2080);
@@ -72,7 +74,7 @@
CHECK_OFFSET(bionic_tls, bionic_systrace_disabled, 12193);
CHECK_OFFSET(bionic_tls, padding, 12194);
#else
- CHECK_SIZE(pthread_internal_t, 668);
+ CHECK_SIZE(pthread_internal_t, 704);
CHECK_OFFSET(pthread_internal_t, next, 0);
CHECK_OFFSET(pthread_internal_t, prev, 4);
CHECK_OFFSET(pthread_internal_t, tid, 8);
@@ -97,6 +99,8 @@
CHECK_OFFSET(pthread_internal_t, dlerror_buffer, 148);
CHECK_OFFSET(pthread_internal_t, bionic_tls, 660);
CHECK_OFFSET(pthread_internal_t, errno_value, 664);
+ CHECK_OFFSET(pthread_internal_t, bionic_tcb, 668);
+ CHECK_OFFSET(pthread_internal_t, stack_mte_ringbuffer_vma_name_buffer, 672);
CHECK_SIZE(bionic_tls, 11080);
CHECK_OFFSET(bionic_tls, key_data, 0);
CHECK_OFFSET(bionic_tls, locale, 1040);
diff --git a/tests/sys_hwprobe_test.cpp b/tests/sys_hwprobe_test.cpp
index 6b74e18..fd59e1d 100644
--- a/tests/sys_hwprobe_test.cpp
+++ b/tests/sys_hwprobe_test.cpp
@@ -33,6 +33,68 @@
#include <sys/syscall.h>
#endif
+
+#if defined(__riscv)
+#include <riscv_vector.h>
+
+__attribute__((noinline))
+uint64_t scalar_cast(uint8_t const* p) {
+ return *(uint64_t const*)p;
+}
+
+__attribute__((noinline))
+uint64_t scalar_memcpy(uint8_t const* p) {
+ uint64_t r;
+ __builtin_memcpy(&r, p, sizeof(r));
+ return r;
+}
+
+__attribute__((noinline))
+uint64_t vector_memcpy(uint8_t* d, uint8_t const* p) {
+ __builtin_memcpy(d, p, 16);
+ return *(uint64_t const*)d;
+}
+
+__attribute__((noinline))
+uint64_t vector_ldst(uint8_t* d, uint8_t const* p) {
+ __riscv_vse8(d, __riscv_vle8_v_u8m1(p, 16), 16);
+ return *(uint64_t const*)d;
+}
+
+__attribute__((noinline))
+uint64_t vector_ldst64(uint8_t* d, uint8_t const* p) {
+ __riscv_vse64((unsigned long *)d, __riscv_vle64_v_u64m1((const unsigned long *)p, 16), 16);
+ return *(uint64_t const*)d;
+}
+
+// For testing scalar and vector unaligned accesses.
+uint64_t tmp[3] = {1,1,1};
+uint64_t dst[3] = {1,1,1};
+#endif
+
+TEST(sys_hwprobe, __riscv_hwprobe_misaligned_scalar) {
+#if defined(__riscv)
+ uint8_t* p = (uint8_t*)tmp + 1;
+ ASSERT_NE(0U, scalar_cast(p));
+ ASSERT_NE(0U, scalar_memcpy(p));
+#else
+ GTEST_SKIP() << "__riscv_hwprobe requires riscv64";
+#endif
+}
+
+TEST(sys_hwprobe, __riscv_hwprobe_misaligned_vector) {
+#if defined(__riscv)
+ uint8_t* p = (uint8_t*)tmp + 1;
+ uint8_t* d = (uint8_t*)dst + 1;
+
+ ASSERT_NE(0U, vector_ldst(d, p));
+ ASSERT_NE(0U, vector_memcpy(d, p));
+ ASSERT_NE(0U, vector_ldst64(d, p));
+#else
+ GTEST_SKIP() << "__riscv_hwprobe requires riscv64";
+#endif
+}
+
TEST(sys_hwprobe, __riscv_hwprobe) {
#if defined(__riscv) && __has_include(<sys/hwprobe.h>)
riscv_hwprobe probes[] = {{.key = RISCV_HWPROBE_KEY_IMA_EXT_0},
@@ -82,4 +144,4 @@
#else
GTEST_SKIP() << "__riscv_hwprobe requires riscv64";
#endif
-}
+}
\ No newline at end of file
diff --git a/libc/arch-x86_64/static_function_dispatch.S b/tests/sys_io_test.cpp
similarity index 71%
copy from libc/arch-x86_64/static_function_dispatch.S
copy to tests/sys_io_test.cpp
index 93ff5f2..293ceb2 100644
--- a/libc/arch-x86_64/static_function_dispatch.S
+++ b/tests/sys_io_test.cpp
@@ -1,5 +1,5 @@
/*
- * Copyright (C) 2022 The Android Open Source Project
+ * Copyright (C) 2024 The Android Open Source Project
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@@ -26,12 +26,28 @@
* SUCH DAMAGE.
*/
-#include <private/bionic_asm.h>
+#include <gtest/gtest.h>
-#define FUNCTION_DELEGATE(name, impl) \
-ENTRY(name); \
- jmp impl; \
-END(name)
+#include <sys/io.h>
-FUNCTION_DELEGATE(memset, memset_generic)
-FUNCTION_DELEGATE(__memset_chk, __memset_chk_generic)
+#include "utils.h"
+
+TEST(sys_io, iopl) {
+#if defined(__i386__) || defined(__x86_64__)
+ errno = 0;
+ ASSERT_EQ(-1, iopl(4));
+ ASSERT_ERRNO(EINVAL);
+#else
+ GTEST_SKIP() << "iopl requires x86/x86-64";
+#endif
+}
+
+TEST(sys_io, ioperm) {
+#if defined(__i386__) || defined(__x86_64__)
+ errno = 0;
+ ASSERT_EQ(-1, ioperm(65535, 4, 0));
+ ASSERT_ERRNO(EINVAL);
+#else
+ GTEST_SKIP() << "ioperm requires x86/x86-64";
+#endif
+}
diff --git a/tests/sys_mman_test.cpp b/tests/sys_mman_test.cpp
index df13e07..54a0b64 100644
--- a/tests/sys_mman_test.cpp
+++ b/tests/sys_mman_test.cpp
@@ -243,6 +243,20 @@
ASSERT_EQ(0, munmap(map, kPageSize));
}
+TEST(sys_mman, mremap_MREMAP_FIXED) {
+ // We're not trying to test the kernel here; that's external/ltp's job.
+ // We just want to check that optional argument (mremap() is varargs)
+ // gets passed through in an MREMAP_FIXED call.
+ void* vma1 = mmap(NULL, getpagesize(), PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ ASSERT_NE(MAP_FAILED, vma1);
+
+ void* vma2 = mmap(NULL, getpagesize(), PROT_READ, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ ASSERT_NE(MAP_FAILED, vma2);
+
+ void* vma3 = mremap(vma1, getpagesize(), getpagesize(), MREMAP_FIXED | MREMAP_MAYMOVE, vma2);
+ ASSERT_EQ(vma2, vma3);
+}
+
TEST(sys_mman, mmap_bug_27265969) {
char* base = reinterpret_cast<char*>(
mmap(nullptr, kPageSize * 2, PROT_EXEC | PROT_READ, MAP_ANONYMOUS | MAP_PRIVATE, -1, 0));
@@ -306,3 +320,30 @@
close(fd);
#endif
}
+
+TEST(sys_mseal, mseal) {
+#if defined(__GLIBC__)
+ GTEST_SKIP() << "needs glibc 2.40";
+#else
+ void* map = mmap(nullptr, kPageSize, PROT_NONE, MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
+ ASSERT_NE(MAP_FAILED, map);
+
+#if defined(__LP64__)
+ int rc = mseal(map, kPageSize, 0);
+ if (rc == -1) {
+ ASSERT_ERRNO(ENOSYS);
+ GTEST_SKIP() << "needs kernel with mseal(2)";
+ }
+ ASSERT_EQ(-1, mprotect(map, kPageSize, PROT_READ));
+ ASSERT_ERRNO(EPERM);
+#else
+ // No mseal() for ILP32.
+ errno = 0;
+ ASSERT_EQ(-1, mseal(map, kPageSize, 0));
+ ASSERT_ERRNO(ENOSYS);
+ GTEST_SKIP() << "mseal(2) is LP64-only";
+#endif
+
+ // We can't munmap() our test mapping if mseal() actually succeeded :-)
+#endif
+}
diff --git a/tests/sys_ptrace_test.cpp b/tests/sys_ptrace_test.cpp
index 93daac3..499adbb 100644
--- a/tests/sys_ptrace_test.cpp
+++ b/tests/sys_ptrace_test.cpp
@@ -41,11 +41,6 @@
using android::base::unique_fd;
-// Host libc does not define this.
-#ifndef TRAP_HWBKPT
-#define TRAP_HWBKPT 4
-#endif
-
class ChildGuard {
public:
explicit ChildGuard(pid_t pid) : pid(pid) {}
diff --git a/tests/sys_stat_test.cpp b/tests/sys_stat_test.cpp
index 126f469..50c50df 100644
--- a/tests/sys_stat_test.cpp
+++ b/tests/sys_stat_test.cpp
@@ -151,12 +151,12 @@
ASSERT_ERRNO(EINVAL);
}
-TEST(sys_stat, fchmodat_nonexistant_file) {
+TEST(sys_stat, fchmodat_nonexistent_file) {
ASSERT_EQ(-1, fchmodat(AT_FDCWD, "/blah", 0751, 0));
ASSERT_ERRNO(ENOENT);
}
-TEST(sys_stat, fchmodat_AT_SYMLINK_NOFOLLOW_nonexistant_file) {
+TEST(sys_stat, fchmodat_AT_SYMLINK_NOFOLLOW_nonexistent_file) {
ASSERT_EQ(-1, fchmodat(AT_FDCWD, "/blah", 0751, AT_SYMLINK_NOFOLLOW));
#if defined(__BIONIC__)
ASSERT_ERRNO(ENOENT);
@@ -305,7 +305,7 @@
ASSERT_EQ(0, faccessat(AT_FDCWD, "/dev/null", R_OK|W_OK, 0));
}
-TEST(sys_stat, faccessat_nonexistant) {
+TEST(sys_stat, faccessat_nonexistent) {
ASSERT_EQ(-1, faccessat(AT_FDCWD, "/blah", F_OK, AT_SYMLINK_NOFOLLOW));
#if defined(__BIONIC__)
// Android doesn't support AT_SYMLINK_NOFOLLOW
@@ -314,3 +314,26 @@
ASSERT_ERRNO(ENOENT);
#endif
}
+
+TEST(sys_stat, lchmod) {
+ TemporaryFile tf;
+ struct stat tf_sb;
+ ASSERT_EQ(0, stat(tf.path, &tf_sb));
+
+ char linkname[255];
+ snprintf(linkname, sizeof(linkname), "%s.link", tf.path);
+
+ ASSERT_EQ(0, symlink(tf.path, linkname));
+ int result = lchmod(linkname, 0751);
+ // Whether or not chmod is allowed on a symlink depends on the kernel.
+ if (result == 0) {
+ AssertSymlinkModeEquals(0751, linkname);
+ } else {
+ ASSERT_EQ(-1, result);
+ ASSERT_ERRNO(ENOTSUP);
+ }
+
+ // The target file mode shouldn't be modified.
+ AssertFileModeEquals(tf_sb.st_mode, tf.path);
+ unlink(linkname);
+}
diff --git a/tests/sys_statvfs_test.cpp b/tests/sys_statvfs_test.cpp
index 73b2a96..25256ff 100644
--- a/tests/sys_statvfs_test.cpp
+++ b/tests/sys_statvfs_test.cpp
@@ -25,7 +25,15 @@
#include <string>
template <typename StatVfsT> void Check(StatVfsT& sb) {
- EXPECT_EQ(4096U, sb.f_bsize);
+#if defined(__x86_64__)
+ // On x86_64 based 16kb page size targets, the page size in userspace is simulated to 16kb but
+ // the underlying filesystem block size would remain unchanged, i.e., 4kb.
+ // For more info:
+ // https://source.android.com/docs/core/architecture/16kb-page-size/getting-started-cf-x86-64-pgagnostic
+ EXPECT_EQ(4096, static_cast<int>(sb.f_bsize));
+#else
+ EXPECT_EQ(getpagesize(), static_cast<int>(sb.f_bsize));
+#endif
EXPECT_EQ(0U, sb.f_bfree);
EXPECT_EQ(0U, sb.f_ffree);
EXPECT_EQ(255U, sb.f_namemax);
diff --git a/tests/sys_vfs_test.cpp b/tests/sys_vfs_test.cpp
index 96fd61a..90b6da9 100644
--- a/tests/sys_vfs_test.cpp
+++ b/tests/sys_vfs_test.cpp
@@ -27,7 +27,15 @@
#include "utils.h"
template <typename StatFsT> void Check(StatFsT& sb) {
+#if defined(__x86_64__)
+ // On x86_64 based 16kb page size targets, the page size in userspace is simulated to 16kb but
+ // the underlying filesystem block size would remain unchanged, i.e., 4kb.
+ // For more info:
+ // https://source.android.com/docs/core/architecture/16kb-page-size/getting-started-cf-x86-64-pgagnostic
EXPECT_EQ(4096, static_cast<int>(sb.f_bsize));
+#else
+ EXPECT_EQ(getpagesize(), static_cast<int>(sb.f_bsize));
+#endif
EXPECT_EQ(0U, sb.f_bfree);
EXPECT_EQ(0U, sb.f_ffree);
EXPECT_EQ(255, static_cast<int>(sb.f_namelen));
diff --git a/tests/system_properties_test.cpp b/tests/system_properties_test.cpp
index 0b7f5ae..5b5e009 100644
--- a/tests/system_properties_test.cpp
+++ b/tests/system_properties_test.cpp
@@ -33,10 +33,9 @@
#if defined(__BIONIC__)
-#define _REALLY_INCLUDE_SYS__SYSTEM_PROPERTIES_H_
#include <stdlib.h>
-#include <sys/_system_properties.h>
#include <sys/mount.h>
+#include <sys/system_properties.h>
#include <system_properties/system_properties.h>
@@ -593,7 +592,13 @@
ASSERT_TRUE(system_properties.valid());
auto name = "ro.super_long_property"s;
+
+#ifdef LARGE_SYSTEM_PROPERTY_NODE
+ auto value = std::string(1024 * 1024 + 1, 'x');
+#else
auto value = std::string(128 * 1024 + 1, 'x');
+#endif
+
ASSERT_NE(0, system_properties.Add(name.c_str(), name.size(), value.c_str(), value.size()));
#else // __BIONIC__
diff --git a/tests/termios_test.cpp b/tests/termios_test.cpp
index 480f3af..19e9bfe 100644
--- a/tests/termios_test.cpp
+++ b/tests/termios_test.cpp
@@ -96,7 +96,7 @@
EXPECT_EQ(0U, (t.c_oflag & OPOST));
EXPECT_EQ(0U, (t.c_lflag & (ECHO|ECHONL|ICANON|ISIG|IEXTEN)));
EXPECT_EQ(0U, (t.c_cflag & PARENB));
- EXPECT_EQ(CS8, static_cast<int>(t.c_cflag & CSIZE));
+ EXPECT_EQ(static_cast<unsigned>(CS8), (t.c_cflag & CSIZE));
EXPECT_EQ(1, t.c_cc[VMIN]);
EXPECT_EQ(0, t.c_cc[VTIME]);
}
diff --git a/tests/time_test.cpp b/tests/time_test.cpp
index ca8e260..baafbf6 100644
--- a/tests/time_test.cpp
+++ b/tests/time_test.cpp
@@ -31,6 +31,8 @@
#include <thread>
#include "SignalUtils.h"
+#include "android-base/file.h"
+#include "android-base/strings.h"
#include "utils.h"
using namespace std::chrono_literals;
@@ -797,21 +799,41 @@
ASSERT_EQ(1, timer_create_NULL_signal_handler_invocation_count);
}
-TEST(time, timer_create_EINVAL) {
- clockid_t invalid_clock = 16;
+static int GetThreadCount() {
+ std::string status;
+ if (android::base::ReadFileToString("/proc/self/status", &status)) {
+ for (const auto& line : android::base::Split(status, "\n")) {
+ int thread_count;
+ if (sscanf(line.c_str(), "Threads: %d", &thread_count) == 1) {
+ return thread_count;
+ }
+ }
+ }
+ return -1;
+}
- // A SIGEV_SIGNAL timer is easy; the kernel does all that.
+TEST(time, timer_create_EINVAL) {
+ const clockid_t kInvalidClock = 16;
+
+ // A SIGEV_SIGNAL timer failure is easy; that's the kernel's problem.
timer_t timer_id;
- ASSERT_EQ(-1, timer_create(invalid_clock, nullptr, &timer_id));
+ ASSERT_EQ(-1, timer_create(kInvalidClock, nullptr, &timer_id));
ASSERT_ERRNO(EINVAL);
- // A SIGEV_THREAD timer is more interesting because we have stuff to clean up.
- sigevent se;
- memset(&se, 0, sizeof(se));
+ // A SIGEV_THREAD timer failure is more interesting because we have a thread
+ // to clean up (https://issuetracker.google.com/340125671).
+ sigevent se = {};
se.sigev_notify = SIGEV_THREAD;
se.sigev_notify_function = NoOpNotifyFunction;
- ASSERT_EQ(-1, timer_create(invalid_clock, &se, &timer_id));
+ ASSERT_EQ(-1, timer_create(kInvalidClock, &se, &timer_id));
ASSERT_ERRNO(EINVAL);
+
+ // timer_create() doesn't guarantee that the thread will be dead _before_
+ // it returns because that would require extra synchronization that's
+ // unnecessary in the normal (successful) case. A timeout here means we
+ // leaked a thread.
+ while (GetThreadCount() > 1) {
+ }
}
TEST(time, timer_create_multiple) {
diff --git a/tests/utils.h b/tests/utils.h
index dcb08f5..3c83b73 100644
--- a/tests/utils.h
+++ b/tests/utils.h
@@ -38,6 +38,7 @@
#endif
#include <atomic>
+#include <iomanip>
#include <string>
#include <regex>
@@ -253,7 +254,7 @@
AssertChildExited(pid, expected_exit_status, &error_msg);
if (expected_output_regex != nullptr) {
if (!std::regex_search(output_, std::regex(expected_output_regex))) {
- FAIL() << "regex " << expected_output_regex << " didn't match " << output_;
+ FAIL() << "regex " << std::quoted(expected_output_regex) << " didn't match " << std::quoted(output_);
}
}
}
diff --git a/tests/wchar_test.cpp b/tests/wchar_test.cpp
index 5256b08..a811fd8 100644
--- a/tests/wchar_test.cpp
+++ b/tests/wchar_test.cpp
@@ -556,7 +556,7 @@
} else {
// If the subject sequence begins with a <hyphen-minus>, the value resulting
// from the conversion shall be negated.
- // http://pubs.opengroup.org/onlinepubs/9699919799/functions/strtoul.html
+ // https://pubs.opengroup.org/onlinepubs/9799919799.2024edition/functions/strtoul.html
ASSERT_EQ(std::numeric_limits<T>::max(), fn(min_str, nullptr, 0)) << min_str;
}
ASSERT_EQ(std::numeric_limits<T>::max(), fn(max_str, nullptr, 0)) << max_str;
@@ -1075,10 +1075,39 @@
EXPECT_EQ(0, wcwidth(0x0300)); // Combining grave.
EXPECT_EQ(0, wcwidth(0x20dd)); // Combining enclosing circle.
- EXPECT_EQ(0, wcwidth(0x00ad)); // Soft hyphen (SHY).
EXPECT_EQ(0, wcwidth(0x200b)); // Zero width space.
}
+TEST(wchar, wcwidth_non_spacing_special_cases) {
+ if (!have_dl()) return;
+
+ // U+00AD is a soft hyphen, which normally shouldn't be rendered at all.
+ // I think the assumption here is that you elide the soft hyphen character
+ // completely in that case, and never call wcwidth() if you don't want to
+ // render it as an actual hyphen. Whereas if you do want to render it,
+ // you call wcwidth(), and 1 is the right answer. This is what Markus Kuhn's
+ // original https://www.cl.cam.ac.uk/~mgk25/ucs/wcwidth.c did,
+ // and glibc and iOS do the same.
+ // See also: https://en.wikipedia.org/wiki/Soft_hyphen#Text_to_be_formatted_by_the_recipient
+ EXPECT_EQ(1, wcwidth(0x00ad)); // Soft hyphen (SHY).
+
+ // U+115F is the Hangeul choseong filler (for a degenerate composed
+ // character missing an initial consonant (as opposed to one with a
+ // leading ieung). Since the code points for combining jungseong (medial
+ // vowels) and jongseong (trailing consonants) have width 0, the choseong
+ // (initial consonant) has width 2 to cover the entire syllable. So unless
+ // U+115f has width 2, a degenerate composed "syllable" without an initial
+ // consonant or ieung would have a total width of 0, which is silly.
+ // The following sequence is effectively "약" without the leading ieung...
+ EXPECT_EQ(2, wcwidth(0x115f)); // Hangeul choseong filler.
+ EXPECT_EQ(0, wcwidth(0x1163)); // Hangeul jungseong "ya".
+ EXPECT_EQ(0, wcwidth(0x11a8)); // Hangeul jongseong "kiyeok".
+
+ // U+1160, the jungseong filler, has width 0 because it must have been
+ // preceded by either a choseong or choseong filler.
+ EXPECT_EQ(0, wcwidth(0x1160));
+}
+
TEST(wchar, wcwidth_cjk) {
if (!have_dl()) return;
@@ -1102,8 +1131,10 @@
if (!have_dl()) return;
EXPECT_EQ(2, wcwidth(0xac00)); // Start of block.
- EXPECT_EQ(2, wcwidth(0xd7a3)); // End of defined code points in Unicode 7.
- // Undefined characters at the end of the block have width 1.
+ EXPECT_EQ(2, wcwidth(0xd7a3)); // End of defined code points as of Unicode 15.
+
+ // Undefined characters at the end of the block currently have width 1,
+ // but since they're undefined, we don't test that.
}
TEST(wchar, wcwidth_kana) {
@@ -1137,11 +1168,21 @@
EXPECT_EQ(0, wcwidth(0xe0000)); // ...through 0xe0fff.
}
-TEST(wchar, wcwidth_korean_common_non_syllables) {
+TEST(wchar, wcwidth_hangeul_compatibility_jamo) {
if (!have_dl()) return;
- EXPECT_EQ(2, wcwidth(L'ㅜ')); // Korean "crying" emoticon.
- EXPECT_EQ(2, wcwidth(L'ㅋ')); // Korean "laughing" emoticon.
+ // These are actually the *compatibility* jamo code points, *not* the regular
+ // jamo code points (U+1100-U+11FF) using a jungseong filler. If you use the
+ // Android IME to type any of these, you get these code points.
+
+ // (Half of) the Korean "crying" emoticon "ㅠㅠ".
+ // Actually U+3160 "Hangeul Letter Yu" from Hangeul Compatibility Jamo.
+ EXPECT_EQ(2, wcwidth(L'ㅠ'));
+ // The two halves of the Korean internet shorthand "ㄱㅅ" (short for 감사).
+ // Actually U+3131 "Hangeul Letter Kiyeok" and U+3145 "Hangeul Letter Sios"
+ // from Hangeul Compatibility Jamo.
+ EXPECT_EQ(2, wcwidth(L'ㄱ'));
+ EXPECT_EQ(2, wcwidth(L'ㅅ'));
}
TEST(wchar, wcswidth) {
diff --git a/tests/wctype_test.cpp b/tests/wctype_test.cpp
index 0f07956..f4b7a8f 100644
--- a/tests/wctype_test.cpp
+++ b/tests/wctype_test.cpp
@@ -109,6 +109,8 @@
EXPECT_EQ(wint_t('!'), towlower(L'!'));
EXPECT_EQ(wint_t('a'), towlower(L'a'));
EXPECT_EQ(wint_t('a'), towlower(L'A'));
+ EXPECT_EQ(wint_t('z'), towlower(L'z'));
+ EXPECT_EQ(wint_t('z'), towlower(L'Z'));
if (have_dl()) {
EXPECT_EQ(wint_t(L'ç'), towlower(L'ç'));
EXPECT_EQ(wint_t(L'ç'), towlower(L'Ç'));
@@ -125,6 +127,8 @@
EXPECT_EQ(wint_t('!'), towlower_l(L'!', l.l));
EXPECT_EQ(wint_t('a'), towlower_l(L'a', l.l));
EXPECT_EQ(wint_t('a'), towlower_l(L'A', l.l));
+ EXPECT_EQ(wint_t('z'), towlower_l(L'z', l.l));
+ EXPECT_EQ(wint_t('z'), towlower_l(L'Z', l.l));
if (have_dl()) {
EXPECT_EQ(wint_t(L'ç'), towlower_l(L'ç', l.l));
EXPECT_EQ(wint_t(L'ç'), towlower_l(L'Ç', l.l));
@@ -140,6 +144,8 @@
EXPECT_EQ(wint_t('!'), towupper(L'!'));
EXPECT_EQ(wint_t('A'), towupper(L'a'));
EXPECT_EQ(wint_t('A'), towupper(L'A'));
+ EXPECT_EQ(wint_t('Z'), towupper(L'z'));
+ EXPECT_EQ(wint_t('Z'), towupper(L'Z'));
if (have_dl()) {
EXPECT_EQ(wint_t(L'Ç'), towupper(L'ç'));
EXPECT_EQ(wint_t(L'Ç'), towupper(L'Ç'));
@@ -156,6 +162,8 @@
EXPECT_EQ(wint_t('!'), towupper_l(L'!', l.l));
EXPECT_EQ(wint_t('A'), towupper_l(L'a', l.l));
EXPECT_EQ(wint_t('A'), towupper_l(L'A', l.l));
+ EXPECT_EQ(wint_t('Z'), towupper_l(L'z', l.l));
+ EXPECT_EQ(wint_t('Z'), towupper_l(L'Z', l.l));
if (have_dl()) {
EXPECT_EQ(wint_t(L'Ç'), towupper_l(L'ç', l.l));
EXPECT_EQ(wint_t(L'Ç'), towupper_l(L'Ç', l.l));
@@ -218,34 +226,64 @@
EXPECT_EQ(0, iswctype_l(WEOF, wctype_l("alnum", l.l), l.l));
}
-TEST(wctype, towctrans) {
+TEST(wctype, wctrans) {
EXPECT_TRUE(wctrans("tolower") != nullptr);
EXPECT_TRUE(wctrans("toupper") != nullptr);
+ errno = 0;
EXPECT_TRUE(wctrans("monkeys") == nullptr);
-}
-
-TEST(wctype, towctrans_l) {
- UtfLocale l;
- EXPECT_TRUE(wctrans_l("tolower", l.l) != nullptr);
- EXPECT_TRUE(wctrans_l("toupper", l.l) != nullptr);
-
- EXPECT_TRUE(wctrans_l("monkeys", l.l) == nullptr);
-}
-
-TEST(wctype, wctrans) {
- EXPECT_EQ(wint_t('a'), towctrans(L'A', wctrans("tolower")));
- EXPECT_EQ(WEOF, towctrans(WEOF, wctrans("tolower")));
-
- EXPECT_EQ(wint_t('A'), towctrans(L'a', wctrans("toupper")));
- EXPECT_EQ(WEOF, towctrans(WEOF, wctrans("toupper")));
+ #if defined(__BIONIC__)
+ // Android/FreeBSD/iOS set errno, but musl/glibc don't.
+ EXPECT_ERRNO(EINVAL);
+ #endif
}
TEST(wctype, wctrans_l) {
UtfLocale l;
- EXPECT_EQ(wint_t('a'), towctrans_l(L'A', wctrans_l("tolower", l.l), l.l));
- EXPECT_EQ(WEOF, towctrans_l(WEOF, wctrans_l("tolower", l.l), l.l));
+ EXPECT_TRUE(wctrans_l("tolower", l.l) != nullptr);
+ EXPECT_TRUE(wctrans_l("toupper", l.l) != nullptr);
- EXPECT_EQ(wint_t('A'), towctrans_l(L'a', wctrans_l("toupper", l.l), l.l));
- EXPECT_EQ(WEOF, towctrans_l(WEOF, wctrans_l("toupper", l.l), l.l));
+ errno = 0;
+ EXPECT_TRUE(wctrans_l("monkeys", l.l) == nullptr);
+ #if defined(__BIONIC__)
+ // Android/FreeBSD/iOS set errno, but musl/glibc don't.
+ EXPECT_ERRNO(EINVAL);
+ #endif
+}
+
+TEST(wctype, towctrans) {
+ wctrans_t lower = wctrans("tolower");
+ EXPECT_EQ(wint_t('a'), towctrans(L'A', lower));
+ EXPECT_EQ(WEOF, towctrans(WEOF, lower));
+
+ wctrans_t upper = wctrans("toupper");
+ EXPECT_EQ(wint_t('A'), towctrans(L'a', upper));
+ EXPECT_EQ(WEOF, towctrans(WEOF, upper));
+
+ wctrans_t invalid = wctrans("monkeys");
+ errno = 0;
+ EXPECT_EQ(wint_t('a'), towctrans(L'a', invalid));
+ #if defined(__BIONIC__)
+ // Android/FreeBSD/iOS set errno, but musl/glibc don't.
+ EXPECT_ERRNO(EINVAL);
+ #endif
+}
+
+TEST(wctype, towctrans_l) {
+ UtfLocale l;
+ wctrans_t lower = wctrans_l("tolower", l.l);
+ EXPECT_EQ(wint_t('a'), towctrans_l(L'A', lower, l.l));
+ EXPECT_EQ(WEOF, towctrans_l(WEOF, lower, l.l));
+
+ wctrans_t upper = wctrans_l("toupper", l.l);
+ EXPECT_EQ(wint_t('A'), towctrans_l(L'a', upper, l.l));
+ EXPECT_EQ(WEOF, towctrans_l(WEOF, upper, l.l));
+
+ wctrans_t invalid = wctrans_l("monkeys", l.l);
+ errno = 0;
+ EXPECT_EQ(wint_t('a'), towctrans_l(L'a', invalid, l.l));
+ #if defined(__BIONIC__)
+ // Android/FreeBSD/iOS set errno, but musl/glibc don't.
+ EXPECT_ERRNO(EINVAL);
+ #endif
}
diff --git a/tools/versioner/src/DeclarationDatabase.cpp b/tools/versioner/src/DeclarationDatabase.cpp
index a029c3b..9794286 100644
--- a/tools/versioner/src/DeclarationDatabase.cpp
+++ b/tools/versioner/src/DeclarationDatabase.cpp
@@ -103,7 +103,7 @@
}
std::string declaration_name = getDeclName(named_decl);
- bool is_extern = named_decl->getFormalLinkage() == ExternalLinkage;
+ bool is_extern = named_decl->getFormalLinkage() == Linkage::External;
bool is_definition = false;
bool no_guard = false;
bool fortify_inline = false;
diff --git a/tools/versioner/src/Driver.cpp b/tools/versioner/src/Driver.cpp
index 24dc5ec..79672ac 100644
--- a/tools/versioner/src/Driver.cpp
+++ b/tools/versioner/src/Driver.cpp
@@ -42,7 +42,7 @@
#include <llvm/ADT/SmallVector.h>
#include <llvm/ADT/StringRef.h>
#include <llvm/Option/Option.h>
-#include <llvm/Support/Host.h>
+#include <llvm/TargetParser/Host.h>
#include <llvm/Support/VirtualFileSystem.h>
#include "Arch.h"
diff --git a/tools/versioner/src/Preprocessor.cpp b/tools/versioner/src/Preprocessor.cpp
index 47b9017..74d5ba0 100644
--- a/tools/versioner/src/Preprocessor.cpp
+++ b/tools/versioner/src/Preprocessor.cpp
@@ -448,7 +448,7 @@
while (FTSENT* ent = fts_read(fts.get())) {
llvm::StringRef path = ent->fts_path;
- if (!path.startswith(src_dir)) {
+ if (!path.starts_with(src_dir)) {
err(1, "path '%s' doesn't start with source dir '%s'", ent->fts_path, src_dir.c_str());
}
@@ -489,7 +489,7 @@
// TODO: Merge adjacent non-identical guards.
mergeGuards(file_lines[file_path.str()], guard_map);
- if (!file_path.startswith(src_dir)) {
+ if (!file_path.starts_with(src_dir)) {
errx(1, "input file %s is not in %s\n", file_path.str().c_str(), src_dir.c_str());
}
diff --git a/tools/versioner/src/Utils.cpp b/tools/versioner/src/Utils.cpp
index dc6b5dd..d2bb1a8 100644
--- a/tools/versioner/src/Utils.cpp
+++ b/tools/versioner/src/Utils.cpp
@@ -83,7 +83,7 @@
}
llvm::StringRef StripPrefix(llvm::StringRef string, llvm::StringRef prefix) {
- if (string.startswith(prefix)) {
+ if (string.starts_with(prefix)) {
return string.drop_front(prefix.size());
}
return string;
diff --git a/tools/versioner/src/versioner.cpp b/tools/versioner/src/versioner.cpp
index 5afa00b..37c8bac 100644
--- a/tools/versioner/src/versioner.cpp
+++ b/tools/versioner/src/versioner.cpp
@@ -142,11 +142,11 @@
auto new_end = std::remove_if(headers.begin(), headers.end(), [&arch](llvm::StringRef header) {
for (const auto& it : ignored_headers) {
- if (it.second.find(arch) == it.second.end()) {
+ if (!it.second.contains(arch)) {
continue;
}
- if (header.endswith("/" + it.first)) {
+ if (header.ends_with("/" + it.first)) {
return true;
}
}