Make improvements

- Introduce portable sched_getcpu() api
- Support GCC's __target_clones__ feature
- Make fma() go faster on x86 in default mode
- Remove some asan checks from core libraries
- WinMain() now ensures $HOME and $USER are defined
This commit is contained in:
Justine Tunney 2024-02-01 03:39:46 -08:00
parent d5225a693b
commit 2ab9e9f7fd
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
192 changed files with 2809 additions and 932 deletions

View file

@ -223,6 +223,7 @@ $(THIRD_PARTY_LIBCXX_A_OBJS): private \
-fdata-sections \
-fexceptions \
-frtti \
-Wno-alloc-size-larger-than \
-DLIBCXX_BUILDING_LIBCXXABI
THIRD_PARTY_LIBCXX_LIBS = $(foreach x,$(THIRD_PARTY_LIBCXX_ARTIFACTS),$($(x)))

View file

@ -78,7 +78,7 @@
#if defined(_LIBCPP_ABI_UNSTABLE) || _LIBCPP_ABI_VERSION >= 2
// Change short string representation so that string data starts at offset 0,
// improving its alignment in some cases.
# define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// # define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// Fix deque iterator type in order to support incomplete types.
# define _LIBCPP_ABI_INCOMPLETE_TYPES_IN_DEQUE
// Fix undefined behavior in how std::list stores its linked nodes.
@ -332,7 +332,7 @@
#if (defined(__APPLE__) && !defined(__i386__) && !defined(__x86_64__) && \
(!defined(__arm__) || __ARM_ARCH_7K__ >= 2)) || \
defined(_LIBCPP_ALTERNATE_STRING_LAYOUT)
#define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
// #define _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
#endif
#if __has_feature(cxx_alignas)

View file

@ -17,7 +17,7 @@ Macros:
*/
#include "third_party/libcxx/__config"
#include "libc/assert.h"
#include "libc/isystem/assert.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -53,7 +53,7 @@ int feupdateenv(const fenv_t* envp);
*/
#include "third_party/libcxx/__config"
#include "libc/runtime/fenv.h"
#include "libc/isystem/fenv.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -70,8 +70,7 @@ Macros:
*/
#include "third_party/libcxx/__config"
#include "libc/math.h"
#include "libc/runtime/fenv.h"
#include "libc/isystem/float.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -236,8 +236,7 @@ uintmax_t wcstoumax(const wchar_t* restrict nptr, wchar_t** restrict endptr, int
#include "third_party/libcxx/__config"
#include "third_party/libcxx/cstdint"
#include "libc/inttypes.h"
#include "libc/fmt/conv.h"
#include "libc/isystem/inttypes.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -21,4 +21,6 @@
#pragma GCC system_header
#endif
#include "libc/isystem/iso646.h"
#endif // _LIBCPP_CISO646

View file

@ -35,8 +35,7 @@ lconv* localeconv();
*/
#include "third_party/libcxx/__config"
#include "libc/str/unicode.h"
#include "libc/str/locale.h"
#include "libc/isystem/locale.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -31,7 +31,7 @@ void longjmp(jmp_buf env, int val);
*/
#include "third_party/libcxx/__config"
#include "libc/runtime/runtime.h"
#include "libc/isystem/setjmp.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -40,12 +40,7 @@ int raise(int sig);
*/
#include "third_party/libcxx/__config"
#include "libc/calls/calls.h"
#include "libc/calls/struct/sigaction.h"
#include "libc/calls/struct/siginfo.h"
#include "libc/sysv/consts/sa.h"
#include "libc/sysv/consts/sig.h"
#include "libc/sysv/consts/sicode.h"
#include "libc/isystem/signal.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -11,6 +11,7 @@
#define _LIBCPP_CSTDARG
#include "third_party/libcxx/__config"
#include "libc/isystem/stdarg.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -20,6 +20,7 @@ Macros:
*/
#include "third_party/libcxx/__config"
#include "libc/isystem/stdbool.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -35,6 +35,7 @@ Types:
#include "third_party/libcxx/__config"
#include "third_party/libcxx/version"
#include "libc/isystem/stddef.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -10,11 +10,7 @@
#ifndef _LIBCPP_CSTDINT
#define _LIBCPP_CSTDINT
#include "libc/inttypes.h"
#include "libc/fmt/conv.h"
#include "libc/limits.h"
#include "libc/literal.h"
#include "libc/calls/weirdtypes.h"
#include "libc/isystem/stdint.h"
#include "third_party/libcxx/__config"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View file

@ -13,6 +13,7 @@
#include "third_party/libcxx/__config"
#include "libc/str/str.h"
#include "third_party/libcxx/stdlib.h"
#include "libc/isystem/stdlib.h"
/*
cstdlib synopsis

View file

@ -11,15 +11,7 @@
#define _LIBCPP_CTIME
#include "third_party/libcxx/__config"
#include "libc/calls/struct/timespec.h"
#include "libc/calls/struct/timeval.h"
#include "libc/sysv/consts/clock.h"
#include "libc/sysv/consts/sched.h"
#include "libc/sysv/consts/timer.h"
#include "libc/calls/weirdtypes.h"
#include "libc/time/struct/tm.h"
#include "libc/calls/calls.h"
#include "libc/time/time.h"
#include "libc/isystem/time.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -35,7 +35,7 @@ int toupper(int c);
#pragma GCC system_header
#endif
#include "libc/str/str.h"
#include "libc/isystem/ctype.h"
#ifdef __cplusplus

View file

@ -28,7 +28,7 @@ Macros:
#pragma GCC system_header
#endif
#include "libc/errno.h"
#include "libc/isystem/errno.h"
#ifdef __cplusplus

View file

@ -43,22 +43,6 @@ Macros:
#pragma GCC system_header
#endif
#ifndef __GNUC__
#include "libc/limits.h"
#else
// GCC header limits.h recursively includes itself through another header called
// syslimits.h for some reason. This setup breaks down if we directly
// #include_next GCC's limits.h (reasons not entirely clear to me). Therefore,
// we manually re-create the necessary include sequence below:
// Get the system limits.h defines (force recurse into the next level)
#define _GCC_LIMITS_H_
#define _GCC_NEXT_LIMITS_H
#include "libc/limits.h"
// Get the ISO C defines
#undef _GCC_LIMITS_H_
#include "libc/limits.h"
#endif // __GNUC__
#include "libc/isystem/limits.h"
#endif // _LIBCPP_LIMITS_H

View file

@ -39,7 +39,6 @@ Functions:
#pragma GCC system_header
#endif
#include "libc/str/locale.h"
#include "libc/str/unicode.h"
#include "libc/isystem/locale.h"
#endif // _LIBCPP_LOCALE_H

View file

@ -19,7 +19,7 @@
#define _LIBCPP_STDLIB_INCLUDE_NEXT
#include "third_party/libcxx/stdlib.h"
#include "libc/math.h"
#include "libc/isystem/math.h"
#ifdef __cplusplus

View file

@ -102,9 +102,7 @@ void perror(const char* s);
#pragma GCC system_header
#endif
#include "libc/calls/calls.h"
#include "libc/temp.h"
#include "libc/stdio/stdio.h"
#include "libc/isystem/stdio.h"
#ifdef __cplusplus

View file

@ -9,13 +9,7 @@
#if defined(__need_malloc_and_calloc) || defined(_LIBCPP_STDLIB_INCLUDE_NEXT)
#include "libc/stdio/rand.h"
#include "libc/mem/mem.h"
#include "libc/runtime/runtime.h"
#include "libc/runtime/runtime.h"
#include "libc/mem/alg.h"
#include "libc/stdio/stdio.h"
#include "libc/fmt/conv.h"
#include "libc/isystem/stdlib.h"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)
#pragma GCC system_header

View file

@ -702,34 +702,41 @@ private:
#ifdef _LIBCPP_ABI_ALTERNATE_STRING_LAYOUT
struct __long
{
pointer __data_;
struct __long {
pointer __data_;
size_type __size_;
size_type __cap_;
size_type __cap_ : sizeof(size_type) * CHAR_BIT - 1;
size_type __is_long_ : 1;
};
#ifdef _LIBCPP_BIG_ENDIAN
static const size_type __short_mask = 0x01;
static const size_type __long_mask = 0x1ul;
#else // _LIBCPP_BIG_ENDIAN
static const size_type __short_mask = 0x80;
static const size_type __long_mask = ~(size_type(~0) >> 1);
#endif // _LIBCPP_BIG_ENDIAN
enum { __min_cap = (sizeof(__long) - 1) / sizeof(value_type) > 2 ? (sizeof(__long) - 1) / sizeof(value_type) : 2 };
enum {__min_cap = (sizeof(__long) - 1)/sizeof(value_type) > 2 ?
(sizeof(__long) - 1)/sizeof(value_type) : 2};
struct __short
{
struct __short {
value_type __data_[__min_cap];
struct
: __padding<value_type>
{
unsigned char __size_;
};
unsigned char __padding_[sizeof(value_type) - 1];
unsigned char __size_ : 7;
unsigned char __is_long_ : 1;
};
// The __endian_factor is required because the field we use to store the size
// has one fewer bit than it would if it were not a bitfield.
//
// If the LSB is used to store the short-flag in the short string representation,
// we have to multiply the size by two when it is stored and divide it by two when
// it is loaded to make sure that we always store an even number. In the long string
// representation, we can ignore this because we can assume that we always allocate
// an even amount of value_types.
//
// If the MSB is used for the short-flag, the max_size() is numeric_limits<size_type>::max() / 2.
// This does not impact the short string representation, since we never need the MSB
// for representing the size of a short string anyway.
# ifdef _LIBCPP_BIG_ENDIAN
static const size_type __endian_factor = 2;
# else
static const size_type __endian_factor = 1;
# endif
#else
struct __long

View file

@ -16,7 +16,7 @@
#pragma GCC system_header
#endif
#include "libc/str/str.h"
#include "libc/isystem/string.h"
/*
string.h synopsis

View file

@ -9,8 +9,7 @@
#ifndef _LIBCPP_WCHAR_H
#define _LIBCPP_WCHAR_H
#include "libc/str/str.h"
#include "libc/time/time.h"
#include "libc/isystem/wchar.h"
#include "third_party/libcxx/__config"
#if !defined(_LIBCPP_HAS_NO_PRAGMA_SYSTEM_HEADER)

View file

@ -50,8 +50,7 @@ wctrans_t wctrans(const char* property);
#pragma GCC system_header
#endif
#include "libc/str/str.h"
#include "libc/time/time.h"
#include "libc/isystem/wctype.h"
#ifdef __cplusplus