From ec86d4dec47597069377d963c5ca2bd99f49e16c Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 14 Jan 2020 14:24:12 -0800 Subject: [PATCH 01/30] Improvements to wasi-headers tool (#160) * wasi-headers: update WASI submodule, handle changes to witx ast * wasi-headers: restructure lib and exe to be more flexible just factor out some of the hard-coded stuff --- tools/wasi-headers/Cargo.toml | 5 +- tools/wasi-headers/WASI | 2 +- tools/wasi-headers/src/c_header.rs | 73 ++++++++++++++++++++++++++---- tools/wasi-headers/src/lib.rs | 26 +++++++---- tools/wasi-headers/src/main.rs | 59 ++++++++++++++++++++++-- tools/wasi-headers/tests/verify.rs | 12 +++-- 6 files changed, 150 insertions(+), 27 deletions(-) diff --git a/tools/wasi-headers/Cargo.toml b/tools/wasi-headers/Cargo.toml index 7c519ce..018ca46 100644 --- a/tools/wasi-headers/Cargo.toml +++ b/tools/wasi-headers/Cargo.toml @@ -1,7 +1,7 @@ [package] name = "wasi-headers" -version = "0.0.0" -authors = ["Dan Gohman "] +version = "0.0.1" +authors = ["Dan Gohman ", "Pat Hickey "] license = "Apache-2.0" edition = "2018" publish = false @@ -10,6 +10,7 @@ publish = false heck = "0.3.1" witx = { path = "WASI/tools/witx" } anyhow = "1.0.22" +clap = "2.23" [dev-dependencies] diff = "0.1.11" diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 8ff4e84..04d4eba 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 8ff4e845d7baf48bf7cf7b6d9cc2a32a973da04e +Subproject commit 04d4eba571dc1d6fe9ab129ea9343911bcc256dc diff --git a/tools/wasi-headers/src/c_header.rs b/tools/wasi-headers/src/c_header.rs index 04556d3..d37094a 100644 --- a/tools/wasi-headers/src/c_header.rs +++ b/tools/wasi-headers/src/c_header.rs @@ -78,9 +78,10 @@ fn print_datatype(ret: &mut String, nt: &NamedType) { ret.push_str(" */\n"); } - match &nt.dt { + match &nt.tref { TypeRef::Value(v) => match &**v { Type::Enum(e) => print_enum(ret, &nt.name, e), + Type::Int(i) => print_int(ret, &nt.name, i), Type::Flags(f) => print_flags(ret, &nt.name, f), Type::Struct(s) => print_struct(ret, &nt.name, s), Type::Union(u) => print_union(ret, &nt.name, u), @@ -88,9 +89,9 @@ fn print_datatype(ret: &mut String, nt: &NamedType) { Type::Builtin { .. } | Type::Array { .. } | Type::Pointer { .. } - | Type::ConstPointer { .. } => print_alias(ret, &nt.name, &nt.dt), + | Type::ConstPointer { .. } => print_alias(ret, &nt.name, &nt.tref), }, - TypeRef::Name(_) => print_alias(ret, &nt.name, &nt.dt), + TypeRef::Name(_) => print_alias(ret, &nt.name, &nt.tref), } } @@ -147,6 +148,46 @@ fn print_enum(ret: &mut String, name: &Id, e: &EnumDatatype) { } } +fn print_int(ret: &mut String, name: &Id, i: &IntDatatype) { + ret.push_str(&format!( + "typedef {} __wasi_{}_t;\n", + intrepr_name(i.repr), + ident_name(name) + )); + ret.push_str("\n"); + + for (index, const_) in i.consts.iter().enumerate() { + if !const_.docs.is_empty() { + ret.push_str("/**\n"); + for line in const_.docs.lines() { + ret.push_str(&format!(" * {}\n", line)); + } + ret.push_str(" */\n"); + } + ret.push_str(&format!( + "#define __WASI_{}_{} ({}({}))\n", + ident_name(&name).to_shouty_snake_case(), + ident_name(&const_.name).to_shouty_snake_case(), + intrepr_const(i.repr), + index + )); + ret.push_str("\n"); + } + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + i.repr.mem_size() + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + i.repr.mem_align() + )); + + ret.push_str("\n"); +} + fn print_flags(ret: &mut String, name: &Id, f: &FlagsDatatype) { ret.push_str(&format!( "typedef {} __wasi_{}_t;\n", @@ -377,7 +418,10 @@ fn ident_name(i: &Id) -> String { fn builtin_type_name(b: BuiltinType) -> &'static str { match b { - BuiltinType::String => "string", + BuiltinType::String | BuiltinType::Char8 => { + panic!("no type name for string or char8 builtins") + } + BuiltinType::USize => "size_t", BuiltinType::U8 => "uint8_t", BuiltinType::U16 => "uint16_t", BuiltinType::U32 => "uint32_t", @@ -392,13 +436,26 @@ fn builtin_type_name(b: BuiltinType) -> &'static str { } fn typeref_name(tref: &TypeRef) -> String { + match &*tref.type_() { + Type::Builtin(BuiltinType::String) | Type::Builtin(BuiltinType::Char8) | Type::Array(_) => { + panic!("unsupported grammar: cannot construct name of string or array",) + } + _ => {} + } + match tref { - TypeRef::Name(named_type) => format!("__wasi_{}_t", named_type.name.as_str()), - TypeRef::Value(anon_type) => match &**anon_type { - Type::Builtin(b) => builtin_type_name(*b).to_string(), - Type::Array(_) => unreachable!("arrays should be special-cased"), + TypeRef::Name(named_type) => match &*named_type.type_() { Type::Pointer(p) => format!("{} *", typeref_name(&*p)), Type::ConstPointer(p) => format!("const {} *", typeref_name(&*p)), + Type::Array(_) => unreachable!("arrays excluded above"), + _ => format!("__wasi_{}_t", named_type.name.as_str()), + }, + TypeRef::Value(anon_type) => match &**anon_type { + Type::Array(_) => unreachable!("arrays excluded above"), + Type::Builtin(b) => builtin_type_name(*b).to_string(), + Type::Pointer(p) => format!("{} *", typeref_name(&*p)), + Type::ConstPointer(p) => format!("const {} *", typeref_name(&*p)), + Type::Int(i) => format!("{}", intrepr_name(i.repr)), Type::Struct { .. } | Type::Union { .. } | Type::Enum { .. } diff --git a/tools/wasi-headers/src/lib.rs b/tools/wasi-headers/src/lib.rs index a382621..8dc6b04 100644 --- a/tools/wasi-headers/src/lib.rs +++ b/tools/wasi-headers/src/lib.rs @@ -2,17 +2,12 @@ mod c_header; use anyhow::{anyhow, Result}; use c_header::to_c_header; -use std::fs::read_dir; +use std::fs; use std::io; +use std::path::PathBuf; use witx::load; -pub fn generate() -> Result { - let mut inputs = read_dir("WASI/phases/snapshot/witx")? - .map(|res| res.map(|e| e.path())) - .collect::, io::Error>>()?; - - inputs.sort(); - +pub fn generate(inputs: &[PathBuf]) -> Result { // TODO: drop the anyhow! part once witx switches to anyhow. let doc = load(&inputs).map_err(|e| anyhow!(e.to_string()))?; @@ -24,3 +19,18 @@ pub fn generate() -> Result { Ok(to_c_header(&doc, &inputs_str)) } + +pub fn snapshot_witx_files() -> Result> { + let snapshot_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("WASI/phases/snapshot/witx"); + let mut inputs = fs::read_dir(snapshot_dir)? + .map(|res| res.map(|e| e.path())) + .collect::, io::Error>>()?; + + inputs.sort(); + Ok(inputs) +} + +pub fn libc_wasi_api_header() -> PathBuf { + PathBuf::from(env!("CARGO_MANIFEST_DIR")) + .join("../../libc-bottom-half/headers/public/wasi/api.h") +} diff --git a/tools/wasi-headers/src/main.rs b/tools/wasi-headers/src/main.rs index 7cb3c58..23bff0e 100644 --- a/tools/wasi-headers/src/main.rs +++ b/tools/wasi-headers/src/main.rs @@ -1,11 +1,60 @@ +#[macro_use] +extern crate clap; + use anyhow::Result; +use clap::{Arg, SubCommand}; use std::fs::File; use std::io::Write; -use wasi_headers::generate; +use std::path::PathBuf; +use wasi_headers::{generate, libc_wasi_api_header, snapshot_witx_files}; -pub fn main() -> Result<()> { - let c_header = generate()?; - let mut file = File::create("../../libc-bottom-half/headers/public/wasi/api.h")?; - file.write_all(c_header.as_bytes())?; +struct GenerateCommand { + /// Input witx file + inputs: Vec, + /// Output header file + output: PathBuf, +} + +impl GenerateCommand { + pub fn execute(&self) -> Result<()> { + let c_header = generate(&self.inputs)?; + let mut file = File::create(&self.output)?; + file.write_all(c_header.as_bytes())?; + Ok(()) + } +} + +fn main() -> Result<()> { + let matches = app_from_crate!() + .arg(Arg::with_name("inputs").required(true).multiple(true)) + .arg( + Arg::with_name("output") + .short("o") + .long("output") + .takes_value(true) + .required(true), + ) + .subcommand( + SubCommand::with_name("generate-libc") + .about("generate libc api.h from current snapshot"), + ) + .get_matches(); + + let cmd = if matches.subcommand_matches("generate-libc").is_some() { + let inputs = snapshot_witx_files()?; + let output = libc_wasi_api_header(); + GenerateCommand { inputs, output } + } else { + GenerateCommand { + inputs: matches + .values_of("inputs") + .expect("inputs required") + .map(PathBuf::from) + .collect(), + output: PathBuf::from(matches.value_of("output").expect("output required")), + } + }; + + cmd.execute()?; Ok(()) } diff --git a/tools/wasi-headers/tests/verify.rs b/tools/wasi-headers/tests/verify.rs index f448fd7..5ff8327 100644 --- a/tools/wasi-headers/tests/verify.rs +++ b/tools/wasi-headers/tests/verify.rs @@ -1,7 +1,11 @@ +use std::fs; + #[test] fn assert_same_as_src() { - let actual = include_str!("../../../libc-bottom-half/headers/public/wasi/api.h"); - let expected = wasi_headers::generate().expect("header generation should succeed"); + let actual = + fs::read_to_string(wasi_headers::libc_wasi_api_header()).expect("read libc wasi/api.h"); + let witx_files = wasi_headers::snapshot_witx_files().expect("parse snapshot witx files"); + let expected = wasi_headers::generate(&witx_files).expect("header generation"); if actual == expected { return; } @@ -63,7 +67,9 @@ fn assert_same_as_src() { } eprintln!(); - eprintln!("To regenerate the files, run `cd tools/wasi-headers && cargo run`."); + eprintln!( + "To regenerate the files, run `cd tools/wasi-headers && cargo run -- generate-libc`." + ); eprintln!(); panic!(); } From 12f5832b45c7450f8320db271334081247191d58 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 16 Jan 2020 16:00:37 -0800 Subject: [PATCH 02/30] Convert more wasi-libc code to `//`-style comments. (#153) This is purely a style change, in accordance with #116. --- dlmalloc/src/dlmalloc.c | 68 +++++++++++++++++++---------------------- 1 file changed, 31 insertions(+), 37 deletions(-) diff --git a/dlmalloc/src/dlmalloc.c b/dlmalloc/src/dlmalloc.c index 5801acb..dab8df5 100644 --- a/dlmalloc/src/dlmalloc.c +++ b/dlmalloc/src/dlmalloc.c @@ -1,74 +1,68 @@ -/* - * This file is a wrapper around malloc.c, which is the upstream source file. - * It sets configuration flags and controls which symbols are exported. - */ +// This file is a wrapper around malloc.c, which is the upstream source file. +// It sets configuration flags and controls which symbols are exported. #include #include -/* Define configuration macros for dlmalloc. */ +// Define configuration macros for dlmalloc. -/* WebAssembly doesn't have mmap-style memory allocation. */ +// WebAssembly doesn't have mmap-style memory allocation. #define HAVE_MMAP 0 -/* WebAssembly doesn't support shrinking linear memory. */ +// WebAssembly doesn't support shrinking linear memory. #define MORECORE_CANNOT_TRIM 1 -/* Disable sanity checks to reduce code size. */ +// Disable sanity checks to reduce code size. #define ABORT __builtin_unreachable() -/* If threads are enabled, enable support for threads. */ +// If threads are enabled, enable support for threads. #ifdef _REENTRANT #define USE_LOCKS 1 #endif -/* Make malloc deterministic. */ +// Make malloc deterministic. #define LACKS_TIME_H 1 -/* Disable malloc statistics generation to reduce code size. */ +// Disable malloc statistics generation to reduce code size. #define NO_MALLINFO 1 #define NO_MALLOC_STATS 1 -/* Align malloc regions to 16, to avoid unaligned SIMD accesses. */ +// Align malloc regions to 16, to avoid unaligned SIMD accesses. #define MALLOC_ALIGNMENT 16 -/* - * Declare errno values used by dlmalloc. We define them like this to avoid - * putting specific errno values in the ABI. - */ +// Declare errno values used by dlmalloc. We define them like this to avoid +// putting specific errno values in the ABI. extern const int __ENOMEM; #define ENOMEM __ENOMEM extern const int __EINVAL; #define EINVAL __EINVAL -/* - * Define USE_DL_PREFIX so that we leave dlmalloc's names prefixed with 'dl'. - * We define them as "static", and we wrap them with public names below. This - * serves two purposes: - * - * One is to make it easy to control which symbols are exported; dlmalloc - * defines several non-standard functions and we wish to explicitly control - * which functions are part of our public-facing interface. - * - * The other is to protect against compilers optimizing based on the assumption - * that they know what functions with names like "malloc" do. Code in the - * implementation will call functions like "dlmalloc" and assume it can use - * the resulting pointers to access the metadata outside of the nominally - * allocated objects. However, if the function were named "malloc", compilers - * might see code like that and assume it has undefined behavior and can be - * optimized away. By using "dlmalloc" in the implementation, we don't need - * -fno-builtin to avoid this problem. - */ +// Define USE_DL_PREFIX so that we leave dlmalloc's names prefixed with 'dl'. +// We define them as "static", and we wrap them with public names below. This +// serves two purposes: +// +// One is to make it easy to control which symbols are exported; dlmalloc +// defines several non-standard functions and we wish to explicitly control +// which functions are part of our public-facing interface. +// +// The other is to protect against compilers optimizing based on the assumption +// that they know what functions with names like "malloc" do. Code in the +// implementation will call functions like "dlmalloc" and assume it can use +// the resulting pointers to access the metadata outside of the nominally +// allocated objects. However, if the function were named "malloc", compilers +// might see code like that and assume it has undefined behavior and can be +// optimized away. By using "dlmalloc" in the implementation, we don't need +// -fno-builtin to avoid this problem. #define USE_DL_PREFIX 1 #define DLMALLOC_EXPORT static inline -/* This isn't declared with DLMALLOC_EXPORT so make it static explicitly. */ +// This isn't declared with DLMALLOC_EXPORT so make it static explicitly. static size_t dlmalloc_usable_size(void*); -/* Include the upstream dlmalloc's malloc.c. */ +// Include the upstream dlmalloc's malloc.c. #include "malloc.c" -/* Export the public names. */ +// Export the public names. void *malloc(size_t size) { return dlmalloc(size); From 37c663f2f020d69b2f9017e27cae214ef584f1a4 Mon Sep 17 00:00:00 2001 From: Daniel Bevenius Date: Fri, 7 Feb 2020 14:18:10 +0100 Subject: [PATCH 03/30] Correct minor typo in c_headers.rs (#166) The header api.h was update using the following command: $ cd tools/wasi-headers $ cargo run -- WASI/phases/snapshot/witx/typenames.witx \ WASI/phases/snapshot/witx/wasi_snapshot_preview1.witx \ --output ../../libc-bottom-half/headers/public/wasi/api.h --- libc-bottom-half/headers/public/wasi/api.h | 2 +- tools/wasi-headers/src/c_header.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/libc-bottom-half/headers/public/wasi/api.h b/libc-bottom-half/headers/public/wasi/api.h index a9683e6..2033d6b 100644 --- a/libc-bottom-half/headers/public/wasi/api.h +++ b/libc-bottom-half/headers/public/wasi/api.h @@ -7,7 +7,7 @@ * and defined values (macros). * * The interface described here is greatly inspired by [CloudABI]'s clean, - * thoughtfully-designed, cabability-oriented, POSIX-style API. + * thoughtfully-designed, capability-oriented, POSIX-style API. * * [CloudABI]: https://github.com/NuxiNL/cloudlibc * [WASI]: https://github.com/WebAssembly/WASI/ diff --git a/tools/wasi-headers/src/c_header.rs b/tools/wasi-headers/src/c_header.rs index d37094a..b379bca 100644 --- a/tools/wasi-headers/src/c_header.rs +++ b/tools/wasi-headers/src/c_header.rs @@ -14,7 +14,7 @@ pub(crate) fn to_c_header(doc: &Document, inputs_str: &str) -> String { * and defined values (macros). * * The interface described here is greatly inspired by [CloudABI]'s clean, - * thoughtfully-designed, cabability-oriented, POSIX-style API. + * thoughtfully-designed, capability-oriented, POSIX-style API. * * [CloudABI]: https://github.com/NuxiNL/cloudlibc * [WASI]: https://github.com/WebAssembly/WASI/ From c6f2c0517f6121c594dffcfe061ae3ade8c1921e Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Fri, 7 Feb 2020 13:21:18 -0800 Subject: [PATCH 04/30] gen-headers: Generate assertions of layout from witx (#149) * use pch/layout branch for witx; generate assertions of layout * address review comments, add asserts for handle * change wasm32 support comment to a preprocessor error * expose `to_c_header` in wasi-headers crate for use in external test harness * main.rs: inputs and output arguments are optional so that generate-libc command works * regen header --- libc-bottom-half/headers/public/wasi/api.h | 227 ++++++++++++++++++--- tools/wasi-headers/WASI | 2 +- tools/wasi-headers/src/c_header.rs | 96 ++++++++- tools/wasi-headers/src/lib.rs | 2 +- tools/wasi-headers/src/main.rs | 4 +- 5 files changed, 302 insertions(+), 29 deletions(-) diff --git a/libc-bottom-half/headers/public/wasi/api.h b/libc-bottom-half/headers/public/wasi/api.h index 2033d6b..22c4125 100644 --- a/libc-bottom-half/headers/public/wasi/api.h +++ b/libc-bottom-half/headers/public/wasi/api.h @@ -20,6 +20,10 @@ #error is only supported on WASI platforms. #endif +#ifndef __wasm32__ +#error only supports wasm32; doesn't yet support wasm64 +#endif + #include #include @@ -31,6 +35,7 @@ _Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout"); _Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout"); _Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout"); _Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout"); +_Static_assert(_Alignof(void*) == 4, "non-wasi data layout"); #ifdef __cplusplus extern "C" { @@ -40,16 +45,25 @@ extern "C" { #define __WASI_DIRCOOKIE_START (UINT64_C(0)) typedef __SIZE_TYPE__ __wasi_size_t; +_Static_assert(sizeof(__wasi_size_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_size_t) == 4, "witx calculated align"); + /** * Non-negative file size or length of a region within a file. */ typedef uint64_t __wasi_filesize_t; +_Static_assert(sizeof(__wasi_filesize_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_filesize_t) == 8, "witx calculated align"); + /** * Timestamp in nanoseconds. */ typedef uint64_t __wasi_timestamp_t; +_Static_assert(sizeof(__wasi_timestamp_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_timestamp_t) == 8, "witx calculated align"); + /** * Identifiers for clocks. */ @@ -79,6 +93,9 @@ typedef uint32_t __wasi_clockid_t; */ #define __WASI_CLOCKID_THREAD_CPUTIME_ID (UINT32_C(3)) +_Static_assert(sizeof(__wasi_clockid_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_clockid_t) == 4, "witx calculated align"); + /** * Error codes returned by functions. * Not all of these error codes are returned by the functions provided by this @@ -472,6 +489,9 @@ typedef uint16_t __wasi_errno_t; */ #define __WASI_ERRNO_NOTCAPABLE (UINT16_C(76)) +_Static_assert(sizeof(__wasi_errno_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_errno_t) == 2, "witx calculated align"); + /** * File descriptor rights, determining which actions may be performed. */ @@ -480,7 +500,7 @@ typedef uint64_t __wasi_rights_t; /** * The right to invoke `fd_datasync`. * If `path_open` is set, includes the right to invoke - * `path_open` with `fdflag::dsync`. + * `path_open` with `fdflags::dsync`. */ #define __WASI_RIGHTS_FD_DATASYNC (UINT64_C(1)) @@ -503,13 +523,13 @@ typedef uint64_t __wasi_rights_t; /** * The right to invoke `fd_sync`. * If `path_open` is set, includes the right to invoke - * `path_open` with `fdflag::rsync` and `fdflag::dsync`. + * `path_open` with `fdflags::rsync` and `fdflags::dsync`. */ #define __WASI_RIGHTS_FD_SYNC (UINT64_C(16)) /** * The right to invoke `fd_seek` in such a way that the file offset - * remains unaltered (i.e., `WHENCE_CUR` with offset zero), or to + * remains unaltered (i.e., `whence::cur` with offset zero), or to * invoke `fd_tell`. */ #define __WASI_RIGHTS_FD_TELL (UINT64_C(32)) @@ -634,11 +654,17 @@ typedef uint64_t __wasi_rights_t; */ #define __WASI_RIGHTS_SOCK_SHUTDOWN (UINT64_C(268435456)) +_Static_assert(sizeof(__wasi_rights_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_rights_t) == 8, "witx calculated align"); + /** * A file descriptor index. */ typedef uint32_t __wasi_fd_t; +_Static_assert(sizeof(__wasi_fd_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_fd_t) == 4, "witx calculated align"); + /** * A region of memory for scatter/gather reads. */ @@ -655,6 +681,11 @@ typedef struct __wasi_iovec_t { } __wasi_iovec_t; +_Static_assert(sizeof(__wasi_iovec_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_iovec_t) == 4, "witx calculated align"); +_Static_assert(offsetof(__wasi_iovec_t, buf) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_iovec_t, buf_len) == 4, "witx calculated offset"); + /** * A region of memory for scatter/gather writes. */ @@ -671,11 +702,19 @@ typedef struct __wasi_ciovec_t { } __wasi_ciovec_t; +_Static_assert(sizeof(__wasi_ciovec_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_ciovec_t) == 4, "witx calculated align"); +_Static_assert(offsetof(__wasi_ciovec_t, buf) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_ciovec_t, buf_len) == 4, "witx calculated offset"); + /** * Relative offset within a file. */ typedef int64_t __wasi_filedelta_t; +_Static_assert(sizeof(__wasi_filedelta_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_filedelta_t) == 8, "witx calculated align"); + /** * The position relative to which to set the offset of the file descriptor. */ @@ -696,6 +735,9 @@ typedef uint8_t __wasi_whence_t; */ #define __WASI_WHENCE_END (UINT8_C(2)) +_Static_assert(sizeof(__wasi_whence_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_whence_t) == 1, "witx calculated align"); + /** * A reference to the offset of a directory entry. * @@ -703,16 +745,25 @@ typedef uint8_t __wasi_whence_t; */ typedef uint64_t __wasi_dircookie_t; +_Static_assert(sizeof(__wasi_dircookie_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_dircookie_t) == 8, "witx calculated align"); + /** * The type for the $d_namlen field of $dirent. */ typedef uint32_t __wasi_dirnamlen_t; +_Static_assert(sizeof(__wasi_dirnamlen_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_dirnamlen_t) == 4, "witx calculated align"); + /** * File serial number that is unique within its file system. */ typedef uint64_t __wasi_inode_t; +_Static_assert(sizeof(__wasi_inode_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_inode_t) == 8, "witx calculated align"); + /** * The type of a file descriptor or file. */ @@ -758,6 +809,9 @@ typedef uint8_t __wasi_filetype_t; */ #define __WASI_FILETYPE_SYMBOLIC_LINK (UINT8_C(7)) +_Static_assert(sizeof(__wasi_filetype_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_filetype_t) == 1, "witx calculated align"); + /** * A directory entry. */ @@ -784,6 +838,13 @@ typedef struct __wasi_dirent_t { } __wasi_dirent_t; +_Static_assert(sizeof(__wasi_dirent_t) == 24, "witx calculated size"); +_Static_assert(_Alignof(__wasi_dirent_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_dirent_t, d_next) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_dirent_t, d_ino) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_dirent_t, d_namlen) == 16, "witx calculated offset"); +_Static_assert(offsetof(__wasi_dirent_t, d_type) == 20, "witx calculated offset"); + /** * File or memory access pattern advisory information. */ @@ -819,6 +880,9 @@ typedef uint8_t __wasi_advice_t; */ #define __WASI_ADVICE_NOREUSE (UINT8_C(5)) +_Static_assert(sizeof(__wasi_advice_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_advice_t) == 1, "witx calculated align"); + /** * File descriptor flags. */ @@ -851,6 +915,9 @@ typedef uint16_t __wasi_fdflags_t; */ #define __WASI_FDFLAGS_SYNC (UINT16_C(16)) +_Static_assert(sizeof(__wasi_fdflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_fdflags_t) == 2, "witx calculated align"); + /** * File descriptor attributes. */ @@ -878,37 +945,50 @@ typedef struct __wasi_fdstat_t { } __wasi_fdstat_t; +_Static_assert(sizeof(__wasi_fdstat_t) == 24, "witx calculated size"); +_Static_assert(_Alignof(__wasi_fdstat_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_fdstat_t, fs_filetype) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_fdstat_t, fs_flags) == 2, "witx calculated offset"); +_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_base) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_fdstat_t, fs_rights_inheriting) == 16, "witx calculated offset"); + /** * Identifier for a device containing a file system. Can be used in combination * with `inode` to uniquely identify a file or directory in the filesystem. */ typedef uint64_t __wasi_device_t; +_Static_assert(sizeof(__wasi_device_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_device_t) == 8, "witx calculated align"); + /** * Which file time attributes to adjust. */ typedef uint16_t __wasi_fstflags_t; /** - * Adjust the last data access timestamp to the value stored in `filestat::st_atim`. + * Adjust the last data access timestamp to the value stored in `filestat::atim`. */ #define __WASI_FSTFLAGS_ATIM (UINT16_C(1)) /** - * Adjust the last data access timestamp to the time of clock `clock::realtime`. + * Adjust the last data access timestamp to the time of clock `clockid::realtime`. */ #define __WASI_FSTFLAGS_ATIM_NOW (UINT16_C(2)) /** - * Adjust the last data modification timestamp to the value stored in `filestat::st_mtim`. + * Adjust the last data modification timestamp to the value stored in `filestat::mtim`. */ #define __WASI_FSTFLAGS_MTIM (UINT16_C(4)) /** - * Adjust the last data modification timestamp to the time of clock `clock::realtime`. + * Adjust the last data modification timestamp to the time of clock `clockid::realtime`. */ #define __WASI_FSTFLAGS_MTIM_NOW (UINT16_C(8)) +_Static_assert(sizeof(__wasi_fstflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_fstflags_t) == 2, "witx calculated align"); + /** * Flags determining the method of how paths are resolved. */ @@ -919,6 +999,9 @@ typedef uint32_t __wasi_lookupflags_t; */ #define __WASI_LOOKUPFLAGS_SYMLINK_FOLLOW (UINT32_C(1)) +_Static_assert(sizeof(__wasi_lookupflags_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_lookupflags_t) == 4, "witx calculated align"); + /** * Open flags used by `path_open`. */ @@ -944,11 +1027,17 @@ typedef uint16_t __wasi_oflags_t; */ #define __WASI_OFLAGS_TRUNC (UINT16_C(8)) +_Static_assert(sizeof(__wasi_oflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_oflags_t) == 2, "witx calculated align"); + /** * Number of hard links to an inode. */ typedef uint64_t __wasi_linkcount_t; +_Static_assert(sizeof(__wasi_linkcount_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_linkcount_t) == 8, "witx calculated align"); + /** * File attributes. */ @@ -995,35 +1084,52 @@ typedef struct __wasi_filestat_t { } __wasi_filestat_t; +_Static_assert(sizeof(__wasi_filestat_t) == 64, "witx calculated size"); +_Static_assert(_Alignof(__wasi_filestat_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_filestat_t, dev) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, ino) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, filetype) == 16, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, nlink) == 24, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, size) == 32, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, atim) == 40, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, mtim) == 48, "witx calculated offset"); +_Static_assert(offsetof(__wasi_filestat_t, ctim) == 56, "witx calculated offset"); + /** * User-provided value that may be attached to objects that is retained when * extracted from the implementation. */ typedef uint64_t __wasi_userdata_t; +_Static_assert(sizeof(__wasi_userdata_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_userdata_t) == 8, "witx calculated align"); + /** * Type of a subscription to an event or its occurrence. */ typedef uint8_t __wasi_eventtype_t; /** - * The time value of clock `subscription::u.clock.clock_id` has - * reached timestamp `subscription::u.clock.timeout`. + * The time value of clock `subscription_clock::id` has + * reached timestamp `subscription_clock::timeout`. */ #define __WASI_EVENTTYPE_CLOCK (UINT8_C(0)) /** - * File descriptor `subscription::u.fd_readwrite.fd` has data + * File descriptor `subscription_fd_readwrite::file_descriptor` has data * available for reading. This event always triggers for regular files. */ #define __WASI_EVENTTYPE_FD_READ (UINT8_C(1)) /** - * File descriptor `subscription::u.fd_readwrite.fd` has capacity + * File descriptor `subscription_fd_readwrite::file_descriptor` has capacity * available for writing. This event always triggers for regular files. */ #define __WASI_EVENTTYPE_FD_WRITE (UINT8_C(2)) +_Static_assert(sizeof(__wasi_eventtype_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_eventtype_t) == 1, "witx calculated align"); + /** * The state of the file descriptor subscribed to with * `eventtype::fd_read` or `eventtype::fd_write`. @@ -1035,6 +1141,9 @@ typedef uint16_t __wasi_eventrwflags_t; */ #define __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP (UINT16_C(1)) +_Static_assert(sizeof(__wasi_eventrwflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_eventrwflags_t) == 2, "witx calculated align"); + /** * The contents of an $event when type is `eventtype::fd_read` or * `eventtype::fd_write`. @@ -1052,6 +1161,11 @@ typedef struct __wasi_event_fd_readwrite_t { } __wasi_event_fd_readwrite_t; +_Static_assert(sizeof(__wasi_event_fd_readwrite_t) == 16, "witx calculated size"); +_Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset"); + /** * The contents of an $event. */ @@ -1063,6 +1177,9 @@ typedef union __wasi_event_u_t { } __wasi_event_u_t; +_Static_assert(sizeof(__wasi_event_u_t) == 16, "witx calculated size"); +_Static_assert(_Alignof(__wasi_event_u_t) == 8, "witx calculated align"); + /** * An event that occurred. */ @@ -1089,21 +1206,31 @@ typedef struct __wasi_event_t { } __wasi_event_t; +_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size"); +_Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_t, u) == 16, "witx calculated offset"); + /** * Flags determining how to interpret the timestamp provided in - * `subscription::u.clock.timeout.` + * `subscription_clock::timeout`. */ typedef uint16_t __wasi_subclockflags_t; /** * If set, treat the timestamp provided in - * `subscription::u.clock.timeout` as an absolute timestamp of clock - * `subscription::u.clock.clock_id.` If clear, treat the timestamp - * provided in `subscription::u.clock.timeout` relative to the - * current time value of clock `subscription::u.clock.clock_id.` + * `subscription_clock::timeout` as an absolute timestamp of clock + * `subscription_clock::id`. If clear, treat the timestamp + * provided in `subscription_clock::timeout` relative to the + * current time value of clock `subscription_clock::id`. */ #define __WASI_SUBCLOCKFLAGS_SUBSCRIPTION_CLOCK_ABSTIME (UINT16_C(1)) +_Static_assert(sizeof(__wasi_subclockflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_subclockflags_t) == 2, "witx calculated align"); + /** * The contents of a $subscription when type is `eventtype::clock`. */ @@ -1131,6 +1258,13 @@ typedef struct __wasi_subscription_clock_t { } __wasi_subscription_clock_t; +_Static_assert(sizeof(__wasi_subscription_clock_t) == 32, "witx calculated size"); +_Static_assert(_Alignof(__wasi_subscription_clock_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_subscription_clock_t, id) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_clock_t, timeout) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_clock_t, precision) == 16, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_clock_t, flags) == 24, "witx calculated offset"); + /** * The contents of a $subscription when type is type is * `eventtype::fd_read` or `eventtype::fd_write`. @@ -1143,6 +1277,10 @@ typedef struct __wasi_subscription_fd_readwrite_t { } __wasi_subscription_fd_readwrite_t; +_Static_assert(sizeof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_subscription_fd_readwrite_t) == 4, "witx calculated align"); +_Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == 0, "witx calculated offset"); + /** * The contents of a $subscription. */ @@ -1159,6 +1297,9 @@ typedef union __wasi_subscription_u_t { } __wasi_subscription_u_t; +_Static_assert(sizeof(__wasi_subscription_u_t) == 32, "witx calculated size"); +_Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align"); + /** * Subscription to an event. */ @@ -1181,11 +1322,20 @@ typedef struct __wasi_subscription_t { } __wasi_subscription_t; +_Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size"); +_Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_t, type) == 8, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_t, u) == 16, "witx calculated offset"); + /** * Exit code generated by a process when exiting. */ typedef uint32_t __wasi_exitcode_t; +_Static_assert(sizeof(__wasi_exitcode_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_exitcode_t) == 4, "witx calculated align"); + /** * Signal condition. */ @@ -1377,6 +1527,9 @@ typedef uint8_t __wasi_signal_t; */ #define __WASI_SIGNAL_SYS (UINT8_C(30)) +_Static_assert(sizeof(__wasi_signal_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_signal_t) == 1, "witx calculated align"); + /** * Flags provided to `sock_recv`. */ @@ -1392,6 +1545,9 @@ typedef uint16_t __wasi_riflags_t; */ #define __WASI_RIFLAGS_RECV_WAITALL (UINT16_C(2)) +_Static_assert(sizeof(__wasi_riflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_riflags_t) == 2, "witx calculated align"); + /** * Flags returned by `sock_recv`. */ @@ -1402,12 +1558,18 @@ typedef uint16_t __wasi_roflags_t; */ #define __WASI_ROFLAGS_RECV_DATA_TRUNCATED (UINT16_C(1)) +_Static_assert(sizeof(__wasi_roflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_roflags_t) == 2, "witx calculated align"); + /** * Flags provided to `sock_send`. As there are currently no flags * defined, it must be set to zero. */ typedef uint16_t __wasi_siflags_t; +_Static_assert(sizeof(__wasi_siflags_t) == 2, "witx calculated size"); +_Static_assert(_Alignof(__wasi_siflags_t) == 2, "witx calculated align"); + /** * Which channels on a socket to shut down. */ @@ -1423,6 +1585,9 @@ typedef uint8_t __wasi_sdflags_t; */ #define __WASI_SDFLAGS_WR (UINT8_C(2)) +_Static_assert(sizeof(__wasi_sdflags_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_sdflags_t) == 1, "witx calculated align"); + /** * Identifiers for preopened capabilities. */ @@ -1433,6 +1598,9 @@ typedef uint8_t __wasi_preopentype_t; */ #define __WASI_PREOPENTYPE_DIR (UINT8_C(0)) +_Static_assert(sizeof(__wasi_preopentype_t) == 1, "witx calculated size"); +_Static_assert(_Alignof(__wasi_preopentype_t) == 1, "witx calculated align"); + /** * The contents of a $prestat when type is `preopentype::dir`. */ @@ -1444,6 +1612,10 @@ typedef struct __wasi_prestat_dir_t { } __wasi_prestat_dir_t; +_Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align"); +_Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset"); + /** * The contents of an $prestat. */ @@ -1455,6 +1627,9 @@ typedef union __wasi_prestat_u_t { } __wasi_prestat_u_t; +_Static_assert(sizeof(__wasi_prestat_u_t) == 4, "witx calculated size"); +_Static_assert(_Alignof(__wasi_prestat_u_t) == 4, "witx calculated align"); + /** * Information about a pre-opened capability. */ @@ -1471,6 +1646,11 @@ typedef struct __wasi_prestat_t { } __wasi_prestat_t; +_Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size"); +_Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align"); +_Static_assert(offsetof(__wasi_prestat_t, pr_type) == 0, "witx calculated offset"); +_Static_assert(offsetof(__wasi_prestat_t, u) == 4, "witx calculated offset"); + /** * @defgroup wasi_snapshot_preview1 * @{ @@ -1478,7 +1658,7 @@ typedef struct __wasi_prestat_t { /** * Read command-line argument data. - * The size of the array should match that returned by `wasi_args_sizes_get()` + * The size of the array should match that returned by `args_sizes_get` */ __wasi_errno_t __wasi_args_get( uint8_t * * argv, @@ -1510,7 +1690,7 @@ __wasi_errno_t __wasi_args_sizes_get( /** * Read environment variable data. - * The sizes of the buffers should match that returned by `environ.sizes_get()`. + * The sizes of the buffers should match that returned by `environ_sizes_get`. */ __wasi_errno_t __wasi_environ_get( uint8_t * * environ, @@ -1542,7 +1722,8 @@ __wasi_errno_t __wasi_environ_sizes_get( /** * Return the resolution of a clock. - * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks, return `WASI_EINVAL` + * Implementations are required to provide a non-zero value for supported clocks. For unsupported clocks, + * return `errno::inval`. * Note: This is similar to `clock_getres` in POSIX. */ __wasi_errno_t __wasi_clock_res_get( @@ -1695,7 +1876,7 @@ __wasi_errno_t __wasi_fd_fdstat_set_flags( /** * Adjust the rights associated with a file descriptor. - * This can only be used to remove rights, and returns `ENOTCAPABLE` if called in a way that would attempt to add rights + * This can only be used to remove rights, and returns `errno::notcapable` if called in a way that would attempt to add rights */ __wasi_errno_t __wasi_fd_fdstat_set_rights( __wasi_fd_t fd, @@ -2196,7 +2377,7 @@ __wasi_errno_t __wasi_path_open( /** * The relative path of the file or directory to open, relative to the - * `dirfd` directory. + * `path_open::fd` directory. */ const char *path, @@ -2271,7 +2452,7 @@ __wasi_errno_t __wasi_path_readlink( /** * Remove a directory. - * Return `ENOTEMPTY` if the directory is not empty. + * Return `errno::notempty` if the directory is not empty. * Note: This is similar to `unlinkat(fd, path, AT_REMOVEDIR)` in POSIX. */ __wasi_errno_t __wasi_path_remove_directory( @@ -2363,7 +2544,7 @@ __wasi_errno_t __wasi_path_symlink( /** * Unlink a file. - * Return `EISDIR` if the path refers to a directory. + * Return `errno::isdir` if the path refers to a directory. * Note: This is similar to `unlinkat(fd, path, 0)` in POSIX. */ __wasi_errno_t __wasi_path_unlink_file( diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 04d4eba..491b1bf 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 04d4eba571dc1d6fe9ab129ea9343911bcc256dc +Subproject commit 491b1bffea31ae66a028ef6ad394f65d6562a040 diff --git a/tools/wasi-headers/src/c_header.rs b/tools/wasi-headers/src/c_header.rs index b379bca..5e0fb97 100644 --- a/tools/wasi-headers/src/c_header.rs +++ b/tools/wasi-headers/src/c_header.rs @@ -1,7 +1,7 @@ use heck::ShoutySnakeCase; use witx::*; -pub(crate) fn to_c_header(doc: &Document, inputs_str: &str) -> String { +pub fn to_c_header(doc: &Document, inputs_str: &str) -> String { let mut ret = String::new(); ret.push_str(&format!( @@ -27,6 +27,10 @@ pub(crate) fn to_c_header(doc: &Document, inputs_str: &str) -> String { #error is only supported on WASI platforms. #endif +#ifndef __wasm32__ +#error only supports wasm32; doesn't yet support wasm64 +#endif + #include #include @@ -38,6 +42,7 @@ _Static_assert(_Alignof(int32_t) == 4, "non-wasi data layout"); _Static_assert(_Alignof(uint32_t) == 4, "non-wasi data layout"); _Static_assert(_Alignof(int64_t) == 8, "non-wasi data layout"); _Static_assert(_Alignof(uint64_t) == 8, "non-wasi data layout"); +_Static_assert(_Alignof(void*) == 4, "non-wasi data layout"); #ifdef __cplusplus extern "C" {{ @@ -117,6 +122,19 @@ fn print_alias(ret: &mut String, name: &Id, dest: &TypeRef) { )); } ret.push_str("\n"); + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + dest.mem_size_align().size + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + dest.mem_size_align().align + )); + + ret.push_str("\n"); } } } @@ -146,6 +164,19 @@ fn print_enum(ret: &mut String, name: &Id, e: &EnumDatatype) { )); ret.push_str("\n"); } + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + e.repr.mem_size() + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + e.repr.mem_align() + )); + + ret.push_str("\n"); } fn print_int(ret: &mut String, name: &Id, i: &IntDatatype) { @@ -213,6 +244,19 @@ fn print_flags(ret: &mut String, name: &Id, f: &FlagsDatatype) { )); ret.push_str("\n"); } + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + f.repr.mem_size(), + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + f.repr.mem_align(), + )); + + ret.push_str("\n"); } fn print_struct(ret: &mut String, name: &Id, s: &StructDatatype) { @@ -239,6 +283,28 @@ fn print_struct(ret: &mut String, name: &Id, s: &StructDatatype) { ret.push_str(&format!("}} __wasi_{}_t;\n", ident_name(name))); ret.push_str("\n"); + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + s.mem_size() + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + s.mem_align() + )); + + for layout in s.member_layout() { + ret.push_str(&format!( + "_Static_assert(offsetof(__wasi_{}_t, {}) == {}, \"witx calculated offset\");\n", + ident_name(name), + ident_name(&layout.member.name), + layout.offset + )); + } + + ret.push_str("\n"); } fn print_union(ret: &mut String, name: &Id, u: &UnionDatatype) { @@ -262,10 +328,36 @@ fn print_union(ret: &mut String, name: &Id, u: &UnionDatatype) { ret.push_str(&format!("}} __wasi_{}_t;\n", ident_name(name))); ret.push_str("\n"); + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + u.mem_size() + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + u.mem_align() + )); + + ret.push_str("\n"); } -fn print_handle(ret: &mut String, name: &Id, _h: &HandleDatatype) { +fn print_handle(ret: &mut String, name: &Id, h: &HandleDatatype) { ret.push_str(&format!("typedef int __wasi_{}_t;", ident_name(name))); + + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_t) == {}, \"witx calculated size\");\n", + ident_name(name), + h.mem_size() + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_t) == {}, \"witx calculated align\");\n", + ident_name(name), + h.mem_align() + )); + + ret.push_str("\n"); } fn print_module(ret: &mut String, m: &Module) { diff --git a/tools/wasi-headers/src/lib.rs b/tools/wasi-headers/src/lib.rs index 8dc6b04..b3f2563 100644 --- a/tools/wasi-headers/src/lib.rs +++ b/tools/wasi-headers/src/lib.rs @@ -1,7 +1,7 @@ mod c_header; use anyhow::{anyhow, Result}; -use c_header::to_c_header; +pub use c_header::to_c_header; use std::fs; use std::io; use std::path::PathBuf; diff --git a/tools/wasi-headers/src/main.rs b/tools/wasi-headers/src/main.rs index 23bff0e..24adcc1 100644 --- a/tools/wasi-headers/src/main.rs +++ b/tools/wasi-headers/src/main.rs @@ -26,13 +26,13 @@ impl GenerateCommand { fn main() -> Result<()> { let matches = app_from_crate!() - .arg(Arg::with_name("inputs").required(true).multiple(true)) + .arg(Arg::with_name("inputs").required(false).multiple(true)) .arg( Arg::with_name("output") .short("o") .long("output") .takes_value(true) - .required(true), + .required(false), ) .subcommand( SubCommand::with_name("generate-libc") From 2c2fc9a2fddd0927a66f1c142e65c8dab6f5c5d7 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 14 Feb 2020 14:02:59 -0800 Subject: [PATCH 05/30] Don't call `free` on paths which are about to call `_Exit`. (#161) This is a minor code-size optimization. --- libc-bottom-half/libpreopen/libpreopen.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libc-bottom-half/libpreopen/libpreopen.c b/libc-bottom-half/libpreopen/libpreopen.c index 25c1040..789fe8d 100644 --- a/libc-bottom-half/libpreopen/libpreopen.c +++ b/libc-bottom-half/libpreopen/libpreopen.c @@ -547,13 +547,11 @@ __wasilibc_populate_libpreopen(void) // TODO: Remove the cast on `path` once the witx is updated with char8 support. ret = __wasi_fd_prestat_dir_name(fd, (uint8_t *)path, prestat.u.dir.pr_name_len); if (ret != __WASI_ERRNO_SUCCESS) { - free(path); goto oserr; } path[prestat.u.dir.pr_name_len] = '\0'; if (internal_register_preopened_fd(fd, path) != 0) { - free(path); goto software; } From 9580a259270d0987905d1322b00bd397cf2ce1bc Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 18 Feb 2020 17:46:29 -0800 Subject: [PATCH 06/30] deprecate azure pipelines CI, build libc on GH Actions --- .azure-pipelines.yml | 55 --------------------------------- .github/workflows/main.yml | 63 ++++++++++++++++++++++++++++++++++++-- 2 files changed, 61 insertions(+), 57 deletions(-) delete mode 100644 .azure-pipelines.yml diff --git a/.azure-pipelines.yml b/.azure-pipelines.yml deleted file mode 100644 index a733ad4..0000000 --- a/.azure-pipelines.yml +++ /dev/null @@ -1,55 +0,0 @@ -trigger: - - master - -jobs: -- job: Build - timeoutInMinutes: 360 - strategy: - matrix: - windows: - imageName: 'vs2017-win2016' - mac: - imageName: 'macos-10.14' - linux: - imageName: 'ubuntu-16.04' - - pool: - vmImage: $(imageName) - - steps: - - script: | - powershell -Command "$ProgressPreference = 'SilentlyContinue'; iwr -outf %TEMP%\LLVM-8.0.0-win64.exe https://rust-lang-ci2.s3.amazonaws.com/rust-ci-mirror/LLVM-8.0.0-win64.exe" - set CLANG_DIR=%CD%\citools\clang-rust - start "" /WAIT %TEMP%\LLVM-8.0.0-win64.exe /S /NCRC /D=%CLANG_DIR% - echo ##vso[task.prependpath]%CLANG_DIR%/bin - condition: and(succeeded(), eq(variables['Agent.OS'], 'Windows_NT')) - displayName: Install clang (Windows) - - bash: | - set -euo pipefail - curl -f http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz | tar xJf - - export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/bin - echo "##vso[task.prependpath]$CLANG_DIR" - displayName: Install clang (OSX) - condition: and(succeeded(), eq(variables['Agent.OS'], 'Darwin')) - - bash: | - set -euo pipefail - curl -f http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - - export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin - echo "##vso[task.prependpath]$CLANG_DIR" - displayName: Install clang (Linux) - condition: and(succeeded(), eq(variables['Agent.OS'], 'Linux')) - - bash: | - # Windows releases of LLVM don't include the llvm-nm tool, which is needed for building - # wasi-libc. Rust's llvm-tools include llvm-nm, and Rust is installed on Azure's Windows - # images, so we can use that to make llvm-nm available without too much overhead. - set -euo pipefail - # Add --no-self-update as a workaround for - # https://github.com/microsoft/azure-pipelines-image-generation/issues/1224 - rustup update stable --no-self-update - rustup default stable - rustup component add llvm-tools-preview - echo "##vso[task.setvariable variable=WASM_NM;]$(rustc --print sysroot|sed 's|C:|/c|'|sed 's|\\|/|g')/lib/rustlib/x86_64-pc-windows-msvc/bin/llvm-nm.exe" - displayName: Install llvm-nm (Windows) - condition: and(succeeded(), eq( variables['Agent.OS'], 'Windows_NT' )) - - script: make -j4 - displayName: Build diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index e25ddaa..ab9a7c1 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -2,8 +2,67 @@ name: CI on: [push, pull_request] jobs: - test: - name: Test + buildlibc: + name: Build libc + runs-on: ${{ matrix.os }} + strategy: + matrix: + os: [ubuntu-latest, macos-latest, windows-latest] + steps: + - uses: actions/checkout@v1 + with: + submodules: true + + - name: Install clang (Windows) + shell: bash + run: | + curl -fsSLO https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe + 7z x LLVM-8.0.0-win64.exe -y -o"llvm" + echo "::add-path::$(pwd)/llvm/bin" + echo "::set-env name=WASM_AR::$(pwd)/llvm/bin/llvm-ar.exe" + if: matrix.os == 'windows-latest' + + - name: Install llvm-nm (Windows) + shell: bash + run: | + # Add --no-self-update as a workaround for + # https://github.com/microsoft/azure-pipelines-image-generation/issues/1224 + rustup update stable --no-self-update + rustup default stable + rustup component add llvm-tools-preview + echo "::set-env name=WASM_NM::$(rustc --print sysroot|sed 's|C:|/c|'|sed 's|\\|/|g')/lib/rustlib/x86_64-pc-windows-msvc/bin/llvm-nm.exe" + if: matrix.os == 'windows-latest' + + - name: Install clang (MacOS) + shell: bash + run: | + curl -sSf http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz | tar xJf - + export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/bin + echo "::add-path::$CLANG_DIR" + echo "::set-env name=WASM_CC::$CLANG_DIR/clang" + if: matrix.os == 'macos-latest' + + - name: Install clang (Linux) + shell: bash + run: | + curl -sSf http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - + export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin + echo "::add-path::$CLANG_DIR" + echo "::set-env name=WASM_CC::$CLANG_DIR/clang" + if: matrix.os == 'ubuntu-latest' + + - name: Build libc + shell: bash + run: make -j4 + + - uses: actions/upload-artifact@v1 + with: + # Upload the sysroot folder. Give it a name according to the OS it was built for. + name: ${{ format( 'sysroot-{0}.tgz', matrix.os) }} + path: sysroot + + headerstest: + name: wasi-headers test runs-on: ${{ matrix.os }} strategy: matrix: From 9ca5187170012327d853963fcd8166191f96f2ba Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 19 Feb 2020 14:09:50 -0800 Subject: [PATCH 07/30] remove no-self-update workaround for windows azure --- .github/workflows/main.yml | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index ab9a7c1..d5df7ab 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -25,9 +25,7 @@ jobs: - name: Install llvm-nm (Windows) shell: bash run: | - # Add --no-self-update as a workaround for - # https://github.com/microsoft/azure-pipelines-image-generation/issues/1224 - rustup update stable --no-self-update + rustup update stable rustup default stable rustup component add llvm-tools-preview echo "::set-env name=WASM_NM::$(rustc --print sysroot|sed 's|C:|/c|'|sed 's|\\|/|g')/lib/rustlib/x86_64-pc-windows-msvc/bin/llvm-nm.exe" From 7c39519ec49ea2684fa4bbcb510a73f8ba1203f9 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 19 Feb 2020 14:15:48 -0800 Subject: [PATCH 08/30] CI: upgrade to llvm 9.0.0 --- .github/workflows/main.yml | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index d5df7ab..30503bd 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -16,8 +16,8 @@ jobs: - name: Install clang (Windows) shell: bash run: | - curl -fsSLO https://releases.llvm.org/8.0.0/LLVM-8.0.0-win64.exe - 7z x LLVM-8.0.0-win64.exe -y -o"llvm" + curl -fsSLO https://releases.llvm.org/9.0.0/LLVM-9.0.0-win64.exe + 7z x LLVM-9.0.0-win64.exe -y -o"llvm" echo "::add-path::$(pwd)/llvm/bin" echo "::set-env name=WASM_AR::$(pwd)/llvm/bin/llvm-ar.exe" if: matrix.os == 'windows-latest' @@ -34,8 +34,8 @@ jobs: - name: Install clang (MacOS) shell: bash run: | - curl -sSf http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-apple-darwin.tar.xz | tar xJf - - export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-apple-darwin/bin + curl -sSf http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-apple-darwin.tar.xz | tar xJf - + export CLANG_DIR=`pwd`/clang+llvm-9.0.0-x86_64-apple-darwin/bin echo "::add-path::$CLANG_DIR" echo "::set-env name=WASM_CC::$CLANG_DIR/clang" if: matrix.os == 'macos-latest' @@ -43,8 +43,8 @@ jobs: - name: Install clang (Linux) shell: bash run: | - curl -sSf http://releases.llvm.org/8.0.0/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - - export CLANG_DIR=`pwd`/clang+llvm-8.0.0-x86_64-linux-gnu-ubuntu-16.04/bin + curl -sSf http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - + export CLANG_DIR=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04/bin echo "::add-path::$CLANG_DIR" echo "::set-env name=WASM_CC::$CLANG_DIR/clang" if: matrix.os == 'ubuntu-latest' From 5933c205df976a9da0468802f164e5bb4f061b11 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 19 Feb 2020 15:24:14 -0800 Subject: [PATCH 09/30] fix macos filename, use https --- .github/workflows/main.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 30503bd..bcf4f3e 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,8 +34,8 @@ jobs: - name: Install clang (MacOS) shell: bash run: | - curl -sSf http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-apple-darwin.tar.xz | tar xJf - - export CLANG_DIR=`pwd`/clang+llvm-9.0.0-x86_64-apple-darwin/bin + curl -sSf http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-darwin-apple.tar.xz | tar xJf - + export CLANG_DIR=`pwd`/clang+llvm-9.0.0-x86_64-darwin-apple/bin echo "::add-path::$CLANG_DIR" echo "::set-env name=WASM_CC::$CLANG_DIR/clang" if: matrix.os == 'macos-latest' @@ -43,7 +43,7 @@ jobs: - name: Install clang (Linux) shell: bash run: | - curl -sSf http://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - + curl -sSf https://releases.llvm.org/9.0.0/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04.tar.xz | tar xJf - export CLANG_DIR=`pwd`/clang+llvm-9.0.0-x86_64-linux-gnu-ubuntu-16.04/bin echo "::add-path::$CLANG_DIR" echo "::set-env name=WASM_CC::$CLANG_DIR/clang" From 870a25121b8dae457340058d1cd245515dd1ce5c Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 21 Feb 2020 11:40:23 -0800 Subject: [PATCH 10/30] Remove unused cloudlibc headers. (#170) --- .../cloudlibc/src/common/parser_strtoint.h | 85 --------- libc-bottom-half/cloudlibc/src/common/tls.h | 171 ------------------ 2 files changed, 256 deletions(-) delete mode 100644 libc-bottom-half/cloudlibc/src/common/parser_strtoint.h delete mode 100644 libc-bottom-half/cloudlibc/src/common/tls.h diff --git a/libc-bottom-half/cloudlibc/src/common/parser_strtoint.h b/libc-bottom-half/cloudlibc/src/common/parser_strtoint.h deleted file mode 100644 index b2a56e4..0000000 --- a/libc-bottom-half/cloudlibc/src/common/parser_strtoint.h +++ /dev/null @@ -1,85 +0,0 @@ -// Copyright (c) 2015 Nuxi, https://nuxi.nl/ -// -// SPDX-License-Identifier: BSD-2-Clause - -// Parser of integer literals as performed by strtol(), scanf(), etc. - -// Result of parsing. -bool have_number = false; -bool have_overflow = false; -int_t number = 0; - -{ - // Negative or positive number? - bool negative = false; - if (allow_negative && PEEK(0) == '-') { - negative = true; - SKIP(1); - } else if (PEEK(0) == '+') { - SKIP(1); - } - - // Determine the base. - if ((base == 0 || base == 16) && PEEK(0) == '0' && - (PEEK(1) == 'x' || PEEK(1) == 'X') && - ((PEEK(2) >= '0' && PEEK(2) <= '9') || - (PEEK(2) >= 'A' && PEEK(2) <= 'F') || - (PEEK(2) >= 'a' && PEEK(2) <= 'f'))) { - SKIP(2); - base = 16; - } else if (base == 0) { - base = PEEK(0) == '0' ? 8 : 10; - } - - // Only perform conversion if the base is valid. - if (base >= 2 && base <= 36) { - uint_fast8_t radix = base; - - // Determine the highest value up to which we can parse so that the - // next digit does not cause an overflow. - uintmax_t ceil; - uint_fast8_t last_digit; - if (negative) { - ceil = -(min / radix); - last_digit = -(min % radix); - } else { - ceil = max / radix; - last_digit = max % radix; - } - - uintmax_t value = 0; - for (;;) { - // Parse next digit. - uint_fast8_t digit; - if (PEEK(0) >= '0' && PEEK(0) <= '9') - digit = PEEK(0) - '0'; - else if (PEEK(0) >= 'A' && PEEK(0) <= 'Z') - digit = PEEK(0) - 'A' + 10; - else if (PEEK(0) >= 'a' && PEEK(0) <= 'z') - digit = PEEK(0) - 'a' + 10; - else - break; - if (digit >= radix) - break; - SKIP(1); - - // Add it to result. - have_number = true; - if (value > ceil || (value == ceil && digit > last_digit)) { - // Addition of the new digit would cause an overflow. - have_overflow = true; - } else { - value = value * radix + digit; - } - } - - if (have_overflow) { - // Set value to min or max depending whether the input is negative - // and whether the output type is signed. - number = (int_t)-1 >= 0 || !negative ? max : min; - } else { - // Return parsed value. - number = negative ? -value : value; - } - } -} diff --git a/libc-bottom-half/cloudlibc/src/common/tls.h b/libc-bottom-half/cloudlibc/src/common/tls.h deleted file mode 100644 index c7af4a5..0000000 --- a/libc-bottom-half/cloudlibc/src/common/tls.h +++ /dev/null @@ -1,171 +0,0 @@ -// Copyright (c) 2016-2017 Nuxi, https://nuxi.nl/ -// -// SPDX-License-Identifier: BSD-2-Clause - -#ifndef COMMON_TLS_H -#define COMMON_TLS_H - -#include -#include -#include -#include - -#if defined(__aarch64__) - -#define TLS_VARIANT 1 -#define TCB_SIZE 16 - -// Fetches the TCB from the CPU's registers. -static inline __wasi_tcb_t *tcb_get(void) { - __wasi_tcb_t *tcb; - asm volatile("mrs %0, tpidr_el0" : "=r"(tcb)); - return tcb; -} - -// Changes the TCB in the CPU's registers. -static inline void tcb_set(__wasi_tcb_t *tcb) { - asm volatile("msr tpidr_el0, %0" : : "r"(tcb)); -} - -#elif defined(__arm__) - -#define TLS_VARIANT 1 -#define TCB_SIZE 8 - -// Fetches the TCB from the CPU's registers. -static inline __wasi_tcb_t *tcb_get(void) { - __wasi_tcb_t *tcb; - asm volatile("mrc p15, 0, %0, cr13, cr0, 2" : "=r"(tcb)); - return tcb; -} - -// Changes the TCB in the CPU's registers. -static inline void tcb_set(__wasi_tcb_t *tcb) { - asm volatile("mcr p15, 0, %0, cr13, cr0, 2" : : "r"(tcb)); -} - -#elif defined(__i386__) - -#define TLS_VARIANT 2 - -// Fetches the TCB from the CPU's registers. -static inline __wasi_tcb_t *tcb_get(void) { - __wasi_tcb_t *tcb; - asm volatile("mov %%gs:0, %0" : "=r"(tcb)); - return tcb; -} - -// Changes the TCB in the CPU's registers. -static inline void tcb_set(__wasi_tcb_t *tcb) { - asm volatile("mov %0, %%gs:0" : : "r"(tcb)); -} - -#elif defined(__x86_64__) - -#define TLS_VARIANT 2 - -// Fetches the TCB from the CPU's registers. -static inline __wasi_tcb_t *tcb_get(void) { - __wasi_tcb_t *tcb; - asm volatile("mov %%fs:0, %0" : "=r"(tcb)); - return tcb; -} - -// Changes the TCB in the CPU's registers. -static inline void tcb_set(__wasi_tcb_t *tcb) { - asm volatile("mov %0, %%fs:0" : : "r"(tcb)); -} - -#else -#error "Unsupported architecture" -#endif - -#if TLS_VARIANT == 1 - -// TLS Variant I: TLS register points to the TCB. The TLS data is stored -// after the TCB. This approach has the disadvantage that the TCB size -// needs to be known. - -static_assert(sizeof(__wasi_tcb_t) <= TCB_SIZE, - "TCB does not fit in reserved space before TLS"); - -// Computes the total size needed to store a TCB with TLS data. -static inline size_t tls_size(void) { - return TCB_SIZE + __pt_tls_memsz_aligned + - (__pt_tls_align > alignof(__wasi_tcb_t) ? __pt_tls_align - : sizeof(__wasi_tcb_t)) - - 1; -} - -// Computes the address of the TCB in the combined TCB/TLS area. -static inline __wasi_tcb_t *tcb_addr(char *buf) { - if (alignof(__wasi_tcb_t) < __pt_tls_align) { - return ( - __wasi_tcb_t *)(__roundup((uintptr_t)buf + TCB_SIZE, __pt_tls_align) - - TCB_SIZE); - } else { - return (__wasi_tcb_t *)__roundup((uintptr_t)buf, alignof(__wasi_tcb_t)); - } -} - -// Computes the address of the TLS data in the combined TCB/TLS area. -static inline char *tls_addr(char *buf) { - return (char *)tcb_addr(buf) + TCB_SIZE; -} - -// Fetches the TLS area of the currently running thread. -static inline char *tls_get(void) { - return (char *)tcb_get() + TCB_SIZE; -} - -#elif TLS_VARIANT == 2 - -// TLS Variant II: TLS register points to the TCB. The TLS data is -// stored before the TCB. This approach has the advantage that the TCB -// size does not need to be known. - -// Computes the total size needed to store a TCB with TLS data. -static inline size_t tls_size(void) { - return __pt_tls_memsz_aligned + sizeof(__wasi_tcb_t) + - (__pt_tls_align > alignof(__wasi_tcb_t) ? __pt_tls_align - : sizeof(__wasi_tcb_t)) - - 1; -} - -// Computes the address of the TLS data in the combined TCB/TLS area. -static inline char *tls_addr(char *buf) { - if (alignof(__wasi_tcb_t) < __pt_tls_align) { - return (char *)(__roundup((uintptr_t)buf, __pt_tls_align)); - } else { - return (char *)(__roundup((uintptr_t)buf + __pt_tls_memsz_aligned, - alignof(__wasi_tcb_t)) - - __pt_tls_memsz_aligned); - } -} - -// Computes the address of the TCB in the combined TCB/TLS area. -static inline __wasi_tcb_t *tcb_addr(char *buf) { - return (__wasi_tcb_t *)(tls_addr(buf) + __pt_tls_memsz_aligned); -} - -// Fetches the TLS area of the currently running thread. -static inline char *tls_get(void) { - return (char *)tcb_get() - __pt_tls_memsz_aligned; -} - -#else -#error "Unknown TLS variant" -#endif - -// Changes the CPU's registers to point to a new TLS area. -// -// This function ensures that the TCB of the old TLS area is copied into -// the new TLS area. This ensures that the runtime (kernel, emulator, -// etc) still has access to its own private data. -static inline void tls_replace(char *buf) { - __wasi_tcb_t *tcb = tcb_addr(buf); - *tcb = *tcb_get(); - tcb_set(tcb); -} - -#endif From af92c5f9b3384a67d93b9ce63d79d38bbfa1bdd6 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 21 Feb 2020 11:40:41 -0800 Subject: [PATCH 11/30] WASI libc supports environment variables; update the README. (#172) --- libc-top-half/README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/libc-top-half/README.md b/libc-top-half/README.md index 1de0584..b2dd7c9 100644 --- a/libc-top-half/README.md +++ b/libc-top-half/README.md @@ -13,7 +13,6 @@ Some major known missing areas include: - ipc - termios - nss - - environment variables - timezones - non-builtin locales - TIOCGWINSZ (because cloudabi lacks it; affects isatty, line buffering for stdout) From 3af77075aa2c96bcddf3de311a589739665b5576 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 21 Feb 2020 11:41:05 -0800 Subject: [PATCH 12/30] Define a_clz_32 for musl so that it doesn't use a software version. (#171) --- libc-top-half/musl/arch/wasm32/atomic_arch.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libc-top-half/musl/arch/wasm32/atomic_arch.h b/libc-top-half/musl/arch/wasm32/atomic_arch.h index ef897da..01412d4 100644 --- a/libc-top-half/musl/arch/wasm32/atomic_arch.h +++ b/libc-top-half/musl/arch/wasm32/atomic_arch.h @@ -5,3 +5,7 @@ #define a_barrier() (__sync_synchronize()) #define a_cas(p, t, s) (__sync_val_compare_and_swap((p), (t), (s))) #define a_crash() (__builtin_trap()) +#define a_clz_32 __builtin_clz +#define a_clz_64 __builtin_clzll +#define a_ctz_32 __builtin_ctz +#define a_ctz_64 __builtin_ctzll From 71d279a4b0380c6527e6f9be6e7110cf6bc62df1 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 6 Feb 2020 13:19:44 -0800 Subject: [PATCH 13/30] wasi-headers: unions are tagged now --- tools/wasi-headers/src/c_header.rs | 54 +++++++++++++++++++++++------- 1 file changed, 42 insertions(+), 12 deletions(-) diff --git a/tools/wasi-headers/src/c_header.rs b/tools/wasi-headers/src/c_header.rs index 5e0fb97..fee5486 100644 --- a/tools/wasi-headers/src/c_header.rs +++ b/tools/wasi-headers/src/c_header.rs @@ -308,23 +308,36 @@ fn print_struct(ret: &mut String, name: &Id, s: &StructDatatype) { } fn print_union(ret: &mut String, name: &Id, u: &UnionDatatype) { - ret.push_str(&format!("typedef union __wasi_{}_t {{\n", ident_name(name))); + ret.push_str(&format!( + "typedef union __wasi_{}_u_t {{\n", + ident_name(name) + )); for variant in &u.variants { - if !variant.docs.is_empty() { - ret.push_str(" /**\n"); - for line in variant.docs.lines() { - ret.push_str(&format!(" * {}\n", line)); + if let Some(ref tref) = variant.tref { + if !variant.docs.is_empty() { + ret.push_str(" /**\n"); + for line in variant.docs.lines() { + ret.push_str(&format!(" * {}\n", line)); + } + ret.push_str(" */\n"); } - ret.push_str(" */\n"); + ret.push_str(&format!( + " {} {};\n", + typeref_name(tref), + ident_name(&variant.name) + )); } - ret.push_str(&format!( - " {} {};\n", - typeref_name(&variant.tref), - ident_name(&variant.name) - )); - ret.push_str("\n"); } + ret.push_str(&format!("}} __wasi_{}_u_t;\n", ident_name(name))); + + ret.push_str(&format!( + "typedef struct __wasi_{}_t {{\n", + ident_name(name) + )); + + ret.push_str(&format!(" {} tag;\n", typeref_name(&u.tag))); + ret.push_str(&format!(" __wasi_{}_u_t u;\n", ident_name(name))); ret.push_str(&format!("}} __wasi_{}_t;\n", ident_name(name))); ret.push_str("\n"); @@ -340,6 +353,23 @@ fn print_union(ret: &mut String, name: &Id, u: &UnionDatatype) { u.mem_align() )); + let l = u.union_layout(); + ret.push_str(&format!( + "_Static_assert(offsetof(__wasi_{}_t, u) == {}, \"witx calculated union offset\");\n", + ident_name(name), + l.contents_offset, + )); + ret.push_str(&format!( + "_Static_assert(sizeof(__wasi_{}_u_t) == {}, \"witx calculated union size\");\n", + ident_name(name), + l.contents_size, + )); + ret.push_str(&format!( + "_Static_assert(_Alignof(__wasi_{}_u_t) == {}, \"witx calculated union align\");\n", + ident_name(name), + l.contents_align, + )); + ret.push_str("\n"); } From 4f03c9bbe7b2f2b7fb9f9a8274888b06a8d34397 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 6 Feb 2020 13:19:58 -0800 Subject: [PATCH 14/30] WASI: tagged unions PR wip --- tools/wasi-headers/WASI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 491b1bf..868340e 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 491b1bffea31ae66a028ef6ad394f65d6562a040 +Subproject commit 868340e220b48a2bdd59e9db6eda33de115f21d6 From 852d093a3ce37c1692c98751c3f207b0af223eca Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 6 Feb 2020 13:20:57 -0800 Subject: [PATCH 15/30] wasi/api.h: regenerated with tagged unions --- libc-bottom-half/headers/public/wasi/api.h | 92 ++++++++-------------- 1 file changed, 33 insertions(+), 59 deletions(-) diff --git a/libc-bottom-half/headers/public/wasi/api.h b/libc-bottom-half/headers/public/wasi/api.h index 22c4125..70be414 100644 --- a/libc-bottom-half/headers/public/wasi/api.h +++ b/libc-bottom-half/headers/public/wasi/api.h @@ -1169,16 +1169,20 @@ _Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculat /** * The contents of an $event. */ -typedef union __wasi_event_u_t { - /** - * When type is `eventtype::fd_read` or `eventtype::fd_write`: - */ - __wasi_event_fd_readwrite_t fd_readwrite; - +typedef union __wasi_event_u_u_t { + __wasi_event_fd_readwrite_t fd_read; + __wasi_event_fd_readwrite_t fd_write; +} __wasi_event_u_u_t; +typedef struct __wasi_event_u_t { + __wasi_eventtype_t tag; + __wasi_event_u_u_t u; } __wasi_event_u_t; -_Static_assert(sizeof(__wasi_event_u_t) == 16, "witx calculated size"); +_Static_assert(sizeof(__wasi_event_u_t) == 24, "witx calculated size"); _Static_assert(_Alignof(__wasi_event_u_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_event_u_t, u) == 8, "witx calculated union offset"); +_Static_assert(sizeof(__wasi_event_u_u_t) == 16, "witx calculated union size"); +_Static_assert(_Alignof(__wasi_event_u_u_t) == 8, "witx calculated union align"); /** * An event that occurred. @@ -1195,22 +1199,16 @@ typedef struct __wasi_event_t { __wasi_errno_t error; /** - * The type of the event that occurred. - */ - __wasi_eventtype_t type; - - /** - * The contents of the event. + * The type of the event that occurred, and its contents. */ __wasi_event_u_t u; } __wasi_event_t; -_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size"); +_Static_assert(sizeof(__wasi_event_t) == 40, "witx calculated size"); _Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align"); _Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset"); _Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset"); -_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset"); _Static_assert(offsetof(__wasi_event_t, u) == 16, "witx calculated offset"); /** @@ -1284,21 +1282,21 @@ _Static_assert(offsetof(__wasi_subscription_fd_readwrite_t, file_descriptor) == /** * The contents of a $subscription. */ -typedef union __wasi_subscription_u_t { - /** - * When type is `eventtype::clock`: - */ +typedef union __wasi_subscription_u_u_t { __wasi_subscription_clock_t clock; - - /** - * When type is `eventtype::fd_read` or `eventtype::fd_write`: - */ - __wasi_subscription_fd_readwrite_t fd_readwrite; - + __wasi_subscription_fd_readwrite_t fd_read; + __wasi_subscription_fd_readwrite_t fd_write; +} __wasi_subscription_u_u_t; +typedef struct __wasi_subscription_u_t { + __wasi_eventtype_t tag; + __wasi_subscription_u_u_t u; } __wasi_subscription_u_t; -_Static_assert(sizeof(__wasi_subscription_u_t) == 32, "witx calculated size"); +_Static_assert(sizeof(__wasi_subscription_u_t) == 40, "witx calculated size"); _Static_assert(_Alignof(__wasi_subscription_u_t) == 8, "witx calculated align"); +_Static_assert(offsetof(__wasi_subscription_u_t, u) == 8, "witx calculated union offset"); +_Static_assert(sizeof(__wasi_subscription_u_u_t) == 32, "witx calculated union size"); +_Static_assert(_Alignof(__wasi_subscription_u_u_t) == 8, "witx calculated union align"); /** * Subscription to an event. @@ -1311,12 +1309,7 @@ typedef struct __wasi_subscription_t { __wasi_userdata_t userdata; /** - * The type of the event to which to subscribe. - */ - __wasi_eventtype_t type; - - /** - * The contents of the subscription. + * The type of the event to which to subscribe, and its contents */ __wasi_subscription_u_t u; @@ -1325,8 +1318,7 @@ typedef struct __wasi_subscription_t { _Static_assert(sizeof(__wasi_subscription_t) == 48, "witx calculated size"); _Static_assert(_Alignof(__wasi_subscription_t) == 8, "witx calculated align"); _Static_assert(offsetof(__wasi_subscription_t, userdata) == 0, "witx calculated offset"); -_Static_assert(offsetof(__wasi_subscription_t, type) == 8, "witx calculated offset"); -_Static_assert(offsetof(__wasi_subscription_t, u) == 16, "witx calculated offset"); +_Static_assert(offsetof(__wasi_subscription_t, u) == 8, "witx calculated offset"); /** * Exit code generated by a process when exiting. @@ -1616,40 +1608,22 @@ _Static_assert(sizeof(__wasi_prestat_dir_t) == 4, "witx calculated size"); _Static_assert(_Alignof(__wasi_prestat_dir_t) == 4, "witx calculated align"); _Static_assert(offsetof(__wasi_prestat_dir_t, pr_name_len) == 0, "witx calculated offset"); -/** - * The contents of an $prestat. - */ -typedef union __wasi_prestat_u_t { - /** - * When type is `preopentype::dir`: - */ - __wasi_prestat_dir_t dir; - -} __wasi_prestat_u_t; - -_Static_assert(sizeof(__wasi_prestat_u_t) == 4, "witx calculated size"); -_Static_assert(_Alignof(__wasi_prestat_u_t) == 4, "witx calculated align"); - /** * Information about a pre-opened capability. */ +typedef union __wasi_prestat_u_t { + __wasi_prestat_dir_t dir; +} __wasi_prestat_u_t; typedef struct __wasi_prestat_t { - /** - * The type of the pre-opened capability. - */ - __wasi_preopentype_t pr_type; - - /** - * The contents of the information. - */ + __wasi_preopentype_t tag; __wasi_prestat_u_t u; - } __wasi_prestat_t; _Static_assert(sizeof(__wasi_prestat_t) == 8, "witx calculated size"); _Static_assert(_Alignof(__wasi_prestat_t) == 4, "witx calculated align"); -_Static_assert(offsetof(__wasi_prestat_t, pr_type) == 0, "witx calculated offset"); -_Static_assert(offsetof(__wasi_prestat_t, u) == 4, "witx calculated offset"); +_Static_assert(offsetof(__wasi_prestat_t, u) == 4, "witx calculated union offset"); +_Static_assert(sizeof(__wasi_prestat_u_t) == 4, "witx calculated union size"); +_Static_assert(_Alignof(__wasi_prestat_u_t) == 4, "witx calculated union align"); /** * @defgroup wasi_snapshot_preview1 From c2ae180deebed87494a7b49a71578165602c8db6 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 6 Feb 2020 13:21:11 -0800 Subject: [PATCH 16/30] cloudlibc & libpreopen: changes for tagged unions we decided to abandon the upstream code guarded by #ifdef __wasilibc_unmodified_upstream // non-anonymous unions because these changes are sprawling and those guards are of diminishing importance --- .../cloudlibc/src/libc/poll/poll.c | 52 +++++++------------ .../cloudlibc/src/libc/sys/ioctl/ioctl.c | 25 +++------ .../cloudlibc/src/libc/sys/select/pselect.c | 40 ++++---------- .../cloudlibc/src/libc/time/clock_nanosleep.c | 17 ++---- libc-bottom-half/libpreopen/libpreopen.c | 2 +- 5 files changed, 42 insertions(+), 94 deletions(-) diff --git a/libc-bottom-half/cloudlibc/src/libc/poll/poll.c b/libc-bottom-half/cloudlibc/src/libc/poll/poll.c index b55651a..c60dcce 100644 --- a/libc-bottom-half/cloudlibc/src/libc/poll/poll.c +++ b/libc-bottom-half/cloudlibc/src/libc/poll/poll.c @@ -21,13 +21,8 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ .userdata = (uintptr_t)pollfd, - .type = __WASI_EVENTTYPE_FD_READ, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .fd_readwrite.fd = pollfd->fd, - .fd_readwrite.flags = __WASI_SUBSCRIPTION_FD_READWRITE_POLL, -#else - .u.fd_readwrite.file_descriptor = pollfd->fd, -#endif + .u.tag = __WASI_EVENTTYPE_FD_READ, + .u.u.fd_read.file_descriptor = pollfd->fd, }; created_events = true; } @@ -35,13 +30,8 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ .userdata = (uintptr_t)pollfd, - .type = __WASI_EVENTTYPE_FD_WRITE, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .fd_readwrite.fd = pollfd->fd, - .fd_readwrite.flags = __WASI_SUBSCRIPTION_FD_READWRITE_POLL, -#else - .u.fd_readwrite.file_descriptor = pollfd->fd, -#endif + .u.tag = __WASI_EVENTTYPE_FD_WRITE, + .u.u.fd_write.file_descriptor = pollfd->fd, }; created_events = true; } @@ -59,14 +49,9 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { if (timeout >= 0) { __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ - .type = __WASI_EVENTTYPE_CLOCK, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .clock.clock_id = __WASI_CLOCK_REALTIME, - .clock.timeout = (__wasi_timestamp_t)timeout * 1000000, -#else - .u.clock.id = __WASI_CLOCKID_REALTIME, - .u.clock.timeout = (__wasi_timestamp_t)timeout * 1000000, -#endif + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = __WASI_CLOCKID_REALTIME, + .u.u.clock.timeout = (__wasi_timestamp_t)timeout * 1000000, }; } @@ -92,8 +77,8 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { // Set revents fields. for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if (event->type == __WASI_EVENTTYPE_FD_READ || - event->type == __WASI_EVENTTYPE_FD_WRITE) { + if (event->u.tag == __WASI_EVENTTYPE_FD_READ || + event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { struct pollfd *pollfd = (struct pollfd *)(uintptr_t)event->userdata; #ifdef __wasilibc_unmodified_upstream // generated constant names if (event->error == __WASI_EBADF) { @@ -114,14 +99,17 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { pollfd->revents |= POLLERR; } else { // Data can be read or written. - pollfd->revents |= - event->type == __WASI_EVENTTYPE_FD_READ ? POLLRDNORM : POLLWRNORM; -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - if (event->fd_readwrite.flags & __WASI_EVENT_FD_READWRITE_HANGUP) -#else - if (event->u.fd_readwrite.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) -#endif - pollfd->revents |= POLLHUP; + if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { + pollfd->revents |= POLLRDNORM; + if (event->u.u.fd_read.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { + pollfd->revents |= POLLHUP; + } + } else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { + pollfd->revents |= POLLWRNORM; + if (event->u.u.fd_write.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { + pollfd->revents |= POLLHUP; + } + } } } } diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c index e047fc7..acc240c 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c +++ b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c @@ -14,21 +14,12 @@ int ioctl(int fildes, int request, ...) { // Poll the file descriptor to determine how many bytes can be read. __wasi_subscription_t subscriptions[2] = { { - .type = __WASI_EVENTTYPE_FD_READ, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .fd_readwrite.fd = fildes, - .fd_readwrite.flags = __WASI_SUBSCRIPTION_FD_READWRITE_POLL, -#else - .u.fd_readwrite.file_descriptor = fildes, -#endif + .u.tag = __WASI_EVENTTYPE_FD_READ, + .u.u.fd_read.file_descriptor = fildes, }, { - .type = __WASI_EVENTTYPE_CLOCK, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .clock.clock_id = __WASI_CLOCK_MONOTONIC, -#else - .u.clock.id = __WASI_CLOCKID_MONOTONIC, -#endif + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = __WASI_CLOCKID_MONOTONIC, }, }; __wasi_event_t events[__arraycount(subscriptions)]; @@ -57,12 +48,8 @@ int ioctl(int fildes, int request, ...) { errno = event->error; return -1; } - if (event->type == __WASI_EVENTTYPE_FD_READ) { -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - *result = event->fd_readwrite.nbytes; -#else - *result = event->u.fd_readwrite.nbytes; -#endif + if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { + *result = event->u.u.fd_read.nbytes; return 0; } } diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c b/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c index b31741e..2ffff9a 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c +++ b/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c @@ -49,13 +49,8 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ .userdata = fd, - .type = __WASI_EVENTTYPE_FD_READ, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .fd_readwrite.fd = fd, - .fd_readwrite.flags = __WASI_SUBSCRIPTION_FD_READWRITE_POLL, -#else - .u.fd_readwrite.file_descriptor = fd, -#endif + .u.tag = __WASI_EVENTTYPE_FD_READ, + .u.u.fd_read.file_descriptor = fd, }; } } @@ -67,13 +62,8 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ .userdata = fd, - .type = __WASI_EVENTTYPE_FD_WRITE, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .fd_readwrite.fd = fd, - .fd_readwrite.flags = __WASI_SUBSCRIPTION_FD_READWRITE_POLL, -#else - .u.fd_readwrite.file_descriptor = fd, -#endif + .u.tag = __WASI_EVENTTYPE_FD_WRITE, + .u.u.fd_write.file_descriptor = fd, }; } } @@ -82,18 +72,10 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, if (timeout != NULL) { __wasi_subscription_t *subscription = &subscriptions[nevents++]; *subscription = (__wasi_subscription_t){ - .type = __WASI_EVENTTYPE_CLOCK, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .clock.clock_id = __WASI_CLOCK_REALTIME, -#else - .u.clock.id = __WASI_CLOCKID_REALTIME, -#endif + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = __WASI_CLOCKID_REALTIME, }; -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - if (!timespec_to_timestamp_clamp(timeout, &subscription->clock.timeout)) { -#else - if (!timespec_to_timestamp_clamp(timeout, &subscription->u.clock.timeout)) { -#endif + if (!timespec_to_timestamp_clamp(timeout, &subscription->u.u.clock.timeout)) { errno = EINVAL; return -1; } @@ -115,8 +97,8 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, // Test for EBADF. for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if ((event->type == __WASI_EVENTTYPE_FD_READ || - event->type == __WASI_EVENTTYPE_FD_WRITE) && + if ((event->u.tag == __WASI_EVENTTYPE_FD_READ || + event->u.tag == __WASI_EVENTTYPE_FD_WRITE) && #ifdef __wasilibc_unmodified_upstream // generated constant names event->error == __WASI_EBADF) { #else @@ -132,9 +114,9 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, FD_ZERO(writefds); for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if (event->type == __WASI_EVENTTYPE_FD_READ) { + if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { readfds->__fds[readfds->__nfds++] = event->userdata; - } else if (event->type == __WASI_EVENTTYPE_FD_WRITE) { + } else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { writefds->__fds[writefds->__nfds++] = event->userdata; } } diff --git a/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c b/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c index 9b8505f..cd8ecfc 100644 --- a/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c +++ b/libc-bottom-half/cloudlibc/src/libc/time/clock_nanosleep.c @@ -29,20 +29,11 @@ int clock_nanosleep(clockid_t clock_id, int flags, const struct timespec *rqtp, // Prepare polling subscription. __wasi_subscription_t sub = { - .type = __WASI_EVENTTYPE_CLOCK, -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - .clock.clock_id = clock_id->id, - .clock.flags = flags, -#else - .u.clock.id = clock_id->id, - .u.clock.flags = flags, -#endif + .u.tag = __WASI_EVENTTYPE_CLOCK, + .u.u.clock.id = clock_id->id, + .u.u.clock.flags = flags, }; -#ifdef __wasilibc_unmodified_upstream // non-anonymous unions - if (!timespec_to_timestamp_clamp(rqtp, &sub.clock.timeout)) -#else - if (!timespec_to_timestamp_clamp(rqtp, &sub.u.clock.timeout)) -#endif + if (!timespec_to_timestamp_clamp(rqtp, &sub.u.u.clock.timeout)) return EINVAL; // Block until polling event is triggered. diff --git a/libc-bottom-half/libpreopen/libpreopen.c b/libc-bottom-half/libpreopen/libpreopen.c index 789fe8d..f8eca3b 100644 --- a/libc-bottom-half/libpreopen/libpreopen.c +++ b/libc-bottom-half/libpreopen/libpreopen.c @@ -538,7 +538,7 @@ __wasilibc_populate_libpreopen(void) break; if (ret != __WASI_ERRNO_SUCCESS) goto oserr; - switch (prestat.pr_type) { + switch (prestat.tag) { case __WASI_PREOPENTYPE_DIR: { char *path = malloc(prestat.u.dir.pr_name_len + 1); if (path == NULL) From 7f8930168f1fb7961d24a4b14e526e35246a45ba Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Feb 2020 09:49:07 -0800 Subject: [PATCH 17/30] update to WASI where snashot event_u flattened to struct --- libc-bottom-half/headers/public/wasi/api.h | 33 ++++++++-------------- tools/wasi-headers/WASI | 2 +- 2 files changed, 12 insertions(+), 23 deletions(-) diff --git a/libc-bottom-half/headers/public/wasi/api.h b/libc-bottom-half/headers/public/wasi/api.h index 70be414..fe81162 100644 --- a/libc-bottom-half/headers/public/wasi/api.h +++ b/libc-bottom-half/headers/public/wasi/api.h @@ -1166,24 +1166,6 @@ _Static_assert(_Alignof(__wasi_event_fd_readwrite_t) == 8, "witx calculated alig _Static_assert(offsetof(__wasi_event_fd_readwrite_t, nbytes) == 0, "witx calculated offset"); _Static_assert(offsetof(__wasi_event_fd_readwrite_t, flags) == 8, "witx calculated offset"); -/** - * The contents of an $event. - */ -typedef union __wasi_event_u_u_t { - __wasi_event_fd_readwrite_t fd_read; - __wasi_event_fd_readwrite_t fd_write; -} __wasi_event_u_u_t; -typedef struct __wasi_event_u_t { - __wasi_eventtype_t tag; - __wasi_event_u_u_t u; -} __wasi_event_u_t; - -_Static_assert(sizeof(__wasi_event_u_t) == 24, "witx calculated size"); -_Static_assert(_Alignof(__wasi_event_u_t) == 8, "witx calculated align"); -_Static_assert(offsetof(__wasi_event_u_t, u) == 8, "witx calculated union offset"); -_Static_assert(sizeof(__wasi_event_u_u_t) == 16, "witx calculated union size"); -_Static_assert(_Alignof(__wasi_event_u_u_t) == 8, "witx calculated union align"); - /** * An event that occurred. */ @@ -1199,17 +1181,24 @@ typedef struct __wasi_event_t { __wasi_errno_t error; /** - * The type of the event that occurred, and its contents. + * The type of event that occured */ - __wasi_event_u_t u; + __wasi_eventtype_t type; + + /** + * The contents of the event, if it is an `eventtype::fd_read` or + * `eventtype::fd_write`. `eventtype::clock` events ignore this field. + */ + __wasi_event_fd_readwrite_t fd_readwrite; } __wasi_event_t; -_Static_assert(sizeof(__wasi_event_t) == 40, "witx calculated size"); +_Static_assert(sizeof(__wasi_event_t) == 32, "witx calculated size"); _Static_assert(_Alignof(__wasi_event_t) == 8, "witx calculated align"); _Static_assert(offsetof(__wasi_event_t, userdata) == 0, "witx calculated offset"); _Static_assert(offsetof(__wasi_event_t, error) == 8, "witx calculated offset"); -_Static_assert(offsetof(__wasi_event_t, u) == 16, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_t, type) == 10, "witx calculated offset"); +_Static_assert(offsetof(__wasi_event_t, fd_readwrite) == 16, "witx calculated offset"); /** * Flags determining how to interpret the timestamp provided in diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 868340e..ee9b993 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 868340e220b48a2bdd59e9db6eda33de115f21d6 +Subproject commit ee9b993fa148649c32a40942f692134aa5c632d6 From 3de8c71d0628ac49420a1fbf2f7707a26956e5f9 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Wed, 12 Feb 2020 09:55:32 -0800 Subject: [PATCH 18/30] libc: change to flattened event struct --- libc-bottom-half/cloudlibc/src/libc/poll/poll.c | 12 ++++++------ .../cloudlibc/src/libc/sys/ioctl/ioctl.c | 4 ++-- .../cloudlibc/src/libc/sys/select/pselect.c | 8 ++++---- 3 files changed, 12 insertions(+), 12 deletions(-) diff --git a/libc-bottom-half/cloudlibc/src/libc/poll/poll.c b/libc-bottom-half/cloudlibc/src/libc/poll/poll.c index c60dcce..be76ecd 100644 --- a/libc-bottom-half/cloudlibc/src/libc/poll/poll.c +++ b/libc-bottom-half/cloudlibc/src/libc/poll/poll.c @@ -77,8 +77,8 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { // Set revents fields. for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if (event->u.tag == __WASI_EVENTTYPE_FD_READ || - event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { + if (event->type == __WASI_EVENTTYPE_FD_READ || + event->type == __WASI_EVENTTYPE_FD_WRITE) { struct pollfd *pollfd = (struct pollfd *)(uintptr_t)event->userdata; #ifdef __wasilibc_unmodified_upstream // generated constant names if (event->error == __WASI_EBADF) { @@ -99,14 +99,14 @@ int poll(struct pollfd *fds, size_t nfds, int timeout) { pollfd->revents |= POLLERR; } else { // Data can be read or written. - if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { + if (event->type == __WASI_EVENTTYPE_FD_READ) { pollfd->revents |= POLLRDNORM; - if (event->u.u.fd_read.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { + if (event->fd_readwrite.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { pollfd->revents |= POLLHUP; } - } else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { + } else if (event->type == __WASI_EVENTTYPE_FD_WRITE) { pollfd->revents |= POLLWRNORM; - if (event->u.u.fd_write.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { + if (event->fd_readwrite.flags & __WASI_EVENTRWFLAGS_FD_READWRITE_HANGUP) { pollfd->revents |= POLLHUP; } } diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c index acc240c..e464d88 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c +++ b/libc-bottom-half/cloudlibc/src/libc/sys/ioctl/ioctl.c @@ -48,8 +48,8 @@ int ioctl(int fildes, int request, ...) { errno = event->error; return -1; } - if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { - *result = event->u.u.fd_read.nbytes; + if (event->type == __WASI_EVENTTYPE_FD_READ) { + *result = event->fd_readwrite.nbytes; return 0; } } diff --git a/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c b/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c index 2ffff9a..bd1d2fd 100644 --- a/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c +++ b/libc-bottom-half/cloudlibc/src/libc/sys/select/pselect.c @@ -97,8 +97,8 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, // Test for EBADF. for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if ((event->u.tag == __WASI_EVENTTYPE_FD_READ || - event->u.tag == __WASI_EVENTTYPE_FD_WRITE) && + if ((event->type == __WASI_EVENTTYPE_FD_READ || + event->type == __WASI_EVENTTYPE_FD_WRITE) && #ifdef __wasilibc_unmodified_upstream // generated constant names event->error == __WASI_EBADF) { #else @@ -114,9 +114,9 @@ int pselect(int nfds, fd_set *restrict readfds, fd_set *restrict writefds, FD_ZERO(writefds); for (size_t i = 0; i < nevents; ++i) { const __wasi_event_t *event = &events[i]; - if (event->u.tag == __WASI_EVENTTYPE_FD_READ) { + if (event->type == __WASI_EVENTTYPE_FD_READ) { readfds->__fds[readfds->__nfds++] = event->userdata; - } else if (event->u.tag == __WASI_EVENTTYPE_FD_WRITE) { + } else if (event->type == __WASI_EVENTTYPE_FD_WRITE) { writefds->__fds[writefds->__nfds++] = event->userdata; } } From d415ae65e19072eed86946b902cb64db7a1e4266 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 13 Feb 2020 16:48:17 -0800 Subject: [PATCH 19/30] minor change in union AST in wasi- tag is namedtype --- tools/wasi-headers/WASI | 2 +- tools/wasi-headers/src/c_header.rs | 18 +++++++++++------- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index ee9b993..300871a 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit ee9b993fa148649c32a40942f692134aa5c632d6 +Subproject commit 300871ad75ebf3b3f3292d3de69609e5499300aa diff --git a/tools/wasi-headers/src/c_header.rs b/tools/wasi-headers/src/c_header.rs index fee5486..8e87972 100644 --- a/tools/wasi-headers/src/c_header.rs +++ b/tools/wasi-headers/src/c_header.rs @@ -336,7 +336,7 @@ fn print_union(ret: &mut String, name: &Id, u: &UnionDatatype) { ident_name(name) )); - ret.push_str(&format!(" {} tag;\n", typeref_name(&u.tag))); + ret.push_str(&format!(" {} tag;\n", namedtype_name(&u.tag))); ret.push_str(&format!(" __wasi_{}_u_t u;\n", ident_name(name))); ret.push_str(&format!("}} __wasi_{}_t;\n", ident_name(name))); @@ -566,12 +566,7 @@ fn typeref_name(tref: &TypeRef) -> String { } match tref { - TypeRef::Name(named_type) => match &*named_type.type_() { - Type::Pointer(p) => format!("{} *", typeref_name(&*p)), - Type::ConstPointer(p) => format!("const {} *", typeref_name(&*p)), - Type::Array(_) => unreachable!("arrays excluded above"), - _ => format!("__wasi_{}_t", named_type.name.as_str()), - }, + TypeRef::Name(named_type) => namedtype_name(&named_type), TypeRef::Value(anon_type) => match &**anon_type { Type::Array(_) => unreachable!("arrays excluded above"), Type::Builtin(b) => builtin_type_name(*b).to_string(), @@ -589,6 +584,15 @@ fn typeref_name(tref: &TypeRef) -> String { } } +fn namedtype_name(named_type: &NamedType) -> String { + match &*named_type.type_() { + Type::Pointer(p) => format!("{} *", typeref_name(&*p)), + Type::ConstPointer(p) => format!("const {} *", typeref_name(&*p)), + Type::Array(_) => unreachable!("arrays excluded above"), + _ => format!("__wasi_{}_t", named_type.name.as_str()), + } +} + fn intrepr_name(i: IntRepr) -> &'static str { match i { IntRepr::U8 => "uint8_t", From b3c57f19a3d627317e217db250ff717795009e07 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 13 Feb 2020 16:48:33 -0800 Subject: [PATCH 20/30] main: get more useful help by requiring subcommand fake required arguments are no good --- tools/wasi-headers/src/lib.rs | 13 ++++++-- tools/wasi-headers/src/main.rs | 60 +++++++++++++++------------------- 2 files changed, 37 insertions(+), 36 deletions(-) diff --git a/tools/wasi-headers/src/lib.rs b/tools/wasi-headers/src/lib.rs index b3f2563..09450df 100644 --- a/tools/wasi-headers/src/lib.rs +++ b/tools/wasi-headers/src/lib.rs @@ -4,16 +4,23 @@ use anyhow::{anyhow, Result}; pub use c_header::to_c_header; use std::fs; use std::io; -use std::path::PathBuf; +use std::path::{Path, PathBuf}; use witx::load; -pub fn generate(inputs: &[PathBuf]) -> Result { +pub fn generate>(inputs: &[P]) -> Result { // TODO: drop the anyhow! part once witx switches to anyhow. let doc = load(&inputs).map_err(|e| anyhow!(e.to_string()))?; let inputs_str = &inputs .iter() - .map(|p| p.file_name().unwrap().to_str().unwrap().to_string()) + .map(|p| { + p.as_ref() + .file_name() + .unwrap() + .to_str() + .unwrap() + .to_string() + }) .collect::>() .join(", "); diff --git a/tools/wasi-headers/src/main.rs b/tools/wasi-headers/src/main.rs index 24adcc1..1ec5087 100644 --- a/tools/wasi-headers/src/main.rs +++ b/tools/wasi-headers/src/main.rs @@ -5,34 +5,29 @@ use anyhow::Result; use clap::{Arg, SubCommand}; use std::fs::File; use std::io::Write; -use std::path::PathBuf; +use std::path::Path; use wasi_headers::{generate, libc_wasi_api_header, snapshot_witx_files}; -struct GenerateCommand { - /// Input witx file - inputs: Vec, - /// Output header file - output: PathBuf, -} - -impl GenerateCommand { - pub fn execute(&self) -> Result<()> { - let c_header = generate(&self.inputs)?; - let mut file = File::create(&self.output)?; - file.write_all(c_header.as_bytes())?; - Ok(()) - } +pub fn run, Q: AsRef>(inputs: &[P], output: Q) -> Result<()> { + let c_header = generate(inputs)?; + let mut file = File::create(output)?; + file.write_all(c_header.as_bytes())?; + Ok(()) } fn main() -> Result<()> { let matches = app_from_crate!() - .arg(Arg::with_name("inputs").required(false).multiple(true)) - .arg( - Arg::with_name("output") - .short("o") - .long("output") - .takes_value(true) - .required(false), + .setting(clap::AppSettings::SubcommandRequiredElseHelp) + .subcommand( + SubCommand::with_name("generate") + .arg(Arg::with_name("inputs").required(true).multiple(true)) + .arg( + Arg::with_name("output") + .short("o") + .long("output") + .takes_value(true) + .required(true), + ), ) .subcommand( SubCommand::with_name("generate-libc") @@ -40,21 +35,20 @@ fn main() -> Result<()> { ) .get_matches(); - let cmd = if matches.subcommand_matches("generate-libc").is_some() { + if matches.subcommand_matches("generate-libc").is_some() { let inputs = snapshot_witx_files()?; let output = libc_wasi_api_header(); - GenerateCommand { inputs, output } + run(&inputs, &output)?; + } else if let Some(generate) = matches.subcommand_matches("generate") { + let inputs = generate + .values_of("inputs") + .expect("required inputs arg") + .collect::>(); + let output = generate.value_of("output").expect("required output arg"); + run(&inputs, output)?; } else { - GenerateCommand { - inputs: matches - .values_of("inputs") - .expect("inputs required") - .map(PathBuf::from) - .collect(), - output: PathBuf::from(matches.value_of("output").expect("output required")), - } + unreachable!("a subcommand must be provided") }; - cmd.execute()?; Ok(()) } From ec63fd5e9c465b41c310a47df83a1e19286408c2 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Thu, 13 Feb 2020 17:12:43 -0800 Subject: [PATCH 21/30] rebased wasi repo branch --- tools/wasi-headers/WASI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 300871a..7219c5a 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 300871ad75ebf3b3f3292d3de69609e5499300aa +Subproject commit 7219c5a34470b04d033a8635c014f835d1b32c02 From e1149ab0677317c6c981bcbb5e4c159e4d2b9669 Mon Sep 17 00:00:00 2001 From: Pat Hickey Date: Tue, 18 Feb 2020 12:36:35 -0800 Subject: [PATCH 22/30] point at WASI with tagged unions merged into master --- tools/wasi-headers/WASI | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/wasi-headers/WASI b/tools/wasi-headers/WASI index 7219c5a..85df508 160000 --- a/tools/wasi-headers/WASI +++ b/tools/wasi-headers/WASI @@ -1 +1 @@ -Subproject commit 7219c5a34470b04d033a8635c014f835d1b32c02 +Subproject commit 85df5085172a75f2a490a89833821c85cdbfaba7 From 79a9b40837bfbf27dfbc991182ab8c4f5e98ba09 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Mon, 14 Oct 2019 09:00:02 -0700 Subject: [PATCH 23/30] Update to musl 1.1.24. See the WHATSNEW file for details; this doesn't have any major changes for wasi-libc; in particular, the new catgets and GLOB_TILDE features are disabled. --- expected/wasm32-wasi/defined-symbols.txt | 1 + expected/wasm32-wasi/predefined-macros.txt | 4 +- .../cloudlibc/src/libc/unistd/lseek.c | 9 +- .../headers/public/__header_netinet_in.h | 14 ++ .../headers/public/__struct_in6_addr.h | 2 +- libc-top-half/musl/COPYRIGHT | 3 +- libc-top-half/musl/INSTALL | 3 +- libc-top-half/musl/VERSION | 2 +- libc-top-half/musl/WHATSNEW | 49 ++++ libc-top-half/musl/arch/aarch64/bits/hwcap.h | 8 + libc-top-half/musl/arch/aarch64/bits/ipc.h | 14 -- libc-top-half/musl/arch/aarch64/bits/msg.h | 13 -- .../musl/arch/aarch64/bits/syscall.h.in | 6 + libc-top-half/musl/arch/aarch64/kstat.h | 21 ++ .../musl/arch/aarch64/syscall_arch.h | 2 + libc-top-half/musl/arch/arm/bits/ipcstat.h | 1 + .../musl/arch/{powerpc64 => arm}/bits/msg.h | 3 + .../musl/arch/{mips64 => arm}/bits/sem.h | 10 +- .../musl/arch/{x86_64 => arm}/bits/shm.h | 4 +- libc-top-half/musl/arch/arm/bits/syscall.h.in | 6 + libc-top-half/musl/arch/arm/kstat.h | 21 ++ libc-top-half/musl/arch/generic/bits/ipc.h | 2 - .../musl/arch/generic/bits/ipcstat.h | 1 + libc-top-half/musl/arch/generic/bits/msg.h | 3 - libc-top-half/musl/arch/generic/bits/sem.h | 10 +- libc-top-half/musl/arch/generic/bits/shm.h | 4 - libc-top-half/musl/arch/i386/bits/ipcstat.h | 1 + .../musl/arch/{s390x => i386}/bits/msg.h | 3 + libc-top-half/musl/arch/i386/bits/sem.h | 11 + .../musl/arch/{mips64 => i386}/bits/shm.h | 3 + .../musl/arch/i386/bits/syscall.h.in | 6 + libc-top-half/musl/arch/i386/kstat.h | 21 ++ .../musl/arch/m68k/bits/alltypes.h.in | 4 + libc-top-half/musl/arch/m68k/bits/ipcstat.h | 1 + .../musl/arch/{x86_64 => m68k}/bits/msg.h | 3 + libc-top-half/musl/arch/m68k/bits/sem.h | 11 + .../musl/arch/{s390x => m68k}/bits/shm.h | 4 +- .../musl/arch/m68k/bits/syscall.h.in | 6 + libc-top-half/musl/arch/m68k/kstat.h | 21 ++ .../musl/arch/microblaze/bits/ipcstat.h | 1 + .../arch/{mips64 => microblaze}/bits/msg.h | 6 +- .../arch/{aarch64 => microblaze}/bits/sem.h | 10 +- .../arch/{aarch64 => microblaze}/bits/shm.h | 3 + .../musl/arch/microblaze/bits/syscall.h.in | 6 + libc-top-half/musl/arch/microblaze/kstat.h | 21 ++ libc-top-half/musl/arch/mips/bits/ipcstat.h | 1 + libc-top-half/musl/arch/mips/bits/sem.h | 8 +- libc-top-half/musl/arch/mips/bits/shm.h | 1 - .../musl/arch/mips/bits/syscall.h.in | 6 + libc-top-half/musl/arch/mips/kstat.h | 22 ++ libc-top-half/musl/arch/mips/syscall_arch.h | 140 +++++------- libc-top-half/musl/arch/mips64/bits/ipc.h | 2 - libc-top-half/musl/arch/mips64/bits/stat.h | 3 - .../musl/arch/mips64/bits/syscall.h.in | 6 + libc-top-half/musl/arch/mips64/kstat.h | 21 ++ libc-top-half/musl/arch/mips64/syscall_arch.h | 212 +++++------------- .../musl/arch/mipsn32/bits/ipcstat.h | 1 + libc-top-half/musl/arch/mipsn32/bits/sem.h | 8 +- libc-top-half/musl/arch/mipsn32/bits/stat.h | 3 - .../musl/arch/mipsn32/bits/syscall.h.in | 6 + libc-top-half/musl/arch/mipsn32/kstat.h | 22 ++ .../musl/arch/mipsn32/syscall_arch.h | 119 +++++----- libc-top-half/musl/arch/or1k/bits/ipc.h | 13 -- libc-top-half/musl/arch/or1k/bits/ipcstat.h | 1 + libc-top-half/musl/arch/or1k/bits/sem.h | 11 + libc-top-half/musl/arch/or1k/bits/shm.h | 27 +++ .../musl/arch/or1k/bits/syscall.h.in | 6 + libc-top-half/musl/arch/or1k/kstat.h | 21 ++ libc-top-half/musl/arch/or1k/syscall_arch.h | 2 + .../musl/arch/powerpc/bits/alltypes.h.in | 4 + libc-top-half/musl/arch/powerpc/bits/ipc.h | 3 - .../musl/arch/powerpc/bits/ipcstat.h | 1 + libc-top-half/musl/arch/powerpc/bits/shm.h | 1 - .../musl/arch/powerpc/bits/syscall.h.in | 6 + libc-top-half/musl/arch/powerpc/bits/user.h | 10 +- libc-top-half/musl/arch/powerpc/kstat.h | 20 ++ libc-top-half/musl/arch/powerpc/reloc.h | 1 + .../musl/arch/powerpc/syscall_arch.h | 3 + libc-top-half/musl/arch/powerpc64/bits/ipc.h | 3 - libc-top-half/musl/arch/powerpc64/bits/sem.h | 13 -- libc-top-half/musl/arch/powerpc64/bits/shm.h | 1 - .../musl/arch/powerpc64/bits/syscall.h.in | 6 + libc-top-half/musl/arch/powerpc64/bits/user.h | 10 +- libc-top-half/musl/arch/powerpc64/kstat.h | 19 ++ libc-top-half/musl/arch/powerpc64/reloc.h | 1 + .../musl/arch/powerpc64/syscall_arch.h | 3 + libc-top-half/musl/arch/riscv64/atomic_arch.h | 20 +- libc-top-half/musl/arch/riscv64/bits/ipc.h | 14 -- libc-top-half/musl/arch/riscv64/bits/msg.h | 13 -- libc-top-half/musl/arch/riscv64/bits/sem.h | 9 - libc-top-half/musl/arch/riscv64/bits/shm.h | 25 --- libc-top-half/musl/arch/riscv64/bits/signal.h | 69 +++--- .../musl/arch/riscv64/bits/syscall.h.in | 15 ++ libc-top-half/musl/arch/riscv64/bits/user.h | 42 +--- libc-top-half/musl/arch/riscv64/kstat.h | 21 ++ .../musl/arch/riscv64/pthread_arch.h | 2 +- .../musl/arch/riscv64/syscall_arch.h | 4 +- libc-top-half/musl/arch/s390x/bits/ipc.h | 14 -- libc-top-half/musl/arch/s390x/bits/sem.h | 7 - .../musl/arch/s390x/bits/syscall.h.in | 6 + libc-top-half/musl/arch/s390x/kstat.h | 19 ++ libc-top-half/musl/arch/sh/bits/alltypes.h.in | 4 + libc-top-half/musl/arch/sh/bits/ipcstat.h | 1 + libc-top-half/musl/arch/sh/bits/msg.h | 15 ++ libc-top-half/musl/arch/sh/bits/sem.h | 16 ++ libc-top-half/musl/arch/sh/bits/syscall.h.in | 6 + libc-top-half/musl/arch/sh/bits/user.h | 34 +-- libc-top-half/musl/arch/sh/kstat.h | 21 ++ libc-top-half/musl/arch/sh/syscall_arch.h | 3 + .../musl/arch/x32/bits/alltypes.h.in | 4 + libc-top-half/musl/arch/x32/bits/ipc.h | 2 - libc-top-half/musl/arch/x32/bits/sem.h | 11 + libc-top-half/musl/arch/x32/bits/syscall.h.in | 6 + libc-top-half/musl/arch/x32/kstat.h | 22 ++ libc-top-half/musl/arch/x32/syscall_arch.h | 81 ++----- libc-top-half/musl/arch/x86_64/bits/ipc.h | 13 -- libc-top-half/musl/arch/x86_64/bits/sem.h | 11 + .../musl/arch/x86_64/bits/syscall.h.in | 6 + libc-top-half/musl/arch/x86_64/kstat.h | 22 ++ libc-top-half/musl/arch/x86_64/syscall_arch.h | 2 + libc-top-half/musl/include/fcntl.h | 5 + libc-top-half/musl/include/glob.h | 5 + libc-top-half/musl/include/netinet/if_ether.h | 1 + libc-top-half/musl/include/netinet/in.h | 2 + libc-top-half/musl/include/sched.h | 11 +- libc-top-half/musl/include/spawn.h | 5 + libc-top-half/musl/include/stdlib.h | 1 + libc-top-half/musl/include/sys/ipc.h | 2 +- libc-top-half/musl/include/sys/msg.h | 4 +- libc-top-half/musl/include/sys/sem.h | 4 +- libc-top-half/musl/include/sys/shm.h | 4 +- libc-top-half/musl/include/unistd.h | 2 + libc-top-half/musl/ldso/dynlink.c | 113 +++++----- libc-top-half/musl/src/conf/fpathconf.c | 2 +- libc-top-half/musl/src/env/secure_getenv.c | 8 + libc-top-half/musl/src/include/time.h | 1 + libc-top-half/musl/src/include/unistd.h | 1 + libc-top-half/musl/src/internal/dynlink.h | 1 + libc-top-half/musl/src/internal/floatscan.c | 2 +- .../musl/src/internal/pthread_impl.h | 1 - libc-top-half/musl/src/internal/syscall.h | 109 ++++++++- libc-top-half/musl/src/ipc/ipc.h | 12 + libc-top-half/musl/src/ipc/msgctl.c | 13 +- libc-top-half/musl/src/ipc/semctl.c | 21 +- libc-top-half/musl/src/ipc/semtimedop.c | 26 ++- libc-top-half/musl/src/ipc/shmctl.c | 13 +- libc-top-half/musl/src/ldso/aarch64/tlsdesc.s | 6 +- libc-top-half/musl/src/ldso/arm/tlsdesc.S | 6 +- libc-top-half/musl/src/ldso/i386/tlsdesc.s | 2 - libc-top-half/musl/src/ldso/x86_64/tlsdesc.s | 2 - libc-top-half/musl/src/linux/adjtime.c | 2 +- libc-top-half/musl/src/linux/adjtimex.c | 4 +- libc-top-half/musl/src/linux/clock_adjtime.c | 112 +++++++++ .../musl/src/linux/copy_file_range.c | 8 + libc-top-half/musl/src/linux/ppoll.c | 18 +- libc-top-half/musl/src/linux/settimeofday.c | 7 +- libc-top-half/musl/src/linux/timerfd.c | 42 ++++ libc-top-half/musl/src/locale/catclose.c | 12 + libc-top-half/musl/src/locale/catgets.c | 38 ++++ libc-top-half/musl/src/locale/catopen.c | 81 ++++++- libc-top-half/musl/src/math/i386/asin.s | 10 +- libc-top-half/musl/src/math/i386/atan.s | 7 +- libc-top-half/musl/src/math/i386/atan2.s | 3 - libc-top-half/musl/src/math/i386/atan2f.s | 3 - libc-top-half/musl/src/math/i386/atanf.s | 7 +- libc-top-half/musl/src/math/i386/exp.s | 10 +- libc-top-half/musl/src/math/i386/log1p.s | 7 +- libc-top-half/musl/src/math/i386/log1pf.s | 7 +- libc-top-half/musl/src/math/lrint.c | 28 ++- libc-top-half/musl/src/math/sqrt.c | 3 +- libc-top-half/musl/src/math/sqrtf.c | 3 +- libc-top-half/musl/src/misc/getopt.c | 1 + libc-top-half/musl/src/misc/ioctl.c | 25 ++- libc-top-half/musl/src/mq/mq_timedreceive.c | 17 ++ libc-top-half/musl/src/mq/mq_timedsend.c | 17 ++ libc-top-half/musl/src/multibyte/mbsrtowcs.c | 10 +- libc-top-half/musl/src/network/getsockopt.c | 27 ++- libc-top-half/musl/src/network/recvmmsg.c | 18 ++ libc-top-half/musl/src/network/setsockopt.c | 32 ++- libc-top-half/musl/src/process/fdop.h | 2 + libc-top-half/musl/src/process/posix_spawn.c | 8 + .../posix_spawn_file_actions_addchdir.c | 18 ++ .../posix_spawn_file_actions_addfchdir.c | 17 ++ libc-top-half/musl/src/regex/glob.c | 65 +++++- .../musl/src/sched/sched_rr_get_interval.c | 14 ++ libc-top-half/musl/src/select/pselect.c | 20 +- libc-top-half/musl/src/select/select.c | 47 ++-- .../src/setjmp/arm/{longjmp.s => longjmp.S} | 7 + .../src/setjmp/arm/{setjmp.s => setjmp.S} | 7 + libc-top-half/musl/src/setjmp/mips/longjmp.S | 18 +- libc-top-half/musl/src/setjmp/mips/setjmp.S | 18 +- libc-top-half/musl/src/signal/getitimer.c | 11 + libc-top-half/musl/src/signal/setitimer.c | 19 ++ libc-top-half/musl/src/signal/sigaction.c | 2 +- libc-top-half/musl/src/signal/sigtimedwait.c | 28 ++- libc-top-half/musl/src/signal/x32/getitimer.c | 7 + libc-top-half/musl/src/signal/x32/setitimer.c | 7 + libc-top-half/musl/src/stat/fstat.c | 14 +- libc-top-half/musl/src/stat/fstatat.c | 124 +++++++++- libc-top-half/musl/src/stat/lstat.c | 7 +- libc-top-half/musl/src/stat/stat.c | 7 +- libc-top-half/musl/src/stat/utimensat.c | 43 +++- libc-top-half/musl/src/stdio/__stdio_seek.c | 17 +- libc-top-half/musl/src/stdio/vfwprintf.c | 2 + libc-top-half/musl/src/thread/__timedwait.c | 24 +- libc-top-half/musl/src/thread/arm/atomics.s | 4 +- libc-top-half/musl/src/thread/arm/clone.s | 10 +- .../musl/src/thread/arm/syscall_cp.s | 8 +- .../musl/src/thread/pthread_create.c | 57 +++-- libc-top-half/musl/src/thread/pthread_join.c | 1 + .../musl/src/thread/pthread_mutex_timedlock.c | 20 +- libc-top-half/musl/src/thread/thrd_sleep.c | 3 +- .../musl/src/thread/x32/syscall_cp.s | 8 +- .../musl/src/thread/x32/syscall_cp_fixup.c | 39 ---- libc-top-half/musl/src/time/clock_getres.c | 14 ++ libc-top-half/musl/src/time/clock_gettime.c | 52 +++++ libc-top-half/musl/src/time/clock_nanosleep.c | 35 ++- libc-top-half/musl/src/time/clock_settime.c | 17 ++ libc-top-half/musl/src/time/nanosleep.c | 2 +- libc-top-half/musl/src/time/strftime.c | 4 + libc-top-half/musl/src/time/timer_create.c | 4 +- libc-top-half/musl/src/time/timer_gettime.c | 16 ++ libc-top-half/musl/src/time/timer_settime.c | 25 +++ libc-top-half/musl/src/unistd/alarm.c | 6 +- libc-top-half/musl/src/unistd/lseek.c | 13 +- libc-top-half/musl/src/unistd/mipsn32/lseek.c | 20 ++ libc-top-half/musl/src/unistd/x32/lseek.c | 15 ++ 227 files changed, 2478 insertions(+), 1077 deletions(-) delete mode 100644 libc-top-half/musl/arch/aarch64/bits/ipc.h delete mode 100644 libc-top-half/musl/arch/aarch64/bits/msg.h create mode 100644 libc-top-half/musl/arch/aarch64/kstat.h create mode 100644 libc-top-half/musl/arch/arm/bits/ipcstat.h rename libc-top-half/musl/arch/{powerpc64 => arm}/bits/msg.h (83%) rename libc-top-half/musl/arch/{mips64 => arm}/bits/sem.h (52%) rename libc-top-half/musl/arch/{x86_64 => arm}/bits/shm.h (90%) create mode 100644 libc-top-half/musl/arch/arm/kstat.h create mode 100644 libc-top-half/musl/arch/generic/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/i386/bits/ipcstat.h rename libc-top-half/musl/arch/{s390x => i386}/bits/msg.h (83%) create mode 100644 libc-top-half/musl/arch/i386/bits/sem.h rename libc-top-half/musl/arch/{mips64 => i386}/bits/shm.h (90%) create mode 100644 libc-top-half/musl/arch/i386/kstat.h create mode 100644 libc-top-half/musl/arch/m68k/bits/ipcstat.h rename libc-top-half/musl/arch/{x86_64 => m68k}/bits/msg.h (83%) create mode 100644 libc-top-half/musl/arch/m68k/bits/sem.h rename libc-top-half/musl/arch/{s390x => m68k}/bits/shm.h (90%) create mode 100644 libc-top-half/musl/arch/m68k/kstat.h create mode 100644 libc-top-half/musl/arch/microblaze/bits/ipcstat.h rename libc-top-half/musl/arch/{mips64 => microblaze}/bits/msg.h (73%) rename libc-top-half/musl/arch/{aarch64 => microblaze}/bits/sem.h (52%) rename libc-top-half/musl/arch/{aarch64 => microblaze}/bits/shm.h (90%) create mode 100644 libc-top-half/musl/arch/microblaze/kstat.h create mode 100644 libc-top-half/musl/arch/mips/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/mips/kstat.h create mode 100644 libc-top-half/musl/arch/mips64/kstat.h create mode 100644 libc-top-half/musl/arch/mipsn32/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/mipsn32/kstat.h delete mode 100644 libc-top-half/musl/arch/or1k/bits/ipc.h create mode 100644 libc-top-half/musl/arch/or1k/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/or1k/bits/sem.h create mode 100644 libc-top-half/musl/arch/or1k/bits/shm.h create mode 100644 libc-top-half/musl/arch/or1k/kstat.h create mode 100644 libc-top-half/musl/arch/powerpc/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/powerpc/kstat.h delete mode 100644 libc-top-half/musl/arch/powerpc64/bits/sem.h create mode 100644 libc-top-half/musl/arch/powerpc64/kstat.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/ipc.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/msg.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/sem.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/shm.h create mode 100644 libc-top-half/musl/arch/riscv64/kstat.h delete mode 100644 libc-top-half/musl/arch/s390x/bits/ipc.h delete mode 100644 libc-top-half/musl/arch/s390x/bits/sem.h create mode 100644 libc-top-half/musl/arch/s390x/kstat.h create mode 100644 libc-top-half/musl/arch/sh/bits/ipcstat.h create mode 100644 libc-top-half/musl/arch/sh/bits/msg.h create mode 100644 libc-top-half/musl/arch/sh/bits/sem.h create mode 100644 libc-top-half/musl/arch/sh/kstat.h create mode 100644 libc-top-half/musl/arch/x32/bits/sem.h create mode 100644 libc-top-half/musl/arch/x32/kstat.h delete mode 100644 libc-top-half/musl/arch/x86_64/bits/ipc.h create mode 100644 libc-top-half/musl/arch/x86_64/bits/sem.h create mode 100644 libc-top-half/musl/arch/x86_64/kstat.h create mode 100644 libc-top-half/musl/src/env/secure_getenv.c create mode 100644 libc-top-half/musl/src/linux/copy_file_range.c create mode 100644 libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c create mode 100644 libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c rename libc-top-half/musl/src/setjmp/arm/{longjmp.s => longjmp.S} (87%) rename libc-top-half/musl/src/setjmp/arm/{setjmp.s => setjmp.S} (88%) create mode 100644 libc-top-half/musl/src/signal/x32/getitimer.c create mode 100644 libc-top-half/musl/src/signal/x32/setitimer.c delete mode 100644 libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c create mode 100644 libc-top-half/musl/src/unistd/mipsn32/lseek.c create mode 100644 libc-top-half/musl/src/unistd/x32/lseek.c diff --git a/expected/wasm32-wasi/defined-symbols.txt b/expected/wasm32-wasi/defined-symbols.txt index b3a46b8..a510508 100644 --- a/expected/wasm32-wasi/defined-symbols.txt +++ b/expected/wasm32-wasi/defined-symbols.txt @@ -139,6 +139,7 @@ __log2_data __log2f_data __log_data __logf_data +__lseek __math_divzero __math_divzerof __math_invalid diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index b95d563..f7fa6e4 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -597,8 +597,8 @@ #define ILL_PRVOPC 5 #define ILL_PRVREG 6 #define IN6ADDRSZ NS_IN6ADDRSZ -#define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } -#define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } +#define IN6ADDR_ANY_INIT { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 } } +#define IN6ADDR_LOOPBACK_INIT { { 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01 } } #define IN6_ARE_ADDR_EQUAL(a,b) __ARE_4_EQUAL((const uint32_t *)(a), (const uint32_t *)(b)) #define IN6_IS_ADDR_LINKLOCAL(a) ((((uint8_t *) (a))[0]) == 0xfe && (((uint8_t *) (a))[1] & 0xc0) == 0x80) #define IN6_IS_ADDR_LOOPBACK(a) (((uint32_t *) (a))[0] == 0 && ((uint32_t *) (a))[1] == 0 && ((uint32_t *) (a))[2] == 0 && ((uint8_t *) (a))[12] == 0 && ((uint8_t *) (a))[13] == 0 && ((uint8_t *) (a))[14] == 0 && ((uint8_t *) (a))[15] == 1 ) diff --git a/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c b/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c index f21e328..cb5d995 100644 --- a/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c +++ b/libc-bottom-half/cloudlibc/src/libc/unistd/lseek.c @@ -11,10 +11,10 @@ static_assert(SEEK_CUR == __WASI_WHENCE_CUR, "Value mismatch"); static_assert(SEEK_END == __WASI_WHENCE_END, "Value mismatch"); static_assert(SEEK_SET == __WASI_WHENCE_SET, "Value mismatch"); -#ifdef __wasilibc_unmodified_upstream /* Optimize the readonly case of lseek */ +#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point off_t lseek(int fildes, off_t offset, int whence) { #else -off_t (lseek)(int fildes, off_t offset, int whence) { +off_t __lseek(int fildes, off_t offset, int whence) { #endif __wasi_filesize_t new_offset; __wasi_errno_t error = @@ -25,3 +25,8 @@ off_t (lseek)(int fildes, off_t offset, int whence) { } return new_offset; } + +#ifdef __wasilibc_unmodified_upstream // Provide an __lseek entry point +#else +extern __typeof(__lseek) lseek __attribute__((weak, alias("__lseek"))); +#endif diff --git a/libc-bottom-half/headers/public/__header_netinet_in.h b/libc-bottom-half/headers/public/__header_netinet_in.h index a20a394..30359c8 100644 --- a/libc-bottom-half/headers/public/__header_netinet_in.h +++ b/libc-bottom-half/headers/public/__header_netinet_in.h @@ -13,4 +13,18 @@ #define IPPROTO_IPV6 41 #define IPPROTO_RAW 255 +#define IN6ADDR_ANY_INIT { { \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00 \ +} } + +#define IN6ADDR_LOOPBACK_INIT { { \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x00, \ + 0x00, 0x00, 0x00, 0x01 \ +} } + #endif diff --git a/libc-bottom-half/headers/public/__struct_in6_addr.h b/libc-bottom-half/headers/public/__struct_in6_addr.h index 8d61ada..cf2fafe 100644 --- a/libc-bottom-half/headers/public/__struct_in6_addr.h +++ b/libc-bottom-half/headers/public/__struct_in6_addr.h @@ -2,7 +2,7 @@ #define __wasilibc___struct_in6_addr_h struct in6_addr { - _Alignas(long) unsigned char s6_addr[16]; + _Alignas(int32_t) unsigned char s6_addr[16]; }; #endif diff --git a/libc-top-half/musl/COPYRIGHT b/libc-top-half/musl/COPYRIGHT index 2525ffb..67802d1 100644 --- a/libc-top-half/musl/COPYRIGHT +++ b/libc-top-half/musl/COPYRIGHT @@ -122,7 +122,8 @@ Copyright © 1993,2004 Sun Microsystems or Copyright © 2003-2011 David Schultz or Copyright © 2003-2009 Steven G. Kargl or Copyright © 2003-2009 Bruce D. Evans or -Copyright © 2008 Stephen L. Moshier +Copyright © 2008 Stephen L. Moshier or +Copyright © 2017-2018 Arm Limited and labelled as such in comments in the individual source files. All have been licensed under extremely permissive terms. diff --git a/libc-top-half/musl/INSTALL b/libc-top-half/musl/INSTALL index 322ee97..22477b6 100644 --- a/libc-top-half/musl/INSTALL +++ b/libc-top-half/musl/INSTALL @@ -55,12 +55,13 @@ and ABI combinations: * Little-endian default; big-endian variants also supported * MIPS - * ABI is o32 + * ABI is o32, fp32/fpxx (except on r6 which is fp64) * Big-endian default; little-endian variants also supported * Default ABI variant uses FPU registers; alternate soft-float ABI that does not use FPU registers or instructions is available * MIPS2 or later, or kernel emulation of ll/sc (standard in Linux) is required + * MIPS32r6, an incompatible ISA, is supported as a variant "mipsr6" * MIPS64 * ABI is n64 (LP64) or n32 (ILP32) diff --git a/libc-top-half/musl/VERSION b/libc-top-half/musl/VERSION index 32ffe12..3fe3e58 100644 --- a/libc-top-half/musl/VERSION +++ b/libc-top-half/musl/VERSION @@ -1 +1 @@ -1.1.23 +1.1.24 diff --git a/libc-top-half/musl/WHATSNEW b/libc-top-half/musl/WHATSNEW index b46e9ae..f9879bd 100644 --- a/libc-top-half/musl/WHATSNEW +++ b/libc-top-half/musl/WHATSNEW @@ -2115,3 +2115,52 @@ arch-specfic bugs fixed: - passing of 64-bit syscall arguments was broken on microblaze - posix_fadvise was broken on mips due to missing 7-arg syscall support - vrregset_t layout and member naming was wrong on powerpc64 + + + +1.1.24 release notes + +new features: +- GLOB_TILDE extension to glob +- non-stub catgets localization API, using netbsd binary catalog format +- posix_spawn file actions for [f]chdir (extension, pending future standard) +- secure_getenv function (extension) +- copy_file_range syscall wrapper (Linux extension) +- header-level support for new linux features in 5.2 + +performance: +- new fast path for lrint (generic C version) on 32-bit archs + +major internal changes: +- functions involving time are overhauled to be time64-ready in 32-bit archs +- x32 uses the new time64 code paths to replace nasty hacks in syscall glue + +compatibility & conformance: +- support for powerpc[64] unaligned relocation types +- powerpc[64] and sh sys/user.h no longer clash with kernel asm/ptrace.h +- select no longer modifies timeout on failure (or at all) +- mips64 stat results are no longer limited to 32-bit time range +- optreset (BSD extension) now has a public declaration +- support for clang inconsistencies in wchar_t type vs some 32-bit archs +- mips r6 syscall asm no longer has invalid lo/hi register clobbers +- vestigial asm declarations of __tls_get_new are removed (broke some tooling) +- riscv64 mcontext_t mismatch glibc's member naming is corrected + +bugs fixed: +- glob failed to match broken symlinks consistently +- invalid use of interposed calloc to allocate initial TLS +- various dlsym symbol resolution logic errors +- semctl with SEM_STAT_ANY didn't work +- pthread_create with explicit scheduling was subject to priority inversion +- pthread_create failure path had data race for thread count +- timer_create with SIGEV_THREAD notification had data race getting timer id +- wide printf family failed to support l modifier for float formats + +arch-specific bugs fixed: +- x87 floating point stack imbalance in math asm (i386-only CVE-2019-14697) +- x32 clock_adjtime, getrusage, wait3, wait4 produced junk (struct mismatches) +- lseek broken on x32 and mipsn32 with large file offsets +- riscv64 atomics weren't compiler barriers +- riscv64 atomics had broken asm constraints (missing earlyclobber flag) +- arm clone() was broken when compiled as thumb if start function returned +- mipsr6 setjmp/longjmp did not preserve fpu register state correctly diff --git a/libc-top-half/musl/arch/aarch64/bits/hwcap.h b/libc-top-half/musl/arch/aarch64/bits/hwcap.h index ad67091..a748402 100644 --- a/libc-top-half/musl/arch/aarch64/bits/hwcap.h +++ b/libc-top-half/musl/arch/aarch64/bits/hwcap.h @@ -30,3 +30,11 @@ #define HWCAP_SB (1 << 29) #define HWCAP_PACA (1 << 30) #define HWCAP_PACG (1UL << 31) + +#define HWCAP2_DCPODP (1 << 0) +#define HWCAP2_SVE2 (1 << 1) +#define HWCAP2_SVEAES (1 << 2) +#define HWCAP2_SVEPMULL (1 << 3) +#define HWCAP2_SVEBITPERM (1 << 4) +#define HWCAP2_SVESHA3 (1 << 5) +#define HWCAP2_SVESM4 (1 << 6) diff --git a/libc-top-half/musl/arch/aarch64/bits/ipc.h b/libc-top-half/musl/arch/aarch64/bits/ipc.h deleted file mode 100644 index 6f3328a..0000000 --- a/libc-top-half/musl/arch/aarch64/bits/ipc.h +++ /dev/null @@ -1,14 +0,0 @@ -struct ipc_perm { - key_t __ipc_perm_key; - uid_t uid; - gid_t gid; - uid_t cuid; - gid_t cgid; - mode_t mode; - unsigned short __ipc_perm_seq; - - unsigned long __pad1; - unsigned long __pad2; -}; - -#define IPC_64 0 diff --git a/libc-top-half/musl/arch/aarch64/bits/msg.h b/libc-top-half/musl/arch/aarch64/bits/msg.h deleted file mode 100644 index 641e170..0000000 --- a/libc-top-half/musl/arch/aarch64/bits/msg.h +++ /dev/null @@ -1,13 +0,0 @@ -struct msqid_ds { - struct ipc_perm msg_perm; - time_t msg_stime; - time_t msg_rtime; - time_t msg_ctime; - unsigned long msg_cbytes; - msgqnum_t msg_qnum; - msglen_t msg_qbytes; - pid_t msg_lspid; - pid_t msg_lrpid; - unsigned long __pad1; - unsigned long __pad2; -}; diff --git a/libc-top-half/musl/arch/aarch64/bits/syscall.h.in b/libc-top-half/musl/arch/aarch64/bits/syscall.h.in index eed5a61..955e2ca 100644 --- a/libc-top-half/musl/arch/aarch64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/aarch64/bits/syscall.h.in @@ -281,4 +281,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/aarch64/kstat.h b/libc-top-half/musl/arch/aarch64/kstat.h new file mode 100644 index 0000000..92625f3 --- /dev/null +++ b/libc-top-half/musl/arch/aarch64/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned long __pad; + off_t st_size; + blksize_t st_blksize; + int __pad2; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/libc-top-half/musl/arch/aarch64/syscall_arch.h b/libc-top-half/musl/arch/aarch64/syscall_arch.h index 25f5ce6..504983a 100644 --- a/libc-top-half/musl/arch/aarch64/syscall_arch.h +++ b/libc-top-half/musl/arch/aarch64/syscall_arch.h @@ -74,3 +74,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo #define VDSO_USEFUL #define VDSO_CGT_SYM "__kernel_clock_gettime" #define VDSO_CGT_VER "LINUX_2.6.39" + +#define IPC_64 0 diff --git a/libc-top-half/musl/arch/arm/bits/ipcstat.h b/libc-top-half/musl/arch/arm/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/arm/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/powerpc64/bits/msg.h b/libc-top-half/musl/arch/arm/bits/msg.h similarity index 83% rename from libc-top-half/musl/arch/powerpc64/bits/msg.h rename to libc-top-half/musl/arch/arm/bits/msg.h index 2e23ca2..bc8436c 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/msg.h +++ b/libc-top-half/musl/arch/arm/bits/msg.h @@ -1,8 +1,11 @@ struct msqid_ds { struct ipc_perm msg_perm; time_t msg_stime; + int __unused1; time_t msg_rtime; + int __unused2; time_t msg_ctime; + int __unused3; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; diff --git a/libc-top-half/musl/arch/mips64/bits/sem.h b/libc-top-half/musl/arch/arm/bits/sem.h similarity index 52% rename from libc-top-half/musl/arch/mips64/bits/sem.h rename to libc-top-half/musl/arch/arm/bits/sem.h index e46ced9..d383d4e 100644 --- a/libc-top-half/musl/arch/mips64/bits/sem.h +++ b/libc-top-half/musl/arch/arm/bits/sem.h @@ -1,14 +1,16 @@ struct semid_ds { struct ipc_perm sem_perm; time_t sem_otime; + long __unused1; time_t sem_ctime; + long __unused2; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; #else - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - time_t __unused3; - time_t __unused4; + long __unused3; + long __unused4; }; diff --git a/libc-top-half/musl/arch/x86_64/bits/shm.h b/libc-top-half/musl/arch/arm/bits/shm.h similarity index 90% rename from libc-top-half/musl/arch/x86_64/bits/shm.h rename to libc-top-half/musl/arch/arm/bits/shm.h index 6652d65..81b2a29 100644 --- a/libc-top-half/musl/arch/x86_64/bits/shm.h +++ b/libc-top-half/musl/arch/arm/bits/shm.h @@ -4,8 +4,11 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; time_t shm_atime; + int __unused1; time_t shm_dtime; + int __unused2; time_t shm_ctime; + int __unused3; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; @@ -22,4 +25,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/arm/bits/syscall.h.in b/libc-top-half/musl/arch/arm/bits/syscall.h.in index 8ce1d70..a565a4e 100644 --- a/libc-top-half/musl/arch/arm/bits/syscall.h.in +++ b/libc-top-half/musl/arch/arm/bits/syscall.h.in @@ -381,6 +381,12 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 #define __ARM_NR_breakpoint 0x0f0001 #define __ARM_NR_cacheflush 0x0f0002 diff --git a/libc-top-half/musl/arch/arm/kstat.h b/libc-top-half/musl/arch/arm/kstat.h new file mode 100644 index 0000000..af449c9 --- /dev/null +++ b/libc-top-half/musl/arch/arm/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + int __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + ino_t st_ino; +}; diff --git a/libc-top-half/musl/arch/generic/bits/ipc.h b/libc-top-half/musl/arch/generic/bits/ipc.h index 779c42f..40d6f3a 100644 --- a/libc-top-half/musl/arch/generic/bits/ipc.h +++ b/libc-top-half/musl/arch/generic/bits/ipc.h @@ -9,5 +9,3 @@ struct ipc_perm { long __pad1; long __pad2; }; - -#define IPC_64 0x100 diff --git a/libc-top-half/musl/arch/generic/bits/ipcstat.h b/libc-top-half/musl/arch/generic/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/generic/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/generic/bits/msg.h b/libc-top-half/musl/arch/generic/bits/msg.h index bc8436c..2e23ca2 100644 --- a/libc-top-half/musl/arch/generic/bits/msg.h +++ b/libc-top-half/musl/arch/generic/bits/msg.h @@ -1,11 +1,8 @@ struct msqid_ds { struct ipc_perm msg_perm; time_t msg_stime; - int __unused1; time_t msg_rtime; - int __unused2; time_t msg_ctime; - int __unused3; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; diff --git a/libc-top-half/musl/arch/generic/bits/sem.h b/libc-top-half/musl/arch/generic/bits/sem.h index c629b81..5184eb5 100644 --- a/libc-top-half/musl/arch/generic/bits/sem.h +++ b/libc-top-half/musl/arch/generic/bits/sem.h @@ -1,16 +1,14 @@ struct semid_ds { struct ipc_perm sem_perm; time_t sem_otime; - time_t __unused1; time_t sem_ctime; - time_t __unused2; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; #else - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - time_t __unused3; - time_t __unused4; + long __unused3; + long __unused4; }; diff --git a/libc-top-half/musl/arch/generic/bits/shm.h b/libc-top-half/musl/arch/generic/bits/shm.h index 45d1d15..8d19378 100644 --- a/libc-top-half/musl/arch/generic/bits/shm.h +++ b/libc-top-half/musl/arch/generic/bits/shm.h @@ -4,11 +4,8 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; time_t shm_atime; - int __unused1; time_t shm_dtime; - int __unused2; time_t shm_ctime; - int __unused3; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; @@ -25,4 +22,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/i386/bits/ipcstat.h b/libc-top-half/musl/arch/i386/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/i386/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/s390x/bits/msg.h b/libc-top-half/musl/arch/i386/bits/msg.h similarity index 83% rename from libc-top-half/musl/arch/s390x/bits/msg.h rename to libc-top-half/musl/arch/i386/bits/msg.h index 2e23ca2..bc8436c 100644 --- a/libc-top-half/musl/arch/s390x/bits/msg.h +++ b/libc-top-half/musl/arch/i386/bits/msg.h @@ -1,8 +1,11 @@ struct msqid_ds { struct ipc_perm msg_perm; time_t msg_stime; + int __unused1; time_t msg_rtime; + int __unused2; time_t msg_ctime; + int __unused3; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; diff --git a/libc-top-half/musl/arch/i386/bits/sem.h b/libc-top-half/musl/arch/i386/bits/sem.h new file mode 100644 index 0000000..e61571c --- /dev/null +++ b/libc-top-half/musl/arch/i386/bits/sem.h @@ -0,0 +1,11 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long __unused1; + time_t sem_ctime; + long __unused2; + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + long __unused3; + long __unused4; +}; diff --git a/libc-top-half/musl/arch/mips64/bits/shm.h b/libc-top-half/musl/arch/i386/bits/shm.h similarity index 90% rename from libc-top-half/musl/arch/mips64/bits/shm.h rename to libc-top-half/musl/arch/i386/bits/shm.h index 8d19378..81b2a29 100644 --- a/libc-top-half/musl/arch/mips64/bits/shm.h +++ b/libc-top-half/musl/arch/i386/bits/shm.h @@ -4,8 +4,11 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; time_t shm_atime; + int __unused1; time_t shm_dtime; + int __unused2; time_t shm_ctime; + int __unused3; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; diff --git a/libc-top-half/musl/arch/i386/bits/syscall.h.in b/libc-top-half/musl/arch/i386/bits/syscall.h.in index fdfdc71..c95e108 100644 --- a/libc-top-half/musl/arch/i386/bits/syscall.h.in +++ b/libc-top-half/musl/arch/i386/bits/syscall.h.in @@ -418,4 +418,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/i386/kstat.h b/libc-top-half/musl/arch/i386/kstat.h new file mode 100644 index 0000000..af449c9 --- /dev/null +++ b/libc-top-half/musl/arch/i386/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + int __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + ino_t st_ino; +}; diff --git a/libc-top-half/musl/arch/m68k/bits/alltypes.h.in b/libc-top-half/musl/arch/m68k/bits/alltypes.h.in index a4a8141..bd37a63 100644 --- a/libc-top-half/musl/arch/m68k/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/m68k/bits/alltypes.h.in @@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list; TYPEDEF __builtin_va_list __isoc_va_list; #ifndef __cplusplus +#ifdef __WCHAR_TYPE__ +TYPEDEF __WCHAR_TYPE__ wchar_t; +#else TYPEDEF long wchar_t; #endif +#endif #if __mcffpu__ TYPEDEF float float_t; diff --git a/libc-top-half/musl/arch/m68k/bits/ipcstat.h b/libc-top-half/musl/arch/m68k/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/m68k/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/x86_64/bits/msg.h b/libc-top-half/musl/arch/m68k/bits/msg.h similarity index 83% rename from libc-top-half/musl/arch/x86_64/bits/msg.h rename to libc-top-half/musl/arch/m68k/bits/msg.h index 2e23ca2..bc8436c 100644 --- a/libc-top-half/musl/arch/x86_64/bits/msg.h +++ b/libc-top-half/musl/arch/m68k/bits/msg.h @@ -1,8 +1,11 @@ struct msqid_ds { struct ipc_perm msg_perm; time_t msg_stime; + int __unused1; time_t msg_rtime; + int __unused2; time_t msg_ctime; + int __unused3; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; diff --git a/libc-top-half/musl/arch/m68k/bits/sem.h b/libc-top-half/musl/arch/m68k/bits/sem.h new file mode 100644 index 0000000..08faafe --- /dev/null +++ b/libc-top-half/musl/arch/m68k/bits/sem.h @@ -0,0 +1,11 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long __unused1; + time_t sem_ctime; + long __unused2; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + unsigned short sem_nsems; + long __unused3; + long __unused4; +}; diff --git a/libc-top-half/musl/arch/s390x/bits/shm.h b/libc-top-half/musl/arch/m68k/bits/shm.h similarity index 90% rename from libc-top-half/musl/arch/s390x/bits/shm.h rename to libc-top-half/musl/arch/m68k/bits/shm.h index 6652d65..81b2a29 100644 --- a/libc-top-half/musl/arch/s390x/bits/shm.h +++ b/libc-top-half/musl/arch/m68k/bits/shm.h @@ -4,8 +4,11 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; time_t shm_atime; + int __unused1; time_t shm_dtime; + int __unused2; time_t shm_ctime; + int __unused3; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; @@ -22,4 +25,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/m68k/bits/syscall.h.in b/libc-top-half/musl/arch/m68k/bits/syscall.h.in index c7859b9..fb522b4 100644 --- a/libc-top-half/musl/arch/m68k/bits/syscall.h.in +++ b/libc-top-half/musl/arch/m68k/bits/syscall.h.in @@ -398,3 +398,9 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/m68k/kstat.h b/libc-top-half/musl/arch/m68k/kstat.h new file mode 100644 index 0000000..ac13e27 --- /dev/null +++ b/libc-top-half/musl/arch/m68k/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + short __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + short __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + ino_t st_ino; +}; diff --git a/libc-top-half/musl/arch/microblaze/bits/ipcstat.h b/libc-top-half/musl/arch/microblaze/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/microblaze/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/mips64/bits/msg.h b/libc-top-half/musl/arch/microblaze/bits/msg.h similarity index 73% rename from libc-top-half/musl/arch/mips64/bits/msg.h rename to libc-top-half/musl/arch/microblaze/bits/msg.h index 641e170..bc8436c 100644 --- a/libc-top-half/musl/arch/mips64/bits/msg.h +++ b/libc-top-half/musl/arch/microblaze/bits/msg.h @@ -1,13 +1,15 @@ struct msqid_ds { struct ipc_perm msg_perm; time_t msg_stime; + int __unused1; time_t msg_rtime; + int __unused2; time_t msg_ctime; + int __unused3; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; - unsigned long __pad1; - unsigned long __pad2; + unsigned long __unused[2]; }; diff --git a/libc-top-half/musl/arch/aarch64/bits/sem.h b/libc-top-half/musl/arch/microblaze/bits/sem.h similarity index 52% rename from libc-top-half/musl/arch/aarch64/bits/sem.h rename to libc-top-half/musl/arch/microblaze/bits/sem.h index e46ced9..d383d4e 100644 --- a/libc-top-half/musl/arch/aarch64/bits/sem.h +++ b/libc-top-half/musl/arch/microblaze/bits/sem.h @@ -1,14 +1,16 @@ struct semid_ds { struct ipc_perm sem_perm; time_t sem_otime; + long __unused1; time_t sem_ctime; + long __unused2; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; #else - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - time_t __unused3; - time_t __unused4; + long __unused3; + long __unused4; }; diff --git a/libc-top-half/musl/arch/aarch64/bits/shm.h b/libc-top-half/musl/arch/microblaze/bits/shm.h similarity index 90% rename from libc-top-half/musl/arch/aarch64/bits/shm.h rename to libc-top-half/musl/arch/microblaze/bits/shm.h index 8d19378..81b2a29 100644 --- a/libc-top-half/musl/arch/aarch64/bits/shm.h +++ b/libc-top-half/musl/arch/microblaze/bits/shm.h @@ -4,8 +4,11 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; time_t shm_atime; + int __unused1; time_t shm_dtime; + int __unused2; time_t shm_ctime; + int __unused3; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; diff --git a/libc-top-half/musl/arch/microblaze/bits/syscall.h.in b/libc-top-half/musl/arch/microblaze/bits/syscall.h.in index 91bc244..59f8623 100644 --- a/libc-top-half/musl/arch/microblaze/bits/syscall.h.in +++ b/libc-top-half/musl/arch/microblaze/bits/syscall.h.in @@ -419,4 +419,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/microblaze/kstat.h b/libc-top-half/musl/arch/microblaze/kstat.h new file mode 100644 index 0000000..c144957 --- /dev/null +++ b/libc-top-half/musl/arch/microblaze/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long long __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + int __st_blksize_padding; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/libc-top-half/musl/arch/mips/bits/ipcstat.h b/libc-top-half/musl/arch/mips/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/mips/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/mips/bits/sem.h b/libc-top-half/musl/arch/mips/bits/sem.h index e46ced9..5184eb5 100644 --- a/libc-top-half/musl/arch/mips/bits/sem.h +++ b/libc-top-half/musl/arch/mips/bits/sem.h @@ -4,11 +4,11 @@ struct semid_ds { time_t sem_ctime; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; #else - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - time_t __unused3; - time_t __unused4; + long __unused3; + long __unused4; }; diff --git a/libc-top-half/musl/arch/mips/bits/shm.h b/libc-top-half/musl/arch/mips/bits/shm.h index 6652d65..8d19378 100644 --- a/libc-top-half/musl/arch/mips/bits/shm.h +++ b/libc-top-half/musl/arch/mips/bits/shm.h @@ -22,4 +22,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/mips/bits/syscall.h.in b/libc-top-half/musl/arch/mips/bits/syscall.h.in index 6175a7c..582fa3b 100644 --- a/libc-top-half/musl/arch/mips/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mips/bits/syscall.h.in @@ -400,4 +400,10 @@ #define __NR_io_uring_setup 4425 #define __NR_io_uring_enter 4426 #define __NR_io_uring_register 4427 +#define __NR_open_tree 4428 +#define __NR_move_mount 4429 +#define __NR_fsopen 4430 +#define __NR_fsconfig 4431 +#define __NR_fsmount 4432 +#define __NR_fspick 4433 diff --git a/libc-top-half/musl/arch/mips/kstat.h b/libc-top-half/musl/arch/mips/kstat.h new file mode 100644 index 0000000..5e637ea --- /dev/null +++ b/libc-top-half/musl/arch/mips/kstat.h @@ -0,0 +1,22 @@ +struct kstat { + unsigned st_dev; + long __st_padding1[3]; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + unsigned st_rdev; + long __st_padding2[3]; + off_t st_size; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + blksize_t st_blksize; + long __st_padding3; + blkcnt_t st_blocks; + long __st_padding4[14]; +}; diff --git a/libc-top-half/musl/arch/mips/syscall_arch.h b/libc-top-half/musl/arch/mips/syscall_arch.h index 43bcdee..6ea7343 100644 --- a/libc-top-half/musl/arch/mips/syscall_arch.h +++ b/libc-top-half/musl/arch/mips/syscall_arch.h @@ -5,27 +5,25 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __stat_fix(st) ((st),(void)0) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" #else -#include -static inline void __stat_fix(long p) -{ - struct stat *st = (struct stat *)p; - st->st_dev >>= 32; - st->st_rdev >>= 32; -} +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "hi", "lo", "memory" #endif static inline long __syscall0(long n) { register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+r"(r2), "=r"(r7) + : + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -33,13 +31,12 @@ static inline long __syscall1(long n, long a) { register long r4 __asm__("$4") = a; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+r"(r2), "=r"(r7) + : "r"(r4) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); return r7 ? -r2 : r2; } @@ -48,17 +45,13 @@ static inline long __syscall2(long n, long a, long b) register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return ret; + "syscall" + : "+r"(r2), "=r"(r7) + : "r"(r4), "r"(r5) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 ? -r2 : r2; } static inline long __syscall3(long n, long a, long b, long c) @@ -67,17 +60,13 @@ static inline long __syscall3(long n, long a, long b, long c) register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - return ret; + "syscall" + : "+r"(r2), "=r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 ? -r2 : r2; } static inline long __syscall4(long n, long a, long b, long c, long d) @@ -86,18 +75,13 @@ static inline long __syscall4(long n, long a, long b, long c, long d) register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat64) __stat_fix(c); - return ret; + "syscall" + : "+r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$8", "$9", "$10"); + return r7 ? -r2 : r2; } static inline long __syscall5(long n, long a, long b, long c, long d, long e) @@ -107,20 +91,15 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e) register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( "subu $sp,$sp,32 ; sw $8,16($sp) ; " - "addu $2,$0,%3 ; syscall ;" + "syscall ;" "addu $sp,$sp,32" - : "=&r"(r2), "=r"(r7), "+r"(r8) - : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat64) __stat_fix(c); - return r2; + : "+r"(r2), "+r"(r7), "+r"(r8) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$9", "$10"); + return r7 ? -r2 : r2; } static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) @@ -131,20 +110,15 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; register long r9 __asm__("$9") = f; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; " - "addu $2,$0,%4 ; syscall ;" + "syscall ;" "addu $sp,$sp,32" - : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9) - : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat64) __stat_fix(c); - return r2; + : "+r"(r2), "+r"(r7), "+r"(r8), "+r"(r9) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST, "$10"); + return r7 ? -r2 : r2; } static inline long __syscall7(long n, long a, long b, long c, long d, long e, long f, long g) @@ -156,22 +130,20 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo register long r8 __asm__("$8") = e; register long r9 __asm__("$9") = f; register long r10 __asm__("$10") = g; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( "subu $sp,$sp,32 ; sw $8,16($sp) ; sw $9,20($sp) ; sw $10,24($sp) ; " - "addu $2,$0,%5 ; syscall ;" + "syscall ;" "addu $sp,$sp,32" - : "=&r"(r2), "=r"(r7), "+r"(r8), "+r"(r9), "+r"(r10) - : "ir"(n), "0"(r2), "1"(r7), "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat64 || n == SYS_fstat64 || n == SYS_lstat64) __stat_fix(b); - if (n == SYS_fstatat64) __stat_fix(c); - return r2; + : "+r"(r2), "+r"(r7), "+r"(r8), "+r"(r9), "+r"(r10) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } #define VDSO_USEFUL #define VDSO_CGT_SYM "__vdso_clock_gettime" #define VDSO_CGT_VER "LINUX_2.6" + +#define SO_SNDTIMEO_OLD 0x1005 +#define SO_RCVTIMEO_OLD 0x1006 diff --git a/libc-top-half/musl/arch/mips64/bits/ipc.h b/libc-top-half/musl/arch/mips64/bits/ipc.h index 43a8314..df22716 100644 --- a/libc-top-half/musl/arch/mips64/bits/ipc.h +++ b/libc-top-half/musl/arch/mips64/bits/ipc.h @@ -10,5 +10,3 @@ struct ipc_perm { unsigned long __unused1; unsigned long __unused2; }; - -#define IPC_64 0x100 diff --git a/libc-top-half/musl/arch/mips64/bits/stat.h b/libc-top-half/musl/arch/mips64/bits/stat.h index b46617f..b620e14 100644 --- a/libc-top-half/musl/arch/mips64/bits/stat.h +++ b/libc-top-half/musl/arch/mips64/bits/stat.h @@ -1,6 +1,3 @@ -#include -#include - struct stat { dev_t st_dev; int __pad1[3]; diff --git a/libc-top-half/musl/arch/mips64/bits/syscall.h.in b/libc-top-half/musl/arch/mips64/bits/syscall.h.in index ca99e45..34b9752 100644 --- a/libc-top-half/musl/arch/mips64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mips64/bits/syscall.h.in @@ -330,4 +330,10 @@ #define __NR_io_uring_setup 5425 #define __NR_io_uring_enter 5426 #define __NR_io_uring_register 5427 +#define __NR_open_tree 5428 +#define __NR_move_mount 5429 +#define __NR_fsopen 5430 +#define __NR_fsconfig 5431 +#define __NR_fsmount 5432 +#define __NR_fspick 5433 diff --git a/libc-top-half/musl/arch/mips64/kstat.h b/libc-top-half/musl/arch/mips64/kstat.h new file mode 100644 index 0000000..9a4468b --- /dev/null +++ b/libc-top-half/musl/arch/mips64/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + unsigned st_dev; + int __pad1[3]; + ino_t st_ino; + mode_t st_mode; + unsigned st_nlink; + uid_t st_uid; + gid_t st_gid; + unsigned st_rdev; + int __pad2[3]; + off_t st_size; + int st_atime_sec; + int st_atime_nsec; + int st_mtime_sec; + int st_mtime_nsec; + int st_ctime_sec; + int st_ctime_nsec; + unsigned st_blksize; + unsigned __pad3; + blkcnt_t st_blocks; +}; diff --git a/libc-top-half/musl/arch/mips64/syscall_arch.h b/libc-top-half/musl/arch/mips64/syscall_arch.h index 99eebc3..69c429b 100644 --- a/libc-top-half/musl/arch/mips64/syscall_arch.h +++ b/libc-top-half/musl/arch/mips64/syscall_arch.h @@ -3,58 +3,25 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) -#include -struct kernel_stat { - unsigned int st_dev; - unsigned int __pad1[3]; - unsigned long long st_ino; - unsigned int st_mode; - unsigned int st_nlink; - int st_uid; - int st_gid; - unsigned int st_rdev; - unsigned int __pad2[3]; - long long st_size; - unsigned int st_atime_sec; - unsigned int st_atime_nsec; - unsigned int st_mtime_sec; - unsigned int st_mtime_nsec; - unsigned int st_ctime_sec; - unsigned int st_ctime_nsec; - unsigned int st_blksize; - unsigned int __pad3; - unsigned long long st_blocks; -}; - -static void __stat_fix(struct kernel_stat *kst, struct stat *st) -{ - st->st_dev = kst->st_dev; - st->st_ino = kst->st_ino; - st->st_mode = kst->st_mode; - st->st_nlink = kst->st_nlink; - st->st_uid = kst->st_uid; - st->st_gid = kst->st_gid; - st->st_rdev = kst->st_rdev; - st->st_size = kst->st_size; - st->st_atim.tv_sec = kst->st_atime_sec; - st->st_atim.tv_nsec = kst->st_atime_nsec; - st->st_mtim.tv_sec = kst->st_mtime_sec; - st->st_mtim.tv_nsec = kst->st_mtime_nsec; - st->st_ctim.tv_sec = kst->st_ctime_sec; - st->st_ctim.tv_nsec = kst->st_ctime_nsec; - st->st_blksize = kst->st_blksize; - st->st_blocks = kst->st_blocks; -} +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" +#else +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "hi", "lo", "memory" +#endif static inline long __syscall0(long n) { register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+&r"(r2), "=r"(r7) + : + : SYSCALL_CLOBBERLIST); return r7 ? -r2 : r2; } @@ -62,175 +29,100 @@ static inline long __syscall1(long n, long a) { register long r4 __asm__("$4") = a; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4) + : SYSCALL_CLOBBERLIST); return r7 ? -r2 : r2; } static inline long __syscall2(long n, long a, long b) { - struct kernel_stat kst; - long ret; register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - r5 = (long) &kst; + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - - if (r7) return -r2; - ret = r2; - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - __stat_fix(&kst, (struct stat *)b); - - return ret; + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4), "r"(r5) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall3(long n, long a, long b, long c) { - struct kernel_stat kst; - long ret; register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - r5 = (long) &kst; + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - - if (r7) return -r2; - ret = r2; - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - __stat_fix(&kst, (struct stat *)b); - - return ret; + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall4(long n, long a, long b, long c, long d) { - struct kernel_stat kst; - long ret; register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; - register long r2 __asm__("$2"); - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - r5 = (long) &kst; - if (n == SYS_newfstatat) - r6 = (long) &kst; + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - - if (r7) return -r2; - ret = r2; - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - __stat_fix(&kst, (struct stat *)b); - if (n == SYS_newfstatat) - __stat_fix(&kst, (struct stat *)c); - - return ret; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall5(long n, long a, long b, long c, long d, long e) { - struct kernel_stat kst; - long ret; register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; - register long r2 __asm__("$2"); - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - r5 = (long) &kst; - if (n == SYS_newfstatat) - r6 = (long) &kst; + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6), "r"(r8) - : "$1", "$3", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - - if (r7) return -r2; - ret = r2; - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - __stat_fix(&kst, (struct stat *)b); - if (n == SYS_newfstatat) - __stat_fix(&kst, (struct stat *)c); - - return ret; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6), "r"(r8) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) { - struct kernel_stat kst; - long ret; register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; register long r9 __asm__("$9") = f; - register long r2 __asm__("$2"); - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - r5 = (long) &kst; - if (n == SYS_newfstatat) - r6 = (long) &kst; + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "daddu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9) - : "$1", "$3", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - - if (r7) return -r2; - ret = r2; - - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) - __stat_fix(&kst, (struct stat *)b); - if (n == SYS_newfstatat) - __stat_fix(&kst, (struct stat *)c); - - return ret; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } #define VDSO_USEFUL #define VDSO_CGT_SYM "__vdso_clock_gettime" #define VDSO_CGT_VER "LINUX_2.6" + +#define SO_SNDTIMEO_OLD 0x1005 +#define SO_RCVTIMEO_OLD 0x1006 diff --git a/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h b/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/mipsn32/bits/sem.h b/libc-top-half/musl/arch/mipsn32/bits/sem.h index e46ced9..5184eb5 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/sem.h +++ b/libc-top-half/musl/arch/mipsn32/bits/sem.h @@ -4,11 +4,11 @@ struct semid_ds { time_t sem_ctime; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; #else - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - time_t __unused3; - time_t __unused4; + long __unused3; + long __unused4; }; diff --git a/libc-top-half/musl/arch/mipsn32/bits/stat.h b/libc-top-half/musl/arch/mipsn32/bits/stat.h index f4d1df8..27d36b5 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/stat.h +++ b/libc-top-half/musl/arch/mipsn32/bits/stat.h @@ -1,6 +1,3 @@ -#include -#include - struct stat { dev_t st_dev; long __pad1[2]; diff --git a/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in b/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in index f31ee44..d80cafa 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in @@ -354,4 +354,10 @@ #define __NR_io_uring_setup 6425 #define __NR_io_uring_enter 6426 #define __NR_io_uring_register 6427 +#define __NR_open_tree 6428 +#define __NR_move_mount 6429 +#define __NR_fsopen 6430 +#define __NR_fsconfig 6431 +#define __NR_fsmount 6432 +#define __NR_fspick 6433 diff --git a/libc-top-half/musl/arch/mipsn32/kstat.h b/libc-top-half/musl/arch/mipsn32/kstat.h new file mode 100644 index 0000000..3841559 --- /dev/null +++ b/libc-top-half/musl/arch/mipsn32/kstat.h @@ -0,0 +1,22 @@ +struct kstat { + unsigned st_dev; + long __pad1[3]; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + unsigned st_rdev; + long __pad2[3]; + off_t st_size; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + blksize_t st_blksize; + long __pad3; + blkcnt_t st_blocks; + long __pad4[14]; +}; diff --git a/libc-top-half/musl/arch/mipsn32/syscall_arch.h b/libc-top-half/musl/arch/mipsn32/syscall_arch.h index 7b11740..5ff43bb 100644 --- a/libc-top-half/musl/arch/mipsn32/syscall_arch.h +++ b/libc-top-half/musl/arch/mipsn32/syscall_arch.h @@ -3,27 +3,25 @@ #define SYSCALL_RLIM_INFINITY (-1UL/2) -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __stat_fix(st) ((st),(void)0) +#if __mips_isa_rev >= 6 +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "memory" #else -#include -static inline void __stat_fix(long p) -{ - struct stat *st = (struct stat *)p; - st->st_dev >>= 32; - st->st_rdev >>= 32; -} +#define SYSCALL_CLOBBERLIST \ + "$1", "$3", "$10", "$11", "$12", "$13", \ + "$14", "$15", "$24", "$25", "hi", "lo", "memory" #endif static inline long __syscall0(long n) { register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+&r"(r2), "=r"(r7) + : + : SYSCALL_CLOBBERLIST); return r7 ? -r2 : r2; } @@ -31,13 +29,12 @@ static inline long __syscall1(long n, long a) { register long r4 __asm__("$4") = a; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4) + : SYSCALL_CLOBBERLIST); return r7 ? -r2 : r2; } @@ -46,17 +43,13 @@ static inline long __syscall2(long n, long a, long b) register long r4 __asm__("$4") = a; register long r5 __asm__("$5") = b; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b); - return ret; + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4), "r"(r5) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall3(long n, long a, long b, long c) @@ -65,17 +58,13 @@ static inline long __syscall3(long n, long a, long b, long c) register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7"); - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b); - return ret; + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall4(long n, long a, long b, long c, long d) @@ -84,18 +73,13 @@ static inline long __syscall4(long n, long a, long b, long c, long d) register long r5 __asm__("$5") = b; register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6) - : "$1", "$3", "$8", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (r7) return -r2; - long ret = r2; - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b); - if (n == SYS_newfstatat) __stat_fix(c); - return ret; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall5(long n, long a, long b, long c, long d, long e) @@ -105,16 +89,13 @@ static inline long __syscall5(long n, long a, long b, long c, long d, long e) register long r6 __asm__("$6") = c; register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6), "r"(r8) - : "$1", "$3", "$9", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b); - if (n == SYS_newfstatat) __stat_fix(c); - return r2; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6), "r"(r8) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } static inline long __syscall6(long n, long a, long b, long c, long d, long e, long f) @@ -125,18 +106,18 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo register long r7 __asm__("$7") = d; register long r8 __asm__("$8") = e; register long r9 __asm__("$9") = f; - register long r2 __asm__("$2"); + register long r2 __asm__("$2") = n; __asm__ __volatile__ ( - "addu $2,$0,%2 ; syscall" - : "=&r"(r2), "=r"(r7) : "ir"(n), "0"(r2), "1"(r7), - "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9) - : "$1", "$3", "$10", "$11", "$12", "$13", - "$14", "$15", "$24", "$25", "hi", "lo", "memory"); - if (n == SYS_stat || n == SYS_fstat || n == SYS_lstat) __stat_fix(b); - if (n == SYS_newfstatat) __stat_fix(c); - return r2; + "syscall" + : "+&r"(r2), "+r"(r7) + : "r"(r4), "r"(r5), "r"(r6), "r"(r8), "r"(r9) + : SYSCALL_CLOBBERLIST); + return r7 ? -r2 : r2; } #define VDSO_USEFUL #define VDSO_CGT_SYM "__vdso_clock_gettime" #define VDSO_CGT_VER "LINUX_2.6" + +#define SO_SNDTIMEO_OLD 0x1005 +#define SO_RCVTIMEO_OLD 0x1006 diff --git a/libc-top-half/musl/arch/or1k/bits/ipc.h b/libc-top-half/musl/arch/or1k/bits/ipc.h deleted file mode 100644 index 3d894e3..0000000 --- a/libc-top-half/musl/arch/or1k/bits/ipc.h +++ /dev/null @@ -1,13 +0,0 @@ -struct ipc_perm { - key_t __ipc_perm_key; - uid_t uid; - gid_t gid; - uid_t cuid; - gid_t cgid; - mode_t mode; - int __ipc_perm_seq; - long __pad1; - long __pad2; -}; - -#define IPC_64 0 diff --git a/libc-top-half/musl/arch/or1k/bits/ipcstat.h b/libc-top-half/musl/arch/or1k/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/or1k/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/or1k/bits/sem.h b/libc-top-half/musl/arch/or1k/bits/sem.h new file mode 100644 index 0000000..08faafe --- /dev/null +++ b/libc-top-half/musl/arch/or1k/bits/sem.h @@ -0,0 +1,11 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long __unused1; + time_t sem_ctime; + long __unused2; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + unsigned short sem_nsems; + long __unused3; + long __unused4; +}; diff --git a/libc-top-half/musl/arch/or1k/bits/shm.h b/libc-top-half/musl/arch/or1k/bits/shm.h new file mode 100644 index 0000000..81b2a29 --- /dev/null +++ b/libc-top-half/musl/arch/or1k/bits/shm.h @@ -0,0 +1,27 @@ +#define SHMLBA 4096 + +struct shmid_ds { + struct ipc_perm shm_perm; + size_t shm_segsz; + time_t shm_atime; + int __unused1; + time_t shm_dtime; + int __unused2; + time_t shm_ctime; + int __unused3; + pid_t shm_cpid; + pid_t shm_lpid; + unsigned long shm_nattch; + unsigned long __pad1; + unsigned long __pad2; +}; + +struct shminfo { + unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4]; +}; + +struct shm_info { + int __used_ids; + unsigned long shm_tot, shm_rss, shm_swp; + unsigned long __swap_attempts, __swap_successes; +}; diff --git a/libc-top-half/musl/arch/or1k/bits/syscall.h.in b/libc-top-half/musl/arch/or1k/bits/syscall.h.in index 33a8686..8ffcfae 100644 --- a/libc-top-half/musl/arch/or1k/bits/syscall.h.in +++ b/libc-top-half/musl/arch/or1k/bits/syscall.h.in @@ -303,4 +303,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/or1k/kstat.h b/libc-top-half/musl/arch/or1k/kstat.h new file mode 100644 index 0000000..c144957 --- /dev/null +++ b/libc-top-half/musl/arch/or1k/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + long long __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + int __st_blksize_padding; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/libc-top-half/musl/arch/or1k/syscall_arch.h b/libc-top-half/musl/arch/or1k/syscall_arch.h index 5a9b074..21738ce 100644 --- a/libc-top-half/musl/arch/or1k/syscall_arch.h +++ b/libc-top-half/musl/arch/or1k/syscall_arch.h @@ -111,3 +111,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo "r23", "r25", "r27", "r29", "r31"); return r11; } + +#define IPC_64 0 diff --git a/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in b/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in index 37f27d6..8e687ef 100644 --- a/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in @@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list; TYPEDEF __builtin_va_list __isoc_va_list; #ifndef __cplusplus +#ifdef __WCHAR_TYPE__ +TYPEDEF __WCHAR_TYPE__ wchar_t; +#else TYPEDEF long wchar_t; #endif +#endif TYPEDEF float float_t; TYPEDEF double double_t; diff --git a/libc-top-half/musl/arch/powerpc/bits/ipc.h b/libc-top-half/musl/arch/powerpc/bits/ipc.h index 3f2ede0..a388d56 100644 --- a/libc-top-half/musl/arch/powerpc/bits/ipc.h +++ b/libc-top-half/musl/arch/powerpc/bits/ipc.h @@ -10,6 +10,3 @@ struct ipc_perm { long long __pad2; long long __pad3; }; - -#define IPC_64 0x100 - diff --git a/libc-top-half/musl/arch/powerpc/bits/ipcstat.h b/libc-top-half/musl/arch/powerpc/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/powerpc/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/powerpc/bits/shm.h b/libc-top-half/musl/arch/powerpc/bits/shm.h index 40e5e8b..b19801d 100644 --- a/libc-top-half/musl/arch/powerpc/bits/shm.h +++ b/libc-top-half/musl/arch/powerpc/bits/shm.h @@ -26,4 +26,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/powerpc/bits/syscall.h.in b/libc-top-half/musl/arch/powerpc/bits/syscall.h.in index 0a6c9ad..adcf63d 100644 --- a/libc-top-half/musl/arch/powerpc/bits/syscall.h.in +++ b/libc-top-half/musl/arch/powerpc/bits/syscall.h.in @@ -407,4 +407,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/powerpc/bits/user.h b/libc-top-half/musl/arch/powerpc/bits/user.h index 6cc8aaf..7f52874 100644 --- a/libc-top-half/musl/arch/powerpc/bits/user.h +++ b/libc-top-half/musl/arch/powerpc/bits/user.h @@ -1,10 +1,8 @@ -struct pt_regs { - unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, mq; - unsigned long trap, dar, dsisr, result; -}; - struct user { - struct pt_regs regs; + struct { + unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, mq; + unsigned long trap, dar, dsisr, result; + } regs; unsigned long u_tsize, u_dsize, u_ssize; unsigned long start_code, start_data, start_stack; long signal; diff --git a/libc-top-half/musl/arch/powerpc/kstat.h b/libc-top-half/musl/arch/powerpc/kstat.h new file mode 100644 index 0000000..5a611e7 --- /dev/null +++ b/libc-top-half/musl/arch/powerpc/kstat.h @@ -0,0 +1,20 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + short __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/libc-top-half/musl/arch/powerpc/reloc.h b/libc-top-half/musl/arch/powerpc/reloc.h index 1b4cab3..527b6b7 100644 --- a/libc-top-half/musl/arch/powerpc/reloc.h +++ b/libc-top-half/musl/arch/powerpc/reloc.h @@ -9,6 +9,7 @@ #define TPOFF_K (-0x7000) #define REL_SYMBOLIC R_PPC_ADDR32 +#define REL_USYMBOLIC R_PPC_UADDR32 #define REL_GOT R_PPC_GLOB_DAT #define REL_PLT R_PPC_JMP_SLOT #define REL_RELATIVE R_PPC_RELATIVE diff --git a/libc-top-half/musl/arch/powerpc/syscall_arch.h b/libc-top-half/musl/arch/powerpc/syscall_arch.h index e26a3c3..ede97c1 100644 --- a/libc-top-half/musl/arch/powerpc/syscall_arch.h +++ b/libc-top-half/musl/arch/powerpc/syscall_arch.h @@ -89,3 +89,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo } #define SYSCALL_FADVISE_6_ARG + +#define SO_RCVTIMEO_OLD 18 +#define SO_SNDTIMEO_OLD 19 diff --git a/libc-top-half/musl/arch/powerpc64/bits/ipc.h b/libc-top-half/musl/arch/powerpc64/bits/ipc.h index 3f2ede0..a388d56 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/ipc.h +++ b/libc-top-half/musl/arch/powerpc64/bits/ipc.h @@ -10,6 +10,3 @@ struct ipc_perm { long long __pad2; long long __pad3; }; - -#define IPC_64 0x100 - diff --git a/libc-top-half/musl/arch/powerpc64/bits/sem.h b/libc-top-half/musl/arch/powerpc64/bits/sem.h deleted file mode 100644 index 558184d..0000000 --- a/libc-top-half/musl/arch/powerpc64/bits/sem.h +++ /dev/null @@ -1,13 +0,0 @@ -#include - -struct semid_ds { - struct ipc_perm sem_perm; - time_t sem_otime; - time_t sem_ctime; -#if __BYTE_ORDER == __BIG_ENDIAN - unsigned short __pad[3], sem_nsems; -#else - unsigned short sem_nsems, __pad[3]; -#endif - unsigned long __unused[2]; -}; diff --git a/libc-top-half/musl/arch/powerpc64/bits/shm.h b/libc-top-half/musl/arch/powerpc64/bits/shm.h index 8108c3a..b7f73a8 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/shm.h +++ b/libc-top-half/musl/arch/powerpc64/bits/shm.h @@ -21,4 +21,3 @@ struct shm_info { unsigned long shm_tot, shm_rss, shm_swp; unsigned long __swap_attempts, __swap_successes; }; - diff --git a/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in b/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in index 0c894a2..32545b3 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in @@ -379,4 +379,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/powerpc64/bits/user.h b/libc-top-half/musl/arch/powerpc64/bits/user.h index 7ca459b..7e75d20 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/user.h +++ b/libc-top-half/musl/arch/powerpc64/bits/user.h @@ -1,10 +1,8 @@ -struct pt_regs { - unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, softe; - unsigned long trap, dar, dsisr, result; -}; - struct user { - struct pt_regs regs; + struct { + unsigned long gpr[32], nip, msr, orig_gpr3, ctr, link, xer, ccr, softe; + unsigned long trap, dar, dsisr, result; + } regs; unsigned long u_tsize, u_dsize, u_ssize; unsigned long start_code, start_data, start_stack; long signal; diff --git a/libc-top-half/musl/arch/powerpc64/kstat.h b/libc-top-half/musl/arch/powerpc64/kstat.h new file mode 100644 index 0000000..887b3e2 --- /dev/null +++ b/libc-top-half/musl/arch/powerpc64/kstat.h @@ -0,0 +1,19 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned long __unused[3]; +}; diff --git a/libc-top-half/musl/arch/powerpc64/reloc.h b/libc-top-half/musl/arch/powerpc64/reloc.h index faf70ac..5bdaeed 100644 --- a/libc-top-half/musl/arch/powerpc64/reloc.h +++ b/libc-top-half/musl/arch/powerpc64/reloc.h @@ -11,6 +11,7 @@ #define TPOFF_K (-0x7000) #define REL_SYMBOLIC R_PPC64_ADDR64 +#define REL_USYMBOLIC R_PPC64_UADDR64 #define REL_GOT R_PPC64_GLOB_DAT #define REL_PLT R_PPC64_JMP_SLOT #define REL_RELATIVE R_PPC64_RELATIVE diff --git a/libc-top-half/musl/arch/powerpc64/syscall_arch.h b/libc-top-half/musl/arch/powerpc64/syscall_arch.h index 1e73062..76b4e33 100644 --- a/libc-top-half/musl/arch/powerpc64/syscall_arch.h +++ b/libc-top-half/musl/arch/powerpc64/syscall_arch.h @@ -85,3 +85,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo :: "memory", "cr0", "r9", "r10", "r11", "r12"); return r3; } + +#define SO_RCVTIMEO_OLD 18 +#define SO_SNDTIMEO_OLD 19 diff --git a/libc-top-half/musl/arch/riscv64/atomic_arch.h b/libc-top-half/musl/arch/riscv64/atomic_arch.h index 98f12fc..41ad4d0 100644 --- a/libc-top-half/musl/arch/riscv64/atomic_arch.h +++ b/libc-top-half/musl/arch/riscv64/atomic_arch.h @@ -8,13 +8,15 @@ static inline void a_barrier() static inline int a_cas(volatile int *p, int t, int s) { int old, tmp; - __asm__("\n1: lr.w.aqrl %0, %2\n" + __asm__ __volatile__ ( + "\n1: lr.w.aqrl %0, (%2)\n" " bne %0, %3, 1f\n" - " sc.w.aqrl %1, %4, %2\n" + " sc.w.aqrl %1, %4, (%2)\n" " bnez %1, 1b\n" "1:" - : "=&r"(old), "+r"(tmp), "+A"(*p) - : "r"(t), "r"(s)); + : "=&r"(old), "=&r"(tmp) + : "r"(p), "r"(t), "r"(s) + : "memory"); return old; } @@ -23,12 +25,14 @@ static inline void *a_cas_p(volatile void *p, void *t, void *s) { void *old; int tmp; - __asm__("\n1: lr.d.aqrl %0, %2\n" + __asm__ __volatile__ ( + "\n1: lr.d.aqrl %0, (%2)\n" " bne %0, %3, 1f\n" - " sc.d.aqrl %1, %4, %2\n" + " sc.d.aqrl %1, %4, (%2)\n" " bnez %1, 1b\n" "1:" - : "=&r"(old), "+r"(tmp), "+A"(*(long *)p) - : "r"(t), "r"(s)); + : "=&r"(old), "=&r"(tmp) + : "r"(p), "r"(t), "r"(s) + : "memory"); return old; } diff --git a/libc-top-half/musl/arch/riscv64/bits/ipc.h b/libc-top-half/musl/arch/riscv64/bits/ipc.h deleted file mode 100644 index 6f3328a..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/ipc.h +++ /dev/null @@ -1,14 +0,0 @@ -struct ipc_perm { - key_t __ipc_perm_key; - uid_t uid; - gid_t gid; - uid_t cuid; - gid_t cgid; - mode_t mode; - unsigned short __ipc_perm_seq; - - unsigned long __pad1; - unsigned long __pad2; -}; - -#define IPC_64 0 diff --git a/libc-top-half/musl/arch/riscv64/bits/msg.h b/libc-top-half/musl/arch/riscv64/bits/msg.h deleted file mode 100644 index 641e170..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/msg.h +++ /dev/null @@ -1,13 +0,0 @@ -struct msqid_ds { - struct ipc_perm msg_perm; - time_t msg_stime; - time_t msg_rtime; - time_t msg_ctime; - unsigned long msg_cbytes; - msgqnum_t msg_qnum; - msglen_t msg_qbytes; - pid_t msg_lspid; - pid_t msg_lrpid; - unsigned long __pad1; - unsigned long __pad2; -}; diff --git a/libc-top-half/musl/arch/riscv64/bits/sem.h b/libc-top-half/musl/arch/riscv64/bits/sem.h deleted file mode 100644 index 5f93c12..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/sem.h +++ /dev/null @@ -1,9 +0,0 @@ -struct semid_ds { - struct ipc_perm sem_perm; - time_t sem_otime; - time_t sem_ctime; - unsigned short sem_nsems; - char __sem_nsems_pad[sizeof(time_t)-sizeof(short)]; - time_t __unused3; - time_t __unused4; -}; diff --git a/libc-top-half/musl/arch/riscv64/bits/shm.h b/libc-top-half/musl/arch/riscv64/bits/shm.h deleted file mode 100644 index 4c3c9fb..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/shm.h +++ /dev/null @@ -1,25 +0,0 @@ -#define SHMLBA 4096 - -struct shmid_ds -{ - struct ipc_perm shm_perm; - size_t shm_segsz; - time_t shm_atime; - time_t shm_dtime; - time_t shm_ctime; - pid_t shm_cpid; - pid_t shm_lpid; - unsigned long shm_nattch; - unsigned long __pad1; - unsigned long __pad2; -}; - -struct shminfo { - unsigned long shmmax, shmmin, shmmni, shmseg, shmall, __unused[4]; -}; - -struct shm_info { - int __used_ids; - unsigned long shm_tot, shm_rss, shm_swp; - unsigned long __swap_attempts, __swap_successes; -}; diff --git a/libc-top-half/musl/arch/riscv64/bits/signal.h b/libc-top-half/musl/arch/riscv64/bits/signal.h index 4c94a8f..2ff4be3 100644 --- a/libc-top-half/musl/arch/riscv64/bits/signal.h +++ b/libc-top-half/musl/arch/riscv64/bits/signal.h @@ -6,46 +6,43 @@ # define SIGSTKSZ 8192 #endif -/* gregs[0] holds the program counter. */ +typedef unsigned long __riscv_mc_gp_state[32]; + +struct __riscv_mc_f_ext_state { + unsigned int __f[32]; + unsigned int __fcsr; +}; + +struct __riscv_mc_d_ext_state { + unsigned long long __f[32]; + unsigned int __fcsr; +}; + +struct __riscv_mc_q_ext_state { + unsigned long long __f[64] __attribute__((aligned(16))); + unsigned int __fcsr; + unsigned int __reserved[3]; +}; + +union __riscv_mc_fp_state { + struct __riscv_mc_f_ext_state __f; + struct __riscv_mc_d_ext_state __d; + struct __riscv_mc_q_ext_state __q; +}; + +typedef struct mcontext_t { + __riscv_mc_gp_state __gregs; + union __riscv_mc_fp_state __fpregs; +} mcontext_t; #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) typedef unsigned long greg_t; typedef unsigned long gregset_t[32]; - -struct __riscv_f_ext_state { - unsigned int f[32]; - unsigned int fcsr; -}; - -struct __riscv_d_ext_state { - unsigned long long f[32]; - unsigned int fcsr; -}; - -struct __riscv_q_ext_state { - unsigned long long f[64] __attribute__((aligned(16))); - unsigned int fcsr; - unsigned int reserved[3]; -}; - -union __riscv_fp_state { - struct __riscv_f_ext_state f; - struct __riscv_d_ext_state d; - struct __riscv_q_ext_state q; -}; - -typedef union __riscv_fp_state fpregset_t; - -typedef struct sigcontext { +typedef union __riscv_mc_fp_state fpregset_t; +struct sigcontext { gregset_t gregs; fpregset_t fpregs; -} mcontext_t; - -#else -typedef struct { - unsigned long gregs[32]; - unsigned long long fpregs[66]; -} mcontext_t; +}; #endif struct sigaltstack { @@ -54,10 +51,10 @@ struct sigaltstack { size_t ss_size; }; -typedef struct __ucontext +typedef struct ucontext_t { unsigned long uc_flags; - struct __ucontext *uc_link; + struct ucontext_t *uc_link; stack_t uc_stack; sigset_t uc_sigmask; mcontext_t uc_mcontext; diff --git a/libc-top-half/musl/arch/riscv64/bits/syscall.h.in b/libc-top-half/musl/arch/riscv64/bits/syscall.h.in index 03d7f86..1db70cf 100644 --- a/libc-top-half/musl/arch/riscv64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/riscv64/bits/syscall.h.in @@ -273,5 +273,20 @@ #define __NR_pkey_mprotect 288 #define __NR_pkey_alloc 289 #define __NR_pkey_free 290 +#define __NR_statx 291 +#define __NR_io_pgetevents 292 +#define __NR_rseq 293 +#define __NR_kexec_file_load 294 +#define __NR_pidfd_send_signal 424 +#define __NR_io_uring_setup 425 +#define __NR_io_uring_enter 426 +#define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 + #define __NR_sysriscv __NR_arch_specific_syscall #define __NR_riscv_flush_icache (__NR_sysriscv + 15) diff --git a/libc-top-half/musl/arch/riscv64/bits/user.h b/libc-top-half/musl/arch/riscv64/bits/user.h index bd0f0fc..2da743e 100644 --- a/libc-top-half/musl/arch/riscv64/bits/user.h +++ b/libc-top-half/musl/arch/riscv64/bits/user.h @@ -1,43 +1,5 @@ -struct user_regs_struct { - unsigned long pc; - unsigned long ra; - unsigned long sp; - unsigned long gp; - unsigned long tp; - unsigned long t0; - unsigned long t1; - unsigned long t2; - unsigned long s0; - unsigned long s1; - unsigned long a0; - unsigned long a1; - unsigned long a2; - unsigned long a3; - unsigned long a4; - unsigned long a5; - unsigned long a6; - unsigned long a7; - unsigned long s2; - unsigned long s3; - unsigned long s4; - unsigned long s5; - unsigned long s6; - unsigned long s7; - unsigned long s8; - unsigned long s9; - unsigned long s10; - unsigned long s11; - unsigned long t3; - unsigned long t4; - unsigned long t5; - unsigned long t6; -}; - -struct user_fpregs_struct { - double f[32]; - unsigned int fcsr; -}; +#include #define ELF_NGREG 32 typedef unsigned long elf_greg_t, elf_gregset_t[ELF_NGREG]; -typedef struct user_fpregs_struct elf_fpregset_t; +typedef union __riscv_mc_fp_state elf_fpregset_t; diff --git a/libc-top-half/musl/arch/riscv64/kstat.h b/libc-top-half/musl/arch/riscv64/kstat.h new file mode 100644 index 0000000..92625f3 --- /dev/null +++ b/libc-top-half/musl/arch/riscv64/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + unsigned long __pad; + off_t st_size; + blksize_t st_blksize; + int __pad2; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + unsigned __unused[2]; +}; diff --git a/libc-top-half/musl/arch/riscv64/pthread_arch.h b/libc-top-half/musl/arch/riscv64/pthread_arch.h index 1268b72..db414b1 100644 --- a/libc-top-half/musl/arch/riscv64/pthread_arch.h +++ b/libc-top-half/musl/arch/riscv64/pthread_arch.h @@ -11,4 +11,4 @@ static inline struct pthread *__pthread_self() #define DTP_OFFSET 0x800 -#define MC_PC gregs[0] +#define MC_PC __gregs[0] diff --git a/libc-top-half/musl/arch/riscv64/syscall_arch.h b/libc-top-half/musl/arch/riscv64/syscall_arch.h index 1aaeb63..7fd042c 100644 --- a/libc-top-half/musl/arch/riscv64/syscall_arch.h +++ b/libc-top-half/musl/arch/riscv64/syscall_arch.h @@ -3,7 +3,7 @@ #define __asm_syscall(...) \ __asm__ __volatile__ ("ecall\n\t" \ - : "+r"(a0) : __VA_ARGS__ : "memory"); \ + : "=r"(a0) : __VA_ARGS__ : "memory"); \ return a0; \ static inline long __syscall0(long n) @@ -74,3 +74,5 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo /* We don't have a clock_gettime function. #define VDSO_CGT_SYM "__vdso_clock_gettime" #define VDSO_CGT_VER "LINUX_2.6" */ + +#define IPC_64 0 diff --git a/libc-top-half/musl/arch/s390x/bits/ipc.h b/libc-top-half/musl/arch/s390x/bits/ipc.h deleted file mode 100644 index 4710c12..0000000 --- a/libc-top-half/musl/arch/s390x/bits/ipc.h +++ /dev/null @@ -1,14 +0,0 @@ -struct ipc_perm { - key_t __ipc_perm_key; - uid_t uid; - gid_t gid; - uid_t cuid; - gid_t cgid; - mode_t mode; - unsigned short __pad1; - unsigned short __ipc_perm_seq; - unsigned long __pad2; - unsigned long __pad3; -}; - -#define IPC_64 0x100 diff --git a/libc-top-half/musl/arch/s390x/bits/sem.h b/libc-top-half/musl/arch/s390x/bits/sem.h deleted file mode 100644 index 644f68a..0000000 --- a/libc-top-half/musl/arch/s390x/bits/sem.h +++ /dev/null @@ -1,7 +0,0 @@ -struct semid_ds { - struct ipc_perm sem_perm; - time_t sem_otime; - time_t sem_ctime; - unsigned short __pad[3], sem_nsems; - unsigned long __unused[2]; -}; diff --git a/libc-top-half/musl/arch/s390x/bits/syscall.h.in b/libc-top-half/musl/arch/s390x/bits/syscall.h.in index 72fd2cc..c4c7047 100644 --- a/libc-top-half/musl/arch/s390x/bits/syscall.h.in +++ b/libc-top-half/musl/arch/s390x/bits/syscall.h.in @@ -344,4 +344,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/s390x/kstat.h b/libc-top-half/musl/arch/s390x/kstat.h new file mode 100644 index 0000000..001c10b --- /dev/null +++ b/libc-top-half/musl/arch/s390x/kstat.h @@ -0,0 +1,19 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + off_t st_size; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + blksize_t st_blksize; + blkcnt_t st_blocks; + unsigned long __unused[3]; +}; diff --git a/libc-top-half/musl/arch/sh/bits/alltypes.h.in b/libc-top-half/musl/arch/sh/bits/alltypes.h.in index 37f27d6..8e687ef 100644 --- a/libc-top-half/musl/arch/sh/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/sh/bits/alltypes.h.in @@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list; TYPEDEF __builtin_va_list __isoc_va_list; #ifndef __cplusplus +#ifdef __WCHAR_TYPE__ +TYPEDEF __WCHAR_TYPE__ wchar_t; +#else TYPEDEF long wchar_t; #endif +#endif TYPEDEF float float_t; TYPEDEF double double_t; diff --git a/libc-top-half/musl/arch/sh/bits/ipcstat.h b/libc-top-half/musl/arch/sh/bits/ipcstat.h new file mode 100644 index 0000000..0018ad1 --- /dev/null +++ b/libc-top-half/musl/arch/sh/bits/ipcstat.h @@ -0,0 +1 @@ +#define IPC_STAT 2 diff --git a/libc-top-half/musl/arch/sh/bits/msg.h b/libc-top-half/musl/arch/sh/bits/msg.h new file mode 100644 index 0000000..bc8436c --- /dev/null +++ b/libc-top-half/musl/arch/sh/bits/msg.h @@ -0,0 +1,15 @@ +struct msqid_ds { + struct ipc_perm msg_perm; + time_t msg_stime; + int __unused1; + time_t msg_rtime; + int __unused2; + time_t msg_ctime; + int __unused3; + unsigned long msg_cbytes; + msgqnum_t msg_qnum; + msglen_t msg_qbytes; + pid_t msg_lspid; + pid_t msg_lrpid; + unsigned long __unused[2]; +}; diff --git a/libc-top-half/musl/arch/sh/bits/sem.h b/libc-top-half/musl/arch/sh/bits/sem.h new file mode 100644 index 0000000..d383d4e --- /dev/null +++ b/libc-top-half/musl/arch/sh/bits/sem.h @@ -0,0 +1,16 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long __unused1; + time_t sem_ctime; + long __unused2; +#if __BYTE_ORDER == __LITTLE_ENDIAN + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; +#else + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + unsigned short sem_nsems; +#endif + long __unused3; + long __unused4; +}; diff --git a/libc-top-half/musl/arch/sh/bits/syscall.h.in b/libc-top-half/musl/arch/sh/bits/syscall.h.in index ad35fc6..4705ef9 100644 --- a/libc-top-half/musl/arch/sh/bits/syscall.h.in +++ b/libc-top-half/musl/arch/sh/bits/syscall.h.in @@ -391,4 +391,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/sh/bits/user.h b/libc-top-half/musl/arch/sh/bits/user.h index d7363f7..07fe843 100644 --- a/libc-top-half/musl/arch/sh/bits/user.h +++ b/libc-top-half/musl/arch/sh/bits/user.h @@ -17,34 +17,6 @@ #define REG_FPSCR 55 #define REG_FPUL 56 -struct pt_regs { - unsigned long regs[16]; - unsigned long pc; - unsigned long pr; - unsigned long sr; - unsigned long gbr; - unsigned long mach; - unsigned long macl; - long tra; -}; - -struct pt_dspregs { - unsigned long a1; - unsigned long a0g; - unsigned long a1g; - unsigned long m0; - unsigned long m1; - unsigned long a0; - unsigned long x0; - unsigned long x1; - unsigned long y0; - unsigned long y1; - unsigned long dsr; - unsigned long rs; - unsigned long re; - unsigned long mod; -}; - struct user_fpu_struct { unsigned long fp_regs[16]; unsigned long xfp_regs[16]; @@ -58,7 +30,11 @@ typedef elf_greg_t elf_gregset_t[ELF_NGREG]; typedef struct user_fpu_struct elf_fpregset_t; struct user { - struct pt_regs regs; + struct { + unsigned long regs[16]; + unsigned long pc, pr, sr, gbr, mach, macl; + long tra; + } regs; struct user_fpu_struct fpu; int u_fpvalid; unsigned long u_tsize; diff --git a/libc-top-half/musl/arch/sh/kstat.h b/libc-top-half/musl/arch/sh/kstat.h new file mode 100644 index 0000000..af449c9 --- /dev/null +++ b/libc-top-half/musl/arch/sh/kstat.h @@ -0,0 +1,21 @@ +struct kstat { + dev_t st_dev; + int __st_dev_padding; + long __st_ino_truncated; + mode_t st_mode; + nlink_t st_nlink; + uid_t st_uid; + gid_t st_gid; + dev_t st_rdev; + int __st_rdev_padding; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + ino_t st_ino; +}; diff --git a/libc-top-half/musl/arch/sh/syscall_arch.h b/libc-top-half/musl/arch/sh/syscall_arch.h index 48f61d9..628d8d3 100644 --- a/libc-top-half/musl/arch/sh/syscall_arch.h +++ b/libc-top-half/musl/arch/sh/syscall_arch.h @@ -88,3 +88,6 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo } #define SYSCALL_IPC_BROKEN_MODE + +#define SIOCGSTAMP_OLD (2U<<30 | 's'<<8 | 100 | 8<<16) +#define SIOCGSTAMPNS_OLD (2U<<30 | 's'<<8 | 101 | 8<<16) diff --git a/libc-top-half/musl/arch/x32/bits/alltypes.h.in b/libc-top-half/musl/arch/x32/bits/alltypes.h.in index 1639129..c612eec 100644 --- a/libc-top-half/musl/arch/x32/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/x32/bits/alltypes.h.in @@ -6,8 +6,12 @@ TYPEDEF __builtin_va_list va_list; TYPEDEF __builtin_va_list __isoc_va_list; #ifndef __cplusplus +#ifdef __WCHAR_TYPE__ +TYPEDEF __WCHAR_TYPE__ wchar_t; +#else TYPEDEF long wchar_t; #endif +#endif #if defined(__FLT_EVAL_METHOD__) && __FLT_EVAL_METHOD__ == 2 TYPEDEF long double float_t; diff --git a/libc-top-half/musl/arch/x32/bits/ipc.h b/libc-top-half/musl/arch/x32/bits/ipc.h index 55d2e41..a12380f 100644 --- a/libc-top-half/musl/arch/x32/bits/ipc.h +++ b/libc-top-half/musl/arch/x32/bits/ipc.h @@ -9,5 +9,3 @@ struct ipc_perm { long long __pad1; long long __pad2; }; - -#define IPC_64 0 diff --git a/libc-top-half/musl/arch/x32/bits/sem.h b/libc-top-half/musl/arch/x32/bits/sem.h new file mode 100644 index 0000000..18745f4 --- /dev/null +++ b/libc-top-half/musl/arch/x32/bits/sem.h @@ -0,0 +1,11 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long long __unused1; + time_t sem_ctime; + long long __unused2; + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long long)-sizeof(short)]; + long long __unused3; + long long __unused4; +}; diff --git a/libc-top-half/musl/arch/x32/bits/syscall.h.in b/libc-top-half/musl/arch/x32/bits/syscall.h.in index 77ec432..4d72852 100644 --- a/libc-top-half/musl/arch/x32/bits/syscall.h.in +++ b/libc-top-half/musl/arch/x32/bits/syscall.h.in @@ -290,6 +290,12 @@ #define __NR_io_uring_setup (0x40000000 + 425) #define __NR_io_uring_enter (0x40000000 + 426) #define __NR_io_uring_register (0x40000000 + 427) +#define __NR_open_tree (0x40000000 + 428) +#define __NR_move_mount (0x40000000 + 429) +#define __NR_fsopen (0x40000000 + 430) +#define __NR_fsconfig (0x40000000 + 431) +#define __NR_fsmount (0x40000000 + 432) +#define __NR_fspick (0x40000000 + 433) #define __NR_rt_sigaction (0x40000000 + 512) #define __NR_rt_sigreturn (0x40000000 + 513) diff --git a/libc-top-half/musl/arch/x32/kstat.h b/libc-top-half/musl/arch/x32/kstat.h new file mode 100644 index 0000000..ce25fce --- /dev/null +++ b/libc-top-half/musl/arch/x32/kstat.h @@ -0,0 +1,22 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + unsigned int __pad0; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + long long st_atime_sec; + long st_atime_nsec; + long long st_mtime_sec; + long st_mtime_nsec; + long long st_ctime_sec; + long st_ctime_nsec; + long long __unused[3]; +}; diff --git a/libc-top-half/musl/arch/x32/syscall_arch.h b/libc-top-half/musl/arch/x32/syscall_arch.h index 344da03..e0a2216 100644 --- a/libc-top-half/musl/arch/x32/syscall_arch.h +++ b/libc-top-half/musl/arch/x32/syscall_arch.h @@ -3,35 +3,6 @@ #define __scc(X) sizeof(1?(X):0ULL) < 8 ? (unsigned long) (X) : (long long) (X) typedef long long syscall_arg_t; -struct __timespec { long long tv_sec; long tv_nsec; }; -struct __timespec_kernel { long long tv_sec; long long tv_nsec; }; -#define __tsc(X) ((struct __timespec*)(unsigned long)(X)) -#define __fixup(X) do { if(X) { \ - ts->tv_sec = __tsc(X)->tv_sec; \ - ts->tv_nsec = __tsc(X)->tv_nsec; \ - (X) = (unsigned long)ts; } } while(0) -#define __fixup_case_2 \ - case SYS_nanosleep: \ - __fixup(a1); break; \ - case SYS_clock_settime: \ - __fixup(a2); break; -#define __fixup_case_3 \ - case SYS_clock_nanosleep: case SYS_rt_sigtimedwait: case SYS_ppoll: \ - __fixup(a3); break; \ - case SYS_utimensat: \ - if(a3) { \ - ts[0].tv_sec = __tsc(a3)[0].tv_sec; \ - ts[0].tv_nsec = __tsc(a3)[0].tv_nsec; \ - ts[1].tv_sec = __tsc(a3)[1].tv_sec; \ - ts[1].tv_nsec = __tsc(a3)[1].tv_nsec; \ - a3 = (unsigned long)ts; \ - } break; -#define __fixup_case_4 \ - case SYS_futex: \ - if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) __fixup(a4); break; -#define __fixup_case_5 \ - case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6: \ - __fixup(a5); break; static __inline long __syscall0(long long n) { @@ -50,10 +21,6 @@ static __inline long __syscall1(long long n, long long a1) static __inline long __syscall2(long long n, long long a1, long long a2) { unsigned long ret; - struct __timespec_kernel ts[1]; - switch (n) { - __fixup_case_2; - } __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2) : "rcx", "r11", "memory"); return ret; @@ -62,11 +29,6 @@ static __inline long __syscall2(long long n, long long a1, long long a2) static __inline long __syscall3(long long n, long long a1, long long a2, long long a3) { unsigned long ret; - struct __timespec_kernel ts[2]; - switch (n) { - __fixup_case_2; - __fixup_case_3; - } __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3) : "rcx", "r11", "memory"); return ret; @@ -77,12 +39,6 @@ static __inline long __syscall4(long long n, long long a1, long long a2, long lo { unsigned long ret; register long long a4 __asm__("r10") = a4_; - struct __timespec_kernel ts[2]; - switch (n) { - __fixup_case_2; - __fixup_case_3; - __fixup_case_4; - } __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(a4): "rcx", "r11", "memory"); return ret; @@ -94,13 +50,6 @@ static __inline long __syscall5(long long n, long long a1, long long a2, long lo unsigned long ret; register long long a4 __asm__("r10") = a4_; register long long a5 __asm__("r8") = a5_; - struct __timespec_kernel ts[2]; - switch (n) { - __fixup_case_2; - __fixup_case_3; - __fixup_case_4; - __fixup_case_5; - } __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(a4), "r"(a5) : "rcx", "r11", "memory"); return ret; @@ -113,14 +62,30 @@ static __inline long __syscall6(long long n, long long a1, long long a2, long lo register long long a4 __asm__("r10") = a4_; register long long a5 __asm__("r8") = a5_; register long long a6 __asm__("r9") = a6_; - struct __timespec_kernel ts[2]; - switch (n) { - __fixup_case_2; - __fixup_case_3; - __fixup_case_4; - __fixup_case_5; - } __asm__ __volatile__ ("syscall" : "=a"(ret) : "a"(n), "D"(a1), "S"(a2), "d"(a3), "r"(a4), "r"(a5), "r"(a6) : "rcx", "r11", "memory"); return ret; } + +#undef SYS_futimesat + +#define SYS_clock_gettime64 SYS_clock_gettime +#define SYS_clock_settime64 SYS_clock_settime +#define SYS_clock_adjtime64 SYS_clock_adjtime +#define SYS_clock_nanosleep_time64 SYS_clock_nanosleep +#define SYS_timer_gettime64 SYS_timer_gettime +#define SYS_timer_settime64 SYS_timer_settime +#define SYS_timerfd_gettime64 SYS_timerfd_gettime +#define SYS_timerfd_settime64 SYS_timerfd_settime +#define SYS_utimensat_time64 SYS_utimensat +#define SYS_pselect6_time64 SYS_pselect6 +#define SYS_ppoll_time64 SYS_ppoll +#define SYS_recvmmsg_time64 SYS_recvmmsg +#define SYS_mq_timedsend_time64 SYS_mq_timedsend +#define SYS_mq_timedreceive_time64 SYS_mq_timedreceive +#define SYS_semtimedop_time64 SYS_semtimedop +#define SYS_rt_sigtimedwait_time64 SYS_rt_sigtimedwait +#define SYS_futex_time64 SYS_futex +#define SYS_sched_rr_get_interval_time64 SYS_sched_rr_get_interval + +#define IPC_64 0 diff --git a/libc-top-half/musl/arch/x86_64/bits/ipc.h b/libc-top-half/musl/arch/x86_64/bits/ipc.h deleted file mode 100644 index 3d894e3..0000000 --- a/libc-top-half/musl/arch/x86_64/bits/ipc.h +++ /dev/null @@ -1,13 +0,0 @@ -struct ipc_perm { - key_t __ipc_perm_key; - uid_t uid; - gid_t gid; - uid_t cuid; - gid_t cgid; - mode_t mode; - int __ipc_perm_seq; - long __pad1; - long __pad2; -}; - -#define IPC_64 0 diff --git a/libc-top-half/musl/arch/x86_64/bits/sem.h b/libc-top-half/musl/arch/x86_64/bits/sem.h new file mode 100644 index 0000000..e61571c --- /dev/null +++ b/libc-top-half/musl/arch/x86_64/bits/sem.h @@ -0,0 +1,11 @@ +struct semid_ds { + struct ipc_perm sem_perm; + time_t sem_otime; + long __unused1; + time_t sem_ctime; + long __unused2; + unsigned short sem_nsems; + char __sem_nsems_pad[sizeof(long)-sizeof(short)]; + long __unused3; + long __unused4; +}; diff --git a/libc-top-half/musl/arch/x86_64/bits/syscall.h.in b/libc-top-half/musl/arch/x86_64/bits/syscall.h.in index 49572ef..2d4634f 100644 --- a/libc-top-half/musl/arch/x86_64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/x86_64/bits/syscall.h.in @@ -337,4 +337,10 @@ #define __NR_io_uring_setup 425 #define __NR_io_uring_enter 426 #define __NR_io_uring_register 427 +#define __NR_open_tree 428 +#define __NR_move_mount 429 +#define __NR_fsopen 430 +#define __NR_fsconfig 431 +#define __NR_fsmount 432 +#define __NR_fspick 433 diff --git a/libc-top-half/musl/arch/x86_64/kstat.h b/libc-top-half/musl/arch/x86_64/kstat.h new file mode 100644 index 0000000..5976c04 --- /dev/null +++ b/libc-top-half/musl/arch/x86_64/kstat.h @@ -0,0 +1,22 @@ +struct kstat { + dev_t st_dev; + ino_t st_ino; + nlink_t st_nlink; + + mode_t st_mode; + uid_t st_uid; + gid_t st_gid; + unsigned int __pad0; + dev_t st_rdev; + off_t st_size; + blksize_t st_blksize; + blkcnt_t st_blocks; + + long st_atime_sec; + long st_atime_nsec; + long st_mtime_sec; + long st_mtime_nsec; + long st_ctime_sec; + long st_ctime_nsec; + long __unused[3]; +}; diff --git a/libc-top-half/musl/arch/x86_64/syscall_arch.h b/libc-top-half/musl/arch/x86_64/syscall_arch.h index 54e05ff..92d5c17 100644 --- a/libc-top-half/musl/arch/x86_64/syscall_arch.h +++ b/libc-top-half/musl/arch/x86_64/syscall_arch.h @@ -66,3 +66,5 @@ static __inline long __syscall6(long n, long a1, long a2, long a3, long a4, long #define VDSO_CGT_VER "LINUX_2.6" #define VDSO_GETCPU_SYM "__vdso_getcpu" #define VDSO_GETCPU_VER "LINUX_2.6" + +#define IPC_64 0 diff --git a/libc-top-half/musl/include/fcntl.h b/libc-top-half/musl/include/fcntl.h index 969b6f7..15bef28 100644 --- a/libc-top-half/musl/include/fcntl.h +++ b/libc-top-half/musl/include/fcntl.h @@ -105,6 +105,11 @@ int posix_fallocate(int, off_t, off_t); #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define AT_NO_AUTOMOUNT 0x800 #define AT_EMPTY_PATH 0x1000 +#define AT_STATX_SYNC_TYPE 0x6000 +#define AT_STATX_SYNC_AS_STAT 0x0000 +#define AT_STATX_FORCE_SYNC 0x2000 +#define AT_STATX_DONT_SYNC 0x4000 +#define AT_RECURSIVE 0x8000 #define FAPPEND O_APPEND #define FFSYNC O_SYNC diff --git a/libc-top-half/musl/include/glob.h b/libc-top-half/musl/include/glob.h index 76f6c1c..8c4bf15 100644 --- a/libc-top-half/musl/include/glob.h +++ b/libc-top-half/musl/include/glob.h @@ -31,6 +31,11 @@ void globfree(glob_t *); #define GLOB_NOESCAPE 0x40 #define GLOB_PERIOD 0x80 +#ifdef __wasilibc_unmodified_upstream // WASI has no usernames +#define GLOB_TILDE 0x1000 +#define GLOB_TILDE_CHECK 0x4000 +#endif + #define GLOB_NOSPACE 1 #define GLOB_ABORTED 2 #define GLOB_NOMATCH 3 diff --git a/libc-top-half/musl/include/netinet/if_ether.h b/libc-top-half/musl/include/netinet/if_ether.h index ecd6c73..8af47db 100644 --- a/libc-top-half/musl/include/netinet/if_ether.h +++ b/libc-top-half/musl/include/netinet/if_ether.h @@ -76,6 +76,7 @@ #define ETH_P_QINQ2 0x9200 #define ETH_P_QINQ3 0x9300 #define ETH_P_EDSA 0xDADA +#define ETH_P_DSA_8021Q 0xDADB #define ETH_P_IFE 0xED3E #define ETH_P_AF_IUCV 0xFBFB diff --git a/libc-top-half/musl/include/netinet/in.h b/libc-top-half/musl/include/netinet/in.h index b39685a..887b926 100644 --- a/libc-top-half/musl/include/netinet/in.h +++ b/libc-top-half/musl/include/netinet/in.h @@ -67,8 +67,10 @@ struct ipv6_mreq { #define INADDR_ALLSNOOPERS_GROUP ((in_addr_t) 0xe000006a) #define INADDR_MAX_LOCAL_GROUP ((in_addr_t) 0xe00000ff) +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ #define IN6ADDR_ANY_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 } } } #define IN6ADDR_LOOPBACK_INIT { { { 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1 } } } +#endif extern const struct in6_addr in6addr_any, in6addr_loopback; diff --git a/libc-top-half/musl/include/sched.h b/libc-top-half/musl/include/sched.h index 6c20036..290e174 100644 --- a/libc-top-half/musl/include/sched.h +++ b/libc-top-half/musl/include/sched.h @@ -19,10 +19,12 @@ extern "C" { #ifdef __wasilibc_unmodified_upstream /* WASI has no CPU scheduling support. */ struct sched_param { int sched_priority; - int sched_ss_low_priority; - struct timespec sched_ss_repl_period; - struct timespec sched_ss_init_budget; - int sched_ss_max_repl; + int __reserved1; + struct { + time_t __reserved1; + long __reserved2; + } __reserved2[2]; + int __reserved3; }; int sched_get_priority_max(int); @@ -50,6 +52,7 @@ int sched_yield(void); #define CLONE_FS 0x00000200 #define CLONE_FILES 0x00000400 #define CLONE_SIGHAND 0x00000800 +#define CLONE_PIDFD 0x00001000 #define CLONE_PTRACE 0x00002000 #define CLONE_VFORK 0x00004000 #define CLONE_PARENT 0x00008000 diff --git a/libc-top-half/musl/include/spawn.h b/libc-top-half/musl/include/spawn.h index c9bd193..8eb73e0 100644 --- a/libc-top-half/musl/include/spawn.h +++ b/libc-top-half/musl/include/spawn.h @@ -71,6 +71,11 @@ int posix_spawn_file_actions_addopen(posix_spawn_file_actions_t *__restrict, int int posix_spawn_file_actions_addclose(posix_spawn_file_actions_t *, int); int posix_spawn_file_actions_adddup2(posix_spawn_file_actions_t *, int, int); +#if defined(_BSD_SOURCE) || defined(_GNU_SOURCE) +int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *__restrict, const char *__restrict); +int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *, int); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/stdlib.h b/libc-top-half/musl/include/stdlib.h index 42f628e..3d4b1f3 100644 --- a/libc-top-half/musl/include/stdlib.h +++ b/libc-top-half/musl/include/stdlib.h @@ -180,6 +180,7 @@ int ptsname_r(int, char *, size_t); char *ecvt(double, int, int *, int *); char *fcvt(double, int, int *, int *); char *gcvt(double, int, char *); +char *secure_getenv(const char *); struct __locale_struct; float strtof_l(const char *__restrict, char **__restrict, struct __locale_struct *); double strtod_l(const char *__restrict, char **__restrict, struct __locale_struct *); diff --git a/libc-top-half/musl/include/sys/ipc.h b/libc-top-half/musl/include/sys/ipc.h index c5a3981..9e366b7 100644 --- a/libc-top-half/musl/include/sys/ipc.h +++ b/libc-top-half/musl/include/sys/ipc.h @@ -22,6 +22,7 @@ extern "C" { #endif #include +#include #define IPC_CREAT 01000 #define IPC_EXCL 02000 @@ -29,7 +30,6 @@ extern "C" { #define IPC_RMID 0 #define IPC_SET 1 -#define IPC_STAT 2 #define IPC_INFO 3 #define IPC_PRIVATE ((key_t) 0) diff --git a/libc-top-half/musl/include/sys/msg.h b/libc-top-half/musl/include/sys/msg.h index be6afc3..db5c62a 100644 --- a/libc-top-half/musl/include/sys/msg.h +++ b/libc-top-half/musl/include/sys/msg.h @@ -25,9 +25,9 @@ typedef unsigned long msglen_t; #define MSG_NOERROR 010000 #define MSG_EXCEPT 020000 -#define MSG_STAT 11 +#define MSG_STAT (11 | (IPC_STAT & 0x100)) #define MSG_INFO 12 -#define MSG_STAT_ANY 13 +#define MSG_STAT_ANY (13 | (IPC_STAT & 0x100)) struct msginfo { int msgpool, msgmap, msgmax, msgmnb, msgmni, msgssz, msgtql; diff --git a/libc-top-half/musl/include/sys/sem.h b/libc-top-half/musl/include/sys/sem.h index 61cdb83..410c877 100644 --- a/libc-top-half/musl/include/sys/sem.h +++ b/libc-top-half/musl/include/sys/sem.h @@ -31,9 +31,9 @@ extern "C" { #define _SEM_SEMUN_UNDEFINED 1 -#define SEM_STAT 18 +#define SEM_STAT (18 | (IPC_STAT & 0x100)) #define SEM_INFO 19 -#define SEM_STAT_ANY 20 +#define SEM_STAT_ANY (20 | (IPC_STAT & 0x100)) struct seminfo { int semmap; diff --git a/libc-top-half/musl/include/sys/shm.h b/libc-top-half/musl/include/sys/shm.h index 8ef4e8f..fd708ca 100644 --- a/libc-top-half/musl/include/sys/shm.h +++ b/libc-top-half/musl/include/sys/shm.h @@ -33,9 +33,9 @@ extern "C" { #define SHM_LOCK 11 #define SHM_UNLOCK 12 -#define SHM_STAT 13 +#define SHM_STAT (13 | (IPC_STAT & 0x100)) #define SHM_INFO 14 -#define SHM_STAT_ANY 15 +#define SHM_STAT_ANY (15 | (IPC_STAT & 0x100)) #define SHM_DEST 01000 #define SHM_LOCKED 02000 #define SHM_HUGETLB 04000 diff --git a/libc-top-half/musl/include/unistd.h b/libc-top-half/musl/include/unistd.h index 302e536..c6fe070 100644 --- a/libc-top-half/musl/include/unistd.h +++ b/libc-top-half/musl/include/unistd.h @@ -245,6 +245,7 @@ int execvpe(const char *, char *const [], char *const []); int issetugid(void); #endif int getentropy(void *, size_t); +extern int optreset; #endif #ifdef _GNU_SOURCE @@ -264,6 +265,7 @@ int syncfs(int); #ifdef __wasilibc_unmodified_upstream /* WASI has no eaccess */ int euidaccess(const char *, int); int eaccess(const char *, int); +ssize_t copy_file_range(int, off_t *, int, off_t *, size_t, unsigned); #endif #endif diff --git a/libc-top-half/musl/ldso/dynlink.c b/libc-top-half/musl/ldso/dynlink.c index d1edb13..7ac0bf7 100644 --- a/libc-top-half/musl/ldso/dynlink.c +++ b/libc-top-half/musl/ldso/dynlink.c @@ -283,12 +283,16 @@ static Sym *gnu_lookup_filtered(uint32_t h1, uint32_t *hashtab, struct dso *dso, #define ARCH_SYM_REJECT_UND(s) 0 #endif -static struct symdef find_sym(struct dso *dso, const char *s, int need_def) +#if defined(__GNUC__) +__attribute__((always_inline)) +#endif +static inline struct symdef find_sym2(struct dso *dso, const char *s, int need_def, int use_deps) { uint32_t h = 0, gh = gnu_hash(s), gho = gh / (8*sizeof(size_t)), *ght; size_t ghm = 1ul << gh % (8*sizeof(size_t)); struct symdef def = {0}; - for (; dso; dso=dso->syms_next) { + struct dso **deps = use_deps ? dso->deps : 0; + for (; dso; dso=use_deps ? *deps++ : dso->syms_next) { Sym *sym; if ((ght = dso->ghashtab)) { sym = gnu_lookup_filtered(gh, ght, dso, s, gho, ghm); @@ -313,6 +317,11 @@ static struct symdef find_sym(struct dso *dso, const char *s, int need_def) return def; } +static struct symdef find_sym(struct dso *dso, const char *s, int need_def) +{ + return find_sym2(dso, s, need_def, 0); +} + static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stride) { unsigned char *base = dso->base; @@ -363,7 +372,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri sym = syms + sym_index; name = strings + sym->st_name; ctx = type==REL_COPY ? head->syms_next : head; - def = (sym->st_info&0xf) == STT_SECTION + def = (sym->st_info>>4) == STB_LOCAL ? (struct symdef){ .dso = dso, .sym = sym } : find_sym(ctx, name, type==REL_PLT); if (!def.sym && (sym->st_shndx != SHN_UNDEF @@ -390,7 +399,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri tls_val = def.sym ? def.sym->st_value : 0; if ((type == REL_TPOFF || type == REL_TPOFF_NEG) - && runtime && def.dso->tls_id > static_tls_cnt) { + && def.dso->tls_id > static_tls_cnt) { error("Error relocating %s: %s: initial-exec TLS " "resolves to dynamic definition in %s", dso->name, name, def.dso->name); @@ -407,6 +416,9 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri case REL_PLT: *reloc_addr = sym_val + addend; break; + case REL_USYMBOLIC: + memcpy(reloc_addr, &(size_t){sym_val + addend}, sizeof(size_t)); + break; case REL_RELATIVE: *reloc_addr = (size_t)base + addend; break; @@ -450,7 +462,7 @@ static void do_relocs(struct dso *dso, size_t *rel, size_t rel_size, size_t stri #endif case REL_TLSDESC: if (stride<3) addend = reloc_addr[1]; - if (runtime && def.dso->tls_id > static_tls_cnt) { + if (def.dso->tls_id > static_tls_cnt) { struct td_index *new = malloc(sizeof *new); if (!new) { error( @@ -1874,19 +1886,28 @@ void __dls3(size_t *sp) * code can see to perform. */ main_ctor_queue = queue_ctors(&app); - /* The main program must be relocated LAST since it may contin - * copy relocations which depend on libraries' relocations. */ - reloc_all(app.next); - reloc_all(&app); - + /* Initial TLS must also be allocated before final relocations + * might result in calloc being a call to application code. */ update_tls_size(); + void *initial_tls = builtin_tls; if (libc.tls_size > sizeof builtin_tls || tls_align > MIN_TLS_ALIGN) { - void *initial_tls = calloc(libc.tls_size, 1); + initial_tls = calloc(libc.tls_size, 1); if (!initial_tls) { dprintf(2, "%s: Error getting %zu bytes thread-local storage: %m\n", argv[0], libc.tls_size); _exit(127); } + } + static_tls_cnt = tls_cnt; + + /* The main program must be relocated LAST since it may contain + * copy relocations which depend on libraries' relocations. */ + reloc_all(app.next); + reloc_all(&app); + + /* Actual copying to new TLS needs to happen after relocations, + * since the TLS images might have contained relocated addresses. */ + if (initial_tls != builtin_tls) { if (__init_tp(__copy_tls(initial_tls)) < 0) { a_crash(); } @@ -1900,7 +1921,6 @@ void __dls3(size_t *sp) if (__copy_tls((void*)builtin_tls) != self) a_crash(); libc.tls_size = tmp_tls_size; } - static_tls_cnt = tls_cnt; if (ldso_fail) _exit(127); if (ldd_mode) _exit(0); @@ -2118,58 +2138,27 @@ static void *addr2dso(size_t a) static void *do_dlsym(struct dso *p, const char *s, void *ra) { - size_t i; - uint32_t h = 0, gh = 0, *ght; - Sym *sym; - if (p == head || p == RTLD_DEFAULT || p == RTLD_NEXT) { - if (p == RTLD_DEFAULT) { - p = head; - } else if (p == RTLD_NEXT) { - p = addr2dso((size_t)ra); - if (!p) p=head; - p = p->next; - } - struct symdef def = find_sym(p, s, 0); - if (!def.sym) goto failed; - if ((def.sym->st_info&0xf) == STT_TLS) - return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && (def.sym->st_info&0xf) == STT_FUNC) - return def.dso->funcdescs + (def.sym - def.dso->syms); - return laddr(def.dso, def.sym->st_value); - } - if (__dl_invalid_handle(p)) + int use_deps = 0; + if (p == head || p == RTLD_DEFAULT) { + p = head; + } else if (p == RTLD_NEXT) { + p = addr2dso((size_t)ra); + if (!p) p=head; + p = p->next; + } else if (__dl_invalid_handle(p)) { + return 0; + } else + use_deps = 1; + struct symdef def = find_sym2(p, s, 0, use_deps); + if (!def.sym) { + error("Symbol not found: %s", s); return 0; - if ((ght = p->ghashtab)) { - gh = gnu_hash(s); - sym = gnu_lookup(gh, ght, p, s); - } else { - h = sysv_hash(s); - sym = sysv_lookup(s, h, p); } - if (sym && (sym->st_info&0xf) == STT_TLS) - return __tls_get_addr((tls_mod_off_t []){p->tls_id, sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC) - return p->funcdescs + (sym - p->syms); - if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) - return laddr(p, sym->st_value); - for (i=0; p->deps[i]; i++) { - if ((ght = p->deps[i]->ghashtab)) { - if (!gh) gh = gnu_hash(s); - sym = gnu_lookup(gh, ght, p->deps[i], s); - } else { - if (!h) h = sysv_hash(s); - sym = sysv_lookup(s, h, p->deps[i]); - } - if (sym && (sym->st_info&0xf) == STT_TLS) - return __tls_get_addr((tls_mod_off_t []){p->deps[i]->tls_id, sym->st_value-DTP_OFFSET}); - if (DL_FDPIC && sym && sym->st_shndx && (sym->st_info&0xf) == STT_FUNC) - return p->deps[i]->funcdescs + (sym - p->deps[i]->syms); - if (sym && sym->st_value && (1<<(sym->st_info&0xf) & OK_TYPES)) - return laddr(p->deps[i], sym->st_value); - } -failed: - error("Symbol not found: %s", s); - return 0; + if ((def.sym->st_info&0xf) == STT_TLS) + return __tls_get_addr((tls_mod_off_t []){def.dso->tls_id, def.sym->st_value-DTP_OFFSET}); + if (DL_FDPIC && (def.sym->st_info&0xf) == STT_FUNC) + return def.dso->funcdescs + (def.sym - def.dso->syms); + return laddr(def.dso, def.sym->st_value); } int dladdr(const void *addr_arg, Dl_info *info) diff --git a/libc-top-half/musl/src/conf/fpathconf.c b/libc-top-half/musl/src/conf/fpathconf.c index b960ba1..058b62a 100644 --- a/libc-top-half/musl/src/conf/fpathconf.c +++ b/libc-top-half/musl/src/conf/fpathconf.c @@ -10,7 +10,7 @@ long fpathconf(int fd, int name) [_PC_MAX_INPUT] = _POSIX_MAX_INPUT, [_PC_NAME_MAX] = NAME_MAX, [_PC_PATH_MAX] = PATH_MAX, -#ifdef __wasilibc_unmodified_upstream /* WASI has no pipes */ +#ifdef __wasilibc_unmodified_upstream // WASI has no pipes [_PC_PIPE_BUF] = PIPE_BUF, #else [_PC_PIPE_BUF] = -1, diff --git a/libc-top-half/musl/src/env/secure_getenv.c b/libc-top-half/musl/src/env/secure_getenv.c new file mode 100644 index 0000000..72322f8 --- /dev/null +++ b/libc-top-half/musl/src/env/secure_getenv.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "libc.h" + +char *secure_getenv(const char *name) +{ + return libc.secure ? NULL : getenv(name); +} diff --git a/libc-top-half/musl/src/include/time.h b/libc-top-half/musl/src/include/time.h index 24c8797..cbabde4 100644 --- a/libc-top-half/musl/src/include/time.h +++ b/libc-top-half/musl/src/include/time.h @@ -4,6 +4,7 @@ #include "../../include/time.h" hidden int __clock_gettime(clockid_t, struct timespec *); +hidden int __clock_nanosleep(clockid_t, int, const struct timespec *, struct timespec *); hidden char *__asctime_r(const struct tm *, char *); hidden struct tm *__gmtime_r(const time_t *restrict, struct tm *restrict); diff --git a/libc-top-half/musl/src/include/unistd.h b/libc-top-half/musl/src/include/unistd.h index 6deb1bc..1b4605c 100644 --- a/libc-top-half/musl/src/include/unistd.h +++ b/libc-top-half/musl/src/include/unistd.h @@ -9,5 +9,6 @@ hidden int __dup3(int, int, int); hidden int __mkostemps(char *, int, int); hidden int __execvpe(const char *, char *const *, char *const *); hidden int __aio_close(int); +hidden off_t __lseek(int, off_t, int); #endif diff --git a/libc-top-half/musl/src/internal/dynlink.h b/libc-top-half/musl/src/internal/dynlink.h index 165bbed..ffd06b0 100644 --- a/libc-top-half/musl/src/internal/dynlink.h +++ b/libc-top-half/musl/src/internal/dynlink.h @@ -28,6 +28,7 @@ typedef Elf64_Sym Sym; enum { REL_NONE = 0, REL_SYMBOLIC = -100, + REL_USYMBOLIC, REL_GOT, REL_PLT, REL_RELATIVE, diff --git a/libc-top-half/musl/src/internal/floatscan.c b/libc-top-half/musl/src/internal/floatscan.c index 7fd0060..0fbea30 100644 --- a/libc-top-half/musl/src/internal/floatscan.c +++ b/libc-top-half/musl/src/internal/floatscan.c @@ -332,7 +332,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po y -= bias; if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) { - if (fabs(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) { + if (fabsl(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) { if (denormal && bits==LDBL_MANT_DIG+e2-emin) denormal = 0; y *= 0.5; diff --git a/libc-top-half/musl/src/internal/pthread_impl.h b/libc-top-half/musl/src/internal/pthread_impl.h index 9b00142..5742dfc 100644 --- a/libc-top-half/musl/src/internal/pthread_impl.h +++ b/libc-top-half/musl/src/internal/pthread_impl.h @@ -125,7 +125,6 @@ struct __timer { 0x80000000 }) void *__tls_get_addr(tls_mod_off_t *); -hidden void *__tls_get_new(tls_mod_off_t *); hidden int __init_tp(void *); hidden void *__copy_tls(unsigned char *); hidden void __reset_tls(); diff --git a/libc-top-half/musl/src/internal/syscall.h b/libc-top-half/musl/src/internal/syscall.h index 69f019c..9f2784d 100644 --- a/libc-top-half/musl/src/internal/syscall.h +++ b/libc-top-half/musl/src/internal/syscall.h @@ -43,8 +43,8 @@ hidden long __syscall_ret(unsigned long), #define __syscall(...) __SYSCALL_DISP(__syscall,__VA_ARGS__) #define syscall(...) __syscall_ret(__syscall(__VA_ARGS__)) -#define socketcall __socketcall -#define socketcall_cp __socketcall_cp +#define socketcall(nm,a,b,c,d,e,f) __syscall_ret(__socketcall(nm,a,b,c,d,e,f)) +#define socketcall_cp(nm,a,b,c,d,e,f) __syscall_ret(__socketcall_cp(nm,a,b,c,d,e,f)) #define __syscall_cp0(n) (__syscall_cp)(n,0,0,0,0,0,0) #define __syscall_cp1(n,a) (__syscall_cp)(n,__scc(a),0,0,0,0,0) @@ -58,12 +58,12 @@ hidden long __syscall_ret(unsigned long), #define syscall_cp(...) __syscall_ret(__syscall_cp(__VA_ARGS__)) #ifndef SYSCALL_USE_SOCKETCALL -#define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_##nm, a, b, c, d, e, f) -#define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_##nm, a, b, c, d, e, f) +#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_##nm, a, b, c, d, e, f) +#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_##nm, a, b, c, d, e, f) #else -#define __socketcall(nm,a,b,c,d,e,f) syscall(SYS_socketcall, __SC_##nm, \ +#define __socketcall(nm,a,b,c,d,e,f) __syscall(SYS_socketcall, __SC_##nm, \ ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) -#define __socketcall_cp(nm,a,b,c,d,e,f) syscall_cp(SYS_socketcall, __SC_##nm, \ +#define __socketcall_cp(nm,a,b,c,d,e,f) __syscall_cp(SYS_socketcall, __SC_##nm, \ ((long [6]){ (long)a, (long)b, (long)c, (long)d, (long)e, (long)f })) #endif @@ -193,6 +193,89 @@ hidden long __syscall_ret(unsigned long), #define SYS_sendfile SYS_sendfile64 #endif + +/* Ensure that the plain syscall names are defined even for "time64-only" + * archs. These facilitate callers passing null time arguments, and make + * tests for establishing which to use/fallback-to more consistent when + * they do need to be called with time arguments. */ + +#ifndef SYS_clock_gettime +#define SYS_clock_gettime SYS_clock_gettime64 +#endif + +#ifndef SYS_clock_settime +#define SYS_clock_settime SYS_clock_settime64 +#endif + +#ifndef SYS_clock_adjtime +#define SYS_clock_adjtime SYS_clock_adjtime64 +#endif + +#ifndef SYS_clock_getres +#define SYS_clock_getres SYS_clock_getres_time64 +#endif + +#ifndef SYS_clock_nanosleep +#define SYS_clock_nanosleep SYS_clock_nanosleep_time64 +#endif + +#ifndef SYS_timer_gettime +#define SYS_timer_gettime SYS_timer_gettime64 +#endif + +#ifndef SYS_timer_settime +#define SYS_timer_settime SYS_timer_settime64 +#endif + +#ifndef SYS_timerfd_gettime +#define SYS_timerfd_gettime SYS_timerfd_gettime64 +#endif + +#ifndef SYS_timerfd_settime +#define SYS_timerfd_settime SYS_timerfd_settime64 +#endif + +#ifndef SYS_utimensat +#define SYS_utimensat SYS_utimensat_time64 +#endif + +#ifndef SYS_pselect6 +#define SYS_pselect6 SYS_pselect6_time64 +#endif + +#ifndef SYS_ppoll +#define SYS_ppoll SYS_ppoll_time64 +#endif + +#ifndef SYS_recvmmsg +#define SYS_recvmmsg SYS_recvmmsg_time64 +#endif + +#ifndef SYS_mq_timedsend +#define SYS_mq_timedsend SYS_mq_timedsend_time64 +#endif + +#ifndef SYS_mq_timedreceive +#define SYS_mq_timedreceive SYS_mq_timedreceive_time64 +#endif + +/* SYS_semtimedop omitted because SYS_ipc may provide it */ + +#ifndef SYS_rt_sigtimedwait +#define SYS_rt_sigtimedwait SYS_rt_sigtimedwait_time64 +#endif + +#ifndef SYS_futex +#define SYS_futex SYS_futex_time64 +#endif + +#ifndef SYS_sched_rr_get_interval +#define SYS_sched_rr_get_interval SYS_sched_rr_get_interval_time64 +#endif + + + + /* socketcall calls */ #define __SC_socket 1 @@ -216,6 +299,20 @@ hidden long __syscall_ret(unsigned long), #define __SC_recvmmsg 19 #define __SC_sendmmsg 20 +#ifndef SO_RCVTIMEO_OLD +#define SO_RCVTIMEO_OLD 20 +#endif +#ifndef SO_SNDTIMEO_OLD +#define SO_SNDTIMEO_OLD 21 +#endif + +#ifndef SIOCGSTAMP_OLD +#define SIOCGSTAMP_OLD 0x8906 +#endif +#ifndef SIOCGSTAMPNS_OLD +#define SIOCGSTAMPNS_OLD 0x8907 +#endif + #ifdef SYS_open #define __sys_open2(x,pn,fl) __syscall2(SYS_open, pn, (fl)|O_LARGEFILE) #define __sys_open3(x,pn,fl,mo) __syscall3(SYS_open, pn, (fl)|O_LARGEFILE, mo) diff --git a/libc-top-half/musl/src/ipc/ipc.h b/libc-top-half/musl/src/ipc/ipc.h index 30ab939..746a905 100644 --- a/libc-top-half/musl/src/ipc/ipc.h +++ b/libc-top-half/musl/src/ipc/ipc.h @@ -1,3 +1,5 @@ +#include "syscall.h" + #define IPCOP_semop 1 #define IPCOP_semget 2 #define IPCOP_semctl 3 @@ -10,3 +12,13 @@ #define IPCOP_shmdt 22 #define IPCOP_shmget 23 #define IPCOP_shmctl 24 + +#ifndef IPC_64 +#define IPC_64 0x100 +#endif + +#define IPC_TIME64 (IPC_STAT & 0x100) + +#define IPC_CMD(cmd) (((cmd) & ~IPC_TIME64) | IPC_64) + +#define IPC_HILO(b,t) ((b)->t = (b)->__##t##_lo | 0LL+(b)->__##t##_hi<<32) diff --git a/libc-top-half/musl/src/ipc/msgctl.c b/libc-top-half/musl/src/ipc/msgctl.c index 868197f..b043041 100644 --- a/libc-top-half/musl/src/ipc/msgctl.c +++ b/libc-top-half/musl/src/ipc/msgctl.c @@ -18,17 +18,24 @@ int msgctl(int q, int cmd, struct msqid_ds *buf) } #endif #ifndef SYS_ipc - int r = __syscall(SYS_msgctl, q, cmd | IPC_64, buf); + int r = __syscall(SYS_msgctl, q, IPC_CMD(cmd), buf); #else - int r = __syscall(SYS_ipc, IPCOP_msgctl, q, cmd | IPC_64, 0, buf, 0); + int r = __syscall(SYS_ipc, IPCOP_msgctl, q, IPC_CMD(cmd), 0, buf, 0); #endif #ifdef SYSCALL_IPC_BROKEN_MODE - if (r >= 0) switch (cmd) { + if (r >= 0) switch (cmd | IPC_TIME64) { case IPC_STAT: case MSG_STAT: case MSG_STAT_ANY: buf->msg_perm.mode >>= 16; } +#endif +#if IPC_TIME64 + if (r >= 0 && (cmd&IPC_TIME64)) { + IPC_HILO(buf, msg_stime); + IPC_HILO(buf, msg_rtime); + IPC_HILO(buf, msg_ctime); + } #endif return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/ipc/semctl.c b/libc-top-half/musl/src/ipc/semctl.c index ce1fb16..ed98274 100644 --- a/libc-top-half/musl/src/ipc/semctl.c +++ b/libc-top-half/musl/src/ipc/semctl.c @@ -18,9 +18,12 @@ int semctl(int id, int num, int cmd, ...) { union semun arg = {0}; va_list ap; - switch (cmd) { - case SETVAL: case GETALL: case SETALL: case IPC_STAT: case IPC_SET: - case IPC_INFO: case SEM_INFO: case SEM_STAT: + switch (cmd & ~IPC_TIME64) { + case SETVAL: case GETALL: case SETALL: case IPC_SET: + case IPC_INFO: case SEM_INFO: + case IPC_STAT & ~IPC_TIME64: + case SEM_STAT & ~IPC_TIME64: + case SEM_STAT_ANY & ~IPC_TIME64: va_start(ap, cmd); arg = va_arg(ap, union semun); va_end(ap); @@ -34,17 +37,23 @@ int semctl(int id, int num, int cmd, ...) } #endif #ifndef SYS_ipc - int r = __syscall(SYS_semctl, id, num, cmd | IPC_64, arg.buf); + int r = __syscall(SYS_semctl, id, num, IPC_CMD(cmd), arg.buf); #else - int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, cmd | IPC_64, &arg.buf); + int r = __syscall(SYS_ipc, IPCOP_semctl, id, num, IPC_CMD(cmd), &arg.buf); #endif #ifdef SYSCALL_IPC_BROKEN_MODE - if (r >= 0) switch (cmd) { + if (r >= 0) switch (cmd | IPC_TIME64) { case IPC_STAT: case SEM_STAT: case SEM_STAT_ANY: arg.buf->sem_perm.mode >>= 16; } +#endif +#if IPC_TIME64 + if (r >= 0 && (cmd&IPC_TIME64)) { + IPC_HILO(arg.buf, sem_otime); + IPC_HILO(arg.buf, sem_ctime); + } #endif return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/ipc/semtimedop.c b/libc-top-half/musl/src/ipc/semtimedop.c index 51e7080..1632e7b 100644 --- a/libc-top-half/musl/src/ipc/semtimedop.c +++ b/libc-top-half/musl/src/ipc/semtimedop.c @@ -1,13 +1,35 @@ #define _GNU_SOURCE #include +#include #include "syscall.h" #include "ipc.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + +#if !defined(SYS_semtimedop) && !defined(SYS_ipc) +#define NO_TIME32 1 +#else +#define NO_TIME32 0 +#endif + int semtimedop(int id, struct sembuf *buf, size_t n, const struct timespec *ts) { -#ifndef SYS_ipc +#ifdef SYS_semtimedop_time64 + time_t s = ts ? ts->tv_sec : 0; + long ns = ts ? ts->tv_nsec : 0; + int r = -ENOSYS; + if (NO_TIME32 || !IS32BIT(s)) + r = __syscall(SYS_semtimedop_time64, id, buf, n, + ts ? ((long long[]){s, ns}) : 0); + if (NO_TIME32 || r!=-ENOSYS) return __syscall_ret(r); + ts = ts ? (void *)(long[]){CLAMP(s), ns} : 0; +#endif +#if defined(SYS_ipc) + return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts); +#elif defined(SYS_semtimedop) return syscall(SYS_semtimedop, id, buf, n, ts); #else - return syscall(SYS_ipc, IPCOP_semtimedop, id, n, 0, buf, ts); + return __syscall_ret(-ENOSYS); #endif } diff --git a/libc-top-half/musl/src/ipc/shmctl.c b/libc-top-half/musl/src/ipc/shmctl.c index c2b2bb0..de3ce9d 100644 --- a/libc-top-half/musl/src/ipc/shmctl.c +++ b/libc-top-half/musl/src/ipc/shmctl.c @@ -18,17 +18,24 @@ int shmctl(int id, int cmd, struct shmid_ds *buf) } #endif #ifndef SYS_ipc - int r = __syscall(SYS_shmctl, id, cmd | IPC_64, buf); + int r = __syscall(SYS_shmctl, id, IPC_CMD(cmd), buf); #else - int r = __syscall(SYS_ipc, IPCOP_shmctl, id, cmd | IPC_64, 0, buf, 0); + int r = __syscall(SYS_ipc, IPCOP_shmctl, id, IPC_CMD(cmd), 0, buf, 0); #endif #ifdef SYSCALL_IPC_BROKEN_MODE - if (r >= 0) switch (cmd) { + if (r >= 0) switch (cmd | IPC_TIME64) { case IPC_STAT: case SHM_STAT: case SHM_STAT_ANY: buf->shm_perm.mode >>= 16; } +#endif +#if IPC_TIME64 + if (r >= 0 && (cmd&IPC_TIME64)) { + IPC_HILO(buf, shm_atime); + IPC_HILO(buf, shm_dtime); + IPC_HILO(buf, shm_ctime); + } #endif return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s b/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s index 04d97e7..c6c685b 100644 --- a/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s +++ b/libc-top-half/musl/src/ldso/aarch64/tlsdesc.s @@ -9,15 +9,11 @@ __tlsdesc_static: ldr x0,[x0,#8] ret -.hidden __tls_get_new - // size_t __tlsdesc_dynamic(size_t *a) // { // struct {size_t modidx,off;} *p = (void*)a[1]; // size_t *dtv = *(size_t**)(tp - 8); -// if (p->modidx <= dtv[0]) -// return dtv[p->modidx] + p->off - tp; -// return __tls_get_new(p) - tp; +// return dtv[p->modidx] + p->off - tp; // } .global __tlsdesc_dynamic .hidden __tlsdesc_dynamic diff --git a/libc-top-half/musl/src/ldso/arm/tlsdesc.S b/libc-top-half/musl/src/ldso/arm/tlsdesc.S index 455eac1..3ae133c 100644 --- a/libc-top-half/musl/src/ldso/arm/tlsdesc.S +++ b/libc-top-half/musl/src/ldso/arm/tlsdesc.S @@ -8,8 +8,6 @@ __tlsdesc_static: ldr r0,[r0] bx lr -.hidden __tls_get_new - .global __tlsdesc_dynamic .hidden __tlsdesc_dynamic .type __tlsdesc_dynamic,%function @@ -29,8 +27,12 @@ __tlsdesc_dynamic: 2: #if __ARM_ARCH >= 5 blx r0 // r0 = tp +#else +#if __thumb__ + add lr,pc,#1 #else mov lr,pc +#endif bx r0 #endif #endif diff --git a/libc-top-half/musl/src/ldso/i386/tlsdesc.s b/libc-top-half/musl/src/ldso/i386/tlsdesc.s index a5c0100..32c8176 100644 --- a/libc-top-half/musl/src/ldso/i386/tlsdesc.s +++ b/libc-top-half/musl/src/ldso/i386/tlsdesc.s @@ -6,8 +6,6 @@ __tlsdesc_static: mov 4(%eax),%eax ret -.hidden __tls_get_new - .global __tlsdesc_dynamic .hidden __tlsdesc_dynamic .type __tlsdesc_dynamic,@function diff --git a/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s b/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s index 0151d15..e08f1d7 100644 --- a/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s +++ b/libc-top-half/musl/src/ldso/x86_64/tlsdesc.s @@ -6,8 +6,6 @@ __tlsdesc_static: mov 8(%rax),%rax ret -.hidden __tls_get_new - .global __tlsdesc_dynamic .hidden __tlsdesc_dynamic .type __tlsdesc_dynamic,@function diff --git a/libc-top-half/musl/src/linux/adjtime.c b/libc-top-half/musl/src/linux/adjtime.c index fa8af9f..5a707f2 100644 --- a/libc-top-half/musl/src/linux/adjtime.c +++ b/libc-top-half/musl/src/linux/adjtime.c @@ -15,7 +15,7 @@ int adjtime(const struct timeval *in, struct timeval *out) tx.offset = in->tv_sec*1000000 + in->tv_usec; tx.modes = ADJ_OFFSET_SINGLESHOT; } - if (syscall(SYS_adjtimex, &tx) < 0) return -1; + if (adjtimex(&tx) < 0) return -1; if (out) { out->tv_sec = tx.offset / 1000000; if ((out->tv_usec = tx.offset % 1000000) < 0) { diff --git a/libc-top-half/musl/src/linux/adjtimex.c b/libc-top-half/musl/src/linux/adjtimex.c index 91de682..e9d727c 100644 --- a/libc-top-half/musl/src/linux/adjtimex.c +++ b/libc-top-half/musl/src/linux/adjtimex.c @@ -1,7 +1,7 @@ #include -#include "syscall.h" +#include int adjtimex(struct timex *tx) { - return syscall(SYS_adjtimex, tx); + return clock_adjtime(CLOCK_REALTIME, tx); } diff --git a/libc-top-half/musl/src/linux/clock_adjtime.c b/libc-top-half/musl/src/linux/clock_adjtime.c index 056ad6d..2f53139 100644 --- a/libc-top-half/musl/src/linux/clock_adjtime.c +++ b/libc-top-half/musl/src/linux/clock_adjtime.c @@ -1,7 +1,119 @@ #include +#include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + +struct ktimex64 { + unsigned modes; + int :32; + long long offset, freq, maxerror, esterror; + int status; + int :32; + long long constant, precision, tolerance; + long long time_sec, time_usec; + long long tick, ppsfreq, jitter; + int shift; + int :32; + long long stabil, jitcnt, calcnt, errcnt, stbcnt; + int tai; + int __padding[11]; +}; + +struct ktimex { + unsigned modes; + long offset, freq, maxerror, esterror; + int status; + long constant, precision, tolerance; + long time_sec, time_usec; + long tick, ppsfreq, jitter; + int shift; + long stabil, jitcnt, calcnt, errcnt, stbcnt; + int tai; + int __padding[11]; +}; + int clock_adjtime (clockid_t clock_id, struct timex *utx) { + int r = -ENOSYS; +#ifdef SYS_clock_adjtime64 + if (SYS_clock_adjtime == SYS_clock_adjtime64 || + (utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec)) { + struct ktimex64 ktx = { + .modes = utx->modes, + .offset = utx->offset, + .freq = utx->freq, + .maxerror = utx->maxerror, + .esterror = utx->esterror, + .status = utx->status, + .constant = utx->constant, + .precision = utx->precision, + .tolerance = utx->tolerance, + .time_sec = utx->time.tv_sec, + .time_usec = utx->time.tv_usec, + .tick = utx->tick, + .ppsfreq = utx->ppsfreq, + .jitter = utx->jitter, + .shift = utx->shift, + .stabil = utx->stabil, + .jitcnt = utx->jitcnt, + .calcnt = utx->calcnt, + .errcnt = utx->errcnt, + .stbcnt = utx->stbcnt, + .tai = utx->tai, + }; + r = __syscall(SYS_clock_adjtime, clock_id, &ktx); + if (r>=0) { + utx->modes = ktx.modes; + utx->offset = ktx.offset; + utx->freq = ktx.freq; + utx->maxerror = ktx.maxerror; + utx->esterror = ktx.esterror; + utx->status = ktx.status; + utx->constant = ktx.constant; + utx->precision = ktx.precision; + utx->tolerance = ktx.tolerance; + utx->time.tv_sec = ktx.time_sec; + utx->time.tv_usec = ktx.time_usec; + utx->tick = ktx.tick; + utx->ppsfreq = ktx.ppsfreq; + utx->jitter = ktx.jitter; + utx->shift = ktx.shift; + utx->stabil = ktx.stabil; + utx->jitcnt = ktx.jitcnt; + utx->calcnt = ktx.calcnt; + utx->errcnt = ktx.errcnt; + utx->stbcnt = ktx.stbcnt; + utx->tai = ktx.tai; + } + } + if (SYS_clock_adjtime == SYS_clock_adjtime64 || r!=-ENOSYS) + return __syscall_ret(r); + if ((utx->modes & ADJ_SETOFFSET) && !IS32BIT(utx->time.tv_sec)) + return __syscall_ret(-ENOTSUP); +#endif + if (sizeof(time_t) > sizeof(long)) { + union { + struct timex utx; + struct ktimex ktx; + } u = { *utx }; + u.ktx.time_sec = utx->time.tv_sec; + u.ktx.time_usec = utx->time.tv_usec; +#ifdef SYS_adjtimex + if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &u); + else +#endif + r = __syscall(SYS_clock_adjtime, clock_id, &u); + if (r>=0) { + *utx = u.utx; + utx->time.tv_sec = u.ktx.time_sec; + utx->time.tv_usec = u.ktx.time_usec; + } + return __syscall_ret(r); + } +#ifdef SYS_adjtimex + if (clock_id==CLOCK_REALTIME) return syscall(SYS_adjtimex, utx); +#endif return syscall(SYS_clock_adjtime, clock_id, utx); } diff --git a/libc-top-half/musl/src/linux/copy_file_range.c b/libc-top-half/musl/src/linux/copy_file_range.c new file mode 100644 index 0000000..dd4b133 --- /dev/null +++ b/libc-top-half/musl/src/linux/copy_file_range.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include +#include "syscall.h" + +ssize_t copy_file_range(int fd_in, off_t *off_in, int fd_out, off_t *off_out, size_t len, unsigned flags) +{ + return syscall(SYS_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags); +} diff --git a/libc-top-half/musl/src/linux/ppoll.c b/libc-top-half/musl/src/linux/ppoll.c index 9e26247..e614600 100644 --- a/libc-top-half/musl/src/linux/ppoll.c +++ b/libc-top-half/musl/src/linux/ppoll.c @@ -1,10 +1,26 @@ #define _GNU_SOURCE #include #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int ppoll(struct pollfd *fds, nfds_t n, const struct timespec *to, const sigset_t *mask) { + time_t s = to ? to->tv_sec : 0; + long ns = to ? to->tv_nsec : 0; +#ifdef SYS_ppoll_time64 + int r = -ENOSYS; + if (SYS_ppoll == SYS_ppoll_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_ppoll_time64, fds, n, + to ? ((long long[]){s, ns}) : 0, + mask, _NSIG/8); + if (SYS_ppoll == SYS_ppoll_time64 || r != -ENOSYS) + return __syscall_ret(r); + s = CLAMP(s); +#endif return syscall_cp(SYS_ppoll, fds, n, - to ? (struct timespec []){*to} : 0, mask, _NSIG/8); + to ? ((long[]){s, ns}) : 0, mask, _NSIG/8); } diff --git a/libc-top-half/musl/src/linux/settimeofday.c b/libc-top-half/musl/src/linux/settimeofday.c index 15c18c6..860fb5d 100644 --- a/libc-top-half/musl/src/linux/settimeofday.c +++ b/libc-top-half/musl/src/linux/settimeofday.c @@ -1,8 +1,13 @@ #define _BSD_SOURCE #include +#include +#include #include "syscall.h" int settimeofday(const struct timeval *tv, const struct timezone *tz) { - return syscall(SYS_settimeofday, tv, 0); + if (!tv) return 0; + if (tv->tv_usec >= 1000000ULL) return __syscall_ret(-EINVAL); + return clock_settime(CLOCK_REALTIME, &((struct timespec){ + .tv_sec = tv->tv_sec, .tv_nsec = tv->tv_usec * 1000})); } diff --git a/libc-top-half/musl/src/linux/timerfd.c b/libc-top-half/musl/src/linux/timerfd.c index 62cc277..5bdfaf1 100644 --- a/libc-top-half/musl/src/linux/timerfd.c +++ b/libc-top-half/musl/src/linux/timerfd.c @@ -1,6 +1,9 @@ #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + int timerfd_create(int clockid, int flags) { return syscall(SYS_timerfd_create, clockid, flags); @@ -8,10 +11,49 @@ int timerfd_create(int clockid, int flags) int timerfd_settime(int fd, int flags, const struct itimerspec *new, struct itimerspec *old) { +#ifdef SYS_timerfd_settime64 + time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec; + long ins = new->it_interval.tv_nsec, vns = new->it_value.tv_nsec; + int r = -ENOSYS; + if (SYS_timerfd_settime == SYS_timerfd_settime64 + || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old)) + r = __syscall(SYS_timerfd_settime64, fd, flags, + ((long long[]){is, ins, vs, vns}), old); + if (SYS_timerfd_settime == SYS_timerfd_settime64 || r!=-ENOSYS) + return __syscall_ret(r); + if (!IS32BIT(is) || !IS32BIT(vs)) + return __syscall_ret(-ENOTSUP); + long old32[4]; + r = __syscall(SYS_timerfd_settime, fd, flags, + ((long[]){is, ins, vs, vns}), old32); + if (!r && old) { + old->it_interval.tv_sec = old32[0]; + old->it_interval.tv_nsec = old32[1]; + old->it_value.tv_sec = old32[2]; + old->it_value.tv_nsec = old32[3]; + } + return __syscall_ret(r); +#endif return syscall(SYS_timerfd_settime, fd, flags, new, old); } int timerfd_gettime(int fd, struct itimerspec *cur) { +#ifdef SYS_timerfd_gettime64 + int r = -ENOSYS; + if (sizeof(time_t) > 4) + r = __syscall(SYS_timerfd_gettime64, fd, cur); + if (SYS_timerfd_gettime == SYS_timerfd_gettime64 || r!=-ENOSYS) + return __syscall_ret(r); + long cur32[4]; + r = __syscall(SYS_timerfd_gettime, fd, cur32); + if (!r) { + cur->it_interval.tv_sec = cur32[0]; + cur->it_interval.tv_nsec = cur32[1]; + cur->it_value.tv_sec = cur32[2]; + cur->it_value.tv_nsec = cur32[3]; + } + return __syscall_ret(r); +#endif return syscall(SYS_timerfd_gettime, fd, cur); } diff --git a/libc-top-half/musl/src/locale/catclose.c b/libc-top-half/musl/src/locale/catclose.c index 02cd3e5..a110246 100644 --- a/libc-top-half/musl/src/locale/catclose.c +++ b/libc-top-half/musl/src/locale/catclose.c @@ -1,6 +1,18 @@ +#define _BSD_SOURCE #include +#include +#include +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet +#include +#endif + +#define V(p) be32toh(*(uint32_t *)(p)) int catclose (nl_catd catd) { +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet + char *map = (char *)catd; + munmap(map, V(map+8)+20); +#endif return 0; } diff --git a/libc-top-half/musl/src/locale/catgets.c b/libc-top-half/musl/src/locale/catgets.c index bbee898..ad0457f 100644 --- a/libc-top-half/musl/src/locale/catgets.c +++ b/libc-top-half/musl/src/locale/catgets.c @@ -1,6 +1,44 @@ +#define _BSD_SOURCE #include +#include +#include +#include +#include + +#define V(p) be32toh(*(uint32_t *)(p)) + +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet +static int cmp(const void *a, const void *b) +{ + uint32_t x = V(a), y = V(b); + return xy ? 1 : 0; +} +#endif char *catgets (nl_catd catd, int set_id, int msg_id, const char *s) { +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet + const char *map = (const char *)catd; + uint32_t nsets = V(map+4); + const char *sets = map+20; + const char *msgs = map+20+V(map+12); + const char *strings = map+20+V(map+16); + uint32_t set_id_be = htobe32(set_id); + uint32_t msg_id_be = htobe32(msg_id); + const char *set = bsearch(&set_id_be, sets, nsets, 12, cmp); + if (!set) { + errno = ENOMSG; + return (char *)s; + } + uint32_t nmsgs = V(set+4); + msgs += 12*V(set+8); + const char *msg = bsearch(&msg_id_be, msgs, nmsgs, 12, cmp); + if (!msg) { + errno = ENOMSG; + return (char *)s; + } + return (char *)(strings + V(msg+8)); +#else return (char *)s; +#endif } diff --git a/libc-top-half/musl/src/locale/catopen.c b/libc-top-half/musl/src/locale/catopen.c index 3fbc771..c6116b1 100644 --- a/libc-top-half/musl/src/locale/catopen.c +++ b/libc-top-half/musl/src/locale/catopen.c @@ -1,8 +1,87 @@ +#define _BSD_SOURCE #include +#include +#include +#include #include +#include +#include +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet +#include +#endif +#include "libc.h" -nl_catd catopen (const char *name, int oflag) +#define V(p) be32toh(*(uint32_t *)(p)) + +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet +static nl_catd do_catopen(const char *name) { + size_t size; + const unsigned char *map = __map_file(name, &size); + /* Size recorded in the file must match file size; otherwise + * the information needed to unmap the file will be lost. */ + if (!map || V(map) != 0xff88ff89 || 20+V(map+8) != size) { + if(map) munmap((void *)map, size); + errno = ENOENT; + return (nl_catd)-1; + } + return (nl_catd)map; +} +#endif + +nl_catd catopen(const char *name, int oflag) +{ +#ifdef __wasilibc_unmodified_upstream // wasi-libc doesn't support catgets yet + nl_catd catd; + + if (strchr(name, '/')) return do_catopen(name); + + char buf[PATH_MAX]; + size_t i; + const char *path, *lang, *p, *z; + if (libc.secure || !(path = getenv("NLSPATH"))) { + errno = ENOENT; + return (nl_catd)-1; + } + lang = oflag ? nl_langinfo(_NL_LOCALE_NAME(LC_MESSAGES)) : getenv("LANG"); + if (!lang) lang = ""; + for (p=path; *p; p=z) { + i = 0; + z = __strchrnul(p, ':'); + for (; p= sizeof buf - i) { + break; + } + memcpy(buf+i, v, l); + i += l; + } + if (!*z && (p #include +#include #include "libm.h" /* @@ -26,7 +27,18 @@ as a double. */ #if LONG_MAX < 1U<<53 && defined(FE_INEXACT) -long lrint(double x) +#include +#include +#if FLT_EVAL_METHOD==0 || FLT_EVAL_METHOD==1 +#define EPS DBL_EPSILON +#elif FLT_EVAL_METHOD==2 +#define EPS LDBL_EPSILON +#endif +#ifdef __GNUC__ +/* avoid stack frame in lrint */ +__attribute__((noinline)) +#endif +static long lrint_slow(double x) { #pragma STDC FENV_ACCESS ON int e; @@ -38,6 +50,20 @@ long lrint(double x) /* conversion */ return x; } + +long lrint(double x) +{ + uint32_t abstop = asuint64(x)>>32 & 0x7fffffff; + uint64_t sign = asuint64(x) & (1ULL << 63); + + if (abstop < 0x41dfffff) { + /* |x| < 0x7ffffc00, no overflow */ + double_t toint = asdouble(asuint64(1/EPS) | sign); + double_t y = x + toint - toint; + return (long)y; + } + return lrint_slow(x); +} #else long lrint(double x) { diff --git a/libc-top-half/musl/src/math/sqrt.c b/libc-top-half/musl/src/math/sqrt.c index b277567..f1f6d76 100644 --- a/libc-top-half/musl/src/math/sqrt.c +++ b/libc-top-half/musl/src/math/sqrt.c @@ -179,7 +179,6 @@ double sqrt(double x) ix1 = q1>>1; if (q&1) ix1 |= sign; - ix0 += m << 20; - INSERT_WORDS(z, ix0, ix1); + INSERT_WORDS(z, ix0 + ((uint32_t)m << 20), ix1); return z; } diff --git a/libc-top-half/musl/src/math/sqrtf.c b/libc-top-half/musl/src/math/sqrtf.c index 28cb4ad..d6ace38 100644 --- a/libc-top-half/musl/src/math/sqrtf.c +++ b/libc-top-half/musl/src/math/sqrtf.c @@ -78,7 +78,6 @@ float sqrtf(float x) } } ix = (q>>1) + 0x3f000000; - ix += m << 23; - SET_FLOAT_WORD(z, ix); + SET_FLOAT_WORD(z, ix + ((uint32_t)m << 23)); return z; } diff --git a/libc-top-half/musl/src/misc/getopt.c b/libc-top-half/musl/src/misc/getopt.c index 864d52c..c3f6699 100644 --- a/libc-top-half/musl/src/misc/getopt.c +++ b/libc-top-half/musl/src/misc/getopt.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include #include #include diff --git a/libc-top-half/musl/src/misc/ioctl.c b/libc-top-half/musl/src/misc/ioctl.c index 5a41f0e..6f31d4b 100644 --- a/libc-top-half/musl/src/misc/ioctl.c +++ b/libc-top-half/musl/src/misc/ioctl.c @@ -1,5 +1,8 @@ #include #include +#include +#include +#include #include "syscall.h" int ioctl(int fd, int req, ...) @@ -9,5 +12,25 @@ int ioctl(int fd, int req, ...) va_start(ap, req); arg = va_arg(ap, void *); va_end(ap); - return syscall(SYS_ioctl, fd, req, arg); + int r = __syscall(SYS_ioctl, fd, req, arg); + if (r==-ENOTTY) switch (req) { + case SIOCGSTAMP: + case SIOCGSTAMPNS: + if (SIOCGSTAMP==SIOCGSTAMP_OLD) break; + if (req==SIOCGSTAMP) req=SIOCGSTAMP_OLD; + if (req==SIOCGSTAMPNS) req=SIOCGSTAMPNS_OLD; + long t32[2]; + r = __syscall(SYS_ioctl, fd, req, t32); + if (r<0) break; + if (req==SIOCGSTAMP_OLD) { + struct timeval *tv = arg; + tv->tv_sec = t32[0]; + tv->tv_usec = t32[1]; + } else { + struct timespec *ts = arg; + ts->tv_sec = t32[0]; + ts->tv_nsec = t32[1]; + } + } + return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/mq/mq_timedreceive.c b/libc-top-half/musl/src/mq/mq_timedreceive.c index 2cef6a8..f41b664 100644 --- a/libc-top-half/musl/src/mq/mq_timedreceive.c +++ b/libc-top-half/musl/src/mq/mq_timedreceive.c @@ -1,7 +1,24 @@ #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + ssize_t mq_timedreceive(mqd_t mqd, char *restrict msg, size_t len, unsigned *restrict prio, const struct timespec *restrict at) { +#ifdef SYS_mq_timedreceive_time64 + time_t s = at ? at->tv_sec : 0; + long ns = at ? at->tv_nsec : 0; + long r = -ENOSYS; + if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_mq_timedreceive_time64, mqd, msg, len, prio, + at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0); + if (SYS_mq_timedreceive == SYS_mq_timedreceive_time64 || r != -ENOSYS) + return __syscall_ret(r); + return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio, + at ? ((long[]){CLAMP(s), ns}) : 0); +#else return syscall_cp(SYS_mq_timedreceive, mqd, msg, len, prio, at); +#endif } diff --git a/libc-top-half/musl/src/mq/mq_timedsend.c b/libc-top-half/musl/src/mq/mq_timedsend.c index 1c00aa0..56cfcbb 100644 --- a/libc-top-half/musl/src/mq/mq_timedsend.c +++ b/libc-top-half/musl/src/mq/mq_timedsend.c @@ -1,7 +1,24 @@ #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int mq_timedsend(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec *at) { +#ifdef SYS_mq_timedsend_time64 + time_t s = at ? at->tv_sec : 0; + long ns = at ? at->tv_nsec : 0; + long r = -ENOSYS; + if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_mq_timedsend_time64, mqd, msg, len, prio, + at ? ((long long []){at->tv_sec, at->tv_nsec}) : 0); + if (SYS_mq_timedsend == SYS_mq_timedsend_time64 || r != -ENOSYS) + return __syscall_ret(r); + return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio, + at ? ((long[]){CLAMP(s), ns}) : 0); +#else return syscall_cp(SYS_mq_timedsend, mqd, msg, len, prio, at); +#endif } diff --git a/libc-top-half/musl/src/multibyte/mbsrtowcs.c b/libc-top-half/musl/src/multibyte/mbsrtowcs.c index 0ee8b69..9b2f2df 100644 --- a/libc-top-half/musl/src/multibyte/mbsrtowcs.c +++ b/libc-top-half/musl/src/multibyte/mbsrtowcs.c @@ -38,12 +38,15 @@ size_t mbsrtowcs(wchar_t *restrict ws, const char **restrict src, size_t wn, mbs } if (!ws) for (;;) { +#ifdef __GNUC__ + typedef uint32_t __attribute__((__may_alias__)) w32; if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) { - while (!(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { + while (!(( *(w32*)s | *(w32*)s-0x01010101) & 0x80808080)) { s += 4; wn -= 4; } } +#endif if (*s-1u < 0x7f) { s++; wn--; @@ -69,8 +72,10 @@ resume0: *src = (const void *)s; return wn0; } +#ifdef __GNUC__ + typedef uint32_t __attribute__((__may_alias__)) w32; if (*s-1u < 0x7f && (uintptr_t)s%4 == 0) { - while (wn>=5 && !(( *(uint32_t*)s | *(uint32_t*)s-0x01010101) & 0x80808080)) { + while (wn>=5 && !(( *(w32*)s | *(w32*)s-0x01010101) & 0x80808080)) { *ws++ = *s++; *ws++ = *s++; *ws++ = *s++; @@ -78,6 +83,7 @@ resume0: wn -= 4; } } +#endif if (*s-1u < 0x7f) { *ws++ = *s++; wn--; diff --git a/libc-top-half/musl/src/network/getsockopt.c b/libc-top-half/musl/src/network/getsockopt.c index 28079d8..e871d62 100644 --- a/libc-top-half/musl/src/network/getsockopt.c +++ b/libc-top-half/musl/src/network/getsockopt.c @@ -1,7 +1,32 @@ #include +#include +#include #include "syscall.h" int getsockopt(int fd, int level, int optname, void *restrict optval, socklen_t *restrict optlen) { - return socketcall(getsockopt, fd, level, optname, optval, optlen, 0); + long tv32[2]; + struct timeval *tv; + + int r = __socketcall(getsockopt, fd, level, optname, optval, optlen, 0); + + if (r==-ENOPROTOOPT) switch (level) { + case SOL_SOCKET: + switch (optname) { + case SO_RCVTIMEO: + case SO_SNDTIMEO: + if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break; + if (*optlen < sizeof *tv) return __syscall_ret(-EINVAL); + if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD; + if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD; + r = __socketcall(getsockopt, fd, level, optname, + tv32, (socklen_t[]){sizeof tv32}, 0); + if (r<0) break; + tv = optval; + tv->tv_sec = tv32[0]; + tv->tv_usec = tv32[1]; + *optlen = sizeof *tv; + } + } + return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/network/recvmmsg.c b/libc-top-half/musl/src/network/recvmmsg.c index 58b1b2f..d5dc6b5 100644 --- a/libc-top-half/musl/src/network/recvmmsg.c +++ b/libc-top-half/musl/src/network/recvmmsg.c @@ -1,8 +1,13 @@ #define _GNU_SOURCE #include #include +#include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout) { #if LONG_MAX > INT_MAX @@ -11,5 +16,18 @@ int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla for (i = vlen; i; i--, mh++) mh->msg_hdr.__pad1 = mh->msg_hdr.__pad2 = 0; #endif +#ifdef SYS_recvmmsg_time64 + time_t s = timeout ? timeout->tv_sec : 0; + long ns = timeout ? timeout->tv_nsec : 0; + int r = -ENOSYS; + if (SYS_recvmmsg == SYS_recvmmsg_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags, + timeout ? ((long long[]){s, ns}) : 0); + if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS) + return __syscall_ret(r); + return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, + timeout ? ((long[]){CLAMP(s), ns}) : 0); +#else return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, timeout); +#endif } diff --git a/libc-top-half/musl/src/network/setsockopt.c b/libc-top-half/musl/src/network/setsockopt.c index c960c9c..2c188a9 100644 --- a/libc-top-half/musl/src/network/setsockopt.c +++ b/libc-top-half/musl/src/network/setsockopt.c @@ -1,7 +1,37 @@ #include +#include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int setsockopt(int fd, int level, int optname, const void *optval, socklen_t optlen) { - return socketcall(setsockopt, fd, level, optname, optval, optlen, 0); + const struct timeval *tv; + time_t s; + suseconds_t us; + + int r = __socketcall(setsockopt, fd, level, optname, optval, optlen, 0); + + if (r==-ENOPROTOOPT) switch (level) { + case SOL_SOCKET: + switch (optname) { + case SO_RCVTIMEO: + case SO_SNDTIMEO: + if (SO_RCVTIMEO == SO_RCVTIMEO_OLD) break; + if (optlen < sizeof *tv) return __syscall_ret(-EINVAL); + tv = optval; + s = tv->tv_sec; + us = tv->tv_usec; + if (!IS32BIT(s)) return __syscall_ret(-ENOTSUP); + + if (optname==SO_RCVTIMEO) optname=SO_RCVTIMEO_OLD; + if (optname==SO_SNDTIMEO) optname=SO_SNDTIMEO_OLD; + + r = __socketcall(setsockopt, fd, level, optname, + ((long[]){s, CLAMP(us)}), 2*sizeof(long), 0); + } + } + return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/process/fdop.h b/libc-top-half/musl/src/process/fdop.h index 00b8751..5adf144 100644 --- a/libc-top-half/musl/src/process/fdop.h +++ b/libc-top-half/musl/src/process/fdop.h @@ -1,6 +1,8 @@ #define FDOP_CLOSE 1 #define FDOP_DUP2 2 #define FDOP_OPEN 3 +#define FDOP_CHDIR 4 +#define FDOP_FCHDIR 5 struct fdop { struct fdop *next, *prev; diff --git a/libc-top-half/musl/src/process/posix_spawn.c b/libc-top-half/musl/src/process/posix_spawn.c index 306faa0..2965219 100644 --- a/libc-top-half/musl/src/process/posix_spawn.c +++ b/libc-top-half/musl/src/process/posix_spawn.c @@ -125,6 +125,14 @@ static int child(void *args_vp) __syscall(SYS_close, fd); } break; + case FDOP_CHDIR: + ret = __syscall(SYS_chdir, op->path); + if (ret<0) goto fail; + break; + case FDOP_FCHDIR: + ret = __syscall(SYS_fchdir, op->fd); + if (ret<0) goto fail; + break; } } } diff --git a/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c b/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c new file mode 100644 index 0000000..7f2590a --- /dev/null +++ b/libc-top-half/musl/src/process/posix_spawn_file_actions_addchdir.c @@ -0,0 +1,18 @@ +#include +#include +#include +#include +#include "fdop.h" + +int posix_spawn_file_actions_addchdir_np(posix_spawn_file_actions_t *restrict fa, const char *restrict path) +{ + struct fdop *op = malloc(sizeof *op + strlen(path) + 1); + if (!op) return ENOMEM; + op->cmd = FDOP_CHDIR; + op->fd = -1; + strcpy(op->path, path); + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; + fa->__actions = op; + return 0; +} diff --git a/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c b/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c new file mode 100644 index 0000000..436c683 --- /dev/null +++ b/libc-top-half/musl/src/process/posix_spawn_file_actions_addfchdir.c @@ -0,0 +1,17 @@ +#include +#include +#include +#include +#include "fdop.h" + +int posix_spawn_file_actions_addfchdir_np(posix_spawn_file_actions_t *fa, int fd) +{ + struct fdop *op = malloc(sizeof *op); + if (!op) return ENOMEM; + op->cmd = FDOP_FCHDIR; + op->fd = fd; + if ((op->next = fa->__actions)) op->next->prev = op; + op->prev = 0; + fa->__actions = op; + return 0; +} diff --git a/libc-top-half/musl/src/regex/glob.c b/libc-top-half/musl/src/regex/glob.c index aa1c6a4..78063a4 100644 --- a/libc-top-half/musl/src/regex/glob.c +++ b/libc-top-half/musl/src/regex/glob.c @@ -8,6 +8,10 @@ #include #include #include +#include +#ifdef __wasilibc_unmodified_upstream // WASI has no usernames +#include +#endif struct match { @@ -90,16 +94,23 @@ static int do_glob(char *buf, size_t pos, int type, char *pat, int flags, int (* if (!*pat) { /* If we consumed any components above, or if GLOB_MARK is * requested and we don't yet know if the match is a dir, - * we must call stat to confirm the file exists and/or - * determine its type. */ + * we must confirm the file exists and/or determine its type. + * + * If marking dirs, symlink type is inconclusive; we need the + * type for the symlink target, and therefore must try stat + * first unless type is known not to be a symlink. Otherwise, + * or if that fails, use lstat for determining existence to + * avoid false negatives in the case of broken symlinks. */ struct stat st; - if ((flags & GLOB_MARK) && type==DT_LNK) type = 0; - if (!type && stat(buf, &st)) { + if ((flags & GLOB_MARK) && (!type||type==DT_LNK) && !stat(buf, &st)) { + if (S_ISDIR(st.st_mode)) type = DT_DIR; + else type = DT_REG; + } + if (!type && lstat(buf, &st)) { if (errno!=ENOENT && (errfunc(buf, errno) || (flags & GLOB_ERR))) return GLOB_ABORTED; return 0; } - if (!type && S_ISDIR(st.st_mode)) type = DT_DIR; if (append(tail, buf, pos, (flags & GLOB_MARK) && type==DT_DIR)) return GLOB_NOSPACE; return 0; @@ -182,6 +193,41 @@ static int sort(const void *a, const void *b) return strcmp(*(const char **)a, *(const char **)b); } +#ifdef __wasilibc_unmodified_upstream // WASI has no usernames +static int expand_tilde(char **pat, char *buf, size_t *pos) +{ + char *p = *pat + 1; + size_t i = 0; + + char delim, *name_end = __strchrnul(p, '/'); + if ((delim = *name_end)) *name_end++ = 0; + *pat = name_end; + + char *home = *p ? NULL : getenv("HOME"); + if (!home) { + struct passwd pw, *res; + switch (*p ? getpwnam_r(p, &pw, buf, PATH_MAX, &res) + : getpwuid_r(getuid(), &pw, buf, PATH_MAX, &res)) { + case ENOMEM: + return GLOB_NOSPACE; + case 0: + if (!res) + default: + return GLOB_NOMATCH; + } + home = pw.pw_dir; + } + while (i < PATH_MAX - 2 && *home) + buf[i++] = *home++; + if (*home) + return GLOB_NOMATCH; + if ((buf[i] = delim)) + buf[++i] = 0; + *pos = i; + return 0; +} +#endif + int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, int err), glob_t *restrict g) { struct match head = { .next = NULL }, *tail = &head; @@ -202,7 +248,14 @@ int glob(const char *restrict pat, int flags, int (*errfunc)(const char *path, i char *p = strdup(pat); if (!p) return GLOB_NOSPACE; buf[0] = 0; - error = do_glob(buf, 0, 0, p, flags, errfunc, &tail); + size_t pos = 0; + char *s = p; +#ifdef __wasilibc_unmodified_upstream // WASI has no usernames + if ((flags & (GLOB_TILDE | GLOB_TILDE_CHECK)) && *p == '~') + error = expand_tilde(&s, buf, &pos); +#endif + if (!error) + error = do_glob(buf, pos, 0, s, flags, errfunc, &tail); free(p); } diff --git a/libc-top-half/musl/src/sched/sched_rr_get_interval.c b/libc-top-half/musl/src/sched/sched_rr_get_interval.c index 4b01028..33a3d1a 100644 --- a/libc-top-half/musl/src/sched/sched_rr_get_interval.c +++ b/libc-top-half/musl/src/sched/sched_rr_get_interval.c @@ -3,5 +3,19 @@ int sched_rr_get_interval(pid_t pid, struct timespec *ts) { +#ifdef SYS_sched_rr_get_interval_time64 + /* On a 32-bit arch, use the old syscall if it exists. */ + if (SYS_sched_rr_get_interval != SYS_sched_rr_get_interval_time64) { + long ts32[2]; + int r = __syscall(SYS_sched_rr_get_interval, pid, ts32); + if (!r) { + ts->tv_sec = ts32[0]; + ts->tv_nsec = ts32[1]; + } + return __syscall_ret(r); + } +#endif + /* If reaching this point, it's a 64-bit arch or time64-only + * 32-bit arch and we can get result directly into timespec. */ return syscall(SYS_sched_rr_get_interval, pid, ts); } diff --git a/libc-top-half/musl/src/select/pselect.c b/libc-top-half/musl/src/select/pselect.c index 762af37..54cfb29 100644 --- a/libc-top-half/musl/src/select/pselect.c +++ b/libc-top-half/musl/src/select/pselect.c @@ -1,12 +1,26 @@ #include #include #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int pselect(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec *restrict ts, const sigset_t *restrict mask) { syscall_arg_t data[2] = { (uintptr_t)mask, _NSIG/8 }; - struct timespec ts_tmp; - if (ts) ts_tmp = *ts; - return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, ts ? &ts_tmp : 0, data); + time_t s = ts ? ts->tv_sec : 0; + long ns = ts ? ts->tv_nsec : 0; +#ifdef SYS_pselect6_time64 + int r = -ENOSYS; + if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds, + ts ? ((long long[]){s, ns}) : 0, data); + if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS) + return __syscall_ret(r); + s = CLAMP(s); +#endif + return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, + ts ? ((long[]){s, ns}) : 0, data); } diff --git a/libc-top-half/musl/src/select/select.c b/libc-top-half/musl/src/select/select.c index 02fd75c..8a78688 100644 --- a/libc-top-half/musl/src/select/select.c +++ b/libc-top-half/musl/src/select/select.c @@ -4,22 +4,41 @@ #include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + int select(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval *restrict tv) { -#ifdef SYS_select - return syscall_cp(SYS_select, n, rfds, wfds, efds, tv); -#else - syscall_arg_t data[2] = { 0, _NSIG/8 }; - struct timespec ts; - if (tv) { - if (tv->tv_sec < 0 || tv->tv_usec < 0) - return __syscall_ret(-EINVAL); - time_t extra_secs = tv->tv_usec / 1000000; - ts.tv_nsec = tv->tv_usec % 1000000 * 1000; - const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1; - ts.tv_sec = extra_secs > max_time - tv->tv_sec ? - max_time : tv->tv_sec + extra_secs; + time_t s = tv ? tv->tv_sec : 0; + suseconds_t us = tv ? tv->tv_usec : 0; + long ns; + const time_t max_time = (1ULL<<8*sizeof(time_t)-1)-1; + + if (s<0 || us<0) return __syscall_ret(-EINVAL); + if (us/1000000 > max_time - s) { + s = max_time; + us = 999999; + ns = 999999999; + } else { + s += us/1000000; + us %= 1000000; + ns = us*1000; } - return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, tv ? &ts : 0, data); + +#ifdef SYS_pselect6_time64 + int r = -ENOSYS; + if (SYS_pselect6 == SYS_pselect6_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_pselect6_time64, n, rfds, wfds, efds, + tv ? ((long long[]){s, ns}) : 0, + ((syscall_arg_t[]){ 0, _NSIG/8 })); + if (SYS_pselect6 == SYS_pselect6_time64 || r!=-ENOSYS) + return __syscall_ret(r); +#endif +#ifdef SYS_select + return syscall_cp(SYS_select, n, rfds, wfds, efds, + tv ? ((long[]){s, us}) : 0); +#else + return syscall_cp(SYS_pselect6, n, rfds, wfds, efds, + tv ? ((long[]){s, ns}) : 0, ((syscall_arg_t[]){ 0, _NSIG/8 })); #endif } diff --git a/libc-top-half/musl/src/setjmp/arm/longjmp.s b/libc-top-half/musl/src/setjmp/arm/longjmp.S similarity index 87% rename from libc-top-half/musl/src/setjmp/arm/longjmp.s rename to libc-top-half/musl/src/setjmp/arm/longjmp.S index 76cc292..8df0b81 100644 --- a/libc-top-half/musl/src/setjmp/arm/longjmp.s +++ b/libc-top-half/musl/src/setjmp/arm/longjmp.S @@ -16,11 +16,14 @@ longjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f ldc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -28,6 +31,8 @@ longjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f ldcl p1, cr10, [ip], #8 @@ -36,6 +41,8 @@ longjmp: ldcl p1, cr13, [ip], #8 ldcl p1, cr14, [ip], #8 ldcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/libc-top-half/musl/src/setjmp/arm/setjmp.s b/libc-top-half/musl/src/setjmp/arm/setjmp.S similarity index 88% rename from libc-top-half/musl/src/setjmp/arm/setjmp.s rename to libc-top-half/musl/src/setjmp/arm/setjmp.S index 011315b..45731d2 100644 --- a/libc-top-half/musl/src/setjmp/arm/setjmp.s +++ b/libc-top-half/musl/src/setjmp/arm/setjmp.S @@ -18,11 +18,14 @@ setjmp: ldr r2,1f ldr r1,[r1,r2] +#if __ARM_ARCH < 8 tst r1,#0x260 beq 3f + // HWCAP_ARM_FPA tst r1,#0x20 beq 2f stc p2, cr4, [ip], #48 +#endif 2: tst r1,#0x40 beq 2f .fpu vfp @@ -30,6 +33,8 @@ setjmp: .fpu softvfp .eabi_attribute 10, 0 .eabi_attribute 27, 0 +#if __ARM_ARCH < 8 + // HWCAP_ARM_IWMMXT 2: tst r1,#0x200 beq 3f stcl p1, cr10, [ip], #8 @@ -38,6 +43,8 @@ setjmp: stcl p1, cr13, [ip], #8 stcl p1, cr14, [ip], #8 stcl p1, cr15, [ip], #8 +#endif +2: 3: bx lr .hidden __hwcap diff --git a/libc-top-half/musl/src/setjmp/mips/longjmp.S b/libc-top-half/musl/src/setjmp/mips/longjmp.S index fdb6c95..ecf4085 100644 --- a/libc-top-half/musl/src/setjmp/mips/longjmp.S +++ b/libc-top-half/musl/src/setjmp/mips/longjmp.S @@ -12,18 +12,12 @@ longjmp: addu $2, $2, 1 1: #ifndef __mips_soft_float - lwc1 $20, 56($4) - lwc1 $21, 60($4) - lwc1 $22, 64($4) - lwc1 $23, 68($4) - lwc1 $24, 72($4) - lwc1 $25, 76($4) - lwc1 $26, 80($4) - lwc1 $27, 84($4) - lwc1 $28, 88($4) - lwc1 $29, 92($4) - lwc1 $30, 96($4) - lwc1 $31, 100($4) + l.d $f20, 56($4) + l.d $f22, 64($4) + l.d $f24, 72($4) + l.d $f26, 80($4) + l.d $f28, 88($4) + l.d $f30, 96($4) #endif lw $ra, 0($4) lw $sp, 4($4) diff --git a/libc-top-half/musl/src/setjmp/mips/setjmp.S b/libc-top-half/musl/src/setjmp/mips/setjmp.S index 501d526..7ae8832 100644 --- a/libc-top-half/musl/src/setjmp/mips/setjmp.S +++ b/libc-top-half/musl/src/setjmp/mips/setjmp.S @@ -22,18 +22,12 @@ setjmp: sw $30, 40($4) sw $28, 44($4) #ifndef __mips_soft_float - swc1 $20, 56($4) - swc1 $21, 60($4) - swc1 $22, 64($4) - swc1 $23, 68($4) - swc1 $24, 72($4) - swc1 $25, 76($4) - swc1 $26, 80($4) - swc1 $27, 84($4) - swc1 $28, 88($4) - swc1 $29, 92($4) - swc1 $30, 96($4) - swc1 $31, 100($4) + s.d $f20, 56($4) + s.d $f22, 64($4) + s.d $f24, 72($4) + s.d $f26, 80($4) + s.d $f28, 88($4) + s.d $f30, 96($4) #endif jr $ra li $2, 0 diff --git a/libc-top-half/musl/src/signal/getitimer.c b/libc-top-half/musl/src/signal/getitimer.c index 8a8046a..36d1eb9 100644 --- a/libc-top-half/musl/src/signal/getitimer.c +++ b/libc-top-half/musl/src/signal/getitimer.c @@ -3,5 +3,16 @@ int getitimer(int which, struct itimerval *old) { + if (sizeof(time_t) > sizeof(long)) { + long old32[4]; + int r = __syscall(SYS_getitimer, which, old32); + if (!r) { + old->it_interval.tv_sec = old32[0]; + old->it_interval.tv_usec = old32[1]; + old->it_value.tv_sec = old32[2]; + old->it_value.tv_usec = old32[3]; + } + return __syscall_ret(r); + } return syscall(SYS_getitimer, which, old); } diff --git a/libc-top-half/musl/src/signal/setitimer.c b/libc-top-half/musl/src/signal/setitimer.c index 21b1f45..0dfbeb4 100644 --- a/libc-top-half/musl/src/signal/setitimer.c +++ b/libc-top-half/musl/src/signal/setitimer.c @@ -1,7 +1,26 @@ #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old) { + if (sizeof(time_t) > sizeof(long)) { + time_t is = new->it_interval.tv_sec, vs = new->it_value.tv_sec; + long ius = new->it_interval.tv_usec, vus = new->it_value.tv_usec; + if (!IS32BIT(is) || !IS32BIT(vs)) + return __syscall_ret(-ENOTSUP); + long old32[4]; + int r = __syscall(SYS_setitimer, which, + ((long[]){is, ius, vs, vus}), old32); + if (!r && old) { + old->it_interval.tv_sec = old32[0]; + old->it_interval.tv_usec = old32[1]; + old->it_value.tv_sec = old32[2]; + old->it_value.tv_usec = old32[3]; + } + return __syscall_ret(r); + } return syscall(SYS_setitimer, which, new, old); } diff --git a/libc-top-half/musl/src/signal/sigaction.c b/libc-top-half/musl/src/signal/sigaction.c index 0544508..c109bea 100644 --- a/libc-top-half/musl/src/signal/sigaction.c +++ b/libc-top-half/musl/src/signal/sigaction.c @@ -7,7 +7,7 @@ #include "lock.h" #include "ksigaction.h" -volatile int dummy_lock[1] = { 0 }; +static volatile int dummy_lock[1] = { 0 }; extern hidden volatile int __abort_lock[1]; diff --git a/libc-top-half/musl/src/signal/sigtimedwait.c b/libc-top-half/musl/src/signal/sigtimedwait.c index 7bcfe72..1287174 100644 --- a/libc-top-half/musl/src/signal/sigtimedwait.c +++ b/libc-top-half/musl/src/signal/sigtimedwait.c @@ -2,11 +2,31 @@ #include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + +static int do_sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict ts) +{ +#ifdef SYS_rt_sigtimedwait_time64 + time_t s = ts ? ts->tv_sec : 0; + long ns = ts ? ts->tv_nsec : 0; + int r = -ENOSYS; + if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_rt_sigtimedwait_time64, mask, si, + ts ? ((long long[]){s, ns}) : 0, _NSIG/8); + if (SYS_rt_sigtimedwait == SYS_rt_sigtimedwait_time64 || r!=-ENOSYS) + return r; + return __syscall_cp(SYS_rt_sigtimedwait, mask, si, + ts ? ((long[]){CLAMP(s), ns}) : 0, _NSIG/8);; +#else + return __syscall_cp(SYS_rt_sigtimedwait, mask, si, ts, _NSIG/8); +#endif +} + int sigtimedwait(const sigset_t *restrict mask, siginfo_t *restrict si, const struct timespec *restrict timeout) { int ret; - do ret = syscall_cp(SYS_rt_sigtimedwait, mask, - si, timeout, _NSIG/8); - while (ret<0 && errno==EINTR); - return ret; + do ret = do_sigtimedwait(mask, si, timeout); + while (ret==-EINTR); + return __syscall_ret(ret); } diff --git a/libc-top-half/musl/src/signal/x32/getitimer.c b/libc-top-half/musl/src/signal/x32/getitimer.c new file mode 100644 index 0000000..8a8046a --- /dev/null +++ b/libc-top-half/musl/src/signal/x32/getitimer.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int getitimer(int which, struct itimerval *old) +{ + return syscall(SYS_getitimer, which, old); +} diff --git a/libc-top-half/musl/src/signal/x32/setitimer.c b/libc-top-half/musl/src/signal/x32/setitimer.c new file mode 100644 index 0000000..21b1f45 --- /dev/null +++ b/libc-top-half/musl/src/signal/x32/setitimer.c @@ -0,0 +1,7 @@ +#include +#include "syscall.h" + +int setitimer(int which, const struct itimerval *restrict new, struct itimerval *restrict old) +{ + return syscall(SYS_setitimer, which, new, old); +} diff --git a/libc-top-half/musl/src/stat/fstat.c b/libc-top-half/musl/src/stat/fstat.c index 4f13f4f..07f9a5d 100644 --- a/libc-top-half/musl/src/stat/fstat.c +++ b/libc-top-half/musl/src/stat/fstat.c @@ -1,3 +1,4 @@ +#define _BSD_SOURCE #include #include #include @@ -5,17 +6,8 @@ int fstat(int fd, struct stat *st) { - int ret = __syscall(SYS_fstat, fd, st); - if (ret != -EBADF || __syscall(SYS_fcntl, fd, F_GETFD) < 0) - return __syscall_ret(ret); - - char buf[15+3*sizeof(int)]; - __procfdname(buf, fd); -#ifdef SYS_stat - return syscall(SYS_stat, buf, st); -#else - return syscall(SYS_fstatat, AT_FDCWD, buf, st, 0); -#endif + if (fd<0) return __syscall_ret(-EBADF); + return fstatat(fd, "", st, AT_EMPTY_PATH); } weak_alias(fstat, fstat64); diff --git a/libc-top-half/musl/src/stat/fstatat.c b/libc-top-half/musl/src/stat/fstatat.c index 582db44..d915fa1 100644 --- a/libc-top-half/musl/src/stat/fstatat.c +++ b/libc-top-half/musl/src/stat/fstatat.c @@ -1,9 +1,129 @@ +#define _BSD_SOURCE #include +#include +#include +#include +#include +#include #include "syscall.h" +#include "kstat.h" -int fstatat(int fd, const char *restrict path, struct stat *restrict buf, int flag) +struct statx { + uint32_t stx_mask; + uint32_t stx_blksize; + uint64_t stx_attributes; + uint32_t stx_nlink; + uint32_t stx_uid; + uint32_t stx_gid; + uint16_t stx_mode; + uint16_t pad1; + uint64_t stx_ino; + uint64_t stx_size; + uint64_t stx_blocks; + uint64_t stx_attributes_mask; + struct { + int64_t tv_sec; + uint32_t tv_nsec; + int32_t pad; + } stx_atime, stx_btime, stx_ctime, stx_mtime; + uint32_t stx_rdev_major; + uint32_t stx_rdev_minor; + uint32_t stx_dev_major; + uint32_t stx_dev_minor; + uint64_t spare[14]; +}; + +static int fstatat_statx(int fd, const char *restrict path, struct stat *restrict st, int flag) { - return syscall(SYS_fstatat, fd, path, buf, flag); + struct statx stx; + + int ret = __syscall(SYS_statx, fd, path, flag, 0x7ff, &stx); + if (ret) return ret; + + *st = (struct stat){ + .st_dev = makedev(stx.stx_dev_major, stx.stx_dev_minor), + .st_ino = stx.stx_ino, + .st_mode = stx.stx_mode, + .st_nlink = stx.stx_nlink, + .st_uid = stx.stx_uid, + .st_gid = stx.stx_gid, + .st_rdev = makedev(stx.stx_rdev_major, stx.stx_rdev_minor), + .st_size = stx.stx_size, + .st_blksize = stx.stx_blksize, + .st_blocks = stx.stx_blocks, + .st_atim.tv_sec = stx.stx_atime.tv_sec, + .st_atim.tv_nsec = stx.stx_atime.tv_nsec, + .st_mtim.tv_sec = stx.stx_mtime.tv_sec, + .st_mtim.tv_nsec = stx.stx_mtime.tv_nsec, + .st_ctim.tv_sec = stx.stx_ctime.tv_sec, + .st_ctim.tv_nsec = stx.stx_ctime.tv_nsec, + }; + return 0; +} + +static int fstatat_kstat(int fd, const char *restrict path, struct stat *restrict st, int flag) +{ + int ret; + struct kstat kst; + + if (flag==AT_EMPTY_PATH && fd>=0 && !*path) { + ret = __syscall(SYS_fstat, fd, &kst); + if (ret==-EBADF && __syscall(SYS_fcntl, fd, F_GETFD)>=0) { + ret = __syscall(SYS_fstatat, fd, path, &kst, flag); + if (ret==-EINVAL) { + char buf[15+3*sizeof(int)]; + __procfdname(buf, fd); +#ifdef SYS_stat + ret = __syscall(SYS_stat, buf, &kst); +#else + ret = __syscall(SYS_fstatat, AT_FDCWD, buf, &kst, 0); +#endif + } + } + } +#ifdef SYS_lstat + else if ((fd == AT_FDCWD || *path=='/') && flag==AT_SYMLINK_NOFOLLOW) + ret = __syscall(SYS_lstat, path, &kst); +#endif +#ifdef SYS_stat + else if ((fd == AT_FDCWD || *path=='/') && !flag) + ret = __syscall(SYS_stat, path, &kst); +#endif + else ret = __syscall(SYS_fstatat, fd, path, &kst, flag); + + if (ret) return ret; + + *st = (struct stat){ + .st_dev = kst.st_dev, + .st_ino = kst.st_ino, + .st_mode = kst.st_mode, + .st_nlink = kst.st_nlink, + .st_uid = kst.st_uid, + .st_gid = kst.st_gid, + .st_rdev = kst.st_rdev, + .st_size = kst.st_size, + .st_blksize = kst.st_blksize, + .st_blocks = kst.st_blocks, + .st_atim.tv_sec = kst.st_atime_sec, + .st_atim.tv_nsec = kst.st_atime_nsec, + .st_mtim.tv_sec = kst.st_mtime_sec, + .st_mtim.tv_nsec = kst.st_mtime_nsec, + .st_ctim.tv_sec = kst.st_ctime_sec, + .st_ctim.tv_nsec = kst.st_ctime_nsec, + }; + + return 0; +} + +int fstatat(int fd, const char *restrict path, struct stat *restrict st, int flag) +{ + int ret; + if (sizeof((struct kstat){0}.st_atime_sec) < sizeof(time_t)) { + ret = fstatat_statx(fd, path, st, flag); + if (ret!=-ENOSYS) return __syscall_ret(ret); + } + ret = fstatat_kstat(fd, path, st, flag); + return __syscall_ret(ret); } weak_alias(fstatat, fstatat64); diff --git a/libc-top-half/musl/src/stat/lstat.c b/libc-top-half/musl/src/stat/lstat.c index 5b89f29..9f95218 100644 --- a/libc-top-half/musl/src/stat/lstat.c +++ b/libc-top-half/musl/src/stat/lstat.c @@ -1,14 +1,9 @@ #include #include -#include "syscall.h" int lstat(const char *restrict path, struct stat *restrict buf) { -#ifdef SYS_lstat - return syscall(SYS_lstat, path, buf); -#else - return syscall(SYS_fstatat, AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); -#endif + return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); } weak_alias(lstat, lstat64); diff --git a/libc-top-half/musl/src/stat/stat.c b/libc-top-half/musl/src/stat/stat.c index 0bec9d6..528870d 100644 --- a/libc-top-half/musl/src/stat/stat.c +++ b/libc-top-half/musl/src/stat/stat.c @@ -1,14 +1,9 @@ #include #include -#include "syscall.h" int stat(const char *restrict path, struct stat *restrict buf) { -#ifdef SYS_stat - return syscall(SYS_stat, path, buf); -#else - return syscall(SYS_fstatat, AT_FDCWD, path, buf, 0); -#endif + return fstatat(AT_FDCWD, path, buf, 0); } weak_alias(stat, stat64); diff --git a/libc-top-half/musl/src/stat/utimensat.c b/libc-top-half/musl/src/stat/utimensat.c index 159c8be..730723a 100644 --- a/libc-top-half/musl/src/stat/utimensat.c +++ b/libc-top-half/musl/src/stat/utimensat.c @@ -4,28 +4,51 @@ #include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define NS_SPECIAL(ns) ((ns)==UTIME_NOW || (ns)==UTIME_OMIT) + int utimensat(int fd, const char *path, const struct timespec times[2], int flags) { - int r = __syscall(SYS_utimensat, fd, path, times, flags); + int r; + if (times && times[0].tv_nsec==UTIME_NOW && times[1].tv_nsec==UTIME_NOW) + times = 0; +#ifdef SYS_utimensat_time64 + r = -ENOSYS; + time_t s0=0, s1=0; + long ns0=0, ns1=0; + if (times) { + ns0 = times[0].tv_nsec; + ns1 = times[1].tv_nsec; + if (!NS_SPECIAL(ns0)) s0 = times[0].tv_sec; + if (!NS_SPECIAL(ns1)) s1 = times[1].tv_sec; + } + if (SYS_utimensat == SYS_utimensat_time64 || !IS32BIT(s0) || !IS32BIT(s1)) + r = __syscall(SYS_utimensat_time64, fd, path, times ? + ((long long[]){s0, ns0, s1, ns1}) : 0, flags); + if (SYS_utimensat == SYS_utimensat_time64 || r!=-ENOSYS) + return __syscall_ret(r); + if (!IS32BIT(s0) || !IS32BIT(s1)) + return __syscall_ret(-ENOTSUP); + r = __syscall(SYS_utimensat, fd, path, + times ? ((long[]){s0, ns0, s1, ns1}) : 0, flags); +#else + r = __syscall(SYS_utimensat, fd, path, times, flags); +#endif + #ifdef SYS_futimesat if (r != -ENOSYS || flags) return __syscall_ret(r); - struct timeval *tv = 0, tmp[2]; + long *tv=0, tmp[4]; if (times) { int i; tv = tmp; for (i=0; i<2; i++) { if (times[i].tv_nsec >= 1000000000ULL) { - if (times[i].tv_nsec == UTIME_NOW && - times[1-i].tv_nsec == UTIME_NOW) { - tv = 0; - break; - } - if (times[i].tv_nsec == UTIME_OMIT) + if (NS_SPECIAL(times[i].tv_nsec)) return __syscall_ret(-ENOSYS); return __syscall_ret(-EINVAL); } - tmp[i].tv_sec = times[i].tv_sec; - tmp[i].tv_usec = times[i].tv_nsec / 1000; + tmp[2*i+0] = times[i].tv_sec; + tmp[2*i+1] = times[i].tv_nsec / 1000; } } diff --git a/libc-top-half/musl/src/stdio/__stdio_seek.c b/libc-top-half/musl/src/stdio/__stdio_seek.c index 709904f..782c678 100644 --- a/libc-top-half/musl/src/stdio/__stdio_seek.c +++ b/libc-top-half/musl/src/stdio/__stdio_seek.c @@ -7,20 +7,5 @@ off_t __stdio_seek(FILE *f, off_t off, int whence) { - off_t ret; -#ifdef SYS__llseek -#ifdef __wasilibc_unmodified_upstream // WASI has no syscall - if (syscall(SYS__llseek, f->fd, off>>32, off, &ret, whence)<0) -#else - if (llseek(f->fd, off>>32, off, &ret, whence)<0) -#endif - ret = -1; -#else -#ifdef __wasilibc_unmodified_upstream // WASI has no syscall - ret = syscall(SYS_lseek, f->fd, off, whence); -#else - ret = lseek(f->fd, off, whence); -#endif -#endif - return ret; + return __lseek(f->fd, off, whence); } diff --git a/libc-top-half/musl/src/stdio/vfwprintf.c b/libc-top-half/musl/src/stdio/vfwprintf.c index ea6285e..e660fcc 100644 --- a/libc-top-half/musl/src/stdio/vfwprintf.c +++ b/libc-top-half/musl/src/stdio/vfwprintf.c @@ -57,6 +57,8 @@ static const unsigned char states[]['z'-'A'+1] = { }, { /* 1: l-prefixed */ S('d') = LONG, S('i') = LONG, S('o') = ULONG, S('u') = ULONG, S('x') = ULONG, S('X') = ULONG, + S('e') = DBL, S('f') = DBL, S('g') = DBL, S('a') = DBL, + S('E') = DBL, S('F') = DBL, S('G') = DBL, S('A') = DBL, S('c') = INT, S('s') = PTR, S('n') = PTR, S('l') = LLPRE, }, { /* 2: ll-prefixed */ diff --git a/libc-top-half/musl/src/thread/__timedwait.c b/libc-top-half/musl/src/thread/__timedwait.c index ae19bd6..666093b 100644 --- a/libc-top-half/musl/src/thread/__timedwait.c +++ b/libc-top-half/musl/src/thread/__timedwait.c @@ -5,6 +5,27 @@ #include "syscall.h" #include "pthread_impl.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + +static int __futex4_cp(volatile void *addr, int op, int val, const struct timespec *to) +{ + int r; +#ifdef SYS_futex_time64 + time_t s = to ? to->tv_sec : 0; + long ns = to ? to->tv_nsec : 0; + r = -ENOSYS; + if (SYS_futex == SYS_futex_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_futex_time64, addr, op, val, + to ? ((long long[]){s, ns}) : 0); + if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r; + to = to ? (void *)(long[]){CLAMP(s), ns} : 0; +#endif + r = __syscall_cp(SYS_futex, addr, op, val, to); + if (r != -ENOSYS) return r; + return __syscall_cp(SYS_futex, addr, op & ~FUTEX_PRIVATE, val, to); +} + static volatile int dummy = 0; weak_alias(dummy, __eintr_valid_flag); @@ -28,8 +49,7 @@ int __timedwait_cp(volatile int *addr, int val, top = &to; } - r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT|priv, val, top); - if (r == ENOSYS) r = -__syscall_cp(SYS_futex, addr, FUTEX_WAIT, val, top); + r = -__futex4_cp(addr, FUTEX_WAIT|priv, val, top); if (r != EINTR && r != ETIMEDOUT && r != ECANCELED) r = 0; /* Mitigate bug in old kernels wrongly reporting EINTR for non- * interrupting (SA_RESTART) signal handlers. This is only practical diff --git a/libc-top-half/musl/src/thread/arm/atomics.s b/libc-top-half/musl/src/thread/arm/atomics.s index 101ad39..da50508 100644 --- a/libc-top-half/musl/src/thread/arm/atomics.s +++ b/libc-top-half/musl/src/thread/arm/atomics.s @@ -15,10 +15,10 @@ __a_barrier_oldkuser: mov r1,r0 mov r2,sp ldr ip,=0xffff0fc0 - mov lr,pc - mov pc,ip + bl 1f pop {r0,r1,r2,r3,ip,lr} bx lr +1: bx ip .global __a_barrier_v6 .hidden __a_barrier_v6 diff --git a/libc-top-half/musl/src/thread/arm/clone.s b/libc-top-half/musl/src/thread/arm/clone.s index e16b132..bb0965d 100644 --- a/libc-top-half/musl/src/thread/arm/clone.s +++ b/libc-top-half/musl/src/thread/arm/clone.s @@ -20,13 +20,9 @@ __clone: bx lr 1: mov r0,r6 - tst r5,#1 - bne 1f - mov lr,pc - mov pc,r5 + bl 3f 2: mov r7,#1 svc 0 - -1: mov lr,pc - bx r5 b 2b + +3: bx r5 diff --git a/libc-top-half/musl/src/thread/arm/syscall_cp.s b/libc-top-half/musl/src/thread/arm/syscall_cp.s index a5730c0..e607dd4 100644 --- a/libc-top-half/musl/src/thread/arm/syscall_cp.s +++ b/libc-top-half/musl/src/thread/arm/syscall_cp.s @@ -11,19 +11,19 @@ .type __syscall_cp_asm,%function __syscall_cp_asm: mov ip,sp - stmfd sp!,{r4,r5,r6,r7,lr} + stmfd sp!,{r4,r5,r6,r7} __cp_begin: ldr r0,[r0] cmp r0,#0 - blne __cp_cancel + bne __cp_cancel mov r7,r1 mov r0,r2 mov r1,r3 ldmfd ip,{r2,r3,r4,r5,r6} svc 0 __cp_end: - ldmfd sp!,{r4,r5,r6,r7,lr} + ldmfd sp!,{r4,r5,r6,r7} bx lr __cp_cancel: - ldmfd sp!,{r4,r5,r6,r7,lr} + ldmfd sp!,{r4,r5,r6,r7} b __cancel diff --git a/libc-top-half/musl/src/thread/pthread_create.c b/libc-top-half/musl/src/thread/pthread_create.c index ebf61de..5f49109 100644 --- a/libc-top-half/musl/src/thread/pthread_create.c +++ b/libc-top-half/musl/src/thread/pthread_create.c @@ -172,23 +172,20 @@ void __do_cleanup_pop(struct __ptcb *cb) struct start_args { void *(*start_func)(void *); void *start_arg; - pthread_attr_t *attr; - volatile int *perr; + volatile int control; unsigned long sig_mask[_NSIG/8/sizeof(long)]; }; static int start(void *p) { struct start_args *args = p; - if (args->attr) { - pthread_t self = __pthread_self(); - int ret = -__syscall(SYS_sched_setscheduler, self->tid, - args->attr->_a_policy, &args->attr->_a_prio); - if (a_swap(args->perr, ret)==-2) - __wake(args->perr, 1, 1); - if (ret) { - self->detach_state = DT_DETACHED; - __pthread_exit(0); + int state = args->control; + if (state) { + if (a_cas(&args->control, 1, 2)==1) + __wait(&args->control, 0, 2, 1); + if (args->control) { + __syscall(SYS_set_tid_address, &args->control); + for (;;) __syscall(SYS_exit, 0); } } __syscall(SYS_rt_sigprocmask, SIG_SETMASK, &args->sig_mask, 0, _NSIG/8); @@ -233,7 +230,6 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att | CLONE_PARENT_SETTID | CLONE_CHILD_CLEARTID | CLONE_DETACHED; pthread_attr_t attr = { 0 }; sigset_t set; - volatile int err = -1; if (!libc.can_do_threads) return ENOSYS; self = __pthread_self(); @@ -325,13 +321,7 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att struct start_args *args = (void *)stack; args->start_func = entry; args->start_arg = arg; - if (attr._a_sched) { - args->attr = &attr; - args->perr = &err; - } else { - args->attr = 0; - args->perr = 0; - } + args->control = attr._a_sched ? 1 : 0; /* Application signals (but not the synccall signal) must be * blocked before the thread list lock can be taken, to ensure @@ -349,29 +339,36 @@ int __pthread_create(pthread_t *restrict res, const pthread_attr_t *restrict att libc.threads_minus_1++; ret = __clone((c11 ? start_c11 : start), stack, flags, args, &new->tid, TP_ADJ(new), &__thread_list_lock); - /* If clone succeeded, new thread must be linked on the thread - * list before unlocking it, even if scheduling may still fail. */ + /* All clone failures translate to EAGAIN. If explicit scheduling + * was requested, attempt it before unlocking the thread list so + * that the failed thread is never exposed and so that we can + * clean up all transient resource usage before returning. */ + if (ret < 0) { + ret = -EAGAIN; + } else if (attr._a_sched) { + ret = __syscall(SYS_sched_setscheduler, + new->tid, attr._a_policy, &attr._a_prio); + if (a_swap(&args->control, ret ? 3 : 0)==2) + __wake(&args->control, 1, 1); + if (ret) + __wait(&args->control, 0, 3, 0); + } + if (ret >= 0) { new->next = self->next; new->prev = self; new->next->prev = new; new->prev->next = new; + } else { + libc.threads_minus_1--; } __tl_unlock(); __restore_sigs(&set); __release_ptc(); if (ret < 0) { - libc.threads_minus_1--; if (map) __munmap(map, size); - return EAGAIN; - } - - if (attr._a_sched) { - if (a_cas(&err, -1, -2)==-1) - __wait(&err, 0, -2, 1); - ret = err; - if (ret) return ret; + return -ret; } *res = new; diff --git a/libc-top-half/musl/src/thread/pthread_join.c b/libc-top-half/musl/src/thread/pthread_join.c index b8813e0..17dae85 100644 --- a/libc-top-half/musl/src/thread/pthread_join.c +++ b/libc-top-half/musl/src/thread/pthread_join.c @@ -1,3 +1,4 @@ +#define _GNU_SOURCE #include "pthread_impl.h" #include diff --git a/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c b/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c index 6b89362..9279fc5 100644 --- a/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c +++ b/libc-top-half/musl/src/thread/pthread_mutex_timedlock.c @@ -1,5 +1,23 @@ #include "pthread_impl.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + +static int __futex4(volatile void *addr, int op, int val, const struct timespec *to) +{ +#ifdef SYS_futex_time64 + time_t s = to ? to->tv_sec : 0; + long ns = to ? to->tv_nsec : 0; + int r = -ENOSYS; + if (SYS_futex == SYS_futex_time64 || !IS32BIT(s)) + r = __syscall(SYS_futex_time64, addr, op, val, + to ? ((long long[]){s, ns}) : 0); + if (SYS_futex == SYS_futex_time64 || r!=-ENOSYS) return r; + to = to ? (void *)(long[]){CLAMP(s), ns} : 0; +#endif + return __syscall(SYS_futex, addr, op, val, to); +} + static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct timespec *restrict at) { int type = m->_m_type; @@ -9,7 +27,7 @@ static int pthread_mutex_timedlock_pi(pthread_mutex_t *restrict m, const struct if (!priv) self->robust_list.pending = &m->_m_next; - do e = -__syscall(SYS_futex, &m->_m_lock, FUTEX_LOCK_PI|priv, 0, at); + do e = -__futex4(&m->_m_lock, FUTEX_LOCK_PI|priv, 0, at); while (e==EINTR); if (e) self->robust_list.pending = 0; diff --git a/libc-top-half/musl/src/thread/thrd_sleep.c b/libc-top-half/musl/src/thread/thrd_sleep.c index e8dfe40..97de534 100644 --- a/libc-top-half/musl/src/thread/thrd_sleep.c +++ b/libc-top-half/musl/src/thread/thrd_sleep.c @@ -1,10 +1,11 @@ #include +#include #include #include "syscall.h" int thrd_sleep(const struct timespec *req, struct timespec *rem) { - int ret = __syscall(SYS_nanosleep, req, rem); + int ret = -__clock_nanosleep(CLOCK_REALTIME, 0, req, rem); switch (ret) { case 0: return 0; case -EINTR: return -1; /* value specified by C11 */ diff --git a/libc-top-half/musl/src/thread/x32/syscall_cp.s b/libc-top-half/musl/src/thread/x32/syscall_cp.s index 9805af0..4f10171 100644 --- a/libc-top-half/musl/src/thread/x32/syscall_cp.s +++ b/libc-top-half/musl/src/thread/x32/syscall_cp.s @@ -6,10 +6,10 @@ .global __cp_cancel .hidden __cp_cancel .hidden __cancel -.global __syscall_cp_internal -.hidden __syscall_cp_internal -.type __syscall_cp_internal,@function -__syscall_cp_internal: +.global __syscall_cp_asm +.hidden __syscall_cp_asm +.type __syscall_cp_asm,@function +__syscall_cp_asm: __cp_begin: mov (%rdi),%eax diff --git a/libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c b/libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c deleted file mode 100644 index 4956610..0000000 --- a/libc-top-half/musl/src/thread/x32/syscall_cp_fixup.c +++ /dev/null @@ -1,39 +0,0 @@ -#include -#include - -hidden long __syscall_cp_internal(volatile void*, long long, long long, - long long, long long, long long, - long long, long long); - -struct __timespec { long long tv_sec; long tv_nsec; }; -struct __timespec_kernel { long long tv_sec; long long tv_nsec; }; -#define __tsc(X) ((struct __timespec*)(unsigned long)(X)) -#define __fixup(X) do { if(X) { \ - ts->tv_sec = __tsc(X)->tv_sec; \ - ts->tv_nsec = __tsc(X)->tv_nsec; \ - (X) = (unsigned long)ts; } } while(0) - -hidden long __syscall_cp_asm (volatile void * foo, long long n, long long a1, - long long a2, long long a3, long long a4, - long long a5, long long a6) -{ - struct __timespec_kernel ts[1]; - switch (n) { - case SYS_mq_timedsend: case SYS_mq_timedreceive: case SYS_pselect6: - __fixup(a5); - break; - case SYS_futex: - if((a2 & (~128 /* FUTEX_PRIVATE_FLAG */)) == 0 /* FUTEX_WAIT */) - __fixup(a4); - break; - case SYS_clock_nanosleep: - case SYS_rt_sigtimedwait: case SYS_ppoll: - __fixup(a3); - break; - case SYS_nanosleep: - __fixup(a1); - break; - } - return __syscall_cp_internal(foo, n, a1, a2, a3, a4, a5, a6); -} - diff --git a/libc-top-half/musl/src/time/clock_getres.c b/libc-top-half/musl/src/time/clock_getres.c index 36a0d69..81c6703 100644 --- a/libc-top-half/musl/src/time/clock_getres.c +++ b/libc-top-half/musl/src/time/clock_getres.c @@ -3,5 +3,19 @@ int clock_getres(clockid_t clk, struct timespec *ts) { +#ifdef SYS_clock_getres_time64 + /* On a 32-bit arch, use the old syscall if it exists. */ + if (SYS_clock_getres != SYS_clock_getres_time64) { + long ts32[2]; + int r = __syscall(SYS_clock_getres, clk, ts32); + if (!r && ts) { + ts->tv_sec = ts32[0]; + ts->tv_nsec = ts32[1]; + } + return __syscall_ret(r); + } +#endif + /* If reaching this point, it's a 64-bit arch or time64-only + * 32-bit arch and we can get result directly into timespec. */ return syscall(SYS_clock_getres, clk, ts); } diff --git a/libc-top-half/musl/src/time/clock_gettime.c b/libc-top-half/musl/src/time/clock_gettime.c index 8fd1b8f..3e1d097 100644 --- a/libc-top-half/musl/src/time/clock_gettime.c +++ b/libc-top-half/musl/src/time/clock_gettime.c @@ -8,9 +8,41 @@ static void *volatile vdso_func; +#ifdef VDSO_CGT32_SYM +static void *volatile vdso_func_32; +static int cgt_time32_wrap(clockid_t clk, struct timespec *ts) +{ + long ts32[2]; + int (*f)(clockid_t, long[2]) = + (int (*)(clockid_t, long[2]))vdso_func_32; + int r = f(clk, ts32); + if (!r) { + /* Fallback to syscalls if time32 overflowed. Maybe + * we lucked out and somehow migrated to a kernel with + * time64 syscalls available. */ + if (ts32[0] < 0) { + a_cas_p(&vdso_func, (void *)cgt_time32_wrap, 0); + return -ENOSYS; + } + ts->tv_sec = ts32[0]; + ts->tv_nsec = ts32[1]; + } + return r; +} +#endif + static int cgt_init(clockid_t clk, struct timespec *ts) { void *p = __vdsosym(VDSO_CGT_VER, VDSO_CGT_SYM); +#ifdef VDSO_CGT32_SYM + if (!p) { + void *q = __vdsosym(VDSO_CGT32_VER, VDSO_CGT32_SYM); + if (q) { + a_cas_p(&vdso_func_32, 0, q); + p = cgt_time32_wrap; + } + } +#endif int (*f)(clockid_t, struct timespec *) = (int (*)(clockid_t, struct timespec *))p; a_cas_p(&vdso_func, (void *)cgt_init, p); @@ -40,6 +72,25 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) } #endif +#ifdef SYS_clock_gettime64 + r = -ENOSYS; + if (sizeof(time_t) > 4) + r = __syscall(SYS_clock_gettime64, clk, ts); + if (SYS_clock_gettime == SYS_clock_gettime64 || r!=-ENOSYS) + return __syscall_ret(r); + long ts32[2]; + r = __syscall(SYS_clock_gettime, clk, ts32); + if (r==-ENOSYS && clk==CLOCK_REALTIME) { + r = __syscall(SYS_gettimeofday, ts32, 0); + ts32[1] *= 1000; + } + if (!r) { + ts->tv_sec = ts32[0]; + ts->tv_nsec = ts32[1]; + return r; + } + return __syscall_ret(r); +#else r = __syscall(SYS_clock_gettime, clk, ts); if (r == -ENOSYS) { if (clk == CLOCK_REALTIME) { @@ -50,6 +101,7 @@ int __clock_gettime(clockid_t clk, struct timespec *ts) r = -EINVAL; } return __syscall_ret(r); +#endif } weak_alias(__clock_gettime, clock_gettime); diff --git a/libc-top-half/musl/src/time/clock_nanosleep.c b/libc-top-half/musl/src/time/clock_nanosleep.c index 32f0c07..e195499 100644 --- a/libc-top-half/musl/src/time/clock_nanosleep.c +++ b/libc-top-half/musl/src/time/clock_nanosleep.c @@ -2,8 +2,37 @@ #include #include "syscall.h" -int clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem) +#define IS32BIT(x) !((x)+0x80000000ULL>>32) +#define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) + +int __clock_nanosleep(clockid_t clk, int flags, const struct timespec *req, struct timespec *rem) { - int r = -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); - return clk == CLOCK_THREAD_CPUTIME_ID ? EINVAL : r; + if (clk == CLOCK_THREAD_CPUTIME_ID) return EINVAL; +#ifdef SYS_clock_nanosleep_time64 + time_t s = req->tv_sec; + long ns = req->tv_nsec; + int r = -ENOSYS; + if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || !IS32BIT(s)) + r = __syscall_cp(SYS_clock_nanosleep_time64, clk, flags, + ((long long[]){s, ns}), rem); + if (SYS_clock_nanosleep == SYS_clock_nanosleep_time64 || r!=-ENOSYS) + return -r; + long long extra = s - CLAMP(s); + long ts32[2] = { CLAMP(s), ns }; + if (clk == CLOCK_REALTIME && !flags) + r = __syscall_cp(SYS_nanosleep, &ts32, &ts32); + else + r = __syscall_cp(SYS_clock_nanosleep, clk, flags, &ts32, &ts32); + if (r==-EINTR && rem && !(flags & TIMER_ABSTIME)) { + rem->tv_sec = ts32[0] + extra; + rem->tv_nsec = ts32[1]; + } + return -r; +#else + if (clk == CLOCK_REALTIME && !flags) + return -__syscall_cp(SYS_nanosleep, req, rem); + return -__syscall_cp(SYS_clock_nanosleep, clk, flags, req, rem); +#endif } + +weak_alias(__clock_nanosleep, clock_nanosleep); diff --git a/libc-top-half/musl/src/time/clock_settime.c b/libc-top-half/musl/src/time/clock_settime.c index 66b8162..1004ed1 100644 --- a/libc-top-half/musl/src/time/clock_settime.c +++ b/libc-top-half/musl/src/time/clock_settime.c @@ -1,7 +1,24 @@ #include +#include #include "syscall.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + int clock_settime(clockid_t clk, const struct timespec *ts) { +#ifdef SYS_clock_settime64 + time_t s = ts->tv_sec; + long ns = ts->tv_nsec; + int r = -ENOSYS; + if (SYS_clock_settime == SYS_clock_settime64 || !IS32BIT(s)) + r = __syscall(SYS_clock_settime64, clk, + ((long long[]){s, ns})); + if (SYS_clock_settime == SYS_clock_settime64 || r!=-ENOSYS) + return __syscall_ret(r); + if (!IS32BIT(s)) + return __syscall_ret(-ENOTSUP); + return syscall(SYS_clock_settime, clk, ((long[]){s, ns})); +#else return syscall(SYS_clock_settime, clk, ts); +#endif } diff --git a/libc-top-half/musl/src/time/nanosleep.c b/libc-top-half/musl/src/time/nanosleep.c index 1e6f392..bc9f789 100644 --- a/libc-top-half/musl/src/time/nanosleep.c +++ b/libc-top-half/musl/src/time/nanosleep.c @@ -3,5 +3,5 @@ int nanosleep(const struct timespec *req, struct timespec *rem) { - return syscall_cp(SYS_nanosleep, req, rem); + return __syscall_ret(-__clock_nanosleep(CLOCK_REALTIME, 0, req, rem)); } diff --git a/libc-top-half/musl/src/time/strftime.c b/libc-top-half/musl/src/time/strftime.c index cc53d53..a1db9cb 100644 --- a/libc-top-half/musl/src/time/strftime.c +++ b/libc-top-half/musl/src/time/strftime.c @@ -175,7 +175,11 @@ const char *__strftime_fmt_1(char (*s)[100], size_t *l, int f, const struct tm * *l = 0; return ""; } +#ifdef __wasilibc_unmodified_upstream // wasi-libc's __tm_gmtoff is an int *l = snprintf(*s, sizeof *s, "%+.4ld", +#else + *l = snprintf(*s, sizeof *s, "%+.4d", +#endif tm->__tm_gmtoff/3600*100 + tm->__tm_gmtoff%3600/60); return *s; case 'Z': diff --git a/libc-top-half/musl/src/time/timer_create.c b/libc-top-half/musl/src/time/timer_create.c index c5e40a1..455d49f 100644 --- a/libc-top-half/musl/src/time/timer_create.c +++ b/libc-top-half/musl/src/time/timer_create.c @@ -1,5 +1,6 @@ #include #include +#include #include "pthread_impl.h" struct ksigevent { @@ -48,7 +49,6 @@ static void *start(void *arg) { pthread_t self = __pthread_self(); struct start_args *args = arg; - int id = self->timer_id; jmp_buf jb; void (*notify)(union sigval) = args->sev->sigev_notify_function; @@ -65,7 +65,7 @@ static void *start(void *arg) } if (self->timer_id < 0) break; } - __syscall(SYS_timer_delete, id); + __syscall(SYS_timer_delete, self->timer_id & INT_MAX); return 0; } diff --git a/libc-top-half/musl/src/time/timer_gettime.c b/libc-top-half/musl/src/time/timer_gettime.c index ed6d8d6..21c9d32 100644 --- a/libc-top-half/musl/src/time/timer_gettime.c +++ b/libc-top-half/musl/src/time/timer_gettime.c @@ -8,5 +8,21 @@ int timer_gettime(timer_t t, struct itimerspec *val) pthread_t td = (void *)((uintptr_t)t << 1); t = (void *)(uintptr_t)(td->timer_id & INT_MAX); } +#ifdef SYS_timer_gettime64 + int r = -ENOSYS; + if (sizeof(time_t) > 4) + r = __syscall(SYS_timer_gettime64, t, val); + if (SYS_timer_gettime == SYS_timer_gettime64 || r!=-ENOSYS) + return __syscall_ret(r); + long val32[4]; + r = __syscall(SYS_timer_gettime, t, val32); + if (!r) { + val->it_interval.tv_sec = val32[0]; + val->it_interval.tv_nsec = val32[1]; + val->it_value.tv_sec = val32[2]; + val->it_value.tv_nsec = val32[3]; + } + return __syscall_ret(r); +#endif return syscall(SYS_timer_gettime, t, val); } diff --git a/libc-top-half/musl/src/time/timer_settime.c b/libc-top-half/musl/src/time/timer_settime.c index 62631aa..373f00c 100644 --- a/libc-top-half/musl/src/time/timer_settime.c +++ b/libc-top-half/musl/src/time/timer_settime.c @@ -2,11 +2,36 @@ #include #include "pthread_impl.h" +#define IS32BIT(x) !((x)+0x80000000ULL>>32) + int timer_settime(timer_t t, int flags, const struct itimerspec *restrict val, struct itimerspec *restrict old) { if ((intptr_t)t < 0) { pthread_t td = (void *)((uintptr_t)t << 1); t = (void *)(uintptr_t)(td->timer_id & INT_MAX); } +#ifdef SYS_timer_settime64 + time_t is = val->it_interval.tv_sec, vs = val->it_value.tv_sec; + long ins = val->it_interval.tv_nsec, vns = val->it_value.tv_nsec; + int r = -ENOSYS; + if (SYS_timer_settime == SYS_timer_settime64 + || !IS32BIT(is) || !IS32BIT(vs) || (sizeof(time_t)>4 && old)) + r = __syscall(SYS_timer_settime64, t, flags, + ((long long[]){is, ins, vs, vns}), old); + if (SYS_timer_settime == SYS_timer_settime64 || r!=-ENOSYS) + return __syscall_ret(r); + if (!IS32BIT(is) || !IS32BIT(vs)) + return __syscall_ret(-ENOTSUP); + long old32[4]; + r = __syscall(SYS_timer_settime, t, flags, + ((long[]){is, ins, vs, vns}), old32); + if (!r && old) { + old->it_interval.tv_sec = old32[0]; + old->it_interval.tv_nsec = old32[1]; + old->it_value.tv_sec = old32[2]; + old->it_value.tv_nsec = old32[3]; + } + return __syscall_ret(r); +#endif return syscall(SYS_timer_settime, t, flags, val, old); } diff --git a/libc-top-half/musl/src/unistd/alarm.c b/libc-top-half/musl/src/unistd/alarm.c index 2e3263a..a5e0c82 100644 --- a/libc-top-half/musl/src/unistd/alarm.c +++ b/libc-top-half/musl/src/unistd/alarm.c @@ -4,7 +4,7 @@ unsigned alarm(unsigned seconds) { - struct itimerval it = { .it_value.tv_sec = seconds }; - __syscall(SYS_setitimer, ITIMER_REAL, &it, &it); - return it.it_value.tv_sec + !!it.it_value.tv_usec; + struct itimerval it = { .it_value.tv_sec = seconds }, old = { 0 }; + setitimer(ITIMER_REAL, &it, &old); + return old.it_value.tv_sec + !!old.it_value.tv_usec; } diff --git a/libc-top-half/musl/src/unistd/lseek.c b/libc-top-half/musl/src/unistd/lseek.c index bf8cd85..48a638a 100644 --- a/libc-top-half/musl/src/unistd/lseek.c +++ b/libc-top-half/musl/src/unistd/lseek.c @@ -1,14 +1,23 @@ #include #include "syscall.h" -off_t lseek(int fd, off_t offset, int whence) +off_t __lseek(int fd, off_t offset, int whence) { #ifdef SYS__llseek off_t result; +#ifdef __wasilibc_unmodified_upstream // WASI has no syscall return syscall(SYS__llseek, fd, offset>>32, offset, &result, whence) ? -1 : result; #else + return llseek(fd, offset>>32, offset, &result, whence) ? -1 : result; +#endif +#else +#ifdef __wasilibc_unmodified_upstream // WASI has no syscall return syscall(SYS_lseek, fd, offset, whence); +#else + return lseek(fd, offset, whence); +#endif #endif } -weak_alias(lseek, lseek64); +weak_alias(__lseek, lseek); +weak_alias(__lseek, lseek64); diff --git a/libc-top-half/musl/src/unistd/mipsn32/lseek.c b/libc-top-half/musl/src/unistd/mipsn32/lseek.c new file mode 100644 index 0000000..60e74a5 --- /dev/null +++ b/libc-top-half/musl/src/unistd/mipsn32/lseek.c @@ -0,0 +1,20 @@ +#include +#include "syscall.h" + +off_t __lseek(int fd, off_t offset, int whence) +{ + register long long r4 __asm__("$4") = fd; + register long long r5 __asm__("$5") = offset; + register long long r6 __asm__("$6") = whence; + register long long r7 __asm__("$7"); + register long long r2 __asm__("$2") = SYS_lseek; + __asm__ __volatile__ ( + "syscall" + : "+&r"(r2), "=r"(r7) + : "r"(r4), "r"(r5), "r"(r6) + : SYSCALL_CLOBBERLIST); + return r7 ? __syscall_ret(-r2) : r2; +} + +weak_alias(__lseek, lseek); +weak_alias(__lseek, lseek64); diff --git a/libc-top-half/musl/src/unistd/x32/lseek.c b/libc-top-half/musl/src/unistd/x32/lseek.c new file mode 100644 index 0000000..3263642 --- /dev/null +++ b/libc-top-half/musl/src/unistd/x32/lseek.c @@ -0,0 +1,15 @@ +#include +#include "syscall.h" + +off_t __lseek(int fd, off_t offset, int whence) +{ + off_t ret; + __asm__ __volatile__ ("syscall" + : "=a"(ret) + : "a"(SYS_lseek), "D"(fd), "S"(offset), "d"(whence) + : "rcx", "r11", "memory"); + return ret < 0 ? __syscall_ret(ret) : ret; +} + +weak_alias(__lseek, lseek); +weak_alias(__lseek, lseek64); From 575e1579a4ebaa6dccb884ca657188a92982af23 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Wed, 26 Feb 2020 08:56:59 -0800 Subject: [PATCH 24/30] Update to musl 1.2.0. See the WHATSNEW file for details. The biggest change in musl is the switch to 64-bit time_t for 32-bit targets, however WASI libc was already using 64-bit time_t. The main change affecting WASI is an update to Unicode 12.1.0. --- expected/wasm32-wasi/predefined-macros.txt | 20 +- libc-top-half/musl/.mailmap | 1 + libc-top-half/musl/COPYRIGHT | 4 +- libc-top-half/musl/Makefile | 5 +- libc-top-half/musl/VERSION | 2 +- libc-top-half/musl/WHATSNEW | 36 ++ .../musl/arch/aarch64/bits/alltypes.h.in | 20 +- libc-top-half/musl/arch/aarch64/bits/endian.h | 5 - libc-top-half/musl/arch/aarch64/bits/limits.h | 7 - libc-top-half/musl/arch/aarch64/bits/socket.h | 33 -- .../musl/arch/aarch64/bits/syscall.h.in | 2 + libc-top-half/musl/arch/aarch64/reloc.h | 2 - libc-top-half/musl/arch/arm/arch.mak | 1 + .../musl/arch/arm/bits/alltypes.h.in | 21 +- libc-top-half/musl/arch/arm/bits/endian.h | 5 - libc-top-half/musl/arch/arm/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/arm/bits/limits.h | 7 - libc-top-half/musl/arch/arm/bits/msg.h | 15 +- libc-top-half/musl/arch/arm/bits/sem.h | 10 +- libc-top-half/musl/arch/arm/bits/shm.h | 16 +- libc-top-half/musl/arch/arm/bits/stat.h | 6 +- libc-top-half/musl/arch/arm/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/arm/reloc.h | 2 - libc-top-half/musl/arch/arm/syscall_arch.h | 4 +- libc-top-half/musl/arch/generic/bits/dirent.h | 11 + libc-top-half/musl/arch/generic/bits/ioctl.h | 5 + libc-top-half/musl/arch/generic/bits/limits.h | 0 libc-top-half/musl/arch/generic/bits/socket.h | 15 - libc-top-half/musl/arch/i386/arch.mak | 1 + .../musl/arch/i386/bits/alltypes.h.in | 21 +- libc-top-half/musl/arch/i386/bits/endian.h | 1 - libc-top-half/musl/arch/i386/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/i386/bits/limits.h | 7 - libc-top-half/musl/arch/i386/bits/msg.h | 15 +- libc-top-half/musl/arch/i386/bits/sem.h | 10 +- libc-top-half/musl/arch/i386/bits/shm.h | 16 +- libc-top-half/musl/arch/i386/bits/stat.h | 6 +- .../musl/arch/i386/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/i386/syscall_arch.h | 4 +- libc-top-half/musl/arch/m68k/arch.mak | 1 + .../musl/arch/m68k/bits/alltypes.h.in | 16 +- libc-top-half/musl/arch/m68k/bits/endian.h | 1 - libc-top-half/musl/arch/m68k/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/m68k/bits/limits.h | 7 - libc-top-half/musl/arch/m68k/bits/msg.h | 15 +- libc-top-half/musl/arch/m68k/bits/sem.h | 10 +- libc-top-half/musl/arch/m68k/bits/shm.h | 16 +- libc-top-half/musl/arch/m68k/bits/stat.h | 6 +- .../musl/arch/m68k/bits/syscall.h.in | 21 +- libc-top-half/musl/arch/m68k/bits/user.h | 5 + libc-top-half/musl/arch/microblaze/arch.mak | 1 + .../musl/arch/microblaze/bits/alltypes.h.in | 21 +- .../musl/arch/microblaze/bits/endian.h | 5 - .../musl/arch/microblaze/bits/ipcstat.h | 2 +- .../musl/arch/microblaze/bits/limits.h | 7 - libc-top-half/musl/arch/microblaze/bits/msg.h | 15 +- libc-top-half/musl/arch/microblaze/bits/sem.h | 10 +- libc-top-half/musl/arch/microblaze/bits/shm.h | 16 +- .../musl/arch/microblaze/bits/stat.h | 6 +- .../musl/arch/microblaze/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/microblaze/reloc.h | 2 - libc-top-half/musl/arch/mips/arch.mak | 1 + .../musl/arch/mips/bits/alltypes.h.in | 21 +- libc-top-half/musl/arch/mips/bits/endian.h | 5 - libc-top-half/musl/arch/mips/bits/hwcap.h | 11 + libc-top-half/musl/arch/mips/bits/ioctl.h | 4 +- libc-top-half/musl/arch/mips/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/mips/bits/limits.h | 7 - libc-top-half/musl/arch/mips/bits/msg.h | 27 +- libc-top-half/musl/arch/mips/bits/sem.h | 10 +- libc-top-half/musl/arch/mips/bits/shm.h | 15 +- libc-top-half/musl/arch/mips/bits/signal.h | 8 +- libc-top-half/musl/arch/mips/bits/socket.h | 18 - libc-top-half/musl/arch/mips/bits/stat.h | 12 +- .../musl/arch/mips/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/mips/reloc.h | 2 - libc-top-half/musl/arch/mips/syscall_arch.h | 4 +- .../musl/arch/mips64/bits/alltypes.h.in | 20 +- libc-top-half/musl/arch/mips64/bits/endian.h | 5 - libc-top-half/musl/arch/mips64/bits/limits.h | 7 - libc-top-half/musl/arch/mips64/bits/socket.h | 34 -- .../musl/arch/mips64/bits/syscall.h.in | 2 + libc-top-half/musl/arch/mips64/reloc.h | 10 +- libc-top-half/musl/arch/mipsn32/arch.mak | 1 + .../musl/arch/mipsn32/bits/alltypes.h.in | 21 +- libc-top-half/musl/arch/mipsn32/bits/endian.h | 5 - libc-top-half/musl/arch/mipsn32/bits/ioctl.h | 4 +- .../musl/arch/mipsn32/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/mipsn32/bits/limits.h | 7 - libc-top-half/musl/arch/mipsn32/bits/msg.h | 27 +- libc-top-half/musl/arch/mipsn32/bits/sem.h | 10 +- libc-top-half/musl/arch/mipsn32/bits/shm.h | 15 +- libc-top-half/musl/arch/mipsn32/bits/socket.h | 18 - libc-top-half/musl/arch/mipsn32/bits/stat.h | 12 +- .../musl/arch/mipsn32/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/mipsn32/reloc.h | 2 - .../musl/arch/mipsn32/syscall_arch.h | 4 +- libc-top-half/musl/arch/or1k/arch.mak | 1 + .../musl/arch/or1k/bits/alltypes.h.in | 16 +- libc-top-half/musl/arch/or1k/bits/endian.h | 1 - libc-top-half/musl/arch/or1k/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/or1k/bits/limits.h | 7 - libc-top-half/musl/arch/or1k/bits/msg.h | 15 +- libc-top-half/musl/arch/or1k/bits/sem.h | 10 +- libc-top-half/musl/arch/or1k/bits/shm.h | 16 +- libc-top-half/musl/arch/or1k/bits/stat.h | 10 +- .../musl/arch/or1k/bits/syscall.h.in | 22 +- libc-top-half/musl/arch/powerpc/arch.mak | 1 + .../musl/arch/powerpc/bits/alltypes.h.in | 16 +- libc-top-half/musl/arch/powerpc/bits/endian.h | 15 - libc-top-half/musl/arch/powerpc/bits/ioctl.h | 4 +- .../musl/arch/powerpc/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/powerpc/bits/limits.h | 7 - libc-top-half/musl/arch/powerpc/bits/msg.h | 15 +- libc-top-half/musl/arch/powerpc/bits/sem.h | 10 +- libc-top-half/musl/arch/powerpc/bits/shm.h | 16 +- libc-top-half/musl/arch/powerpc/bits/signal.h | 2 +- libc-top-half/musl/arch/powerpc/bits/socket.h | 18 - libc-top-half/musl/arch/powerpc/bits/stat.h | 6 +- .../musl/arch/powerpc/bits/syscall.h.in | 22 +- .../musl/arch/powerpc64/bits/alltypes.h.in | 20 +- .../musl/arch/powerpc64/bits/endian.h | 5 - .../musl/arch/powerpc64/bits/limits.h | 7 - .../musl/arch/powerpc64/bits/signal.h | 8 +- .../musl/arch/powerpc64/bits/socket.h | 34 -- .../musl/arch/powerpc64/bits/syscall.h.in | 2 + libc-top-half/musl/arch/powerpc64/reloc.h | 2 - libc-top-half/musl/arch/riscv64/atomic_arch.h | 2 +- .../musl/arch/riscv64/bits/alltypes.h.in | 15 +- libc-top-half/musl/arch/riscv64/bits/endian.h | 1 - libc-top-half/musl/arch/riscv64/bits/limits.h | 7 - libc-top-half/musl/arch/riscv64/bits/reg.h | 6 - libc-top-half/musl/arch/riscv64/bits/signal.h | 9 + libc-top-half/musl/arch/riscv64/bits/socket.h | 19 - .../musl/arch/riscv64/bits/syscall.h.in | 2 + .../musl/arch/s390x/bits/alltypes.h.in | 15 +- libc-top-half/musl/arch/s390x/bits/endian.h | 1 - libc-top-half/musl/arch/s390x/bits/limits.h | 7 - libc-top-half/musl/arch/s390x/bits/socket.h | 17 - .../musl/arch/s390x/bits/syscall.h.in | 2 + libc-top-half/musl/arch/s390x/reloc.h | 2 - libc-top-half/musl/arch/sh/arch.mak | 1 + libc-top-half/musl/arch/sh/bits/alltypes.h.in | 21 +- libc-top-half/musl/arch/sh/bits/endian.h | 5 - libc-top-half/musl/arch/sh/bits/ioctl.h | 4 +- libc-top-half/musl/arch/sh/bits/ipcstat.h | 2 +- libc-top-half/musl/arch/sh/bits/limits.h | 7 - libc-top-half/musl/arch/sh/bits/msg.h | 15 +- libc-top-half/musl/arch/sh/bits/sem.h | 10 +- libc-top-half/musl/arch/sh/bits/shm.h | 16 +- libc-top-half/musl/arch/sh/bits/stat.h | 6 +- libc-top-half/musl/arch/sh/bits/syscall.h.in | 21 +- libc-top-half/musl/arch/sh/reloc.h | 2 - .../musl/arch/wasm32/bits/alltypes.h.in | 20 +- libc-top-half/musl/arch/wasm32/bits/dirent.h | 1 + libc-top-half/musl/arch/wasm32/bits/endian.h | 1 - libc-top-half/musl/arch/wasm32/bits/limits.h | 7 - libc-top-half/musl/arch/wasm32/bits/socket.h | 1 - .../musl/arch/x32/bits/alltypes.h.in | 15 +- libc-top-half/musl/arch/x32/bits/endian.h | 1 - libc-top-half/musl/arch/x32/bits/ioctl_fix.h | 4 + libc-top-half/musl/arch/x32/bits/limits.h | 7 - libc-top-half/musl/arch/x32/bits/socket.h | 21 +- libc-top-half/musl/arch/x32/bits/syscall.h.in | 3 + libc-top-half/musl/arch/x32/syscall_arch.h | 2 + .../musl/arch/x86_64/bits/alltypes.h.in | 15 +- libc-top-half/musl/arch/x86_64/bits/endian.h | 1 - libc-top-half/musl/arch/x86_64/bits/limits.h | 7 - libc-top-half/musl/arch/x86_64/bits/socket.h | 16 - .../musl/arch/x86_64/bits/syscall.h.in | 2 + libc-top-half/musl/compat/time32/__xstat.c | 24 ++ libc-top-half/musl/compat/time32/adjtime32.c | 21 ++ .../musl/compat/time32/adjtimex_time32.c | 10 + .../musl/compat/time32/aio_suspend_time32.c | 11 + .../musl/compat/time32/clock_adjtime32.c | 70 ++++ .../musl/compat/time32/clock_getres_time32.c | 13 + .../musl/compat/time32/clock_gettime32.c | 18 + .../compat/time32/clock_nanosleep_time32.c | 15 + .../musl/compat/time32/clock_settime32.c | 9 + .../musl/compat/time32/cnd_timedwait_time32.c | 9 + libc-top-half/musl/compat/time32/ctime32.c | 7 + libc-top-half/musl/compat/time32/ctime32_r.c | 7 + libc-top-half/musl/compat/time32/difftime32.c | 7 + .../musl/compat/time32/fstat_time32.c | 17 + .../musl/compat/time32/fstatat_time32.c | 17 + libc-top-half/musl/compat/time32/ftime32.c | 25 ++ .../musl/compat/time32/futimens_time32.c | 10 + .../musl/compat/time32/futimes_time32.c | 12 + .../musl/compat/time32/futimesat_time32.c | 12 + .../musl/compat/time32/getitimer_time32.c | 15 + .../musl/compat/time32/getrusage_time32.c | 39 ++ .../musl/compat/time32/gettimeofday_time32.c | 19 + libc-top-half/musl/compat/time32/gmtime32.c | 7 + libc-top-half/musl/compat/time32/gmtime32_r.c | 7 + .../musl/compat/time32/localtime32.c | 7 + .../musl/compat/time32/localtime32_r.c | 7 + .../musl/compat/time32/lstat_time32.c | 17 + .../musl/compat/time32/lutimes_time32.c | 12 + libc-top-half/musl/compat/time32/mktime32.c | 16 + .../compat/time32/mq_timedreceive_time32.c | 9 + .../musl/compat/time32/mq_timedsend_time32.c | 9 + .../musl/compat/time32/mtx_timedlock_time32.c | 9 + .../musl/compat/time32/nanosleep_time32.c | 15 + .../musl/compat/time32/ppoll_time32.c | 10 + .../musl/compat/time32/pselect_time32.c | 9 + .../time32/pthread_cond_timedwait_time32.c | 9 + .../time32/pthread_mutex_timedlock_time32.c | 9 + .../pthread_rwlock_timedrdlock_time32.c | 9 + .../pthread_rwlock_timedwrlock_time32.c | 9 + .../time32/pthread_timedjoin_np_time32.c | 10 + .../musl/compat/time32/recvmmsg_time32.c | 10 + .../time32/sched_rr_get_interval_time32.c | 13 + .../musl/compat/time32/select_time32.c | 10 + .../musl/compat/time32/sem_timedwait_time32.c | 9 + .../musl/compat/time32/semtimedop_time32.c | 10 + .../musl/compat/time32/setitimer_time32.c | 25 ++ .../musl/compat/time32/settimeofday_time32.c | 10 + .../musl/compat/time32/sigtimedwait_time32.c | 9 + .../musl/compat/time32/stat_time32.c | 17 + libc-top-half/musl/compat/time32/stime32.c | 8 + .../musl/compat/time32/thrd_sleep_time32.c | 16 + libc-top-half/musl/compat/time32/time32.c | 15 + libc-top-half/musl/compat/time32/time32.h | 91 +++++ libc-top-half/musl/compat/time32/time32gm.c | 15 + .../musl/compat/time32/timer_gettime32.c | 15 + .../musl/compat/time32/timer_settime32.c | 25 ++ .../musl/compat/time32/timerfd_gettime32.c | 16 + .../musl/compat/time32/timerfd_settime32.c | 26 ++ .../musl/compat/time32/timespec_get_time32.c | 18 + .../musl/compat/time32/utime_time32.c | 14 + .../musl/compat/time32/utimensat_time32.c | 11 + .../musl/compat/time32/utimes_time32.c | 11 + .../musl/compat/time32/wait3_time32.c | 40 ++ .../musl/compat/time32/wait4_time32.c | 40 ++ libc-top-half/musl/configure | 9 + libc-top-half/musl/include/aio.h | 4 + libc-top-half/musl/include/alloca.h | 2 - libc-top-half/musl/include/alltypes.h.in | 31 +- libc-top-half/musl/include/arpa/nameser.h | 1 - libc-top-half/musl/include/dirent.h | 18 +- libc-top-half/musl/include/dlfcn.h | 4 + libc-top-half/musl/include/endian.h | 46 ++- libc-top-half/musl/include/features.h | 2 + libc-top-half/musl/include/limits.h | 18 +- libc-top-half/musl/include/mqueue.h | 5 + libc-top-half/musl/include/netinet/icmp6.h | 1 - libc-top-half/musl/include/netinet/if_ether.h | 1 + libc-top-half/musl/include/netinet/ip.h | 3 +- libc-top-half/musl/include/netinet/ip6.h | 1 - libc-top-half/musl/include/netinet/tcp.h | 4 +- libc-top-half/musl/include/poll.h | 6 + libc-top-half/musl/include/pthread.h | 10 + libc-top-half/musl/include/sched.h | 8 + libc-top-half/musl/include/semaphore.h | 4 + libc-top-half/musl/include/signal.h | 8 + libc-top-half/musl/include/sys/acct.h | 1 - libc-top-half/musl/include/sys/ioctl.h | 1 + libc-top-half/musl/include/sys/mman.h | 2 + libc-top-half/musl/include/sys/prctl.h | 4 + libc-top-half/musl/include/sys/procfs.h | 7 +- libc-top-half/musl/include/sys/ptrace.h | 29 ++ libc-top-half/musl/include/sys/resource.h | 7 +- libc-top-half/musl/include/sys/select.h | 5 + libc-top-half/musl/include/sys/sem.h | 8 +- libc-top-half/musl/include/sys/socket.h | 73 +++- libc-top-half/musl/include/sys/stat.h | 9 + libc-top-half/musl/include/sys/statvfs.h | 2 - libc-top-half/musl/include/sys/time.h | 14 + libc-top-half/musl/include/sys/timeb.h | 6 + libc-top-half/musl/include/sys/timerfd.h | 5 + libc-top-half/musl/include/sys/timex.h | 5 + libc-top-half/musl/include/sys/ttydefaults.h | 7 +- libc-top-half/musl/include/sys/wait.h | 10 +- libc-top-half/musl/include/threads.h | 6 + libc-top-half/musl/include/time.h | 28 ++ libc-top-half/musl/include/utime.h | 6 + libc-top-half/musl/include/utmpx.h | 7 +- libc-top-half/musl/ldso/dynlink.c | 65 +++- libc-top-half/musl/src/aio/aio_suspend.c | 2 + libc-top-half/musl/src/complex/cacosh.c | 5 +- libc-top-half/musl/src/complex/cacoshf.c | 5 +- libc-top-half/musl/src/complex/cacoshl.c | 5 +- libc-top-half/musl/src/complex/catanf.c | 14 +- libc-top-half/musl/src/complex/catanl.c | 14 +- libc-top-half/musl/src/ctype/alpha.h | 159 ++++---- libc-top-half/musl/src/ctype/casemap.h | 297 +++++++++++++++ libc-top-half/musl/src/ctype/nonspacing.h | 90 ++--- libc-top-half/musl/src/ctype/punct.h | 162 ++++---- libc-top-half/musl/src/ctype/towctrans.c | 348 +++--------------- libc-top-half/musl/src/ctype/wcwidth.c | 2 +- libc-top-half/musl/src/ctype/wide.h | 26 +- libc-top-half/musl/src/fenv/riscv64/fenv.S | 5 +- libc-top-half/musl/src/internal/dynlink.h | 1 - libc-top-half/musl/src/internal/floatscan.c | 5 +- libc-top-half/musl/src/internal/syscall.h | 46 +++ libc-top-half/musl/src/ldso/__dlsym.c | 4 + .../musl/src/ldso/arm/dlsym_time64.S | 3 + .../musl/src/ldso/i386/dlsym_time64.S | 3 + .../musl/src/ldso/m68k/dlsym_time64.S | 3 + .../musl/src/ldso/microblaze/dlsym_time64.S | 3 + .../musl/src/ldso/mips/dlsym_time64.S | 3 + .../musl/src/ldso/mipsn32/dlsym_time64.S | 3 + .../musl/src/ldso/or1k/dlsym_time64.S | 3 + .../musl/src/ldso/powerpc/dlsym_time64.S | 3 + libc-top-half/musl/src/ldso/sh/dlsym_time64.S | 3 + libc-top-half/musl/src/linux/clock_adjtime.c | 57 ++- libc-top-half/musl/src/linux/wait4.c | 34 +- libc-top-half/musl/src/math/i386/acos.s | 16 +- libc-top-half/musl/src/math/i386/acosf.s | 17 +- libc-top-half/musl/src/math/i386/acosl.s | 15 +- libc-top-half/musl/src/math/i386/asin.s | 32 +- libc-top-half/musl/src/math/i386/asinf.s | 24 +- libc-top-half/musl/src/math/i386/asinl.s | 13 +- libc-top-half/musl/src/math/i386/atan.s | 2 + libc-top-half/musl/src/math/i386/atan2.s | 3 +- libc-top-half/musl/src/math/i386/atan2f.s | 3 +- libc-top-half/musl/src/math/i386/atanf.s | 2 + libc-top-half/musl/src/math/i386/exp2.s | 1 - libc-top-half/musl/src/math/i386/exp2f.s | 1 - libc-top-half/musl/src/math/i386/exp2l.s | 2 +- .../musl/src/math/i386/{exp.s => exp_ld.s} | 55 +-- libc-top-half/musl/src/math/i386/expf.s | 1 - libc-top-half/musl/src/math/i386/expm1.s | 1 - libc-top-half/musl/src/math/i386/expm1f.s | 1 - libc-top-half/musl/src/math/i386/expm1l.s | 2 +- libc-top-half/musl/src/math/i386/log.s | 2 + libc-top-half/musl/src/math/i386/log10.s | 2 + libc-top-half/musl/src/math/i386/log10f.s | 2 + libc-top-half/musl/src/math/i386/log1p.s | 4 + libc-top-half/musl/src/math/i386/log1pf.s | 4 + libc-top-half/musl/src/math/i386/log2.s | 2 + libc-top-half/musl/src/math/i386/log2f.s | 2 + libc-top-half/musl/src/math/i386/logf.s | 2 + libc-top-half/musl/src/math/mips/fabs.c | 16 + libc-top-half/musl/src/math/mips/fabsf.c | 16 + libc-top-half/musl/src/math/mips/sqrt.c | 16 + libc-top-half/musl/src/math/mips/sqrtf.c | 16 + libc-top-half/musl/src/math/powerpc/fabs.c | 2 +- libc-top-half/musl/src/math/powerpc/fma.c | 2 +- libc-top-half/musl/src/math/x32/lrintl.s | 4 +- libc-top-half/musl/src/misc/getrusage.c | 30 +- libc-top-half/musl/src/misc/ioctl.c | 136 ++++++- libc-top-half/musl/src/misc/pty.c | 4 +- libc-top-half/musl/src/network/getsockopt.c | 9 + libc-top-half/musl/src/network/recvmmsg.c | 14 +- libc-top-half/musl/src/network/recvmsg.c | 47 +++ libc-top-half/musl/src/network/setsockopt.c | 9 + libc-top-half/musl/src/signal/arm/sigsetjmp.s | 5 +- libc-top-half/musl/src/stat/__xstat.c | 4 + libc-top-half/musl/src/stat/fchmodat.c | 3 +- libc-top-half/musl/src/stat/fstat.c | 2 + libc-top-half/musl/src/stat/fstatat.c | 18 + libc-top-half/musl/src/stat/lstat.c | 2 + libc-top-half/musl/src/stat/stat.c | 2 + libc-top-half/musl/src/stdio/tempnam.c | 5 +- libc-top-half/musl/src/stdio/tmpnam.c | 5 +- libc-top-half/musl/src/stdio/ungetc.c | 2 +- libc-top-half/musl/src/string/arm/memcpy.c | 2 +- libc-top-half/musl/src/string/arm/memcpy_le.S | 13 +- libc-top-half/musl/src/time/__map_file.c | 3 +- libc-top-half/musl/tools/add-cfi.i386.awk | 2 +- libc-top-half/musl/tools/add-cfi.x86_64.awk | 2 +- 362 files changed, 3314 insertions(+), 1769 deletions(-) create mode 100644 libc-top-half/musl/.mailmap delete mode 100644 libc-top-half/musl/arch/aarch64/bits/endian.h delete mode 100644 libc-top-half/musl/arch/aarch64/bits/limits.h delete mode 100644 libc-top-half/musl/arch/aarch64/bits/socket.h create mode 100644 libc-top-half/musl/arch/arm/arch.mak delete mode 100644 libc-top-half/musl/arch/arm/bits/endian.h delete mode 100644 libc-top-half/musl/arch/arm/bits/limits.h create mode 100644 libc-top-half/musl/arch/generic/bits/dirent.h create mode 100644 libc-top-half/musl/arch/generic/bits/limits.h create mode 100644 libc-top-half/musl/arch/i386/arch.mak delete mode 100644 libc-top-half/musl/arch/i386/bits/endian.h create mode 100644 libc-top-half/musl/arch/m68k/arch.mak delete mode 100644 libc-top-half/musl/arch/m68k/bits/endian.h delete mode 100644 libc-top-half/musl/arch/m68k/bits/limits.h create mode 100644 libc-top-half/musl/arch/microblaze/arch.mak delete mode 100644 libc-top-half/musl/arch/microblaze/bits/endian.h delete mode 100644 libc-top-half/musl/arch/microblaze/bits/limits.h create mode 100644 libc-top-half/musl/arch/mips/arch.mak delete mode 100644 libc-top-half/musl/arch/mips/bits/endian.h delete mode 100644 libc-top-half/musl/arch/mips/bits/limits.h delete mode 100644 libc-top-half/musl/arch/mips64/bits/endian.h delete mode 100644 libc-top-half/musl/arch/mips64/bits/limits.h create mode 100644 libc-top-half/musl/arch/mipsn32/arch.mak delete mode 100644 libc-top-half/musl/arch/mipsn32/bits/endian.h delete mode 100644 libc-top-half/musl/arch/mipsn32/bits/limits.h create mode 100644 libc-top-half/musl/arch/or1k/arch.mak delete mode 100644 libc-top-half/musl/arch/or1k/bits/endian.h create mode 100644 libc-top-half/musl/arch/powerpc/arch.mak delete mode 100644 libc-top-half/musl/arch/powerpc/bits/endian.h delete mode 100644 libc-top-half/musl/arch/powerpc/bits/limits.h delete mode 100644 libc-top-half/musl/arch/powerpc64/bits/endian.h delete mode 100644 libc-top-half/musl/arch/powerpc64/bits/limits.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/endian.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/limits.h delete mode 100644 libc-top-half/musl/arch/riscv64/bits/socket.h delete mode 100644 libc-top-half/musl/arch/s390x/bits/endian.h delete mode 100644 libc-top-half/musl/arch/s390x/bits/socket.h create mode 100644 libc-top-half/musl/arch/sh/arch.mak delete mode 100644 libc-top-half/musl/arch/sh/bits/endian.h create mode 100644 libc-top-half/musl/arch/wasm32/bits/dirent.h delete mode 100644 libc-top-half/musl/arch/wasm32/bits/endian.h delete mode 100644 libc-top-half/musl/arch/wasm32/bits/socket.h delete mode 100644 libc-top-half/musl/arch/x32/bits/endian.h create mode 100644 libc-top-half/musl/arch/x32/bits/ioctl_fix.h delete mode 100644 libc-top-half/musl/arch/x86_64/bits/endian.h delete mode 100644 libc-top-half/musl/arch/x86_64/bits/socket.h create mode 100644 libc-top-half/musl/compat/time32/__xstat.c create mode 100644 libc-top-half/musl/compat/time32/adjtime32.c create mode 100644 libc-top-half/musl/compat/time32/adjtimex_time32.c create mode 100644 libc-top-half/musl/compat/time32/aio_suspend_time32.c create mode 100644 libc-top-half/musl/compat/time32/clock_adjtime32.c create mode 100644 libc-top-half/musl/compat/time32/clock_getres_time32.c create mode 100644 libc-top-half/musl/compat/time32/clock_gettime32.c create mode 100644 libc-top-half/musl/compat/time32/clock_nanosleep_time32.c create mode 100644 libc-top-half/musl/compat/time32/clock_settime32.c create mode 100644 libc-top-half/musl/compat/time32/cnd_timedwait_time32.c create mode 100644 libc-top-half/musl/compat/time32/ctime32.c create mode 100644 libc-top-half/musl/compat/time32/ctime32_r.c create mode 100644 libc-top-half/musl/compat/time32/difftime32.c create mode 100644 libc-top-half/musl/compat/time32/fstat_time32.c create mode 100644 libc-top-half/musl/compat/time32/fstatat_time32.c create mode 100644 libc-top-half/musl/compat/time32/ftime32.c create mode 100644 libc-top-half/musl/compat/time32/futimens_time32.c create mode 100644 libc-top-half/musl/compat/time32/futimes_time32.c create mode 100644 libc-top-half/musl/compat/time32/futimesat_time32.c create mode 100644 libc-top-half/musl/compat/time32/getitimer_time32.c create mode 100644 libc-top-half/musl/compat/time32/getrusage_time32.c create mode 100644 libc-top-half/musl/compat/time32/gettimeofday_time32.c create mode 100644 libc-top-half/musl/compat/time32/gmtime32.c create mode 100644 libc-top-half/musl/compat/time32/gmtime32_r.c create mode 100644 libc-top-half/musl/compat/time32/localtime32.c create mode 100644 libc-top-half/musl/compat/time32/localtime32_r.c create mode 100644 libc-top-half/musl/compat/time32/lstat_time32.c create mode 100644 libc-top-half/musl/compat/time32/lutimes_time32.c create mode 100644 libc-top-half/musl/compat/time32/mktime32.c create mode 100644 libc-top-half/musl/compat/time32/mq_timedreceive_time32.c create mode 100644 libc-top-half/musl/compat/time32/mq_timedsend_time32.c create mode 100644 libc-top-half/musl/compat/time32/mtx_timedlock_time32.c create mode 100644 libc-top-half/musl/compat/time32/nanosleep_time32.c create mode 100644 libc-top-half/musl/compat/time32/ppoll_time32.c create mode 100644 libc-top-half/musl/compat/time32/pselect_time32.c create mode 100644 libc-top-half/musl/compat/time32/pthread_cond_timedwait_time32.c create mode 100644 libc-top-half/musl/compat/time32/pthread_mutex_timedlock_time32.c create mode 100644 libc-top-half/musl/compat/time32/pthread_rwlock_timedrdlock_time32.c create mode 100644 libc-top-half/musl/compat/time32/pthread_rwlock_timedwrlock_time32.c create mode 100644 libc-top-half/musl/compat/time32/pthread_timedjoin_np_time32.c create mode 100644 libc-top-half/musl/compat/time32/recvmmsg_time32.c create mode 100644 libc-top-half/musl/compat/time32/sched_rr_get_interval_time32.c create mode 100644 libc-top-half/musl/compat/time32/select_time32.c create mode 100644 libc-top-half/musl/compat/time32/sem_timedwait_time32.c create mode 100644 libc-top-half/musl/compat/time32/semtimedop_time32.c create mode 100644 libc-top-half/musl/compat/time32/setitimer_time32.c create mode 100644 libc-top-half/musl/compat/time32/settimeofday_time32.c create mode 100644 libc-top-half/musl/compat/time32/sigtimedwait_time32.c create mode 100644 libc-top-half/musl/compat/time32/stat_time32.c create mode 100644 libc-top-half/musl/compat/time32/stime32.c create mode 100644 libc-top-half/musl/compat/time32/thrd_sleep_time32.c create mode 100644 libc-top-half/musl/compat/time32/time32.c create mode 100644 libc-top-half/musl/compat/time32/time32.h create mode 100644 libc-top-half/musl/compat/time32/time32gm.c create mode 100644 libc-top-half/musl/compat/time32/timer_gettime32.c create mode 100644 libc-top-half/musl/compat/time32/timer_settime32.c create mode 100644 libc-top-half/musl/compat/time32/timerfd_gettime32.c create mode 100644 libc-top-half/musl/compat/time32/timerfd_settime32.c create mode 100644 libc-top-half/musl/compat/time32/timespec_get_time32.c create mode 100644 libc-top-half/musl/compat/time32/utime_time32.c create mode 100644 libc-top-half/musl/compat/time32/utimensat_time32.c create mode 100644 libc-top-half/musl/compat/time32/utimes_time32.c create mode 100644 libc-top-half/musl/compat/time32/wait3_time32.c create mode 100644 libc-top-half/musl/compat/time32/wait4_time32.c create mode 100644 libc-top-half/musl/src/ctype/casemap.h create mode 100644 libc-top-half/musl/src/ldso/arm/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/i386/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/m68k/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/microblaze/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/mips/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/mipsn32/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/or1k/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/powerpc/dlsym_time64.S create mode 100644 libc-top-half/musl/src/ldso/sh/dlsym_time64.S delete mode 100644 libc-top-half/musl/src/math/i386/exp2.s delete mode 100644 libc-top-half/musl/src/math/i386/exp2f.s rename libc-top-half/musl/src/math/i386/{exp.s => exp_ld.s} (67%) delete mode 100644 libc-top-half/musl/src/math/i386/expf.s delete mode 100644 libc-top-half/musl/src/math/i386/expm1.s delete mode 100644 libc-top-half/musl/src/math/i386/expm1f.s create mode 100644 libc-top-half/musl/src/math/mips/fabs.c create mode 100644 libc-top-half/musl/src/math/mips/fabsf.c create mode 100644 libc-top-half/musl/src/math/mips/sqrt.c create mode 100644 libc-top-half/musl/src/math/mips/sqrtf.c diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index f7fa6e4..9510bf2 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -86,7 +86,7 @@ #define CDISCARD CTRL('o') #define CDSUSP CTRL('y') #define CEOF CTRL('d') -#define CEOL _POSIX_VDISABLE +#define CEOL '\0' #define CEOT CEOF #define CERASE 0177 #define CFLUSH CDISCARD @@ -124,11 +124,11 @@ #define CRNCYSTR 0x4000F #define CRPRNT CREPRINT #define CSTART CTRL('q') -#define CSTATUS _POSIX_VDISABLE +#define CSTATUS '\0' #define CSTOP CTRL('s') #define CSUSP CTRL('z') #define CTIME 0 -#define CTRL(x) (x&037) +#define CTRL(x) ((x)&037) #define CWERASE CTRL('w') #define C_ANY ns_c_any #define C_CHAOS ns_c_chaos @@ -996,7 +996,7 @@ #define LFLOW_RESTART_ANY 2 #define LFLOW_RESTART_XON 3 #define LITTLE_ENDIAN __LITTLE_ENDIAN -#define LLONG_MAX (0x7fffffffffffffffLL) +#define LLONG_MAX 0x7fffffffffffffffLL #define LLONG_MIN (-LLONG_MAX-1) #define LM_FORWARDMASK 2 #define LM_MODE 1 @@ -1007,8 +1007,8 @@ #define LOCK_SH 1 #define LOCK_UN 8 #define LONGBITS (sizeof(long) * 8) -#define LONG_BIT (32) -#define LONG_MAX (0x7fffffffL) +#define LONG_BIT 32 +#define LONG_MAX __LONG_MAX #define LONG_MIN (-LONG_MAX-1) #define L_INCR 1 #define L_SET 0 @@ -1825,6 +1825,7 @@ #define TCP_THIN_LINEAR_TIMEOUTS 16 #define TCP_TIMESTAMP 24 #define TCP_TIME_WAIT 6 +#define TCP_TX_DELAY 37 #define TCP_ULP 31 #define TCP_USER_TIMEOUT 18 #define TCP_WINDOW_CLAMP 10 @@ -2428,7 +2429,7 @@ #define __BIGGEST_ALIGNMENT__ 16 #define __BIG_ENDIAN 4321 #define __BIND 19950621 -#define __BYTE_ORDER __LITTLE_ENDIAN +#define __BYTE_ORDER __BYTE_ORDER__ #define __BYTE_ORDER__ __ORDER_LITTLE_ENDIAN__ #define __CHAR16_TYPE__ unsigned short #define __CHAR32_TYPE__ unsigned int @@ -2647,6 +2648,7 @@ #define __LITTLE_ENDIAN 1234 #define __LITTLE_ENDIAN__ 1 #define __LONG_LONG_MAX__ 9223372036854775807LL +#define __LONG_MAX __LONG_MAX__ #define __LONG_MAX__ 2147483647L #define __NAMESER 19991006 #define __NEED_FILE @@ -2735,6 +2737,7 @@ #define __PTRDIFF_MAX__ 2147483647L #define __PTRDIFF_TYPE__ long int #define __PTRDIFF_WIDTH__ 32 +#define __REDIR(x,y) __typeof__(x) x __asm__(#y) #define __RETCAST(x) #define __RETCAST_2(x,y) #define __RETCAST_3(x,y,z) @@ -2782,6 +2785,7 @@ #define __UAPI_DEF_IN_IPPROTO 0 #define __UAPI_DEF_IN_PKTINFO 0 #define __UAPI_DEF_IP6_MTUINFO 0 +#define __UAPI_DEF_IPHDR 0 #define __UAPI_DEF_IPPROTO_V6 0 #define __UAPI_DEF_IPV6_MREQ 0 #define __UAPI_DEF_IPV6_OPTIONS 0 @@ -2880,6 +2884,7 @@ #define __UINT_LEAST8_MAX__ 255 #define __UINT_LEAST8_TYPE__ unsigned char #define __USER_LABEL_PREFIX__ +#define __USE_TIME_BITS64 1 #define __WASI_ADVICE_DONTNEED (UINT8_C(4)) #define __WASI_ADVICE_NOREUSE (UINT8_C(5)) #define __WASI_ADVICE_NORMAL (UINT8_C(0)) @@ -3168,6 +3173,7 @@ #define acosh(x) __tg_real_complex(acosh, (x)) #define alignas _Alignas #define alignof _Alignof +#define alloca __builtin_alloca #define alphasort64 alphasort #define and && #define and_eq &= diff --git a/libc-top-half/musl/.mailmap b/libc-top-half/musl/.mailmap new file mode 100644 index 0000000..aede9ec --- /dev/null +++ b/libc-top-half/musl/.mailmap @@ -0,0 +1 @@ +Ada Worcester diff --git a/libc-top-half/musl/COPYRIGHT b/libc-top-half/musl/COPYRIGHT index 67802d1..e647237 100644 --- a/libc-top-half/musl/COPYRIGHT +++ b/libc-top-half/musl/COPYRIGHT @@ -1,7 +1,7 @@ musl as a whole is licensed under the following standard MIT license: ---------------------------------------------------------------------- -Copyright © 2005-2019 Rich Felker, et al. +Copyright © 2005-2020 Rich Felker, et al. Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the @@ -26,6 +26,7 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. Authors/contributors include: A. Wilcox +Ada Worcester Alex Dowad Alex Suykov Alexander Monakov @@ -65,7 +66,6 @@ Jeremy Huntwork Jo-Philipp Wich Joakim Sindholt John Spencer -Josiah Worcester Julien Ramseier Justin Cormack Kaarle Ritvanen diff --git a/libc-top-half/musl/Makefile b/libc-top-half/musl/Makefile index b46f8ca..bd8f5c3 100644 --- a/libc-top-half/musl/Makefile +++ b/libc-top-half/musl/Makefile @@ -17,7 +17,7 @@ includedir = $(prefix)/include libdir = $(prefix)/lib syslibdir = /lib -SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso) +SRC_DIRS = $(addprefix $(srcdir)/,src/* crt ldso $(COMPAT_SRC_DIRS)) BASE_GLOBS = $(addsuffix /*.c,$(SRC_DIRS)) ARCH_GLOBS = $(addsuffix /$(ARCH)/*.[csS],$(SRC_DIRS)) BASE_SRCS = $(sort $(wildcard $(BASE_GLOBS))) @@ -27,7 +27,7 @@ ARCH_OBJS = $(patsubst $(srcdir)/%,%.o,$(basename $(ARCH_SRCS))) REPLACED_OBJS = $(sort $(subst /$(ARCH)/,/,$(ARCH_OBJS))) ALL_OBJS = $(addprefix obj/, $(filter-out $(REPLACED_OBJS), $(sort $(BASE_OBJS) $(ARCH_OBJS)))) -LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS)) +LIBC_OBJS = $(filter obj/src/%,$(ALL_OBJS)) $(filter obj/compat/%,$(ALL_OBJS)) LDSO_OBJS = $(filter obj/ldso/%,$(ALL_OBJS:%.o=%.lo)) CRT_OBJS = $(filter obj/crt/%,$(ALL_OBJS)) @@ -75,6 +75,7 @@ WRAPCC_CLANG = clang LDSO_PATHNAME = $(syslibdir)/ld-musl-$(ARCH)$(SUBARCH).so.1 -include config.mak +-include $(srcdir)/arch/$(ARCH)/arch.mak ifeq ($(ARCH),) diff --git a/libc-top-half/musl/VERSION b/libc-top-half/musl/VERSION index 3fe3e58..26aaba0 100644 --- a/libc-top-half/musl/VERSION +++ b/libc-top-half/musl/VERSION @@ -1 +1 @@ -1.1.24 +1.2.0 diff --git a/libc-top-half/musl/WHATSNEW b/libc-top-half/musl/WHATSNEW index f9879bd..ecf0ceb 100644 --- a/libc-top-half/musl/WHATSNEW +++ b/libc-top-half/musl/WHATSNEW @@ -2164,3 +2164,39 @@ arch-specific bugs fixed: - riscv64 atomics had broken asm constraints (missing earlyclobber flag) - arm clone() was broken when compiled as thumb if start function returned - mipsr6 setjmp/longjmp did not preserve fpu register state correctly + + + +1.2.0 release notes + +new features: +- time_t is now 64-bit on all archs (not just 64-bit archs) +- character type & case mapping data updated to Unicode 12.1.0 +- header-level support for new linux features in 5.3 and 5.4 + +performance: +- new O(1) wchar_t case mapping implementation +- i386 now uses C math code for exp, faster than old asm +- mips math asm + +compatibility & conformance: +- endian.h now aims to conform to future POSIX definition +- support older compilers that don't accept powerpc math asm constraints +- fdpic code in ldso was incompatible with valid optimizations in gcc 9+ +- RLIMIT_RTTIME was missing from sys/resource.h + +bugs fixed: +- wcwidth wrongly returned 0 for most of planes 4 and up +- missing case mapping between U+03F3 and U+037F +- wrong cacosh results for arguments with negative imaginary part +- wrong catanf/catanl results for various classes of arguments +- wrong return value for ungetc with argument outside [0,UCHAR_MAX] +- posix_openpt with no ptys available produced wrong errno + +arch-specific bugs fixed: +- sigcontext/regset definition mistakes & omissions on m68k, powerpc64 +- fesetenv(FE_DFL_ENV) crashed on riscv64 +- sh2 dynamic linker was broken since 1.1.21 (crash in stage 2b) +- arm dynamic linker chose wrong tls/atomic variants since 1.1.21 +- some math library functions returned excess precision on i386 +- unconfirmed regression in fchmodat AT_SYMLINK_NOFOLLOW on mips* diff --git a/libc-top-half/musl/arch/aarch64/bits/alltypes.h.in b/libc-top-half/musl/arch/aarch64/bits/alltypes.h.in index d56abda..c547ca0 100644 --- a/libc-top-half/musl/arch/aarch64/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/aarch64/bits/alltypes.h.in @@ -2,8 +2,13 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if __AARCH64EB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF unsigned wchar_t; @@ -17,14 +22,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/aarch64/bits/endian.h b/libc-top-half/musl/arch/aarch64/bits/endian.h deleted file mode 100644 index 7a74d2f..0000000 --- a/libc-top-half/musl/arch/aarch64/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __AARCH64EB__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/aarch64/bits/limits.h b/libc-top-half/musl/arch/aarch64/bits/limits.h deleted file mode 100644 index 0226588..0000000 --- a/libc-top-half/musl/arch/aarch64/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/aarch64/bits/socket.h b/libc-top-half/musl/arch/aarch64/bits/socket.h deleted file mode 100644 index c11677e..0000000 --- a/libc-top-half/musl/arch/aarch64/bits/socket.h +++ /dev/null @@ -1,33 +0,0 @@ -#include - -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1, msg_iovlen; -#else - int msg_iovlen, __pad1; -#endif - void *msg_control; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad2; - socklen_t msg_controllen; -#else - socklen_t msg_controllen; - int __pad2; -#endif - int msg_flags; -}; - -struct cmsghdr { -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1; - socklen_t cmsg_len; -#else - socklen_t cmsg_len; - int __pad1; -#endif - int cmsg_level; - int cmsg_type; -}; diff --git a/libc-top-half/musl/arch/aarch64/bits/syscall.h.in b/libc-top-half/musl/arch/aarch64/bits/syscall.h.in index 955e2ca..93648af 100644 --- a/libc-top-half/musl/arch/aarch64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/aarch64/bits/syscall.h.in @@ -287,4 +287,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/aarch64/reloc.h b/libc-top-half/musl/arch/aarch64/reloc.h index 40cf0b2..b1b68c7 100644 --- a/libc-top-half/musl/arch/aarch64/reloc.h +++ b/libc-top-half/musl/arch/aarch64/reloc.h @@ -1,5 +1,3 @@ -#include - #if __BYTE_ORDER == __BIG_ENDIAN #define ENDIAN_SUFFIX "_be" #else diff --git a/libc-top-half/musl/arch/arm/arch.mak b/libc-top-half/musl/arch/arm/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/arm/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/arm/bits/alltypes.h.in b/libc-top-half/musl/arch/arm/bits/alltypes.h.in index 667963c..d62bd7b 100644 --- a/libc-top-half/musl/arch/arm/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/arm/bits/alltypes.h.in @@ -1,9 +1,15 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if __ARMEB__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus TYPEDEF unsigned wchar_t; @@ -13,14 +19,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/arm/bits/endian.h b/libc-top-half/musl/arch/arm/bits/endian.h deleted file mode 100644 index 5953724..0000000 --- a/libc-top-half/musl/arch/arm/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __ARMEB__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/arm/bits/ipcstat.h b/libc-top-half/musl/arch/arm/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/arm/bits/ipcstat.h +++ b/libc-top-half/musl/arch/arm/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/arm/bits/limits.h b/libc-top-half/musl/arch/arm/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/arm/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/arm/bits/msg.h b/libc-top-half/musl/arch/arm/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/arm/bits/msg.h +++ b/libc-top-half/musl/arch/arm/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/arm/bits/sem.h b/libc-top-half/musl/arch/arm/bits/sem.h index d383d4e..544e3d2 100644 --- a/libc-top-half/musl/arch/arm/bits/sem.h +++ b/libc-top-half/musl/arch/arm/bits/sem.h @@ -1,9 +1,9 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; @@ -13,4 +13,6 @@ struct semid_ds { #endif long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/arm/bits/shm.h b/libc-top-half/musl/arch/arm/bits/shm.h index 81b2a29..725fb46 100644 --- a/libc-top-half/musl/arch/arm/bits/shm.h +++ b/libc-top-half/musl/arch/arm/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/arm/bits/stat.h b/libc-top-half/musl/arch/arm/bits/stat.h index 22b19bb..5d7828c 100644 --- a/libc-top-half/musl/arch/arm/bits/stat.h +++ b/libc-top-half/musl/arch/arm/bits/stat.h @@ -14,8 +14,12 @@ struct stat { off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + ino_t st_ino; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - ino_t st_ino; }; diff --git a/libc-top-half/musl/arch/arm/bits/syscall.h.in b/libc-top-half/musl/arch/arm/bits/syscall.h.in index a565a4e..11d6776 100644 --- a/libc-top-half/musl/arch/arm/bits/syscall.h.in +++ b/libc-top-half/musl/arch/arm/bits/syscall.h.in @@ -55,8 +55,8 @@ #define __NR_sethostname 74 #define __NR_setrlimit 75 #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_symlink 83 @@ -211,14 +211,14 @@ #define __NR_remap_file_pages 253 #define __NR_set_tid_address 256 #define __NR_timer_create 257 -#define __NR_timer_settime 258 -#define __NR_timer_gettime 259 +#define __NR_timer_settime32 258 +#define __NR_timer_gettime32 259 #define __NR_timer_getoverrun 260 #define __NR_timer_delete 261 -#define __NR_clock_settime 262 -#define __NR_clock_gettime 263 -#define __NR_clock_getres 264 -#define __NR_clock_nanosleep 265 +#define __NR_clock_settime32 262 +#define __NR_clock_gettime32 263 +#define __NR_clock_getres_time32 264 +#define __NR_clock_nanosleep_time32 265 #define __NR_statfs64 266 #define __NR_fstatfs64 267 #define __NR_tgkill 268 @@ -308,8 +308,8 @@ #define __NR_timerfd_create 350 #define __NR_eventfd 351 #define __NR_fallocate 352 -#define __NR_timerfd_settime 353 -#define __NR_timerfd_gettime 354 +#define __NR_timerfd_settime32 353 +#define __NR_timerfd_gettime32 354 #define __NR_signalfd4 355 #define __NR_eventfd2 356 #define __NR_epoll_create1 357 @@ -387,6 +387,8 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 #define __ARM_NR_breakpoint 0x0f0001 #define __ARM_NR_cacheflush 0x0f0002 diff --git a/libc-top-half/musl/arch/arm/reloc.h b/libc-top-half/musl/arch/arm/reloc.h index 2c2e7f5..d091d2a 100644 --- a/libc-top-half/musl/arch/arm/reloc.h +++ b/libc-top-half/musl/arch/arm/reloc.h @@ -1,5 +1,3 @@ -#include - #if __BYTE_ORDER == __BIG_ENDIAN #define ENDIAN_SUFFIX "eb" #else diff --git a/libc-top-half/musl/arch/arm/syscall_arch.h b/libc-top-half/musl/arch/arm/syscall_arch.h index 53fb155..4b08762 100644 --- a/libc-top-half/musl/arch/arm/syscall_arch.h +++ b/libc-top-half/musl/arch/arm/syscall_arch.h @@ -99,7 +99,9 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo } #define VDSO_USEFUL -#define VDSO_CGT_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_VER "LINUX_2.6" +#define VDSO_CGT_SYM "__vdso_clock_gettime64" #define VDSO_CGT_VER "LINUX_2.6" #define SYSCALL_FADVISE_6_ARG diff --git a/libc-top-half/musl/arch/generic/bits/dirent.h b/libc-top-half/musl/arch/generic/bits/dirent.h new file mode 100644 index 0000000..c845fe8 --- /dev/null +++ b/libc-top-half/musl/arch/generic/bits/dirent.h @@ -0,0 +1,11 @@ +#define _DIRENT_HAVE_D_RECLEN +#define _DIRENT_HAVE_D_OFF +#define _DIRENT_HAVE_D_TYPE + +struct dirent { + ino_t d_ino; + off_t d_off; + unsigned short d_reclen; + unsigned char d_type; + char d_name[256]; +}; diff --git a/libc-top-half/musl/arch/generic/bits/ioctl.h b/libc-top-half/musl/arch/generic/bits/ioctl.h index d1a6c03..60ae8b8 100644 --- a/libc-top-half/musl/arch/generic/bits/ioctl.h +++ b/libc-top-half/musl/arch/generic/bits/ioctl.h @@ -104,7 +104,12 @@ #define FIOGETOWN 0x8903 #define SIOCGPGRP 0x8904 #define SIOCATMARK 0x8905 +#if __LONG_MAX == 0x7fffffff +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) +#else #define SIOCGSTAMP 0x8906 #define SIOCGSTAMPNS 0x8907 +#endif #include diff --git a/libc-top-half/musl/arch/generic/bits/limits.h b/libc-top-half/musl/arch/generic/bits/limits.h new file mode 100644 index 0000000..e69de29 diff --git a/libc-top-half/musl/arch/generic/bits/socket.h b/libc-top-half/musl/arch/generic/bits/socket.h index 1f73b99..e69de29 100644 --- a/libc-top-half/musl/arch/generic/bits/socket.h +++ b/libc-top-half/musl/arch/generic/bits/socket.h @@ -1,15 +0,0 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen; - void *msg_control; - socklen_t msg_controllen; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; -}; diff --git a/libc-top-half/musl/arch/i386/arch.mak b/libc-top-half/musl/arch/i386/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/i386/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/i386/bits/alltypes.h.in b/libc-top-half/musl/arch/i386/bits/alltypes.h.in index 1a8432d..6feb03a 100644 --- a/libc-top-half/musl/arch/i386/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/i386/bits/alltypes.h.in @@ -1,14 +1,10 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -#if __GNUC__ >= 3 -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; -#else -TYPEDEF struct __va_list * va_list; -TYPEDEF struct __va_list * __isoc_va_list; -#endif +#define __BYTE_ORDER 1234 +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus #ifdef __WCHAR_TYPE__ @@ -33,14 +29,3 @@ TYPEDEF struct { __attribute__((__aligned__(8))) long long __ll; long double __l #else TYPEDEF struct { alignas(8) long long __ll; long double __ld; } max_align_t; #endif - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/i386/bits/endian.h b/libc-top-half/musl/arch/i386/bits/endian.h deleted file mode 100644 index 172c338..0000000 --- a/libc-top-half/musl/arch/i386/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/libc-top-half/musl/arch/i386/bits/ipcstat.h b/libc-top-half/musl/arch/i386/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/i386/bits/ipcstat.h +++ b/libc-top-half/musl/arch/i386/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/i386/bits/limits.h b/libc-top-half/musl/arch/i386/bits/limits.h index c340ceb..07743b6 100644 --- a/libc-top-half/musl/arch/i386/bits/limits.h +++ b/libc-top-half/musl/arch/i386/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 4096 -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/i386/bits/msg.h b/libc-top-half/musl/arch/i386/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/i386/bits/msg.h +++ b/libc-top-half/musl/arch/i386/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/i386/bits/sem.h b/libc-top-half/musl/arch/i386/bits/sem.h index e61571c..6566154 100644 --- a/libc-top-half/musl/arch/i386/bits/sem.h +++ b/libc-top-half/musl/arch/i386/bits/sem.h @@ -1,11 +1,13 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/i386/bits/shm.h b/libc-top-half/musl/arch/i386/bits/shm.h index 81b2a29..725fb46 100644 --- a/libc-top-half/musl/arch/i386/bits/shm.h +++ b/libc-top-half/musl/arch/i386/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/i386/bits/stat.h b/libc-top-half/musl/arch/i386/bits/stat.h index 22b19bb..5d7828c 100644 --- a/libc-top-half/musl/arch/i386/bits/stat.h +++ b/libc-top-half/musl/arch/i386/bits/stat.h @@ -14,8 +14,12 @@ struct stat { off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + ino_t st_ino; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - ino_t st_ino; }; diff --git a/libc-top-half/musl/arch/i386/bits/syscall.h.in b/libc-top-half/musl/arch/i386/bits/syscall.h.in index c95e108..1ae4e48 100644 --- a/libc-top-half/musl/arch/i386/bits/syscall.h.in +++ b/libc-top-half/musl/arch/i386/bits/syscall.h.in @@ -76,8 +76,8 @@ #define __NR_setrlimit 75 #define __NR_getrlimit 76 /* Back compatible 2Gig limited rlimit */ #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_select 82 @@ -257,14 +257,14 @@ #define __NR_remap_file_pages 257 #define __NR_set_tid_address 258 #define __NR_timer_create 259 -#define __NR_timer_settime (__NR_timer_create+1) -#define __NR_timer_gettime (__NR_timer_create+2) +#define __NR_timer_settime32 (__NR_timer_create+1) +#define __NR_timer_gettime32 (__NR_timer_create+2) #define __NR_timer_getoverrun (__NR_timer_create+3) #define __NR_timer_delete (__NR_timer_create+4) -#define __NR_clock_settime (__NR_timer_create+5) -#define __NR_clock_gettime (__NR_timer_create+6) -#define __NR_clock_getres (__NR_timer_create+7) -#define __NR_clock_nanosleep (__NR_timer_create+8) +#define __NR_clock_settime32 (__NR_timer_create+5) +#define __NR_clock_gettime32 (__NR_timer_create+6) +#define __NR_clock_getres_time32 (__NR_timer_create+7) +#define __NR_clock_nanosleep_time32 (__NR_timer_create+8) #define __NR_statfs64 268 #define __NR_fstatfs64 269 #define __NR_tgkill 270 @@ -322,8 +322,8 @@ #define __NR_timerfd_create 322 #define __NR_eventfd 323 #define __NR_fallocate 324 -#define __NR_timerfd_settime 325 -#define __NR_timerfd_gettime 326 +#define __NR_timerfd_settime32 325 +#define __NR_timerfd_gettime32 326 #define __NR_signalfd4 327 #define __NR_eventfd2 328 #define __NR_epoll_create1 329 @@ -424,4 +424,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/i386/syscall_arch.h b/libc-top-half/musl/arch/i386/syscall_arch.h index 22b0b28..69642e5 100644 --- a/libc-top-half/musl/arch/i386/syscall_arch.h +++ b/libc-top-half/musl/arch/i386/syscall_arch.h @@ -83,7 +83,9 @@ static inline long __syscall6(long n, long a1, long a2, long a3, long a4, long a } #define VDSO_USEFUL -#define VDSO_CGT_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_VER "LINUX_2.6" +#define VDSO_CGT_SYM "__vdso_clock_gettime64" #define VDSO_CGT_VER "LINUX_2.6" #define SYSCALL_USE_SOCKETCALL diff --git a/libc-top-half/musl/arch/m68k/arch.mak b/libc-top-half/musl/arch/m68k/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/m68k/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/m68k/bits/alltypes.h.in b/libc-top-half/musl/arch/m68k/bits/alltypes.h.in index bd37a63..f564690 100644 --- a/libc-top-half/musl/arch/m68k/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/m68k/bits/alltypes.h.in @@ -1,9 +1,10 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 4321 +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus #ifdef __WCHAR_TYPE__ @@ -22,14 +23,3 @@ TYPEDEF long double double_t; #endif TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/m68k/bits/endian.h b/libc-top-half/musl/arch/m68k/bits/endian.h deleted file mode 100644 index ef074b7..0000000 --- a/libc-top-half/musl/arch/m68k/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __BIG_ENDIAN diff --git a/libc-top-half/musl/arch/m68k/bits/ipcstat.h b/libc-top-half/musl/arch/m68k/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/m68k/bits/ipcstat.h +++ b/libc-top-half/musl/arch/m68k/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/m68k/bits/limits.h b/libc-top-half/musl/arch/m68k/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/m68k/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/m68k/bits/msg.h b/libc-top-half/musl/arch/m68k/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/m68k/bits/msg.h +++ b/libc-top-half/musl/arch/m68k/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/m68k/bits/sem.h b/libc-top-half/musl/arch/m68k/bits/sem.h index 08faafe..d88338e 100644 --- a/libc-top-half/musl/arch/m68k/bits/sem.h +++ b/libc-top-half/musl/arch/m68k/bits/sem.h @@ -1,11 +1,13 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/m68k/bits/shm.h b/libc-top-half/musl/arch/m68k/bits/shm.h index 81b2a29..725fb46 100644 --- a/libc-top-half/musl/arch/m68k/bits/shm.h +++ b/libc-top-half/musl/arch/m68k/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/m68k/bits/stat.h b/libc-top-half/musl/arch/m68k/bits/stat.h index 0f7b66a..f876814 100644 --- a/libc-top-half/musl/arch/m68k/bits/stat.h +++ b/libc-top-half/musl/arch/m68k/bits/stat.h @@ -14,8 +14,12 @@ struct stat { off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + ino_t st_ino; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - ino_t st_ino; }; diff --git a/libc-top-half/musl/arch/m68k/bits/syscall.h.in b/libc-top-half/musl/arch/m68k/bits/syscall.h.in index fb522b4..ddfa72e 100644 --- a/libc-top-half/musl/arch/m68k/bits/syscall.h.in +++ b/libc-top-half/musl/arch/m68k/bits/syscall.h.in @@ -67,8 +67,8 @@ #define __NR_setrlimit 75 #define __NR_getrlimit 76 #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_select 82 @@ -235,14 +235,14 @@ #define __NR_remap_file_pages 252 #define __NR_set_tid_address 253 #define __NR_timer_create 254 -#define __NR_timer_settime 255 -#define __NR_timer_gettime 256 +#define __NR_timer_settime32 255 +#define __NR_timer_gettime32 256 #define __NR_timer_getoverrun 257 #define __NR_timer_delete 258 -#define __NR_clock_settime 259 -#define __NR_clock_gettime 260 -#define __NR_clock_getres 261 -#define __NR_clock_nanosleep 262 +#define __NR_clock_settime32 259 +#define __NR_clock_gettime32 260 +#define __NR_clock_getres_time32 261 +#define __NR_clock_nanosleep_time32 262 #define __NR_statfs64 263 #define __NR_fstatfs64 264 #define __NR_tgkill 265 @@ -300,8 +300,8 @@ #define __NR_timerfd_create 318 #define __NR_eventfd 319 #define __NR_fallocate 320 -#define __NR_timerfd_settime 321 -#define __NR_timerfd_gettime 322 +#define __NR_timerfd_settime32 321 +#define __NR_timerfd_gettime32 322 #define __NR_signalfd4 323 #define __NR_eventfd2 324 #define __NR_epoll_create1 325 @@ -404,3 +404,4 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 diff --git a/libc-top-half/musl/arch/m68k/bits/user.h b/libc-top-half/musl/arch/m68k/bits/user.h index 9a4ca12..6a44391 100644 --- a/libc-top-half/musl/arch/m68k/bits/user.h +++ b/libc-top-half/musl/arch/m68k/bits/user.h @@ -27,6 +27,11 @@ struct user { char u_comm[32]; }; +#define ELF_NGREG 20 +typedef unsigned long elf_greg_t; +typedef elf_greg_t elf_gregset_t[ELF_NGREG]; +typedef struct user_m68kfp_struct elf_fpregset_t; + #define NBPG 4096 #define UPAGES 1 #define HOST_TEXT_START_ADDR (u.start_code) diff --git a/libc-top-half/musl/arch/microblaze/arch.mak b/libc-top-half/musl/arch/microblaze/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/microblaze/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/microblaze/bits/alltypes.h.in b/libc-top-half/musl/arch/microblaze/bits/alltypes.h.in index 66ca18a..9a4ce29 100644 --- a/libc-top-half/musl/arch/microblaze/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/microblaze/bits/alltypes.h.in @@ -1,9 +1,15 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if __MICROBLAZEEL__ +#define __BYTE_ORDER 1234 +#else +#define __BYTE_ORDER 4321 +#endif + +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -13,14 +19,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/microblaze/bits/endian.h b/libc-top-half/musl/arch/microblaze/bits/endian.h deleted file mode 100644 index d82a92a..0000000 --- a/libc-top-half/musl/arch/microblaze/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __MICROBLAZEEL__ -#define __BYTE_ORDER __LITTLE_ENDIAN -#else -#define __BYTE_ORDER __BIG_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/microblaze/bits/ipcstat.h b/libc-top-half/musl/arch/microblaze/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/microblaze/bits/ipcstat.h +++ b/libc-top-half/musl/arch/microblaze/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/microblaze/bits/limits.h b/libc-top-half/musl/arch/microblaze/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/microblaze/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/microblaze/bits/msg.h b/libc-top-half/musl/arch/microblaze/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/microblaze/bits/msg.h +++ b/libc-top-half/musl/arch/microblaze/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/microblaze/bits/sem.h b/libc-top-half/musl/arch/microblaze/bits/sem.h index d383d4e..544e3d2 100644 --- a/libc-top-half/musl/arch/microblaze/bits/sem.h +++ b/libc-top-half/musl/arch/microblaze/bits/sem.h @@ -1,9 +1,9 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; @@ -13,4 +13,6 @@ struct semid_ds { #endif long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/microblaze/bits/shm.h b/libc-top-half/musl/arch/microblaze/bits/shm.h index 81b2a29..725fb46 100644 --- a/libc-top-half/musl/arch/microblaze/bits/shm.h +++ b/libc-top-half/musl/arch/microblaze/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/microblaze/bits/stat.h b/libc-top-half/musl/arch/microblaze/bits/stat.h index ce6a6bd..8a4d509 100644 --- a/libc-top-half/musl/arch/microblaze/bits/stat.h +++ b/libc-top-half/musl/arch/microblaze/bits/stat.h @@ -14,8 +14,12 @@ struct stat { blksize_t st_blksize; int __st_blksize_padding; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + unsigned __unused[2]; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - unsigned __unused[2]; }; diff --git a/libc-top-half/musl/arch/microblaze/bits/syscall.h.in b/libc-top-half/musl/arch/microblaze/bits/syscall.h.in index 59f8623..963386a 100644 --- a/libc-top-half/musl/arch/microblaze/bits/syscall.h.in +++ b/libc-top-half/musl/arch/microblaze/bits/syscall.h.in @@ -76,8 +76,8 @@ #define __NR_setrlimit 75 #define __NR_getrlimit 76 #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_select 82 @@ -255,14 +255,14 @@ #define __NR_remap_file_pages 257 #define __NR_set_tid_address 258 #define __NR_timer_create 259 -#define __NR_timer_settime 260 -#define __NR_timer_gettime 261 +#define __NR_timer_settime32 260 +#define __NR_timer_gettime32 261 #define __NR_timer_getoverrun 262 #define __NR_timer_delete 263 -#define __NR_clock_settime 264 -#define __NR_clock_gettime 265 -#define __NR_clock_getres 266 -#define __NR_clock_nanosleep 267 +#define __NR_clock_settime32 264 +#define __NR_clock_gettime32 265 +#define __NR_clock_getres_time32 266 +#define __NR_clock_nanosleep_time32 267 #define __NR_statfs64 268 #define __NR_fstatfs64 269 #define __NR_tgkill 270 @@ -320,8 +320,8 @@ #define __NR_eventfd 323 #define __NR_fallocate 324 #define __NR_semtimedop 325 -#define __NR_timerfd_settime 326 -#define __NR_timerfd_gettime 327 +#define __NR_timerfd_settime32 326 +#define __NR_timerfd_gettime32 327 #define __NR_semctl 328 #define __NR_semget 329 #define __NR_semop 330 @@ -425,4 +425,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/microblaze/reloc.h b/libc-top-half/musl/arch/microblaze/reloc.h index 0a030c7..6302c6e 100644 --- a/libc-top-half/musl/arch/microblaze/reloc.h +++ b/libc-top-half/musl/arch/microblaze/reloc.h @@ -1,5 +1,3 @@ -#include - #if __BYTE_ORDER == __LITTLE_ENDIAN #define ENDIAN_SUFFIX "el" #else diff --git a/libc-top-half/musl/arch/mips/arch.mak b/libc-top-half/musl/arch/mips/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/mips/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/mips/bits/alltypes.h.in b/libc-top-half/musl/arch/mips/bits/alltypes.h.in index 66ca18a..ff934a4 100644 --- a/libc-top-half/musl/arch/mips/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/mips/bits/alltypes.h.in @@ -1,9 +1,15 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if _MIPSEL || __MIPSEL || __MIPSEL__ +#define __BYTE_ORDER 1234 +#else +#define __BYTE_ORDER 4321 +#endif + +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -13,14 +19,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/mips/bits/endian.h b/libc-top-half/musl/arch/mips/bits/endian.h deleted file mode 100644 index 5399dcb..0000000 --- a/libc-top-half/musl/arch/mips/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __BYTE_ORDER __LITTLE_ENDIAN -#else -#define __BYTE_ORDER __BIG_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/mips/bits/hwcap.h b/libc-top-half/musl/arch/mips/bits/hwcap.h index 13e86fe..7986deb 100644 --- a/libc-top-half/musl/arch/mips/bits/hwcap.h +++ b/libc-top-half/musl/arch/mips/bits/hwcap.h @@ -1,3 +1,14 @@ #define HWCAP_MIPS_R6 (1 << 0) #define HWCAP_MIPS_MSA (1 << 1) #define HWCAP_MIPS_CRC32 (1 << 2) +#define HWCAP_MIPS_MIPS16 (1 << 3) +#define HWCAP_MIPS_MDMX (1 << 4) +#define HWCAP_MIPS_MIPS3D (1 << 5) +#define HWCAP_MIPS_SMARTMIPS (1 << 6) +#define HWCAP_MIPS_DSP (1 << 7) +#define HWCAP_MIPS_DSP2 (1 << 8) +#define HWCAP_MIPS_DSP3 (1 << 9) +#define HWCAP_MIPS_MIPS16E2 (1 << 10) +#define HWCAP_LOONGSON_MMI (1 << 11) +#define HWCAP_LOONGSON_EXT (1 << 12) +#define HWCAP_LOONGSON_EXT2 (1 << 13) diff --git a/libc-top-half/musl/arch/mips/bits/ioctl.h b/libc-top-half/musl/arch/mips/bits/ioctl.h index e277c3f..e20bf19 100644 --- a/libc-top-half/musl/arch/mips/bits/ioctl.h +++ b/libc-top-half/musl/arch/mips/bits/ioctl.h @@ -110,5 +110,5 @@ #define SIOCATMARK _IOR('s', 7, int) #define SIOCSPGRP _IOW('s', 8, pid_t) #define SIOCGPGRP _IOR('s', 9, pid_t) -#define SIOCGSTAMP 0x8906 -#define SIOCGSTAMPNS 0x8907 +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) diff --git a/libc-top-half/musl/arch/mips/bits/ipcstat.h b/libc-top-half/musl/arch/mips/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/mips/bits/ipcstat.h +++ b/libc-top-half/musl/arch/mips/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/mips/bits/limits.h b/libc-top-half/musl/arch/mips/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/mips/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/mips/bits/msg.h b/libc-top-half/musl/arch/mips/bits/msg.h index f28aece..c734dbb 100644 --- a/libc-top-half/musl/arch/mips/bits/msg.h +++ b/libc-top-half/musl/arch/mips/bits/msg.h @@ -1,19 +1,19 @@ struct msqid_ds { struct ipc_perm msg_perm; #if _MIPSEL || __MIPSEL || __MIPSEL__ - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; #else - int __unused1; - time_t msg_stime; - int __unused2; - time_t msg_rtime; - int __unused3; - time_t msg_ctime; + unsigned long __msg_stime_hi; + unsigned long __msg_stime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_ctime_hi; + unsigned long __msg_ctime_lo; #endif unsigned long msg_cbytes; msgqnum_t msg_qnum; @@ -21,4 +21,7 @@ struct msqid_ds { pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/mips/bits/sem.h b/libc-top-half/musl/arch/mips/bits/sem.h index 5184eb5..fe6f094 100644 --- a/libc-top-half/musl/arch/mips/bits/sem.h +++ b/libc-top-half/musl/arch/mips/bits/sem.h @@ -1,7 +1,7 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - time_t sem_ctime; + unsigned long __sem_otime_lo; + unsigned long __sem_ctime_lo; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; @@ -9,6 +9,8 @@ struct semid_ds { char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - long __unused3; - long __unused4; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_hi; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/mips/bits/shm.h b/libc-top-half/musl/arch/mips/bits/shm.h index 8d19378..ab8c642 100644 --- a/libc-top-half/musl/arch/mips/bits/shm.h +++ b/libc-top-half/musl/arch/mips/bits/shm.h @@ -3,14 +3,19 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - time_t shm_dtime; - time_t shm_ctime; + unsigned long __shm_atime_lo; + unsigned long __shm_dtime_lo; + unsigned long __shm_ctime_lo; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; - unsigned long __pad1; - unsigned long __pad2; + unsigned short __shm_atime_hi; + unsigned short __shm_dtime_hi; + unsigned short __shm_ctime_hi; + unsigned short __pad1; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/mips/bits/signal.h b/libc-top-half/musl/arch/mips/bits/signal.h index 1a84de5..e1d97ac 100644 --- a/libc-top-half/musl/arch/mips/bits/signal.h +++ b/libc-top-half/musl/arch/mips/bits/signal.h @@ -19,14 +19,18 @@ typedef struct { } fpregset_t; struct sigcontext { unsigned sc_regmask, sc_status; - unsigned long long sc_pc, sc_regs[32], sc_fpregs[32]; + unsigned long long sc_pc; + gregset_t sc_regs; + fpregset_t sc_fpregs; unsigned sc_ownedfp, sc_fpc_csr, sc_fpc_eir, sc_used_math, sc_dsp; unsigned long long sc_mdhi, sc_mdlo; unsigned long sc_hi1, sc_lo1, sc_hi2, sc_lo2, sc_hi3, sc_lo3; }; typedef struct { unsigned regmask, status; - unsigned long long pc, gregs[32], fpregs[32]; + unsigned long long pc; + gregset_t gregs; + fpregset_t fpregs; unsigned ownedfp, fpc_csr, fpc_eir, used_math, dsp; unsigned long long mdhi, mdlo; unsigned long hi1, lo1, hi2, lo2, hi3, lo3; diff --git a/libc-top-half/musl/arch/mips/bits/socket.h b/libc-top-half/musl/arch/mips/bits/socket.h index b82c7d3..02fbb88 100644 --- a/libc-top-half/musl/arch/mips/bits/socket.h +++ b/libc-top-half/musl/arch/mips/bits/socket.h @@ -1,19 +1,3 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen; - void *msg_control; - socklen_t msg_controllen; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; -}; - #define SOCK_STREAM 2 #define SOCK_DGRAM 1 @@ -32,8 +16,6 @@ struct cmsghdr { #define SO_RCVBUF 0x1002 #define SO_SNDLOWAT 0x1003 #define SO_RCVLOWAT 0x1004 -#define SO_RCVTIMEO 0x1006 -#define SO_SNDTIMEO 0x1005 #define SO_ERROR 0x1007 #define SO_TYPE 0x1008 #define SO_ACCEPTCONN 0x1009 diff --git a/libc-top-half/musl/arch/mips/bits/stat.h b/libc-top-half/musl/arch/mips/bits/stat.h index 3291a63..48d4ac8 100644 --- a/libc-top-half/musl/arch/mips/bits/stat.h +++ b/libc-top-half/musl/arch/mips/bits/stat.h @@ -12,11 +12,15 @@ struct stat { dev_t st_rdev; long __st_padding2[2]; off_t st_size; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; blksize_t st_blksize; long __st_padding3; blkcnt_t st_blocks; - long __st_padding4[14]; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + long __st_padding4[2]; }; diff --git a/libc-top-half/musl/arch/mips/bits/syscall.h.in b/libc-top-half/musl/arch/mips/bits/syscall.h.in index 582fa3b..86251bf 100644 --- a/libc-top-half/musl/arch/mips/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mips/bits/syscall.h.in @@ -76,8 +76,8 @@ #define __NR_setrlimit 4075 #define __NR_getrlimit 4076 #define __NR_getrusage 4077 -#define __NR_gettimeofday 4078 -#define __NR_settimeofday 4079 +#define __NR_gettimeofday_time32 4078 +#define __NR_settimeofday_time32 4079 #define __NR_getgroups 4080 #define __NR_setgroups 4081 #define __NR_reserved82 4082 @@ -256,14 +256,14 @@ #define __NR_statfs64 4255 #define __NR_fstatfs64 4256 #define __NR_timer_create 4257 -#define __NR_timer_settime 4258 -#define __NR_timer_gettime 4259 +#define __NR_timer_settime32 4258 +#define __NR_timer_gettime32 4259 #define __NR_timer_getoverrun 4260 #define __NR_timer_delete 4261 -#define __NR_clock_settime 4262 -#define __NR_clock_gettime 4263 -#define __NR_clock_getres 4264 -#define __NR_clock_nanosleep 4265 +#define __NR_clock_settime32 4262 +#define __NR_clock_gettime32 4263 +#define __NR_clock_getres_time32 4264 +#define __NR_clock_nanosleep_time32 4265 #define __NR_tgkill 4266 #define __NR_utimes 4267 #define __NR_mbind 4268 @@ -319,8 +319,8 @@ #define __NR_eventfd 4319 #define __NR_fallocate 4320 #define __NR_timerfd_create 4321 -#define __NR_timerfd_gettime 4322 -#define __NR_timerfd_settime 4323 +#define __NR_timerfd_gettime32 4322 +#define __NR_timerfd_settime32 4323 #define __NR_signalfd4 4324 #define __NR_eventfd2 4325 #define __NR_epoll_create1 4326 @@ -406,4 +406,6 @@ #define __NR_fsconfig 4431 #define __NR_fsmount 4432 #define __NR_fspick 4433 +#define __NR_pidfd_open 4434 +#define __NR_clone3 4435 diff --git a/libc-top-half/musl/arch/mips/reloc.h b/libc-top-half/musl/arch/mips/reloc.h index b3d59a4..88d2363 100644 --- a/libc-top-half/musl/arch/mips/reloc.h +++ b/libc-top-half/musl/arch/mips/reloc.h @@ -1,5 +1,3 @@ -#include - #if __mips_isa_rev >= 6 #define ISA_SUFFIX "r6" #else diff --git a/libc-top-half/musl/arch/mips/syscall_arch.h b/libc-top-half/musl/arch/mips/syscall_arch.h index 6ea7343..f821e73 100644 --- a/libc-top-half/musl/arch/mips/syscall_arch.h +++ b/libc-top-half/musl/arch/mips/syscall_arch.h @@ -142,7 +142,9 @@ static inline long __syscall7(long n, long a, long b, long c, long d, long e, lo } #define VDSO_USEFUL -#define VDSO_CGT_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_VER "LINUX_2.6" +#define VDSO_CGT_SYM "__vdso_clock_gettime64" #define VDSO_CGT_VER "LINUX_2.6" #define SO_SNDTIMEO_OLD 0x1005 diff --git a/libc-top-half/musl/arch/mips64/bits/alltypes.h.in b/libc-top-half/musl/arch/mips64/bits/alltypes.h.in index 2b2e34a..fcd61ee 100644 --- a/libc-top-half/musl/arch/mips64/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/mips64/bits/alltypes.h.in @@ -2,8 +2,13 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if _MIPSEL || __MIPSEL || __MIPSEL__ +#define __BYTE_ORDER 1234 +#else +#define __BYTE_ORDER 4321 +#endif + +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -14,15 +19,4 @@ TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - TYPEDEF unsigned nlink_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/mips64/bits/endian.h b/libc-top-half/musl/arch/mips64/bits/endian.h deleted file mode 100644 index 5399dcb..0000000 --- a/libc-top-half/musl/arch/mips64/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __BYTE_ORDER __LITTLE_ENDIAN -#else -#define __BYTE_ORDER __BIG_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/mips64/bits/limits.h b/libc-top-half/musl/arch/mips64/bits/limits.h deleted file mode 100644 index 58698c6..0000000 --- a/libc-top-half/musl/arch/mips64/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/mips64/bits/socket.h b/libc-top-half/musl/arch/mips64/bits/socket.h index 5aff0d9..519b9c8 100644 --- a/libc-top-half/musl/arch/mips64/bits/socket.h +++ b/libc-top-half/musl/arch/mips64/bits/socket.h @@ -1,37 +1,3 @@ -#include - -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1, msg_iovlen; -#else - int msg_iovlen, __pad1; -#endif - void *msg_control; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad2; - socklen_t msg_controllen; -#else - socklen_t msg_controllen; - int __pad2; -#endif - int msg_flags; -}; - -struct cmsghdr { -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1; - socklen_t cmsg_len; -#else - socklen_t cmsg_len; - int __pad1; -#endif - int cmsg_level; - int cmsg_type; -}; - #define SOCK_STREAM 2 #define SOCK_DGRAM 1 #define SOL_SOCKET 65535 diff --git a/libc-top-half/musl/arch/mips64/bits/syscall.h.in b/libc-top-half/musl/arch/mips64/bits/syscall.h.in index 34b9752..9b406e9 100644 --- a/libc-top-half/musl/arch/mips64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mips64/bits/syscall.h.in @@ -336,4 +336,6 @@ #define __NR_fsconfig 5431 #define __NR_fsmount 5432 #define __NR_fspick 5433 +#define __NR_pidfd_open 5434 +#define __NR_clone3 5435 diff --git a/libc-top-half/musl/arch/mips64/reloc.h b/libc-top-half/musl/arch/mips64/reloc.h index bbd9bd9..fdb5edc 100644 --- a/libc-top-half/musl/arch/mips64/reloc.h +++ b/libc-top-half/musl/arch/mips64/reloc.h @@ -1,9 +1,3 @@ -#ifndef __RELOC_H__ -#define __RELOC_H__ - -#define _GNU_SOURCE -#include - #if __mips_isa_rev >= 6 #define ISA_SUFFIX "r6" #else @@ -33,6 +27,8 @@ #define REL_DTPOFF R_MIPS_TLS_DTPREL64 #define REL_TPOFF R_MIPS_TLS_TPREL64 +#include + #undef R_TYPE #undef R_SYM #undef R_INFO @@ -62,5 +58,3 @@ " daddu %0, %0, $ra \n" \ ".set pop \n" \ : "=r"(*(fp)) : : "memory", "ra" ) - -#endif diff --git a/libc-top-half/musl/arch/mipsn32/arch.mak b/libc-top-half/musl/arch/mipsn32/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/mipsn32/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/mipsn32/bits/alltypes.h.in b/libc-top-half/musl/arch/mipsn32/bits/alltypes.h.in index 66ca18a..ff934a4 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/mipsn32/bits/alltypes.h.in @@ -1,9 +1,15 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if _MIPSEL || __MIPSEL || __MIPSEL__ +#define __BYTE_ORDER 1234 +#else +#define __BYTE_ORDER 4321 +#endif + +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -13,14 +19,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/mipsn32/bits/endian.h b/libc-top-half/musl/arch/mipsn32/bits/endian.h deleted file mode 100644 index 5399dcb..0000000 --- a/libc-top-half/musl/arch/mipsn32/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if _MIPSEL || __MIPSEL || __MIPSEL__ -#define __BYTE_ORDER __LITTLE_ENDIAN -#else -#define __BYTE_ORDER __BIG_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/mipsn32/bits/ioctl.h b/libc-top-half/musl/arch/mipsn32/bits/ioctl.h index e277c3f..e20bf19 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/ioctl.h +++ b/libc-top-half/musl/arch/mipsn32/bits/ioctl.h @@ -110,5 +110,5 @@ #define SIOCATMARK _IOR('s', 7, int) #define SIOCSPGRP _IOW('s', 8, pid_t) #define SIOCGPGRP _IOR('s', 9, pid_t) -#define SIOCGSTAMP 0x8906 -#define SIOCGSTAMPNS 0x8907 +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) diff --git a/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h b/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h +++ b/libc-top-half/musl/arch/mipsn32/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/mipsn32/bits/limits.h b/libc-top-half/musl/arch/mipsn32/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/mipsn32/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/mipsn32/bits/msg.h b/libc-top-half/musl/arch/mipsn32/bits/msg.h index f28aece..c734dbb 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/msg.h +++ b/libc-top-half/musl/arch/mipsn32/bits/msg.h @@ -1,19 +1,19 @@ struct msqid_ds { struct ipc_perm msg_perm; #if _MIPSEL || __MIPSEL || __MIPSEL__ - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; #else - int __unused1; - time_t msg_stime; - int __unused2; - time_t msg_rtime; - int __unused3; - time_t msg_ctime; + unsigned long __msg_stime_hi; + unsigned long __msg_stime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_ctime_hi; + unsigned long __msg_ctime_lo; #endif unsigned long msg_cbytes; msgqnum_t msg_qnum; @@ -21,4 +21,7 @@ struct msqid_ds { pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/mipsn32/bits/sem.h b/libc-top-half/musl/arch/mipsn32/bits/sem.h index 5184eb5..fe6f094 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/sem.h +++ b/libc-top-half/musl/arch/mipsn32/bits/sem.h @@ -1,7 +1,7 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - time_t sem_ctime; + unsigned long __sem_otime_lo; + unsigned long __sem_ctime_lo; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; @@ -9,6 +9,8 @@ struct semid_ds { char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; #endif - long __unused3; - long __unused4; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_hi; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/mipsn32/bits/shm.h b/libc-top-half/musl/arch/mipsn32/bits/shm.h index 8d19378..ab8c642 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/shm.h +++ b/libc-top-half/musl/arch/mipsn32/bits/shm.h @@ -3,14 +3,19 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - time_t shm_dtime; - time_t shm_ctime; + unsigned long __shm_atime_lo; + unsigned long __shm_dtime_lo; + unsigned long __shm_ctime_lo; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; - unsigned long __pad1; - unsigned long __pad2; + unsigned short __shm_atime_hi; + unsigned short __shm_dtime_hi; + unsigned short __shm_ctime_hi; + unsigned short __pad1; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/mipsn32/bits/socket.h b/libc-top-half/musl/arch/mipsn32/bits/socket.h index b82c7d3..02fbb88 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/socket.h +++ b/libc-top-half/musl/arch/mipsn32/bits/socket.h @@ -1,19 +1,3 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen; - void *msg_control; - socklen_t msg_controllen; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; -}; - #define SOCK_STREAM 2 #define SOCK_DGRAM 1 @@ -32,8 +16,6 @@ struct cmsghdr { #define SO_RCVBUF 0x1002 #define SO_SNDLOWAT 0x1003 #define SO_RCVLOWAT 0x1004 -#define SO_RCVTIMEO 0x1006 -#define SO_SNDTIMEO 0x1005 #define SO_ERROR 0x1007 #define SO_TYPE 0x1008 #define SO_ACCEPTCONN 0x1009 diff --git a/libc-top-half/musl/arch/mipsn32/bits/stat.h b/libc-top-half/musl/arch/mipsn32/bits/stat.h index 27d36b5..6e2f280 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/stat.h +++ b/libc-top-half/musl/arch/mipsn32/bits/stat.h @@ -9,11 +9,15 @@ struct stat { dev_t st_rdev; long __pad2[2]; off_t st_size; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; blksize_t st_blksize; long __pad3; blkcnt_t st_blocks; - long __pad4[14]; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; + long __pad4[2]; }; diff --git a/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in b/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in index d80cafa..2ad48d1 100644 --- a/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in +++ b/libc-top-half/musl/arch/mipsn32/bits/syscall.h.in @@ -92,7 +92,7 @@ #define __NR_fchown 6091 #define __NR_lchown 6092 #define __NR_umask 6093 -#define __NR_gettimeofday 6094 +#define __NR_gettimeofday_time32 6094 #define __NR_getrlimit 6095 #define __NR_getrusage 6096 #define __NR_sysinfo 6097 @@ -157,7 +157,7 @@ #define __NR_chroot 6156 #define __NR_sync 6157 #define __NR_acct 6158 -#define __NR_settimeofday 6159 +#define __NR_settimeofday_time32 6159 #define __NR_mount 6160 #define __NR_umount2 6161 #define __NR_swapon 6162 @@ -219,14 +219,14 @@ #define __NR_fstatfs64 6218 #define __NR_sendfile64 6219 #define __NR_timer_create 6220 -#define __NR_timer_settime 6221 -#define __NR_timer_gettime 6222 +#define __NR_timer_settime32 6221 +#define __NR_timer_gettime32 6222 #define __NR_timer_getoverrun 6223 #define __NR_timer_delete 6224 -#define __NR_clock_settime 6225 -#define __NR_clock_gettime 6226 -#define __NR_clock_getres 6227 -#define __NR_clock_nanosleep 6228 +#define __NR_clock_settime32 6225 +#define __NR_clock_gettime32 6226 +#define __NR_clock_getres_time32 6227 +#define __NR_clock_nanosleep_time32 6228 #define __NR_tgkill 6229 #define __NR_utimes 6230 #define __NR_mbind 6231 @@ -282,8 +282,8 @@ #define __NR_eventfd 6282 #define __NR_fallocate 6283 #define __NR_timerfd_create 6284 -#define __NR_timerfd_gettime 6285 -#define __NR_timerfd_settime 6286 +#define __NR_timerfd_gettime32 6285 +#define __NR_timerfd_settime32 6286 #define __NR_signalfd4 6287 #define __NR_eventfd2 6288 #define __NR_epoll_create1 6289 @@ -360,4 +360,6 @@ #define __NR_fsconfig 6431 #define __NR_fsmount 6432 #define __NR_fspick 6433 +#define __NR_pidfd_open 6434 +#define __NR_clone3 6435 diff --git a/libc-top-half/musl/arch/mipsn32/reloc.h b/libc-top-half/musl/arch/mipsn32/reloc.h index 728aaab..47c6e59 100644 --- a/libc-top-half/musl/arch/mipsn32/reloc.h +++ b/libc-top-half/musl/arch/mipsn32/reloc.h @@ -1,5 +1,3 @@ -#include - #if __mips_isa_rev >= 6 #define ISA_SUFFIX "r6" #else diff --git a/libc-top-half/musl/arch/mipsn32/syscall_arch.h b/libc-top-half/musl/arch/mipsn32/syscall_arch.h index 5ff43bb..c1a4b7d 100644 --- a/libc-top-half/musl/arch/mipsn32/syscall_arch.h +++ b/libc-top-half/musl/arch/mipsn32/syscall_arch.h @@ -116,7 +116,9 @@ static inline long __syscall6(long n, long a, long b, long c, long d, long e, lo } #define VDSO_USEFUL -#define VDSO_CGT_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_SYM "__vdso_clock_gettime" +#define VDSO_CGT32_VER "LINUX_2.6" +#define VDSO_CGT_SYM "__vdso_clock_gettime64" #define VDSO_CGT_VER "LINUX_2.6" #define SO_SNDTIMEO_OLD 0x1005 diff --git a/libc-top-half/musl/arch/or1k/arch.mak b/libc-top-half/musl/arch/or1k/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/or1k/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/or1k/bits/alltypes.h.in b/libc-top-half/musl/arch/or1k/bits/alltypes.h.in index 667963c..7d3e291 100644 --- a/libc-top-half/musl/arch/or1k/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/or1k/bits/alltypes.h.in @@ -1,9 +1,10 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 4321 +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus TYPEDEF unsigned wchar_t; @@ -13,14 +14,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/or1k/bits/endian.h b/libc-top-half/musl/arch/or1k/bits/endian.h deleted file mode 100644 index ef074b7..0000000 --- a/libc-top-half/musl/arch/or1k/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __BIG_ENDIAN diff --git a/libc-top-half/musl/arch/or1k/bits/ipcstat.h b/libc-top-half/musl/arch/or1k/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/or1k/bits/ipcstat.h +++ b/libc-top-half/musl/arch/or1k/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/or1k/bits/limits.h b/libc-top-half/musl/arch/or1k/bits/limits.h index 3a811c9..fac47aa 100644 --- a/libc-top-half/musl/arch/or1k/bits/limits.h +++ b/libc-top-half/musl/arch/or1k/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 8192 -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/or1k/bits/msg.h b/libc-top-half/musl/arch/or1k/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/or1k/bits/msg.h +++ b/libc-top-half/musl/arch/or1k/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/or1k/bits/sem.h b/libc-top-half/musl/arch/or1k/bits/sem.h index 08faafe..d88338e 100644 --- a/libc-top-half/musl/arch/or1k/bits/sem.h +++ b/libc-top-half/musl/arch/or1k/bits/sem.h @@ -1,11 +1,13 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; unsigned short sem_nsems; long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/or1k/bits/shm.h b/libc-top-half/musl/arch/or1k/bits/shm.h index 81b2a29..725fb46 100644 --- a/libc-top-half/musl/arch/or1k/bits/shm.h +++ b/libc-top-half/musl/arch/or1k/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/or1k/bits/stat.h b/libc-top-half/musl/arch/or1k/bits/stat.h index ce6a6bd..cde3fd0 100644 --- a/libc-top-half/musl/arch/or1k/bits/stat.h +++ b/libc-top-half/musl/arch/or1k/bits/stat.h @@ -14,8 +14,12 @@ struct stat { blksize_t st_blksize; int __st_blksize_padding; blkcnt_t st_blocks; - struct timespec st_atim; - struct timespec st_mtim; - struct timespec st_ctim; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; unsigned __unused[2]; + struct timespec st_atim; + struct timespec st_mtim; + struct timespec st_ctim; }; diff --git a/libc-top-half/musl/arch/or1k/bits/syscall.h.in b/libc-top-half/musl/arch/or1k/bits/syscall.h.in index 8ffcfae..e9c925e 100644 --- a/libc-top-half/musl/arch/or1k/bits/syscall.h.in +++ b/libc-top-half/musl/arch/or1k/bits/syscall.h.in @@ -85,8 +85,8 @@ #define __NR_fdatasync 83 #define __NR_sync_file_range 84 #define __NR_timerfd_create 85 -#define __NR_timerfd_settime 86 -#define __NR_timerfd_gettime 87 +#define __NR_timerfd_settime32 86 +#define __NR_timerfd_gettime32 87 #define __NR_utimensat 88 #define __NR_acct 89 #define __NR_capget 90 @@ -107,14 +107,14 @@ #define __NR_init_module 105 #define __NR_delete_module 106 #define __NR_timer_create 107 -#define __NR_timer_gettime 108 +#define __NR_timer_gettime32 108 #define __NR_timer_getoverrun 109 -#define __NR_timer_settime 110 +#define __NR_timer_settime32 110 #define __NR_timer_delete 111 -#define __NR_clock_settime 112 -#define __NR_clock_gettime 113 -#define __NR_clock_getres 114 -#define __NR_clock_nanosleep 115 +#define __NR_clock_settime32 112 +#define __NR_clock_gettime32 113 +#define __NR_clock_getres_time32 114 +#define __NR_clock_nanosleep_time32 115 #define __NR_syslog 116 #define __NR_ptrace 117 #define __NR_sched_setparam 118 @@ -168,8 +168,8 @@ #define __NR_umask 166 #define __NR_prctl 167 #define __NR_getcpu 168 -#define __NR_gettimeofday 169 -#define __NR_settimeofday 170 +#define __NR_gettimeofday_time32 169 +#define __NR_settimeofday_time32 170 #define __NR_adjtimex 171 #define __NR_getpid 172 #define __NR_getppid 173 @@ -309,4 +309,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/powerpc/arch.mak b/libc-top-half/musl/arch/powerpc/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/powerpc/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in b/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in index 8e687ef..b48df6a 100644 --- a/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/powerpc/bits/alltypes.h.in @@ -1,9 +1,10 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 4321 +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus #ifdef __WCHAR_TYPE__ @@ -17,14 +18,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/powerpc/bits/endian.h b/libc-top-half/musl/arch/powerpc/bits/endian.h deleted file mode 100644 index 4442abf..0000000 --- a/libc-top-half/musl/arch/powerpc/bits/endian.h +++ /dev/null @@ -1,15 +0,0 @@ -#ifdef __BIG_ENDIAN__ - #if __BIG_ENDIAN__ - #define __BYTE_ORDER __BIG_ENDIAN - #endif -#endif /* __BIG_ENDIAN__ */ - -#ifdef __LITTLE_ENDIAN__ - #if __LITTLE_ENDIAN__ - #define __BYTE_ORDER __LITTLE_ENDIAN - #endif -#endif /* __LITTLE_ENDIAN__ */ - -#ifndef __BYTE_ORDER - #define __BYTE_ORDER __BIG_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/powerpc/bits/ioctl.h b/libc-top-half/musl/arch/powerpc/bits/ioctl.h index b6cbb18..ac9bfd2 100644 --- a/libc-top-half/musl/arch/powerpc/bits/ioctl.h +++ b/libc-top-half/musl/arch/powerpc/bits/ioctl.h @@ -116,5 +116,5 @@ #define FIOGETOWN 0x8903 #define SIOCGPGRP 0x8904 #define SIOCATMARK 0x8905 -#define SIOCGSTAMP 0x8906 -#define SIOCGSTAMPNS 0x8907 +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) diff --git a/libc-top-half/musl/arch/powerpc/bits/ipcstat.h b/libc-top-half/musl/arch/powerpc/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/powerpc/bits/ipcstat.h +++ b/libc-top-half/musl/arch/powerpc/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/powerpc/bits/limits.h b/libc-top-half/musl/arch/powerpc/bits/limits.h deleted file mode 100644 index fbc6d23..0000000 --- a/libc-top-half/musl/arch/powerpc/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/powerpc/bits/msg.h b/libc-top-half/musl/arch/powerpc/bits/msg.h index 171c11a..9fb15dc 100644 --- a/libc-top-half/musl/arch/powerpc/bits/msg.h +++ b/libc-top-half/musl/arch/powerpc/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - int __unused1; - time_t msg_stime; - int __unused2; - time_t msg_rtime; - int __unused3; - time_t msg_ctime; + unsigned long __msg_stime_hi; + unsigned long __msg_stime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_ctime_hi; + unsigned long __msg_ctime_lo; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/powerpc/bits/sem.h b/libc-top-half/musl/arch/powerpc/bits/sem.h index bc2d6d1..28be484 100644 --- a/libc-top-half/musl/arch/powerpc/bits/sem.h +++ b/libc-top-half/musl/arch/powerpc/bits/sem.h @@ -1,10 +1,12 @@ struct semid_ds { struct ipc_perm sem_perm; - int __unused1; - time_t sem_otime; - int __unused2; - time_t sem_ctime; + unsigned long __sem_otime_hi; + unsigned long __sem_otime_lo; + unsigned long __sem_ctime_hi; + unsigned long __sem_ctime_lo; unsigned short __sem_nsems_pad, sem_nsems; long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/powerpc/bits/shm.h b/libc-top-half/musl/arch/powerpc/bits/shm.h index b19801d..fb1d402 100644 --- a/libc-top-half/musl/arch/powerpc/bits/shm.h +++ b/libc-top-half/musl/arch/powerpc/bits/shm.h @@ -2,19 +2,21 @@ struct shmid_ds { struct ipc_perm shm_perm; - int __unused1; - time_t shm_atime; - int __unused2; - time_t shm_dtime; - int __unused3; - time_t shm_ctime; - int __unused4; + unsigned long __shm_atime_hi; + unsigned long __shm_atime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_ctime_hi; + unsigned long __shm_ctime_lo; size_t shm_segsz; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/powerpc/bits/signal.h b/libc-top-half/musl/arch/powerpc/bits/signal.h index 06efb11..c1bf3ca 100644 --- a/libc-top-half/musl/arch/powerpc/bits/signal.h +++ b/libc-top-half/musl/arch/powerpc/bits/signal.h @@ -28,7 +28,7 @@ struct sigcontext { int signal; unsigned long handler; unsigned long oldmask; - void *regs; + struct pt_regs *regs; }; typedef struct { diff --git a/libc-top-half/musl/arch/powerpc/bits/socket.h b/libc-top-half/musl/arch/powerpc/bits/socket.h index a94b8bd..b19ed42 100644 --- a/libc-top-half/musl/arch/powerpc/bits/socket.h +++ b/libc-top-half/musl/arch/powerpc/bits/socket.h @@ -1,19 +1,3 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen; - void *msg_control; - socklen_t msg_controllen; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; -}; - #define SO_DEBUG 1 #define SO_REUSEADDR 2 #define SO_TYPE 3 @@ -31,8 +15,6 @@ struct cmsghdr { #define SO_REUSEPORT 15 #define SO_RCVLOWAT 16 #define SO_SNDLOWAT 17 -#define SO_RCVTIMEO 18 -#define SO_SNDTIMEO 19 #define SO_PASSCRED 20 #define SO_PEERCRED 21 #define SO_ACCEPTCONN 30 diff --git a/libc-top-half/musl/arch/powerpc/bits/stat.h b/libc-top-half/musl/arch/powerpc/bits/stat.h index dcb896f..585d98e 100644 --- a/libc-top-half/musl/arch/powerpc/bits/stat.h +++ b/libc-top-half/musl/arch/powerpc/bits/stat.h @@ -13,8 +13,12 @@ struct stat { off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + unsigned __unused[2]; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - unsigned __unused[2]; }; diff --git a/libc-top-half/musl/arch/powerpc/bits/syscall.h.in b/libc-top-half/musl/arch/powerpc/bits/syscall.h.in index adcf63d..8d4f79b 100644 --- a/libc-top-half/musl/arch/powerpc/bits/syscall.h.in +++ b/libc-top-half/musl/arch/powerpc/bits/syscall.h.in @@ -76,8 +76,8 @@ #define __NR_setrlimit 75 #define __NR_getrlimit 76 #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_select 82 @@ -238,14 +238,14 @@ #define __NR_epoll_wait 238 #define __NR_remap_file_pages 239 #define __NR_timer_create 240 -#define __NR_timer_settime 241 -#define __NR_timer_gettime 242 +#define __NR_timer_settime32 241 +#define __NR_timer_gettime32 242 #define __NR_timer_getoverrun 243 #define __NR_timer_delete 244 -#define __NR_clock_settime 245 -#define __NR_clock_gettime 246 -#define __NR_clock_getres 247 -#define __NR_clock_nanosleep 248 +#define __NR_clock_settime32 245 +#define __NR_clock_gettime32 246 +#define __NR_clock_getres_time32 247 +#define __NR_clock_nanosleep_time32 248 #define __NR_swapcontext 249 #define __NR_tgkill 250 #define __NR_utimes 251 @@ -307,8 +307,8 @@ #define __NR_sync_file_range2 308 #define __NR_fallocate 309 #define __NR_subpage_prot 310 -#define __NR_timerfd_settime 311 -#define __NR_timerfd_gettime 312 +#define __NR_timerfd_settime32 311 +#define __NR_timerfd_gettime32 312 #define __NR_signalfd4 313 #define __NR_eventfd2 314 #define __NR_epoll_create1 315 @@ -413,4 +413,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/powerpc64/bits/alltypes.h.in b/libc-top-half/musl/arch/powerpc64/bits/alltypes.h.in index 5b20585..143ffa8 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/powerpc64/bits/alltypes.h.in @@ -2,8 +2,13 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if __BIG_ENDIAN__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -13,14 +18,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/powerpc64/bits/endian.h b/libc-top-half/musl/arch/powerpc64/bits/endian.h deleted file mode 100644 index 2016cb2..0000000 --- a/libc-top-half/musl/arch/powerpc64/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __BIG_ENDIAN__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/powerpc64/bits/limits.h b/libc-top-half/musl/arch/powerpc64/bits/limits.h deleted file mode 100644 index 0226588..0000000 --- a/libc-top-half/musl/arch/powerpc64/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/powerpc64/bits/signal.h b/libc-top-half/musl/arch/powerpc64/bits/signal.h index 2cc0604..d5493b1 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/signal.h +++ b/libc-top-half/musl/arch/powerpc64/bits/signal.h @@ -9,11 +9,7 @@ #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) typedef unsigned long greg_t, gregset_t[48]; - -typedef struct { - double fpregs[32]; - double fpscr; -} fpregset_t; +typedef double fpregset_t[33]; typedef struct { #ifdef __GNUC__ @@ -36,7 +32,7 @@ typedef struct sigcontext { int _pad0; unsigned long handler; unsigned long oldmask; - void *regs; + struct pt_regs *regs; gregset_t gp_regs; fpregset_t fp_regs; vrregset_t *v_regs; diff --git a/libc-top-half/musl/arch/powerpc64/bits/socket.h b/libc-top-half/musl/arch/powerpc64/bits/socket.h index 0f3c9aa..557e324 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/socket.h +++ b/libc-top-half/musl/arch/powerpc64/bits/socket.h @@ -1,37 +1,3 @@ -#include - -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1, msg_iovlen; -#else - int msg_iovlen, __pad1; -#endif - void *msg_control; -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad2; - socklen_t msg_controllen; -#else - socklen_t msg_controllen; - int __pad2; -#endif - int msg_flags; -}; - -struct cmsghdr { -#if __BYTE_ORDER == __BIG_ENDIAN - int __pad1; - socklen_t cmsg_len; -#else - socklen_t cmsg_len; - int __pad1; -#endif - int cmsg_level; - int cmsg_type; -}; - #define SO_DEBUG 1 #define SO_REUSEADDR 2 #define SO_TYPE 3 diff --git a/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in b/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in index 32545b3..b935864 100644 --- a/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/powerpc64/bits/syscall.h.in @@ -385,4 +385,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/powerpc64/reloc.h b/libc-top-half/musl/arch/powerpc64/reloc.h index 5bdaeed..2f1bba0 100644 --- a/libc-top-half/musl/arch/powerpc64/reloc.h +++ b/libc-top-half/musl/arch/powerpc64/reloc.h @@ -1,5 +1,3 @@ -#include - #if __BYTE_ORDER == __LITTLE_ENDIAN #define ENDIAN_SUFFIX "le" #else diff --git a/libc-top-half/musl/arch/riscv64/atomic_arch.h b/libc-top-half/musl/arch/riscv64/atomic_arch.h index 41ad4d0..0c38258 100644 --- a/libc-top-half/musl/arch/riscv64/atomic_arch.h +++ b/libc-top-half/musl/arch/riscv64/atomic_arch.h @@ -15,7 +15,7 @@ static inline int a_cas(volatile int *p, int t, int s) " bnez %1, 1b\n" "1:" : "=&r"(old), "=&r"(tmp) - : "r"(p), "r"(t), "r"(s) + : "r"(p), "r"((long)t), "r"((long)s) : "memory"); return old; } diff --git a/libc-top-half/musl/arch/riscv64/bits/alltypes.h.in b/libc-top-half/musl/arch/riscv64/bits/alltypes.h.in index ae9ba41..4579d17 100644 --- a/libc-top-half/musl/arch/riscv64/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/riscv64/bits/alltypes.h.in @@ -2,8 +2,8 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 1234 +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -16,14 +16,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/riscv64/bits/endian.h b/libc-top-half/musl/arch/riscv64/bits/endian.h deleted file mode 100644 index 172c338..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/libc-top-half/musl/arch/riscv64/bits/limits.h b/libc-top-half/musl/arch/riscv64/bits/limits.h deleted file mode 100644 index 0226588..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/limits.h +++ /dev/null @@ -1,7 +0,0 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/riscv64/bits/reg.h b/libc-top-half/musl/arch/riscv64/bits/reg.h index c800788..2633f39 100644 --- a/libc-top-half/musl/arch/riscv64/bits/reg.h +++ b/libc-top-half/musl/arch/riscv64/bits/reg.h @@ -1,8 +1,2 @@ #undef __WORDSIZE #define __WORDSIZE 64 -#define REG_PC 0 -#define REG_RA 1 -#define REG_SP 2 -#define REG_TP 4 -#define REG_S0 8 -#define REG_A0 10 diff --git a/libc-top-half/musl/arch/riscv64/bits/signal.h b/libc-top-half/musl/arch/riscv64/bits/signal.h index 2ff4be3..b006334 100644 --- a/libc-top-half/musl/arch/riscv64/bits/signal.h +++ b/libc-top-half/musl/arch/riscv64/bits/signal.h @@ -35,6 +35,15 @@ typedef struct mcontext_t { union __riscv_mc_fp_state __fpregs; } mcontext_t; +#if defined(_GNU_SOURCE) +#define REG_PC 0 +#define REG_RA 1 +#define REG_SP 2 +#define REG_TP 4 +#define REG_S0 8 +#define REG_A0 10 +#endif + #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) typedef unsigned long greg_t; typedef unsigned long gregset_t[32]; diff --git a/libc-top-half/musl/arch/riscv64/bits/socket.h b/libc-top-half/musl/arch/riscv64/bits/socket.h deleted file mode 100644 index aae537d..0000000 --- a/libc-top-half/musl/arch/riscv64/bits/socket.h +++ /dev/null @@ -1,19 +0,0 @@ -#include - -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen, __pad1; - void *msg_control; - socklen_t msg_controllen; - int __pad2; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int __pad1; - int cmsg_level; - int cmsg_type; -}; diff --git a/libc-top-half/musl/arch/riscv64/bits/syscall.h.in b/libc-top-half/musl/arch/riscv64/bits/syscall.h.in index 1db70cf..0043eeb 100644 --- a/libc-top-half/musl/arch/riscv64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/riscv64/bits/syscall.h.in @@ -287,6 +287,8 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 #define __NR_sysriscv __NR_arch_specific_syscall #define __NR_riscv_flush_icache (__NR_sysriscv + 15) diff --git a/libc-top-half/musl/arch/s390x/bits/alltypes.h.in b/libc-top-half/musl/arch/s390x/bits/alltypes.h.in index 1a83846..15d18c8 100644 --- a/libc-top-half/musl/arch/s390x/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/s390x/bits/alltypes.h.in @@ -2,8 +2,8 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 4321 +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -13,14 +13,3 @@ TYPEDEF double float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/s390x/bits/endian.h b/libc-top-half/musl/arch/s390x/bits/endian.h deleted file mode 100644 index ef074b7..0000000 --- a/libc-top-half/musl/arch/s390x/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __BIG_ENDIAN diff --git a/libc-top-half/musl/arch/s390x/bits/limits.h b/libc-top-half/musl/arch/s390x/bits/limits.h index 86ef766..07743b6 100644 --- a/libc-top-half/musl/arch/s390x/bits/limits.h +++ b/libc-top-half/musl/arch/s390x/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 4096 -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/s390x/bits/socket.h b/libc-top-half/musl/arch/s390x/bits/socket.h deleted file mode 100644 index bd4b20c..0000000 --- a/libc-top-half/musl/arch/s390x/bits/socket.h +++ /dev/null @@ -1,17 +0,0 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int __pad1, msg_iovlen; - void *msg_control; - int __pad2; - socklen_t msg_controllen; - int msg_flags; -}; - -struct cmsghdr { - int __pad1; - socklen_t cmsg_len; - int cmsg_level; - int cmsg_type; -}; diff --git a/libc-top-half/musl/arch/s390x/bits/syscall.h.in b/libc-top-half/musl/arch/s390x/bits/syscall.h.in index c4c7047..e89f378 100644 --- a/libc-top-half/musl/arch/s390x/bits/syscall.h.in +++ b/libc-top-half/musl/arch/s390x/bits/syscall.h.in @@ -350,4 +350,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/arch/s390x/reloc.h b/libc-top-half/musl/arch/s390x/reloc.h index a238dc6..6e5c1fb 100644 --- a/libc-top-half/musl/arch/s390x/reloc.h +++ b/libc-top-half/musl/arch/s390x/reloc.h @@ -1,5 +1,3 @@ -#include - #define LDSO_ARCH "s390x" #define REL_SYMBOLIC R_390_64 diff --git a/libc-top-half/musl/arch/sh/arch.mak b/libc-top-half/musl/arch/sh/arch.mak new file mode 100644 index 0000000..aa4d05c --- /dev/null +++ b/libc-top-half/musl/arch/sh/arch.mak @@ -0,0 +1 @@ +COMPAT_SRC_DIRS = compat/time32 diff --git a/libc-top-half/musl/arch/sh/bits/alltypes.h.in b/libc-top-half/musl/arch/sh/bits/alltypes.h.in index 8e687ef..6a53835 100644 --- a/libc-top-half/musl/arch/sh/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/sh/bits/alltypes.h.in @@ -1,9 +1,15 @@ +#define _REDIR_TIME64 1 #define _Addr int #define _Int64 long long #define _Reg int -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#if __BIG_ENDIAN__ +#define __BYTE_ORDER 4321 +#else +#define __BYTE_ORDER 1234 +#endif + +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus #ifdef __WCHAR_TYPE__ @@ -17,14 +23,3 @@ TYPEDEF float float_t; TYPEDEF double double_t; TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/sh/bits/endian.h b/libc-top-half/musl/arch/sh/bits/endian.h deleted file mode 100644 index 2016cb2..0000000 --- a/libc-top-half/musl/arch/sh/bits/endian.h +++ /dev/null @@ -1,5 +0,0 @@ -#if __BIG_ENDIAN__ -#define __BYTE_ORDER __BIG_ENDIAN -#else -#define __BYTE_ORDER __LITTLE_ENDIAN -#endif diff --git a/libc-top-half/musl/arch/sh/bits/ioctl.h b/libc-top-half/musl/arch/sh/bits/ioctl.h index c430565..370b690 100644 --- a/libc-top-half/musl/arch/sh/bits/ioctl.h +++ b/libc-top-half/musl/arch/sh/bits/ioctl.h @@ -108,5 +108,5 @@ #define SIOCATMARK _IOR('s', 7, int) #define SIOCSPGRP _IOW('s', 8, int) #define SIOCGPGRP _IOW('s', 9, int) -#define SIOCGSTAMP _IOR('s', 100, char[8]) -#define SIOCGSTAMPNS _IOR('s', 101, char[8]) +#define SIOCGSTAMP _IOR(0x89, 6, char[16]) +#define SIOCGSTAMPNS _IOR(0x89, 7, char[16]) diff --git a/libc-top-half/musl/arch/sh/bits/ipcstat.h b/libc-top-half/musl/arch/sh/bits/ipcstat.h index 0018ad1..4f4fcb0 100644 --- a/libc-top-half/musl/arch/sh/bits/ipcstat.h +++ b/libc-top-half/musl/arch/sh/bits/ipcstat.h @@ -1 +1 @@ -#define IPC_STAT 2 +#define IPC_STAT 0x102 diff --git a/libc-top-half/musl/arch/sh/bits/limits.h b/libc-top-half/musl/arch/sh/bits/limits.h index c340ceb..07743b6 100644 --- a/libc-top-half/musl/arch/sh/bits/limits.h +++ b/libc-top-half/musl/arch/sh/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 4096 -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/sh/bits/msg.h b/libc-top-half/musl/arch/sh/bits/msg.h index bc8436c..7bbbb2b 100644 --- a/libc-top-half/musl/arch/sh/bits/msg.h +++ b/libc-top-half/musl/arch/sh/bits/msg.h @@ -1,15 +1,18 @@ struct msqid_ds { struct ipc_perm msg_perm; - time_t msg_stime; - int __unused1; - time_t msg_rtime; - int __unused2; - time_t msg_ctime; - int __unused3; + unsigned long __msg_stime_lo; + unsigned long __msg_stime_hi; + unsigned long __msg_rtime_lo; + unsigned long __msg_rtime_hi; + unsigned long __msg_ctime_lo; + unsigned long __msg_ctime_hi; unsigned long msg_cbytes; msgqnum_t msg_qnum; msglen_t msg_qbytes; pid_t msg_lspid; pid_t msg_lrpid; unsigned long __unused[2]; + time_t msg_stime; + time_t msg_rtime; + time_t msg_ctime; }; diff --git a/libc-top-half/musl/arch/sh/bits/sem.h b/libc-top-half/musl/arch/sh/bits/sem.h index d383d4e..544e3d2 100644 --- a/libc-top-half/musl/arch/sh/bits/sem.h +++ b/libc-top-half/musl/arch/sh/bits/sem.h @@ -1,9 +1,9 @@ struct semid_ds { struct ipc_perm sem_perm; - time_t sem_otime; - long __unused1; - time_t sem_ctime; - long __unused2; + unsigned long __sem_otime_lo; + unsigned long __sem_otime_hi; + unsigned long __sem_ctime_lo; + unsigned long __sem_ctime_hi; #if __BYTE_ORDER == __LITTLE_ENDIAN unsigned short sem_nsems; char __sem_nsems_pad[sizeof(long)-sizeof(short)]; @@ -13,4 +13,6 @@ struct semid_ds { #endif long __unused3; long __unused4; + time_t sem_otime; + time_t sem_ctime; }; diff --git a/libc-top-half/musl/arch/sh/bits/shm.h b/libc-top-half/musl/arch/sh/bits/shm.h index 6cdac13..adc01e3 100644 --- a/libc-top-half/musl/arch/sh/bits/shm.h +++ b/libc-top-half/musl/arch/sh/bits/shm.h @@ -3,17 +3,21 @@ struct shmid_ds { struct ipc_perm shm_perm; size_t shm_segsz; - time_t shm_atime; - int __unused1; - time_t shm_dtime; - int __unused2; - time_t shm_ctime; - int __unused3; + unsigned long __shm_atime_lo; + unsigned long __shm_atime_hi; + unsigned long __shm_dtime_lo; + unsigned long __shm_dtime_hi; + unsigned long __shm_ctime_lo; + unsigned long __shm_ctime_hi; pid_t shm_cpid; pid_t shm_lpid; unsigned long shm_nattch; unsigned long __pad1; unsigned long __pad2; + unsigned long __pad3; + time_t shm_atime; + time_t shm_dtime; + time_t shm_ctime; }; struct shminfo { diff --git a/libc-top-half/musl/arch/sh/bits/stat.h b/libc-top-half/musl/arch/sh/bits/stat.h index 22b19bb..5d7828c 100644 --- a/libc-top-half/musl/arch/sh/bits/stat.h +++ b/libc-top-half/musl/arch/sh/bits/stat.h @@ -14,8 +14,12 @@ struct stat { off_t st_size; blksize_t st_blksize; blkcnt_t st_blocks; + struct { + long tv_sec; + long tv_nsec; + } __st_atim32, __st_mtim32, __st_ctim32; + ino_t st_ino; struct timespec st_atim; struct timespec st_mtim; struct timespec st_ctim; - ino_t st_ino; }; diff --git a/libc-top-half/musl/arch/sh/bits/syscall.h.in b/libc-top-half/musl/arch/sh/bits/syscall.h.in index 4705ef9..0102dda 100644 --- a/libc-top-half/musl/arch/sh/bits/syscall.h.in +++ b/libc-top-half/musl/arch/sh/bits/syscall.h.in @@ -67,8 +67,8 @@ #define __NR_setrlimit 75 #define __NR_getrlimit 76 #define __NR_getrusage 77 -#define __NR_gettimeofday 78 -#define __NR_settimeofday 79 +#define __NR_gettimeofday_time32 78 +#define __NR_settimeofday_time32 79 #define __NR_getgroups 80 #define __NR_setgroups 81 #define __NR_symlink 83 @@ -231,14 +231,14 @@ #define __NR_remap_file_pages 257 #define __NR_set_tid_address 258 #define __NR_timer_create 259 -#define __NR_timer_settime 260 -#define __NR_timer_gettime 261 +#define __NR_timer_settime32 260 +#define __NR_timer_gettime32 261 #define __NR_timer_getoverrun 262 #define __NR_timer_delete 263 -#define __NR_clock_settime 264 -#define __NR_clock_gettime 265 -#define __NR_clock_getres 266 -#define __NR_clock_nanosleep 267 +#define __NR_clock_settime32 264 +#define __NR_clock_gettime32 265 +#define __NR_clock_getres_time32 266 +#define __NR_clock_nanosleep_time32 267 #define __NR_statfs64 268 #define __NR_fstatfs64 269 #define __NR_tgkill 270 @@ -294,8 +294,8 @@ #define __NR_timerfd_create 322 #define __NR_eventfd 323 #define __NR_fallocate 324 -#define __NR_timerfd_settime 325 -#define __NR_timerfd_gettime 326 +#define __NR_timerfd_settime32 325 +#define __NR_timerfd_gettime32 326 #define __NR_signalfd4 327 #define __NR_eventfd2 328 #define __NR_epoll_create1 329 @@ -397,4 +397,5 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 diff --git a/libc-top-half/musl/arch/sh/reloc.h b/libc-top-half/musl/arch/sh/reloc.h index a1f16cb..17b1a9a 100644 --- a/libc-top-half/musl/arch/sh/reloc.h +++ b/libc-top-half/musl/arch/sh/reloc.h @@ -1,5 +1,3 @@ -#include - #if __BYTE_ORDER == __BIG_ENDIAN #define ENDIAN_SUFFIX "eb" #else diff --git a/libc-top-half/musl/arch/wasm32/bits/alltypes.h.in b/libc-top-half/musl/arch/wasm32/bits/alltypes.h.in index 1b4fe67..5dcfc9a 100644 --- a/libc-top-half/musl/arch/wasm32/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/wasm32/bits/alltypes.h.in @@ -2,18 +2,15 @@ #define _Int64 long long #define _Reg long long +#define __BYTE_ORDER __BYTE_ORDER__ + +#define __LONG_MAX __LONG_MAX__ + /* * Rather than define everything ourselves here in the musl layer, for * WASI, reference the definitions in the lower layers. */ -#if defined(__NEED_va_list) && !defined(__DEFINED_va_list) -#include -#define __DEFINED_va_list -#endif - -TYPEDEF __builtin_va_list __isoc_va_list; - #if defined(__NEED_wchar_t) && !defined(__DEFINED_wchar_t) #define __need_wchar_t #include @@ -59,12 +56,3 @@ TYPEDEF double double_t; #include <__typedef_clock_t.h> #define __DEFINED_clock_t #endif - -/* TODO: Threads support. */ -TYPEDEF unsigned char pthread_attr_t; -TYPEDEF unsigned char pthread_mutex_t; -TYPEDEF unsigned char mtx_t; -TYPEDEF unsigned char pthread_cond_t; -TYPEDEF unsigned char cnd_t; -TYPEDEF unsigned char pthread_rwlock_t; -TYPEDEF unsigned char pthread_barrier_t; diff --git a/libc-top-half/musl/arch/wasm32/bits/dirent.h b/libc-top-half/musl/arch/wasm32/bits/dirent.h new file mode 100644 index 0000000..55f2bc9 --- /dev/null +++ b/libc-top-half/musl/arch/wasm32/bits/dirent.h @@ -0,0 +1 @@ +#include <__struct_dirent.h> diff --git a/libc-top-half/musl/arch/wasm32/bits/endian.h b/libc-top-half/musl/arch/wasm32/bits/endian.h deleted file mode 100644 index 172c338..0000000 --- a/libc-top-half/musl/arch/wasm32/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/libc-top-half/musl/arch/wasm32/bits/limits.h b/libc-top-half/musl/arch/wasm32/bits/limits.h index 0589f25..801bc48 100644 --- a/libc-top-half/musl/arch/wasm32/bits/limits.h +++ b/libc-top-half/musl/arch/wasm32/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #include <__macro_PAGESIZE.h> -#define LONG_BIT (32) -#endif - -#define LONG_MAX (0x7fffffffL) -#define LLONG_MAX (0x7fffffffffffffffLL) diff --git a/libc-top-half/musl/arch/wasm32/bits/socket.h b/libc-top-half/musl/arch/wasm32/bits/socket.h deleted file mode 100644 index d8ea454..0000000 --- a/libc-top-half/musl/arch/wasm32/bits/socket.h +++ /dev/null @@ -1 +0,0 @@ -#include <__struct_msghdr.h> diff --git a/libc-top-half/musl/arch/x32/bits/alltypes.h.in b/libc-top-half/musl/arch/x32/bits/alltypes.h.in index c612eec..9f9d241 100644 --- a/libc-top-half/musl/arch/x32/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/x32/bits/alltypes.h.in @@ -2,8 +2,8 @@ #define _Int64 long long #define _Reg long long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 1234 +#define __LONG_MAX 0x7fffffffL #ifndef __cplusplus #ifdef __WCHAR_TYPE__ @@ -22,14 +22,3 @@ TYPEDEF double double_t; #endif TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long long time_t; -TYPEDEF long long suseconds_t; - -TYPEDEF struct { union { int __i[9]; volatile int __vi[9]; unsigned __s[9]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[6]; volatile int __vi[6]; volatile void *volatile __p[6]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[8]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[5]; volatile int __vi[5]; void *__p[5]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/x32/bits/endian.h b/libc-top-half/musl/arch/x32/bits/endian.h deleted file mode 100644 index 172c338..0000000 --- a/libc-top-half/musl/arch/x32/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/libc-top-half/musl/arch/x32/bits/ioctl_fix.h b/libc-top-half/musl/arch/x32/bits/ioctl_fix.h new file mode 100644 index 0000000..83b957b --- /dev/null +++ b/libc-top-half/musl/arch/x32/bits/ioctl_fix.h @@ -0,0 +1,4 @@ +#undef SIOCGSTAMP +#undef SIOCGSTAMPNS +#define SIOCGSTAMP 0x8906 +#define SIOCGSTAMPNS 0x8907 diff --git a/libc-top-half/musl/arch/x32/bits/limits.h b/libc-top-half/musl/arch/x32/bits/limits.h index c340ceb..07743b6 100644 --- a/libc-top-half/musl/arch/x32/bits/limits.h +++ b/libc-top-half/musl/arch/x32/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 4096 -#define LONG_BIT 32 -#endif - -#define LONG_MAX 0x7fffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/x32/bits/socket.h b/libc-top-half/musl/arch/x32/bits/socket.h index a4c89f3..8d83001 100644 --- a/libc-top-half/musl/arch/x32/bits/socket.h +++ b/libc-top-half/musl/arch/x32/bits/socket.h @@ -1,16 +1,5 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen, __pad1; - void *msg_control; - socklen_t msg_controllen, __pad2; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int __pad1; - int cmsg_level; - int cmsg_type; -}; +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#define SO_TIMESTAMP 29 +#define SO_TIMESTAMPNS 35 +#define SO_TIMESTAMPING 37 diff --git a/libc-top-half/musl/arch/x32/bits/syscall.h.in b/libc-top-half/musl/arch/x32/bits/syscall.h.in index 4d72852..f47bdee 100644 --- a/libc-top-half/musl/arch/x32/bits/syscall.h.in +++ b/libc-top-half/musl/arch/x32/bits/syscall.h.in @@ -296,6 +296,9 @@ #define __NR_fsconfig (0x40000000 + 431) #define __NR_fsmount (0x40000000 + 432) #define __NR_fspick (0x40000000 + 433) +#define __NR_pidfd_open (0x40000000 + 434) +#define __NR_clone3 (0x40000000 + 435) + #define __NR_rt_sigaction (0x40000000 + 512) #define __NR_rt_sigreturn (0x40000000 + 513) diff --git a/libc-top-half/musl/arch/x32/syscall_arch.h b/libc-top-half/musl/arch/x32/syscall_arch.h index e0a2216..e0111cc 100644 --- a/libc-top-half/musl/arch/x32/syscall_arch.h +++ b/libc-top-half/musl/arch/x32/syscall_arch.h @@ -87,5 +87,7 @@ static __inline long __syscall6(long long n, long long a1, long long a2, long lo #define SYS_rt_sigtimedwait_time64 SYS_rt_sigtimedwait #define SYS_futex_time64 SYS_futex #define SYS_sched_rr_get_interval_time64 SYS_sched_rr_get_interval +#define SYS_getrusage_time64 SYS_getrusage +#define SYS_wait4_time64 SYS_wait4 #define IPC_64 0 diff --git a/libc-top-half/musl/arch/x86_64/bits/alltypes.h.in b/libc-top-half/musl/arch/x86_64/bits/alltypes.h.in index dc551d4..5cd8a29 100644 --- a/libc-top-half/musl/arch/x86_64/bits/alltypes.h.in +++ b/libc-top-half/musl/arch/x86_64/bits/alltypes.h.in @@ -2,8 +2,8 @@ #define _Int64 long #define _Reg long -TYPEDEF __builtin_va_list va_list; -TYPEDEF __builtin_va_list __isoc_va_list; +#define __BYTE_ORDER 1234 +#define __LONG_MAX 0x7fffffffffffffffL #ifndef __cplusplus TYPEDEF int wchar_t; @@ -18,14 +18,3 @@ TYPEDEF double double_t; #endif TYPEDEF struct { long long __ll; long double __ld; } max_align_t; - -TYPEDEF long time_t; -TYPEDEF long suseconds_t; - -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; unsigned long __s[7]; } __u; } pthread_attr_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } pthread_mutex_t; -TYPEDEF struct { union { int __i[10]; volatile int __vi[10]; volatile void *volatile __p[5]; } __u; } mtx_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } pthread_cond_t; -TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[6]; } __u; } cnd_t; -TYPEDEF struct { union { int __i[14]; volatile int __vi[14]; void *__p[7]; } __u; } pthread_rwlock_t; -TYPEDEF struct { union { int __i[8]; volatile int __vi[8]; void *__p[4]; } __u; } pthread_barrier_t; diff --git a/libc-top-half/musl/arch/x86_64/bits/endian.h b/libc-top-half/musl/arch/x86_64/bits/endian.h deleted file mode 100644 index 172c338..0000000 --- a/libc-top-half/musl/arch/x86_64/bits/endian.h +++ /dev/null @@ -1 +0,0 @@ -#define __BYTE_ORDER __LITTLE_ENDIAN diff --git a/libc-top-half/musl/arch/x86_64/bits/limits.h b/libc-top-half/musl/arch/x86_64/bits/limits.h index 86ef766..07743b6 100644 --- a/libc-top-half/musl/arch/x86_64/bits/limits.h +++ b/libc-top-half/musl/arch/x86_64/bits/limits.h @@ -1,8 +1 @@ -#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ - || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) #define PAGESIZE 4096 -#define LONG_BIT 64 -#endif - -#define LONG_MAX 0x7fffffffffffffffL -#define LLONG_MAX 0x7fffffffffffffffLL diff --git a/libc-top-half/musl/arch/x86_64/bits/socket.h b/libc-top-half/musl/arch/x86_64/bits/socket.h deleted file mode 100644 index a4c89f3..0000000 --- a/libc-top-half/musl/arch/x86_64/bits/socket.h +++ /dev/null @@ -1,16 +0,0 @@ -struct msghdr { - void *msg_name; - socklen_t msg_namelen; - struct iovec *msg_iov; - int msg_iovlen, __pad1; - void *msg_control; - socklen_t msg_controllen, __pad2; - int msg_flags; -}; - -struct cmsghdr { - socklen_t cmsg_len; - int __pad1; - int cmsg_level; - int cmsg_type; -}; diff --git a/libc-top-half/musl/arch/x86_64/bits/syscall.h.in b/libc-top-half/musl/arch/x86_64/bits/syscall.h.in index 2d4634f..6a646ad 100644 --- a/libc-top-half/musl/arch/x86_64/bits/syscall.h.in +++ b/libc-top-half/musl/arch/x86_64/bits/syscall.h.in @@ -343,4 +343,6 @@ #define __NR_fsconfig 431 #define __NR_fsmount 432 #define __NR_fspick 433 +#define __NR_pidfd_open 434 +#define __NR_clone3 435 diff --git a/libc-top-half/musl/compat/time32/__xstat.c b/libc-top-half/musl/compat/time32/__xstat.c new file mode 100644 index 0000000..acfbd3c --- /dev/null +++ b/libc-top-half/musl/compat/time32/__xstat.c @@ -0,0 +1,24 @@ +#include "time32.h" +#include + +struct stat32; + +int __fxstat64(int ver, int fd, struct stat32 *buf) +{ + return __fstat_time32(fd, buf); +} + +int __fxstatat64(int ver, int fd, const char *path, struct stat32 *buf, int flag) +{ + return __fstatat_time32(fd, path, buf, flag); +} + +int __lxstat64(int ver, const char *path, struct stat32 *buf) +{ + return __lstat_time32(path, buf); +} + +int __xstat64(int ver, const char *path, struct stat32 *buf) +{ + return __stat_time32(path, buf); +} diff --git a/libc-top-half/musl/compat/time32/adjtime32.c b/libc-top-half/musl/compat/time32/adjtime32.c new file mode 100644 index 0000000..b0042c6 --- /dev/null +++ b/libc-top-half/musl/compat/time32/adjtime32.c @@ -0,0 +1,21 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include +#include + +int __adjtime32(const struct timeval32 *in32, struct timeval32 *out32) +{ + struct timeval out; + int r = adjtime((&(struct timeval){ + .tv_sec = in32->tv_sec, + .tv_usec = in32->tv_usec}), &out); + if (r) return r; + /* We can't range-check the result because success was already + * committed by the above call. */ + if (out32) { + out32->tv_sec = out.tv_sec; + out32->tv_usec = out.tv_usec; + } + return r; +} diff --git a/libc-top-half/musl/compat/time32/adjtimex_time32.c b/libc-top-half/musl/compat/time32/adjtimex_time32.c new file mode 100644 index 0000000..9c6f190 --- /dev/null +++ b/libc-top-half/musl/compat/time32/adjtimex_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#include +#include + +struct timex32; + +int __adjtimex_time32(struct timex32 *tx32) +{ + return __clock_adjtime32(CLOCK_REALTIME, tx32); +} diff --git a/libc-top-half/musl/compat/time32/aio_suspend_time32.c b/libc-top-half/musl/compat/time32/aio_suspend_time32.c new file mode 100644 index 0000000..ed5119b --- /dev/null +++ b/libc-top-half/musl/compat/time32/aio_suspend_time32.c @@ -0,0 +1,11 @@ +#include "time32.h" +#include +#include + +int __aio_suspend_time32(const struct aiocb *const cbs[], int cnt, const struct timespec32 *ts32) +{ + return aio_suspend(cbs, cnt, ts32 ? (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); +} + +weak_alias(aio_suspend, aio_suspend64); diff --git a/libc-top-half/musl/compat/time32/clock_adjtime32.c b/libc-top-half/musl/compat/time32/clock_adjtime32.c new file mode 100644 index 0000000..5a25b8a --- /dev/null +++ b/libc-top-half/musl/compat/time32/clock_adjtime32.c @@ -0,0 +1,70 @@ +#include "time32.h" +#include +#include +#include +#include +#include + +struct timex32 { + unsigned modes; + long offset, freq, maxerror, esterror; + int status; + long constant, precision, tolerance; + struct timeval32 time; + long tick, ppsfreq, jitter; + int shift; + long stabil, jitcnt, calcnt, errcnt, stbcnt; + int tai; + int __padding[11]; +}; + +int __clock_adjtime32(clockid_t clock_id, struct timex32 *tx32) +{ + struct timex utx = { + .modes = tx32->modes, + .offset = tx32->offset, + .freq = tx32->freq, + .maxerror = tx32->maxerror, + .esterror = tx32->esterror, + .status = tx32->status, + .constant = tx32->constant, + .precision = tx32->precision, + .tolerance = tx32->tolerance, + .time.tv_sec = tx32->time.tv_sec, + .time.tv_usec = tx32->time.tv_usec, + .tick = tx32->tick, + .ppsfreq = tx32->ppsfreq, + .jitter = tx32->jitter, + .shift = tx32->shift, + .stabil = tx32->stabil, + .jitcnt = tx32->jitcnt, + .calcnt = tx32->calcnt, + .errcnt = tx32->errcnt, + .stbcnt = tx32->stbcnt, + .tai = tx32->tai, + }; + int r = clock_adjtime(clock_id, &utx); + if (r<0) return r; + tx32->modes = utx.modes; + tx32->offset = utx.offset; + tx32->freq = utx.freq; + tx32->maxerror = utx.maxerror; + tx32->esterror = utx.esterror; + tx32->status = utx.status; + tx32->constant = utx.constant; + tx32->precision = utx.precision; + tx32->tolerance = utx.tolerance; + tx32->time.tv_sec = utx.time.tv_sec; + tx32->time.tv_usec = utx.time.tv_usec; + tx32->tick = utx.tick; + tx32->ppsfreq = utx.ppsfreq; + tx32->jitter = utx.jitter; + tx32->shift = utx.shift; + tx32->stabil = utx.stabil; + tx32->jitcnt = utx.jitcnt; + tx32->calcnt = utx.calcnt; + tx32->errcnt = utx.errcnt; + tx32->stbcnt = utx.stbcnt; + tx32->tai = utx.tai; + return r; +} diff --git a/libc-top-half/musl/compat/time32/clock_getres_time32.c b/libc-top-half/musl/compat/time32/clock_getres_time32.c new file mode 100644 index 0000000..47a24c1 --- /dev/null +++ b/libc-top-half/musl/compat/time32/clock_getres_time32.c @@ -0,0 +1,13 @@ +#include "time32.h" +#include + +int __clock_getres_time32(clockid_t clk, struct timespec32 *ts32) +{ + struct timespec ts; + int r = clock_getres(clk, &ts); + if (!r && ts32) { + ts32->tv_sec = ts.tv_sec; + ts32->tv_nsec = ts.tv_nsec; + } + return r; +} diff --git a/libc-top-half/musl/compat/time32/clock_gettime32.c b/libc-top-half/musl/compat/time32/clock_gettime32.c new file mode 100644 index 0000000..0cac7bb --- /dev/null +++ b/libc-top-half/musl/compat/time32/clock_gettime32.c @@ -0,0 +1,18 @@ +#include "time32.h" +#include +#include +#include + +int __clock_gettime32(clockid_t clk, struct timespec32 *ts32) +{ + struct timespec ts; + int r = clock_gettime(clk, &ts); + if (r) return r; + if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + ts32->tv_sec = ts.tv_sec; + ts32->tv_nsec = ts.tv_nsec; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/clock_nanosleep_time32.c b/libc-top-half/musl/compat/time32/clock_nanosleep_time32.c new file mode 100644 index 0000000..91ef067 --- /dev/null +++ b/libc-top-half/musl/compat/time32/clock_nanosleep_time32.c @@ -0,0 +1,15 @@ +#include "time32.h" +#include +#include + +int __clock_nanosleep_time32(clockid_t clk, int flags, const struct timespec32 *req32, struct timespec32 *rem32) +{ + struct timespec rem; + int ret = clock_nanosleep(clk, flags, (&(struct timespec){ + .tv_sec = req32->tv_sec, .tv_nsec = req32->tv_nsec}), &rem); + if (ret==EINTR && rem32 && !(flags & TIMER_ABSTIME)) { + rem32->tv_sec = rem.tv_sec; + rem32->tv_nsec = rem.tv_nsec; + } + return ret; +} diff --git a/libc-top-half/musl/compat/time32/clock_settime32.c b/libc-top-half/musl/compat/time32/clock_settime32.c new file mode 100644 index 0000000..7ca4f0e --- /dev/null +++ b/libc-top-half/musl/compat/time32/clock_settime32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include + +int __clock_settime32(clockid_t clk, const struct timespec32 *ts32) +{ + return clock_settime(clk, (&(struct timespec){ + .tv_sec = ts32->tv_sec, + .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/cnd_timedwait_time32.c b/libc-top-half/musl/compat/time32/cnd_timedwait_time32.c new file mode 100644 index 0000000..314251d --- /dev/null +++ b/libc-top-half/musl/compat/time32/cnd_timedwait_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __cnd_timedwait_time32(cnd_t *restrict c, mtx_t *restrict m, const struct timespec32 *restrict ts32) +{ + return cnd_timedwait(c, m, ts32 ? (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); +} diff --git a/libc-top-half/musl/compat/time32/ctime32.c b/libc-top-half/musl/compat/time32/ctime32.c new file mode 100644 index 0000000..a057274 --- /dev/null +++ b/libc-top-half/musl/compat/time32/ctime32.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +char *__ctime32(time32_t *t) +{ + return ctime(&(time_t){*t}); +} diff --git a/libc-top-half/musl/compat/time32/ctime32_r.c b/libc-top-half/musl/compat/time32/ctime32_r.c new file mode 100644 index 0000000..e1ad2e2 --- /dev/null +++ b/libc-top-half/musl/compat/time32/ctime32_r.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +char *__ctime32_r(time32_t *t, char *buf) +{ + return ctime_r(&(time_t){*t}, buf); +} diff --git a/libc-top-half/musl/compat/time32/difftime32.c b/libc-top-half/musl/compat/time32/difftime32.c new file mode 100644 index 0000000..5950943 --- /dev/null +++ b/libc-top-half/musl/compat/time32/difftime32.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +double __difftime32(time32_t t1, time32_t t2) +{ + return difftime(t1, t2); +} diff --git a/libc-top-half/musl/compat/time32/fstat_time32.c b/libc-top-half/musl/compat/time32/fstat_time32.c new file mode 100644 index 0000000..3e08439 --- /dev/null +++ b/libc-top-half/musl/compat/time32/fstat_time32.c @@ -0,0 +1,17 @@ +#include "time32.h" +#include +#include +#include +#include + +struct stat32; + +int __fstat_time32(int fd, struct stat32 *restrict st32) +{ + struct stat st; + int r = fstat(fd, &st); + if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); + return r; +} + +weak_alias(fstat, fstat64); diff --git a/libc-top-half/musl/compat/time32/fstatat_time32.c b/libc-top-half/musl/compat/time32/fstatat_time32.c new file mode 100644 index 0000000..85dcb00 --- /dev/null +++ b/libc-top-half/musl/compat/time32/fstatat_time32.c @@ -0,0 +1,17 @@ +#include "time32.h" +#include +#include +#include +#include + +struct stat32; + +int __fstatat_time32(int fd, const char *restrict path, struct stat32 *restrict st32, int flag) +{ + struct stat st; + int r = fstatat(fd, path, &st, flag); + if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); + return r; +} + +weak_alias(fstatat, fstatat64); diff --git a/libc-top-half/musl/compat/time32/ftime32.c b/libc-top-half/musl/compat/time32/ftime32.c new file mode 100644 index 0000000..166a6da --- /dev/null +++ b/libc-top-half/musl/compat/time32/ftime32.c @@ -0,0 +1,25 @@ +#include "time32.h" +#include +#include +#include + +struct timeb32 { + int32_t time; + unsigned short millitm; + short timezone, dstflag; +}; + +int __ftime32(struct timeb32 *tp) +{ + struct timeb tb; + if (ftime(&tb) < 0) return -1; + if (tb.time < INT32_MIN || tb.time > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + tp->time = tb.time; + tp->millitm = tb.millitm; + tp->timezone = tb.timezone; + tp->dstflag = tb.dstflag; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/futimens_time32.c b/libc-top-half/musl/compat/time32/futimens_time32.c new file mode 100644 index 0000000..7856f17 --- /dev/null +++ b/libc-top-half/musl/compat/time32/futimens_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#include +#include + +int __futimens_time32(int fd, const struct timespec32 *times32) +{ + return futimens(fd, !times32 ? 0 : ((struct timespec[2]){ + {.tv_sec = times32[0].tv_sec,.tv_nsec = times32[0].tv_nsec}, + {.tv_sec = times32[1].tv_sec,.tv_nsec = times32[1].tv_nsec}})); +} diff --git a/libc-top-half/musl/compat/time32/futimes_time32.c b/libc-top-half/musl/compat/time32/futimes_time32.c new file mode 100644 index 0000000..f29533f --- /dev/null +++ b/libc-top-half/musl/compat/time32/futimes_time32.c @@ -0,0 +1,12 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include +#include + +int __futimes_time32(int fd, const struct timeval32 times32[2]) +{ + return futimes(fd, !times32 ? 0 : ((struct timeval[2]){ + {.tv_sec = times32[0].tv_sec,.tv_usec = times32[0].tv_usec}, + {.tv_sec = times32[1].tv_sec,.tv_usec = times32[1].tv_usec}})); +} diff --git a/libc-top-half/musl/compat/time32/futimesat_time32.c b/libc-top-half/musl/compat/time32/futimesat_time32.c new file mode 100644 index 0000000..5a1295b --- /dev/null +++ b/libc-top-half/musl/compat/time32/futimesat_time32.c @@ -0,0 +1,12 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include +#include + +int __futimesat_time32(int dirfd, const char *pathname, const struct timeval32 times32[2]) +{ + return futimesat(dirfd, pathname, !times32 ? 0 : ((struct timeval[2]){ + {.tv_sec = times32[0].tv_sec,.tv_usec = times32[0].tv_usec}, + {.tv_sec = times32[1].tv_sec,.tv_usec = times32[1].tv_usec}})); +} diff --git a/libc-top-half/musl/compat/time32/getitimer_time32.c b/libc-top-half/musl/compat/time32/getitimer_time32.c new file mode 100644 index 0000000..4bac4bf --- /dev/null +++ b/libc-top-half/musl/compat/time32/getitimer_time32.c @@ -0,0 +1,15 @@ +#include "time32.h" +#include +#include + +int __getitimer_time32(int which, struct itimerval32 *old32) +{ + struct itimerval old; + int r = getitimer(which, &old); + if (r) return r; + old32->it_interval.tv_sec = old.it_interval.tv_sec; + old32->it_interval.tv_usec = old.it_interval.tv_usec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_usec = old.it_value.tv_usec; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/getrusage_time32.c b/libc-top-half/musl/compat/time32/getrusage_time32.c new file mode 100644 index 0000000..d7487de --- /dev/null +++ b/libc-top-half/musl/compat/time32/getrusage_time32.c @@ -0,0 +1,39 @@ +#include "time32.h" +#include +#include +#include + +struct compat_rusage { + struct timeval32 ru_utime; + struct timeval32 ru_stime; + long ru_maxrss; + long ru_ixrss; + long ru_idrss; + long ru_isrss; + long ru_minflt; + long ru_majflt; + long ru_nswap; + long ru_inblock; + long ru_oublock; + long ru_msgsnd; + long ru_msgrcv; + long ru_nsignals; + long ru_nvcsw; + long ru_nivcsw; +}; + +int __getrusage_time32(int who, struct compat_rusage *usage) +{ + struct rusage ru; + int r = getrusage(who, &ru); + if (!r) { + usage->ru_utime.tv_sec = ru.ru_utime.tv_sec; + usage->ru_utime.tv_usec = ru.ru_utime.tv_usec; + usage->ru_stime.tv_sec = ru.ru_stime.tv_sec; + usage->ru_stime.tv_usec = ru.ru_stime.tv_usec; + memcpy(&usage->ru_maxrss, &ru.ru_maxrss, + sizeof(struct compat_rusage) - + offsetof(struct compat_rusage, ru_maxrss)); + } + return r; +} diff --git a/libc-top-half/musl/compat/time32/gettimeofday_time32.c b/libc-top-half/musl/compat/time32/gettimeofday_time32.c new file mode 100644 index 0000000..1f3ce68 --- /dev/null +++ b/libc-top-half/musl/compat/time32/gettimeofday_time32.c @@ -0,0 +1,19 @@ +#include "time32.h" +#include +#include +#include + +int __gettimeofday_time32(struct timeval32 *tv32, void *tz) +{ + struct timeval tv; + if (!tv32) return 0; + int r = gettimeofday(&tv, 0); + if (r) return r; + if (tv.tv_sec < INT32_MIN || tv.tv_sec > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + tv32->tv_sec = tv.tv_sec; + tv32->tv_usec = tv.tv_usec; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/gmtime32.c b/libc-top-half/musl/compat/time32/gmtime32.c new file mode 100644 index 0000000..963f0e0 --- /dev/null +++ b/libc-top-half/musl/compat/time32/gmtime32.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +struct tm *__gmtime32(time32_t *t) +{ + return gmtime(&(time_t){*t}); +} diff --git a/libc-top-half/musl/compat/time32/gmtime32_r.c b/libc-top-half/musl/compat/time32/gmtime32_r.c new file mode 100644 index 0000000..7d72bfb --- /dev/null +++ b/libc-top-half/musl/compat/time32/gmtime32_r.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +struct tm *__gmtime32_r(time32_t *t, struct tm *tm) +{ + return gmtime_r(&(time_t){*t}, tm); +} diff --git a/libc-top-half/musl/compat/time32/localtime32.c b/libc-top-half/musl/compat/time32/localtime32.c new file mode 100644 index 0000000..96bc303 --- /dev/null +++ b/libc-top-half/musl/compat/time32/localtime32.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +struct tm *__localtime32(time32_t *t) +{ + return localtime(&(time_t){*t}); +} diff --git a/libc-top-half/musl/compat/time32/localtime32_r.c b/libc-top-half/musl/compat/time32/localtime32_r.c new file mode 100644 index 0000000..633ec82 --- /dev/null +++ b/libc-top-half/musl/compat/time32/localtime32_r.c @@ -0,0 +1,7 @@ +#include "time32.h" +#include + +struct tm *__localtime32_r(time32_t *t, struct tm *tm) +{ + return localtime_r(&(time_t){*t}, tm); +} diff --git a/libc-top-half/musl/compat/time32/lstat_time32.c b/libc-top-half/musl/compat/time32/lstat_time32.c new file mode 100644 index 0000000..c1257a1 --- /dev/null +++ b/libc-top-half/musl/compat/time32/lstat_time32.c @@ -0,0 +1,17 @@ +#include "time32.h" +#include +#include +#include +#include + +struct stat32; + +int __lstat_time32(const char *restrict path, struct stat32 *restrict st32) +{ + struct stat st; + int r = lstat(path, &st); + if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); + return r; +} + +weak_alias(lstat, lstat64); diff --git a/libc-top-half/musl/compat/time32/lutimes_time32.c b/libc-top-half/musl/compat/time32/lutimes_time32.c new file mode 100644 index 0000000..7f75cd4 --- /dev/null +++ b/libc-top-half/musl/compat/time32/lutimes_time32.c @@ -0,0 +1,12 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include +#include + +int __lutimes_time32(const char *path, const struct timeval32 times32[2]) +{ + return lutimes(path, !times32 ? 0 : ((struct timeval[2]){ + {.tv_sec = times32[0].tv_sec,.tv_usec = times32[0].tv_usec}, + {.tv_sec = times32[1].tv_sec,.tv_usec = times32[1].tv_usec}})); +} diff --git a/libc-top-half/musl/compat/time32/mktime32.c b/libc-top-half/musl/compat/time32/mktime32.c new file mode 100644 index 0000000..e6f15d5 --- /dev/null +++ b/libc-top-half/musl/compat/time32/mktime32.c @@ -0,0 +1,16 @@ +#include "time32.h" +#include +#include +#include + +time32_t __mktime32(struct tm *tm) +{ + struct tm tmp = *tm; + time_t t = mktime(&tmp); + if (t < INT32_MIN || t > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + *tm = tmp; + return t; +} diff --git a/libc-top-half/musl/compat/time32/mq_timedreceive_time32.c b/libc-top-half/musl/compat/time32/mq_timedreceive_time32.c new file mode 100644 index 0000000..211cea4 --- /dev/null +++ b/libc-top-half/musl/compat/time32/mq_timedreceive_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +ssize_t __mq_timedreceive_time32(mqd_t mqd, char *restrict msg, size_t len, unsigned *restrict prio, const struct timespec32 *restrict ts32) +{ + return mq_timedreceive(mqd, msg, len, prio, ts32 ? (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); +} diff --git a/libc-top-half/musl/compat/time32/mq_timedsend_time32.c b/libc-top-half/musl/compat/time32/mq_timedsend_time32.c new file mode 100644 index 0000000..93b697a --- /dev/null +++ b/libc-top-half/musl/compat/time32/mq_timedsend_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __mq_timedsend_time32(mqd_t mqd, const char *msg, size_t len, unsigned prio, const struct timespec32 *ts32) +{ + return mq_timedsend(mqd, msg, len, prio, ts32 ? (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); +} diff --git a/libc-top-half/musl/compat/time32/mtx_timedlock_time32.c b/libc-top-half/musl/compat/time32/mtx_timedlock_time32.c new file mode 100644 index 0000000..a01f09b --- /dev/null +++ b/libc-top-half/musl/compat/time32/mtx_timedlock_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __mtx_timedlock_time32(mtx_t *restrict m, const struct timespec32 *restrict ts32) +{ + return mtx_timedlock(m, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/nanosleep_time32.c b/libc-top-half/musl/compat/time32/nanosleep_time32.c new file mode 100644 index 0000000..ea6bdd8 --- /dev/null +++ b/libc-top-half/musl/compat/time32/nanosleep_time32.c @@ -0,0 +1,15 @@ +#include "time32.h" +#include +#include + +int __nanosleep_time32(const struct timespec32 *req32, struct timespec32 *rem32) +{ + struct timespec rem; + int ret = nanosleep((&(struct timespec){ + .tv_sec = req32->tv_sec, .tv_nsec = req32->tv_nsec}), &rem); + if (ret<0 && errno==EINTR && rem32) { + rem32->tv_sec = rem.tv_sec; + rem32->tv_nsec = rem.tv_nsec; + } + return ret; +} diff --git a/libc-top-half/musl/compat/time32/ppoll_time32.c b/libc-top-half/musl/compat/time32/ppoll_time32.c new file mode 100644 index 0000000..43b4b0d --- /dev/null +++ b/libc-top-half/musl/compat/time32/ppoll_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#define _GNU_SOURCE +#include +#include + +int __ppoll_time32(struct pollfd *fds, nfds_t n, const struct timespec32 *ts32, const sigset_t *mask) +{ + return ppoll(fds, n, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}), mask); +} diff --git a/libc-top-half/musl/compat/time32/pselect_time32.c b/libc-top-half/musl/compat/time32/pselect_time32.c new file mode 100644 index 0000000..ecaa8f8 --- /dev/null +++ b/libc-top-half/musl/compat/time32/pselect_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __pselect_time32(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, const struct timespec32 *restrict ts32, const sigset_t *restrict mask) +{ + return pselect(n, rfds, wfds, efds, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}), mask); +} diff --git a/libc-top-half/musl/compat/time32/pthread_cond_timedwait_time32.c b/libc-top-half/musl/compat/time32/pthread_cond_timedwait_time32.c new file mode 100644 index 0000000..fba1f2a --- /dev/null +++ b/libc-top-half/musl/compat/time32/pthread_cond_timedwait_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __pthread_cond_timedwait_time32(pthread_cond_t *restrict c, pthread_mutex_t *restrict m, const struct timespec32 *restrict ts32) +{ + return pthread_cond_timedwait(c, m, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/pthread_mutex_timedlock_time32.c b/libc-top-half/musl/compat/time32/pthread_mutex_timedlock_time32.c new file mode 100644 index 0000000..2d29602 --- /dev/null +++ b/libc-top-half/musl/compat/time32/pthread_mutex_timedlock_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __pthread_mutex_timedlock_time32(pthread_mutex_t *restrict m, const struct timespec32 *restrict ts32) +{ + return pthread_mutex_timedlock(m, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/pthread_rwlock_timedrdlock_time32.c b/libc-top-half/musl/compat/time32/pthread_rwlock_timedrdlock_time32.c new file mode 100644 index 0000000..33df27a --- /dev/null +++ b/libc-top-half/musl/compat/time32/pthread_rwlock_timedrdlock_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __pthread_rwlock_timedrdlock_time32(pthread_rwlock_t *restrict rw, const struct timespec32 *restrict ts32) +{ + return pthread_rwlock_timedrdlock(rw, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/pthread_rwlock_timedwrlock_time32.c b/libc-top-half/musl/compat/time32/pthread_rwlock_timedwrlock_time32.c new file mode 100644 index 0000000..99f24f7 --- /dev/null +++ b/libc-top-half/musl/compat/time32/pthread_rwlock_timedwrlock_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __pthread_rwlock_timedwrlock_time32(pthread_rwlock_t *restrict rw, const struct timespec32 *restrict ts32) +{ + return pthread_rwlock_timedwrlock(rw, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/pthread_timedjoin_np_time32.c b/libc-top-half/musl/compat/time32/pthread_timedjoin_np_time32.c new file mode 100644 index 0000000..3ec2995 --- /dev/null +++ b/libc-top-half/musl/compat/time32/pthread_timedjoin_np_time32.c @@ -0,0 +1,10 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include + +int __pthread_timedjoin_np_time32(pthread_t t, void **res, const struct timespec32 *at32) +{ + return pthread_timedjoin_np(t, res, !at32 ? 0 : (&(struct timespec){ + .tv_sec = at32->tv_sec, .tv_nsec = at32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/recvmmsg_time32.c b/libc-top-half/musl/compat/time32/recvmmsg_time32.c new file mode 100644 index 0000000..acf1cfb --- /dev/null +++ b/libc-top-half/musl/compat/time32/recvmmsg_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#define _GNU_SOURCE +#include +#include + +int __recvmmsg_time32(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec32 *ts32) +{ + return recvmmsg(fd, msgvec, vlen, flags, ts32 ? (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec}) : 0); +} diff --git a/libc-top-half/musl/compat/time32/sched_rr_get_interval_time32.c b/libc-top-half/musl/compat/time32/sched_rr_get_interval_time32.c new file mode 100644 index 0000000..36cbbac --- /dev/null +++ b/libc-top-half/musl/compat/time32/sched_rr_get_interval_time32.c @@ -0,0 +1,13 @@ +#include "time32.h" +#include +#include + +int __sched_rr_get_interval_time32(pid_t pid, struct timespec32 *ts32) +{ + struct timespec ts; + int r = sched_rr_get_interval(pid, &ts); + if (r) return r; + ts32->tv_sec = ts.tv_sec; + ts32->tv_nsec = ts.tv_nsec; + return r; +} diff --git a/libc-top-half/musl/compat/time32/select_time32.c b/libc-top-half/musl/compat/time32/select_time32.c new file mode 100644 index 0000000..2d8df9a --- /dev/null +++ b/libc-top-half/musl/compat/time32/select_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#include +#include +#include + +int __select_time32(int n, fd_set *restrict rfds, fd_set *restrict wfds, fd_set *restrict efds, struct timeval32 *restrict tv32) +{ + return select(n, rfds, wfds, efds, !tv32 ? 0 : (&(struct timeval){ + .tv_sec = tv32->tv_sec, .tv_usec = tv32->tv_usec})); +} diff --git a/libc-top-half/musl/compat/time32/sem_timedwait_time32.c b/libc-top-half/musl/compat/time32/sem_timedwait_time32.c new file mode 100644 index 0000000..c3469f9 --- /dev/null +++ b/libc-top-half/musl/compat/time32/sem_timedwait_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __sem_timedwait_time32(sem_t *sem, const struct timespec32 *restrict ts32) +{ + return sem_timedwait(sem, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/semtimedop_time32.c b/libc-top-half/musl/compat/time32/semtimedop_time32.c new file mode 100644 index 0000000..34ec528 --- /dev/null +++ b/libc-top-half/musl/compat/time32/semtimedop_time32.c @@ -0,0 +1,10 @@ +#include "time32.h" +#define _GNU_SOURCE +#include +#include + +int __semtimedop_time32(int id, struct sembuf *buf, size_t n, const struct timespec32 *ts32) +{ + return semtimedop(id, buf, n, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/setitimer_time32.c b/libc-top-half/musl/compat/time32/setitimer_time32.c new file mode 100644 index 0000000..2475fd8 --- /dev/null +++ b/libc-top-half/musl/compat/time32/setitimer_time32.c @@ -0,0 +1,25 @@ +#include "time32.h" +#include +#include + +int __setitimer_time32(int which, const struct itimerval32 *restrict new32, struct itimerval32 *restrict old32) +{ + struct itimerval old; + int r = setitimer(which, (&(struct itimerval){ + .it_interval.tv_sec = new32->it_interval.tv_sec, + .it_interval.tv_usec = new32->it_interval.tv_usec, + .it_value.tv_sec = new32->it_value.tv_sec, + .it_value.tv_usec = new32->it_value.tv_usec}), &old); + if (r) return r; + /* The above call has already committed to success by changing the + * timer setting, so we can't fail on out-of-range old value. + * Since these are relative times, values large enough to overflow + * don't make sense anyway. */ + if (old32) { + old32->it_interval.tv_sec = old.it_interval.tv_sec; + old32->it_interval.tv_usec = old.it_interval.tv_usec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_usec = old.it_value.tv_usec; + } + return 0; +} diff --git a/libc-top-half/musl/compat/time32/settimeofday_time32.c b/libc-top-half/musl/compat/time32/settimeofday_time32.c new file mode 100644 index 0000000..09e625c --- /dev/null +++ b/libc-top-half/musl/compat/time32/settimeofday_time32.c @@ -0,0 +1,10 @@ +#define _BSD_SOURCE +#include "time32.h" +#include + +int __settimeofday_time32(const struct timeval32 *tv32, const void *tz) +{ + return settimeofday(!tv32 ? 0 : (&(struct timeval){ + .tv_sec = tv32->tv_sec, + .tv_usec = tv32->tv_usec}), 0); +} diff --git a/libc-top-half/musl/compat/time32/sigtimedwait_time32.c b/libc-top-half/musl/compat/time32/sigtimedwait_time32.c new file mode 100644 index 0000000..6b3aa39 --- /dev/null +++ b/libc-top-half/musl/compat/time32/sigtimedwait_time32.c @@ -0,0 +1,9 @@ +#include "time32.h" +#include +#include + +int __sigtimedwait_time32(const sigset_t *restrict set, siginfo_t *restrict si, const struct timespec32 *restrict ts32) +{ + return sigtimedwait(set, si, !ts32 ? 0 : (&(struct timespec){ + .tv_sec = ts32->tv_sec, .tv_nsec = ts32->tv_nsec})); +} diff --git a/libc-top-half/musl/compat/time32/stat_time32.c b/libc-top-half/musl/compat/time32/stat_time32.c new file mode 100644 index 0000000..8c6121d --- /dev/null +++ b/libc-top-half/musl/compat/time32/stat_time32.c @@ -0,0 +1,17 @@ +#include "time32.h" +#include +#include +#include +#include + +struct stat32; + +int __stat_time32(const char *restrict path, struct stat32 *restrict st32) +{ + struct stat st; + int r = stat(path, &st); + if (!r) memcpy(st32, &st, offsetof(struct stat, st_atim)); + return r; +} + +weak_alias(stat, stat64); diff --git a/libc-top-half/musl/compat/time32/stime32.c b/libc-top-half/musl/compat/time32/stime32.c new file mode 100644 index 0000000..cc76364 --- /dev/null +++ b/libc-top-half/musl/compat/time32/stime32.c @@ -0,0 +1,8 @@ +#define _GNU_SOURCE +#include "time32.h" +#include + +int __stime32(const time32_t *t) +{ + return stime(&(time_t){*t}); +} diff --git a/libc-top-half/musl/compat/time32/thrd_sleep_time32.c b/libc-top-half/musl/compat/time32/thrd_sleep_time32.c new file mode 100644 index 0000000..5908800 --- /dev/null +++ b/libc-top-half/musl/compat/time32/thrd_sleep_time32.c @@ -0,0 +1,16 @@ +#include "time32.h" +#include +#include +#include + +int __thrd_sleep_time32(const struct timespec32 *req32, struct timespec32 *rem32) +{ + struct timespec rem; + int ret = thrd_sleep((&(struct timespec){ + .tv_sec = req32->tv_sec, .tv_nsec = req32->tv_nsec}), &rem); + if (ret<0 && errno==EINTR && rem32) { + rem32->tv_sec = rem.tv_sec; + rem32->tv_nsec = rem.tv_nsec; + } + return ret; +} diff --git a/libc-top-half/musl/compat/time32/time32.c b/libc-top-half/musl/compat/time32/time32.c new file mode 100644 index 0000000..4b8fac1 --- /dev/null +++ b/libc-top-half/musl/compat/time32/time32.c @@ -0,0 +1,15 @@ +#include "time32.h" +#include +#include +#include + +time32_t __time32(time32_t *p) +{ + time_t t = time(0); + if (t < INT32_MIN || t > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + if (p) *p = t; + return t; +} diff --git a/libc-top-half/musl/compat/time32/time32.h b/libc-top-half/musl/compat/time32/time32.h new file mode 100644 index 0000000..fdec17c --- /dev/null +++ b/libc-top-half/musl/compat/time32/time32.h @@ -0,0 +1,91 @@ +#ifndef TIME32_H +#define TIME32_H + +#include + +typedef long time32_t; + +struct timeval32 { + long tv_sec; + long tv_usec; +}; + +struct itimerval32 { + struct timeval32 it_interval; + struct timeval32 it_value; +}; + +struct timespec32 { + long tv_sec; + long tv_nsec; +}; + +struct itimerspec32 { + struct timespec32 it_interval; + struct timespec32 it_value; +}; + +int __adjtime32() __asm__("adjtime"); +int __adjtimex_time32() __asm__("adjtimex"); +int __aio_suspend_time32() __asm__("aio_suspend"); +int __clock_adjtime32() __asm__("clock_adjtime"); +int __clock_getres_time32() __asm__("clock_getres"); +int __clock_gettime32() __asm__("clock_gettime"); +int __clock_nanosleep_time32() __asm__("clock_nanosleep"); +int __clock_settime32() __asm__("clock_settime"); +int __cnd_timedwait_time32() __asm__("cnd_timedwait"); +char *__ctime32() __asm__("ctime"); +char *__ctime32_r() __asm__("ctime_r"); +double __difftime32() __asm__("difftime"); +int __fstat_time32() __asm__("fstat"); +int __fstatat_time32() __asm__("fstatat"); +int __ftime32() __asm__("ftime"); +int __futimens_time32() __asm__("futimens"); +int __futimes_time32() __asm__("futimes"); +int __futimesat_time32() __asm__("futimesat"); +int __getitimer_time32() __asm__("getitimer"); +int __getrusage_time32() __asm__("getrusage"); +int __gettimeofday_time32() __asm__("gettimeofday"); +struct tm *__gmtime32() __asm__("gmtime"); +struct tm *__gmtime32_r() __asm__("gmtime_r"); +struct tm *__localtime32() __asm__("localtime"); +struct tm *__localtime32_r() __asm__("localtime_r"); +int __lstat_time32() __asm__("lstat"); +int __lutimes_time32() __asm__("lutimes"); +time32_t __mktime32() __asm__("mktime"); +ssize_t __mq_timedreceive_time32() __asm__("mq_timedreceive"); +int __mq_timedsend_time32() __asm__("mq_timedsend"); +int __mtx_timedlock_time32() __asm__("mtx_timedlock"); +int __nanosleep_time32() __asm__("nanosleep"); +int __ppoll_time32() __asm__("ppoll"); +int __pselect_time32() __asm__("pselect"); +int __pthread_cond_timedwait_time32() __asm__("pthread_cond_timedwait"); +int __pthread_mutex_timedlock_time32() __asm__("pthread_mutex_timedlock"); +int __pthread_rwlock_timedrdlock_time32() __asm__("pthread_rwlock_timedrdlock"); +int __pthread_rwlock_timedwrlock_time32() __asm__("pthread_rwlock_timedwrlock"); +int __pthread_timedjoin_np_time32() __asm__("pthread_timedjoin_np"); +int __recvmmsg_time32() __asm__("recvmmsg"); +int __sched_rr_get_interval_time32() __asm__("sched_rr_get_interval"); +int __select_time32() __asm__("select"); +int __sem_timedwait_time32() __asm__("sem_timedwait"); +int __semtimedop_time32() __asm__("semtimedop"); +int __setitimer_time32() __asm__("setitimer"); +int __settimeofday_time32() __asm__("settimeofday"); +int __sigtimedwait_time32() __asm__("sigtimedwait"); +int __stat_time32() __asm__("stat"); +int __stime32() __asm__("stime"); +int __thrd_sleep_time32() __asm__("thrd_sleep"); +time32_t __time32() __asm__("time"); +time32_t __time32gm() __asm__("timegm"); +int __timer_gettime32() __asm__("timer_gettime"); +int __timer_settime32() __asm__("timer_settime"); +int __timerfd_gettime32() __asm__("timerfd_gettime"); +int __timerfd_settime32() __asm__("timerfd_settime"); +int __timespec_get_time32() __asm__("timespec_get"); +int __utime_time32() __asm__("utime"); +int __utimensat_time32() __asm__("utimensat"); +int __utimes_time32() __asm__("utimes"); +pid_t __wait3_time32() __asm__("wait3"); +pid_t __wait4_time32() __asm__("wait4"); + +#endif diff --git a/libc-top-half/musl/compat/time32/time32gm.c b/libc-top-half/musl/compat/time32/time32gm.c new file mode 100644 index 0000000..60d68fb --- /dev/null +++ b/libc-top-half/musl/compat/time32/time32gm.c @@ -0,0 +1,15 @@ +#define _GNU_SOURCE +#include "time32.h" +#include +#include +#include + +time32_t __time32gm(struct tm *tm) +{ + time_t t = timegm(tm); + if (t < INT32_MIN || t > INT32_MAX) { + errno = EOVERFLOW; + return -1; + } + return t; +} diff --git a/libc-top-half/musl/compat/time32/timer_gettime32.c b/libc-top-half/musl/compat/time32/timer_gettime32.c new file mode 100644 index 0000000..b4184cc --- /dev/null +++ b/libc-top-half/musl/compat/time32/timer_gettime32.c @@ -0,0 +1,15 @@ +#include "time32.h" +#include + +int __timer_gettime32(timer_t t, struct itimerspec32 *val32) +{ + struct itimerspec old; + int r = timer_gettime(t, &old); + if (r) return r; + /* No range checking for consistency with settime */ + val32->it_interval.tv_sec = old.it_interval.tv_sec; + val32->it_interval.tv_nsec = old.it_interval.tv_nsec; + val32->it_value.tv_sec = old.it_value.tv_sec; + val32->it_value.tv_nsec = old.it_value.tv_nsec; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/timer_settime32.c b/libc-top-half/musl/compat/time32/timer_settime32.c new file mode 100644 index 0000000..a447e7d --- /dev/null +++ b/libc-top-half/musl/compat/time32/timer_settime32.c @@ -0,0 +1,25 @@ +#include "time32.h" +#include + +int __timer_settime32(timer_t t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32) +{ + struct itimerspec old; + int r = timer_settime(t, flags, (&(struct itimerspec){ + .it_interval.tv_sec = val32->it_interval.tv_sec, + .it_interval.tv_nsec = val32->it_interval.tv_nsec, + .it_value.tv_sec = val32->it_value.tv_sec, + .it_value.tv_nsec = val32->it_value.tv_nsec}), + old32 ? &old : 0); + if (r) return r; + /* The above call has already committed to success by changing the + * timer setting, so we can't fail on out-of-range old value. + * Since these are relative times, values large enough to overflow + * don't make sense anyway. */ + if (old32) { + old32->it_interval.tv_sec = old.it_interval.tv_sec; + old32->it_interval.tv_nsec = old.it_interval.tv_nsec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_nsec = old.it_value.tv_nsec; + } + return 0; +} diff --git a/libc-top-half/musl/compat/time32/timerfd_gettime32.c b/libc-top-half/musl/compat/time32/timerfd_gettime32.c new file mode 100644 index 0000000..75e5435 --- /dev/null +++ b/libc-top-half/musl/compat/time32/timerfd_gettime32.c @@ -0,0 +1,16 @@ +#include "time32.h" +#include +#include + +int __timerfd_gettime32(int t, struct itimerspec32 *val32) +{ + struct itimerspec old; + int r = timerfd_gettime(t, &old); + if (r) return r; + /* No range checking for consistency with settime */ + val32->it_interval.tv_sec = old.it_interval.tv_sec; + val32->it_interval.tv_nsec = old.it_interval.tv_nsec; + val32->it_value.tv_sec = old.it_value.tv_sec; + val32->it_value.tv_nsec = old.it_value.tv_nsec; + return 0; +} diff --git a/libc-top-half/musl/compat/time32/timerfd_settime32.c b/libc-top-half/musl/compat/time32/timerfd_settime32.c new file mode 100644 index 0000000..67830d3 --- /dev/null +++ b/libc-top-half/musl/compat/time32/timerfd_settime32.c @@ -0,0 +1,26 @@ +#include "time32.h" +#include +#include + +int __timerfd_settime32(int t, int flags, const struct itimerspec32 *restrict val32, struct itimerspec32 *restrict old32) +{ + struct itimerspec old; + int r = timerfd_settime(t, flags, (&(struct itimerspec){ + .it_interval.tv_sec = val32->it_interval.tv_sec, + .it_interval.tv_nsec = val32->it_interval.tv_nsec, + .it_value.tv_sec = val32->it_value.tv_sec, + .it_value.tv_nsec = val32->it_value.tv_nsec}), + old32 ? &old : 0); + if (r) return r; + /* The above call has already committed to success by changing the + * timer setting, so we can't fail on out-of-range old value. + * Since these are relative times, values large enough to overflow + * don't make sense anyway. */ + if (old32) { + old32->it_interval.tv_sec = old.it_interval.tv_sec; + old32->it_interval.tv_nsec = old.it_interval.tv_nsec; + old32->it_value.tv_sec = old.it_value.tv_sec; + old32->it_value.tv_nsec = old.it_value.tv_nsec; + } + return 0; +} diff --git a/libc-top-half/musl/compat/time32/timespec_get_time32.c b/libc-top-half/musl/compat/time32/timespec_get_time32.c new file mode 100644 index 0000000..e9ca94c --- /dev/null +++ b/libc-top-half/musl/compat/time32/timespec_get_time32.c @@ -0,0 +1,18 @@ +#include "time32.h" +#include +#include +#include + +int __timespec_get_time32(struct timespec32 *ts32, int base) +{ + struct timespec ts; + int r = timespec_get(&ts, base); + if (!r) return r; + if (ts.tv_sec < INT32_MIN || ts.tv_sec > INT32_MAX) { + errno = EOVERFLOW; + return 0; + } + ts32->tv_sec = ts.tv_sec; + ts32->tv_nsec = ts.tv_nsec; + return r; +} diff --git a/libc-top-half/musl/compat/time32/utime_time32.c b/libc-top-half/musl/compat/time32/utime_time32.c new file mode 100644 index 0000000..65f11d4 --- /dev/null +++ b/libc-top-half/musl/compat/time32/utime_time32.c @@ -0,0 +1,14 @@ +#include "time32.h" +#include +#include + +struct utimbuf32 { + time32_t actime; + time32_t modtime; +}; + +int __utime_time32(const char *path, const struct utimbuf32 *times32) +{ + return utime(path, !times32 ? 0 : (&(struct utimbuf){ + .actime = times32->actime, .modtime = times32->modtime})); +} diff --git a/libc-top-half/musl/compat/time32/utimensat_time32.c b/libc-top-half/musl/compat/time32/utimensat_time32.c new file mode 100644 index 0000000..c687b8d --- /dev/null +++ b/libc-top-half/musl/compat/time32/utimensat_time32.c @@ -0,0 +1,11 @@ +#include "time32.h" +#include +#include + +int __utimensat_time32(int fd, const char *path, const struct timespec32 times32[2], int flags) +{ + return utimensat(fd, path, !times32 ? 0 : ((struct timespec[2]){ + {.tv_sec = times32[0].tv_sec,.tv_nsec = times32[0].tv_nsec}, + {.tv_sec = times32[1].tv_sec,.tv_nsec = times32[1].tv_nsec}}), + flags); +} diff --git a/libc-top-half/musl/compat/time32/utimes_time32.c b/libc-top-half/musl/compat/time32/utimes_time32.c new file mode 100644 index 0000000..59248f6 --- /dev/null +++ b/libc-top-half/musl/compat/time32/utimes_time32.c @@ -0,0 +1,11 @@ +#include "time32.h" +#include +#include +#include + +int __utimes_time32(const char *path, const struct timeval32 times32[2]) +{ + return utimes(path, !times32 ? 0 : ((struct timeval[2]){ + {.tv_sec = times32[0].tv_sec,.tv_usec = times32[0].tv_usec}, + {.tv_sec = times32[1].tv_sec,.tv_usec = times32[1].tv_usec}})); +} diff --git a/libc-top-half/musl/compat/time32/wait3_time32.c b/libc-top-half/musl/compat/time32/wait3_time32.c new file mode 100644 index 0000000..8fe128e --- /dev/null +++ b/libc-top-half/musl/compat/time32/wait3_time32.c @@ -0,0 +1,40 @@ +#define _BSD_SOURCE +#include "time32.h" +#include +#include +#include + +struct compat_rusage { + struct timeval32 ru_utime; + struct timeval32 ru_stime; + long ru_maxrss; + long ru_ixrss; + long ru_idrss; + long ru_isrss; + long ru_minflt; + long ru_majflt; + long ru_nswap; + long ru_inblock; + long ru_oublock; + long ru_msgsnd; + long ru_msgrcv; + long ru_nsignals; + long ru_nvcsw; + long ru_nivcsw; +}; + +pid_t __wait3_time32(int *status, int options, struct compat_rusage *usage) +{ + struct rusage ru; + int r = wait3(status, options, usage ? &ru : 0); + if (!r && usage) { + usage->ru_utime.tv_sec = ru.ru_utime.tv_sec; + usage->ru_utime.tv_usec = ru.ru_utime.tv_usec; + usage->ru_stime.tv_sec = ru.ru_stime.tv_sec; + usage->ru_stime.tv_usec = ru.ru_stime.tv_usec; + memcpy(&usage->ru_maxrss, &ru.ru_maxrss, + sizeof(struct compat_rusage) - + offsetof(struct compat_rusage, ru_maxrss)); + } + return r; +} diff --git a/libc-top-half/musl/compat/time32/wait4_time32.c b/libc-top-half/musl/compat/time32/wait4_time32.c new file mode 100644 index 0000000..918548e --- /dev/null +++ b/libc-top-half/musl/compat/time32/wait4_time32.c @@ -0,0 +1,40 @@ +#define _BSD_SOURCE +#include "time32.h" +#include +#include +#include + +struct compat_rusage { + struct timeval32 ru_utime; + struct timeval32 ru_stime; + long ru_maxrss; + long ru_ixrss; + long ru_idrss; + long ru_isrss; + long ru_minflt; + long ru_majflt; + long ru_nswap; + long ru_inblock; + long ru_oublock; + long ru_msgsnd; + long ru_msgrcv; + long ru_nsignals; + long ru_nvcsw; + long ru_nivcsw; +}; + +pid_t __wait4_time32(pid_t pid, int *status, int options, struct compat_rusage *usage) +{ + struct rusage ru; + int r = wait4(pid, status, options, usage ? &ru : 0); + if (!r && usage) { + usage->ru_utime.tv_sec = ru.ru_utime.tv_sec; + usage->ru_utime.tv_usec = ru.ru_utime.tv_usec; + usage->ru_stime.tv_sec = ru.ru_stime.tv_sec; + usage->ru_stime.tv_usec = ru.ru_stime.tv_usec; + memcpy(&usage->ru_maxrss, &ru.ru_maxrss, + sizeof(struct compat_rusage) - + offsetof(struct compat_rusage, ru_maxrss)); + } + return r; +} diff --git a/libc-top-half/musl/configure b/libc-top-half/musl/configure index ae13e0e..8bacaee 100755 --- a/libc-top-half/musl/configure +++ b/libc-top-half/musl/configure @@ -648,6 +648,15 @@ if test "$ARCH" = "powerpc" ; then trycppif "__NO_FPRS__ && !_SOFT_FLOAT" "$t" && fail \ "$0: error: compiler's floating point configuration is unsupported" trycppif _SOFT_FLOAT "$t" && SUBARCH=${SUBARCH}-sf +printf "checking whether compiler can use 'd' constraint in asm... " +echo 'double f(double x) { __asm__ ("fabs %0, %1" : "=d"(x) : "d"(x)); return x; }' > "$tmpc" +if $CC $CFLAGS_C99FSE $CPPFLAGS $CFLAGS -c -o /dev/null "$tmpc" >/dev/null 2>&1 ; then +printf "yes\n" +else +printf "no\n" +CFLAGS_AUTO="$CFLAGS_AUTO -DBROKEN_PPC_D_ASM" +CFLAGS_AUTO="${CFLAGS_AUTO# }" +fi fi test "$ARCH" = "microblaze" && trycppif __MICROBLAZEEL__ "$t" \ diff --git a/libc-top-half/musl/include/aio.h b/libc-top-half/musl/include/aio.h index 19bc28a..453c41b 100644 --- a/libc-top-half/musl/include/aio.h +++ b/libc-top-half/musl/include/aio.h @@ -62,6 +62,10 @@ int lio_listio(int, struct aiocb *__restrict const *__restrict, int, struct sige #define off64_t off_t #endif +#if _REDIR_TIME64 +__REDIR(aio_suspend, __aio_suspend_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/alloca.h b/libc-top-half/musl/include/alloca.h index d2e6f1c..b8d183d 100644 --- a/libc-top-half/musl/include/alloca.h +++ b/libc-top-half/musl/include/alloca.h @@ -10,9 +10,7 @@ extern "C" { void *alloca(size_t); -#ifdef __GNUC__ #define alloca __builtin_alloca -#endif #ifdef __cplusplus } diff --git a/libc-top-half/musl/include/alltypes.h.in b/libc-top-half/musl/include/alltypes.h.in index d38de75..3daf9f6 100644 --- a/libc-top-half/musl/include/alltypes.h.in +++ b/libc-top-half/musl/include/alltypes.h.in @@ -1,3 +1,7 @@ +#define __LITTLE_ENDIAN 1234 +#define __BIG_ENDIAN 4321 +#define __USE_TIME_BITS64 1 + TYPEDEF unsigned _Addr size_t; TYPEDEF unsigned _Addr uintptr_t; TYPEDEF _Addr ptrdiff_t; @@ -5,6 +9,20 @@ TYPEDEF _Addr ssize_t; TYPEDEF _Addr intptr_t; TYPEDEF _Addr regoff_t; TYPEDEF _Reg register_t; +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ +TYPEDEF _Int64 time_t; +TYPEDEF _Int64 suseconds_t; +#else +#if defined(__NEED_time_t) && !defined(__DEFINED_time_t) +#include <__typedef_time_t.h> +#define __DEFINED_time_t +#endif + +#if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) +#include <__typedef_suseconds_t.h> +#define __DEFINED_suseconds_t +#endif +#endif TYPEDEF signed char int8_t; TYPEDEF signed short int16_t; @@ -36,7 +54,7 @@ TYPEDEF int clockid_t; TYPEDEF long clock_t; #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ STRUCT timeval { time_t tv_sec; suseconds_t tv_usec; }; -STRUCT timespec { time_t tv_sec; long tv_nsec; }; +STRUCT timespec { time_t tv_sec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER==4321); long tv_nsec; int :8*(sizeof(time_t)-sizeof(long))*(__BYTE_ORDER!=4321); }; #else #include <__struct_timeval.h> #include <__struct_timespec.h> @@ -67,6 +85,9 @@ STRUCT _IO_FILE { char __x; }; #endif TYPEDEF struct _IO_FILE FILE; +TYPEDEF __builtin_va_list va_list; +TYPEDEF __builtin_va_list __isoc_va_list; + TYPEDEF struct __mbstate_t { unsigned __opaque1, __opaque2; } mbstate_t; TYPEDEF struct __locale_struct * locale_t; @@ -82,6 +103,14 @@ STRUCT iovec { void *iov_base; size_t iov_len; }; TYPEDEF unsigned socklen_t; TYPEDEF unsigned short sa_family_t; +TYPEDEF struct { union { int __i[sizeof(long)==8?14:9]; volatile int __vi[sizeof(long)==8?14:9]; unsigned long __s[sizeof(long)==8?7:9]; } __u; } pthread_attr_t; +TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } pthread_mutex_t; +TYPEDEF struct { union { int __i[sizeof(long)==8?10:6]; volatile int __vi[sizeof(long)==8?10:6]; volatile void *volatile __p[sizeof(long)==8?5:6]; } __u; } mtx_t; +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } pthread_cond_t; +TYPEDEF struct { union { int __i[12]; volatile int __vi[12]; void *__p[12*sizeof(int)/sizeof(void*)]; } __u; } cnd_t; +TYPEDEF struct { union { int __i[sizeof(long)==8?14:8]; volatile int __vi[sizeof(long)==8?14:8]; void *__p[sizeof(long)==8?7:8]; } __u; } pthread_rwlock_t; +TYPEDEF struct { union { int __i[sizeof(long)==8?8:5]; volatile int __vi[sizeof(long)==8?8:5]; void *__p[sizeof(long)==8?4:5]; } __u; } pthread_barrier_t; + #undef _Addr #undef _Int64 #undef _Reg diff --git a/libc-top-half/musl/include/arpa/nameser.h b/libc-top-half/musl/include/arpa/nameser.h index b315e0f..581925a 100644 --- a/libc-top-half/musl/include/arpa/nameser.h +++ b/libc-top-half/musl/include/arpa/nameser.h @@ -7,7 +7,6 @@ extern "C" { #include #include -#include #define __NAMESER 19991006 #define NS_PACKETSZ 512 diff --git a/libc-top-half/musl/include/dirent.h b/libc-top-half/musl/include/dirent.h index 3a129a4..52a3b16 100644 --- a/libc-top-half/musl/include/dirent.h +++ b/libc-top-half/musl/include/dirent.h @@ -19,28 +19,14 @@ extern "C" { #include +#include + #ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ typedef struct __dirstream DIR; #else #include <__typedef_DIR.h> #endif -#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ -#define _DIRENT_HAVE_D_RECLEN -#define _DIRENT_HAVE_D_OFF -#define _DIRENT_HAVE_D_TYPE - -struct dirent { - ino_t d_ino; - off_t d_off; - unsigned short d_reclen; - unsigned char d_type; - char d_name[256]; -}; -#else -#include <__struct_dirent.h> -#endif - #define d_fileno d_ino int closedir(DIR *); diff --git a/libc-top-half/musl/include/dlfcn.h b/libc-top-half/musl/include/dlfcn.h index 78fb073..13ab71d 100644 --- a/libc-top-half/musl/include/dlfcn.h +++ b/libc-top-half/musl/include/dlfcn.h @@ -35,6 +35,10 @@ int dladdr(const void *, Dl_info *); int dlinfo(void *, int, void *); #endif +#if _REDIR_TIME64 +__REDIR(dlsym, __dlsym_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/endian.h b/libc-top-half/musl/include/endian.h index 1bd4445..172c432 100644 --- a/libc-top-half/musl/include/endian.h +++ b/libc-top-half/musl/include/endian.h @@ -3,25 +3,19 @@ #include -#define __LITTLE_ENDIAN 1234 -#define __BIG_ENDIAN 4321 +#define __NEED_uint16_t +#define __NEED_uint32_t +#define __NEED_uint64_t + +#include + #define __PDP_ENDIAN 3412 -#if defined(__GNUC__) && defined(__BYTE_ORDER__) -#define __BYTE_ORDER __BYTE_ORDER__ -#else -#include -#endif - -#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) - #define BIG_ENDIAN __BIG_ENDIAN #define LITTLE_ENDIAN __LITTLE_ENDIAN #define PDP_ENDIAN __PDP_ENDIAN #define BYTE_ORDER __BYTE_ORDER -#include - static __inline uint16_t __bswap16(uint16_t __x) { return __x<<8 | __x>>8; @@ -40,43 +34,47 @@ static __inline uint64_t __bswap64(uint64_t __x) #if __BYTE_ORDER == __LITTLE_ENDIAN #define htobe16(x) __bswap16(x) #define be16toh(x) __bswap16(x) -#define betoh16(x) __bswap16(x) #define htobe32(x) __bswap32(x) #define be32toh(x) __bswap32(x) -#define betoh32(x) __bswap32(x) #define htobe64(x) __bswap64(x) #define be64toh(x) __bswap64(x) -#define betoh64(x) __bswap64(x) #define htole16(x) (uint16_t)(x) #define le16toh(x) (uint16_t)(x) -#define letoh16(x) (uint16_t)(x) #define htole32(x) (uint32_t)(x) #define le32toh(x) (uint32_t)(x) -#define letoh32(x) (uint32_t)(x) #define htole64(x) (uint64_t)(x) #define le64toh(x) (uint64_t)(x) -#define letoh64(x) (uint64_t)(x) #else #define htobe16(x) (uint16_t)(x) #define be16toh(x) (uint16_t)(x) -#define betoh16(x) (uint16_t)(x) #define htobe32(x) (uint32_t)(x) #define be32toh(x) (uint32_t)(x) -#define betoh32(x) (uint32_t)(x) #define htobe64(x) (uint64_t)(x) #define be64toh(x) (uint64_t)(x) -#define betoh64(x) (uint64_t)(x) #define htole16(x) __bswap16(x) #define le16toh(x) __bswap16(x) -#define letoh16(x) __bswap16(x) #define htole32(x) __bswap32(x) #define le32toh(x) __bswap32(x) -#define letoh32(x) __bswap32(x) #define htole64(x) __bswap64(x) #define le64toh(x) __bswap64(x) +#endif + +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define betoh16(x) __bswap16(x) +#define betoh32(x) __bswap32(x) +#define betoh64(x) __bswap64(x) +#define letoh16(x) (uint16_t)(x) +#define letoh32(x) (uint32_t)(x) +#define letoh64(x) (uint64_t)(x) +#else +#define betoh16(x) (uint16_t)(x) +#define betoh32(x) (uint32_t)(x) +#define betoh64(x) (uint64_t)(x) +#define letoh16(x) __bswap16(x) +#define letoh32(x) __bswap32(x) #define letoh64(x) __bswap64(x) #endif - #endif #endif diff --git a/libc-top-half/musl/include/features.h b/libc-top-half/musl/include/features.h index f4d651e..85cfb72 100644 --- a/libc-top-half/musl/include/features.h +++ b/libc-top-half/musl/include/features.h @@ -35,4 +35,6 @@ #define _Noreturn #endif +#define __REDIR(x,y) __typeof__(x) x __asm__(#y) + #endif diff --git a/libc-top-half/musl/include/limits.h b/libc-top-half/musl/include/limits.h index 96ca363..a78cb2f 100644 --- a/libc-top-half/musl/include/limits.h +++ b/libc-top-half/musl/include/limits.h @@ -3,9 +3,7 @@ #include -/* Most limits are system-specific */ - -#include +#include /* __LONG_MAX */ /* Support signed or unsigned plain-char */ @@ -17,8 +15,6 @@ #define CHAR_MAX 127 #endif -/* Some universal constants... */ - #define CHAR_BIT 8 #define SCHAR_MIN (-128) #define SCHAR_MAX 127 @@ -30,8 +26,10 @@ #define INT_MAX 0x7fffffff #define UINT_MAX 0xffffffffU #define LONG_MIN (-LONG_MAX-1) +#define LONG_MAX __LONG_MAX #define ULONG_MAX (2UL*LONG_MAX+1) #define LLONG_MIN (-LLONG_MAX-1) +#define LLONG_MAX 0x7fffffffffffffffLL #define ULLONG_MAX (2ULL*LLONG_MAX+1) #define MB_LEN_MAX 4 @@ -39,11 +37,15 @@ #if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +#include + #ifdef __wasilibc_unmodified_upstream /* WASI has no pipes */ #define PIPE_BUF 4096 #endif #define FILESIZEBITS 64 +#ifndef NAME_MAX #define NAME_MAX 255 +#endif #define PATH_MAX 4096 #define NGROUPS_MAX 32 #define ARG_MAX 131072 @@ -55,6 +57,12 @@ #define TTY_NAME_MAX 32 #define HOST_NAME_MAX 255 +#if LONG_MAX == 0x7fffffffL +#define LONG_BIT 32 +#else +#define LONG_BIT 64 +#endif + /* Implementation choices... */ #if defined(__wasilibc_unmodified_upstream) || defined(_REENTRANT) diff --git a/libc-top-half/musl/include/mqueue.h b/libc-top-half/musl/include/mqueue.h index f5cbe79..0c807ea 100644 --- a/libc-top-half/musl/include/mqueue.h +++ b/libc-top-half/musl/include/mqueue.h @@ -30,6 +30,11 @@ ssize_t mq_timedreceive(mqd_t, char *__restrict, size_t, unsigned *__restrict, c int mq_timedsend(mqd_t, const char *, size_t, unsigned, const struct timespec *); int mq_unlink(const char *); +#if _REDIR_TIME64 +__REDIR(mq_timedreceive, __mq_timedreceive_time64); +__REDIR(mq_timedsend, __mq_timedsend_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/netinet/icmp6.h b/libc-top-half/musl/include/netinet/icmp6.h index cf951d9..01269e7 100644 --- a/libc-top-half/musl/include/netinet/icmp6.h +++ b/libc-top-half/musl/include/netinet/icmp6.h @@ -9,7 +9,6 @@ extern "C" { #include #include #include -#include #define ICMP6_FILTER 1 diff --git a/libc-top-half/musl/include/netinet/if_ether.h b/libc-top-half/musl/include/netinet/if_ether.h index 8af47db..a08485e 100644 --- a/libc-top-half/musl/include/netinet/if_ether.h +++ b/libc-top-half/musl/include/netinet/if_ether.h @@ -58,6 +58,7 @@ #define ETH_P_ERSPAN 0x88BE #define ETH_P_PREAUTH 0x88C7 #define ETH_P_TIPC 0x88CA +#define ETH_P_LLDP 0x88CC #define ETH_P_MACSEC 0x88E5 #define ETH_P_8021AH 0x88E7 #define ETH_P_MVRP 0x88F5 diff --git a/libc-top-half/musl/include/netinet/ip.h b/libc-top-half/musl/include/netinet/ip.h index d7fa8d5..0ae132a 100644 --- a/libc-top-half/musl/include/netinet/ip.h +++ b/libc-top-half/musl/include/netinet/ip.h @@ -7,7 +7,6 @@ extern "C" { #include #include -#include struct timestamp { uint8_t len; @@ -191,6 +190,8 @@ struct ip_timestamp { #define IP_MSS 576 +#define __UAPI_DEF_IPHDR 0 + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/netinet/ip6.h b/libc-top-half/musl/include/netinet/ip6.h index a4347a5..50c626a 100644 --- a/libc-top-half/musl/include/netinet/ip6.h +++ b/libc-top-half/musl/include/netinet/ip6.h @@ -7,7 +7,6 @@ extern "C" { #include #include -#include struct ip6_hdr { union { diff --git a/libc-top-half/musl/include/netinet/tcp.h b/libc-top-half/musl/include/netinet/tcp.h index c7a8648..44a007a 100644 --- a/libc-top-half/musl/include/netinet/tcp.h +++ b/libc-top-half/musl/include/netinet/tcp.h @@ -38,6 +38,7 @@ #define TCP_FASTOPEN_NO_COOKIE 34 #define TCP_ZEROCOPY_RECEIVE 35 #define TCP_INQ 36 +#define TCP_TX_DELAY 37 #define TCP_CM_INQ TCP_INQ @@ -97,7 +98,6 @@ enum { #include #include #include -#include typedef uint32_t tcp_seq; @@ -234,6 +234,8 @@ struct tcp_info { uint64_t tcpi_bytes_retrans; uint32_t tcpi_dsack_dups; uint32_t tcpi_reord_seen; + uint32_t tcpi_rcv_ooopack; + uint32_t tcpi_snd_wnd; }; #define TCP_MD5SIG_MAXKEYLEN 80 diff --git a/libc-top-half/musl/include/poll.h b/libc-top-half/musl/include/poll.h index a5a799b..cdbd29a 100644 --- a/libc-top-half/musl/include/poll.h +++ b/libc-top-half/musl/include/poll.h @@ -56,6 +56,12 @@ int poll (struct pollfd *, nfds_t, int); int ppoll(struct pollfd *, nfds_t, const struct timespec *, const sigset_t *); #endif +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +__REDIR(ppoll, __ppoll_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/pthread.h b/libc-top-half/musl/include/pthread.h index a5ea7b0..d4a9b65 100644 --- a/libc-top-half/musl/include/pthread.h +++ b/libc-top-half/musl/include/pthread.h @@ -230,6 +230,16 @@ int pthread_tryjoin_np(pthread_t, void **); int pthread_timedjoin_np(pthread_t, void **, const struct timespec *); #endif +#if _REDIR_TIME64 +__REDIR(pthread_mutex_timedlock, __pthread_mutex_timedlock_time64); +__REDIR(pthread_cond_timedwait, __pthread_cond_timedwait_time64); +__REDIR(pthread_rwlock_timedrdlock, __pthread_rwlock_timedrdlock_time64); +__REDIR(pthread_rwlock_timedwrlock, __pthread_rwlock_timedwrlock_time64); +#ifdef _GNU_SOURCE +__REDIR(pthread_timedjoin_np, __pthread_timedjoin_np_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sched.h b/libc-top-half/musl/include/sched.h index 290e174..36dd4df 100644 --- a/libc-top-half/musl/include/sched.h +++ b/libc-top-half/musl/include/sched.h @@ -20,10 +20,14 @@ extern "C" { struct sched_param { int sched_priority; int __reserved1; +#if _REDIR_TIME64 + long __reserved2[4]; +#else struct { time_t __reserved1; long __reserved2; } __reserved2[2]; +#endif int __reserved3; }; @@ -137,6 +141,10 @@ __CPU_op_func_S(XOR, ^) #endif #endif +#if _REDIR_TIME64 +__REDIR(sched_rr_get_interval, __sched_rr_get_interval_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/semaphore.h b/libc-top-half/musl/include/semaphore.h index 277c47d..3690f49 100644 --- a/libc-top-half/musl/include/semaphore.h +++ b/libc-top-half/musl/include/semaphore.h @@ -29,6 +29,10 @@ int sem_trywait(sem_t *); int sem_unlink(const char *); int sem_wait(sem_t *); +#if _REDIR_TIME64 +__REDIR(sem_timedwait, __sem_timedwait_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/signal.h b/libc-top-half/musl/include/signal.h index 482e1f7..068234f 100644 --- a/libc-top-half/musl/include/signal.h +++ b/libc-top-half/musl/include/signal.h @@ -285,6 +285,14 @@ void (*signal(int, void (*)(int)))(int); #endif int raise(int); +#if _REDIR_TIME64 +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +__REDIR(sigtimedwait, __sigtimedwait_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/acct.h b/libc-top-half/musl/include/sys/acct.h index 9b0ba36..fae9d05 100644 --- a/libc-top-half/musl/include/sys/acct.h +++ b/libc-top-half/musl/include/sys/acct.h @@ -6,7 +6,6 @@ extern "C" { #endif #include -#include #include #include diff --git a/libc-top-half/musl/include/sys/ioctl.h b/libc-top-half/musl/include/sys/ioctl.h index eb90364..3877ca4 100644 --- a/libc-top-half/musl/include/sys/ioctl.h +++ b/libc-top-half/musl/include/sys/ioctl.h @@ -5,6 +5,7 @@ extern "C" { #endif +#include #include #define N_TTY 0 diff --git a/libc-top-half/musl/include/sys/mman.h b/libc-top-half/musl/include/sys/mman.h index 32357ee..e6079c8 100644 --- a/libc-top-half/musl/include/sys/mman.h +++ b/libc-top-half/musl/include/sys/mman.h @@ -96,6 +96,8 @@ extern "C" { #define MADV_DODUMP 17 #define MADV_WIPEONFORK 18 #define MADV_KEEPONFORK 19 +#define MADV_COLD 20 +#define MADV_PAGEOUT 21 #define MADV_HWPOISON 100 #define MADV_SOFT_OFFLINE 101 #endif diff --git a/libc-top-half/musl/include/sys/prctl.h b/libc-top-half/musl/include/sys/prctl.h index 07f0d73..d9c846e 100644 --- a/libc-top-half/musl/include/sys/prctl.h +++ b/libc-top-half/musl/include/sys/prctl.h @@ -154,6 +154,10 @@ struct prctl_mm_map { #define PR_PAC_APDBKEY (1UL << 3) #define PR_PAC_APGAKEY (1UL << 4) +#define PR_SET_TAGGED_ADDR_CTRL 55 +#define PR_GET_TAGGED_ADDR_CTRL 56 +#define PR_TAGGED_ADDR_ENABLE (1UL << 0) + int prctl (int, ...); #ifdef __cplusplus diff --git a/libc-top-half/musl/include/sys/procfs.h b/libc-top-half/musl/include/sys/procfs.h index e23bf1a..38e58c1 100644 --- a/libc-top-half/musl/include/sys/procfs.h +++ b/libc-top-half/musl/include/sys/procfs.h @@ -23,10 +23,9 @@ struct elf_prstatus { pid_t pr_ppid; pid_t pr_pgrp; pid_t pr_sid; - struct timeval pr_utime; - struct timeval pr_stime; - struct timeval pr_cutime; - struct timeval pr_cstime; + struct { + long tv_sec, tv_usec; + } pr_utime, pr_stime, pr_cutime, pr_cstime; elf_gregset_t pr_reg; int pr_fpvalid; }; diff --git a/libc-top-half/musl/include/sys/ptrace.h b/libc-top-half/musl/include/sys/ptrace.h index 229e1f3..5d62a98 100644 --- a/libc-top-half/musl/include/sys/ptrace.h +++ b/libc-top-half/musl/include/sys/ptrace.h @@ -41,6 +41,7 @@ extern "C" { #define PTRACE_SETSIGMASK 0x420b #define PTRACE_SECCOMP_GET_FILTER 0x420c #define PTRACE_SECCOMP_GET_METADATA 0x420d +#define PTRACE_GET_SYSCALL_INFO 0x420e #define PT_READ_I PTRACE_PEEKTEXT #define PT_READ_D PTRACE_PEEKDATA @@ -88,6 +89,11 @@ extern "C" { #define PTRACE_PEEKSIGINFO_SHARED 1 +#define PTRACE_SYSCALL_INFO_NONE 0 +#define PTRACE_SYSCALL_INFO_ENTRY 1 +#define PTRACE_SYSCALL_INFO_EXIT 2 +#define PTRACE_SYSCALL_INFO_SECCOMP 3 + #include struct __ptrace_peeksiginfo_args { @@ -101,6 +107,29 @@ struct __ptrace_seccomp_metadata { uint64_t flags; }; +struct __ptrace_syscall_info { + uint8_t op; + uint8_t __pad[3]; + uint32_t arch; + uint64_t instruction_pointer; + uint64_t stack_pointer; + union { + struct { + uint64_t nr; + uint64_t args[6]; + } entry; + struct { + int64_t rval; + uint8_t is_error; + } exit; + struct { + uint64_t nr; + uint64_t args[6]; + uint32_t ret_data; + } seccomp; + }; +}; + long ptrace(int, ...); #ifdef __cplusplus diff --git a/libc-top-half/musl/include/sys/resource.h b/libc-top-half/musl/include/sys/resource.h index a12e290..8b55331 100644 --- a/libc-top-half/musl/include/sys/resource.h +++ b/libc-top-half/musl/include/sys/resource.h @@ -91,7 +91,8 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); #define RLIMIT_MSGQUEUE 12 #define RLIMIT_NICE 13 #define RLIMIT_RTPRIO 14 -#define RLIMIT_NLIMITS 15 +#define RLIMIT_RTTIME 15 +#define RLIMIT_NLIMITS 16 #define RLIM_NLIMITS RLIMIT_NLIMITS @@ -108,6 +109,10 @@ int prlimit(pid_t, int, const struct rlimit *, struct rlimit *); #include <__header_sys_resource.h> #endif +#if _REDIR_TIME64 +__REDIR(getrusage, __getrusage_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/select.h b/libc-top-half/musl/include/sys/select.h index cb70ea5..1c1adff 100644 --- a/libc-top-half/musl/include/sys/select.h +++ b/libc-top-half/musl/include/sys/select.h @@ -43,6 +43,11 @@ int pselect (int, fd_set *__restrict, fd_set *__restrict, fd_set *__restrict, co #endif #endif +#if _REDIR_TIME64 +__REDIR(select, __select_time64); +__REDIR(pselect, __pselect_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/sem.h b/libc-top-half/musl/include/sys/sem.h index 410c877..a747784 100644 --- a/libc-top-half/musl/include/sys/sem.h +++ b/libc-top-half/musl/include/sys/sem.h @@ -25,8 +25,6 @@ extern "C" { #define SETVAL 16 #define SETALL 17 -#include - #include #define _SEM_SEMUN_UNDEFINED 1 @@ -62,6 +60,12 @@ int semop(int, struct sembuf *, size_t); int semtimedop(int, struct sembuf *, size_t, const struct timespec *); #endif +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +__REDIR(semtimedop, __semtimedop_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/socket.h b/libc-top-half/musl/include/sys/socket.h index 239b038..cea24cf 100644 --- a/libc-top-half/musl/include/sys/socket.h +++ b/libc-top-half/musl/include/sys/socket.h @@ -23,6 +23,44 @@ extern "C" { #include +#ifdef __wasilibc_unmodified_upstream /* Use alternate WASI libc headers */ +struct msghdr { + void *msg_name; + socklen_t msg_namelen; + struct iovec *msg_iov; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +#endif + int msg_iovlen; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +#endif + void *msg_control; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad2; +#endif + socklen_t msg_controllen; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad2; +#endif + int msg_flags; +}; + +struct cmsghdr { +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __BIG_ENDIAN + int __pad1; +#endif + socklen_t cmsg_len; +#if __LONG_MAX > 0x7fffffff && __BYTE_ORDER == __LITTLE_ENDIAN + int __pad1; +#endif + int cmsg_level; + int cmsg_type; +}; +#else +#include <__struct_msghdr.h> +#endif + #ifdef _GNU_SOURCE struct ucred { pid_t pid; @@ -187,8 +225,6 @@ struct linger { #define SO_PEERCRED 17 #define SO_RCVLOWAT 18 #define SO_SNDLOWAT 19 -#define SO_RCVTIMEO 20 -#define SO_SNDTIMEO 21 #define SO_ACCEPTCONN 30 #define SO_PEERSEC 31 #define SO_SNDBUFFORCE 32 @@ -197,6 +233,28 @@ struct linger { #define SO_DOMAIN 39 #endif +#ifndef SO_RCVTIMEO +#if __LONG_MAX == 0x7fffffff +#define SO_RCVTIMEO 66 +#define SO_SNDTIMEO 67 +#else +#define SO_RCVTIMEO 20 +#define SO_SNDTIMEO 21 +#endif +#endif + +#ifndef SO_TIMESTAMP +#if __LONG_MAX == 0x7fffffff +#define SO_TIMESTAMP 63 +#define SO_TIMESTAMPNS 64 +#define SO_TIMESTAMPING 65 +#else +#define SO_TIMESTAMP 29 +#define SO_TIMESTAMPNS 35 +#define SO_TIMESTAMPING 37 +#endif +#endif + #define SO_SECURITY_AUTHENTICATION 22 #define SO_SECURITY_ENCRYPTION_TRANSPORT 23 #define SO_SECURITY_ENCRYPTION_NETWORK 24 @@ -208,14 +266,10 @@ struct linger { #define SO_GET_FILTER SO_ATTACH_FILTER #define SO_PEERNAME 28 -#define SO_TIMESTAMP 29 #define SCM_TIMESTAMP SO_TIMESTAMP - #define SO_PASSSEC 34 -#define SO_TIMESTAMPNS 35 #define SCM_TIMESTAMPNS SO_TIMESTAMPNS #define SO_MARK 36 -#define SO_TIMESTAMPING 37 #define SCM_TIMESTAMPING SO_TIMESTAMPING #define SO_RXQ_OVFL 40 #define SO_WIFI_STATUS 41 @@ -243,6 +297,7 @@ struct linger { #define SO_TXTIME 61 #define SCM_TXTIME SO_TXTIME #define SO_BINDTOIFINDEX 62 +#define SO_DETACH_REUSEPORT_BPF 68 #ifndef SOL_SOCKET #define SOL_SOCKET 1 @@ -378,6 +433,12 @@ int setsockopt (int, int, int, const void *, socklen_t); int sockatmark (int); #endif +#if _REDIR_TIME64 +#ifdef _GNU_SOURCE +__REDIR(recvmmsg, __recvmmsg_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/stat.h b/libc-top-half/musl/include/sys/stat.h index a91b71b..72e1626 100644 --- a/libc-top-half/musl/include/sys/stat.h +++ b/libc-top-half/musl/include/sys/stat.h @@ -126,6 +126,15 @@ int lchmod(const char *, mode_t); #define off64_t off_t #endif +#if _REDIR_TIME64 +__REDIR(stat, __stat_time64); +__REDIR(fstat, __fstat_time64); +__REDIR(lstat, __lstat_time64); +__REDIR(fstatat, __fstatat_time64); +__REDIR(futimens, __futimens_time64); +__REDIR(utimensat, __utimensat_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/statvfs.h b/libc-top-half/musl/include/sys/statvfs.h index ef07d68..793490b 100644 --- a/libc-top-half/musl/include/sys/statvfs.h +++ b/libc-top-half/musl/include/sys/statvfs.h @@ -11,8 +11,6 @@ extern "C" { #define __NEED_fsfilcnt_t #include -#include - struct statvfs { unsigned long f_bsize, f_frsize; fsblkcnt_t f_blocks, f_bfree, f_bavail; diff --git a/libc-top-half/musl/include/sys/time.h b/libc-top-half/musl/include/sys/time.h index 03c297f..389cdcb 100644 --- a/libc-top-half/musl/include/sys/time.h +++ b/libc-top-half/musl/include/sys/time.h @@ -64,6 +64,20 @@ int adjtime (const struct timeval *, struct timeval *); (void)0 ) #endif +#if _REDIR_TIME64 +__REDIR(gettimeofday, __gettimeofday_time64); +__REDIR(getitimer, __getitimer_time64); +__REDIR(setitimer, __setitimer_time64); +__REDIR(utimes, __utimes_time64); +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +__REDIR(futimes, __futimes_time64); +__REDIR(futimesat, __futimesat_time64); +__REDIR(lutimes, __lutimes_time64); +__REDIR(settimeofday, __settimeofday_time64); +__REDIR(adjtime, __adjtime64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/timeb.h b/libc-top-half/musl/include/sys/timeb.h index 108c1f5..628239b 100644 --- a/libc-top-half/musl/include/sys/timeb.h +++ b/libc-top-half/musl/include/sys/timeb.h @@ -4,6 +4,8 @@ extern "C" { #endif +#include + #define __NEED_time_t #include @@ -16,6 +18,10 @@ struct timeb { int ftime(struct timeb *); +#if _REDIR_TIME64 +__REDIR(ftime, __ftime64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/timerfd.h b/libc-top-half/musl/include/sys/timerfd.h index 2794d36..1b832cd 100644 --- a/libc-top-half/musl/include/sys/timerfd.h +++ b/libc-top-half/musl/include/sys/timerfd.h @@ -20,6 +20,11 @@ int timerfd_create(int, int); int timerfd_settime(int, int, const struct itimerspec *, struct itimerspec *); int timerfd_gettime(int, struct itimerspec *); +#if _REDIR_TIME64 +__REDIR(timerfd_settime, __timerfd_settime64); +__REDIR(timerfd_gettime, __timerfd_gettime64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/timex.h b/libc-top-half/musl/include/sys/timex.h index 2e68888..8b417e1 100644 --- a/libc-top-half/musl/include/sys/timex.h +++ b/libc-top-half/musl/include/sys/timex.h @@ -91,6 +91,11 @@ struct timex { int adjtimex(struct timex *); int clock_adjtime(clockid_t, struct timex *); +#if _REDIR_TIME64 +__REDIR(adjtimex, __adjtimex_time64); +__REDIR(clock_adjtime, __clock_adjtime64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/sys/ttydefaults.h b/libc-top-half/musl/include/sys/ttydefaults.h index d251b71..edb55bc 100644 --- a/libc-top-half/musl/include/sys/ttydefaults.h +++ b/libc-top-half/musl/include/sys/ttydefaults.h @@ -6,16 +6,11 @@ #define TTYDEF_LFLAG (ECHO | ICANON | ISIG | IEXTEN | ECHOE|ECHOKE|ECHOCTL) #define TTYDEF_CFLAG (CREAD | CS7 | PARENB | HUPCL) #define TTYDEF_SPEED (B9600) -#define CTRL(x) (x&037) +#define CTRL(x) ((x)&037) #define CEOF CTRL('d') -#ifdef _POSIX_VDISABLE -#define CEOL _POSIX_VDISABLE -#define CSTATUS _POSIX_VDISABLE -#else #define CEOL '\0' #define CSTATUS '\0' -#endif #define CERASE 0177 #define CINTR CTRL('c') diff --git a/libc-top-half/musl/include/sys/wait.h b/libc-top-half/musl/include/sys/wait.h index 50c5c70..d4b1f2e 100644 --- a/libc-top-half/musl/include/sys/wait.h +++ b/libc-top-half/musl/include/sys/wait.h @@ -13,7 +13,8 @@ extern "C" { typedef enum { P_ALL = 0, P_PID = 1, - P_PGID = 2 + P_PGID = 2, + P_PIDFD = 3 } idtype_t; pid_t wait (int *); @@ -53,6 +54,13 @@ pid_t wait4 (pid_t, int *, int, struct rusage *); #define WIFSIGNALED(s) (((s)&0xffff)-1U < 0xffu) #define WIFCONTINUED(s) ((s) == 0xffff) +#if _REDIR_TIME64 +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +__REDIR(wait3, __wait3_time64); +__REDIR(wait4, __wait4_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/threads.h b/libc-top-half/musl/include/threads.h index 8122b3b..52ec310 100644 --- a/libc-top-half/musl/include/threads.h +++ b/libc-top-half/musl/include/threads.h @@ -80,6 +80,12 @@ void tss_delete(tss_t); int tss_set(tss_t, void *); void *tss_get(tss_t); +#if _REDIR_TIME64 +__REDIR(thrd_sleep, __thrd_sleep_time64); +__REDIR(mtx_timedlock, __mtx_timedlock_time64); +__REDIR(cnd_timedwait, __cnd_timedwait_time64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/time.h b/libc-top-half/musl/include/time.h index 899d862..01ba89b 100644 --- a/libc-top-half/musl/include/time.h +++ b/libc-top-half/musl/include/time.h @@ -157,6 +157,34 @@ int stime(const time_t *); time_t timegm(struct tm *); #endif +#if _REDIR_TIME64 +__REDIR(time, __time64); +__REDIR(difftime, __difftime64); +__REDIR(mktime, __mktime64); +__REDIR(gmtime, __gmtime64); +__REDIR(localtime, __localtime64); +__REDIR(ctime, __ctime64); +__REDIR(timespec_get, __timespec_get_time64); +#if defined(_POSIX_SOURCE) || defined(_POSIX_C_SOURCE) \ + || defined(_XOPEN_SOURCE) || defined(_GNU_SOURCE) \ + || defined(_BSD_SOURCE) +__REDIR(gmtime_r, __gmtime64_r); +__REDIR(localtime_r, __localtime64_r); +__REDIR(ctime_r, __ctime64_r); +__REDIR(nanosleep, __nanosleep_time64); +__REDIR(clock_getres, __clock_getres_time64); +__REDIR(clock_gettime, __clock_gettime64); +__REDIR(clock_settime, __clock_settime64); +__REDIR(clock_nanosleep, __clock_nanosleep_time64); +__REDIR(timer_settime, __timer_settime64); +__REDIR(timer_gettime, __timer_gettime64); +#endif +#if defined(_GNU_SOURCE) || defined(_BSD_SOURCE) +__REDIR(stime, __stime64); +__REDIR(timegm, __timegm_time64); +#endif +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/utime.h b/libc-top-half/musl/include/utime.h index dd5ff92..5755bd5 100644 --- a/libc-top-half/musl/include/utime.h +++ b/libc-top-half/musl/include/utime.h @@ -5,6 +5,8 @@ extern "C" { #endif +#include + #define __NEED_time_t #include @@ -16,6 +18,10 @@ struct utimbuf { int utime (const char *, const struct utimbuf *); +#if _REDIR_TIME64 +__REDIR(utime, __utime64); +#endif + #ifdef __cplusplus } #endif diff --git a/libc-top-half/musl/include/utmpx.h b/libc-top-half/musl/include/utmpx.h index 0429014..b293f42 100644 --- a/libc-top-half/musl/include/utmpx.h +++ b/libc-top-half/musl/include/utmpx.h @@ -16,6 +16,7 @@ extern "C" { struct utmpx { short ut_type; + short __ut_pad1; pid_t ut_pid; char ut_line[32]; char ut_id[4]; @@ -25,7 +26,11 @@ struct utmpx { short __e_termination; short __e_exit; } ut_exit; - long ut_session; +#if __BYTE_ORDER == 1234 + int ut_session, __ut_pad2; +#else + int __ut_pad2, ut_session; +#endif struct timeval ut_tv; unsigned ut_addr_v6[4]; char __unused[20]; diff --git a/libc-top-half/musl/ldso/dynlink.c b/libc-top-half/musl/ldso/dynlink.c index 7ac0bf7..afec985 100644 --- a/libc-top-half/musl/ldso/dynlink.c +++ b/libc-top-half/musl/ldso/dynlink.c @@ -107,6 +107,8 @@ struct symdef { struct dso *dso; }; +typedef void (*stage3_func)(size_t *, size_t *); + static struct builtin_tls { char c; struct pthread pt; @@ -183,8 +185,14 @@ static void *laddr_pg(const struct dso *p, size_t v) } return (void *)(v - p->loadmap->segs[j].p_vaddr + p->loadmap->segs[j].addr); } -#define fpaddr(p, v) ((void (*)())&(struct funcdesc){ \ - laddr(p, v), (p)->got }) +static void (*fdbarrier(void *p))() +{ + void (*fd)(); + __asm__("" : "=r"(fd) : "0"(p)); + return fd; +} +#define fpaddr(p, v) fdbarrier((&(struct funcdesc){ \ + laddr(p, v), (p)->got })) #else #define laddr(p, v) (void *)((p)->base + (v)) #define laddr_pg(p, v) laddr(p, v) @@ -1594,13 +1602,14 @@ static void install_new_tls(void) hidden void __dls2(unsigned char *base, size_t *sp) { + size_t *auxv; + for (auxv=sp+1+*sp+1; *auxv; auxv++); + auxv++; if (DL_FDPIC) { void *p1 = (void *)sp[-2]; void *p2 = (void *)sp[-1]; if (!p1) { - size_t *auxv, aux[AUX_CNT]; - for (auxv=sp+1+*sp+1; *auxv; auxv++); - auxv++; + size_t aux[AUX_CNT]; decode_vec(auxv, aux, AUX_CNT); if (aux[AT_BASE]) ldso.base = (void *)aux[AT_BASE]; else ldso.base = (void *)(aux[AT_PHDR] & -4096); @@ -1646,8 +1655,8 @@ hidden void __dls2(unsigned char *base, size_t *sp) * symbolically as a barrier against moving the address * load across the above relocation processing. */ struct symdef dls2b_def = find_sym(&ldso, "__dls2b", 0); - if (DL_FDPIC) ((stage3_func)&ldso.funcdescs[dls2b_def.sym-ldso.syms])(sp); - else ((stage3_func)laddr(&ldso, dls2b_def.sym->st_value))(sp); + if (DL_FDPIC) ((stage3_func)&ldso.funcdescs[dls2b_def.sym-ldso.syms])(sp, auxv); + else ((stage3_func)laddr(&ldso, dls2b_def.sym->st_value))(sp, auxv); } /* Stage 2b sets up a valid thread pointer, which requires relocations @@ -1656,11 +1665,13 @@ hidden void __dls2(unsigned char *base, size_t *sp) * so that loads of the thread pointer and &errno can be pure/const and * thereby hoistable. */ -void __dls2b(size_t *sp) +void __dls2b(size_t *sp, size_t *auxv) { /* Setup early thread pointer in builtin_tls for ldso/libc itself to * use during dynamic linking. If possible it will also serve as the * thread pointer at runtime. */ + search_vec(auxv, &__hwcap, AT_HWCAP); + libc.auxv = auxv; libc.tls_size = sizeof builtin_tls; libc.tls_align = tls_align; if (__init_tp(__copy_tls((void *)builtin_tls)) < 0) { @@ -1668,8 +1679,8 @@ void __dls2b(size_t *sp) } struct symdef dls3_def = find_sym(&ldso, "__dls3", 0); - if (DL_FDPIC) ((stage3_func)&ldso.funcdescs[dls3_def.sym-ldso.syms])(sp); - else ((stage3_func)laddr(&ldso, dls3_def.sym->st_value))(sp); + if (DL_FDPIC) ((stage3_func)&ldso.funcdescs[dls3_def.sym-ldso.syms])(sp, auxv); + else ((stage3_func)laddr(&ldso, dls3_def.sym->st_value))(sp, auxv); } /* Stage 3 of the dynamic linker is called with the dynamic linker/libc @@ -1677,10 +1688,10 @@ void __dls2b(size_t *sp) * process dependencies and relocations for the main application and * transfer control to its entry point. */ -void __dls3(size_t *sp) +void __dls3(size_t *sp, size_t *auxv) { static struct dso app, vdso; - size_t aux[AUX_CNT], *auxv; + size_t aux[AUX_CNT]; size_t i; char *env_preload=0; char *replace_argv0=0; @@ -1693,10 +1704,7 @@ void __dls3(size_t *sp) /* Find aux vector just past environ[] and use it to initialize * global data that may be needed before we can make syscalls. */ __environ = envp; - for (i=argc+1; argv[i]; i++); - libc.auxv = auxv = (void *)(argv+i+1); decode_vec(auxv, aux, AUX_CNT); - __hwcap = aux[AT_HWCAP]; search_vec(auxv, &__sysinfo, AT_SYSINFO); __pthread_self()->sysinfo = __sysinfo; libc.page_size = aux[AT_PAGESZ]; @@ -2237,6 +2245,33 @@ hidden void *__dlsym(void *restrict p, const char *restrict s, void *restrict ra return res; } +hidden void *__dlsym_redir_time64(void *restrict p, const char *restrict s, void *restrict ra) +{ +#if _REDIR_TIME64 + const char *suffix, *suffix2 = ""; + char redir[36]; + + /* Map the symbol name to a time64 version of itself according to the + * pattern used for naming the redirected time64 symbols. */ + size_t l = strnlen(s, sizeof redir); + if (l<4 || l==sizeof redir) goto no_redir; + if (s[l-2]=='_' && s[l-1]=='r') { + l -= 2; + suffix2 = s+l; + } + if (l<4) goto no_redir; + if (!strcmp(s+l-4, "time")) suffix = "64"; + else suffix = "_time64"; + + /* Use the presence of the remapped symbol name in libc to determine + * whether it's one that requires time64 redirection; replace if so. */ + snprintf(redir, sizeof redir, "__%.*s%s%s", (int)l, s, suffix, suffix2); + if (find_sym(&ldso, redir, 1).sym) s = redir; +no_redir: +#endif + return __dlsym(p, s, ra); +} + int dl_iterate_phdr(int(*callback)(struct dl_phdr_info *info, size_t size, void *data), void *data) { struct dso *current; diff --git a/libc-top-half/musl/src/aio/aio_suspend.c b/libc-top-half/musl/src/aio/aio_suspend.c index 9b24b6a..34b66f8 100644 --- a/libc-top-half/musl/src/aio/aio_suspend.c +++ b/libc-top-half/musl/src/aio/aio_suspend.c @@ -73,4 +73,6 @@ int aio_suspend(const struct aiocb *const cbs[], int cnt, const struct timespec } } +#if !_REDIR_TIME64 weak_alias(aio_suspend, aio_suspend64); +#endif diff --git a/libc-top-half/musl/src/complex/cacosh.c b/libc-top-half/musl/src/complex/cacosh.c index 8e42f1a..76127f7 100644 --- a/libc-top-half/musl/src/complex/cacosh.c +++ b/libc-top-half/musl/src/complex/cacosh.c @@ -4,6 +4,9 @@ double complex cacosh(double complex z) { + int zineg = signbit(cimag(z)); + z = cacos(z); - return CMPLX(-cimag(z), creal(z)); + if (zineg) return CMPLX(cimag(z), -creal(z)); + else return CMPLX(-cimag(z), creal(z)); } diff --git a/libc-top-half/musl/src/complex/cacoshf.c b/libc-top-half/musl/src/complex/cacoshf.c index d7e6b54..8bd8058 100644 --- a/libc-top-half/musl/src/complex/cacoshf.c +++ b/libc-top-half/musl/src/complex/cacoshf.c @@ -2,6 +2,9 @@ float complex cacoshf(float complex z) { + int zineg = signbit(cimagf(z)); + z = cacosf(z); - return CMPLXF(-cimagf(z), crealf(z)); + if (zineg) return CMPLXF(cimagf(z), -crealf(z)); + else return CMPLXF(-cimagf(z), crealf(z)); } diff --git a/libc-top-half/musl/src/complex/cacoshl.c b/libc-top-half/musl/src/complex/cacoshl.c index d3eaee2..3a284be 100644 --- a/libc-top-half/musl/src/complex/cacoshl.c +++ b/libc-top-half/musl/src/complex/cacoshl.c @@ -8,7 +8,10 @@ long double complex cacoshl(long double complex z) #else long double complex cacoshl(long double complex z) { + int zineg = signbit(cimagl(z)); + z = cacosl(z); - return CMPLXL(-cimagl(z), creall(z)); + if (zineg) return CMPLXL(cimagl(z), -creall(z)); + else return CMPLXL(-cimagl(z), creall(z)); } #endif diff --git a/libc-top-half/musl/src/complex/catanf.c b/libc-top-half/musl/src/complex/catanf.c index e10d9c0..ef3907a 100644 --- a/libc-top-half/musl/src/complex/catanf.c +++ b/libc-top-half/musl/src/complex/catanf.c @@ -87,29 +87,17 @@ float complex catanf(float complex z) x = crealf(z); y = cimagf(z); - if ((x == 0.0f) && (y > 1.0f)) - goto ovrf; - x2 = x * x; a = 1.0f - x2 - (y * y); - if (a == 0.0f) - goto ovrf; t = 0.5f * atan2f(2.0f * x, a); w = _redupif(t); t = y - 1.0f; a = x2 + (t * t); - if (a == 0.0f) - goto ovrf; t = y + 1.0f; a = (x2 + (t * t))/a; - w = w + (0.25f * logf (a)) * I; - return w; - -ovrf: - // FIXME - w = MAXNUMF + MAXNUMF * I; + w = CMPLXF(w, 0.25f * logf(a)); return w; } diff --git a/libc-top-half/musl/src/complex/catanl.c b/libc-top-half/musl/src/complex/catanl.c index a9fc02d..e62526c 100644 --- a/libc-top-half/musl/src/complex/catanl.c +++ b/libc-top-half/musl/src/complex/catanl.c @@ -97,30 +97,18 @@ long double complex catanl(long double complex z) x = creall(z); y = cimagl(z); - if ((x == 0.0L) && (y > 1.0L)) - goto ovrf; - x2 = x * x; a = 1.0L - x2 - (y * y); - if (a == 0.0L) - goto ovrf; t = atan2l(2.0L * x, a) * 0.5L; w = redupil(t); t = y - 1.0L; a = x2 + (t * t); - if (a == 0.0L) - goto ovrf; t = y + 1.0L; a = (x2 + (t * t)) / a; - w = w + (0.25L * logl(a)) * I; - return w; - -ovrf: - // FIXME - w = LDBL_MAX + LDBL_MAX * I; + w = CMPLXF(w, 0.25L * logl(a)); return w; } #endif diff --git a/libc-top-half/musl/src/ctype/alpha.h b/libc-top-half/musl/src/ctype/alpha.h index 299277c..4167f38 100644 --- a/libc-top-half/musl/src/ctype/alpha.h +++ b/libc-top-half/musl/src/ctype/alpha.h @@ -8,17 +8,17 @@ 17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, 17,17,17,17,17,17,17,63,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,64,65,17,66,67, -68,69,70,71,72,73,74,17,75,76,77,78,79,80,16,16,16,81,82,83,84,85,86,87,88,89, -16,90,16,91,92,16,16,17,17,17,93,94,95,16,16,16,16,16,16,16,16,16,16,17,17,17, -17,96,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,97,16,16,16,16,16,16, +68,69,70,71,72,73,74,17,75,76,77,78,79,80,81,16,82,83,84,85,86,87,88,89,90,91, +92,93,16,94,95,96,16,17,17,17,97,98,99,16,16,16,16,16,16,16,16,16,16,17,17,17, +17,100,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,17,101,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,17,17,98,99,16,16,16,100,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17,17, -17,17,17,17,17,17,17,101,17,17,102,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,103, -104,16,16,16,16,16,16,16,16,16,105,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,106,107,108,109,16,16,16,16,16,16,16,16,110,16,16, -16,16,16,16,16,111,112,16,16,16,16,113,16,16,114,16,16,16,16,16,16,16,16,16, -16,16,16,16, +16,16,17,17,102,103,16,16,104,105,17,17,17,17,17,17,17,17,17,17,17,17,17,17, +17,17,17,17,17,17,17,17,17,106,17,17,107,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17, +108,109,16,16,16,16,16,16,16,16,16,110,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,16,16,16,16,16,16,16,111,112,113,114,16,16,16,16,16,16,16,16,115,116, +117,16,16,16,16,16,118,119,16,16,16,16,120,16,16,121,16,16,16,16,16,16,16,16, +16,16,16,16,16, 16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,254,255,255,7,254, @@ -27,8 +27,8 @@ 255,195,255,3,0,31,80,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,223,188,64,215,255,255, 251,255,255,255,255,255,255,255,255,255,191,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,3,252,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,254,255,255,255,127,2,254,255,255, -255,255,0,0,0,0,0,255,191,182,0,255,255,255,7,7,0,0,0,255,7,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,254,255,255,255,127,2,255,255,255, +255,255,1,0,0,0,0,255,191,182,0,255,255,255,135,7,0,0,0,255,7,255,255,255,255, 255,255,255,254,255,195,255,255,255,255,255,255,255,255,255,255,255,255,239, 31,254,225,255, 159,0,0,255,255,255,255,255,255,0,224,255,255,255,255,255,255,255,255,255,255, @@ -42,54 +42,55 @@ 255,0,0,239,223,253,255,255,253,239,227,223,29,96,64,207,255,6,0,239,223,253, 255,255,255,255,231,223,93,240,128,207,255,0,252,236,255,127,252,255,255,251, 47,127,128,95,255,192,255,12,0,254,255,255,255,255,127,255,7,63,32,255,3,0,0, -0,0,150,37,240,254,174,236,255,59,95,32,255,243,0,0,0, +0,0,214,247,255,255,175,255,255,59,95,32,255,243,0,0,0, 0,1,0,0,0,255,3,0,0,255,254,255,255,255,31,254,255,3,255,255,254,255,255,255, -31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249,255,3,255,255,231,193,255, -255,127,64,255,51,255,255,255,255,191,32,255,255,255,255,255,247,255,255,255, +31,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,249,255,3,255,255,255,255,255, +255,255,255,255,63,255,255,255,255,191,32,255,255,255,255,255,247,255,255,255, 255,255,255,255,255,255,61,127,61,255,255,255,255,255,61,255,255,255,255,61, 127,61,255,127,255,255,255,255,255,255,255,61,255,255,255,255,255,255,255,255, -135,0,0,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,63,63,254,255, +7,0,0,0,0,255,255,0,0,255,255,255,255,255,255,255,255,255,255,63,63,254,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,159,255,255,254,255,255,7,255,255,255,255,255,255,255,255, 255,199,255,1,255,223,15,0,255,255,15,0,255,255,15,0,255,223,13,0,255,255,255, 255,255,255,207,255,255,1,128,16,255,3,0,0,0,0,255,3,255,255,255,255,255,255, -255,255,255,255,255,0,255,255,255,255,255,7,255,255,255,255,255,255,255,255, +255,255,255,255,255,1,255,255,255,255,255,7,255,255,255,255,255,255,255,255, 63, 0,255,255,255,127,255,15,255,1,192,255,255,255,255,63,31,0,255,255,255,255, 255,15,255,255,255,3,255,3,0,0,0,0,255,255,255,15,255,255,255,255,255,255,255, 127,254,255,31,0,255,3,255,3,128,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255, 255,239,255,239,15,255,3,0,0,0,0,255,255,255,255,255,243,255,255,255,255,255, -255,191,255,3,0,255,255,255,255,255,255,63,0,255,227,255,255,255,255,255,63, -255,1,0,0,0,0,0,0,0,0,0,0,0,222,111,0,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,128,255,31,0, -255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,255,255,255,255, -255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,128, -0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255,243,224,67,0,0, -255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0, +255,191,255,3,0,255,255,255,255,255,255,127,0,255,227,255,255,255,255,255,63, +255,1,255,255,255,255,255,231,0,0,0,0,0,222,111,4,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0, +128,255,31,0,255,255,63,63,255,255,255,255,63,63,255,170,255,255,255,63,255, +255,255,255,255,255,223,95,220,31,207,15,255,31,220,31,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,2,128,0,0,255,31,0,0,0,0,0,0,0,0,0,0,0,0,132,252,47,62,80,189,255,243, +224,67,0,0,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,255,255,255,255,255,255,3,0, 0,255,255,255,255,255,127,255,255,255,255,255,127,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,31,120,12,0,255,255,255,255,191,32,255, 255,255,255,255,255,255,128,0,0,255,255,127,0,127,127,127,127,127,127,127,127, 255,255,255,255,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,224,0,0,0,254,3,62,31,254,255,255,255,255,255,255,255,255,255,127,224,254, -255,255,255,255,255,255,255,255,255,255,247,224,255,255,255,255,127,254,255, +255,255,255,255,255,255,255,255,255,255,247,224,255,255,255,255,255,254,255, 255,255,255,255,255,255,255,255,255,127,0,0,255,255,255,7,0,0,0,0,0,0,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,63,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,0, 0,0,0,0,0,0,255,255,255,255,255,63,255,31,255,255,255,15,0,0,255,255,255,255, 255,127,240,143,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0, 0,128,255,252,255,255,255,255,255,255,255,255,255,255,255,255,249,255,255,255, -127,255,0,0,0,0,0,0,0,128,255,187,247,255,255,255,0,0,0,255,255,255,255,255, -255,15,0,255,255,255,255,255,255,255,255,47,0,255,3,0,0,252,40,255,255,255, -255,255,7,255,255,255,255,7,0,255,255,255,31,255,255,255,255,255,255,247,255, -0,128,255,3,223,255,255,127,255,255,255,255,255,255,127,0,255,63,255,3,255, -255,127,196,255,255,255,255,255,255,255,127,5,0,0,56,255,255,60,0,126,126,126, -0,127,127,255,255,255,255,255,247,63,0,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255,255,255, +255,255,255,124,0,0,0,0,0,128,255,191,255,255,255,255,0,0,0,255,255,255,255, +255,255,15,0,255,255,255,255,255,255,255,255,47,0,255,3,0,0,252,232,255,255, +255,255,255,7,255,255,255,255,7,0,255,255,255,31,255,255,255,255,255,255,247, +255,0,128,255,3,255,255,255,127,255,255,255,255,255,255,127,0,255,63,255,3, +255,255,127,252,255,255,255,255,255,255,255,127,5,0,0,56,255,255,60,0,126,126, +126,0,127,127,255,255,255,255,255,247,255,0,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,7,255,3,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,15,0,255,255,127,248,255,255,255,255, +255, 15,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255,255,255, 255,255,255,255,255,255,255,255,3,0,0,0,0,127,0,248,224,255,253,127,95,219, 255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0,0,248,255,255,255, @@ -109,55 +110,63 @@ 0,0,0,0,0,0,0,0,0,0,0,0,63,253,255,255,255,255,191,145,255,255,63,0,255,255, 127,0,255,255,255,127,0,0,0,0,0,0,0,0,255,255,55,0,255,255,63,0,255,255,255,3, 0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,192,0,0,0,0,0,0,0,0,111,240,239, -254,255,255,15,0,0,0,0,0,255,255,255,31,255,255,255,31,0,0,0,0,255,254,255, +254,255,255,63,0,0,0,0,0,255,255,255,31,255,255,255,31,0,0,0,0,255,254,255, 255,31,0,0,0,255,255,255,255,255,255,63,0,255,255,63,0,255,255,7,0,255,255,3, 0,0,0,0,0,0,0,0,0,0,0,0, 0,255,255,255,255,255,255,255,255,255,1,0,0,0,0,0,0,255,255,255,255,255,255,7, -0,255,255,255,255,255,255,7,0,255,255,255,255,255,255,255,255,63,0,0,0,192, -255,0,0,252,255,255,255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,255,255, -255,255,199,255,0,0,255,255,255,255,71,0,255,255,255,255,255,255,255,255,30,0, -255,23,0,0,0,0,255,255,251,255,255,255,159,64,0,0,0,0,0,0,0,0,127,189,255,191, -255,1,255,255,255,255,255,255,255,1,255,3,239,159,249,255,255,253,237,227,159, -25,129,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255, -255,255,187,7,255,3,0,0,0,0,255,255,255,255,255,255,255,255,179,0,255,3,0,0,0, +0,255,255,255,255,255,255,7,0,255,255,255,255,255,0,255,3,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,31,128,0,255,255,63,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,255,255,127,0,255,255,255,255,255,255,255,255,63,0,0,0, +192,255,0,0,252,255,255,255,255,255,255,1,0,0,255,255,255,1,255,3,255,255,255, +255,255,255,199,255,112,0,255,255,255,255,71,0,255,255,255,255,255,255,255, +255,30,0,255,23,0,0,0,0,255,255,251,255,255,255,159,64,0,0,0,0,0,0,0,0,127, +189,255,191,255,1,255,255,255,255,255,255,255,1,255,3,239,159,249,255,255,253, +237,227,159,25,129,224,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255, +255,255,255,255,255,187,7,255,131,0,0,0,0,255,255,255,255,255,255,255,255,179, +0,255,3,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,63,127,0,0,0,63,0,0, 0,0,255,255,255,255,255,255,255,127,17,0,255,3,0,0,0,0,255,255,255,255,255, -255,63,0,255,3,0,0,0,0,0, -0,255,255,255,227,255,7,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,3, -0,128,255,255,255,255,255,255,231,127,0,0,255,255,255,255,255,255,207,255,255, -0,0,0,0,0,255,255,255,255,255,255,255,1,255,253,255,255,255,255,127,127,1,0, -255,3,0,0,252,255,255,255,252,255,255,254,127,0,0,0,0,0,0,0,0,0,127,251,255, -255,255,255,127,180,203,0,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, +255,63,1,255,3,0,0,0,0,0,0,255,255,255,231,255,7,255,3,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0, +0,255,255,255,255,255,255,255,255,255,3,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,255,252,255,255,255,255,255,252,26,0,0,0,255,255,255,255,255,255,231, +127,0,0,255,255,255,255,255,255,255,255,255,32,0,0,0,0,255,255,255,255,255, +255,255,1,255,253,255,255,255,255,127,127,1,0,255,3,0,0,252,255,255,255,252, +255,255,254,127,0,0,0,0,0,0,0,0,0,127,251,255,255,255,255,127,180,203,0,255,3, +191,253,255,255,255,127,123,1,255,3,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,127,0,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,3,0,0, 0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,127,0, 0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -255,255,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,255,255,255,255,255,255,255,1,255,255,255,127,255,3,0,0,0,0,0,0,0,0,0,0,0, -0,255,255,255,63,0,0,255,255,255,255,255,255,127,0,15,0,255,3,248,255,255,224, -255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,31,0,255, -255,255,255,255,127,0,0,248,255,0,0,0,0,0,0,0,0,3,0,0,0,255,255,255,255,255, +255,255,255,255,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, +255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, +255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, +255,255,255,255,255,255,1,255,255,255,127,255,3,0,0,0,0,0,0,0,0,0,0,0,0,255, +255,255,63,0,0,255,255,255,255,255,255,0,0,15,0,255,3,248,255,255,224,255,255, +0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,255,255,255,255,255,255,255,255,255,135,255,255,255,255,255,255,255,128, +255,255,0,0,0,0,0,0,0,0,11,0,0,0,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,31,0,0,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,7,0, -255,255,255,127,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255, +255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,7,0,255,255,255,127,0,0,0,0,0, +0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,15,255,255,255,255,255, -255,255,255,255,255,255,255,255,7,255,31,255,1,255,67,0,0,0,0,0,0,0,0,0,0,0,0, -255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,255,255,255, -223,100,222,255,235,239,255,255,255,255,255,255,255,191,231,223,223,255,255, -255,123,95,252,253,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,255,255,255,255, +255,255,255,255,255,255,255,255,255,7,255,31,255,1,255,67,0,0,0,0,0,0,0,0,0,0, +0,0,255,255,255,255,255,255,255,255,255,255,223,255,255,255,255,255,255,255, +255,223,100,222,255,235,239,255,255,255,255,255,255, +255,191,231,223,223,255,255,255,123,95,252,253,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,63,255,255,255,253,255,255,247,255,255,255, -247,255,255,223,255,255,255,223,255,255,127,255,255,255,127,255,255,255,253, -255,255,255,253,255,255,247,207,255,255,255,255,255,255,127,255,255,249,219,7, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0, -0,0,0,0,0, -0,255,255,255,255,255,255,255,255,143,0,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,239,255,255,255,150,254,247,10,132,234,150,170,150,247,247,94,255,251, -255,15,238,251,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,3,255,255,255,3, -255,255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,63,255,255,255, +253,255,255,247,255,255,255,247,255,255,223,255,255,255,223,255,255,127,255, +255,255,127,255,255,255,253,255,255,255,253,255,255,247,207,255,255,255,255, +255,255,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,255,255,255,255,255,31,128,63,255,67,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255, +15,255,3,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,31,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255, +143,8,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,239,255,255,255,150,254,247,10,132,234,150,170,150,247,247,94,255,251,255, +15,238,251,255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,3,255,255,255,3,255, +255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/libc-top-half/musl/src/ctype/casemap.h b/libc-top-half/musl/src/ctype/casemap.h new file mode 100644 index 0000000..6ee1209 --- /dev/null +++ b/libc-top-half/musl/src/ctype/casemap.h @@ -0,0 +1,297 @@ +static const unsigned char tab[] = { + 7, 8, 9, 10, 11, 12, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 13, 6, 6, 14, 6, 6, 6, 6, 6, 6, 6, 6, 15, 16, 17, 18, + 6, 19, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 20, 21, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 22, 23, 6, 6, 6, 24, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 25, + 6, 6, 6, 6, 26, 6, 6, 6, 6, 6, 6, 6, 27, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 28, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 29, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 30, 6, 6, 6, 6, 6, 6, + 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, + 43, 43, 43, 43, 43, 43, 43, 43, 1, 0, 84, 86, 86, 86, 86, 86, + 86, 86, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 24, 0, 0, 0, 43, 43, 43, 43, 43, 43, + 43, 7, 43, 43, 91, 86, 86, 86, 86, 86, 86, 86, 74, 86, 86, 5, + 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, + 36, 80, 121, 49, 80, 49, 80, 49, 56, 80, 49, 80, 49, 80, 49, 80, + 49, 80, 49, 80, 49, 80, 49, 80, 78, 49, 2, 78, 13, 13, 78, 3, + 78, 0, 36, 110, 0, 78, 49, 38, 110, 81, 78, 36, 80, 78, 57, 20, + 129, 27, 29, 29, 83, 49, 80, 49, 80, 13, 49, 80, 49, 80, 49, 80, + 27, 83, 36, 80, 49, 2, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, + 20, 121, 92, 123, 92, 123, 92, 45, 43, 73, 3, 72, 3, 120, 92, 123, + 20, 0, 150, 10, 1, 43, 40, 6, 6, 0, 42, 6, 42, 42, 43, 7, + 187, 181, 43, 30, 0, 43, 7, 43, 43, 43, 1, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 1, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 205, 70, 205, 43, 0, 37, 43, 7, 1, 6, 1, 85, 86, 86, 86, + 86, 86, 85, 86, 86, 2, 36, 129, 129, 129, 129, 129, 21, 129, 129, 129, + 0, 0, 43, 0, 178, 209, 178, 209, 178, 209, 178, 209, 0, 0, 205, 204, + 1, 0, 215, 215, 215, 215, 215, 131, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 172, 172, 172, 172, 172, 172, 172, 172, 172, 172, 28, 0, 0, 0, + 0, 0, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 2, 0, 0, + 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, + 49, 80, 78, 49, 80, 49, 80, 78, 49, 80, 49, 80, 49, 80, 49, 80, + 49, 80, 49, 80, 49, 80, 49, 2, 135, 166, 135, 166, 135, 166, 135, 166, + 135, 166, 135, 166, 135, 166, 135, 166, 42, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 0, 0, 0, 84, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 84, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 12, 0, 12, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 7, 42, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 86, 86, 108, 129, 21, 0, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 7, 108, 3, 65, 43, 43, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 44, 86, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 12, 108, 0, 0, 0, 0, 0, 6, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, + 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, + 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, + 6, 37, 6, 37, 6, 37, 6, 37, 86, 122, 158, 38, 6, 37, 6, 37, + 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, + 6, 37, 6, 37, 6, 37, 6, 37, 6, 37, 6, 1, 43, 43, 79, 86, + 86, 44, 43, 127, 86, 86, 57, 43, 43, 85, 86, 86, 43, 43, 79, 86, + 86, 44, 43, 127, 86, 86, 129, 55, 117, 91, 123, 92, 43, 43, 79, 86, + 86, 2, 172, 4, 0, 0, 57, 43, 43, 85, 86, 86, 43, 43, 79, 86, + 86, 44, 43, 43, 86, 86, 50, 19, 129, 87, 0, 111, 129, 126, 201, 215, + 126, 45, 129, 129, 14, 126, 57, 127, 111, 87, 0, 129, 129, 126, 21, 0, + 126, 3, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 7, 43, + 36, 43, 151, 43, 43, 43, 43, 43, 43, 43, 43, 43, 42, 43, 43, 43, + 43, 43, 86, 86, 86, 86, 86, 128, 129, 129, 129, 129, 57, 187, 42, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 1, 129, 129, 129, 129, 129, 129, 129, 129, + 129, 129, 129, 129, 129, 129, 129, 201, 172, 172, 172, 172, 172, 172, 172, 172, + 172, 172, 172, 172, 172, 172, 172, 208, 13, 0, 78, 49, 2, 180, 193, 193, + 215, 215, 36, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, + 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, 49, 80, + 49, 80, 49, 80, 215, 215, 83, 193, 71, 212, 215, 215, 215, 5, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 7, 1, 0, 1, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 78, 49, 80, 49, 80, 49, 80, + 49, 80, 49, 80, 49, 80, 49, 80, 13, 0, 0, 0, 0, 0, 36, 80, + 49, 80, 49, 80, 49, 80, 49, 80, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 121, 92, 123, 92, 123, 79, 123, 92, 123, 92, 123, + 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 123, 92, 45, + 43, 43, 121, 20, 92, 123, 92, 45, 121, 42, 92, 39, 92, 123, 92, 123, + 92, 123, 164, 0, 10, 180, 92, 123, 92, 123, 79, 3, 42, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 1, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 72, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 43, 43, 43, 43, 43, 43, 43, 43, 7, 0, 72, 86, 86, 86, 86, + 86, 86, 86, 86, 2, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 43, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 85, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 86, 86, 86, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 36, 43, 43, 43, 43, 43, 43, 43, 43, 43, + 43, 43, 7, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 36, 43, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 7, 0, 0, + 0, 0, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 86, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 42, 43, 43, + 43, 43, 43, 43, 43, 43, 43, 43, 86, 86, 86, 86, 86, 86, 86, 86, + 86, 86, 14, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 42, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 86, 86, + 86, 86, 86, 86, 86, 86, 86, 86, 14, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 43, 85, + 86, 86, 86, 86, 86, 86, 86, 86, 86, 86, 14, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +static const int rules[] = { + 0x0, 0x2001, -0x2000, 0x1dbf00, 0x2e700, 0x7900, + 0x2402, 0x101, -0x100, 0x0, 0x201, -0x200, + -0xc6ff, -0xe800, -0x78ff, -0x12c00, 0xc300, 0xd201, + 0xce01, 0xcd01, 0x4f01, 0xca01, 0xcb01, 0xcf01, + 0x6100, 0xd301, 0xd101, 0xa300, 0xd501, 0x8200, + 0xd601, 0xda01, 0xd901, 0xdb01, 0x3800, 0x3, + -0x4f00, -0x60ff, -0x37ff, 0x242802, 0x0, 0x101, + -0x100, -0xcd00, -0xda00, -0x81ff, 0x2a2b01, -0xa2ff, + 0x2a2801, 0x2a3f00, -0xc2ff, 0x4501, 0x4701, 0x2a1f00, + 0x2a1c00, 0x2a1e00, -0xd200, -0xce00, -0xca00, -0xcb00, + 0xa54f00, 0xa54b00, -0xcf00, 0xa52800, 0xa54400, -0xd100, + -0xd300, 0x29f700, 0xa54100, 0x29fd00, -0xd500, -0xd600, + 0x29e700, 0xa54300, 0xa52a00, -0x4500, -0xd900, -0x4700, + -0xdb00, 0xa51500, 0xa51200, 0x4c2402, 0x0, 0x2001, + -0x2000, 0x101, -0x100, 0x5400, 0x7401, 0x2601, + 0x2501, 0x4001, 0x3f01, -0x2600, -0x2500, -0x1f00, + -0x4000, -0x3f00, 0x801, -0x3e00, -0x3900, -0x2f00, + -0x3600, -0x800, -0x5600, -0x5000, 0x700, -0x7400, + -0x3bff, -0x6000, -0x6ff, 0x701a02, 0x101, -0x100, + 0x2001, -0x2000, 0x5001, 0xf01, -0xf00, 0x0, + 0x3001, -0x3000, 0x101, -0x100, 0x0, 0xbc000, + 0x1c6001, 0x0, 0x97d001, 0x801, -0x800, 0x8a0502, + 0x0, -0xbbfff, -0x186200, 0x89c200, -0x182500, -0x186e00, + -0x186d00, -0x186400, -0x186300, -0x185c00, 0x0, 0x8a3800, + 0x8a0400, 0xee600, 0x101, -0x100, 0x0, -0x3b00, + -0x1dbeff, 0x8f1d02, 0x800, -0x7ff, 0x0, 0x5600, + -0x55ff, 0x4a00, 0x6400, 0x8000, 0x7000, 0x7e00, + 0x900, -0x49ff, -0x8ff, -0x1c2500, -0x63ff, -0x6fff, + -0x7fff, -0x7dff, 0xac0502, 0x0, 0x1001, -0x1000, + 0x1c01, 0x101, -0x1d5cff, -0x20beff, -0x2045ff, -0x1c00, + 0xb10b02, 0x101, -0x100, 0x3001, -0x3000, 0x0, + -0x29f6ff, -0xee5ff, -0x29e6ff, -0x2a2b00, -0x2a2800, -0x2a1bff, + -0x29fcff, -0x2a1eff, -0x2a1dff, -0x2a3eff, 0x0, -0x1c6000, + 0x0, 0x101, -0x100, 0xbc0c02, 0x0, 0x101, + -0x100, -0xa543ff, 0x3a001, -0x8a03ff, -0xa527ff, 0x3000, + -0xa54eff, -0xa54aff, -0xa540ff, -0xa511ff, -0xa529ff, -0xa514ff, + -0x2fff, -0xa542ff, -0x8a37ff, 0x0, -0x97d000, -0x3a000, + 0x0, 0x2001, -0x2000, 0x0, 0x2801, -0x2800, + 0x0, 0x4001, -0x4000, 0x0, 0x2001, -0x2000, + 0x0, 0x2001, -0x2000, 0x0, 0x2201, -0x2200, +}; +static const unsigned char rulebases[] = { + 0, 6, 39, 81, 111, 119, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 124, 0, 0, 127, 0, 0, 0, 0, 0, 0, 0, 0, 131, 142, 146, 151, + 0, 170, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 180, 196, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 198, 201, 0, 0, 0, 219, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 222, + 0, 0, 0, 0, 225, 0, 0, 0, 0, 0, 0, 0, 228, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 231, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 234, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 237, 0, 0, 0, 0, 0, 0, + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, +}; +static const unsigned char exceptions[][2] = { + { 48, 12 }, { 49, 13 }, { 120, 14 }, { 127, 15 }, + { 128, 16 }, { 129, 17 }, { 134, 18 }, { 137, 19 }, + { 138, 19 }, { 142, 20 }, { 143, 21 }, { 144, 22 }, + { 147, 19 }, { 148, 23 }, { 149, 24 }, { 150, 25 }, + { 151, 26 }, { 154, 27 }, { 156, 25 }, { 157, 28 }, + { 158, 29 }, { 159, 30 }, { 166, 31 }, { 169, 31 }, + { 174, 31 }, { 177, 32 }, { 178, 32 }, { 183, 33 }, + { 191, 34 }, { 197, 35 }, { 200, 35 }, { 203, 35 }, + { 221, 36 }, { 242, 35 }, { 246, 37 }, { 247, 38 }, + { 32, 45 }, { 58, 46 }, { 61, 47 }, { 62, 48 }, + { 63, 49 }, { 64, 49 }, { 67, 50 }, { 68, 51 }, + { 69, 52 }, { 80, 53 }, { 81, 54 }, { 82, 55 }, + { 83, 56 }, { 84, 57 }, { 89, 58 }, { 91, 59 }, + { 92, 60 }, { 97, 61 }, { 99, 62 }, { 101, 63 }, + { 102, 64 }, { 104, 65 }, { 105, 66 }, { 106, 64 }, + { 107, 67 }, { 108, 68 }, { 111, 66 }, { 113, 69 }, + { 114, 70 }, { 117, 71 }, { 125, 72 }, { 130, 73 }, + { 135, 74 }, { 137, 75 }, { 138, 76 }, { 139, 76 }, + { 140, 77 }, { 146, 78 }, { 157, 79 }, { 158, 80 }, + { 69, 87 }, { 123, 29 }, { 124, 29 }, { 125, 29 }, + { 127, 88 }, { 134, 89 }, { 136, 90 }, { 137, 90 }, + { 138, 90 }, { 140, 91 }, { 142, 92 }, { 143, 92 }, + { 172, 93 }, { 173, 94 }, { 174, 94 }, { 175, 94 }, + { 194, 95 }, { 204, 96 }, { 205, 97 }, { 206, 97 }, + { 207, 98 }, { 208, 99 }, { 209, 100 }, { 213, 101 }, + { 214, 102 }, { 215, 103 }, { 240, 104 }, { 241, 105 }, + { 242, 106 }, { 243, 107 }, { 244, 108 }, { 245, 109 }, + { 249, 110 }, { 253, 45 }, { 254, 45 }, { 255, 45 }, + { 80, 105 }, { 81, 105 }, { 82, 105 }, { 83, 105 }, + { 84, 105 }, { 85, 105 }, { 86, 105 }, { 87, 105 }, + { 88, 105 }, { 89, 105 }, { 90, 105 }, { 91, 105 }, + { 92, 105 }, { 93, 105 }, { 94, 105 }, { 95, 105 }, + { 130, 0 }, { 131, 0 }, { 132, 0 }, { 133, 0 }, + { 134, 0 }, { 135, 0 }, { 136, 0 }, { 137, 0 }, + { 192, 117 }, { 207, 118 }, { 128, 137 }, { 129, 138 }, + { 130, 139 }, { 133, 140 }, { 134, 141 }, { 112, 157 }, + { 113, 157 }, { 118, 158 }, { 119, 158 }, { 120, 159 }, + { 121, 159 }, { 122, 160 }, { 123, 160 }, { 124, 161 }, + { 125, 161 }, { 179, 162 }, { 186, 163 }, { 187, 163 }, + { 188, 164 }, { 190, 165 }, { 195, 162 }, { 204, 164 }, + { 218, 166 }, { 219, 166 }, { 229, 106 }, { 234, 167 }, + { 235, 167 }, { 236, 110 }, { 243, 162 }, { 248, 168 }, + { 249, 168 }, { 250, 169 }, { 251, 169 }, { 252, 164 }, + { 38, 176 }, { 42, 177 }, { 43, 178 }, { 78, 179 }, + { 132, 8 }, { 98, 186 }, { 99, 187 }, { 100, 188 }, + { 101, 189 }, { 102, 190 }, { 109, 191 }, { 110, 192 }, + { 111, 193 }, { 112, 194 }, { 126, 195 }, { 127, 195 }, + { 125, 207 }, { 141, 208 }, { 148, 209 }, { 171, 210 }, + { 172, 211 }, { 173, 212 }, { 176, 213 }, { 177, 214 }, + { 178, 215 }, { 196, 216 }, { 197, 217 }, { 198, 218 }, +}; diff --git a/libc-top-half/musl/src/ctype/nonspacing.h b/libc-top-half/musl/src/ctype/nonspacing.h index 48231e7..5d05a3d 100644 --- a/libc-top-half/musl/src/ctype/nonspacing.h +++ b/libc-top-half/musl/src/ctype/nonspacing.h @@ -8,16 +8,16 @@ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,49,16,16,50, -51,16,52,53,54,16,16,16,16,16,16,55,16,16,16,16,16,56,57,58,59,60,61,62,63,16, -16,64,16,65,66,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +51,16,52,53,54,16,16,16,16,16,16,55,16,16,56,16,57,58,59,60,61,62,63,64,65,66, +67,68,16,69,70,71,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,72,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,73,74,16,16,16,75,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,67,68,16,16,16,69,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,70,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,71,72,16,16,16,16,16,16,16,73,16,16,16,16,16,74,16,16,16,16,16,16,16,75, -76,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,16,16,16,16,76,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,77,78,16,16,16,16,16,16,16,79,16,16,16,16,16,80,81,82,16,16,16,16,16,83, +84,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, @@ -25,16 +25,16 @@ 0,0,0,0,0,0,0,248,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,254,255,255,255,255,191,182,0,0,0,0,0,0,0,63,0,255,23,0,0,0,0,0,248,255, 255,0,0,1,0,0,0,0,0,0,0,0,0,0,0,192,191,159,61,0,0,0,128,2,0,0,0,255,255,255, -7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,0,0,0,0,0,248,15,0,0,0,192,251,239,62,0,0,0, -0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,255,255,255,255, +7,0,0,0,0,0,0,0,0,0,0,192,255,1,0,0,0,0,0,0,248,15,32,0,0,192,251,239,62,0,0, +0,0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,255,255,255,255, 255,7,0,0,0,0,0,0,20,254,33,254,0,12,0,0,0,2,0,0,0,0,0,0,16,30,32,0,0,12,0,0, -0,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,190,33,0,0,12,0,0,252, -2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,1,0,0, -0,0,0,0,192,193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,3,0,0,0, -0,0,0,24,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0,0,0,0,0,0,0,0,0,242, -7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,27,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160,2,0, -0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0,0, -224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,0,0,0, +64,6,0,0,0,0,0,0,16,134,57,2,0,0,0,35,0,6,0,0,0,0,0,0,16,190,33,0,0,12,0,0, +252,2,0,0,0,0,0,0,144,30,32,64,0,12,0,0,0,4,0,0,0,0,0,0,0,1,32,0,0,0,0,0,0,17, +0,0,0,0,0,0,192,193,61,96,0,12,0,0,0,2,0,0,0,0,0,0,144,64,48,0,0,12,0,0,0,3,0, +0,0,0,0,0,24,30,32,0,0,12,0,0,0,0,0,0,0,0,0,0,0,0,4,92,0,0,0,0,0,0,0,0,0,0,0, +242,7,128,127,0,0,0,0,0,0,0,0,0,0,0,0,242,31,0,63,0,0,0,0,0,0,0,0,0,3,0,0,160, +2,0,0,0,0,0,0,254,127,223,224,255,254,255,255,255,31,64,0,0,0,0,0,0,0,0,0,0,0, +0,224,253,102,0,0,0,195,1,0,30,0,100,32,0,32,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,224,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0, 0,0,28,0,0,0,12,0,0,0,12,0,0,0,0,0,0,0,176,63,64,254,15,32,0,0,0,0,0,120,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,96,0,0,0,0,2,0,0,0,0,0,0,0,0,0,0,0,0,0,0,135,1,4,14,0, @@ -48,9 +48,9 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,0,0,0,0, 0,60,0,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,128,247,63,0,0,0,192,0,0,0,0,0,0,0,0,0,0,3,0,68,8,0,0,96,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,0,0,0,0,0,192,63,0,0,128,255,3,0,0, -0,0,0,7,0,0,0,0,0,200,19,0,0,0,0,32,0,0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0,0, -16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64, +0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,0,255,255,3,128,0,0,0,0,192,63,0,0,128,255,3,0, +0,0,0,0,7,0,0,0,0,0,200,51,0,0,0,0,32,0,0,0,0,0,0,0,0,126,102,0,8,16,0,0,0,0, +0,16,0,0,0,0,0,0,157,193,2,0,0,0,0,48,64, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,32,33,0,0,0,0,0,64, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0,255,255,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0, @@ -58,24 +58,32 @@ 0,0,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,110,240,0,0,0,0,0,135,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,0,0, -0,2,0,0,0,0,0,0,255,127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,0,0,0,0,0,0,0,0,7, -0,0,0,128,239,31,0,0,0,0,0,0,0,8,0,3,0,0,0,0,0,192,127,0,28,0,0,0,0,0,0,0,0,0, -0,0,128,211,64,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,3,0,0,0,0, -0,0,16,1,0,0,0,192,31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, -92,0,0,0,0,0,0,0,0,0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,60,176,1,0,0,48,0,0,0,0,0,0,0,0,0,0,248,167,1,0,0,0,0,0,0, -0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,0,0,224,188,15,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0, -0,126,6,0,0,0,0,248,121,128,0,126,14,0,0,0,0,0,252,127,3,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,127,191,0,0,0,0,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,126,180,191,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,127, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -96,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,231,15,0,0, -0,60,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, -255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248,254,255,0,0,0, -0,0,0,0,0,0,0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0, -0,0,0,0,0,0,0,240,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,192,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,255, +127,0,0,0,0,0,0,128,3,0,0,0,0,0,120,38,0,32,0,0,0,0,0,0,7,0,0,0,128,239,31,0, +0,0,0,0,0,0,8,0,3,0,0,0,0,0,192,127,0,30,0,0,0,0,0,0,0,0,0,0,0,128,211,64,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,248,7,0,0,3,0,0,0,0,0,0,24,1,0,0,0,192, +31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,92,0,0,64,0,0,0,0,0, +0,0,0,0,0,248,133,13,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,60,176,1,0,0,48,0,0,0, +0,0,0,0,0,0,0,248,167,1,0,0,0,0,0,0,0,0,0,0,0,0,40,191,0,0,0,0,0,0,0,0,0,0,0, +0,224,188,15,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +128,255,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,12,1,0,0,0,254,7,0,0,0,0,248,121,128,0, +126,14,0,0,0,0,0,252,127,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,191,0,0,0, +0,0,0,0,0,0,0,252,255,255,252,109,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,126,180,191,0, +0,0,0,0,0,0,0,0,163,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,24, +0,0,0,0,0,0,0,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,127,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0, +0,128,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,96,15, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,3,248,255,231,15,0,0,0,60,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,28,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,255,255,255,255,255,255,127,248,255,255,255,255,255,31,32,0,16,0,0,248, +254,255,0,0,0,0,0,0,0,0,0, +0,127,255,255,249,219,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,240,7,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/libc-top-half/musl/src/ctype/punct.h b/libc-top-half/musl/src/ctype/punct.h index 7a62394..6792947 100644 --- a/libc-top-half/musl/src/ctype/punct.h +++ b/libc-top-half/musl/src/ctype/punct.h @@ -8,17 +8,17 @@ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,64,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,65,16,16,66,16,67,68, -69,16,70,71,72,16,73,16,16,74,75,76,77,78,16,79,16,80,81,82,83,84,85,86,87,88, -16,89,16,90,91,16,16,16,16,16,16,92,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +69,16,70,71,72,16,73,16,16,74,75,76,77,78,16,79,80,81,82,83,84,85,86,87,88,89, +90,91,16,92,93,94,95,16,16,16,16,96,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,97,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,98,99,16,16,100,101,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,93,94,16,16,16,95,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,96,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,97,98,99,100,16,16,101,102,17,17,103,16,16,16,16,16,16,16,16,16,16,16,16, -16,104,105,16,16,16,16,106,16,107,108,109,17,17,17,110,111,112,113,16,16,16, -16,16, +16,16,16,16,16,16,16,16,102,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, +16,16,16,103,104,105,106,16,16,107,108,17,17,109,16,16,16,16,16,16,110,111,16, +16,16,16,16,112,113,16,16,114,115,116,16,117,118,119,17,17,17,120,121,122,123, +124,16,16,16,16, 16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,254,255,0,252,1,0,0,248,1, @@ -28,25 +28,25 @@ 0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,252,0,0,0,0,0,230,254,255,255,255,0,64,73,0,0,0,0,0,24,0,255,255,0,216, 0,0,0,0,0,0,0,1,0,60,0,0,0,0,0,0,0,0,0,0,0,0,16,224,1,30,0, -96,255,191,0,0,0,0,0,0,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,207,3, -0,0,0,3,0,32,255,127,0,0,0,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,7,252,0,0,0,0,0, -0,0,0,0,16,0,32,30,0,48,0,1,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,252,47,0,0,0,0,0, -0,0,16,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,3,224,0,0,0,0,0,0,0,16, -0,32,0,0,0,0,253,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,255,7,0,0,0,0,0,0,0,0,0,32,0, -0,0,0,0,255,0,0,0,0,0,0,0,16,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,160,0,127,0, -0,255,3,0,0,0,0,0,0,0,0,0,4,0,0,0,0,16,0,0,0,0,0,0,128,0,128,192,223,0,12,0,0, -0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0, +96,255,191,0,0,0,0,0,0,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,248,207, +227,0,0,0,3,0,32,255,127,0,0,0,78,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,7,252,0,0,0, +0,0,0,0,0,0,16,0,32,30,0,48,0,1,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,252,111,0,0,0, +0,0,0,0,16,0,32,0,0,0,0,64,0,0,0,0,0,0,0,0,16,0,32,0,0,0,0,3,224,0,0,0,0,0,0, +0,16,0,32,0,0,0,0,253,0,0,0,0,0,0,0,0,0,0,32,0,0,0,0,255,7,16,0,0,0,0,0,0,0,0, +32,0,0,0,0,128,255,16,0,0,0,0,0,0,16,0,32,0,0,0,0,0,0,0,0,0,0,0,0,0,24,0,160, +0,127,0,0,255,3,0,0,0,0,0,0,0,0,0,4,0,0,0,0,16,0,0,0,0,0,0,128,0,128,192,223, +0,12,0,0,0,0,0,0,0,0,0,0,0,4,0,31,0,0,0,0,0, 0,254,255,255,255,0,252,255,255,0,0,0,0,0,0,0,0,252,0,0,0,0,0,0,192,255,223, -255,7,0,0,0,0,0,0,0,0,0,0,128,6,0,252,0,0,24,62,0,0,128,191,0,204,0,0,0,0,0,0, -0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,96,255,255,255,31,0,0,255,3,0,0,0,0,0,0,0,0, -0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,96,0,0,1,0,0,24,0,0,0,0,0,0,0,0,0,56,0,0,0,0,16,0,0,0,112, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,254,127,47,0,0,255,3,255,127,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,49,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,196,255,255,255, +255,7,0,0,0,0,0,0,0,0,0,0,128,6,0,252,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0, +0,0,8,0,0,0,0,0,0,0,0,0,0,0,224,255,255,255,31,0,0,255,3,0,0,0,0,0,0,0,0,0,0, +0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,96,0,0,1,0,0,24,0,0,0,0,0,0,0,0,0,56,0,0,0,0,16,0,0,0,112,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,48,0,0,254,127,47,0,0,255,3,255,127,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,14,49,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,196,255,255,255, 255,0,0,0,192,0,0,0,0,0,0,0,0,1,0,224,159,0,0,0,0,127,63,255,127,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,16,0,16,0,0,252,255,255,255,31,0,0,0,0,0,12,0,0,0,0,0,0,64,0, -12,240,0,0,0,0,0,0,192,248,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,255,0,255,255, +12,240,0,0,0,0,0,0,128,248,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,255,0,255,255, 255,33,144,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255, 127,0,224,251,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,160,3,224,0,224,0, 224,0,96,128,248,255,255,255,252,255,255,255,255,255,127,223,255,241,127,255, @@ -55,22 +55,23 @@ 255,255,255,255,255,127,0,0,0,255,7,0,0,255,255,255,255,255,255,255,255,255, 255,63,0,0,0,0,0,0,252,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,207,255,255,255, -63,255,255,255,255,227,255,253,7,0,0,240,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,224,135,3,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,128,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,127,255,255,255,3,0,0,0,0,0,0, -255,255,255,251,255,255,255,255,255,255,255,255,255,255,15,0,255,255,255,255, +63,255,255,255,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,224,135,3,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1, +128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,127,255,255,255,255,0, +0,0,0,0,0,255,255,255,251,255,255,255,255,255,255,255,255,255,255,15,0,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,63,0,0,0,255,15,30,255,255,255,1,252,193,224,0,0,0,0,0,0,0,0,0,0, -0,30,1,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,0,0, -0,0,255,255,255,255,15,0,0,0,255,255,255,127,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,63,0,0,0,255,15,30,255,255,255,1,252,193,224,0,0,0,0, +0,0,0,0,0,0,0,30,1,0,0,0,0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +255,255,0,0,0,0,255,255,255,255,15,0,0,0,255,255,255,127,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255, +255,255,255, +255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255, 255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,127,0,0,0, 0,0,0,192,0,224,0,0,0,0,0,0,0,0,0,0,0,128,15,112,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 255,0,255,255,127,0,3,0,0,0,0,0,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -68,8,0,0,0,15,255,3,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,16,192,0,0,255,255,3,23, -0,0,0,0,0,248,0,0,0,0,8,128,0,0,0,0,0,0,0,0,0,0,8,0,255,63,0,192,32,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,240,0,0,128,59,0,0,0,0,0,0,0,128,2,0,0,192,0,0,67,0,0,0,0,0, +64,0,0,0,0,15,255,3,0,0,0,0,0,0,240,0,0,0,0,0,0,0,0,0,16,192,0,0,255,255,3,23, +0,0,0,0,0,248,0,0,0,0,8,128,0,0,0,0,0,0,0,0,0,0,8,0,255,63,0,192,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,240,0,0,128,3,0,0,0,0,0,0,0,128,2,0,0,192,0,0,67,0,0,0,0,0, 0,0,0,0,0,0,0,8,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,56,0, 0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,2,0,0,0,0,0,0, @@ -84,46 +85,57 @@ 0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 128,255,0,0,128,255,0,0,0,0,128,255,0,0,0,0,0,0,0,0,0,248,0,0,192,143,0,0,0, 128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,48,255,255,252,255,255,255,255,255,0,0,0,0, -0,0,0,135,255,0,255,1,0,0,0,224,0,0,0,224,0,0,0,0,0,1,0,0,96,248,127,0,0,0,0, +0,0,0,135,255,1,255,1,0,0,0,224,0,0,0,224,0,0,0,0,0,1,0,0,96,248,127,0,0,0,0, 0,0,0,0,254,0,0,0,255,0,0,0,255,0,0,0,30,0,254,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,0,0,0,0,0,0,0,0,0,0,0, 0,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,192,63,252,255,63,0,0,128,3,0,0,0,0,0,0,254,3,0,0,0,0,0,0,0, -0,0,0,0,0,0,24,0,15,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,225,63,0,232,254,255,31,0, -0,0,0,0,0,0,96,63,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0, -0,16,0,32,0,0,192,31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68, -248,0,40,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,128,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,128,14,0,0,0,255,31, -0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,252,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,224,127,0,0,0,192,255,255,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,192,63,252,255,63,0,0,128,3,0,0,0,0,0,0,254,3,32,0,0,0,0,0,0,0, +0,0,0,0,0,24,0,15,0,0,0,0,0,56,0,0,0,0,0,0,0,0,0,225,63,0,232,254,255,31,0,0, +0,0,0,0,0,96,63,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,0,0,0,0,0,6,0,0,0,0,0,0,0,0,0, +24,0,32,0,0,192,31,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,68, +248,0,104,0,0,0,0,0,0,0,0,0,0,0,0,76,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,128,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,128,14,0,0,0,255, +31,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,8,0,252,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,14,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,7,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,5,0,0,0,0,0,0,0,0,0,24,128,255,0,0,0,0,0, +0,0,0,0,0,223,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,62,0,0,252,255,31,3,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52,0,0,0,0,0,0,0,0,0,128,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,128,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255, +255,3, +128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,255,255,48,0,0,248, +3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, +255,255,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,4,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,15,0,0,0,0,0,0, +0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,63, +0,255,255,255,255,127,254,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,1,0,0,255,255,255,255,255,255,255,255, +63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,15,0,255,255,255,255,255,255, +255,255,255,255,127,0,255,255,255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0,0,8,0,0,0,8,0,0,32,0,0,0,32,0,0,128, +0,0,0,128,0,0,0,2,0,0,0,2,0,0,8,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,15,0,248,254,255,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,127,0,0,128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,240,0, +128,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,255,127,0,0,0,0,0,0,0, +0,0,0,0,0,0,112,7,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,254,255,255,255,255,255,255,255,31,0,0,0,0,0,0,0,0,0,254,255, +255,255,255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,255,255,255,255,255, +15,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,127,254,255,254, +255,254,255,255,255,63,0,255,31,255,255,255,255,0,0,0,252,0,0,0,28,0,0,0,252, +255,255,255,31,0,0,0,0,0,0,192,255,255,255,7,0,255,255,255,255,255,15,255,1,3, +0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,63,0,255,31,255,7,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,1, +255,15,0,0,255,15,255,255,255,255,255,255,255,0,255,3,255,255,255,255,255,0, +255,255,255,63,0,0,0,0,0,0,0,0,0,0,255,239,255,255,255,255,255,255,255,255, +255,255,255,255,123,252,255,255,255,255,231,199,255,255,255,231,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,63,15,7,7,0,63,0, 0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,252,7,0,0,0,0,0,0, -0,24,128,255,0,0,0,0,0,0,0,0,0,0,223,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -128,62,0,0,252,255,31,3,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,52, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,31, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,192,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,63,0,0,0,0,0,0,0,128,255,48,0,0,248,3,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,7,0,0,0,0,0,0,0,0,0,0,0, -0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,176,15,0,0,0,0,0,0,0,0,0,0,0,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,63,0,255,255,255,255,127,254,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,1,0,0,255,255,255,255,255,255,255,255,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,127,0,255,255,3,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,0, -0,8,0,0,0,8,0,0,32,0,0,0,32,0,0,128,0,0,0,128,0,0,0,2,0,0,0,2,0,0,8,0,0,0,0,0, -0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,0, -248,254,255,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,255,127,0,0,0,0,0,0,0,0, -0,0,0,0,0,112,7,0,192,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,3,0,255,255,255,255,255,15,255, -255,255,255,255,255,255,255,255,255,255,255,15,0,255,127,254,255,254,255,254, -255,255,255,63,0,255,31,255,255,255,127,0,0,0,252,0,0,0,12,0,0,0,252,255,255, -255,31,0,0,0,0,0,0,192,255,255,255,7,0,255,255,255,255,255,15,255,1,3,0,63,0, -0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0,255,31, -255,1,255,255,255,255,255,255,255,255,255,255,255,255,255,255,15,0,255,255, -255,255,255,255,255,255,255,255,31,0,0,0,0, -0,255,15,255,255,255,255,255,255,255,0,255,3,255,255,255,255,255,0,255,255, -255,63,0,0,0,0,0,0,0,0,0,0,255,15,255,255,255,255,255,127,255,31,255,255,255, -15,0,0,255,255,255,0,0,0,0,0,1,0,255,255,127,0,0,0, diff --git a/libc-top-half/musl/src/ctype/towctrans.c b/libc-top-half/musl/src/ctype/towctrans.c index 8f68101..76d1376 100644 --- a/libc-top-half/musl/src/ctype/towctrans.c +++ b/libc-top-half/musl/src/ctype/towctrans.c @@ -1,307 +1,73 @@ -#include -#include #include -#define CASEMAP(u1,u2,l) { (u1), (l)-(u1), (u2)-(u1)+1 } -#define CASELACE(u1,u2) CASEMAP((u1),(u2),(u1)+1) +static const unsigned char tab[]; -static const struct { - unsigned short upper; - signed char lower; - unsigned char len; -} casemaps[] = { - CASEMAP(0xc0,0xde,0xe0), +static const unsigned char rulebases[512]; +static const int rules[]; - CASELACE(0x0100,0x012e), - CASELACE(0x0132,0x0136), - CASELACE(0x0139,0x0147), - CASELACE(0x014a,0x0176), - CASELACE(0x0179,0x017d), +static const unsigned char exceptions[][2]; - CASELACE(0x370,0x372), - CASEMAP(0x391,0x3a1,0x3b1), - CASEMAP(0x3a3,0x3ab,0x3c3), - CASEMAP(0x400,0x40f,0x450), - CASEMAP(0x410,0x42f,0x430), +#include "casemap.h" - CASELACE(0x460,0x480), - CASELACE(0x48a,0x4be), - CASELACE(0x4c1,0x4cd), - CASELACE(0x4d0,0x50e), - - CASELACE(0x514,0x52e), - CASEMAP(0x531,0x556,0x561), - - CASELACE(0x01a0,0x01a4), - CASELACE(0x01b3,0x01b5), - CASELACE(0x01cd,0x01db), - CASELACE(0x01de,0x01ee), - CASELACE(0x01f8,0x021e), - CASELACE(0x0222,0x0232), - CASELACE(0x03d8,0x03ee), - - CASELACE(0x1e00,0x1e94), - CASELACE(0x1ea0,0x1efe), - - CASEMAP(0x1f08,0x1f0f,0x1f00), - CASEMAP(0x1f18,0x1f1d,0x1f10), - CASEMAP(0x1f28,0x1f2f,0x1f20), - CASEMAP(0x1f38,0x1f3f,0x1f30), - CASEMAP(0x1f48,0x1f4d,0x1f40), - - CASEMAP(0x1f68,0x1f6f,0x1f60), - CASEMAP(0x1f88,0x1f8f,0x1f80), - CASEMAP(0x1f98,0x1f9f,0x1f90), - CASEMAP(0x1fa8,0x1faf,0x1fa0), - CASEMAP(0x1fb8,0x1fb9,0x1fb0), - CASEMAP(0x1fba,0x1fbb,0x1f70), - CASEMAP(0x1fc8,0x1fcb,0x1f72), - CASEMAP(0x1fd8,0x1fd9,0x1fd0), - CASEMAP(0x1fda,0x1fdb,0x1f76), - CASEMAP(0x1fe8,0x1fe9,0x1fe0), - CASEMAP(0x1fea,0x1feb,0x1f7a), - CASEMAP(0x1ff8,0x1ff9,0x1f78), - CASEMAP(0x1ffa,0x1ffb,0x1f7c), - - CASEMAP(0x13f0,0x13f5,0x13f8), - CASELACE(0xa698,0xa69a), - CASELACE(0xa796,0xa79e), - - CASELACE(0x246,0x24e), - CASELACE(0x510,0x512), - CASEMAP(0x2160,0x216f,0x2170), - CASEMAP(0x2c00,0x2c2e,0x2c30), - CASELACE(0x2c67,0x2c6b), - CASELACE(0x2c80,0x2ce2), - CASELACE(0x2ceb,0x2ced), - - CASELACE(0xa640,0xa66c), - CASELACE(0xa680,0xa696), - - CASELACE(0xa722,0xa72e), - CASELACE(0xa732,0xa76e), - CASELACE(0xa779,0xa77b), - CASELACE(0xa77e,0xa786), - - CASELACE(0xa790,0xa792), - CASELACE(0xa7a0,0xa7a8), - - CASELACE(0xa7b4,0xa7b6), - - CASEMAP(0xff21,0xff3a,0xff41), - { 0,0,0 } -}; - -static const unsigned short pairs[][2] = { - { 'I', 0x0131 }, - { 'S', 0x017f }, - { 0x0130, 'i' }, - { 0x0178, 0x00ff }, - { 0x0181, 0x0253 }, - { 0x0182, 0x0183 }, - { 0x0184, 0x0185 }, - { 0x0186, 0x0254 }, - { 0x0187, 0x0188 }, - { 0x0189, 0x0256 }, - { 0x018a, 0x0257 }, - { 0x018b, 0x018c }, - { 0x018e, 0x01dd }, - { 0x018f, 0x0259 }, - { 0x0190, 0x025b }, - { 0x0191, 0x0192 }, - { 0x0193, 0x0260 }, - { 0x0194, 0x0263 }, - { 0x0196, 0x0269 }, - { 0x0197, 0x0268 }, - { 0x0198, 0x0199 }, - { 0x019c, 0x026f }, - { 0x019d, 0x0272 }, - { 0x019f, 0x0275 }, - { 0x01a6, 0x0280 }, - { 0x01a7, 0x01a8 }, - { 0x01a9, 0x0283 }, - { 0x01ac, 0x01ad }, - { 0x01ae, 0x0288 }, - { 0x01af, 0x01b0 }, - { 0x01b1, 0x028a }, - { 0x01b2, 0x028b }, - { 0x01b7, 0x0292 }, - { 0x01b8, 0x01b9 }, - { 0x01bc, 0x01bd }, - { 0x01c4, 0x01c6 }, - { 0x01c4, 0x01c5 }, - { 0x01c5, 0x01c6 }, - { 0x01c7, 0x01c9 }, - { 0x01c7, 0x01c8 }, - { 0x01c8, 0x01c9 }, - { 0x01ca, 0x01cc }, - { 0x01ca, 0x01cb }, - { 0x01cb, 0x01cc }, - { 0x01f1, 0x01f3 }, - { 0x01f1, 0x01f2 }, - { 0x01f2, 0x01f3 }, - { 0x01f4, 0x01f5 }, - { 0x01f6, 0x0195 }, - { 0x01f7, 0x01bf }, - { 0x0220, 0x019e }, - { 0x0386, 0x03ac }, - { 0x0388, 0x03ad }, - { 0x0389, 0x03ae }, - { 0x038a, 0x03af }, - { 0x038c, 0x03cc }, - { 0x038e, 0x03cd }, - { 0x038f, 0x03ce }, - { 0x0399, 0x0345 }, - { 0x0399, 0x1fbe }, - { 0x03a3, 0x03c2 }, - { 0x03f7, 0x03f8 }, - { 0x03fa, 0x03fb }, - { 0x1e60, 0x1e9b }, - { 0x1e9e, 0xdf }, - - { 0x1f59, 0x1f51 }, - { 0x1f5b, 0x1f53 }, - { 0x1f5d, 0x1f55 }, - { 0x1f5f, 0x1f57 }, - { 0x1fbc, 0x1fb3 }, - { 0x1fcc, 0x1fc3 }, - { 0x1fec, 0x1fe5 }, - { 0x1ffc, 0x1ff3 }, - - { 0x23a, 0x2c65 }, - { 0x23b, 0x23c }, - { 0x23d, 0x19a }, - { 0x23e, 0x2c66 }, - { 0x241, 0x242 }, - { 0x243, 0x180 }, - { 0x244, 0x289 }, - { 0x245, 0x28c }, - { 0x3f4, 0x3b8 }, - { 0x3f9, 0x3f2 }, - { 0x3fd, 0x37b }, - { 0x3fe, 0x37c }, - { 0x3ff, 0x37d }, - { 0x4c0, 0x4cf }, - - { 0x2126, 0x3c9 }, - { 0x212a, 'k' }, - { 0x212b, 0xe5 }, - { 0x2132, 0x214e }, - { 0x2183, 0x2184 }, - { 0x2c60, 0x2c61 }, - { 0x2c62, 0x26b }, - { 0x2c63, 0x1d7d }, - { 0x2c64, 0x27d }, - { 0x2c6d, 0x251 }, - { 0x2c6e, 0x271 }, - { 0x2c6f, 0x250 }, - { 0x2c70, 0x252 }, - { 0x2c72, 0x2c73 }, - { 0x2c75, 0x2c76 }, - { 0x2c7e, 0x23f }, - { 0x2c7f, 0x240 }, - { 0x2cf2, 0x2cf3 }, - - { 0xa77d, 0x1d79 }, - { 0xa78b, 0xa78c }, - { 0xa78d, 0x265 }, - { 0xa7aa, 0x266 }, - - { 0x10c7, 0x2d27 }, - { 0x10cd, 0x2d2d }, - - /* bogus greek 'symbol' letters */ - { 0x376, 0x377 }, - { 0x39c, 0xb5 }, - { 0x392, 0x3d0 }, - { 0x398, 0x3d1 }, - { 0x3a6, 0x3d5 }, - { 0x3a0, 0x3d6 }, - { 0x39a, 0x3f0 }, - { 0x3a1, 0x3f1 }, - { 0x395, 0x3f5 }, - { 0x3cf, 0x3d7 }, - - { 0xa7ab, 0x25c }, - { 0xa7ac, 0x261 }, - { 0xa7ad, 0x26c }, - { 0xa7ae, 0x26a }, - { 0xa7b0, 0x29e }, - { 0xa7b1, 0x287 }, - { 0xa7b2, 0x29d }, - { 0xa7b3, 0xab53 }, - - /* special cyrillic lowercase forms */ - { 0x412, 0x1c80 }, - { 0x414, 0x1c81 }, - { 0x41e, 0x1c82 }, - { 0x421, 0x1c83 }, - { 0x422, 0x1c84 }, - { 0x422, 0x1c85 }, - { 0x42a, 0x1c86 }, - { 0x462, 0x1c87 }, - { 0xa64a, 0x1c88 }, - - { 0,0 } -}; - - -static wchar_t __towcase(wchar_t wc, int lower) +static int casemap(unsigned c, int dir) { - int i; - int lmul = 2*lower-1; - int lmask = lower-1; - /* no letters with case in these large ranges */ - if (!iswalpha(wc) - || (unsigned)wc - 0x0600 <= 0x0fff-0x0600 - || (unsigned)wc - 0x2e00 <= 0xa63f-0x2e00 - || (unsigned)wc - 0xa800 <= 0xab52-0xa800 - || (unsigned)wc - 0xabc0 <= 0xfeff-0xabc0) - return wc; - /* special case because the diff between upper/lower is too big */ - if (lower && (unsigned)wc - 0x10a0 < 0x2e) - if (wc>0x10c5 && wc != 0x10c7 && wc != 0x10cd) return wc; - else return wc + 0x2d00 - 0x10a0; - if (!lower && (unsigned)wc - 0x2d00 < 0x26) - if (wc>0x2d25 && wc != 0x2d27 && wc != 0x2d2d) return wc; - else return wc + 0x10a0 - 0x2d00; - if (lower && (unsigned)wc - 0x13a0 < 0x50) - return wc + 0xab70 - 0x13a0; - if (!lower && (unsigned)wc - 0xab70 < 0x50) - return wc + 0x13a0 - 0xab70; - for (i=0; casemaps[i].len; i++) { - int base = casemaps[i].upper + (lmask & casemaps[i].lower); - if ((unsigned)wc-base < casemaps[i].len) { - if (casemaps[i].lower == 1) - return wc + lower - ((wc-casemaps[i].upper)&1); - return wc + lmul*casemaps[i].lower; + unsigned b, x, y, v, rt, xb, xn; + int r, rd, c0 = c; + + if (c >= 0x20000) return c; + + b = c>>8; + c &= 255; + x = c/3; + y = c%3; + + /* lookup entry in two-level base-6 table */ + v = tab[tab[b]*86+x]; + static const int mt[] = { 2048, 342, 57 }; + v = (v*mt[y]>>11)%6; + + /* use the bit vector out of the tables as an index into + * a block-specific set of rules and decode the rule into + * a type and a case-mapping delta. */ + r = rules[rulebases[b]+v]; + rt = r & 255; + rd = r >> 8; + + /* rules 0/1 are simple lower/upper case with a delta. + * apply according to desired mapping direction. */ + if (rt < 2) return c0 + (rd & -(rt^dir)); + + /* binary search. endpoints of the binary search for + * this block are stored in the rule delta field. */ + xn = rd & 0xff; + xb = (unsigned)rd >> 8; + while (xn) { + unsigned try = exceptions[xb+xn/2][0]; + if (try == c) { + r = rules[exceptions[xb+xn/2][1]]; + rt = r & 255; + rd = r >> 8; + if (rt < 2) return c0 + (rd & -(rt^dir)); + /* Hard-coded for the four exceptional titlecase */ + return c0 + (dir ? -1 : 1); + } else if (try > c) { + xn /= 2; + } else { + xb += xn/2; + xn -= xn/2; } } - for (i=0; pairs[i][1-lower]; i++) { - if (pairs[i][1-lower] == wc) - return pairs[i][lower]; - } - if ((unsigned)wc - (0x10428 - 0x28*lower) < 0x28) - return wc - 0x28 + 0x50*lower; - if ((unsigned)wc - (0x104d8 - 0x28*lower) < 0x24) - return wc - 0x28 + 0x50*lower; - if ((unsigned)wc - (0x10cc0 - 0x40*lower) < 0x33) - return wc - 0x40 + 0x80*lower; - if ((unsigned)wc - (0x118c0 - 0x20*lower) < 0x20) - return wc - 0x20 + 0x40*lower; - if ((unsigned)wc - (0x1e922 - 0x22*lower) < 0x22) - return wc - 0x22 + 0x44*lower; - return wc; -} - -wint_t towupper(wint_t wc) -{ - return (unsigned)wc < 128 ? toupper(wc) : __towcase(wc, 0); + return c0; } wint_t towlower(wint_t wc) { - return (unsigned)wc < 128 ? tolower(wc) : __towcase(wc, 1); + return casemap(wc, 0); +} + +wint_t towupper(wint_t wc) +{ + return casemap(wc, 1); } wint_t __towupper_l(wint_t c, locale_t l) diff --git a/libc-top-half/musl/src/ctype/wcwidth.c b/libc-top-half/musl/src/ctype/wcwidth.c index 49c40ee..36256a5 100644 --- a/libc-top-half/musl/src/ctype/wcwidth.c +++ b/libc-top-half/musl/src/ctype/wcwidth.c @@ -23,7 +23,7 @@ int wcwidth(wchar_t wc) return -1; if (wc-0x20000U < 0x20000) return 2; - if (wc == 0xe0001 || wc-0xe0020U < 0x5f || wc-0xe0100 < 0xef) + if (wc == 0xe0001 || wc-0xe0020U < 0x5f || wc-0xe0100U < 0xef) return 0; return 1; } diff --git a/libc-top-half/musl/src/ctype/wide.h b/libc-top-half/musl/src/ctype/wide.h index e4672b2..e403c9a 100644 --- a/libc-top-half/musl/src/ctype/wide.h +++ b/libc-top-half/musl/src/ctype/wide.h @@ -17,7 +17,7 @@ 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,17,38,39,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, 16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16,16, -16,16,16,16,16,16,16,40,41,42,43,44,45,46,16,16,47,16,16,16,16,16, +16,16,16,16,16,16,16,40,41,42,43,44,45,46,47,16,48,49,16,16,16,16, 16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, @@ -31,10 +31,10 @@ 255,255,255,15,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,63,0,0,0,255,15,255,255,255,255, 255,255,255,127,254,255,255,255,255,255,255,255,255,255,127,254,255,255,255, -255,255,255,255,255,255,255,255,255,224,255,255,255,255,127,254,255,255,255, +255,255,255,255,255,255,255,255,255,224,255,255,255,255,255,254,255,255,255, 255,255,255,255,255,255,255,127,255,255,255,255,255,7,255,255,255,255,15,0, 255,255,255,255,255,127,255,255,255,255,255,0,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,127,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,0, 0,0,0,0,0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 255,31,255,255,255,255,255,255,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255, @@ -43,13 +43,13 @@ 255,15,0,0,0,0,0,0,0,0,0,0,0,0,0,255,3,0,0,255,255,255,255,247,255,127,15,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,254,255,255,255,255,255,255,255,255,255,255, 255,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,127,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, -0,0,0,0,0,0,0,0,0,0,0,0,3,0,0,0,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,31,0, -0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,7,0,255,255,255,127,0,0,0,0,0,0,0, -0,0,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +0,0,0,0,0,0,0,0,0,0,0,0,15,0,0,0,255,255,255,255,255,255,255,255,255,255,255, 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, -255,255,255,255,255,255,255,255,255,255,255,255, +255,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,7,0,255,255,255,127,0,0,0,0,0, +0,7,0,240,0,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, +255,255,255,255,255,255,255,255,255,255,255,255,255,255, 15,16,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,128,0,0,0,0,0,0,0,0,0,0, 0,0,0,0,0,0,0,0,0,0,0,0,0,64,254,7,0,0,0,0,0,0,0,0,0,0,0,0,7,0,255,255,255, 255,255,15,255,1,3,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,255,255,255,255, @@ -58,6 +58,8 @@ 255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255,255, 159,255,255,255,255,255,255,255,63,0,120,255,255,255,0,0,4,0,0,96,0,16,0,0,0, 0,0,0,0,0,0,0,248,255,255,255,255,255,255,255,255,255,255,0,0,0,0,0,0,255,255, -255,255,255,255,255,255,63,16,7,0,0,24,240,1,0,0,255,255,255,255,255,127,255, -31,255,255,255,15,0,0,255,255,255,0,0,0,0,0,1,0,255,255,127,0,0, -0, +255,255,255,255,255,255,63,16,39,0,0,24,240,7,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,0,0,0,0,0,0,0,0,0,0,0,255,15,0, +0,0,224,255,255,255,255,255,255,255,255,255,255,255,255,123,252,255,255,255, +255,231,199,255,255,255,231,255,255,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0, +0,15,7,7,0,63,0,0,0,0,0,0,0,0,0,0,0,0,0, diff --git a/libc-top-half/musl/src/fenv/riscv64/fenv.S b/libc-top-half/musl/src/fenv/riscv64/fenv.S index f149003..0ea78bf 100644 --- a/libc-top-half/musl/src/fenv/riscv64/fenv.S +++ b/libc-top-half/musl/src/fenv/riscv64/fenv.S @@ -45,8 +45,11 @@ fegetenv: .global fesetenv .type fesetenv, %function fesetenv: + li t2, -1 + li t1, 0 + beq a0, t2, 1f lw t1, 0(a0) - fscsr t0, t1 +1: fscsr t1 li a0, 0 ret diff --git a/libc-top-half/musl/src/internal/dynlink.h b/libc-top-half/musl/src/internal/dynlink.h index ffd06b0..764e3a1 100644 --- a/libc-top-half/musl/src/internal/dynlink.h +++ b/libc-top-half/musl/src/internal/dynlink.h @@ -96,7 +96,6 @@ struct fdpic_dummy_loadmap { #define DYN_CNT 32 typedef void (*stage2_func)(unsigned char *, size_t *); -typedef void (*stage3_func)(size_t *); hidden void *__dlsym(void *restrict, const char *restrict, void *restrict); diff --git a/libc-top-half/musl/src/internal/floatscan.c b/libc-top-half/musl/src/internal/floatscan.c index 0fbea30..ec50fe0 100644 --- a/libc-top-half/musl/src/internal/floatscan.c +++ b/libc-top-half/musl/src/internal/floatscan.c @@ -37,9 +37,6 @@ #define MASK (KMAX-1) -#define CONCAT2(x,y) x ## y -#define CONCAT(x,y) CONCAT2(x,y) - static long long scanexp(FILE *f, int pok) { int c; @@ -332,7 +329,7 @@ static long double decfloat(FILE *f, int c, int bits, int emin, int sign, int po y -= bias; if ((e2+LDBL_MANT_DIG & INT_MAX) > emax-5) { - if (fabsl(y) >= CONCAT(0x1p, LDBL_MANT_DIG)) { + if (fabsl(y) >= 2/LDBL_EPSILON) { if (denormal && bits==LDBL_MANT_DIG+e2-emin) denormal = 0; y *= 0.5; diff --git a/libc-top-half/musl/src/internal/syscall.h b/libc-top-half/musl/src/internal/syscall.h index 9f2784d..975a003 100644 --- a/libc-top-half/musl/src/internal/syscall.h +++ b/libc-top-half/musl/src/internal/syscall.h @@ -193,6 +193,45 @@ hidden long __syscall_ret(unsigned long), #define SYS_sendfile SYS_sendfile64 #endif +#ifndef SYS_timer_settime +#define SYS_timer_settime SYS_timer_settime32 +#endif + +#ifndef SYS_timer_gettime +#define SYS_timer_gettime SYS_timer_gettime32 +#endif + +#ifndef SYS_timerfd_settime +#define SYS_timerfd_settime SYS_timerfd_settime32 +#endif + +#ifndef SYS_timerfd_gettime +#define SYS_timerfd_gettime SYS_timerfd_gettime32 +#endif + +#ifndef SYS_clock_settime +#define SYS_clock_settime SYS_clock_settime32 +#endif + +#ifndef SYS_clock_gettime +#define SYS_clock_gettime SYS_clock_gettime32 +#endif + +#ifndef SYS_clock_getres +#define SYS_clock_getres SYS_clock_getres_time32 +#endif + +#ifndef SYS_clock_nanosleep +#define SYS_clock_nanosleep SYS_clock_nanosleep_time32 +#endif + +#ifndef SYS_gettimeofday +#define SYS_gettimeofday SYS_gettimeofday_time32 +#endif + +#ifndef SYS_settimeofday +#define SYS_settimeofday SYS_settimeofday_time32 +#endif /* Ensure that the plain syscall names are defined even for "time64-only" * archs. These facilitate callers passing null time arguments, and make @@ -306,6 +345,13 @@ hidden long __syscall_ret(unsigned long), #define SO_SNDTIMEO_OLD 21 #endif +#define SO_TIMESTAMP_OLD 29 +#define SO_TIMESTAMPNS_OLD 35 +#define SO_TIMESTAMPING_OLD 37 +#define SCM_TIMESTAMP_OLD SO_TIMESTAMP_OLD +#define SCM_TIMESTAMPNS_OLD SO_TIMESTAMPNS_OLD +#define SCM_TIMESTAMPING_OLD SO_TIMESTAMPING_OLD + #ifndef SIOCGSTAMP_OLD #define SIOCGSTAMP_OLD 0x8906 #endif diff --git a/libc-top-half/musl/src/ldso/__dlsym.c b/libc-top-half/musl/src/ldso/__dlsym.c index 8ac0a33..0384f97 100644 --- a/libc-top-half/musl/src/ldso/__dlsym.c +++ b/libc-top-half/musl/src/ldso/__dlsym.c @@ -8,3 +8,7 @@ static void *stub_dlsym(void *restrict p, const char *restrict s, void *restrict } weak_alias(stub_dlsym, __dlsym); + +#if _REDIR_TIME64 +weak_alias(stub_dlsym, __dlsym_redir_time64); +#endif diff --git a/libc-top-half/musl/src/ldso/arm/dlsym_time64.S b/libc-top-half/musl/src/ldso/arm/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/arm/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/i386/dlsym_time64.S b/libc-top-half/musl/src/ldso/i386/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/i386/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/m68k/dlsym_time64.S b/libc-top-half/musl/src/ldso/m68k/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/m68k/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/microblaze/dlsym_time64.S b/libc-top-half/musl/src/ldso/microblaze/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/microblaze/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/mips/dlsym_time64.S b/libc-top-half/musl/src/ldso/mips/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/mips/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/mipsn32/dlsym_time64.S b/libc-top-half/musl/src/ldso/mipsn32/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/mipsn32/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/or1k/dlsym_time64.S b/libc-top-half/musl/src/ldso/or1k/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/or1k/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/powerpc/dlsym_time64.S b/libc-top-half/musl/src/ldso/powerpc/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/powerpc/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/ldso/sh/dlsym_time64.S b/libc-top-half/musl/src/ldso/sh/dlsym_time64.S new file mode 100644 index 0000000..bb2e704 --- /dev/null +++ b/libc-top-half/musl/src/ldso/sh/dlsym_time64.S @@ -0,0 +1,3 @@ +#define __dlsym __dlsym_redir_time64 +#define dlsym __dlsym_time64 +#include "dlsym.s" diff --git a/libc-top-half/musl/src/linux/clock_adjtime.c b/libc-top-half/musl/src/linux/clock_adjtime.c index 2f53139..23eb872 100644 --- a/libc-top-half/musl/src/linux/clock_adjtime.c +++ b/libc-top-half/musl/src/linux/clock_adjtime.c @@ -94,21 +94,56 @@ int clock_adjtime (clockid_t clock_id, struct timex *utx) return __syscall_ret(-ENOTSUP); #endif if (sizeof(time_t) > sizeof(long)) { - union { - struct timex utx; - struct ktimex ktx; - } u = { *utx }; - u.ktx.time_sec = utx->time.tv_sec; - u.ktx.time_usec = utx->time.tv_usec; + struct ktimex ktx = { + .modes = utx->modes, + .offset = utx->offset, + .freq = utx->freq, + .maxerror = utx->maxerror, + .esterror = utx->esterror, + .status = utx->status, + .constant = utx->constant, + .precision = utx->precision, + .tolerance = utx->tolerance, + .time_sec = utx->time.tv_sec, + .time_usec = utx->time.tv_usec, + .tick = utx->tick, + .ppsfreq = utx->ppsfreq, + .jitter = utx->jitter, + .shift = utx->shift, + .stabil = utx->stabil, + .jitcnt = utx->jitcnt, + .calcnt = utx->calcnt, + .errcnt = utx->errcnt, + .stbcnt = utx->stbcnt, + .tai = utx->tai, + }; #ifdef SYS_adjtimex - if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &u); + if (clock_id==CLOCK_REALTIME) r = __syscall(SYS_adjtimex, &ktx); else #endif - r = __syscall(SYS_clock_adjtime, clock_id, &u); + r = __syscall(SYS_clock_adjtime, clock_id, &ktx); if (r>=0) { - *utx = u.utx; - utx->time.tv_sec = u.ktx.time_sec; - utx->time.tv_usec = u.ktx.time_usec; + utx->modes = ktx.modes; + utx->offset = ktx.offset; + utx->freq = ktx.freq; + utx->maxerror = ktx.maxerror; + utx->esterror = ktx.esterror; + utx->status = ktx.status; + utx->constant = ktx.constant; + utx->precision = ktx.precision; + utx->tolerance = ktx.tolerance; + utx->time.tv_sec = ktx.time_sec; + utx->time.tv_usec = ktx.time_usec; + utx->tick = ktx.tick; + utx->ppsfreq = ktx.ppsfreq; + utx->jitter = ktx.jitter; + utx->shift = ktx.shift; + utx->stabil = ktx.stabil; + utx->jitcnt = ktx.jitcnt; + utx->calcnt = ktx.calcnt; + utx->errcnt = ktx.errcnt; + utx->stbcnt = ktx.stbcnt; + utx->tai = ktx.tai; } return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/linux/wait4.c b/libc-top-half/musl/src/linux/wait4.c index 97f12cc..83650e3 100644 --- a/libc-top-half/musl/src/linux/wait4.c +++ b/libc-top-half/musl/src/linux/wait4.c @@ -1,9 +1,39 @@ #define _GNU_SOURCE #include #include +#include +#include #include "syscall.h" -pid_t wait4(pid_t pid, int *status, int options, struct rusage *usage) +pid_t wait4(pid_t pid, int *status, int options, struct rusage *ru) { - return syscall(SYS_wait4, pid, status, options, usage); + int r; +#ifdef SYS_wait4_time64 + if (ru) { + long long kru64[18]; + r = __syscall(SYS_wait4_time64, pid, status, options, kru64); + if (!r) { + ru->ru_utime = (struct timeval) + { .tv_sec = kru64[0], .tv_usec = kru64[1] }; + ru->ru_stime = (struct timeval) + { .tv_sec = kru64[2], .tv_usec = kru64[3] }; + char *slots = (char *)&ru->ru_maxrss; + for (int i=0; i<14; i++) + *(long *)(slots + i*sizeof(long)) = kru64[4+i]; + } + if (SYS_wait4_time64 == SYS_wait4 || r != -ENOSYS) + return __syscall_ret(r); + } +#endif + char *dest = ru ? (char *)&ru->ru_maxrss - 4*sizeof(long) : 0; + r = __syscall(SYS_wait4, pid, status, options, dest); + if (r>0 && ru && sizeof(time_t) > sizeof(long)) { + long kru[4]; + memcpy(kru, dest, 4*sizeof(long)); + ru->ru_utime = (struct timeval) + { .tv_sec = kru[0], .tv_usec = kru[1] }; + ru->ru_stime = (struct timeval) + { .tv_sec = kru[2], .tv_usec = kru[3] }; + } + return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/math/i386/acos.s b/libc-top-half/musl/src/math/i386/acos.s index 47f365e..af423a2 100644 --- a/libc-top-half/musl/src/math/i386/acos.s +++ b/libc-top-half/musl/src/math/i386/acos.s @@ -1,22 +1,10 @@ # use acos(x) = atan2(fabs(sqrt((1-x)*(1+x))), x) -.global acosf -.type acosf,@function -acosf: - flds 4(%esp) - jmp 1f - -.global acosl -.type acosl,@function -acosl: - fldt 4(%esp) - jmp 1f - .global acos .type acos,@function acos: fldl 4(%esp) -1: fld %st(0) + fld %st(0) fld1 fsub %st(0),%st(1) fadd %st(2) @@ -25,4 +13,6 @@ acos: fabs # fix sign of zero (matters in downward rounding mode) fxch %st(1) fpatan + fstpl 4(%esp) + fldl 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/acosf.s b/libc-top-half/musl/src/math/i386/acosf.s index 6c95509..d2cdfdb 100644 --- a/libc-top-half/musl/src/math/i386/acosf.s +++ b/libc-top-half/musl/src/math/i386/acosf.s @@ -1 +1,16 @@ -# see acos.s +.global acosf +.type acosf,@function +acosf: + flds 4(%esp) + fld %st(0) + fld1 + fsub %st(0),%st(1) + fadd %st(2) + fmulp + fsqrt + fabs # fix sign of zero (matters in downward rounding mode) + fxch %st(1) + fpatan + fstps 4(%esp) + flds 4(%esp) + ret diff --git a/libc-top-half/musl/src/math/i386/acosl.s b/libc-top-half/musl/src/math/i386/acosl.s index 6c95509..599c823 100644 --- a/libc-top-half/musl/src/math/i386/acosl.s +++ b/libc-top-half/musl/src/math/i386/acosl.s @@ -1 +1,14 @@ -# see acos.s +.global acosl +.type acosl,@function +acosl: + fldt 4(%esp) + fld %st(0) + fld1 + fsub %st(0),%st(1) + fadd %st(2) + fmulp + fsqrt + fabs # fix sign of zero (matters in downward rounding mode) + fxch %st(1) + fpatan + ret diff --git a/libc-top-half/musl/src/math/i386/asin.s b/libc-top-half/musl/src/math/i386/asin.s index 920d967..2bc8356 100644 --- a/libc-top-half/musl/src/math/i386/asin.s +++ b/libc-top-half/musl/src/math/i386/asin.s @@ -1,23 +1,3 @@ -.global asinf -.type asinf,@function -asinf: - flds 4(%esp) - mov 4(%esp),%eax - add %eax,%eax - cmp $0x01000000,%eax - jae 1f - # subnormal x, return x with underflow - fld %st(0) - fmul %st(1) - fstps 4(%esp) - ret - -.global asinl -.type asinl,@function -asinl: - fldt 4(%esp) - jmp 1f - .global asin .type asin,@function asin: @@ -25,15 +5,17 @@ asin: mov 8(%esp),%eax add %eax,%eax cmp $0x00200000,%eax - jae 1f - # subnormal x, return x with underflow - fsts 4(%esp) - ret -1: fld %st(0) + jb 1f + fld %st(0) fld1 fsub %st(0),%st(1) fadd %st(2) fmulp fsqrt fpatan + fstpl 4(%esp) + fldl 4(%esp) + ret + # subnormal x, return x with underflow +1: fsts 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/asinf.s b/libc-top-half/musl/src/math/i386/asinf.s index e07bf59..0590975 100644 --- a/libc-top-half/musl/src/math/i386/asinf.s +++ b/libc-top-half/musl/src/math/i386/asinf.s @@ -1 +1,23 @@ -# see asin.s +.global asinf +.type asinf,@function +asinf: + flds 4(%esp) + mov 4(%esp),%eax + add %eax,%eax + cmp $0x01000000,%eax + jb 1f + fld %st(0) + fld1 + fsub %st(0),%st(1) + fadd %st(2) + fmulp + fsqrt + fpatan + fstps 4(%esp) + flds 4(%esp) + ret + # subnormal x, return x with underflow +1: fld %st(0) + fmul %st(1) + fstps 4(%esp) + ret diff --git a/libc-top-half/musl/src/math/i386/asinl.s b/libc-top-half/musl/src/math/i386/asinl.s index e07bf59..e973fc8 100644 --- a/libc-top-half/musl/src/math/i386/asinl.s +++ b/libc-top-half/musl/src/math/i386/asinl.s @@ -1 +1,12 @@ -# see asin.s +.global asinl +.type asinl,@function +asinl: + fldt 4(%esp) + fld %st(0) + fld1 + fsub %st(0),%st(1) + fadd %st(2) + fmulp + fsqrt + fpatan + ret diff --git a/libc-top-half/musl/src/math/i386/atan.s b/libc-top-half/musl/src/math/i386/atan.s index a26feae..2c57f6b 100644 --- a/libc-top-half/musl/src/math/i386/atan.s +++ b/libc-top-half/musl/src/math/i386/atan.s @@ -8,6 +8,8 @@ atan: jb 1f fld1 fpatan + fstpl 4(%esp) + fldl 4(%esp) ret # subnormal x, return x with underflow 1: fsts 4(%esp) diff --git a/libc-top-half/musl/src/math/i386/atan2.s b/libc-top-half/musl/src/math/i386/atan2.s index 76b95f3..8bc441b 100644 --- a/libc-top-half/musl/src/math/i386/atan2.s +++ b/libc-top-half/musl/src/math/i386/atan2.s @@ -4,7 +4,8 @@ atan2: fldl 4(%esp) fldl 12(%esp) fpatan - fstl 4(%esp) + fstpl 4(%esp) + fldl 4(%esp) mov 8(%esp),%eax add %eax,%eax cmp $0x00200000,%eax diff --git a/libc-top-half/musl/src/math/i386/atan2f.s b/libc-top-half/musl/src/math/i386/atan2f.s index c9408a9..3908c86 100644 --- a/libc-top-half/musl/src/math/i386/atan2f.s +++ b/libc-top-half/musl/src/math/i386/atan2f.s @@ -4,7 +4,8 @@ atan2f: flds 4(%esp) flds 8(%esp) fpatan - fsts 4(%esp) + fstps 4(%esp) + flds 4(%esp) mov 4(%esp),%eax add %eax,%eax cmp $0x01000000,%eax diff --git a/libc-top-half/musl/src/math/i386/atanf.s b/libc-top-half/musl/src/math/i386/atanf.s index 893beac..c2cbe2e 100644 --- a/libc-top-half/musl/src/math/i386/atanf.s +++ b/libc-top-half/musl/src/math/i386/atanf.s @@ -8,6 +8,8 @@ atanf: jb 1f fld1 fpatan + fstps 4(%esp) + flds 4(%esp) ret # subnormal x, return x with underflow 1: fld %st(0) diff --git a/libc-top-half/musl/src/math/i386/exp2.s b/libc-top-half/musl/src/math/i386/exp2.s deleted file mode 100644 index f335a3e..0000000 --- a/libc-top-half/musl/src/math/i386/exp2.s +++ /dev/null @@ -1 +0,0 @@ -# see exp.s diff --git a/libc-top-half/musl/src/math/i386/exp2f.s b/libc-top-half/musl/src/math/i386/exp2f.s deleted file mode 100644 index f335a3e..0000000 --- a/libc-top-half/musl/src/math/i386/exp2f.s +++ /dev/null @@ -1 +0,0 @@ -# see exp.s diff --git a/libc-top-half/musl/src/math/i386/exp2l.s b/libc-top-half/musl/src/math/i386/exp2l.s index f335a3e..8125761 100644 --- a/libc-top-half/musl/src/math/i386/exp2l.s +++ b/libc-top-half/musl/src/math/i386/exp2l.s @@ -1 +1 @@ -# see exp.s +# see exp_ld.s diff --git a/libc-top-half/musl/src/math/i386/exp.s b/libc-top-half/musl/src/math/i386/exp_ld.s similarity index 67% rename from libc-top-half/musl/src/math/i386/exp.s rename to libc-top-half/musl/src/math/i386/exp_ld.s index df87c49..99cba01 100644 --- a/libc-top-half/musl/src/math/i386/exp.s +++ b/libc-top-half/musl/src/math/i386/exp_ld.s @@ -1,35 +1,8 @@ -.global expm1f -.type expm1f,@function -expm1f: - flds 4(%esp) - mov 4(%esp),%eax - add %eax,%eax - cmp $0x01000000,%eax - jae 1f - # subnormal x, return x with underflow - fld %st(0) - fmul %st(1) - fstps 4(%esp) - ret - .global expm1l .type expm1l,@function expm1l: fldt 4(%esp) - jmp 1f - -.global expm1 -.type expm1,@function -expm1: - fldl 4(%esp) - mov 8(%esp),%eax - add %eax,%eax - cmp $0x00200000,%eax - jae 1f - # subnormal x, return x with underflow - fsts 4(%esp) - ret -1: fldl2e + fldl2e fmulp mov $0xc2820000,%eax push %eax @@ -59,12 +32,6 @@ expm1: fsubrp ret -.global exp2f -.type exp2f,@function -exp2f: - flds 4(%esp) - jmp 1f - .global exp2l .global __exp2l .hidden __exp2l @@ -72,26 +39,6 @@ exp2f: exp2l: __exp2l: fldt 4(%esp) - jmp 1f - -.global expf -.type expf,@function -expf: - flds 4(%esp) - jmp 2f - -.global exp -.type exp,@function -exp: - fldl 4(%esp) -2: fldl2e - fmulp - jmp 1f - -.global exp2 -.type exp2,@function -exp2: - fldl 4(%esp) 1: sub $12,%esp fld %st(0) fstpt (%esp) diff --git a/libc-top-half/musl/src/math/i386/expf.s b/libc-top-half/musl/src/math/i386/expf.s deleted file mode 100644 index f335a3e..0000000 --- a/libc-top-half/musl/src/math/i386/expf.s +++ /dev/null @@ -1 +0,0 @@ -# see exp.s diff --git a/libc-top-half/musl/src/math/i386/expm1.s b/libc-top-half/musl/src/math/i386/expm1.s deleted file mode 100644 index f335a3e..0000000 --- a/libc-top-half/musl/src/math/i386/expm1.s +++ /dev/null @@ -1 +0,0 @@ -# see exp.s diff --git a/libc-top-half/musl/src/math/i386/expm1f.s b/libc-top-half/musl/src/math/i386/expm1f.s deleted file mode 100644 index f335a3e..0000000 --- a/libc-top-half/musl/src/math/i386/expm1f.s +++ /dev/null @@ -1 +0,0 @@ -# see exp.s diff --git a/libc-top-half/musl/src/math/i386/expm1l.s b/libc-top-half/musl/src/math/i386/expm1l.s index f335a3e..8125761 100644 --- a/libc-top-half/musl/src/math/i386/expm1l.s +++ b/libc-top-half/musl/src/math/i386/expm1l.s @@ -1 +1 @@ -# see exp.s +# see exp_ld.s diff --git a/libc-top-half/musl/src/math/i386/log.s b/libc-top-half/musl/src/math/i386/log.s index fcccf03..08c5992 100644 --- a/libc-top-half/musl/src/math/i386/log.s +++ b/libc-top-half/musl/src/math/i386/log.s @@ -4,4 +4,6 @@ log: fldln2 fldl 4(%esp) fyl2x + fstpl 4(%esp) + fldl 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/log10.s b/libc-top-half/musl/src/math/i386/log10.s index 28eb5b2..120e91e 100644 --- a/libc-top-half/musl/src/math/i386/log10.s +++ b/libc-top-half/musl/src/math/i386/log10.s @@ -4,4 +4,6 @@ log10: fldlg2 fldl 4(%esp) fyl2x + fstpl 4(%esp) + fldl 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/log10f.s b/libc-top-half/musl/src/math/i386/log10f.s index c0c0c67..b055493 100644 --- a/libc-top-half/musl/src/math/i386/log10f.s +++ b/libc-top-half/musl/src/math/i386/log10f.s @@ -4,4 +4,6 @@ log10f: fldlg2 flds 4(%esp) fyl2x + fstps 4(%esp) + flds 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/log1p.s b/libc-top-half/musl/src/math/i386/log1p.s index 354f391..f3c95f8 100644 --- a/libc-top-half/musl/src/math/i386/log1p.s +++ b/libc-top-half/musl/src/math/i386/log1p.s @@ -10,10 +10,14 @@ log1p: cmp $0x00100000,%eax jb 2f fyl2xp1 + fstpl 4(%esp) + fldl 4(%esp) ret 1: fld1 faddp fyl2x + fstpl 4(%esp) + fldl 4(%esp) ret # subnormal x, return x with underflow 2: fsts 4(%esp) diff --git a/libc-top-half/musl/src/math/i386/log1pf.s b/libc-top-half/musl/src/math/i386/log1pf.s index 4d3484c..9f13d95 100644 --- a/libc-top-half/musl/src/math/i386/log1pf.s +++ b/libc-top-half/musl/src/math/i386/log1pf.s @@ -10,10 +10,14 @@ log1pf: cmp $0x00800000,%eax jb 2f fyl2xp1 + fstps 4(%esp) + flds 4(%esp) ret 1: fld1 faddp fyl2x + fstps 4(%esp) + flds 4(%esp) ret # subnormal x, return x with underflow 2: fxch diff --git a/libc-top-half/musl/src/math/i386/log2.s b/libc-top-half/musl/src/math/i386/log2.s index 1508803..7eff0b6 100644 --- a/libc-top-half/musl/src/math/i386/log2.s +++ b/libc-top-half/musl/src/math/i386/log2.s @@ -4,4 +4,6 @@ log2: fld1 fldl 4(%esp) fyl2x + fstpl 4(%esp) + fldl 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/log2f.s b/libc-top-half/musl/src/math/i386/log2f.s index 00cdce7..b32fa2f 100644 --- a/libc-top-half/musl/src/math/i386/log2f.s +++ b/libc-top-half/musl/src/math/i386/log2f.s @@ -4,4 +4,6 @@ log2f: fld1 flds 4(%esp) fyl2x + fstps 4(%esp) + flds 4(%esp) ret diff --git a/libc-top-half/musl/src/math/i386/logf.s b/libc-top-half/musl/src/math/i386/logf.s index da7ff3a..4d0346a 100644 --- a/libc-top-half/musl/src/math/i386/logf.s +++ b/libc-top-half/musl/src/math/i386/logf.s @@ -4,4 +4,6 @@ logf: fldln2 flds 4(%esp) fyl2x + fstps 4(%esp) + flds 4(%esp) ret diff --git a/libc-top-half/musl/src/math/mips/fabs.c b/libc-top-half/musl/src/math/mips/fabs.c new file mode 100644 index 0000000..0a5aa3b --- /dev/null +++ b/libc-top-half/musl/src/math/mips/fabs.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && defined(__mips_abs2008) + +#include + +double fabs(double x) +{ + double r; + __asm__("abs.d %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../fabs.c" + +#endif diff --git a/libc-top-half/musl/src/math/mips/fabsf.c b/libc-top-half/musl/src/math/mips/fabsf.c new file mode 100644 index 0000000..35307be --- /dev/null +++ b/libc-top-half/musl/src/math/mips/fabsf.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && defined(__mips_abs2008) + +#include + +float fabsf(float x) +{ + float r; + __asm__("abs.s %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../fabsf.c" + +#endif diff --git a/libc-top-half/musl/src/math/mips/sqrt.c b/libc-top-half/musl/src/math/mips/sqrt.c new file mode 100644 index 0000000..595c9db --- /dev/null +++ b/libc-top-half/musl/src/math/mips/sqrt.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && __mips >= 3 + +#include + +double sqrt(double x) +{ + double r; + __asm__("sqrt.d %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../sqrt.c" + +#endif diff --git a/libc-top-half/musl/src/math/mips/sqrtf.c b/libc-top-half/musl/src/math/mips/sqrtf.c new file mode 100644 index 0000000..84090d2 --- /dev/null +++ b/libc-top-half/musl/src/math/mips/sqrtf.c @@ -0,0 +1,16 @@ +#if !defined(__mips_soft_float) && __mips >= 2 + +#include + +float sqrtf(float x) +{ + float r; + __asm__("sqrt.s %0,%1" : "=f"(r) : "f"(x)); + return r; +} + +#else + +#include "../sqrtf.c" + +#endif diff --git a/libc-top-half/musl/src/math/powerpc/fabs.c b/libc-top-half/musl/src/math/powerpc/fabs.c index f6ec443..0efc21e 100644 --- a/libc-top-half/musl/src/math/powerpc/fabs.c +++ b/libc-top-half/musl/src/math/powerpc/fabs.c @@ -1,6 +1,6 @@ #include -#ifdef _SOFT_FLOAT +#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM) #include "../fabs.c" diff --git a/libc-top-half/musl/src/math/powerpc/fma.c b/libc-top-half/musl/src/math/powerpc/fma.c index fd268f5..135c990 100644 --- a/libc-top-half/musl/src/math/powerpc/fma.c +++ b/libc-top-half/musl/src/math/powerpc/fma.c @@ -1,6 +1,6 @@ #include -#ifdef _SOFT_FLOAT +#if defined(_SOFT_FLOAT) || defined(BROKEN_PPC_D_ASM) #include "../fma.c" diff --git a/libc-top-half/musl/src/math/x32/lrintl.s b/libc-top-half/musl/src/math/x32/lrintl.s index ee97d1c..d4355c3 100644 --- a/libc-top-half/musl/src/math/x32/lrintl.s +++ b/libc-top-half/musl/src/math/x32/lrintl.s @@ -2,6 +2,6 @@ .type lrintl,@function lrintl: fldt 8(%esp) - fistpll 8(%esp) - mov 8(%esp),%rax + fistpl 8(%esp) + movl 8(%esp),%eax ret diff --git a/libc-top-half/musl/src/misc/getrusage.c b/libc-top-half/musl/src/misc/getrusage.c index 0aaf0ac..8e03e2e 100644 --- a/libc-top-half/musl/src/misc/getrusage.c +++ b/libc-top-half/musl/src/misc/getrusage.c @@ -1,7 +1,35 @@ #include +#include +#include #include "syscall.h" int getrusage(int who, struct rusage *ru) { - return syscall(SYS_getrusage, who, ru); + int r; +#ifdef SYS_getrusage_time64 + long long kru64[18]; + r = __syscall(SYS_getrusage_time64, who, kru64); + if (!r) { + ru->ru_utime = (struct timeval) + { .tv_sec = kru64[0], .tv_usec = kru64[1] }; + ru->ru_stime = (struct timeval) + { .tv_sec = kru64[2], .tv_usec = kru64[3] }; + char *slots = (char *)&ru->ru_maxrss; + for (int i=0; i<14; i++) + *(long *)(slots + i*sizeof(long)) = kru64[4+i]; + } + if (SYS_getrusage_time64 == SYS_getrusage || r != -ENOSYS) + return __syscall_ret(r); +#endif + char *dest = (char *)&ru->ru_maxrss - 4*sizeof(long); + r = __syscall(SYS_getrusage, who, dest); + if (!r && sizeof(time_t) > sizeof(long)) { + long kru[4]; + memcpy(kru, dest, 4*sizeof(long)); + ru->ru_utime = (struct timeval) + { .tv_sec = kru[0], .tv_usec = kru[1] }; + ru->ru_stime = (struct timeval) + { .tv_sec = kru[2], .tv_usec = kru[3] }; + } + return __syscall_ret(r); } diff --git a/libc-top-half/musl/src/misc/ioctl.c b/libc-top-half/musl/src/misc/ioctl.c index 6f31d4b..8947751 100644 --- a/libc-top-half/musl/src/misc/ioctl.c +++ b/libc-top-half/musl/src/misc/ioctl.c @@ -3,8 +3,115 @@ #include #include #include +#include +#include #include "syscall.h" +#define alignof(t) offsetof(struct { char c; t x; }, x) + +#define W 1 +#define R 2 +#define WR 3 + +struct ioctl_compat_map { + int new_req, old_req; + unsigned char old_size, dir, force_align, noffs; + unsigned char offsets[8]; +}; + +#define NINTH(a,b,c,d,e,f,g,h,i,...) i +#define COUNT(...) NINTH(__VA_ARGS__,8,7,6,5,4,3,2,1,0) +#define OFFS(...) COUNT(__VA_ARGS__), { __VA_ARGS__ } + +/* yields a type for a struct with original size n, with a misaligned + * timeval/timespec expanded from 32- to 64-bit. for use with ioctl + * number producing macros; only size of result is meaningful. */ +#define new_misaligned(n) struct { int i; time_t t; char c[(n)-4]; } + +static const struct ioctl_compat_map compat_map[] = { + { SIOCGSTAMP, SIOCGSTAMP_OLD, 8, R, 0, OFFS(0, 4) }, + { SIOCGSTAMPNS, SIOCGSTAMPNS_OLD, 8, R, 0, OFFS(0, 4) }, + + /* SNDRV_TIMER_IOCTL_STATUS */ + { _IOR('T', 0x14, char[96]), _IOR('T', 0x14, 88), 88, R, 0, OFFS(0,4) }, + + /* SNDRV_PCM_IOCTL_STATUS[_EXT] */ + { _IOR('A', 0x20, char[128]), _IOR('A', 0x20, char[108]), 108, R, 1, OFFS(4,8,12,16,52,56,60,64) }, + { _IOWR('A', 0x24, char[128]), _IOWR('A', 0x24, char[108]), 108, WR, 1, OFFS(4,8,12,16,52,56,60,64) }, + + /* SNDRV_RAWMIDI_IOCTL_STATUS */ + { _IOWR('W', 0x20, char[48]), _IOWR('W', 0x20, char[36]), 36, WR, 1, OFFS(4,8) }, + + /* SNDRV_PCM_IOCTL_SYNC_PTR - with 3 subtables */ + { _IOWR('A', 0x23, char[136]), _IOWR('A', 0x23, char[132]), 0, WR, 1, 0 }, + { 0, 0, 4, WR, 1, 0 }, /* snd_pcm_sync_ptr (flags only) */ + { 0, 0, 32, WR, 1, OFFS(8,12,16,24,28) }, /* snd_pcm_mmap_status */ + { 0, 0, 8, WR, 1, OFFS(0,4) }, /* snd_pcm_mmap_control */ + + /* VIDIOC_QUERYBUF, VIDIOC_QBUF, VIDIOC_DQBUF, VIDIOC_PREPARE_BUF */ + { _IOWR('V', 9, new_misaligned(72)), _IOWR('V', 9, char[72]), 72, WR, 0, OFFS(20) }, + { _IOWR('V', 15, new_misaligned(72)), _IOWR('V', 15, char[72]), 72, WR, 0, OFFS(20) }, + { _IOWR('V', 17, new_misaligned(72)), _IOWR('V', 17, char[72]), 72, WR, 0, OFFS(20) }, + { _IOWR('V', 93, new_misaligned(72)), _IOWR('V', 93, char[72]), 72, WR, 0, OFFS(20) }, + + /* VIDIOC_DQEVENT */ + { _IOR('V', 89, new_misaligned(96)), _IOR('V', 89, char[96]), 96, R, 0, OFFS(76,80) }, + + /* VIDIOC_OMAP3ISP_STAT_REQ */ + { _IOWR('V', 192+6, char[32]), _IOWR('V', 192+6, char[24]), 22, WR, 0, OFFS(0,4) }, + + /* PPPIOCGIDLE */ + { _IOR('t', 63, char[16]), _IOR('t', 63, char[8]), 8, R, 0, OFFS(0,4) }, + + /* PPGETTIME, PPSETTIME */ + { _IOR('p', 0x95, char[16]), _IOR('p', 0x95, char[8]), 8, R, 0, OFFS(0,4) }, + { _IOW('p', 0x96, char[16]), _IOW('p', 0x96, char[8]), 8, W, 0, OFFS(0,4) }, + + /* LPSETTIMEOUT */ + { _IOW(0x6, 0xf, char[16]), 0x060f, 8, W, 0, OFFS(0,4) }, +}; + +static void convert_ioctl_struct(const struct ioctl_compat_map *map, char *old, char *new, int dir) +{ + int new_offset = 0; + int old_offset = 0; + int old_size = map->old_size; + if (!(dir & map->dir)) return; + if (!map->old_size) { + /* offsets hard-coded for SNDRV_PCM_IOCTL_SYNC_PTR; + * if another exception appears this needs changing. */ + convert_ioctl_struct(map+1, old, new, dir); + convert_ioctl_struct(map+2, old+4, new+8, dir); + convert_ioctl_struct(map+3, old+68, new+72, dir); + return; + } + for (int i=0; i < map->noffs; i++) { + int ts_offset = map->offsets[i]; + int len = ts_offset-old_offset; + if (dir==W) memcpy(old+old_offset, new+new_offset, len); + else memcpy(new+new_offset, old+old_offset, len); + new_offset += len; + old_offset += len; + long long new_ts; + long old_ts; + int align = map->force_align ? sizeof(time_t) : alignof(time_t); + new_offset += (align-1) & -new_offset; + if (dir==W) { + memcpy(&new_ts, new+new_offset, sizeof new_ts); + old_ts = new_ts; + memcpy(old+old_offset, &old_ts, sizeof old_ts); + } else { + memcpy(&old_ts, old+old_offset, sizeof old_ts); + new_ts = old_ts; + memcpy(new+new_offset, &new_ts, sizeof new_ts); + } + new_offset += sizeof new_ts; + old_offset += sizeof old_ts; + } + if (dir==W) memcpy(old+old_offset, new+new_offset, old_size-old_offset); + else memcpy(new+new_offset, old+old_offset, old_size-old_offset); +} + int ioctl(int fd, int req, ...) { void *arg; @@ -13,23 +120,18 @@ int ioctl(int fd, int req, ...) arg = va_arg(ap, void *); va_end(ap); int r = __syscall(SYS_ioctl, fd, req, arg); - if (r==-ENOTTY) switch (req) { - case SIOCGSTAMP: - case SIOCGSTAMPNS: - if (SIOCGSTAMP==SIOCGSTAMP_OLD) break; - if (req==SIOCGSTAMP) req=SIOCGSTAMP_OLD; - if (req==SIOCGSTAMPNS) req=SIOCGSTAMPNS_OLD; - long t32[2]; - r = __syscall(SYS_ioctl, fd, req, t32); - if (r<0) break; - if (req==SIOCGSTAMP_OLD) { - struct timeval *tv = arg; - tv->tv_sec = t32[0]; - tv->tv_usec = t32[1]; - } else { - struct timespec *ts = arg; - ts->tv_sec = t32[0]; - ts->tv_nsec = t32[1]; + if (SIOCGSTAMP != SIOCGSTAMP_OLD && req && r==-ENOTTY) { + for (int i=0; itv_sec = tv32[0]; tv->tv_usec = tv32[1]; *optlen = sizeof *tv; + break; + case SO_TIMESTAMP: + case SO_TIMESTAMPNS: + if (SO_TIMESTAMP == SO_TIMESTAMP_OLD) break; + if (optname==SO_TIMESTAMP) optname=SO_TIMESTAMP_OLD; + if (optname==SO_TIMESTAMPNS) optname=SO_TIMESTAMPNS_OLD; + r = __socketcall(getsockopt, fd, level, + optname, optval, optlen, 0); + break; } } return __syscall_ret(r); diff --git a/libc-top-half/musl/src/network/recvmmsg.c b/libc-top-half/musl/src/network/recvmmsg.c index d5dc6b5..2978e2f 100644 --- a/libc-top-half/musl/src/network/recvmmsg.c +++ b/libc-top-half/musl/src/network/recvmmsg.c @@ -8,6 +8,8 @@ #define IS32BIT(x) !((x)+0x80000000ULL>>32) #define CLAMP(x) (int)(IS32BIT(x) ? (x) : 0x7fffffffU+((0ULL+(x))>>63)) +hidden void __convert_scm_timestamps(struct msghdr *, socklen_t); + int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int flags, struct timespec *timeout) { #if LONG_MAX > INT_MAX @@ -19,14 +21,18 @@ int recvmmsg(int fd, struct mmsghdr *msgvec, unsigned int vlen, unsigned int fla #ifdef SYS_recvmmsg_time64 time_t s = timeout ? timeout->tv_sec : 0; long ns = timeout ? timeout->tv_nsec : 0; - int r = -ENOSYS; - if (SYS_recvmmsg == SYS_recvmmsg_time64 || !IS32BIT(s)) - r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags, + int r = __syscall_cp(SYS_recvmmsg_time64, fd, msgvec, vlen, flags, timeout ? ((long long[]){s, ns}) : 0); if (SYS_recvmmsg == SYS_recvmmsg_time64 || r!=-ENOSYS) return __syscall_ret(r); - return syscall_cp(SYS_recvmmsg, fd, msgvec, vlen, flags, + if (vlen > IOV_MAX) vlen = IOV_MAX; + socklen_t csize[vlen]; + for (int i=0; i #include +#include +#include +#include #include "syscall.h" +hidden void __convert_scm_timestamps(struct msghdr *, socklen_t); + +void __convert_scm_timestamps(struct msghdr *msg, socklen_t csize) +{ + if (SCM_TIMESTAMP == SCM_TIMESTAMP_OLD) return; + if (!msg->msg_control || !msg->msg_controllen) return; + + struct cmsghdr *cmsg, *last=0; + long tmp; + long long tvts[2]; + int type = 0; + + for (cmsg=CMSG_FIRSTHDR(msg); cmsg; cmsg=CMSG_NXTHDR(msg, cmsg)) { + if (cmsg->cmsg_level==SOL_SOCKET) switch (cmsg->cmsg_type) { + case SCM_TIMESTAMP_OLD: + if (type) break; + type = SCM_TIMESTAMP; + goto common; + case SCM_TIMESTAMPNS_OLD: + type = SCM_TIMESTAMPNS; + common: + memcpy(&tmp, CMSG_DATA(cmsg), sizeof tmp); + tvts[0] = tmp; + memcpy(&tmp, CMSG_DATA(cmsg) + sizeof tmp, sizeof tmp); + tvts[1] = tmp; + break; + } + last = cmsg; + } + if (!last || !type) return; + if (CMSG_SPACE(sizeof tvts) > csize-msg->msg_controllen) { + msg->msg_flags |= MSG_CTRUNC; + return; + } + msg->msg_controllen += CMSG_SPACE(sizeof tvts); + cmsg = CMSG_NXTHDR(msg, last); + cmsg->cmsg_level = SOL_SOCKET; + cmsg->cmsg_type = type; + cmsg->cmsg_len = CMSG_LEN(sizeof tvts); + memcpy(CMSG_DATA(cmsg), &tvts, sizeof tvts); +} + ssize_t recvmsg(int fd, struct msghdr *msg, int flags) { ssize_t r; + socklen_t orig_controllen = msg->msg_controllen; #if LONG_MAX > INT_MAX struct msghdr h, *orig = msg; if (msg) { @@ -14,6 +60,7 @@ ssize_t recvmsg(int fd, struct msghdr *msg, int flags) } #endif r = socketcall_cp(recvmsg, fd, msg, flags, 0, 0, 0); + if (r >= 0) __convert_scm_timestamps(msg, orig_controllen); #if LONG_MAX > INT_MAX if (orig) *orig = h; #endif diff --git a/libc-top-half/musl/src/network/setsockopt.c b/libc-top-half/musl/src/network/setsockopt.c index 2c188a9..612a194 100644 --- a/libc-top-half/musl/src/network/setsockopt.c +++ b/libc-top-half/musl/src/network/setsockopt.c @@ -31,6 +31,15 @@ int setsockopt(int fd, int level, int optname, const void *optval, socklen_t opt r = __socketcall(setsockopt, fd, level, optname, ((long[]){s, CLAMP(us)}), 2*sizeof(long), 0); + break; + case SO_TIMESTAMP: + case SO_TIMESTAMPNS: + if (SO_TIMESTAMP == SO_TIMESTAMP_OLD) break; + if (optname==SO_TIMESTAMP) optname=SO_TIMESTAMP_OLD; + if (optname==SO_TIMESTAMPNS) optname=SO_TIMESTAMPNS_OLD; + r = __socketcall(setsockopt, fd, level, + optname, optval, optlen, 0); + break; } } return __syscall_ret(r); diff --git a/libc-top-half/musl/src/signal/arm/sigsetjmp.s b/libc-top-half/musl/src/signal/arm/sigsetjmp.s index 318addb..69ebbf4 100644 --- a/libc-top-half/musl/src/signal/arm/sigsetjmp.s +++ b/libc-top-half/musl/src/signal/arm/sigsetjmp.s @@ -6,9 +6,10 @@ sigsetjmp: __sigsetjmp: tst r1,r1 - beq setjmp + bne 1f + b setjmp - str lr,[r0,#256] +1: str lr,[r0,#256] str r4,[r0,#260+8] mov r4,r0 diff --git a/libc-top-half/musl/src/stat/__xstat.c b/libc-top-half/musl/src/stat/__xstat.c index f630343..630936a 100644 --- a/libc-top-half/musl/src/stat/__xstat.c +++ b/libc-top-half/musl/src/stat/__xstat.c @@ -1,5 +1,7 @@ #include +#if !_REDIR_TIME64 + int __fxstat(int ver, int fd, struct stat *buf) { return fstat(fd, buf); @@ -25,6 +27,8 @@ weak_alias(__fxstatat, __fxstatat64); weak_alias(__lxstat, __lxstat64); weak_alias(__xstat, __xstat64); +#endif + int __xmknod(int ver, const char *path, mode_t mode, dev_t *dev) { return mknod(path, mode, *dev); diff --git a/libc-top-half/musl/src/stat/fchmodat.c b/libc-top-half/musl/src/stat/fchmodat.c index be61bdf..4ee00b0 100644 --- a/libc-top-half/musl/src/stat/fchmodat.c +++ b/libc-top-half/musl/src/stat/fchmodat.c @@ -2,6 +2,7 @@ #include #include #include "syscall.h" +#include "kstat.h" int fchmodat(int fd, const char *path, mode_t mode, int flag) { @@ -10,7 +11,7 @@ int fchmodat(int fd, const char *path, mode_t mode, int flag) if (flag != AT_SYMLINK_NOFOLLOW) return __syscall_ret(-EINVAL); - struct stat st; + struct kstat st; int ret, fd2; char proc[15+3*sizeof(int)]; diff --git a/libc-top-half/musl/src/stat/fstat.c b/libc-top-half/musl/src/stat/fstat.c index 07f9a5d..9bbb46d 100644 --- a/libc-top-half/musl/src/stat/fstat.c +++ b/libc-top-half/musl/src/stat/fstat.c @@ -10,4 +10,6 @@ int fstat(int fd, struct stat *st) return fstatat(fd, "", st, AT_EMPTY_PATH); } +#if !_REDIR_TIME64 weak_alias(fstat, fstat64); +#endif diff --git a/libc-top-half/musl/src/stat/fstatat.c b/libc-top-half/musl/src/stat/fstatat.c index d915fa1..de165b5 100644 --- a/libc-top-half/musl/src/stat/fstatat.c +++ b/libc-top-half/musl/src/stat/fstatat.c @@ -57,6 +57,14 @@ static int fstatat_statx(int fd, const char *restrict path, struct stat *restric .st_mtim.tv_nsec = stx.stx_mtime.tv_nsec, .st_ctim.tv_sec = stx.stx_ctime.tv_sec, .st_ctim.tv_nsec = stx.stx_ctime.tv_nsec, +#if _REDIR_TIME64 + .__st_atim32.tv_sec = stx.stx_atime.tv_sec, + .__st_atim32.tv_nsec = stx.stx_atime.tv_nsec, + .__st_mtim32.tv_sec = stx.stx_mtime.tv_sec, + .__st_mtim32.tv_nsec = stx.stx_mtime.tv_nsec, + .__st_ctim32.tv_sec = stx.stx_ctime.tv_sec, + .__st_ctim32.tv_nsec = stx.stx_ctime.tv_nsec, +#endif }; return 0; } @@ -110,6 +118,14 @@ static int fstatat_kstat(int fd, const char *restrict path, struct stat *restric .st_mtim.tv_nsec = kst.st_mtime_nsec, .st_ctim.tv_sec = kst.st_ctime_sec, .st_ctim.tv_nsec = kst.st_ctime_nsec, +#if _REDIR_TIME64 + .__st_atim32.tv_sec = kst.st_atime_sec, + .__st_atim32.tv_nsec = kst.st_atime_nsec, + .__st_mtim32.tv_sec = kst.st_mtime_sec, + .__st_mtim32.tv_nsec = kst.st_mtime_nsec, + .__st_ctim32.tv_sec = kst.st_ctime_sec, + .__st_ctim32.tv_nsec = kst.st_ctime_nsec, +#endif }; return 0; @@ -126,4 +142,6 @@ int fstatat(int fd, const char *restrict path, struct stat *restrict st, int fla return __syscall_ret(ret); } +#if !_REDIR_TIME64 weak_alias(fstatat, fstatat64); +#endif diff --git a/libc-top-half/musl/src/stat/lstat.c b/libc-top-half/musl/src/stat/lstat.c index 9f95218..6fe004d 100644 --- a/libc-top-half/musl/src/stat/lstat.c +++ b/libc-top-half/musl/src/stat/lstat.c @@ -6,4 +6,6 @@ int lstat(const char *restrict path, struct stat *restrict buf) return fstatat(AT_FDCWD, path, buf, AT_SYMLINK_NOFOLLOW); } +#if !_REDIR_TIME64 weak_alias(lstat, lstat64); +#endif diff --git a/libc-top-half/musl/src/stat/stat.c b/libc-top-half/musl/src/stat/stat.c index 528870d..ea70efc 100644 --- a/libc-top-half/musl/src/stat/stat.c +++ b/libc-top-half/musl/src/stat/stat.c @@ -6,4 +6,6 @@ int stat(const char *restrict path, struct stat *restrict buf) return fstatat(AT_FDCWD, path, buf, 0); } +#if !_REDIR_TIME64 weak_alias(stat, stat64); +#endif diff --git a/libc-top-half/musl/src/stdio/tempnam.c b/libc-top-half/musl/src/stdio/tempnam.c index 84f9197..565df6b 100644 --- a/libc-top-half/musl/src/stdio/tempnam.c +++ b/libc-top-half/musl/src/stdio/tempnam.c @@ -6,6 +6,7 @@ #include #include #include "syscall.h" +#include "kstat.h" #define MAXTRIES 100 @@ -37,10 +38,10 @@ char *tempnam(const char *dir, const char *pfx) for (try=0; try #include #include "syscall.h" +#include "kstat.h" #define MAXTRIES 100 @@ -17,10 +18,10 @@ char *tmpnam(char *buf) for (try=0; tryflags &= ~F_EOF; FUNLOCK(f); - return c; + return (unsigned char)c; } diff --git a/libc-top-half/musl/src/string/arm/memcpy.c b/libc-top-half/musl/src/string/arm/memcpy.c index f703c9b..041614f 100644 --- a/libc-top-half/musl/src/string/arm/memcpy.c +++ b/libc-top-half/musl/src/string/arm/memcpy.c @@ -1,3 +1,3 @@ -#if __ARMEB__ || __thumb__ +#if __ARMEB__ #include "../memcpy.c" #endif diff --git a/libc-top-half/musl/src/string/arm/memcpy_le.S b/libc-top-half/musl/src/string/arm/memcpy_le.S index 9cfbcb2..7b35d30 100644 --- a/libc-top-half/musl/src/string/arm/memcpy_le.S +++ b/libc-top-half/musl/src/string/arm/memcpy_le.S @@ -1,4 +1,4 @@ -#if !__ARMEB__ && !__thumb__ +#if !__ARMEB__ /* * Copyright (C) 2008 The Android Open Source Project @@ -40,8 +40,9 @@ * This file has been modified from the original for use in musl libc. * The main changes are: addition of .type memcpy,%function to make the * code safely callable from thumb mode, adjusting the return - * instructions to be compatible with pre-thumb ARM cpus, and removal - * of prefetch code that is not compatible with older cpus. + * instructions to be compatible with pre-thumb ARM cpus, removal of + * prefetch code that is not compatible with older cpus and support for + * building as thumb 2. */ .syntax unified @@ -241,7 +242,8 @@ non_congruent: beq 2f ldr r5, [r1], #4 sub r2, r2, #4 - orr r4, r3, r5, lsl lr + mov r4, r5, lsl lr + orr r4, r4, r3 mov r3, r5, lsr r12 str r4, [r0], #4 cmp r2, #4 @@ -348,7 +350,8 @@ less_than_thirtytwo: 1: ldr r5, [r1], #4 sub r2, r2, #4 - orr r4, r3, r5, lsl lr + mov r4, r5, lsl lr + orr r4, r4, r3 mov r3, r5, lsr r12 str r4, [r0], #4 cmp r2, #4 diff --git a/libc-top-half/musl/src/time/__map_file.c b/libc-top-half/musl/src/time/__map_file.c index 9d37622..d3cefa8 100644 --- a/libc-top-half/musl/src/time/__map_file.c +++ b/libc-top-half/musl/src/time/__map_file.c @@ -2,10 +2,11 @@ #include #include #include "syscall.h" +#include "kstat.h" const char unsigned *__map_file(const char *pathname, size_t *size) { - struct stat st; + struct kstat st; const unsigned char *map = MAP_FAILED; int fd = sys_open(pathname, O_RDONLY|O_CLOEXEC|O_NONBLOCK); if (fd < 0) return 0; diff --git a/libc-top-half/musl/tools/add-cfi.i386.awk b/libc-top-half/musl/tools/add-cfi.i386.awk index 9162e30..d05037d 100644 --- a/libc-top-half/musl/tools/add-cfi.i386.awk +++ b/libc-top-half/musl/tools/add-cfi.i386.awk @@ -81,7 +81,7 @@ function adjust_sp_offset(delta) { in_function = 0 } } -/^\.type [a-zA-Z0-9_]+,\@function/ { +/^\.type [a-zA-Z0-9_]+,@function/ { functions[substr($2, 1, length($2)-10)] = 1 } # not interested in assembler directives beyond this, just pass them through diff --git a/libc-top-half/musl/tools/add-cfi.x86_64.awk b/libc-top-half/musl/tools/add-cfi.x86_64.awk index bbc90da..7e1513d 100644 --- a/libc-top-half/musl/tools/add-cfi.x86_64.awk +++ b/libc-top-half/musl/tools/add-cfi.x86_64.awk @@ -76,7 +76,7 @@ function adjust_sp_offset(delta) { in_function = 0 } } -/^\.type [a-zA-Z0-9_]+,\@function/ { +/^\.type [a-zA-Z0-9_]+,@function/ { functions[substr($2, 1, length($2)-10)] = 1 } # not interested in assembler directives beyond this, just pass them through From d9066a87c04748e7381695eaf01cc5c9a9c3003b Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Fri, 20 Dec 2019 15:14:02 -0800 Subject: [PATCH 25/30] Add support for `__main_argc_argv`. This adds support for the `__main_argc_argv` change, while preserving compatibility with `__original_main`. This is needed by the LTO build because the `__original_main` hack works in LLVM codegen, which is after LTO. The `__main_argc_argv` change is implemented in clang, which makes it properly visible to LTO. --- basics/crt/crt1.c | 7 ++- expected/wasm32-wasi/defined-symbols.txt | 2 + libc-bottom-half/crt/crt1.c | 8 ++- libc-bottom-half/sources/__main_argc_argv.c | 10 ++++ libc-bottom-half/sources/__main_void.c | 54 +++++++++++++++++++ libc-bottom-half/sources/__original_main.c | 57 +++------------------ 6 files changed, 78 insertions(+), 60 deletions(-) create mode 100644 libc-bottom-half/sources/__main_argc_argv.c create mode 100644 libc-bottom-half/sources/__main_void.c diff --git a/basics/crt/crt1.c b/basics/crt/crt1.c index a0f5a73..744baab 100644 --- a/basics/crt/crt1.c +++ b/basics/crt/crt1.c @@ -7,10 +7,9 @@ void _start(void) { // The linker synthesizes this to call constructors. __wasm_call_ctors(); - // Call `__original_main` which will either be the application's - // zero-argument `main` function (renamed by the compiler) or a libc - // routine which populates `argv` and `argc` and calls the application's - // two-argument `main`. + // Call `__original_main` which will either be the application's zero-argument + // `__original_main` function or a libc routine which calls `__main_void`. + // TODO: Call `main` directly once we no longer have to support old compilers. int r = __original_main(); // Call atexit functions, destructors, stdio cleanup, etc. diff --git a/expected/wasm32-wasi/defined-symbols.txt b/expected/wasm32-wasi/defined-symbols.txt index a510508..761f980 100644 --- a/expected/wasm32-wasi/defined-symbols.txt +++ b/expected/wasm32-wasi/defined-symbols.txt @@ -140,6 +140,8 @@ __log2f_data __log_data __logf_data __lseek +__main_argc_argv +__main_void __math_divzero __math_divzerof __math_invalid diff --git a/libc-bottom-half/crt/crt1.c b/libc-bottom-half/crt/crt1.c index 1b9cadb..f70c24a 100644 --- a/libc-bottom-half/crt/crt1.c +++ b/libc-bottom-half/crt/crt1.c @@ -1,5 +1,4 @@ #include -#include extern void __wasm_call_ctors(void); extern int __original_main(void); extern void __prepare_for_exit(void); @@ -8,10 +7,9 @@ void _start(void) { // The linker synthesizes this to call constructors. __wasm_call_ctors(); - // Call `__original_main` which will either be the application's - // zero-argument `main` function (renamed by the compiler) or a libc - // routine which populates `argv` and `argc` and calls the application's - // two-argument `main`. + // Call `__original_main` which will either be the application's zero-argument + // `__original_main` function or a libc routine which calls `__main_void`. + // TODO: Call `main` directly once we no longer have to support old compilers. int r = __original_main(); // Call atexit functions, destructors, stdio cleanup, etc. diff --git a/libc-bottom-half/sources/__main_argc_argv.c b/libc-bottom-half/sources/__main_argc_argv.c new file mode 100644 index 0000000..decaa2d --- /dev/null +++ b/libc-bottom-half/sources/__main_argc_argv.c @@ -0,0 +1,10 @@ +// New compilers define `__main_argc_argv`. If that doesn't exist, we +// may get called here. Old compilers define `main` expecting an +// argv/argc, so call that. +// TODO: Remove this layer when we no longer have to support old compilers. +int __wasilibc_main(int argc, char *argv[]) asm("main"); + +__attribute__((weak, nodebug)) +int __main_argc_argv(int argc, char *argv[]) { + return __wasilibc_main(argc, argv); +} diff --git a/libc-bottom-half/sources/__main_void.c b/libc-bottom-half/sources/__main_void.c new file mode 100644 index 0000000..6be5c1e --- /dev/null +++ b/libc-bottom-half/sources/__main_void.c @@ -0,0 +1,54 @@ +#include +#include +#include + +// The user's `main` function, expecting arguments. +int __main_argc_argv(int argc, char *argv[]); + +// If the user's `main` function expects arguments, the compiler will rename +// it to `__main_argc_argv`, and this version will get linked in, which +// initializes the argument data and calls `__main_argc_argv`. +__attribute__((weak, nodebug)) +int __main_void(void) { + __wasi_errno_t err; + + // Get the sizes of the arrays we'll have to create to copy in the args. + size_t argv_buf_size; + size_t argc; + err = __wasi_args_sizes_get(&argc, &argv_buf_size); + if (err != __WASI_ERRNO_SUCCESS) { + _Exit(EX_OSERR); + } + + // Add 1 for the NULL pointer to mark the end, and check for overflow. + size_t num_ptrs = argc + 1; + if (num_ptrs == 0) { + _Exit(EX_SOFTWARE); + } + + // Allocate memory for storing the argument chars. + char *argv_buf = malloc(argv_buf_size); + if (argv_buf == NULL) { + _Exit(EX_SOFTWARE); + } + + // Allocate memory for the array of pointers. This uses `calloc` both to + // handle overflow and to initialize the NULL pointer at the end. + char **argv = calloc(num_ptrs, sizeof(char *)); + if (argv == NULL) { + free(argv_buf); + _Exit(EX_SOFTWARE); + } + + // Fill the argument chars, and the argv array with pointers into those chars. + // TODO: Remove the casts on `argv_ptrs` and `argv_buf` once the witx is updated with char8 support. + err = __wasi_args_get((uint8_t **)argv, (uint8_t *)argv_buf); + if (err != __WASI_ERRNO_SUCCESS) { + free(argv_buf); + free(argv); + _Exit(EX_OSERR); + } + + // Call `__main_argc_argv` with the arguments! + return __main_argc_argv(argc, argv); +} diff --git a/libc-bottom-half/sources/__original_main.c b/libc-bottom-half/sources/__original_main.c index b0982d5..73564d4 100644 --- a/libc-bottom-half/sources/__original_main.c +++ b/libc-bottom-half/sources/__original_main.c @@ -1,55 +1,10 @@ -#include -#include -#include -#include +// Old compilers define `__original_main`. If that doesn't exist, we +// get called here. New compilers define `__main_void`. If that doesn't +// exist, we'll try something else. +// TODO: Remove this layer when we no longer have to support old compilers. +int __main_void(void); -// The user's `main` function, expecting arguments. -int main(int argc, char *argv[]); - -// If the user's `main` function expects arguments, the compiler won't emit -// an `__original_main` function so this version will get linked in, which -// initializes the argument data and calls `main`. __attribute__((weak)) int __original_main(void) { - __wasi_errno_t err; - - // Get the sizes of the arrays we'll have to create to copy in the args. - size_t argv_buf_size; - size_t argc; - err = __wasi_args_sizes_get(&argc, &argv_buf_size); - if (err != __WASI_ERRNO_SUCCESS) { - _Exit(EX_OSERR); - } - - // Add 1 for the NULL pointer to mark the end, and check for overflow. - size_t num_ptrs = argc + 1; - if (num_ptrs == 0) { - _Exit(EX_SOFTWARE); - } - - // Allocate memory for storing the argument chars. - char *argv_buf = malloc(argv_buf_size); - if (argv_buf == NULL) { - _Exit(EX_SOFTWARE); - } - - // Allocate memory for the array of pointers. This uses `calloc` both to - // handle overflow and to initialize the NULL pointer at the end. - char **argv = calloc(num_ptrs, sizeof(char *)); - if (argv == NULL) { - free(argv_buf); - _Exit(EX_SOFTWARE); - } - - // Fill the argument chars, and the argv array with pointers into those chars. - // TODO: Remove the casts on `argv_ptrs` and `argv_buf` once the witx is updated with char8 support. - err = __wasi_args_get((uint8_t **)argv, (uint8_t *)argv_buf); - if (err != __WASI_ERRNO_SUCCESS) { - free(argv_buf); - free(argv); - _Exit(EX_OSERR); - } - - // Call main with the arguments! - return main(argc, argv); + return __main_void(); } From 0cc57ac7b4c0e48a9e4a99e52538c793f2516f31 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Sat, 29 Feb 2020 01:52:28 -0800 Subject: [PATCH 26/30] Multi-license wasi-libc under Apache and MIT licenses. (#174) Multi-license wasi-libc under the Apache-2.0 WITH LLVM-exception, Apache-2.0, and MIT licenses. --- LICENSE | 26 ++-- LICENSE-APACHE | 201 ++++++++++++++++++++++++++++ LICENSE-APACHE-LLVM | 220 +++++++++++++++++++++++++++++++ LICENSE-MIT | 23 ++++ basics/LICENSE | 121 ----------------- dlmalloc/LICENSE | 121 ----------------- libc-bottom-half/headers/LICENSE | 121 ----------------- libc-bottom-half/mman/LICENSE | 121 ----------------- libc-bottom-half/sources/LICENSE | 121 ----------------- libc-top-half/headers/LICENSE | 121 ----------------- libc-top-half/sources/LICENSE | 121 ----------------- tools/wasi-headers/LICENSE | 22 +++- 12 files changed, 478 insertions(+), 861 deletions(-) create mode 100644 LICENSE-APACHE create mode 100644 LICENSE-APACHE-LLVM create mode 100644 LICENSE-MIT delete mode 100644 basics/LICENSE delete mode 100644 dlmalloc/LICENSE delete mode 100644 libc-bottom-half/headers/LICENSE delete mode 100644 libc-bottom-half/mman/LICENSE delete mode 100644 libc-bottom-half/sources/LICENSE delete mode 100644 libc-top-half/headers/LICENSE delete mode 100644 libc-top-half/sources/LICENSE diff --git a/LICENSE b/LICENSE index dc3a7e1..bdc0911 100644 --- a/LICENSE +++ b/LICENSE @@ -1,14 +1,16 @@ -Please see the LICENSE file in each top-level directory for the terms applicable to that directory and its relative sub-directories. +wasi-libc as a whole is multi-licensed under the +Apache License v2.0 with LLVM Exceptions, the Apache License v2.0, and +the MIT License. See the LICENSE-APACHE-LLVM, LICENSE-APACHE and LICENSE-MIT +files, respectively, for details. -The relevant directories and licenses are: +Portions of this software are derived from third-party works covered by +their own licenses: -basics/ - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -dlmalloc/ - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -libc-bottom-half/cloudlibc/ - BSD-2-Clause; see libc-bottom-half/cloudlibc/LICENSE for details -libc-bottom-half/libpreopen/ - BSD-2-Clause; see the individual files for details -libc-bottom-half/headers/ - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -libc-bottom-half/sources/ - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -libc-bottom-half/mman/ - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -libc-top-half/musl - MIT; see libc-top-half/musl/COPYRIGHT for details -libc-top-half/headers - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication -libc-top-half/sources - CC0 1.0 Universal (CC0 1.0) Public Domain Dedication +dlmalloc/ - CC0; see the notice in malloc.c for details +libc-bottom-half/cloudlibc/ - BSD-2-Clause; see the LICENSE file for details +libc-bottom-half/libpreopen/ - BSD-2-Clause; see the notice in libpreopen.c for details +libc-top-half/musl/ - MIT; see the COPYRIGHT file for details + +wasi-libc's changes to these files are multi-licensed under the +Apache License v2.0 with LLVM Exceptions, the Apache License v2.0, +the MIT License, and the original licenses of the third-party works. diff --git a/LICENSE-APACHE b/LICENSE-APACHE new file mode 100644 index 0000000..16fe87b --- /dev/null +++ b/LICENSE-APACHE @@ -0,0 +1,201 @@ + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + +TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + +1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + +2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + +3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + +4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + +5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + +6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + +7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + +8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + +9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + +END OF TERMS AND CONDITIONS + +APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + +Copyright [yyyy] [name of copyright owner] + +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. diff --git a/LICENSE-APACHE-LLVM b/LICENSE-APACHE-LLVM new file mode 100644 index 0000000..f9d8195 --- /dev/null +++ b/LICENSE-APACHE-LLVM @@ -0,0 +1,220 @@ + + Apache License + Version 2.0, January 2004 + http://www.apache.org/licenses/ + + TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION + + 1. Definitions. + + "License" shall mean the terms and conditions for use, reproduction, + and distribution as defined by Sections 1 through 9 of this document. + + "Licensor" shall mean the copyright owner or entity authorized by + the copyright owner that is granting the License. + + "Legal Entity" shall mean the union of the acting entity and all + other entities that control, are controlled by, or are under common + control with that entity. For the purposes of this definition, + "control" means (i) the power, direct or indirect, to cause the + direction or management of such entity, whether by contract or + otherwise, or (ii) ownership of fifty percent (50%) or more of the + outstanding shares, or (iii) beneficial ownership of such entity. + + "You" (or "Your") shall mean an individual or Legal Entity + exercising permissions granted by this License. + + "Source" form shall mean the preferred form for making modifications, + including but not limited to software source code, documentation + source, and configuration files. + + "Object" form shall mean any form resulting from mechanical + transformation or translation of a Source form, including but + not limited to compiled object code, generated documentation, + and conversions to other media types. + + "Work" shall mean the work of authorship, whether in Source or + Object form, made available under the License, as indicated by a + copyright notice that is included in or attached to the work + (an example is provided in the Appendix below). + + "Derivative Works" shall mean any work, whether in Source or Object + form, that is based on (or derived from) the Work and for which the + editorial revisions, annotations, elaborations, or other modifications + represent, as a whole, an original work of authorship. For the purposes + of this License, Derivative Works shall not include works that remain + separable from, or merely link (or bind by name) to the interfaces of, + the Work and Derivative Works thereof. + + "Contribution" shall mean any work of authorship, including + the original version of the Work and any modifications or additions + to that Work or Derivative Works thereof, that is intentionally + submitted to Licensor for inclusion in the Work by the copyright owner + or by an individual or Legal Entity authorized to submit on behalf of + the copyright owner. For the purposes of this definition, "submitted" + means any form of electronic, verbal, or written communication sent + to the Licensor or its representatives, including but not limited to + communication on electronic mailing lists, source code control systems, + and issue tracking systems that are managed by, or on behalf of, the + Licensor for the purpose of discussing and improving the Work, but + excluding communication that is conspicuously marked or otherwise + designated in writing by the copyright owner as "Not a Contribution." + + "Contributor" shall mean Licensor and any individual or Legal Entity + on behalf of whom a Contribution has been received by Licensor and + subsequently incorporated within the Work. + + 2. Grant of Copyright License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + copyright license to reproduce, prepare Derivative Works of, + publicly display, publicly perform, sublicense, and distribute the + Work and such Derivative Works in Source or Object form. + + 3. Grant of Patent License. Subject to the terms and conditions of + this License, each Contributor hereby grants to You a perpetual, + worldwide, non-exclusive, no-charge, royalty-free, irrevocable + (except as stated in this section) patent license to make, have made, + use, offer to sell, sell, import, and otherwise transfer the Work, + where such license applies only to those patent claims licensable + by such Contributor that are necessarily infringed by their + Contribution(s) alone or by combination of their Contribution(s) + with the Work to which such Contribution(s) was submitted. If You + institute patent litigation against any entity (including a + cross-claim or counterclaim in a lawsuit) alleging that the Work + or a Contribution incorporated within the Work constitutes direct + or contributory patent infringement, then any patent licenses + granted to You under this License for that Work shall terminate + as of the date such litigation is filed. + + 4. Redistribution. You may reproduce and distribute copies of the + Work or Derivative Works thereof in any medium, with or without + modifications, and in Source or Object form, provided that You + meet the following conditions: + + (a) You must give any other recipients of the Work or + Derivative Works a copy of this License; and + + (b) You must cause any modified files to carry prominent notices + stating that You changed the files; and + + (c) You must retain, in the Source form of any Derivative Works + that You distribute, all copyright, patent, trademark, and + attribution notices from the Source form of the Work, + excluding those notices that do not pertain to any part of + the Derivative Works; and + + (d) If the Work includes a "NOTICE" text file as part of its + distribution, then any Derivative Works that You distribute must + include a readable copy of the attribution notices contained + within such NOTICE file, excluding those notices that do not + pertain to any part of the Derivative Works, in at least one + of the following places: within a NOTICE text file distributed + as part of the Derivative Works; within the Source form or + documentation, if provided along with the Derivative Works; or, + within a display generated by the Derivative Works, if and + wherever such third-party notices normally appear. The contents + of the NOTICE file are for informational purposes only and + do not modify the License. You may add Your own attribution + notices within Derivative Works that You distribute, alongside + or as an addendum to the NOTICE text from the Work, provided + that such additional attribution notices cannot be construed + as modifying the License. + + You may add Your own copyright statement to Your modifications and + may provide additional or different license terms and conditions + for use, reproduction, or distribution of Your modifications, or + for any such Derivative Works as a whole, provided Your use, + reproduction, and distribution of the Work otherwise complies with + the conditions stated in this License. + + 5. Submission of Contributions. Unless You explicitly state otherwise, + any Contribution intentionally submitted for inclusion in the Work + by You to the Licensor shall be under the terms and conditions of + this License, without any additional terms or conditions. + Notwithstanding the above, nothing herein shall supersede or modify + the terms of any separate license agreement you may have executed + with Licensor regarding such Contributions. + + 6. Trademarks. This License does not grant permission to use the trade + names, trademarks, service marks, or product names of the Licensor, + except as required for reasonable and customary use in describing the + origin of the Work and reproducing the content of the NOTICE file. + + 7. Disclaimer of Warranty. Unless required by applicable law or + agreed to in writing, Licensor provides the Work (and each + Contributor provides its Contributions) on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied, including, without limitation, any warranties or conditions + of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A + PARTICULAR PURPOSE. You are solely responsible for determining the + appropriateness of using or redistributing the Work and assume any + risks associated with Your exercise of permissions under this License. + + 8. Limitation of Liability. In no event and under no legal theory, + whether in tort (including negligence), contract, or otherwise, + unless required by applicable law (such as deliberate and grossly + negligent acts) or agreed to in writing, shall any Contributor be + liable to You for damages, including any direct, indirect, special, + incidental, or consequential damages of any character arising as a + result of this License or out of the use or inability to use the + Work (including but not limited to damages for loss of goodwill, + work stoppage, computer failure or malfunction, or any and all + other commercial damages or losses), even if such Contributor + has been advised of the possibility of such damages. + + 9. Accepting Warranty or Additional Liability. While redistributing + the Work or Derivative Works thereof, You may choose to offer, + and charge a fee for, acceptance of support, warranty, indemnity, + or other liability obligations and/or rights consistent with this + License. However, in accepting such obligations, You may act only + on Your own behalf and on Your sole responsibility, not on behalf + of any other Contributor, and only if You agree to indemnify, + defend, and hold each Contributor harmless for any liability + incurred by, or claims asserted against, such Contributor by reason + of your accepting any such warranty or additional liability. + + END OF TERMS AND CONDITIONS + + APPENDIX: How to apply the Apache License to your work. + + To apply the Apache License to your work, attach the following + boilerplate notice, with the fields enclosed by brackets "[]" + replaced with your own identifying information. (Don't include + the brackets!) The text should be enclosed in the appropriate + comment syntax for the file format. We also recommend that a + file or class name and description of purpose be included on the + same "printed page" as the copyright notice for easier + identification within third-party archives. + + Copyright [yyyy] [name of copyright owner] + + 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. + + +--- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + diff --git a/LICENSE-MIT b/LICENSE-MIT new file mode 100644 index 0000000..31aa793 --- /dev/null +++ b/LICENSE-MIT @@ -0,0 +1,23 @@ +Permission is hereby granted, free of charge, to any +person obtaining a copy of this software and associated +documentation files (the "Software"), to deal in the +Software without restriction, including without +limitation the rights to use, copy, modify, merge, +publish, distribute, sublicense, and/or sell copies of +the Software, and to permit persons to whom the Software +is furnished to do so, subject to the following +conditions: + +The above copyright notice and this permission notice +shall be included in all copies or substantial portions +of the Software. + +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF +ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED +TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A +PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT +SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION +OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR +IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER +DEALINGS IN THE SOFTWARE. diff --git a/basics/LICENSE b/basics/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/basics/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/dlmalloc/LICENSE b/dlmalloc/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/dlmalloc/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/libc-bottom-half/headers/LICENSE b/libc-bottom-half/headers/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/libc-bottom-half/headers/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/libc-bottom-half/mman/LICENSE b/libc-bottom-half/mman/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/libc-bottom-half/mman/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/libc-bottom-half/sources/LICENSE b/libc-bottom-half/sources/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/libc-bottom-half/sources/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/libc-top-half/headers/LICENSE b/libc-top-half/headers/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/libc-top-half/headers/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/libc-top-half/sources/LICENSE b/libc-top-half/sources/LICENSE deleted file mode 100644 index 0e259d4..0000000 --- a/libc-top-half/sources/LICENSE +++ /dev/null @@ -1,121 +0,0 @@ -Creative Commons Legal Code - -CC0 1.0 Universal - - CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE - LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN - ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS - INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES - REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS - PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM - THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED - HEREUNDER. - -Statement of Purpose - -The laws of most jurisdictions throughout the world automatically confer -exclusive Copyright and Related Rights (defined below) upon the creator -and subsequent owner(s) (each and all, an "owner") of an original work of -authorship and/or a database (each, a "Work"). - -Certain owners wish to permanently relinquish those rights to a Work for -the purpose of contributing to a commons of creative, cultural and -scientific works ("Commons") that the public can reliably and without fear -of later claims of infringement build upon, modify, incorporate in other -works, reuse and redistribute as freely as possible in any form whatsoever -and for any purposes, including without limitation commercial purposes. -These owners may contribute to the Commons to promote the ideal of a free -culture and the further production of creative, cultural and scientific -works, or to gain reputation or greater distribution for their Work in -part through the use and efforts of others. - -For these and/or other purposes and motivations, and without any -expectation of additional consideration or compensation, the person -associating CC0 with a Work (the "Affirmer"), to the extent that he or she -is an owner of Copyright and Related Rights in the Work, voluntarily -elects to apply CC0 to the Work and publicly distribute the Work under its -terms, with knowledge of his or her Copyright and Related Rights in the -Work and the meaning and intended legal effect of CC0 on those rights. - -1. Copyright and Related Rights. A Work made available under CC0 may be -protected by copyright and related or neighboring rights ("Copyright and -Related Rights"). Copyright and Related Rights include, but are not -limited to, the following: - - i. the right to reproduce, adapt, distribute, perform, display, - communicate, and translate a Work; - ii. moral rights retained by the original author(s) and/or performer(s); -iii. publicity and privacy rights pertaining to a person's image or - likeness depicted in a Work; - iv. rights protecting against unfair competition in regards to a Work, - subject to the limitations in paragraph 4(a), below; - v. rights protecting the extraction, dissemination, use and reuse of data - in a Work; - vi. database rights (such as those arising under Directive 96/9/EC of the - European Parliament and of the Council of 11 March 1996 on the legal - protection of databases, and under any national implementation - thereof, including any amended or successor version of such - directive); and -vii. other similar, equivalent or corresponding rights throughout the - world based on applicable law or treaty, and any national - implementations thereof. - -2. Waiver. To the greatest extent permitted by, but not in contravention -of, applicable law, Affirmer hereby overtly, fully, permanently, -irrevocably and unconditionally waives, abandons, and surrenders all of -Affirmer's Copyright and Related Rights and associated claims and causes -of action, whether now known or unknown (including existing as well as -future claims and causes of action), in the Work (i) in all territories -worldwide, (ii) for the maximum duration provided by applicable law or -treaty (including future time extensions), (iii) in any current or future -medium and for any number of copies, and (iv) for any purpose whatsoever, -including without limitation commercial, advertising or promotional -purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each -member of the public at large and to the detriment of Affirmer's heirs and -successors, fully intending that such Waiver shall not be subject to -revocation, rescission, cancellation, termination, or any other legal or -equitable action to disrupt the quiet enjoyment of the Work by the public -as contemplated by Affirmer's express Statement of Purpose. - -3. Public License Fallback. Should any part of the Waiver for any reason -be judged legally invalid or ineffective under applicable law, then the -Waiver shall be preserved to the maximum extent permitted taking into -account Affirmer's express Statement of Purpose. In addition, to the -extent the Waiver is so judged Affirmer hereby grants to each affected -person a royalty-free, non transferable, non sublicensable, non exclusive, -irrevocable and unconditional license to exercise Affirmer's Copyright and -Related Rights in the Work (i) in all territories worldwide, (ii) for the -maximum duration provided by applicable law or treaty (including future -time extensions), (iii) in any current or future medium and for any number -of copies, and (iv) for any purpose whatsoever, including without -limitation commercial, advertising or promotional purposes (the -"License"). The License shall be deemed effective as of the date CC0 was -applied by Affirmer to the Work. Should any part of the License for any -reason be judged legally invalid or ineffective under applicable law, such -partial invalidity or ineffectiveness shall not invalidate the remainder -of the License, and in such case Affirmer hereby affirms that he or she -will not (i) exercise any of his or her remaining Copyright and Related -Rights in the Work or (ii) assert any associated claims and causes of -action with respect to the Work, in either case contrary to Affirmer's -express Statement of Purpose. - -4. Limitations and Disclaimers. - - a. No trademark or patent rights held by Affirmer are waived, abandoned, - surrendered, licensed or otherwise affected by this document. - b. Affirmer offers the Work as-is and makes no representations or - warranties of any kind concerning the Work, express, implied, - statutory or otherwise, including without limitation warranties of - title, merchantability, fitness for a particular purpose, non - infringement, or the absence of latent or other defects, accuracy, or - the present or absence of errors, whether or not discoverable, all to - the greatest extent permissible under applicable law. - c. Affirmer disclaims responsibility for clearing rights of other persons - that may apply to the Work or any use thereof, including without - limitation any person's Copyright and Related Rights in the Work. - Further, Affirmer disclaims responsibility for obtaining any necessary - consents, permissions or other rights required for any use of the - Work. - d. Affirmer understands and acknowledges that Creative Commons is not a - party to this document and has no duty or obligation with respect to - this CC0 or use of the Work. diff --git a/tools/wasi-headers/LICENSE b/tools/wasi-headers/LICENSE index 8f71f43..f9d8195 100644 --- a/tools/wasi-headers/LICENSE +++ b/tools/wasi-headers/LICENSE @@ -1,3 +1,4 @@ + Apache License Version 2.0, January 2004 http://www.apache.org/licenses/ @@ -178,7 +179,7 @@ APPENDIX: How to apply the Apache License to your work. To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "{}" + boilerplate notice, with the fields enclosed by brackets "[]" replaced with your own identifying information. (Don't include the brackets!) The text should be enclosed in the appropriate comment syntax for the file format. We also recommend that a @@ -186,7 +187,7 @@ same "printed page" as the copyright notice for easier identification within third-party archives. - Copyright {yyyy} {name of copyright owner} + Copyright [yyyy] [name of copyright owner] Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. @@ -200,3 +201,20 @@ See the License for the specific language governing permissions and limitations under the License. + +--- LLVM Exceptions to the Apache 2.0 License ---- + +As an exception, if, as a result of your compiling your source code, portions +of this Software are embedded into an Object form of such source code, you +may redistribute such embedded portions in such Object form without complying +with the conditions of Sections 4(a), 4(b) and 4(d) of the License. + +In addition, if you combine or link compiled forms of this Software with +software that is licensed under the GPLv2 ("Combined Software") and if a +court of competent jurisdiction determines that the patent provision (Section +3), the indemnity provision (Section 9) or other Section of the License +conflicts with the conditions of the GPLv2, you may retroactively and +prospectively choose to deem waived or otherwise exclude such Section(s) of +the License, but only in their entirety and only with respect to the Combined +Software. + From c33ea73e0eac81f474fdc0ec71bf031a66141540 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 10 Mar 2020 16:35:50 -0700 Subject: [PATCH 27/30] Update WASI Libc's README.md. Update the description, point users to wasi-sdk as a simpler place to get started using this library, and remove old text about being a "reference" implementation. --- README.md | 37 ++++++++++++++++--------------------- 1 file changed, 16 insertions(+), 21 deletions(-) diff --git a/README.md b/README.md index 8bd9ab0..8b2e915 100644 --- a/README.md +++ b/README.md @@ -1,30 +1,18 @@ # WASI Libc -This is a work in progress. It's usable for many purposes, though the APIs -aren't stable yet. +WASI Libc is a libc for WebAssembly programs built on top of WASI system calls. +It provides a wide array of POSIX-compatible C APIs, including support for +standard I/O, file I/O, filesystem manipulation, memory management, time, string, +environment variables, program startup, and many other APIs. -## What is this? - -It's several things. - -First, it's a usable libc. It builds a "libc" which can be used by -compilers, such as Clang 8.0, using the wasm32-wasi target. It's a work in -progress, but it is already sufficient to run basic programs. - -Second, it's a "reference" implementation, which means the interfaces defined -here can be used by other tools and libraries, even if they don't use all the -actual implementations here. For example, we don't expect everyone will want -to use the exact `malloc` implementation provided here, but tools and -libraries using an ABI-compatible `malloc` interface will be able to -interoperate regardless of which actual implementation is used. - -Third, it's an example showing the use of the WASI API. The libc functionality -is implemented using calls to WASI functions. +WASI Libc is sufficiently stable and usable for many purposes, as most of the +POSIX-compatible APIs are stable, though it is continuing to evolve to better +align with wasm and WASI. ## Usage -The easiest way to get started with this is to use one of the -[prepackaged releases](https://github.com/CraneStation/wasmtime/blob/master/docs/WASI-intro.md#how-can-i-write-programs-that-use-wasi). +The easiest way to get started with this is to use [wasi-sdk], which includes a +build of WASI Libc in its sysroot. ## Building from source @@ -48,3 +36,10 @@ To use the sysroot, use the `--sysroot=` option: ``` to run the compiler using the newly built sysroot. + +Note that Clang packages typically don't include cross-compiled builds of +compiler-rt, `libclang_rt.builtins-wasm32.a`, so they may not be usable without +extra setup. This is one of the things [wasi-sdk] simplifies, as it includes +a cross-compiled compiler-rt. + +[wasi-sdk]: https://github.com/WebAssembly/wasi-sdk From 42e6901e58f745e06d6dfd84a24e063f346b494e Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Tue, 17 Mar 2020 16:21:10 -0700 Subject: [PATCH 28/30] Mention libcxx and libcxxabi too. --- README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 8b2e915..367c4d3 100644 --- a/README.md +++ b/README.md @@ -38,8 +38,9 @@ To use the sysroot, use the `--sysroot=` option: to run the compiler using the newly built sysroot. Note that Clang packages typically don't include cross-compiled builds of -compiler-rt, `libclang_rt.builtins-wasm32.a`, so they may not be usable without +compiler-rt, libcxx, or libcxxabi, for `libclang_rt.builtins-wasm32.a`, libc++.a, +or libc++abi.a, respectively, so they may not be usable without extra setup. This is one of the things [wasi-sdk] simplifies, as it includes -a cross-compiled compiler-rt. +cross-compiled builds of compiler-rt, libc++.a, and libc++abi.a. [wasi-sdk]: https://github.com/WebAssembly/wasi-sdk From 38b930a26b60558522bc34adc7621fff17925b4a Mon Sep 17 00:00:00 2001 From: Sam Clegg Date: Wed, 18 Mar 2020 07:26:57 -0400 Subject: [PATCH 29/30] Fix -std=gnu17 when generating predefined_macros.txt (#187) * Fix -std=gnu11 when generating predefined_macros.txt The default recently changed in upstream clang: https://reviews.llvm.org/D75383 We want to be immune to such things when generating this list so that we can build wasi-libc with any recent clang version. * 17 --- Makefile | 1 + expected/wasm32-wasi/predefined-macros.txt | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/Makefile b/Makefile index 4fa5fcb..f723e55 100644 --- a/Makefile +++ b/Makefile @@ -480,6 +480,7 @@ finish: startup_files libc # TODO: Filter out __FLT16_* for now, as not all versions of clang have these. "$(WASM_CC)" $(WASM_CFLAGS) "$(SYSROOT_SHARE)/include-all.c" \ -isystem $(SYSROOT_INC) \ + -std=gnu17 \ -E -dM -Wno-\#warnings \ -D_ALL_SOURCE \ -U__llvm__ \ diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index 9510bf2..48f886f 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -2774,7 +2774,7 @@ #define __STDC_ISO_10646__ 201206L #define __STDC_UTF_16__ 1 #define __STDC_UTF_32__ 1 -#define __STDC_VERSION__ 201112L +#define __STDC_VERSION__ 201710L #define __STDC__ 1 #define __STDDEF_H #define __UAPI_DEF_IN6_ADDR 0 From 9efc2f428358564fe64c374d762d0bfce1d92507 Mon Sep 17 00:00:00 2001 From: Dan Gohman Date: Thu, 19 Mar 2020 09:32:41 -0700 Subject: [PATCH 30/30] Lazy-initialize the environment variables. (#184) * Lazy-initialize the environment variables. This is the first in a series of PRs to make it easier to use WASI libc in Wasm modules that don't have a `main` function. By initializing the environment on demand, we avoid depending on having `__wasm_call_ctors` run. This uses weak symbols strategically to ensure that if `environ` is used, it is initialized eagerly, but if only `getenv` and friends are used, the environment is initialized lazily. Eventually, I expect we'll have a convention for wasm modules without main functions which will allow the `__wasm_call_ctors` function to be called automatically, but this helps in simple cases for now. Fixes #180. * Add comments explaining the libc-environ-compat.h header usage. --- expected/wasm32-wasi/defined-symbols.txt | 5 ++- expected/wasm32-wasi/include-all.c | 1 + expected/wasm32-wasi/predefined-macros.txt | 1 + .../headers/public/wasi/libc-environ.h | 19 +++++++++ libc-bottom-half/libpreopen/libpreopen.c | 2 +- ...iron.c => __wasilibc_initialize_environ.c} | 40 ++++++++++++------- libc-bottom-half/sources/environ.c | 26 ++++++++++++ .../private/wasi/libc-environ-compat.h | 12 ++++++ libc-top-half/musl/src/env/clearenv.c | 7 ++++ libc-top-half/musl/src/env/getenv.c | 7 ++++ libc-top-half/musl/src/env/putenv.c | 7 ++++ libc-top-half/musl/src/env/unsetenv.c | 7 ++++ libc-top-half/musl/src/include/unistd.h | 7 ++++ 13 files changed, 124 insertions(+), 17 deletions(-) create mode 100644 libc-bottom-half/headers/public/wasi/libc-environ.h rename libc-bottom-half/sources/{__environ.c => __wasilibc_initialize_environ.c} (54%) create mode 100644 libc-bottom-half/sources/environ.c create mode 100644 libc-top-half/headers/private/wasi/libc-environ-compat.h diff --git a/expected/wasm32-wasi/defined-symbols.txt b/expected/wasm32-wasi/defined-symbols.txt index 761f980..dc20ddf 100644 --- a/expected/wasm32-wasi/defined-symbols.txt +++ b/expected/wasm32-wasi/defined-symbols.txt @@ -39,7 +39,6 @@ __env_rm_add __env_rm_add __env_rm_add __env_rm_add -__environ __exp2f_data __exp_data __expo2 @@ -252,8 +251,12 @@ __uflow __unlist_locked_file __uselocale __utc +__wasilibc_ensure_environ +__wasilibc_environ +__wasilibc_environ __wasilibc_fd_renumber __wasilibc_find_relpath +__wasilibc_initialize_environ __wasilibc_open_nomode __wasilibc_openat_nomode __wasilibc_register_preopened_fd diff --git a/expected/wasm32-wasi/include-all.c b/expected/wasm32-wasi/include-all.c index e1d6231..71665bc 100644 --- a/expected/wasm32-wasi/include-all.c +++ b/expected/wasm32-wasi/include-all.c @@ -166,6 +166,7 @@ #include #include #include +#include #include #include #include diff --git a/expected/wasm32-wasi/predefined-macros.txt b/expected/wasm32-wasi/predefined-macros.txt index 48f886f..db4ae4d 100644 --- a/expected/wasm32-wasi/predefined-macros.txt +++ b/expected/wasm32-wasi/predefined-macros.txt @@ -3098,6 +3098,7 @@ #define __va_copy(d,s) __builtin_va_copy(d,s) #define __wasi__ 1 #define __wasi_api_h +#define __wasi_libc_environ_h #define __wasi_libc_find_relpath_h #define __wasi_libc_h #define __wasilibc___errno_values_h diff --git a/libc-bottom-half/headers/public/wasi/libc-environ.h b/libc-bottom-half/headers/public/wasi/libc-environ.h new file mode 100644 index 0000000..b404add --- /dev/null +++ b/libc-bottom-half/headers/public/wasi/libc-environ.h @@ -0,0 +1,19 @@ +#ifndef __wasi_libc_environ_h +#define __wasi_libc_environ_h + +#ifdef __cplusplus +extern "C" { +#endif + +/// Initialize the global environment variable state. Only needs to be +/// called once; most users should call `__wasilibc_ensure_environ` instead. +void __wasilibc_initialize_environ(void); + +/// If `__wasilibc_initialize_environ` has not yet been called, call it. +void __wasilibc_ensure_environ(void); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/libc-bottom-half/libpreopen/libpreopen.c b/libc-bottom-half/libpreopen/libpreopen.c index f8eca3b..fd1d6f9 100644 --- a/libc-bottom-half/libpreopen/libpreopen.c +++ b/libc-bottom-half/libpreopen/libpreopen.c @@ -524,7 +524,7 @@ __wasilibc_find_relpath( /// This is referenced by weak reference from crt1.c and lives in the same source /// file as `__wasilibc_find_relpath` so that it's linked in when it's needed. // Concerning the 51 -- see the comment by the constructor priority in -// libc-bottom-half/sources/__environ.c. +// libc-bottom-half/sources/__wasilibc_environ.c. __attribute__((constructor(51))) static void __wasilibc_populate_libpreopen(void) diff --git a/libc-bottom-half/sources/__environ.c b/libc-bottom-half/sources/__wasilibc_initialize_environ.c similarity index 54% rename from libc-bottom-half/sources/__environ.c rename to libc-bottom-half/sources/__wasilibc_initialize_environ.c index 8ced813..fe6001a 100644 --- a/libc-bottom-half/sources/__environ.c +++ b/libc-bottom-half/sources/__wasilibc_initialize_environ.c @@ -3,29 +3,38 @@ #include #include #include +#include +/// If the program doesn't use `environ`, it'll get this version of +/// `__wasilibc_environ`, which isn't initialized with a constructor function. +/// `getenv` etc. call `__wasilibc_ensure_environ()` before accessing it. +/// Statically-initialize it to an invalid pointer value so that we can +/// detect if it's been explicitly initialized (we can't use `NULL` because +/// `clearenv` sets it to NULL. +char **__wasilibc_environ __attribute__((weak)) = (char **)-1; + +// See the comments in libc-environ.h. +void __wasilibc_ensure_environ(void) { + if (__wasilibc_environ == (char **)-1) { + __wasilibc_initialize_environ(); + } +} + +/// Avoid dynamic allocation for the case where there are no environment +/// variables, but we still need a non-NULL pointer to an (empty) array. static char *empty_environ[1] = { NULL }; -char **__environ = empty_environ; -extern __typeof(__environ) _environ __attribute__((weak, alias("__environ"))); -extern __typeof(__environ) environ __attribute__((weak, alias("__environ"))); - -// We define this function here in the same source file as __environ, so that -// this function is called in iff environment variable support is used. -// Concerning the 50 -- levels up to 100 are reserved for the implementation, -// so we an arbitrary number in the middle of the range to allow other -// reserved things to go before or after. -__attribute__((constructor(50))) -static void __wasilibc_populate_environ(void) { - __wasi_errno_t err; +// See the comments in libc-environ.h. +void __wasilibc_initialize_environ(void) { // Get the sizes of the arrays we'll have to create to copy in the environment. size_t environ_count; size_t environ_buf_size; - err = __wasi_environ_sizes_get(&environ_count, &environ_buf_size); + __wasi_errno_t err = __wasi_environ_sizes_get(&environ_count, &environ_buf_size); if (err != __WASI_ERRNO_SUCCESS) { goto oserr; } if (environ_count == 0) { + __wasilibc_environ = empty_environ; return; } @@ -49,7 +58,8 @@ static void __wasilibc_populate_environ(void) { goto software; } - // Fill the environment chars, and the __environ array with pointers into those chars. + // Fill the environment chars, and the `__wasilibc_environ` array with + // pointers into those chars. // TODO: Remove the casts on `environ_ptrs` and `environ_buf` once the witx is updated with char8 support. err = __wasi_environ_get((uint8_t **)environ_ptrs, (uint8_t *)environ_buf); if (err != __WASI_ERRNO_SUCCESS) { @@ -58,7 +68,7 @@ static void __wasilibc_populate_environ(void) { goto oserr; } - __environ = environ_ptrs; + __wasilibc_environ = environ_ptrs; return; oserr: _Exit(EX_OSERR); diff --git a/libc-bottom-half/sources/environ.c b/libc-bottom-half/sources/environ.c new file mode 100644 index 0000000..bc5a078 --- /dev/null +++ b/libc-bottom-half/sources/environ.c @@ -0,0 +1,26 @@ +#include +#include +#include +#include +#include +#include + +// If the program does use `environ`, it'll get this version of +// `__wasilibc_environ`, which is initialized with a constructor function, so +// that it's initialized whenever user code might want to access it. +char **__wasilibc_environ; +extern __typeof(__wasilibc_environ) _environ + __attribute__((weak, alias("__wasilibc_environ"))); +extern __typeof(__wasilibc_environ) environ + __attribute__((weak, alias("__wasilibc_environ"))); + +// We define this function here in the same source file as +// `__wasilibc_environ`, so that this function is called in iff environment +// variable support is used. +// Concerning the 50 -- levels up to 100 are reserved for the implementation, +// so we an arbitrary number in the middle of the range to allow other +// reserved things to go before or after. +__attribute__((constructor(50))) +static void __wasilibc_initialize_environ_eagerly(void) { + __wasilibc_initialize_environ(); +} diff --git a/libc-top-half/headers/private/wasi/libc-environ-compat.h b/libc-top-half/headers/private/wasi/libc-environ-compat.h new file mode 100644 index 0000000..fa2747d --- /dev/null +++ b/libc-top-half/headers/private/wasi/libc-environ-compat.h @@ -0,0 +1,12 @@ +// This header file is meant to be included withinin the body of a function +// which uses `__environ`. Code using `__environ` expects it will be initialized +// eagerly. `__wasilibc_environ` is initialized lazily. Provide `__environ` as +// an alias and arrange for the lazy initialization to be performed. + +extern char **__wasilibc_environ; + +__wasilibc_ensure_environ(); + +#ifndef __wasilibc_environ +#define __environ __wasilibc_environ +#endif diff --git a/libc-top-half/musl/src/env/clearenv.c b/libc-top-half/musl/src/env/clearenv.c index db8e8e9..0abbec3 100644 --- a/libc-top-half/musl/src/env/clearenv.c +++ b/libc-top-half/musl/src/env/clearenv.c @@ -7,6 +7,13 @@ weak_alias(dummy, __env_rm_add); int clearenv() { +#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init. +#else +// This specialized header is included within the function body to arranges for +// the environment variables to be lazily initialized. It redefined `__environ`, +// so don't remove or reorder it with respect to other code. +#include "wasi/libc-environ-compat.h" +#endif char **e = __environ; __environ = 0; if (e) while (*e) __env_rm_add(*e++, 0); diff --git a/libc-top-half/musl/src/env/getenv.c b/libc-top-half/musl/src/env/getenv.c index a90d39c..346c333 100644 --- a/libc-top-half/musl/src/env/getenv.c +++ b/libc-top-half/musl/src/env/getenv.c @@ -4,6 +4,13 @@ char *getenv(const char *name) { +#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init. +#else +// This specialized header is included within the function body to arranges for +// the environment variables to be lazily initialized. It redefined `__environ`, +// so don't remove or reorder it with respect to other code. +#include "wasi/libc-environ-compat.h" +#endif size_t l = __strchrnul(name, '=') - name; if (l && !name[l] && __environ) for (char **e = __environ; *e; e++) diff --git a/libc-top-half/musl/src/env/putenv.c b/libc-top-half/musl/src/env/putenv.c index dce8c82..0d59895 100644 --- a/libc-top-half/musl/src/env/putenv.c +++ b/libc-top-half/musl/src/env/putenv.c @@ -7,6 +7,13 @@ weak_alias(dummy, __env_rm_add); int __putenv(char *s, size_t l, char *r) { +#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init. +#else +// This specialized header is included within the function body to arranges for +// the environment variables to be lazily initialized. It redefined `__environ`, +// so don't remove or reorder it with respect to other code. +#include "wasi/libc-environ-compat.h" +#endif size_t i=0; if (__environ) { for (char **e = __environ; *e; e++, i++) diff --git a/libc-top-half/musl/src/env/unsetenv.c b/libc-top-half/musl/src/env/unsetenv.c index b14c4c9..40f0eea 100644 --- a/libc-top-half/musl/src/env/unsetenv.c +++ b/libc-top-half/musl/src/env/unsetenv.c @@ -13,6 +13,13 @@ int unsetenv(const char *name) errno = EINVAL; return -1; } +#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init. +#else +// This specialized header is included within the function body to arranges for +// the environment variables to be lazily initialized. It redefined `__environ`, +// so don't remove or reorder it with respect to other code. +#include "wasi/libc-environ-compat.h" +#endif if (__environ) { char **e = __environ, **eo = e; for (; *e; e++) diff --git a/libc-top-half/musl/src/include/unistd.h b/libc-top-half/musl/src/include/unistd.h index 1b4605c..f372afe 100644 --- a/libc-top-half/musl/src/include/unistd.h +++ b/libc-top-half/musl/src/include/unistd.h @@ -3,7 +3,14 @@ #include "../../include/unistd.h" +#ifdef __wasilibc_unmodified_upstream // Lazy environment variable init. extern char **__environ; +#else +// To support lazy initialization of environment variables, `__environ` is +// omitted, and a lazy `__wasilibc_environ` is used instead. Use +// "wasi/libc-environ-compat.h" in functions that use `__environ`. +#include "wasi/libc-environ.h" +#endif hidden int __dup3(int, int, int); hidden int __mkostemps(char *, int, int);