@zigc/lib 0.17.0-dev.215 → 0.17.0-dev.228
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.
- package/c/math.zig +31 -2
- package/compiler/resinator/compile.zig +1 -1
- package/compiler_rt/cos.zig +1 -1
- package/compiler_rt/rem_pio2l.zig +1 -1
- package/compiler_rt/sin.zig +1 -1
- package/compiler_rt/sincos.zig +1 -1
- package/compiler_rt/tan.zig +1 -1
- package/libcxx/libc/hdr/errno_macros.h +3 -1
- package/libcxx/libc/hdr/stdint_proxy.h +18 -0
- package/libcxx/libc/hdr/types/wchar_t.h +23 -0
- package/libcxx/libc/hdr/wchar_overlay.h +69 -0
- package/libcxx/libc/include/llvm-libc-macros/cfloat128-macros.h +41 -0
- package/libcxx/libc/include/llvm-libc-macros/cfloat16-macros.h +20 -0
- package/libcxx/libc/include/llvm-libc-macros/wchar-macros.h +18 -0
- package/libcxx/libc/include/llvm-libc-types/cfloat128.h +11 -28
- package/libcxx/libc/include/llvm-libc-types/cfloat16.h +4 -7
- package/libcxx/libc/include/llvm-libc-types/wint_t.h +14 -0
- package/libcxx/libc/shared/libc_common.h +5 -0
- package/libcxx/libc/src/__support/CPP/bit.h +50 -12
- package/libcxx/libc/src/__support/CPP/type_traits/is_complex.h +7 -0
- package/libcxx/libc/src/__support/CPP/type_traits/is_destructible.h +2 -1
- package/libcxx/libc/src/__support/CPP/type_traits/is_unsigned.h +6 -0
- package/libcxx/libc/src/__support/CPP/utility/integer_sequence.h +10 -0
- package/libcxx/libc/src/__support/FPUtil/FPBits.h +6 -7
- package/libcxx/libc/src/__support/FPUtil/rounding_mode.h +50 -4
- package/libcxx/libc/src/__support/big_int.h +14 -14
- package/libcxx/libc/src/__support/common.h +3 -2
- package/libcxx/libc/src/__support/ctype_utils.h +19 -12
- package/libcxx/libc/src/__support/detailed_powers_of_ten.h +1 -2
- package/libcxx/libc/src/__support/high_precision_decimal.h +33 -14
- package/libcxx/libc/src/__support/libc_assert.h +2 -0
- package/libcxx/libc/src/__support/macros/attributes.h +44 -1
- package/libcxx/libc/src/__support/macros/config.h +23 -0
- package/libcxx/libc/src/__support/macros/null_check.h +1 -2
- package/libcxx/libc/src/__support/macros/optimization.h +3 -0
- package/libcxx/libc/src/__support/macros/properties/architectures.h +5 -1
- package/libcxx/libc/src/__support/macros/properties/compiler.h +8 -3
- package/libcxx/libc/src/__support/macros/properties/cpu_features.h +17 -1
- package/libcxx/libc/src/__support/macros/properties/types.h +2 -3
- package/libcxx/libc/src/__support/macros/sanitizer.h +0 -10
- package/libcxx/libc/src/__support/math_extras.h +20 -4
- package/libcxx/libc/src/__support/str_to_float.h +98 -125
- package/libcxx/libc/src/__support/str_to_integer.h +39 -27
- package/libcxx/libc/src/__support/wctype_utils.h +588 -0
- package/libunwind/src/AddressSpace.hpp +2 -1
- package/libunwind/src/DwarfParser.hpp +2 -1
- package/package.json +1 -1
- package/std/Build/Step/ConfigHeader.zig +1 -1
- package/std/Io/Kqueue.zig +1 -1
- package/std/Target.zig +5 -6
- package/std/bit_set.zig +76 -59
- package/std/c.zig +2 -2
- package/std/crypto/codecs/base64_hex_ct.zig +1 -1
- package/std/crypto/ml_kem.zig +0 -15
- package/std/enums.zig +2 -2
- package/std/fs/path.zig +1 -1
- package/std/math/float.zig +62 -0
- package/std/math/modf.zig +1 -1
- package/std/math.zig +1 -0
- package/std/std.zig +3 -0
- package/std/testing.zig +1 -1
- package/std/zig/target.zig +1 -2
- package/std/zon/parse.zig +1 -1
- package/compiler_rt/long_double.zig +0 -37
- package/libc/mingw/math/lrintl.c +0 -18
- package/libc/mingw/math/rintl.c +0 -16
- package/libc/musl/src/math/i386/lrintl.c +0 -8
- package/libc/musl/src/math/i386/rintl.c +0 -7
- package/libc/musl/src/math/lrintl.c +0 -36
- package/libc/musl/src/math/rintl.c +0 -29
- package/libc/musl/src/math/s390x/rintl.c +0 -15
- package/libc/musl/src/math/x32/lrintl.s +0 -7
- package/libc/musl/src/math/x32/rintl.s +0 -6
- package/libc/musl/src/math/x86_64/lrintl.c +0 -8
- package/libc/musl/src/math/x86_64/rintl.c +0 -7
package/c/math.zig
CHANGED
|
@@ -2,6 +2,7 @@ const builtin = @import("builtin");
|
|
|
2
2
|
|
|
3
3
|
const std = @import("std");
|
|
4
4
|
const math = std.math;
|
|
5
|
+
const ld = math.long_double;
|
|
5
6
|
|
|
6
7
|
const symbol = @import("../c.zig").symbol;
|
|
7
8
|
|
|
@@ -35,7 +36,9 @@ comptime {
|
|
|
35
36
|
symbol(&frexpl, "frexpl");
|
|
36
37
|
symbol(&hypotf, "hypotf");
|
|
37
38
|
symbol(&hypotl, "hypotl");
|
|
39
|
+
symbol(&lrintl, "lrintl");
|
|
38
40
|
symbol(&modfl, "modfl");
|
|
41
|
+
symbol(&rintl, "rintl");
|
|
39
42
|
}
|
|
40
43
|
|
|
41
44
|
if ((builtin.target.isMinGW() and @sizeOf(f64) != @sizeOf(c_longdouble)) or builtin.target.isMuslLibC() or builtin.target.isWasiLibC()) {
|
|
@@ -254,11 +257,15 @@ fn isnanl(x: c_longdouble) callconv(.c) c_int {
|
|
|
254
257
|
}
|
|
255
258
|
|
|
256
259
|
fn lrint(x: f64) callconv(.c) c_long {
|
|
257
|
-
return @
|
|
260
|
+
return @trunc(rint(x));
|
|
258
261
|
}
|
|
259
262
|
|
|
260
263
|
fn lrintf(x: f32) callconv(.c) c_long {
|
|
261
|
-
return @
|
|
264
|
+
return @trunc(rintf(x));
|
|
265
|
+
}
|
|
266
|
+
|
|
267
|
+
fn lrintl(x: c_longdouble) callconv(.c) c_long {
|
|
268
|
+
return @trunc(rintl(x));
|
|
262
269
|
}
|
|
263
270
|
|
|
264
271
|
fn modfGeneric(comptime T: type, x: T, iptr: *T) T {
|
|
@@ -364,6 +371,28 @@ fn rintf(x: f32) callconv(.c) f32 {
|
|
|
364
371
|
return y;
|
|
365
372
|
}
|
|
366
373
|
|
|
374
|
+
fn rintl(x: c_longdouble) callconv(.c) c_longdouble {
|
|
375
|
+
if (@typeInfo(c_longdouble).float.bits == 64)
|
|
376
|
+
return rint(x);
|
|
377
|
+
|
|
378
|
+
const toint: c_longdouble = 1 << math.floatFractionalBits(c_longdouble);
|
|
379
|
+
const se = ld.signExponent(x);
|
|
380
|
+
|
|
381
|
+
if (se & 0x7fff >= 0x3fff + math.floatFractionalBits(c_longdouble))
|
|
382
|
+
return x;
|
|
383
|
+
|
|
384
|
+
var y: c_longdouble = undefined;
|
|
385
|
+
if ((se >> 15) == 1) {
|
|
386
|
+
y = x - toint + toint;
|
|
387
|
+
} else {
|
|
388
|
+
y = x + toint - toint;
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
if (y == 0)
|
|
392
|
+
return 0 * x;
|
|
393
|
+
return y;
|
|
394
|
+
}
|
|
395
|
+
|
|
367
396
|
fn tanh(x: f64) callconv(.c) f64 {
|
|
368
397
|
return math.tanh(x);
|
|
369
398
|
}
|
|
@@ -3084,7 +3084,7 @@ pub const StringTable = struct {
|
|
|
3084
3084
|
|
|
3085
3085
|
pub const Block = struct {
|
|
3086
3086
|
strings: std.ArrayList(Token) = .empty,
|
|
3087
|
-
set_indexes: std.bit_set.
|
|
3087
|
+
set_indexes: std.bit_set.Integer(16) = .{ .mask = 0 },
|
|
3088
3088
|
memory_flags: MemoryFlags = MemoryFlags.defaults(res.RT.STRING),
|
|
3089
3089
|
characteristics: u32,
|
|
3090
3090
|
version: u32,
|
package/compiler_rt/cos.zig
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const std = @import("std");
|
|
9
9
|
const math = std.math;
|
|
10
|
+
const ld = math.long_double;
|
|
10
11
|
const mem = std.mem;
|
|
11
12
|
const expect = std.testing.expect;
|
|
12
13
|
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
@@ -17,7 +18,6 @@ const trig = @import("trig.zig");
|
|
|
17
18
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
18
19
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
19
20
|
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
20
|
-
const ld = @import("long_double.zig");
|
|
21
21
|
|
|
22
22
|
comptime {
|
|
23
23
|
symbol(&cosh, "__cosh");
|
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
|
|
6
6
|
const std = @import("std");
|
|
7
7
|
const math = std.math;
|
|
8
|
+
const ld = math.long_double;
|
|
8
9
|
|
|
9
|
-
const ld = @import("long_double.zig");
|
|
10
10
|
const rem_pio2_large = @import("rem_pio2_large.zig").rem_pio2_large;
|
|
11
11
|
|
|
12
12
|
pub fn rem_pio2l(comptime T: type, x: T, y: *[2]T) i32 {
|
package/compiler_rt/sin.zig
CHANGED
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
|
|
8
8
|
const std = @import("std");
|
|
9
9
|
const math = std.math;
|
|
10
|
+
const ld = math.long_double;
|
|
10
11
|
const mem = std.mem;
|
|
11
12
|
const expect = std.testing.expect;
|
|
12
13
|
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
@@ -17,7 +18,6 @@ const trig = @import("trig.zig");
|
|
|
17
18
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
18
19
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
19
20
|
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
20
|
-
const ld = @import("long_double.zig");
|
|
21
21
|
|
|
22
22
|
comptime {
|
|
23
23
|
symbol(&sinh, "__sinh");
|
package/compiler_rt/sincos.zig
CHANGED
|
@@ -2,6 +2,7 @@ const std = @import("std");
|
|
|
2
2
|
const builtin = @import("builtin");
|
|
3
3
|
const arch = builtin.cpu.arch;
|
|
4
4
|
const math = std.math;
|
|
5
|
+
const ld = math.long_double;
|
|
5
6
|
const mem = std.mem;
|
|
6
7
|
const expect = std.testing.expect;
|
|
7
8
|
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
@@ -9,7 +10,6 @@ const trig = @import("trig.zig");
|
|
|
9
10
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
10
11
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
11
12
|
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
12
|
-
const ld = @import("long_double.zig");
|
|
13
13
|
const compiler_rt = @import("../compiler_rt.zig");
|
|
14
14
|
const symbol = compiler_rt.symbol;
|
|
15
15
|
|
package/compiler_rt/tan.zig
CHANGED
|
@@ -9,6 +9,7 @@
|
|
|
9
9
|
const std = @import("std");
|
|
10
10
|
const builtin = @import("builtin");
|
|
11
11
|
const math = std.math;
|
|
12
|
+
const ld = math.long_double;
|
|
12
13
|
const mem = std.mem;
|
|
13
14
|
const expect = std.testing.expect;
|
|
14
15
|
const expectApproxEqAbs = std.testing.expectApproxEqAbs;
|
|
@@ -17,7 +18,6 @@ const kernel = @import("trig.zig");
|
|
|
17
18
|
const rem_pio2 = @import("rem_pio2.zig").rem_pio2;
|
|
18
19
|
const rem_pio2f = @import("rem_pio2f.zig").rem_pio2f;
|
|
19
20
|
const rem_pio2l = @import("rem_pio2l.zig").rem_pio2l;
|
|
20
|
-
const ld = @import("long_double.zig");
|
|
21
21
|
|
|
22
22
|
const arch = builtin.cpu.arch;
|
|
23
23
|
const compiler_rt = @import("../compiler_rt.zig");
|
|
@@ -15,7 +15,9 @@
|
|
|
15
15
|
#include <linux/errno.h>
|
|
16
16
|
|
|
17
17
|
#include "include/llvm-libc-macros/error-number-macros.h"
|
|
18
|
-
#
|
|
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/
|
|
12
|
+
#include "../llvm-libc-macros/cfloat128-macros.h"
|
|
13
13
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
//
|
|
18
|
-
|
|
19
|
-
//
|
|
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
|
-
#
|
|
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
|
-
#
|
|
13
|
-
|
|
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
|
-
|
|
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;
|