@zigc/lib 0.17.0-dev.9 → 0.17.0-dev.93
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/fcntl.zig +6 -1
- package/c/inttypes.zig +0 -10
- package/c/math.zig +46 -122
- package/c/search.zig +1 -27
- package/c/stdlib/drand48.zig +0 -57
- package/c/stdlib.zig +0 -100
- package/c/string.zig +0 -7
- package/c/strings.zig +0 -38
- package/c/unistd.zig +27 -26
- package/c.zig +1 -2
- package/compiler/aro/aro/CodeGen.zig +3 -2
- package/compiler/aro/aro/Compilation.zig +15 -12
- package/compiler/aro/aro/Driver.zig +9 -6
- package/compiler/aro/aro/Parser.zig +18 -12
- package/compiler/aro/aro/Pragma.zig +3 -2
- package/compiler/aro/aro/Preprocessor.zig +9 -6
- package/compiler/aro/aro/pragmas/message.zig +3 -2
- package/compiler/aro/aro/text_literal.zig +3 -2
- package/compiler/aro/assembly_backend/x86_64.zig +3 -2
- package/compiler/build_runner.zig +0 -2
- package/compiler/test_runner.zig +1 -1
- package/compiler/translate-c/Translator.zig +4 -0
- package/compiler_rt/cos.zig +0 -2
- package/compiler_rt/divmodei4.zig +40 -17
- package/compiler_rt/exp.zig +1 -6
- package/compiler_rt/exp2.zig +1 -6
- package/compiler_rt/exp_f128.zig +377 -0
- package/compiler_rt/fabs.zig +0 -2
- package/compiler_rt/fma.zig +0 -2
- package/compiler_rt/fmax.zig +0 -2
- package/compiler_rt/fmin.zig +0 -2
- package/compiler_rt/fmod.zig +0 -2
- package/compiler_rt/limb64.zig +876 -15
- package/compiler_rt/log.zig +0 -2
- package/compiler_rt/log10.zig +0 -2
- package/compiler_rt/log2.zig +0 -2
- package/compiler_rt/mulXi3.zig +1 -1
- package/compiler_rt/round.zig +0 -2
- package/compiler_rt/sin.zig +0 -2
- package/compiler_rt/sincos.zig +0 -2
- package/compiler_rt/sqrt.zig +0 -2
- package/compiler_rt/ssp.zig +1 -1
- package/compiler_rt/tan.zig +0 -2
- package/compiler_rt/trunc.zig +0 -2
- package/compiler_rt/udivmodei4.zig +28 -0
- package/fuzzer.zig +2 -0
- package/libc/musl/arch/mipsn32/syscall_arch.h +35 -32
- package/package.json +1 -1
- package/std/Build/Step/Compile.zig +0 -1
- package/std/Build.zig +0 -3
- package/std/Io/Dispatch.zig +3 -13
- package/std/Io/Semaphore.zig +112 -17
- package/std/Io/Threaded.zig +167 -33
- package/std/Io/Uring.zig +12 -14
- package/std/Io/Writer.zig +46 -42
- package/std/Io/net.zig +11 -11
- package/std/Io.zig +89 -25
- package/std/Target.zig +50 -5
- package/std/builtin.zig +4 -0
- package/std/c/haiku.zig +3 -0
- package/std/c/serenity.zig +1 -6
- package/std/c.zig +59 -6
- package/std/debug.zig +4 -3
- package/std/fmt.zig +7 -2
- package/std/fs/path.zig +6 -4
- package/std/heap/BufferFirstAllocator.zig +165 -0
- package/std/heap.zig +2 -126
- package/std/http/Client.zig +21 -24
- package/std/os/linux/aarch64.zig +41 -12
- package/std/os/linux/arc.zig +41 -12
- package/std/os/linux/arm.zig +41 -12
- package/std/os/linux/hexagon.zig +33 -11
- package/std/os/linux/loongarch32.zig +41 -13
- package/std/os/linux/loongarch64.zig +41 -12
- package/std/os/linux/m68k.zig +41 -13
- package/std/os/linux/mips.zig +67 -36
- package/std/os/linux/mips64.zig +60 -29
- package/std/os/linux/mipsn32.zig +60 -29
- package/std/os/linux/or1k.zig +41 -12
- package/std/os/linux/powerpc.zig +41 -12
- package/std/os/linux/powerpc64.zig +41 -12
- package/std/os/linux/riscv32.zig +41 -12
- package/std/os/linux/riscv64.zig +41 -12
- package/std/os/linux/s390x.zig +44 -7
- package/std/os/linux/sparc64.zig +83 -52
- package/std/os/linux/thumb.zig +52 -36
- package/std/os/linux/x32.zig +41 -12
- package/std/os/linux/x86.zig +42 -13
- package/std/os/linux/x86_64.zig +41 -12
- package/std/os/linux.zig +398 -434
- package/std/os.zig +41 -0
- package/std/sort.zig +3 -3
- package/std/zig/AstGen.zig +22 -92
- package/std/zig/AstRlAnnotate.zig +0 -11
- package/std/zig/BuiltinFn.zig +0 -32
- package/std/zig/LibCInstallation.zig +1 -0
- package/std/zig/Zir.zig +50 -63
- package/std/zig/ZonGen.zig +5 -4
- package/std/zig/llvm/Builder.zig +12 -12
- package/std/zig.zig +0 -10
- package/zig.h +340 -1
- package/libc/mingw/math/fdiml.c +0 -24
- package/libc/musl/src/linux/tee.c +0 -8
- package/libc/musl/src/math/fdimf.c +0 -10
- package/libc/musl/src/math/fdiml.c +0 -18
- package/libc/musl/src/unistd/dup2.c +0 -20
- package/libc/musl/src/unistd/dup3.c +0 -26
package/std/zig/llvm/Builder.zig
CHANGED
|
@@ -7638,9 +7638,9 @@ pub const Constant = enum(u32) {
|
|
|
7638
7638
|
std.math.big.int.calcToStringLimbsBufferLen(expected_limbs, 10)
|
|
7639
7639
|
]std.math.big.Limb,
|
|
7640
7640
|
};
|
|
7641
|
-
var
|
|
7642
|
-
|
|
7643
|
-
const allocator =
|
|
7641
|
+
var bfa_buf: ExpectedContents = undefined;
|
|
7642
|
+
var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), data.builder.gpa);
|
|
7643
|
+
const allocator = bfa.allocator();
|
|
7644
7644
|
const str = bigint.toStringAlloc(allocator, 10, undefined) catch return error.WriteFailed;
|
|
7645
7645
|
defer allocator.free(str);
|
|
7646
7646
|
try w.writeAll(str);
|
|
@@ -9209,9 +9209,9 @@ pub fn getIntrinsic(
|
|
|
9209
9209
|
fields: [expected_fields_len]Type,
|
|
9210
9210
|
},
|
|
9211
9211
|
};
|
|
9212
|
-
var
|
|
9213
|
-
|
|
9214
|
-
const allocator =
|
|
9212
|
+
var bfa_buf: ExpectedContents = undefined;
|
|
9213
|
+
var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
|
|
9214
|
+
const allocator = bfa.allocator();
|
|
9215
9215
|
|
|
9216
9216
|
const name = name: {
|
|
9217
9217
|
{
|
|
@@ -10607,9 +10607,9 @@ pub fn print(self: *Builder, w: *Writer) (Writer.Error || Allocator.Error)!void
|
|
|
10607
10607
|
std.math.big.int.calcToStringLimbsBufferLen(expected_limbs, 10)
|
|
10608
10608
|
]std.math.big.Limb,
|
|
10609
10609
|
};
|
|
10610
|
-
var
|
|
10611
|
-
|
|
10612
|
-
const allocator =
|
|
10610
|
+
var bfa_buf: ExpectedContents = undefined;
|
|
10611
|
+
var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
|
|
10612
|
+
const allocator = bfa.allocator();
|
|
10613
10613
|
|
|
10614
10614
|
const limbs = self.metadata_limbs.items[extra.limbs_index..][0..extra.limbs_len];
|
|
10615
10615
|
const bigint: std.math.big.int.Const = .{
|
|
@@ -11129,9 +11129,9 @@ fn bigIntConstAssumeCapacity(
|
|
|
11129
11129
|
const bits = type_item.data;
|
|
11130
11130
|
|
|
11131
11131
|
const ExpectedContents = [64 / @sizeOf(std.math.big.Limb)]std.math.big.Limb;
|
|
11132
|
-
var
|
|
11133
|
-
|
|
11134
|
-
const allocator =
|
|
11132
|
+
var bfa_buf: ExpectedContents = undefined;
|
|
11133
|
+
var bfa: std.heap.BufferFirstAllocator = .init(@ptrCast(&bfa_buf), self.gpa);
|
|
11134
|
+
const allocator = bfa.allocator();
|
|
11135
11135
|
|
|
11136
11136
|
var limbs: []std.math.big.Limb = &.{};
|
|
11137
11137
|
defer allocator.free(limbs);
|
package/std/zig.zig
CHANGED
|
@@ -796,11 +796,6 @@ pub const SimpleComptimeReason = enum(u32) {
|
|
|
796
796
|
operand_branchHint,
|
|
797
797
|
operand_setRuntimeSafety,
|
|
798
798
|
operand_embedFile,
|
|
799
|
-
operand_cImport,
|
|
800
|
-
operand_cDefine_macro_name,
|
|
801
|
-
operand_cDefine_macro_value,
|
|
802
|
-
operand_cInclude_file_name,
|
|
803
|
-
operand_cUndef_macro_name,
|
|
804
799
|
operand_shuffle_mask,
|
|
805
800
|
operand_atomicRmw_operation,
|
|
806
801
|
operand_reduce_operation,
|
|
@@ -891,11 +886,6 @@ pub const SimpleComptimeReason = enum(u32) {
|
|
|
891
886
|
.operand_branchHint => "operand to '@branchHint' must be comptime-known",
|
|
892
887
|
.operand_setRuntimeSafety => "operand to '@setRuntimeSafety' must be comptime-known",
|
|
893
888
|
.operand_embedFile => "operand to '@embedFile' must be comptime-known",
|
|
894
|
-
.operand_cImport => "operand to '@cImport' is evaluated at comptime",
|
|
895
|
-
.operand_cDefine_macro_name => "'@cDefine' macro name must be comptime-known",
|
|
896
|
-
.operand_cDefine_macro_value => "'@cDefine' macro value must be comptime-known",
|
|
897
|
-
.operand_cInclude_file_name => "'@cInclude' file name must be comptime-known",
|
|
898
|
-
.operand_cUndef_macro_name => "'@cUndef' macro name must be comptime-known",
|
|
899
889
|
.operand_shuffle_mask => "'@shuffle' mask must be comptime-known",
|
|
900
890
|
.operand_atomicRmw_operation => "'@atomicRmw' operation must be comptime-known",
|
|
901
891
|
.operand_reduce_operation => "'@reduce' operation must be comptime-known",
|
package/zig.h
CHANGED
|
@@ -79,6 +79,9 @@
|
|
|
79
79
|
#elif defined(__I86__)
|
|
80
80
|
#define zig_x86_16
|
|
81
81
|
#define zig_x86
|
|
82
|
+
#elif defined (__ez80)
|
|
83
|
+
#define zig_ez80
|
|
84
|
+
#define zig_z80
|
|
82
85
|
#endif
|
|
83
86
|
|
|
84
87
|
#if defined(zig_msvc) || __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
|
|
@@ -409,6 +412,8 @@
|
|
|
409
412
|
#define zig_trap() __asm__ volatile("int $0x3")
|
|
410
413
|
#elif defined(zig_x86)
|
|
411
414
|
#define zig_trap() __asm__ volatile("ud2")
|
|
415
|
+
#elif defined(zig_z80)
|
|
416
|
+
#define zig_trap() __asm__ volatile("rst 00h")
|
|
412
417
|
#else
|
|
413
418
|
#define zig_trap() zig_trap_unavailable
|
|
414
419
|
#endif
|
|
@@ -511,7 +516,7 @@ zig_extern void *memcpy (void *zig_restrict, void const *zig_restrict, size_t);
|
|
|
511
516
|
zig_extern void *memset (void *, int, size_t);
|
|
512
517
|
zig_extern void *memmove (void *, void const *, size_t);
|
|
513
518
|
|
|
514
|
-
/* ================ Bool and 8/16/32/64-bit Integer Support ================= */
|
|
519
|
+
/* ================ Bool and 8/16/24/32/48/64-bit Integer Support ================= */
|
|
515
520
|
|
|
516
521
|
#include <limits.h>
|
|
517
522
|
|
|
@@ -590,6 +595,16 @@ typedef signed long long int16_t;
|
|
|
590
595
|
#define INT16_MAX ( INT16_C(0x7FFF))
|
|
591
596
|
#define UINT16_MAX ( INT16_C(0xFFFF))
|
|
592
597
|
|
|
598
|
+
#if defined(zig_ez80)
|
|
599
|
+
typedef unsigned int uint24_t;
|
|
600
|
+
typedef signed int int24_t;
|
|
601
|
+
#define INT24_C(c) c
|
|
602
|
+
#define UINT24_C(c) c##U
|
|
603
|
+
#endif
|
|
604
|
+
#define INT24_MIN (~INT24_C(0x7FFF))
|
|
605
|
+
#define INT24_MAX ( INT24_C(0x7FFF))
|
|
606
|
+
#define UINT24_MAX ( INT24_C(0xFFFF))
|
|
607
|
+
|
|
593
608
|
#if SCHAR_MIN == ~0x7FFFFFFF && SCHAR_MAX == 0x7FFFFFFF && UCHAR_MAX == 0xFFFFFFFF
|
|
594
609
|
typedef unsigned char uint32_t;
|
|
595
610
|
typedef signed char int32_t;
|
|
@@ -620,6 +635,17 @@ typedef signed long long int32_t;
|
|
|
620
635
|
#define INT32_MAX ( INT32_C(0x7FFFFFFF))
|
|
621
636
|
#define UINT32_MAX ( INT32_C(0xFFFFFFFF))
|
|
622
637
|
|
|
638
|
+
#if defined(zig_ez80)
|
|
639
|
+
typedef unsigned __int48 uint48_t;
|
|
640
|
+
typedef signed __int48 int48_t;
|
|
641
|
+
#define INT48_C(c) c
|
|
642
|
+
/* no suffix */
|
|
643
|
+
#define UINT48_C(c) ((uint48_t)(c))
|
|
644
|
+
#endif
|
|
645
|
+
#define INT48_MIN (~INT48_C(0x7FFFFFFFFFFF))
|
|
646
|
+
#define INT48_MAX ( INT48_C(0x7FFFFFFFFFFF))
|
|
647
|
+
#define UINT48_MAX ( INT48_C(0xFFFFFFFFFFFF))
|
|
648
|
+
|
|
623
649
|
#if SCHAR_MIN == ~0x7FFFFFFFFFFFFFFF && SCHAR_MAX == 0x7FFFFFFFFFFFFFFF && UCHAR_MAX == 0xFFFFFFFFFFFFFFFF
|
|
624
650
|
typedef unsigned char uint64_t;
|
|
625
651
|
typedef signed char int64_t;
|
|
@@ -663,10 +689,18 @@ typedef ptrdiff_t intptr_t;
|
|
|
663
689
|
#define zig_maxInt_i16 INT16_MAX
|
|
664
690
|
#define zig_minInt_u16 UINT16_C(0)
|
|
665
691
|
#define zig_maxInt_u16 UINT16_MAX
|
|
692
|
+
#define zig_minInt_i24 INT24_MIN
|
|
693
|
+
#define zig_maxInt_i24 INT24_MAX
|
|
694
|
+
#define zig_minInt_u24 UINT24_C(0)
|
|
695
|
+
#define zig_maxInt_u24 UINT24_MAX
|
|
666
696
|
#define zig_minInt_i32 INT32_MIN
|
|
667
697
|
#define zig_maxInt_i32 INT32_MAX
|
|
668
698
|
#define zig_minInt_u32 UINT32_C(0)
|
|
669
699
|
#define zig_maxInt_u32 UINT32_MAX
|
|
700
|
+
#define zig_minInt_i48 INT48_MIN
|
|
701
|
+
#define zig_maxInt_i48 INT48_MAX
|
|
702
|
+
#define zig_minInt_u48 UINT48_C(0)
|
|
703
|
+
#define zig_maxInt_u48 UINT48_MAX
|
|
670
704
|
#define zig_minInt_i64 INT64_MIN
|
|
671
705
|
#define zig_maxInt_i64 INT64_MAX
|
|
672
706
|
#define zig_minInt_u64 UINT64_C(0)
|
|
@@ -786,6 +820,17 @@ zig_int_helpers(16, unsigned long long)
|
|
|
786
820
|
#else
|
|
787
821
|
zig_int_helpers(16, uint16_t)
|
|
788
822
|
#endif
|
|
823
|
+
#if defined(zig_ez80)
|
|
824
|
+
#if UINT24_MAX <= UINT_MAX
|
|
825
|
+
zig_int_helpers(24, unsigned int)
|
|
826
|
+
#elif UINT24_MAX <= ULONG_MAX
|
|
827
|
+
zig_int_helpers(24, unsigned long)
|
|
828
|
+
#elif UINT24_MAX <= ULLONG_MAX
|
|
829
|
+
zig_int_helpers(24, unsigned long long)
|
|
830
|
+
#else
|
|
831
|
+
zig_int_helpers(24, uint24_t)
|
|
832
|
+
#endif
|
|
833
|
+
#endif
|
|
789
834
|
#if UINT32_MAX <= UINT_MAX
|
|
790
835
|
zig_int_helpers(32, unsigned int)
|
|
791
836
|
#elif UINT32_MAX <= ULONG_MAX
|
|
@@ -795,6 +840,17 @@ zig_int_helpers(32, unsigned long long)
|
|
|
795
840
|
#else
|
|
796
841
|
zig_int_helpers(32, uint32_t)
|
|
797
842
|
#endif
|
|
843
|
+
#if defined(zig_ez80)
|
|
844
|
+
#if UINT24_MAX <= UINT_MAX
|
|
845
|
+
zig_int_helpers(48, unsigned int)
|
|
846
|
+
#elif UINT24_MAX <= ULONG_MAX
|
|
847
|
+
zig_int_helpers(48, unsigned long)
|
|
848
|
+
#elif UINT24_MAX <= ULLONG_MAX
|
|
849
|
+
zig_int_helpers(48, unsigned long long)
|
|
850
|
+
#else
|
|
851
|
+
zig_int_helpers(48, uint48_t)
|
|
852
|
+
#endif
|
|
853
|
+
#endif
|
|
798
854
|
#if UINT64_MAX <= UINT_MAX
|
|
799
855
|
zig_int_helpers(64, unsigned int)
|
|
800
856
|
#elif UINT64_MAX <= ULONG_MAX
|
|
@@ -909,6 +965,66 @@ static inline bool zig_addo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t
|
|
|
909
965
|
#endif
|
|
910
966
|
}
|
|
911
967
|
|
|
968
|
+
#if defined(zig_ez80)
|
|
969
|
+
static inline bool zig_addo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) {
|
|
970
|
+
#if zig_has_builtin(add_overflow) || defined(zig_gcc)
|
|
971
|
+
uint24_t full_res;
|
|
972
|
+
bool overflow = __builtin_add_overflow(lhs, rhs, &full_res);
|
|
973
|
+
*res = zig_wrap_u24(full_res, bits);
|
|
974
|
+
return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits);
|
|
975
|
+
#else
|
|
976
|
+
uint32_t full_res;
|
|
977
|
+
bool overflow = zig_addo_u32(&full_res, lhs, rhs, bits);
|
|
978
|
+
*res = (uint24_t)full_res;
|
|
979
|
+
return overflow;
|
|
980
|
+
#endif
|
|
981
|
+
}
|
|
982
|
+
|
|
983
|
+
static inline bool zig_addo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) {
|
|
984
|
+
#if zig_has_builtin(add_overflow) || defined(zig_gcc)
|
|
985
|
+
int24_t full_res;
|
|
986
|
+
bool overflow = __builtin_add_overflow(lhs, rhs, &full_res);
|
|
987
|
+
*res = zig_wrap_i24(full_res, bits);
|
|
988
|
+
return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits);
|
|
989
|
+
#else
|
|
990
|
+
int32_t full_res;
|
|
991
|
+
bool overflow = zig_addo_i32(&full_res, lhs, rhs, bits);
|
|
992
|
+
*res = (int24_t)full_res;
|
|
993
|
+
return overflow;
|
|
994
|
+
#endif
|
|
995
|
+
}
|
|
996
|
+
#endif
|
|
997
|
+
|
|
998
|
+
#if defined(zig_ez80)
|
|
999
|
+
static inline bool zig_addo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) {
|
|
1000
|
+
#if zig_has_builtin(add_overflow) || defined(zig_gcc)
|
|
1001
|
+
uint48_t full_res;
|
|
1002
|
+
bool overflow = __builtin_add_overflow(lhs, rhs, &full_res);
|
|
1003
|
+
*res = zig_wrap_u48(full_res, bits);
|
|
1004
|
+
return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits);
|
|
1005
|
+
#else
|
|
1006
|
+
uint64_t full_res;
|
|
1007
|
+
bool overflow = zig_addo_u64(&full_res, lhs, rhs, bits);
|
|
1008
|
+
*res = (uint48_t)full_res;
|
|
1009
|
+
return overflow;
|
|
1010
|
+
#endif
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
static inline bool zig_addo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) {
|
|
1014
|
+
#if zig_has_builtin(add_overflow) || defined(zig_gcc)
|
|
1015
|
+
int48_t full_res;
|
|
1016
|
+
bool overflow = __builtin_add_overflow(lhs, rhs, &full_res);
|
|
1017
|
+
*res = zig_wrap_i48(full_res, bits);
|
|
1018
|
+
return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits);
|
|
1019
|
+
#else
|
|
1020
|
+
int64_t full_res;
|
|
1021
|
+
bool overflow = zig_addo_i64(&full_res, lhs, rhs, bits);
|
|
1022
|
+
*res = (int48_t)full_res;
|
|
1023
|
+
return overflow;
|
|
1024
|
+
#endif
|
|
1025
|
+
}
|
|
1026
|
+
#endif
|
|
1027
|
+
|
|
912
1028
|
static inline bool zig_subo_u32(uint32_t *res, uint32_t lhs, uint32_t rhs, uint8_t bits) {
|
|
913
1029
|
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
914
1030
|
uint32_t full_res;
|
|
@@ -933,6 +1049,7 @@ static inline bool zig_subo_i32(int32_t *res, int32_t lhs, int32_t rhs, uint8_t
|
|
|
933
1049
|
return overflow || full_res < zig_minInt_i(32, bits) || full_res > zig_maxInt_i(32, bits);
|
|
934
1050
|
}
|
|
935
1051
|
|
|
1052
|
+
|
|
936
1053
|
static inline bool zig_subo_u64(uint64_t *res, uint64_t lhs, uint64_t rhs, uint8_t bits) {
|
|
937
1054
|
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
938
1055
|
uint64_t full_res;
|
|
@@ -1013,6 +1130,66 @@ static inline bool zig_subo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t
|
|
|
1013
1130
|
#endif
|
|
1014
1131
|
}
|
|
1015
1132
|
|
|
1133
|
+
#if defined(zig_ez80)
|
|
1134
|
+
static inline bool zig_subo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) {
|
|
1135
|
+
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
1136
|
+
uint24_t full_res;
|
|
1137
|
+
bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res);
|
|
1138
|
+
*res = zig_wrap_u24(full_res, bits);
|
|
1139
|
+
return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits);
|
|
1140
|
+
#else
|
|
1141
|
+
uint32_t full_res;
|
|
1142
|
+
bool overflow = zig_subo_u32(&full_res, lhs, rhs, bits);
|
|
1143
|
+
*res = (uint24_t)full_res;
|
|
1144
|
+
return overflow;
|
|
1145
|
+
#endif
|
|
1146
|
+
}
|
|
1147
|
+
|
|
1148
|
+
static inline bool zig_subo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) {
|
|
1149
|
+
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
1150
|
+
int24_t full_res;
|
|
1151
|
+
bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res);
|
|
1152
|
+
*res = zig_wrap_i24(full_res, bits);
|
|
1153
|
+
return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits);
|
|
1154
|
+
#else
|
|
1155
|
+
int32_t full_res;
|
|
1156
|
+
bool overflow = zig_subo_i32(&full_res, lhs, rhs, bits);
|
|
1157
|
+
*res = (int24_t)full_res;
|
|
1158
|
+
return overflow;
|
|
1159
|
+
#endif
|
|
1160
|
+
}
|
|
1161
|
+
#endif
|
|
1162
|
+
|
|
1163
|
+
#if defined(zig_ez80)
|
|
1164
|
+
static inline bool zig_subo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) {
|
|
1165
|
+
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
1166
|
+
uint48_t full_res;
|
|
1167
|
+
bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res);
|
|
1168
|
+
*res = zig_wrap_u48(full_res, bits);
|
|
1169
|
+
return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits);
|
|
1170
|
+
#else
|
|
1171
|
+
uint64_t full_res;
|
|
1172
|
+
bool overflow = zig_subo_u64(&full_res, lhs, rhs, bits);
|
|
1173
|
+
*res = (uint48_t)full_res;
|
|
1174
|
+
return overflow;
|
|
1175
|
+
#endif
|
|
1176
|
+
}
|
|
1177
|
+
|
|
1178
|
+
static inline bool zig_subo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) {
|
|
1179
|
+
#if zig_has_builtin(sub_overflow) || defined(zig_gcc)
|
|
1180
|
+
int48_t full_res;
|
|
1181
|
+
bool overflow = __builtin_sub_overflow(lhs, rhs, &full_res);
|
|
1182
|
+
*res = zig_wrap_i48(full_res, bits);
|
|
1183
|
+
return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits);
|
|
1184
|
+
#else
|
|
1185
|
+
int64_t full_res;
|
|
1186
|
+
bool overflow = zig_subo_i64(&full_res, lhs, rhs, bits);
|
|
1187
|
+
*res = (int48_t)full_res;
|
|
1188
|
+
return overflow;
|
|
1189
|
+
#endif
|
|
1190
|
+
}
|
|
1191
|
+
#endif
|
|
1192
|
+
|
|
1016
1193
|
static inline bool zig_mulo_u32(uint32_t *res, uint32_t lhs, uint32_t rhs, uint8_t bits) {
|
|
1017
1194
|
#if zig_has_builtin(mul_overflow) || defined(zig_gcc)
|
|
1018
1195
|
uint32_t full_res;
|
|
@@ -1121,6 +1298,66 @@ static inline bool zig_mulo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t
|
|
|
1121
1298
|
#endif
|
|
1122
1299
|
}
|
|
1123
1300
|
|
|
1301
|
+
#if defined(zig_ez80)
|
|
1302
|
+
static inline bool zig_mulo_u24(uint24_t *res, uint24_t lhs, uint24_t rhs, uint8_t bits) {
|
|
1303
|
+
#if zig_has_builtin(mul_overflow) || defined(zig_gcc)
|
|
1304
|
+
uint24_t full_res;
|
|
1305
|
+
bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res);
|
|
1306
|
+
*res = zig_wrap_u24(full_res, bits);
|
|
1307
|
+
return overflow || full_res < zig_minInt_u(24, bits) || full_res > zig_maxInt_u(24, bits);
|
|
1308
|
+
#else
|
|
1309
|
+
uint32_t full_res;
|
|
1310
|
+
bool overflow = zig_mulo_u32(&full_res, lhs, rhs, bits);
|
|
1311
|
+
*res = (uint24_t)full_res;
|
|
1312
|
+
return overflow;
|
|
1313
|
+
#endif
|
|
1314
|
+
}
|
|
1315
|
+
|
|
1316
|
+
static inline bool zig_mulo_i24(int24_t *res, int24_t lhs, int24_t rhs, uint8_t bits) {
|
|
1317
|
+
#if zig_has_builtin(mul_overflow) || defined(zig_gcc)
|
|
1318
|
+
int24_t full_res;
|
|
1319
|
+
bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res);
|
|
1320
|
+
*res = zig_wrap_i24(full_res, bits);
|
|
1321
|
+
return overflow || full_res < zig_minInt_i(24, bits) || full_res > zig_maxInt_i(24, bits);
|
|
1322
|
+
#else
|
|
1323
|
+
int32_t full_res;
|
|
1324
|
+
bool overflow = zig_mulo_i32(&full_res, lhs, rhs, bits);
|
|
1325
|
+
*res = (int24_t)full_res;
|
|
1326
|
+
return overflow;
|
|
1327
|
+
#endif
|
|
1328
|
+
}
|
|
1329
|
+
#endif
|
|
1330
|
+
|
|
1331
|
+
#if defined(zig_ez80)
|
|
1332
|
+
static inline bool zig_mulo_u48(uint48_t *res, uint48_t lhs, uint48_t rhs, uint8_t bits) {
|
|
1333
|
+
#if zig_has_builtin(mul_overflow) || defined(zig_gcc)
|
|
1334
|
+
uint48_t full_res;
|
|
1335
|
+
bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res);
|
|
1336
|
+
*res = zig_wrap_u48(full_res, bits);
|
|
1337
|
+
return overflow || full_res < zig_minInt_u(48, bits) || full_res > zig_maxInt_u(48, bits);
|
|
1338
|
+
#else
|
|
1339
|
+
uint64_t full_res;
|
|
1340
|
+
bool overflow = zig_mulo_u64(&full_res, lhs, rhs, bits);
|
|
1341
|
+
*res = (uint48_t)full_res;
|
|
1342
|
+
return overflow;
|
|
1343
|
+
#endif
|
|
1344
|
+
}
|
|
1345
|
+
|
|
1346
|
+
static inline bool zig_mulo_i48(int48_t *res, int48_t lhs, int48_t rhs, uint8_t bits) {
|
|
1347
|
+
#if zig_has_builtin(mul_overflow) || defined(zig_gcc)
|
|
1348
|
+
int48_t full_res;
|
|
1349
|
+
bool overflow = __builtin_mul_overflow(lhs, rhs, &full_res);
|
|
1350
|
+
*res = zig_wrap_i48(full_res, bits);
|
|
1351
|
+
return overflow || full_res < zig_minInt_i(48, bits) || full_res > zig_maxInt_i(48, bits);
|
|
1352
|
+
#else
|
|
1353
|
+
int64_t full_res;
|
|
1354
|
+
bool overflow = zig_mulo_i64(&full_res, lhs, rhs, bits);
|
|
1355
|
+
*res = (int48_t)full_res;
|
|
1356
|
+
return overflow;
|
|
1357
|
+
#endif
|
|
1358
|
+
}
|
|
1359
|
+
#endif
|
|
1360
|
+
|
|
1124
1361
|
#define zig_int_builtins(w) \
|
|
1125
1362
|
static inline bool zig_shlo_u##w(uint##w##_t *res, uint##w##_t lhs, uint8_t rhs, uint8_t bits) { \
|
|
1126
1363
|
*res = zig_shlw_u##w(lhs, rhs, bits); \
|
|
@@ -1180,7 +1417,13 @@ static inline bool zig_mulo_i16(int16_t *res, int16_t lhs, int16_t rhs, uint8_t
|
|
|
1180
1417
|
}
|
|
1181
1418
|
zig_int_builtins(8)
|
|
1182
1419
|
zig_int_builtins(16)
|
|
1420
|
+
#if defined(zig_ez80)
|
|
1421
|
+
zig_int_builtins(24)
|
|
1422
|
+
#endif
|
|
1183
1423
|
zig_int_builtins(32)
|
|
1424
|
+
#if defined(zig_ez80)
|
|
1425
|
+
zig_int_builtins(48)
|
|
1426
|
+
#endif
|
|
1184
1427
|
zig_int_builtins(64)
|
|
1185
1428
|
|
|
1186
1429
|
#define zig_builtin8(name, val) __builtin_##name(val)
|
|
@@ -1189,6 +1432,11 @@ typedef unsigned int zig_Builtin8;
|
|
|
1189
1432
|
#define zig_builtin16(name, val) __builtin_##name(val)
|
|
1190
1433
|
typedef unsigned int zig_Builtin16;
|
|
1191
1434
|
|
|
1435
|
+
#if defined(zig_ez80)
|
|
1436
|
+
#define zig_builtin24(name, val) __builtin_##name(val)
|
|
1437
|
+
typedef unsigned int zig_Builtin24;
|
|
1438
|
+
#endif
|
|
1439
|
+
|
|
1192
1440
|
#if INT_MIN <= INT32_MIN
|
|
1193
1441
|
#define zig_builtin32(name, val) __builtin_##name(val)
|
|
1194
1442
|
typedef unsigned int zig_Builtin32;
|
|
@@ -1197,6 +1445,11 @@ typedef unsigned int zig_Builtin32;
|
|
|
1197
1445
|
typedef unsigned long zig_Builtin32;
|
|
1198
1446
|
#endif
|
|
1199
1447
|
|
|
1448
|
+
#if defined(zig_ez80)
|
|
1449
|
+
#define zig_builtin48(name, val) __builtin_##name(val)
|
|
1450
|
+
typedef unsigned long long zig_Builtin48;
|
|
1451
|
+
#endif
|
|
1452
|
+
|
|
1200
1453
|
#if INT_MIN <= INT64_MIN
|
|
1201
1454
|
#define zig_builtin64(name, val) __builtin_##name(val)
|
|
1202
1455
|
typedef unsigned int zig_Builtin64;
|
|
@@ -1231,6 +1484,23 @@ static inline int16_t zig_byte_swap_i16(int16_t val, uint8_t bits) {
|
|
|
1231
1484
|
return zig_wrap_i16((int16_t)zig_byte_swap_u16((uint16_t)val, bits), bits);
|
|
1232
1485
|
}
|
|
1233
1486
|
|
|
1487
|
+
#if defined(zig_ez80)
|
|
1488
|
+
static inline uint16_t zig_byte_swap_u24(uint24_t val, uint8_t bits) {
|
|
1489
|
+
uint24_t full_res;
|
|
1490
|
+
#if zig_has_builtin(bswap24) || defined(zig_gcc)
|
|
1491
|
+
full_res = __builtin_bswap24(val);
|
|
1492
|
+
#else
|
|
1493
|
+
full_res = (uint24_t)zig_byte_swap_u8((uint8_t)(val >> 0), 8) << 16 |
|
|
1494
|
+
(uint24_t)zig_byte_swap_u16((uint16_t)(val >> 8), 16) >> 0;
|
|
1495
|
+
#endif
|
|
1496
|
+
return zig_wrap_u24(full_res >> (24 - bits), bits);
|
|
1497
|
+
}
|
|
1498
|
+
|
|
1499
|
+
static inline int16_t zig_byte_swap_i24(int24_t val, uint8_t bits) {
|
|
1500
|
+
return zig_wrap_i24((int24_t)zig_byte_swap_u24((uint24_t)val, bits), bits);
|
|
1501
|
+
}
|
|
1502
|
+
#endif
|
|
1503
|
+
|
|
1234
1504
|
static inline uint32_t zig_byte_swap_u32(uint32_t val, uint8_t bits) {
|
|
1235
1505
|
uint32_t full_res;
|
|
1236
1506
|
#if zig_has_builtin(bswap32) || defined(zig_gcc)
|
|
@@ -1246,6 +1516,23 @@ static inline int32_t zig_byte_swap_i32(int32_t val, uint8_t bits) {
|
|
|
1246
1516
|
return zig_wrap_i32((int32_t)zig_byte_swap_u32((uint32_t)val, bits), bits);
|
|
1247
1517
|
}
|
|
1248
1518
|
|
|
1519
|
+
#if defined(zig_ez80)
|
|
1520
|
+
static inline uint32_t zig_byte_swap_u48(uint48_t val, uint8_t bits) {
|
|
1521
|
+
uint48_t full_res;
|
|
1522
|
+
#if zig_has_builtin(bswap48) || defined(zig_gcc)
|
|
1523
|
+
full_res = __builtin_bswap48(val);
|
|
1524
|
+
#else
|
|
1525
|
+
full_res = (uint48_t)zig_byte_swap_u24((uint24_t)(val >> 0), 24) << 24 |
|
|
1526
|
+
(uint48_t)zig_byte_swap_u24((uint24_t)(val >> 24), 24) >> 0;
|
|
1527
|
+
#endif
|
|
1528
|
+
return zig_wrap_u48(full_res >> (48 - bits), bits);
|
|
1529
|
+
}
|
|
1530
|
+
|
|
1531
|
+
static inline int32_t zig_byte_swap_i48(int48_t val, uint8_t bits) {
|
|
1532
|
+
return zig_wrap_i48((int48_t)zig_byte_swap_u48((uint48_t)val, bits), bits);
|
|
1533
|
+
}
|
|
1534
|
+
#endif
|
|
1535
|
+
|
|
1249
1536
|
static inline uint64_t zig_byte_swap_u64(uint64_t val, uint8_t bits) {
|
|
1250
1537
|
uint64_t full_res;
|
|
1251
1538
|
#if zig_has_builtin(bswap64) || defined(zig_gcc)
|
|
@@ -1294,6 +1581,23 @@ static inline int16_t zig_bit_reverse_i16(int16_t val, uint8_t bits) {
|
|
|
1294
1581
|
return zig_wrap_i16((int16_t)zig_bit_reverse_u16((uint16_t)val, bits), bits);
|
|
1295
1582
|
}
|
|
1296
1583
|
|
|
1584
|
+
#if defined(zig_ez80)
|
|
1585
|
+
static inline uint24_t zig_bit_reverse_u24(uint24_t val, uint8_t bits) {
|
|
1586
|
+
uint24_t full_res;
|
|
1587
|
+
#if zig_has_builtin(bitreverse24)
|
|
1588
|
+
full_res = __builtin_bitreverse24(val);
|
|
1589
|
+
#else
|
|
1590
|
+
full_res = (uint24_t)zig_bit_reverse_u8((uint8_t)(val >> 0), 8) << 16 |
|
|
1591
|
+
(uint24_t)zig_bit_reverse_u16((uint16_t)(val >> 8), 16) >> 0;
|
|
1592
|
+
#endif
|
|
1593
|
+
return zig_wrap_u24(full_res >> (24 - bits), bits);
|
|
1594
|
+
}
|
|
1595
|
+
|
|
1596
|
+
static inline int24_t zig_bit_reverse_i24(int24_t val, uint8_t bits) {
|
|
1597
|
+
return zig_wrap_i24((int24_t)zig_bit_reverse_u24((uint24_t)val, bits), bits);
|
|
1598
|
+
}
|
|
1599
|
+
#endif
|
|
1600
|
+
|
|
1297
1601
|
static inline uint32_t zig_bit_reverse_u32(uint32_t val, uint8_t bits) {
|
|
1298
1602
|
uint32_t full_res;
|
|
1299
1603
|
#if zig_has_builtin(bitreverse32)
|
|
@@ -1309,6 +1613,23 @@ static inline int32_t zig_bit_reverse_i32(int32_t val, uint8_t bits) {
|
|
|
1309
1613
|
return zig_wrap_i32((int32_t)zig_bit_reverse_u32((uint32_t)val, bits), bits);
|
|
1310
1614
|
}
|
|
1311
1615
|
|
|
1616
|
+
#if defined(zig_ez80)
|
|
1617
|
+
static inline uint32_t zig_bit_reverse_u48(uint48_t val, uint8_t bits) {
|
|
1618
|
+
uint48_t full_res;
|
|
1619
|
+
#if zig_has_builtin(bitreverse48)
|
|
1620
|
+
full_res = __builtin_bitreverse48(val);
|
|
1621
|
+
#else
|
|
1622
|
+
full_res = (uint48_t)zig_bit_reverse_u24((uint24_t)(val >> 0), 24) << 24 |
|
|
1623
|
+
(uint48_t)zig_bit_reverse_u24((uint24_t)(val >> 24), 24) >> 0;
|
|
1624
|
+
#endif
|
|
1625
|
+
return zig_wrap_u32(full_res >> (48 - bits), bits);
|
|
1626
|
+
}
|
|
1627
|
+
|
|
1628
|
+
static inline int32_t zig_bit_reverse_i48(int48_t val, uint8_t bits) {
|
|
1629
|
+
return zig_wrap_i48((int48_t)zig_bit_reverse_u48((uint48_t)val, bits), bits);
|
|
1630
|
+
}
|
|
1631
|
+
#endif
|
|
1632
|
+
|
|
1312
1633
|
static inline uint64_t zig_bit_reverse_u64(uint64_t val, uint8_t bits) {
|
|
1313
1634
|
uint64_t full_res;
|
|
1314
1635
|
#if zig_has_builtin(bitreverse64)
|
|
@@ -1350,7 +1671,13 @@ static inline int64_t zig_bit_reverse_i64(int64_t val, uint8_t bits) {
|
|
|
1350
1671
|
#endif
|
|
1351
1672
|
zig_builtin_popcount(8)
|
|
1352
1673
|
zig_builtin_popcount(16)
|
|
1674
|
+
#if defined(zig_ez80)
|
|
1675
|
+
zig_builtin_popcount(24)
|
|
1676
|
+
#endif
|
|
1353
1677
|
zig_builtin_popcount(32)
|
|
1678
|
+
#if defined(zig_ez80)
|
|
1679
|
+
zig_builtin_popcount(48)
|
|
1680
|
+
#endif
|
|
1354
1681
|
zig_builtin_popcount(64)
|
|
1355
1682
|
|
|
1356
1683
|
#define zig_builtin_ctz_common(w) \
|
|
@@ -1375,7 +1702,13 @@ zig_builtin_popcount(64)
|
|
|
1375
1702
|
#endif
|
|
1376
1703
|
zig_builtin_ctz(8)
|
|
1377
1704
|
zig_builtin_ctz(16)
|
|
1705
|
+
#if defined(zig_ez80)
|
|
1706
|
+
zig_builtin_ctz(24)
|
|
1707
|
+
#endif
|
|
1378
1708
|
zig_builtin_ctz(32)
|
|
1709
|
+
#if defined(zig_ez80)
|
|
1710
|
+
zig_builtin_ctz(48)
|
|
1711
|
+
#endif
|
|
1379
1712
|
zig_builtin_ctz(64)
|
|
1380
1713
|
|
|
1381
1714
|
#define zig_builtin_clz_common(w) \
|
|
@@ -1400,7 +1733,13 @@ zig_builtin_ctz(64)
|
|
|
1400
1733
|
#endif
|
|
1401
1734
|
zig_builtin_clz(8)
|
|
1402
1735
|
zig_builtin_clz(16)
|
|
1736
|
+
#if defined(zig_ez80)
|
|
1737
|
+
zig_builtin_clz(24)
|
|
1738
|
+
#endif
|
|
1403
1739
|
zig_builtin_clz(32)
|
|
1740
|
+
#if defined(zig_ez80)
|
|
1741
|
+
zig_builtin_clz(48)
|
|
1742
|
+
#endif
|
|
1404
1743
|
zig_builtin_clz(64)
|
|
1405
1744
|
|
|
1406
1745
|
/* ======================== 128-bit Integer Support ========================= */
|
package/libc/mingw/math/fdiml.c
DELETED
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* This file has no copyright assigned and is placed in the Public Domain.
|
|
3
|
-
* This file is part of the mingw-w64 runtime package.
|
|
4
|
-
* No warranty is given; refer to the file DISCLAIMER.PD within this package.
|
|
5
|
-
*/
|
|
6
|
-
#include <errno.h>
|
|
7
|
-
#include <math.h>
|
|
8
|
-
|
|
9
|
-
long double
|
|
10
|
-
fdiml (long double x, long double y)
|
|
11
|
-
{
|
|
12
|
-
int cx = fpclassify (x), cy = fpclassify (y);
|
|
13
|
-
long double r;
|
|
14
|
-
|
|
15
|
-
if (cx == FP_NAN || cy == FP_NAN
|
|
16
|
-
|| (y < 0 && cx == FP_INFINITE && cy == FP_INFINITE))
|
|
17
|
-
return x - y; /* Take care invalid flag is raised. */
|
|
18
|
-
if (x <= y)
|
|
19
|
-
return 0.0;
|
|
20
|
-
r = x - y;
|
|
21
|
-
if (fpclassify (r) == FP_INFINITE)
|
|
22
|
-
errno = ERANGE;
|
|
23
|
-
return r;
|
|
24
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
#include <math.h>
|
|
2
|
-
#include <float.h>
|
|
3
|
-
|
|
4
|
-
#if LDBL_MANT_DIG == 53 && LDBL_MAX_EXP == 1024
|
|
5
|
-
long double fdiml(long double x, long double y)
|
|
6
|
-
{
|
|
7
|
-
return fdim(x, y);
|
|
8
|
-
}
|
|
9
|
-
#else
|
|
10
|
-
long double fdiml(long double x, long double y)
|
|
11
|
-
{
|
|
12
|
-
if (isnan(x))
|
|
13
|
-
return x;
|
|
14
|
-
if (isnan(y))
|
|
15
|
-
return y;
|
|
16
|
-
return x > y ? x - y : 0;
|
|
17
|
-
}
|
|
18
|
-
#endif
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
#include <unistd.h>
|
|
2
|
-
#include <errno.h>
|
|
3
|
-
#include <fcntl.h>
|
|
4
|
-
#include "syscall.h"
|
|
5
|
-
|
|
6
|
-
int dup2(int old, int new)
|
|
7
|
-
{
|
|
8
|
-
int r;
|
|
9
|
-
#ifdef SYS_dup2
|
|
10
|
-
while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
|
|
11
|
-
#else
|
|
12
|
-
if (old==new) {
|
|
13
|
-
r = __syscall(SYS_fcntl, old, F_GETFD);
|
|
14
|
-
if (r >= 0) return old;
|
|
15
|
-
} else {
|
|
16
|
-
while ((r=__syscall(SYS_dup3, old, new, 0))==-EBUSY);
|
|
17
|
-
}
|
|
18
|
-
#endif
|
|
19
|
-
return __syscall_ret(r);
|
|
20
|
-
}
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
#define _GNU_SOURCE
|
|
2
|
-
#include <unistd.h>
|
|
3
|
-
#include <errno.h>
|
|
4
|
-
#include <fcntl.h>
|
|
5
|
-
#include "syscall.h"
|
|
6
|
-
|
|
7
|
-
int __dup3(int old, int new, int flags)
|
|
8
|
-
{
|
|
9
|
-
int r;
|
|
10
|
-
#ifdef SYS_dup2
|
|
11
|
-
if (old==new) return __syscall_ret(-EINVAL);
|
|
12
|
-
if (flags) {
|
|
13
|
-
while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
|
|
14
|
-
if (r!=-ENOSYS) return __syscall_ret(r);
|
|
15
|
-
if (flags & ~O_CLOEXEC) return __syscall_ret(-EINVAL);
|
|
16
|
-
}
|
|
17
|
-
while ((r=__syscall(SYS_dup2, old, new))==-EBUSY);
|
|
18
|
-
if (r >= 0 && (flags & O_CLOEXEC))
|
|
19
|
-
__syscall(SYS_fcntl, new, F_SETFD, FD_CLOEXEC);
|
|
20
|
-
#else
|
|
21
|
-
while ((r=__syscall(SYS_dup3, old, new, flags))==-EBUSY);
|
|
22
|
-
#endif
|
|
23
|
-
return __syscall_ret(r);
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
weak_alias(__dup3, dup3);
|