@zigc/lib 0.17.0-dev.39 → 0.17.0-dev.44
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/compiler/translate-c/Translator.zig +4 -0
- package/package.json +1 -1
- package/std/Target.zig +50 -3
- package/std/builtin.zig +4 -0
- package/std/fmt.zig +7 -2
- package/std/http/Client.zig +21 -24
- package/std/sort.zig +3 -3
- package/zig.h +340 -1
|
@@ -475,8 +475,12 @@ pub const builtin_typedef_map = std.StaticStringMap([]const u8).initComptime(.{
|
|
|
475
475
|
.{ "int8_t", "i8" },
|
|
476
476
|
.{ "uint16_t", "u16" },
|
|
477
477
|
.{ "int16_t", "i16" },
|
|
478
|
+
.{ "uint24_t", "u24" },
|
|
479
|
+
.{ "int24_t", "i24" },
|
|
478
480
|
.{ "uint32_t", "u32" },
|
|
479
481
|
.{ "int32_t", "i32" },
|
|
482
|
+
.{ "uint48_t", "u48" },
|
|
483
|
+
.{ "int48_t", "i48" },
|
|
480
484
|
.{ "uint64_t", "u64" },
|
|
481
485
|
.{ "int64_t", "i64" },
|
|
482
486
|
.{ "intptr_t", "isize" },
|
package/package.json
CHANGED
package/std/Target.zig
CHANGED
|
@@ -68,6 +68,8 @@ pub const Os = struct {
|
|
|
68
68
|
opengl,
|
|
69
69
|
vulkan,
|
|
70
70
|
|
|
71
|
+
tios,
|
|
72
|
+
|
|
71
73
|
// LLVM tags deliberately omitted:
|
|
72
74
|
// - bridgeos
|
|
73
75
|
// - cheriotrtos
|
|
@@ -207,6 +209,8 @@ pub const Os = struct {
|
|
|
207
209
|
.opencl,
|
|
208
210
|
.opengl,
|
|
209
211
|
.vulkan,
|
|
212
|
+
|
|
213
|
+
.tios,
|
|
210
214
|
=> .semver,
|
|
211
215
|
|
|
212
216
|
.hurd => .hurd,
|
|
@@ -670,6 +674,12 @@ pub const Os = struct {
|
|
|
670
674
|
.max = .{ .major = 4, .minor = 6, .patch = 0 },
|
|
671
675
|
},
|
|
672
676
|
},
|
|
677
|
+
.tios => .{
|
|
678
|
+
.semver = .{
|
|
679
|
+
.min = .{ .major = 5, .minor = 0, .patch = 0 },
|
|
680
|
+
.max = .{ .major = 5, .minor = 8, .patch = 4 },
|
|
681
|
+
},
|
|
682
|
+
},
|
|
673
683
|
.vulkan => .{
|
|
674
684
|
.semver = .{
|
|
675
685
|
.min = .{ .major = 1, .minor = 2, .patch = 0 },
|
|
@@ -758,6 +768,7 @@ pub const wasm = @import("Target/wasm.zig");
|
|
|
758
768
|
pub const x86 = @import("Target/x86.zig");
|
|
759
769
|
pub const xcore = @import("Target/xcore.zig");
|
|
760
770
|
pub const xtensa = @import("Target/xtensa.zig");
|
|
771
|
+
pub const z80 = @import("Target/generic.zig");
|
|
761
772
|
|
|
762
773
|
pub const Abi = enum {
|
|
763
774
|
none,
|
|
@@ -942,6 +953,7 @@ pub const Abi = enum {
|
|
|
942
953
|
.opencl,
|
|
943
954
|
.opengl,
|
|
944
955
|
.vulkan,
|
|
956
|
+
.tios,
|
|
945
957
|
=> .none,
|
|
946
958
|
};
|
|
947
959
|
}
|
|
@@ -1068,6 +1080,7 @@ pub fn toElfMachine(target: *const Target) std.elf.EM {
|
|
|
1068
1080
|
.avr => .AVR,
|
|
1069
1081
|
.bpfeb, .bpfel => .BPF,
|
|
1070
1082
|
.csky => .CSKY,
|
|
1083
|
+
.ez80 => .Z80,
|
|
1071
1084
|
.hexagon => .QDSP6,
|
|
1072
1085
|
.hppa, .hppa64 => .PARISC,
|
|
1073
1086
|
.kalimba => .CSR_KALIMBA,
|
|
@@ -1130,6 +1143,7 @@ pub fn toCoffMachine(target: *const Target) std.coff.IMAGE.FILE.MACHINE {
|
|
|
1130
1143
|
.bpfeb,
|
|
1131
1144
|
.bpfel,
|
|
1132
1145
|
.csky,
|
|
1146
|
+
.ez80,
|
|
1133
1147
|
.hexagon,
|
|
1134
1148
|
.hppa,
|
|
1135
1149
|
.hppa64,
|
|
@@ -1336,6 +1350,7 @@ pub const Cpu = struct {
|
|
|
1336
1350
|
bpfeb,
|
|
1337
1351
|
bpfel,
|
|
1338
1352
|
csky,
|
|
1353
|
+
ez80,
|
|
1339
1354
|
hexagon,
|
|
1340
1355
|
hppa,
|
|
1341
1356
|
hppa64,
|
|
@@ -1437,6 +1452,7 @@ pub const Cpu = struct {
|
|
|
1437
1452
|
x86,
|
|
1438
1453
|
xcore,
|
|
1439
1454
|
xtensa,
|
|
1455
|
+
z80,
|
|
1440
1456
|
};
|
|
1441
1457
|
|
|
1442
1458
|
pub inline fn family(arch: Arch) Family {
|
|
@@ -1449,6 +1465,7 @@ pub const Cpu = struct {
|
|
|
1449
1465
|
.avr => .avr,
|
|
1450
1466
|
.bpfeb, .bpfel => .bpf,
|
|
1451
1467
|
.csky => .csky,
|
|
1468
|
+
.ez80 => .z80,
|
|
1452
1469
|
.hexagon => .hexagon,
|
|
1453
1470
|
.hppa, .hppa64 => .hppa,
|
|
1454
1471
|
.kalimba => .kalimba,
|
|
@@ -1678,6 +1695,7 @@ pub const Cpu = struct {
|
|
|
1678
1695
|
.x86_64,
|
|
1679
1696
|
.xcore,
|
|
1680
1697
|
.xtensa,
|
|
1698
|
+
.ez80,
|
|
1681
1699
|
=> .little,
|
|
1682
1700
|
|
|
1683
1701
|
.aarch64_be,
|
|
@@ -1948,6 +1966,10 @@ pub const Cpu = struct {
|
|
|
1948
1966
|
.spirv_fragment,
|
|
1949
1967
|
.spirv_vertex,
|
|
1950
1968
|
=> &.{ .spirv32, .spirv64 },
|
|
1969
|
+
|
|
1970
|
+
.ez80_cet,
|
|
1971
|
+
.ez80_tiflags,
|
|
1972
|
+
=> &.{.ez80},
|
|
1951
1973
|
};
|
|
1952
1974
|
}
|
|
1953
1975
|
};
|
|
@@ -2236,6 +2258,7 @@ pub fn requiresLibC(target: *const Target) bool {
|
|
|
2236
2258
|
.plan9,
|
|
2237
2259
|
.other,
|
|
2238
2260
|
.@"3ds",
|
|
2261
|
+
.tios,
|
|
2239
2262
|
=> false,
|
|
2240
2263
|
};
|
|
2241
2264
|
}
|
|
@@ -2398,6 +2421,8 @@ pub const DynamicLinker = struct {
|
|
|
2398
2421
|
.ps5,
|
|
2399
2422
|
.psp,
|
|
2400
2423
|
.vita,
|
|
2424
|
+
|
|
2425
|
+
.tios,
|
|
2401
2426
|
=> .none,
|
|
2402
2427
|
};
|
|
2403
2428
|
}
|
|
@@ -2815,6 +2840,8 @@ pub const DynamicLinker = struct {
|
|
|
2815
2840
|
.opencl,
|
|
2816
2841
|
.opengl,
|
|
2817
2842
|
.vulkan,
|
|
2843
|
+
|
|
2844
|
+
.tios,
|
|
2818
2845
|
=> none,
|
|
2819
2846
|
|
|
2820
2847
|
// TODO go over each item in this list and either move it to the above list, or
|
|
@@ -2849,6 +2876,9 @@ pub fn ptrBitWidth_arch_abi(cpu_arch: Cpu.Arch, abi: Abi) u16 {
|
|
|
2849
2876
|
.x86_16,
|
|
2850
2877
|
=> 16,
|
|
2851
2878
|
|
|
2879
|
+
.ez80,
|
|
2880
|
+
=> 24,
|
|
2881
|
+
|
|
2852
2882
|
.arc,
|
|
2853
2883
|
.arceb,
|
|
2854
2884
|
.arm,
|
|
@@ -2917,6 +2947,8 @@ pub fn ptrBitWidth(target: *const Target) u16 {
|
|
|
2917
2947
|
pub fn stackAlignment(target: *const Target) u16 {
|
|
2918
2948
|
// Overrides for when the stack alignment is not equal to the pointer width.
|
|
2919
2949
|
switch (target.cpu.arch) {
|
|
2950
|
+
.ez80,
|
|
2951
|
+
=> return 1,
|
|
2920
2952
|
.m68k,
|
|
2921
2953
|
=> return 2,
|
|
2922
2954
|
.amdgcn,
|
|
@@ -2997,6 +3029,7 @@ pub fn cCharSignedness(target: *const Target) std.builtin.Signedness {
|
|
|
2997
3029
|
.arc,
|
|
2998
3030
|
.arceb,
|
|
2999
3031
|
.csky,
|
|
3032
|
+
.ez80,
|
|
3000
3033
|
.hexagon,
|
|
3001
3034
|
.msp430,
|
|
3002
3035
|
.powerpc,
|
|
@@ -3364,6 +3397,13 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
|
|
|
3364
3397
|
.long, .ulong => return 64,
|
|
3365
3398
|
.longlong, .ulonglong, .double, .longdouble => return 64,
|
|
3366
3399
|
},
|
|
3400
|
+
.tios => switch (c_type) {
|
|
3401
|
+
.char => return 8,
|
|
3402
|
+
.short, .ushort => return 16,
|
|
3403
|
+
.int, .uint => return 24,
|
|
3404
|
+
.long, .ulong, .float, .double => return 32,
|
|
3405
|
+
.longlong, .ulonglong, .longdouble => return 64,
|
|
3406
|
+
},
|
|
3367
3407
|
|
|
3368
3408
|
.ps3,
|
|
3369
3409
|
.contiki,
|
|
@@ -3376,7 +3416,7 @@ pub fn cTypeBitSize(target: *const Target, c_type: CType) u16 {
|
|
|
3376
3416
|
pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
|
|
3377
3417
|
// Overrides for unusual alignments
|
|
3378
3418
|
switch (target.cpu.arch) {
|
|
3379
|
-
.avr => return 1,
|
|
3419
|
+
.avr, .ez80 => return 1,
|
|
3380
3420
|
.x86 => switch (target.os.tag) {
|
|
3381
3421
|
.windows, .uefi => switch (c_type) {
|
|
3382
3422
|
.longlong, .ulonglong, .double => return 8,
|
|
@@ -3406,6 +3446,8 @@ pub fn cTypeAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3406
3446
|
return @min(
|
|
3407
3447
|
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
|
|
3408
3448
|
@as(u16, switch (target.cpu.arch) {
|
|
3449
|
+
.ez80 => 1,
|
|
3450
|
+
|
|
3409
3451
|
.msp430,
|
|
3410
3452
|
.x86_16,
|
|
3411
3453
|
=> 2,
|
|
@@ -3484,7 +3526,7 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3484
3526
|
.longdouble => return 4,
|
|
3485
3527
|
else => {},
|
|
3486
3528
|
},
|
|
3487
|
-
.avr => return 1,
|
|
3529
|
+
.avr, .ez80 => return 1,
|
|
3488
3530
|
.x86 => switch (target.os.tag) {
|
|
3489
3531
|
.windows, .uefi => switch (c_type) {
|
|
3490
3532
|
.longdouble => switch (target.abi) {
|
|
@@ -3516,6 +3558,8 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3516
3558
|
return @min(
|
|
3517
3559
|
std.math.ceilPowerOfTwoAssert(u16, (cTypeBitSize(target, c_type) + 7) / 8),
|
|
3518
3560
|
@as(u16, switch (target.cpu.arch) {
|
|
3561
|
+
.ez80 => 1,
|
|
3562
|
+
|
|
3519
3563
|
.x86_16, .msp430 => 2,
|
|
3520
3564
|
|
|
3521
3565
|
.arc,
|
|
@@ -3587,7 +3631,9 @@ pub fn cTypePreferredAlignment(target: *const Target, c_type: CType) u16 {
|
|
|
3587
3631
|
|
|
3588
3632
|
pub fn cMaxIntAlignment(target: *const Target) u16 {
|
|
3589
3633
|
return switch (target.cpu.arch) {
|
|
3590
|
-
.avr
|
|
3634
|
+
.avr,
|
|
3635
|
+
.ez80,
|
|
3636
|
+
=> 1,
|
|
3591
3637
|
|
|
3592
3638
|
.msp430, .x86_16 => 2,
|
|
3593
3639
|
|
|
@@ -3726,6 +3772,7 @@ pub fn cCallingConvention(target: *const Target) ?std.builtin.CallingConvention
|
|
|
3726
3772
|
.amdgcn => .{ .amdgcn_device = .{} },
|
|
3727
3773
|
.nvptx, .nvptx64 => .nvptx_device,
|
|
3728
3774
|
.spirv32, .spirv64 => .spirv_device,
|
|
3775
|
+
.ez80 => .ez80_cet,
|
|
3729
3776
|
};
|
|
3730
3777
|
}
|
|
3731
3778
|
|
package/std/builtin.zig
CHANGED
|
@@ -341,6 +341,10 @@ pub const CallingConvention = union(enum(u8)) {
|
|
|
341
341
|
spirv_fragment,
|
|
342
342
|
spirv_vertex,
|
|
343
343
|
|
|
344
|
+
// Calling conventions for the `ez80` architecture.
|
|
345
|
+
ez80_cet,
|
|
346
|
+
ez80_tiflags,
|
|
347
|
+
|
|
344
348
|
/// Options shared across most calling conventions.
|
|
345
349
|
pub const CommonOptions = struct {
|
|
346
350
|
/// The boundary the stack is aligned to when the function is called.
|
package/std/fmt.zig
CHANGED
|
@@ -1342,9 +1342,9 @@ pub const hex_charset = "0123456789abcdef";
|
|
|
1342
1342
|
|
|
1343
1343
|
/// Converts an unsigned integer of any multiple of u8 to an array of lowercase
|
|
1344
1344
|
/// hex bytes, little endian.
|
|
1345
|
-
pub fn hex(x: anytype) [@
|
|
1345
|
+
pub fn hex(x: anytype) [@typeInfo(@TypeOf(x)).int.bits / 4]u8 {
|
|
1346
1346
|
comptime assert(@typeInfo(@TypeOf(x)).int.signedness == .unsigned);
|
|
1347
|
-
var result: [@
|
|
1347
|
+
var result: [@typeInfo(@TypeOf(x)).int.bits / 4]u8 = undefined;
|
|
1348
1348
|
var i: usize = 0;
|
|
1349
1349
|
while (i < result.len / 2) : (i += 1) {
|
|
1350
1350
|
const byte: u8 = @truncate(x >> @intCast(8 * i));
|
|
@@ -1360,6 +1360,11 @@ test hex {
|
|
|
1360
1360
|
try std.testing.expect(x.len == 8);
|
|
1361
1361
|
try std.testing.expectEqualStrings("efbeadde", &x);
|
|
1362
1362
|
}
|
|
1363
|
+
{
|
|
1364
|
+
const s = "[" ++ hex(@as(u48, 0x12345678_abcd)) ++ "]";
|
|
1365
|
+
try std.testing.expect(s.len == 14);
|
|
1366
|
+
try std.testing.expectEqualStrings("[cdab78563412]", s);
|
|
1367
|
+
}
|
|
1363
1368
|
{
|
|
1364
1369
|
const s = "[" ++ hex(@as(u64, 0x12345678_abcdef00)) ++ "]";
|
|
1365
1370
|
try std.testing.expect(s.len == 18);
|
package/std/http/Client.zig
CHANGED
|
@@ -4,8 +4,6 @@
|
|
|
4
4
|
//!
|
|
5
5
|
//! TLS support may be disabled via `std.options.http_disable_tls`.
|
|
6
6
|
//!
|
|
7
|
-
//! TODO all the lockUncancelable in this file should be changed to regular lock and
|
|
8
|
-
//! `error.Canceled` added to more error sets.
|
|
9
7
|
const Client = @This();
|
|
10
8
|
|
|
11
9
|
const builtin = @import("builtin");
|
|
@@ -84,8 +82,8 @@ pub const ConnectionPool = struct {
|
|
|
84
82
|
/// If no connection is found, null is returned.
|
|
85
83
|
///
|
|
86
84
|
/// Threadsafe.
|
|
87
|
-
pub fn findConnection(pool: *ConnectionPool, io: Io, criteria: Criteria)
|
|
88
|
-
pool.mutex.
|
|
85
|
+
pub fn findConnection(pool: *ConnectionPool, io: Io, criteria: Criteria) Io.Cancelable!?*Connection {
|
|
86
|
+
try pool.mutex.lock(io);
|
|
89
87
|
defer pool.mutex.unlock(io);
|
|
90
88
|
|
|
91
89
|
var next = pool.free.last;
|
|
@@ -113,8 +111,8 @@ pub const ConnectionPool = struct {
|
|
|
113
111
|
}
|
|
114
112
|
|
|
115
113
|
/// Acquires an existing connection from the connection pool. This function is threadsafe.
|
|
116
|
-
pub fn acquire(pool: *ConnectionPool, io: Io, connection: *Connection) void {
|
|
117
|
-
pool.mutex.
|
|
114
|
+
pub fn acquire(pool: *ConnectionPool, io: Io, connection: *Connection) Io.Cancelable!void {
|
|
115
|
+
try pool.mutex.lock(io);
|
|
118
116
|
defer pool.mutex.unlock(io);
|
|
119
117
|
|
|
120
118
|
return pool.acquireUnsafe(connection);
|
|
@@ -150,8 +148,8 @@ pub const ConnectionPool = struct {
|
|
|
150
148
|
}
|
|
151
149
|
|
|
152
150
|
/// Adds a newly created node to the pool of used connections. This function is threadsafe.
|
|
153
|
-
pub fn addUsed(pool: *ConnectionPool, io: Io, connection: *Connection) void {
|
|
154
|
-
pool.mutex.
|
|
151
|
+
pub fn addUsed(pool: *ConnectionPool, io: Io, connection: *Connection) Io.Cancelable!void {
|
|
152
|
+
try pool.mutex.lock(io);
|
|
155
153
|
defer pool.mutex.unlock(io);
|
|
156
154
|
|
|
157
155
|
pool.used.append(&connection.pool_node);
|
|
@@ -162,18 +160,15 @@ pub const ConnectionPool = struct {
|
|
|
162
160
|
/// If the new size is smaller than the current size, then idle connections will be closed until the pool is the new size.
|
|
163
161
|
///
|
|
164
162
|
/// Threadsafe.
|
|
165
|
-
pub fn resize(pool: *ConnectionPool, io: Io,
|
|
166
|
-
pool.mutex.
|
|
163
|
+
pub fn resize(pool: *ConnectionPool, io: Io, new_size: usize) Io.Cancelable!void {
|
|
164
|
+
try pool.mutex.lock(io);
|
|
167
165
|
defer pool.mutex.unlock(io);
|
|
168
166
|
|
|
169
|
-
const next = pool.free.first;
|
|
170
|
-
_ = next;
|
|
171
167
|
while (pool.free_len > new_size) {
|
|
172
|
-
const popped = pool.free.popFirst()
|
|
168
|
+
const popped: *Connection = @alignCast(@fieldParentPtr("pool_node", pool.free.popFirst().?));
|
|
173
169
|
pool.free_len -= 1;
|
|
174
170
|
|
|
175
|
-
popped.
|
|
176
|
-
allocator.destroy(popped);
|
|
171
|
+
popped.destroy(io);
|
|
177
172
|
}
|
|
178
173
|
|
|
179
174
|
pool.free_size = new_size;
|
|
@@ -1323,7 +1318,7 @@ pub fn initDefaultProxies(client: *Client, arena: Allocator, environ_map: *const
|
|
|
1323
1318
|
const io = client.io;
|
|
1324
1319
|
|
|
1325
1320
|
// Prevent any new connections from being created.
|
|
1326
|
-
client.connection_pool.mutex.
|
|
1321
|
+
try client.connection_pool.mutex.lock(io);
|
|
1327
1322
|
defer client.connection_pool.mutex.unlock(io);
|
|
1328
1323
|
|
|
1329
1324
|
assert(client.connection_pool.used.first == null); // There are active requests.
|
|
@@ -1418,7 +1413,7 @@ pub const basic_authorization = struct {
|
|
|
1418
1413
|
|
|
1419
1414
|
pub const ConnectTcpError = error{
|
|
1420
1415
|
TlsInitializationFailed,
|
|
1421
|
-
} || Allocator.Error || HostName.ConnectError;
|
|
1416
|
+
} || Allocator.Error || HostName.ConnectError || Io.Cancelable;
|
|
1422
1417
|
|
|
1423
1418
|
/// Reuses a `Connection` if one matching `host` and `port` is already open.
|
|
1424
1419
|
///
|
|
@@ -1451,7 +1446,7 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp
|
|
|
1451
1446
|
const proxied_host = options.proxied_host orelse host;
|
|
1452
1447
|
const proxied_port = options.proxied_port orelse port;
|
|
1453
1448
|
|
|
1454
|
-
if (client.connection_pool.findConnection(io, .{
|
|
1449
|
+
if (try client.connection_pool.findConnection(io, .{
|
|
1455
1450
|
.host = proxied_host,
|
|
1456
1451
|
.port = proxied_port,
|
|
1457
1452
|
.protocol = protocol,
|
|
@@ -1469,18 +1464,20 @@ pub fn connectTcpOptions(client: *Client, options: ConnectTcpOptions) ConnectTcp
|
|
|
1469
1464
|
error.Canceled => |e| return e,
|
|
1470
1465
|
else => return error.TlsInitializationFailed,
|
|
1471
1466
|
};
|
|
1472
|
-
|
|
1467
|
+
errdefer tc.destroy();
|
|
1468
|
+
try client.connection_pool.addUsed(io, &tc.connection);
|
|
1473
1469
|
return &tc.connection;
|
|
1474
1470
|
},
|
|
1475
1471
|
.plain => {
|
|
1476
1472
|
const pc = try Connection.Plain.create(client, proxied_host, proxied_port, stream);
|
|
1477
|
-
|
|
1473
|
+
errdefer pc.destroy();
|
|
1474
|
+
try client.connection_pool.addUsed(io, &pc.connection);
|
|
1478
1475
|
return &pc.connection;
|
|
1479
1476
|
},
|
|
1480
1477
|
}
|
|
1481
1478
|
}
|
|
1482
1479
|
|
|
1483
|
-
pub const ConnectUnixError = Allocator.Error || std.posix.SocketError || error{NameTooLong} || std.posix.ConnectError;
|
|
1480
|
+
pub const ConnectUnixError = Allocator.Error || std.posix.SocketError || error{NameTooLong} || std.posix.ConnectError || Io.Cancelable;
|
|
1484
1481
|
|
|
1485
1482
|
/// Connect to `path` as a unix domain socket. This will reuse a connection if one is already open.
|
|
1486
1483
|
///
|
|
@@ -1488,7 +1485,7 @@ pub const ConnectUnixError = Allocator.Error || std.posix.SocketError || error{N
|
|
|
1488
1485
|
pub fn connectUnix(client: *Client, path: []const u8) ConnectUnixError!*Connection {
|
|
1489
1486
|
const io = client.io;
|
|
1490
1487
|
|
|
1491
|
-
if (client.connection_pool.findConnection(io, .{
|
|
1488
|
+
if (try client.connection_pool.findConnection(io, .{
|
|
1492
1489
|
.host = path,
|
|
1493
1490
|
.port = 0,
|
|
1494
1491
|
.protocol = .plain,
|
|
@@ -1512,7 +1509,7 @@ pub fn connectUnix(client: *Client, path: []const u8) ConnectUnixError!*Connecti
|
|
|
1512
1509
|
};
|
|
1513
1510
|
errdefer client.allocator.free(conn.data.host);
|
|
1514
1511
|
|
|
1515
|
-
client.connection_pool.addUsed(conn);
|
|
1512
|
+
try client.connection_pool.addUsed(conn);
|
|
1516
1513
|
|
|
1517
1514
|
return &conn.data;
|
|
1518
1515
|
}
|
|
@@ -1530,7 +1527,7 @@ pub fn connectProxied(
|
|
|
1530
1527
|
const io = client.io;
|
|
1531
1528
|
if (!proxy.supports_connect) return error.TunnelNotSupported;
|
|
1532
1529
|
|
|
1533
|
-
if (client.connection_pool.findConnection(io, .{
|
|
1530
|
+
if (try client.connection_pool.findConnection(io, .{
|
|
1534
1531
|
.host = proxied_host,
|
|
1535
1532
|
.port = proxied_port,
|
|
1536
1533
|
.protocol = proxy.protocol,
|
package/std/sort.zig
CHANGED
|
@@ -749,9 +749,9 @@ test partitionPoint {
|
|
|
749
749
|
|
|
750
750
|
/// Returns a tuple of the lower and upper indices in `items` between which all
|
|
751
751
|
/// elements return `.eq` when given to `compareFn`.
|
|
752
|
-
///
|
|
753
|
-
///
|
|
754
|
-
///
|
|
752
|
+
/// If no element in `items` returns `.eq`, both indices are the index of the
|
|
753
|
+
/// first element in `items` which returns `.gt`, or if no element returns `.gt`,
|
|
754
|
+
/// both indices are `items.len`.
|
|
755
755
|
///
|
|
756
756
|
/// `items` must be sorted in ascending order with respect to `compareFn`:
|
|
757
757
|
/// ```
|
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 ========================= */
|