@zigc/lib 0.17.0-dev.215 → 0.17.0-dev.224

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (45) hide show
  1. package/libcxx/libc/hdr/errno_macros.h +3 -1
  2. package/libcxx/libc/hdr/stdint_proxy.h +18 -0
  3. package/libcxx/libc/hdr/types/wchar_t.h +23 -0
  4. package/libcxx/libc/hdr/wchar_overlay.h +69 -0
  5. package/libcxx/libc/include/llvm-libc-macros/cfloat128-macros.h +41 -0
  6. package/libcxx/libc/include/llvm-libc-macros/cfloat16-macros.h +20 -0
  7. package/libcxx/libc/include/llvm-libc-macros/wchar-macros.h +18 -0
  8. package/libcxx/libc/include/llvm-libc-types/cfloat128.h +11 -28
  9. package/libcxx/libc/include/llvm-libc-types/cfloat16.h +4 -7
  10. package/libcxx/libc/include/llvm-libc-types/wint_t.h +14 -0
  11. package/libcxx/libc/shared/libc_common.h +5 -0
  12. package/libcxx/libc/src/__support/CPP/bit.h +50 -12
  13. package/libcxx/libc/src/__support/CPP/type_traits/is_complex.h +7 -0
  14. package/libcxx/libc/src/__support/CPP/type_traits/is_destructible.h +2 -1
  15. package/libcxx/libc/src/__support/CPP/type_traits/is_unsigned.h +6 -0
  16. package/libcxx/libc/src/__support/CPP/utility/integer_sequence.h +10 -0
  17. package/libcxx/libc/src/__support/FPUtil/FPBits.h +6 -7
  18. package/libcxx/libc/src/__support/FPUtil/rounding_mode.h +50 -4
  19. package/libcxx/libc/src/__support/big_int.h +14 -14
  20. package/libcxx/libc/src/__support/common.h +3 -2
  21. package/libcxx/libc/src/__support/ctype_utils.h +19 -12
  22. package/libcxx/libc/src/__support/detailed_powers_of_ten.h +1 -2
  23. package/libcxx/libc/src/__support/high_precision_decimal.h +33 -14
  24. package/libcxx/libc/src/__support/libc_assert.h +2 -0
  25. package/libcxx/libc/src/__support/macros/attributes.h +44 -1
  26. package/libcxx/libc/src/__support/macros/config.h +23 -0
  27. package/libcxx/libc/src/__support/macros/null_check.h +1 -2
  28. package/libcxx/libc/src/__support/macros/optimization.h +3 -0
  29. package/libcxx/libc/src/__support/macros/properties/architectures.h +5 -1
  30. package/libcxx/libc/src/__support/macros/properties/compiler.h +8 -3
  31. package/libcxx/libc/src/__support/macros/properties/cpu_features.h +17 -1
  32. package/libcxx/libc/src/__support/macros/properties/types.h +2 -3
  33. package/libcxx/libc/src/__support/macros/sanitizer.h +0 -10
  34. package/libcxx/libc/src/__support/math_extras.h +20 -4
  35. package/libcxx/libc/src/__support/str_to_float.h +98 -125
  36. package/libcxx/libc/src/__support/str_to_integer.h +39 -27
  37. package/libcxx/libc/src/__support/wctype_utils.h +588 -0
  38. package/libunwind/src/AddressSpace.hpp +2 -1
  39. package/libunwind/src/DwarfParser.hpp +2 -1
  40. package/package.json +1 -1
  41. package/std/Target.zig +5 -6
  42. package/std/crypto/ml_kem.zig +0 -15
  43. package/std/math/modf.zig +1 -1
  44. package/std/zig/target.zig +1 -2
  45. package/std/zon/parse.zig +1 -1
@@ -15,7 +15,9 @@
15
15
  #include <linux/errno.h>
16
16
 
17
17
  #include "include/llvm-libc-macros/error-number-macros.h"
18
- #else // __linux__
18
+ #elif defined(__APPLE__)
19
+ #include <sys/errno.h>
20
+ #else // __APPLE__
19
21
  #include "include/llvm-libc-macros/generic-error-number-macros.h"
20
22
  #endif
21
23
 
@@ -0,0 +1,18 @@
1
+ //===-- stdint.h ----------------------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_HDR_STDINT_PROXY_H
10
+ #define LLVM_LIBC_HDR_STDINT_PROXY_H
11
+
12
+ // This target is to make sure we have correct build order in full build mode,
13
+ // that is `libc.include.stdint` is added to the dependency of all targets
14
+ // that use <stdint.h> header.
15
+
16
+ #include <stdint.h>
17
+
18
+ #endif // LLVM_LIBC_HDR_STDINT_PROXY_H
@@ -0,0 +1,23 @@
1
+ //===-- Definition of wchar_t.h -------------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //
8
+ //===----------------------------------------------------------------------===//
9
+
10
+ #ifndef LLVM_LIBC_HDR_TYPES_WCHAR_T_H
11
+ #define LLVM_LIBC_HDR_TYPES_WCHAR_T_H
12
+
13
+ #ifdef LIBC_FULL_BUILD
14
+
15
+ #include "include/llvm-libc-types/wchar_t.h"
16
+
17
+ #else // overlay mode
18
+
19
+ #include "hdr/wchar_overlay.h"
20
+
21
+ #endif // LLVM_LIBC_FULL_BUILD
22
+
23
+ #endif // LLVM_LIBC_HDR_TYPES_WCHAR_T_H
@@ -0,0 +1,69 @@
1
+ //===-- Including wchar.h in overlay mode ---------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_HDR_WCHAR_OVERLAY_H
10
+ #define LLVM_LIBC_HDR_WCHAR_OVERLAY_H
11
+
12
+ #ifdef LIBC_FULL_BUILD
13
+ #error "This header should only be included in overlay mode"
14
+ #endif
15
+
16
+ // Overlay mode
17
+
18
+ // glibc <wchar.h> header might provide extern inline definitions for few
19
+ // functions, causing external alias errors. They are guarded by
20
+ // `__USE_EXTERN_INLINES` macro. We temporarily disable `__USE_EXTERN_INLINES`
21
+ // macro by defining `__NO_INLINE__` before including <wchar.h>.
22
+ // And the same with `__USE_FORTIFY_LEVEL`, which will be temporarily disabled
23
+ // with `_FORTIFY_SOURCE`.
24
+
25
+ #ifdef _FORTIFY_SOURCE
26
+ #define LIBC_OLD_FORTIFY_SOURCE _FORTIFY_SOURCE
27
+ #undef _FORTIFY_SOURCE
28
+ #endif
29
+
30
+ #ifndef __NO_INLINE__
31
+ #define __NO_INLINE__ 1
32
+ #define LIBC_SET_NO_INLINE
33
+ #endif
34
+
35
+ #ifdef __USE_EXTERN_INLINES
36
+ #define LIBC_OLD_USE_EXTERN_INLINES
37
+ #undef __USE_EXTERN_INLINES
38
+ #endif
39
+
40
+ #ifdef __USE_FORTIFY_LEVEL
41
+ #define LIBC_OLD_USE_FORTIFY_LEVEL __USE_FORTIFY_LEVEL
42
+ #undef __USE_FORTIFY_LEVEL
43
+ #define __USE_FORTIFY_LEVEL 0
44
+ #endif
45
+
46
+ #include <wchar.h>
47
+
48
+ #ifdef LIBC_OLD_FORTIFY_SOURCE
49
+ #define _FORTIFY_SOURCE LIBC_OLD_FORTIFY_SOURCE
50
+ #undef LIBC_OLD_FORTIFY_SOURCE
51
+ #endif
52
+
53
+ #ifdef LIBC_SET_NO_INLINE
54
+ #undef __NO_INLINE__
55
+ #undef LIBC_SET_NO_INLINE
56
+ #endif
57
+
58
+ #ifdef LIBC_OLD_USE_FORTIFY_LEVEL
59
+ #undef __USE_FORTIFY_LEVEL
60
+ #define __USE_FORTIFY_LEVEL LIBC_OLD_USE_FORTIFY_LEVEL
61
+ #undef LIBC_OLD_USE_FORTIFY_LEVEL
62
+ #endif
63
+
64
+ #ifdef LIBC_OLD_USE_EXTERN_INLINES
65
+ #define __USE_EXTERN_INLINES
66
+ #undef LIBC_OLD_USE_EXTERN_INLINES
67
+ #endif
68
+
69
+ #endif // LLVM_LIBC_HDR_WCHAR_OVERLAY_H
@@ -0,0 +1,41 @@
1
+ //===-- Detection of _Complex _Float128 compiler builtin type -------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_MACROS_CFLOAT128_MACROS_H
10
+ #define LLVM_LIBC_MACROS_CFLOAT128_MACROS_H
11
+
12
+ #include "float-macros.h" // LDBL_MANT_DIG
13
+
14
+ // Currently, the complex variant of C23 `_Float128` type is only defined as a
15
+ // built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For
16
+ // clang, the complex variant of `__float128` is defined instead, and only on
17
+ // x86-64 targets for clang 11 or later.
18
+ //
19
+ // TODO: Update the complex variant of C23 `_Float128` type detection again when
20
+ // clang supports it.
21
+ #ifdef __clang__
22
+ #if (__clang_major__ >= 11) && \
23
+ (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
24
+ // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
25
+ // macro to notify the availability of __float128 type:
26
+ // https://reviews.llvm.org/D15120
27
+ #define LIBC_TYPES_HAS_CFLOAT128
28
+ #endif
29
+ #elif defined(__GNUC__)
30
+ #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
31
+ (__GNUC__ >= 13 || (!defined(__cplusplus)))
32
+ #define LIBC_TYPES_HAS_CFLOAT128
33
+ #endif
34
+ #endif
35
+
36
+ #if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113)
37
+ #define LIBC_TYPES_HAS_CFLOAT128
38
+ #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
39
+ #endif
40
+
41
+ #endif // LLVM_LIBC_MACROS_CFLOAT128_MACROS_H
@@ -0,0 +1,20 @@
1
+ //===-- Detection of _Complex _Float16 compiler builtin type --------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_MACROS_CFLOAT16_MACROS_H
10
+ #define LLVM_LIBC_MACROS_CFLOAT16_MACROS_H
11
+
12
+ #if defined(__FLT16_MANT_DIG__) && \
13
+ (!defined(__GNUC__) || __GNUC__ >= 13 || \
14
+ (defined(__clang__) && __clang_major__ >= 14)) && \
15
+ !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \
16
+ !defined(_WIN32)
17
+ #define LIBC_TYPES_HAS_CFLOAT16
18
+ #endif
19
+
20
+ #endif // LLVM_LIBC_MACROS_CFLOAT16_MACROS_H
@@ -0,0 +1,18 @@
1
+ //===-- Macros defined in wchar.h header file -----------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_MACROS_WCHAR_MACROS_H
10
+ #define LLVM_LIBC_MACROS_WCHAR_MACROS_H
11
+
12
+ #include "../llvm-libc-types/wint_t.h"
13
+
14
+ #ifndef WEOF
15
+ #define WEOF ((wint_t)(0xffffffffu))
16
+ #endif
17
+
18
+ #endif // LLVM_LIBC_MACROS_WCHAR_MACROS_H
@@ -9,36 +9,19 @@
9
9
  #ifndef LLVM_LIBC_TYPES_CFLOAT128_H
10
10
  #define LLVM_LIBC_TYPES_CFLOAT128_H
11
11
 
12
- #include "../llvm-libc-macros/float-macros.h" // LDBL_MANT_DIG
12
+ #include "../llvm-libc-macros/cfloat128-macros.h"
13
13
 
14
- // Currently, the complex variant of C23 `_Float128` type is only defined as a
15
- // built-in type in GCC 7 or later, for C and in GCC 13 or later, for C++. For
16
- // clang, the complex variant of `__float128` is defined instead, and only on
17
- // x86-64 targets for clang 11 or later.
18
- //
19
- // TODO: Update the complex variant of C23 `_Float128` type detection again when
20
- // clang supports it.
21
- #ifdef __clang__
22
- #if (__clang_major__ >= 11) && \
23
- (defined(__FLOAT128__) || defined(__SIZEOF_FLOAT128__))
24
- // Use _Complex __float128 type. clang uses __SIZEOF_FLOAT128__ or __FLOAT128__
25
- // macro to notify the availability of __float128 type:
26
- // https://reviews.llvm.org/D15120
27
- #define LIBC_TYPES_HAS_CFLOAT128
14
+ #ifdef LIBC_TYPES_HAS_CFLOAT128
15
+ #ifndef LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
16
+ #if defined(__GNUC__) && !defined(__clang__)
17
+ // Remove the workaround when https://gcc.gnu.org/PR32187 gets fixed.
18
+ typedef __typeof__(_Complex __float128) cfloat128;
19
+ #else // ^^^ workaround / no workaround vvv
28
20
  typedef _Complex __float128 cfloat128;
29
- #endif
30
- #elif defined(__GNUC__)
31
- #if (defined(__STDC_IEC_60559_COMPLEX__) || defined(__SIZEOF_FLOAT128__)) && \
32
- (__GNUC__ >= 13 || (!defined(__cplusplus)))
33
- #define LIBC_TYPES_HAS_CFLOAT128
34
- typedef _Complex _Float128 cfloat128;
35
- #endif
36
- #endif
37
-
38
- #if !defined(LIBC_TYPES_HAS_CFLOAT128) && (LDBL_MANT_DIG == 113)
39
- #define LIBC_TYPES_HAS_CFLOAT128
40
- #define LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
21
+ #endif // ^^^ no workaround ^^^
22
+ #else
41
23
  typedef _Complex long double cfloat128;
42
- #endif
24
+ #endif // LIBC_TYPES_CFLOAT128_IS_COMPLEX_LONG_DOUBLE
25
+ #endif // LIBC_TYPES_HAS_CFLOAT128
43
26
 
44
27
  #endif // LLVM_LIBC_TYPES_CFLOAT128_H
@@ -9,13 +9,10 @@
9
9
  #ifndef LLVM_LIBC_TYPES_CFLOAT16_H
10
10
  #define LLVM_LIBC_TYPES_CFLOAT16_H
11
11
 
12
- #if defined(__FLT16_MANT_DIG__) && \
13
- (!defined(__GNUC__) || __GNUC__ >= 13 || \
14
- (defined(__clang__) && __clang_major__ >= 14)) && \
15
- !defined(__arm__) && !defined(_M_ARM) && !defined(__riscv) && \
16
- !defined(_WIN32)
17
- #define LIBC_TYPES_HAS_CFLOAT16
12
+ #include "../llvm-libc-macros/cfloat16-macros.h"
13
+
14
+ #ifdef LIBC_TYPES_HAS_CFLOAT16
18
15
  typedef _Complex _Float16 cfloat16;
19
- #endif
16
+ #endif // LIBC_TYPES_HAS_CFLOAT16
20
17
 
21
18
  #endif // LLVM_LIBC_TYPES_CFLOAT16_H
@@ -0,0 +1,14 @@
1
+ //===-- Definition of wint_t types ----------------------------------------===//
2
+ //
3
+ // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4
+ // See https://llvm.org/LICENSE.txt for license information.
5
+ // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
+ //
7
+ //===----------------------------------------------------------------------===//
8
+
9
+ #ifndef LLVM_LIBC_TYPES_WINT_T_H
10
+ #define LLVM_LIBC_TYPES_WINT_T_H
11
+
12
+ typedef __WINT_TYPE__ wint_t;
13
+
14
+ #endif // LLVM_LIBC_TYPES_WINT_T_H
@@ -19,6 +19,11 @@
19
19
  #define LIBC_ERRNO_MODE LIBC_ERRNO_MODE_SYSTEM_INLINE
20
20
  #endif // LIBC_ERRNO_MODE
21
21
 
22
+ // Use system fenv functions in math implementations.
23
+ #ifndef LIBC_MATH_USE_SYSTEM_FENV
24
+ #define LIBC_MATH_USE_SYSTEM_FENV
25
+ #endif // LIBC_MATH_USE_SYSTEM_FENV
26
+
22
27
  #ifndef LIBC_NAMESPACE
23
28
  #define LIBC_NAMESPACE __llvm_libc
24
29
  #endif // LIBC_NAMESPACE
@@ -11,14 +11,14 @@
11
11
  #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
12
12
  #define LLVM_LIBC_SRC___SUPPORT_CPP_BIT_H
13
13
 
14
+ #include "hdr/stdint_proxy.h"
14
15
  #include "src/__support/CPP/limits.h" // numeric_limits
15
16
  #include "src/__support/CPP/type_traits.h"
16
17
  #include "src/__support/macros/attributes.h"
17
18
  #include "src/__support/macros/config.h"
19
+ #include "src/__support/macros/properties/compiler.h"
18
20
  #include "src/__support/macros/sanitizer.h"
19
21
 
20
- #include <stdint.h>
21
-
22
22
  namespace LIBC_NAMESPACE_DECL {
23
23
  namespace cpp {
24
24
 
@@ -26,6 +26,16 @@ namespace cpp {
26
26
  #define LLVM_LIBC_HAS_BUILTIN_MEMCPY_INLINE
27
27
  #endif
28
28
 
29
+ template <unsigned N>
30
+ LIBC_INLINE static void inline_copy(const char *from, char *to) {
31
+ #if __has_builtin(__builtin_memcpy_inline)
32
+ __builtin_memcpy_inline(to, from, N);
33
+ #else
34
+ for (unsigned i = 0; i < N; ++i)
35
+ to[i] = from[i];
36
+ #endif // __has_builtin(__builtin_memcpy_inline)
37
+ }
38
+
29
39
  // This implementation of bit_cast requires trivially-constructible To, to avoid
30
40
  // UB in the implementation.
31
41
  template <typename To, typename From>
@@ -37,22 +47,32 @@ LIBC_INLINE constexpr cpp::enable_if_t<
37
47
  To>
38
48
  bit_cast(const From &from) {
39
49
  MSAN_UNPOISON(&from, sizeof(From));
40
- #if __has_builtin(__builtin_bit_cast)
50
+ #if __has_builtin(__builtin_bit_cast) || defined(LIBC_COMPILER_IS_MSVC)
41
51
  return __builtin_bit_cast(To, from);
42
52
  #else
43
- To to;
53
+ To to{};
44
54
  char *dst = reinterpret_cast<char *>(&to);
45
55
  const char *src = reinterpret_cast<const char *>(&from);
46
- #if __has_builtin(__builtin_memcpy_inline)
47
- __builtin_memcpy_inline(dst, src, sizeof(To));
48
- #else
49
- for (unsigned i = 0; i < sizeof(To); ++i)
50
- dst[i] = src[i];
51
- #endif // __has_builtin(__builtin_memcpy_inline)
56
+ inline_copy<sizeof(From)>(src, dst);
52
57
  return to;
53
58
  #endif // __has_builtin(__builtin_bit_cast)
54
59
  }
55
60
 
61
+ // The following simple bit copy from a smaller type to maybe-larger type.
62
+ template <typename To, typename From>
63
+ LIBC_INLINE constexpr cpp::enable_if_t<
64
+ (sizeof(To) >= sizeof(From)) &&
65
+ cpp::is_trivially_constructible<To>::value &&
66
+ cpp::is_trivially_copyable<To>::value &&
67
+ cpp::is_trivially_copyable<From>::value,
68
+ void>
69
+ bit_copy(const From &from, To &to) {
70
+ MSAN_UNPOISON(&from, sizeof(From));
71
+ char *dst = reinterpret_cast<char *>(&to);
72
+ const char *src = reinterpret_cast<const char *>(&from);
73
+ inline_copy<sizeof(From)>(src, dst);
74
+ }
75
+
56
76
  template <typename T>
57
77
  [[nodiscard]] LIBC_INLINE constexpr cpp::enable_if_t<cpp::is_unsigned_v<T>,
58
78
  bool>
@@ -105,10 +125,16 @@ countr_zero(T value) {
105
125
  }
106
126
  #if __has_builtin(__builtin_ctzs)
107
127
  ADD_SPECIALIZATION(countr_zero, unsigned short, __builtin_ctzs)
108
- #endif
128
+ #endif // __has_builtin(__builtin_ctzs)
129
+ #if __has_builtin(__builtin_ctz)
109
130
  ADD_SPECIALIZATION(countr_zero, unsigned int, __builtin_ctz)
131
+ #endif // __has_builtin(__builtin_ctz)
132
+ #if __has_builtin(__builtin_ctzl)
110
133
  ADD_SPECIALIZATION(countr_zero, unsigned long, __builtin_ctzl)
134
+ #endif // __has_builtin(__builtin_ctzl)
135
+ #if __has_builtin(__builtin_ctzll)
111
136
  ADD_SPECIALIZATION(countr_zero, unsigned long long, __builtin_ctzll)
137
+ #endif // __has_builtin(__builtin_ctzll)
112
138
  #endif // __has_builtin(__builtin_ctzg)
113
139
 
114
140
  /// Count number of 0's from the most significant bit to the least
@@ -144,10 +170,16 @@ countl_zero(T value) {
144
170
  }
145
171
  #if __has_builtin(__builtin_clzs)
146
172
  ADD_SPECIALIZATION(countl_zero, unsigned short, __builtin_clzs)
147
- #endif
173
+ #endif // __has_builtin(__builtin_clzs)
174
+ #if __has_builtin(__builtin_clz)
148
175
  ADD_SPECIALIZATION(countl_zero, unsigned int, __builtin_clz)
176
+ #endif // __has_builtin(__builtin_clz)
177
+ #if __has_builtin(__builtin_clzl)
149
178
  ADD_SPECIALIZATION(countl_zero, unsigned long, __builtin_clzl)
179
+ #endif // __has_builtin(__builtin_clzl)
180
+ #if __has_builtin(__builtin_clzll)
150
181
  ADD_SPECIALIZATION(countl_zero, unsigned long long, __builtin_clzll)
182
+ #endif // __has_builtin(__builtin_clzll)
151
183
  #endif // __has_builtin(__builtin_clzg)
152
184
 
153
185
  #undef ADD_SPECIALIZATION
@@ -284,11 +316,17 @@ popcount(T value) {
284
316
  [[nodiscard]] LIBC_INLINE constexpr int popcount<TYPE>(TYPE value) { \
285
317
  return BUILTIN(value); \
286
318
  }
319
+ #if __has_builtin(__builtin_popcount)
287
320
  ADD_SPECIALIZATION(unsigned char, __builtin_popcount)
288
321
  ADD_SPECIALIZATION(unsigned short, __builtin_popcount)
289
322
  ADD_SPECIALIZATION(unsigned, __builtin_popcount)
323
+ #endif // __builtin_popcount
324
+ #if __has_builtin(__builtin_popcountl)
290
325
  ADD_SPECIALIZATION(unsigned long, __builtin_popcountl)
326
+ #endif // __builtin_popcountl
327
+ #if __has_builtin(__builtin_popcountll)
291
328
  ADD_SPECIALIZATION(unsigned long long, __builtin_popcountll)
329
+ #endif // __builtin_popcountll
292
330
  #endif // __builtin_popcountg
293
331
  #undef ADD_SPECIALIZATION
294
332
 
@@ -13,12 +13,17 @@
13
13
  #include "src/__support/macros/attributes.h"
14
14
  #include "src/__support/macros/config.h"
15
15
  // LIBC_TYPES_HAS_CFLOAT16 && LIBC_TYPES_HAS_CFLOAT128
16
+ #include "src/__support/macros/properties/compiler.h"
16
17
  #include "src/__support/macros/properties/complex_types.h"
17
18
 
18
19
  namespace LIBC_NAMESPACE_DECL {
19
20
  namespace cpp {
20
21
 
21
22
  // is_complex
23
+ #ifdef LIBC_COMPILER_IS_MSVC
24
+ // TODO: Add support for complex types with MSVC.
25
+ template <typename T> struct is_complex : false_type {};
26
+ #else
22
27
  template <typename T> struct is_complex {
23
28
  private:
24
29
  template <typename Head, typename... Args>
@@ -40,6 +45,8 @@ public:
40
45
  #endif
41
46
  >();
42
47
  };
48
+ #endif // LIBC_COMPILER_IS_MSVC
49
+
43
50
  template <typename T>
44
51
  LIBC_INLINE_VAR constexpr bool is_complex_v = is_complex<T>::value;
45
52
  template <typename T1, typename T2>
@@ -15,6 +15,7 @@
15
15
  #include "src/__support/CPP/type_traits/remove_all_extents.h"
16
16
  #include "src/__support/CPP/type_traits/true_type.h"
17
17
  #include "src/__support/CPP/type_traits/type_identity.h"
18
+ #include "src/__support/CPP/utility/declval.h"
18
19
  #include "src/__support/macros/attributes.h"
19
20
  #include "src/__support/macros/config.h"
20
21
 
@@ -22,7 +23,7 @@ namespace LIBC_NAMESPACE_DECL {
22
23
  namespace cpp {
23
24
 
24
25
  // is_destructible
25
- #if __has_builtin(__is_destructible)
26
+ #if __has_builtin(__is_destructible) || defined(LIBC_COMPILER_IS_MSVC)
26
27
  template <typename T>
27
28
  struct is_destructible : bool_constant<__is_destructible(T)> {};
28
29
  #else
@@ -16,6 +16,8 @@
16
16
  #include "src/__support/macros/attributes.h"
17
17
  #include "src/__support/macros/config.h"
18
18
 
19
+ #include <stddef.h>
20
+
19
21
  namespace LIBC_NAMESPACE_DECL {
20
22
  namespace cpp {
21
23
 
@@ -46,6 +48,10 @@ public:
46
48
  LIBC_INLINE constexpr bool operator()() const { return is_unsigned::value; }
47
49
  };
48
50
  #endif // LIBC_COMPILER_HAS_FIXED_POINT
51
+ #if LIBC_HAS_VECTOR_TYPE
52
+ template <typename T, size_t N>
53
+ struct is_unsigned<T [[clang::ext_vector_type(N)]]> : bool_constant<false> {};
54
+ #endif
49
55
 
50
56
  template <typename T>
51
57
  LIBC_INLINE_VAR constexpr bool is_unsigned_v = is_unsigned<T>::value;
@@ -5,12 +5,15 @@
5
5
  // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6
6
  //
7
7
  //===----------------------------------------------------------------------===//
8
+
8
9
  #ifndef LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
9
10
  #define LLVM_LIBC_SRC___SUPPORT_CPP_UTILITY_INTEGER_SEQUENCE_H
10
11
 
11
12
  #include "src/__support/CPP/type_traits/is_integral.h"
12
13
  #include "src/__support/macros/config.h"
13
14
 
15
+ #include <stddef.h>
16
+
14
17
  namespace LIBC_NAMESPACE_DECL {
15
18
  namespace cpp {
16
19
 
@@ -34,6 +37,13 @@ template <typename T, int N>
34
37
  using make_integer_sequence =
35
38
  typename detail::make_integer_sequence<T, N - 1>::type;
36
39
 
40
+ // index sequence
41
+ template <size_t... Ints>
42
+ using index_sequence = integer_sequence<size_t, Ints...>;
43
+ template <int N>
44
+ using make_index_sequence =
45
+ typename detail::make_integer_sequence<size_t, N - 1>::type;
46
+
37
47
  } // namespace cpp
38
48
  } // namespace LIBC_NAMESPACE_DECL
39
49
 
@@ -15,6 +15,7 @@
15
15
  #ifndef LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
16
16
  #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_FPBITS_H
17
17
 
18
+ #include "hdr/stdint_proxy.h"
18
19
  #include "src/__support/CPP/bit.h"
19
20
  #include "src/__support/CPP/type_traits.h"
20
21
  #include "src/__support/common.h"
@@ -26,8 +27,6 @@
26
27
  #include "src/__support/sign.h" // Sign
27
28
  #include "src/__support/uint128.h"
28
29
 
29
- #include <stdint.h>
30
-
31
30
  namespace LIBC_NAMESPACE_DECL {
32
31
  namespace fputil {
33
32
 
@@ -790,16 +789,16 @@ struct FPRep : public FPRepImpl<fp_type, FPRep<fp_type>> {
790
789
  // Returns the FPType corresponding to C++ type T on the host.
791
790
  template <typename T> LIBC_INLINE static constexpr FPType get_fp_type() {
792
791
  using UnqualT = cpp::remove_cv_t<T>;
793
- if constexpr (cpp::is_same_v<UnqualT, float> && __FLT_MANT_DIG__ == 24)
792
+ if constexpr (cpp::is_same_v<UnqualT, float> && FLT_MANT_DIG == 24)
794
793
  return FPType::IEEE754_Binary32;
795
- else if constexpr (cpp::is_same_v<UnqualT, double> && __DBL_MANT_DIG__ == 53)
794
+ else if constexpr (cpp::is_same_v<UnqualT, double> && DBL_MANT_DIG == 53)
796
795
  return FPType::IEEE754_Binary64;
797
796
  else if constexpr (cpp::is_same_v<UnqualT, long double>) {
798
- if constexpr (__LDBL_MANT_DIG__ == 53)
797
+ if constexpr (LDBL_MANT_DIG == 53)
799
798
  return FPType::IEEE754_Binary64;
800
- else if constexpr (__LDBL_MANT_DIG__ == 64)
799
+ else if constexpr (LDBL_MANT_DIG == 64)
801
800
  return FPType::X86_Binary80;
802
- else if constexpr (__LDBL_MANT_DIG__ == 113)
801
+ else if constexpr (LDBL_MANT_DIG == 113)
803
802
  return FPType::IEEE754_Binary128;
804
803
  }
805
804
  #if defined(LIBC_TYPES_HAS_FLOAT16)
@@ -10,18 +10,21 @@
10
10
  #define LLVM_LIBC_SRC___SUPPORT_FPUTIL_ROUNDING_MODE_H
11
11
 
12
12
  #include "hdr/fenv_macros.h"
13
+ #include "src/__support/CPP/type_traits.h" // is_constant_evaluated
13
14
  #include "src/__support/macros/attributes.h" // LIBC_INLINE
14
15
  #include "src/__support/macros/config.h"
15
16
 
16
17
  namespace LIBC_NAMESPACE_DECL {
17
18
  namespace fputil {
18
19
 
20
+ namespace generic {
21
+
19
22
  // Quick free-standing test whether fegetround() == FE_UPWARD.
20
23
  // Using the following observation:
21
24
  // 1.0f + 2^-25 = 1.0f for FE_TONEAREST, FE_DOWNWARD, FE_TOWARDZERO
22
25
  // = 0x1.000002f for FE_UPWARD.
23
26
  LIBC_INLINE bool fenv_is_round_up() {
24
- volatile float x = 0x1.0p-25f;
27
+ static volatile float x = 0x1.0p-25f;
25
28
  return (1.0f + x != 1.0f);
26
29
  }
27
30
 
@@ -30,7 +33,7 @@ LIBC_INLINE bool fenv_is_round_up() {
30
33
  // -1.0f - 2^-25 = -1.0f for FE_TONEAREST, FE_UPWARD, FE_TOWARDZERO
31
34
  // = -0x1.000002f for FE_DOWNWARD.
32
35
  LIBC_INLINE bool fenv_is_round_down() {
33
- volatile float x = 0x1.0p-25f;
36
+ static volatile float x = 0x1.0p-25f;
34
37
  return (-1.0f - x != -1.0f);
35
38
  }
36
39
 
@@ -42,8 +45,8 @@ LIBC_INLINE bool fenv_is_round_down() {
42
45
  // = 0x1.0ffffep-1f for FE_DOWNWARD, FE_TOWARDZERO
43
46
  LIBC_INLINE bool fenv_is_round_to_nearest() {
44
47
  static volatile float x = 0x1.0p-24f;
45
- float y = x;
46
- return (1.5f + y == 1.5f - y);
48
+ float y = 1.5f + x;
49
+ return (y == 1.5f - x);
47
50
  }
48
51
 
49
52
  // Quick free-standing test whether fegetround() == FE_TOWARDZERO.
@@ -75,6 +78,49 @@ LIBC_INLINE int quick_get_round() {
75
78
  return (2.0f + y == 2.0f) ? FE_TONEAREST : FE_UPWARD;
76
79
  }
77
80
 
81
+ } // namespace generic
82
+
83
+ LIBC_INLINE static constexpr bool fenv_is_round_up() {
84
+ if (cpp::is_constant_evaluated()) {
85
+ return false;
86
+ } else {
87
+ return generic::fenv_is_round_up();
88
+ }
89
+ }
90
+
91
+ LIBC_INLINE static constexpr bool fenv_is_round_down() {
92
+ if (cpp::is_constant_evaluated()) {
93
+ return false;
94
+ } else {
95
+ return generic::fenv_is_round_down();
96
+ }
97
+ }
98
+
99
+ LIBC_INLINE static constexpr bool fenv_is_round_to_nearest() {
100
+ if (cpp::is_constant_evaluated()) {
101
+ return true;
102
+ } else {
103
+ return generic::fenv_is_round_to_nearest();
104
+ }
105
+ }
106
+
107
+ LIBC_INLINE static constexpr bool fenv_is_round_to_zero() {
108
+ if (cpp::is_constant_evaluated()) {
109
+ return false;
110
+ } else {
111
+ return generic::fenv_is_round_to_zero();
112
+ }
113
+ }
114
+
115
+ // Quick free standing get rounding mode based on the above observations.
116
+ LIBC_INLINE static constexpr int quick_get_round() {
117
+ if (cpp::is_constant_evaluated()) {
118
+ return FE_TONEAREST;
119
+ } else {
120
+ return generic::quick_get_round();
121
+ }
122
+ }
123
+
78
124
  } // namespace fputil
79
125
  } // namespace LIBC_NAMESPACE_DECL
80
126