@zigc/lib 0.17.0-dev.39 → 0.17.0-dev.56

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 CHANGED
@@ -116,13 +116,9 @@ fn atanf(x: f32) callconv(.c) f32 {
116
116
  }
117
117
 
118
118
  fn atanl(x: c_longdouble) callconv(.c) c_longdouble {
119
- return switch (@typeInfo(@TypeOf(x)).float.bits) {
120
- 16 => math.atan(@as(f16, @floatCast(x))),
121
- 32 => math.atan(@as(f32, @floatCast(x))),
122
- 64 => math.atan(@as(f64, @floatCast(x))),
123
- 80 => math.atan(@as(f80, @floatCast(x))),
124
- 128 => math.atan(@as(f128, @floatCast(x))),
125
- else => unreachable,
119
+ return switch (@typeInfo(c_longdouble).float.bits) {
120
+ 64 => std.c.atan(x),
121
+ else => math.atan(x),
126
122
  };
127
123
  }
128
124
 
@@ -143,7 +139,10 @@ fn copysignf(x: f32, y: f32) callconv(.c) f32 {
143
139
  }
144
140
 
145
141
  fn copysignl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
146
- return math.copysign(x, y);
142
+ return switch (@typeInfo(c_longdouble).float.bits) {
143
+ 64 => std.c.copysign(x, y),
144
+ else => math.copysign(x, y),
145
+ };
147
146
  }
148
147
 
149
148
  fn cosh(x: f64) callconv(.c) f64 {
@@ -183,15 +182,18 @@ fn fdimf(x: f32, y: f32) callconv(.c) f32 {
183
182
  }
184
183
 
185
184
  fn fdiml(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
186
- return fdimGeneric(c_longdouble, x, y);
185
+ return switch (@typeInfo(c_longdouble).float.bits) {
186
+ 64 => std.c.fdim(x, y),
187
+ else => fdimGeneric(c_longdouble, x, y),
188
+ };
187
189
  }
188
190
 
189
191
  fn finite(x: f64) callconv(.c) c_int {
190
- return if (math.isFinite(x)) 1 else 0;
192
+ return @intFromBool(math.isFinite(x));
191
193
  }
192
194
 
193
195
  fn finitef(x: f32) callconv(.c) c_int {
194
- return if (math.isFinite(x)) 1 else 0;
196
+ return @intFromBool(math.isFinite(x));
195
197
  }
196
198
 
197
199
  fn frexpGeneric(comptime T: type, x: T, e: *c_int) T {
@@ -222,7 +224,10 @@ fn frexpf(x: f32, e: *c_int) callconv(.c) f32 {
222
224
  }
223
225
 
224
226
  fn frexpl(x: c_longdouble, e: *c_int) callconv(.c) c_longdouble {
225
- return frexpGeneric(c_longdouble, x, e);
227
+ return switch (@typeInfo(c_longdouble).float.bits) {
228
+ 64 => std.c.frexp(x, e),
229
+ else => frexpGeneric(c_longdouble, x, e),
230
+ };
226
231
  }
227
232
 
228
233
  fn hypot(x: f64, y: f64) callconv(.c) f64 {
@@ -234,19 +239,22 @@ fn hypotf(x: f32, y: f32) callconv(.c) f32 {
234
239
  }
235
240
 
236
241
  fn hypotl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
237
- return math.hypot(x, y);
242
+ return switch (@typeInfo(c_longdouble).float.bits) {
243
+ 64 => std.c.hypot(x, y),
244
+ else => math.hypot(x, y),
245
+ };
238
246
  }
239
247
 
240
248
  fn isnan(x: f64) callconv(.c) c_int {
241
- return if (math.isNan(x)) 1 else 0;
249
+ return @intFromBool(math.isNan(x));
242
250
  }
243
251
 
244
252
  fn isnanf(x: f32) callconv(.c) c_int {
245
- return if (math.isNan(x)) 1 else 0;
253
+ return @intFromBool(math.isNan(x));
246
254
  }
247
255
 
248
256
  fn isnanl(x: c_longdouble) callconv(.c) c_int {
249
- return if (math.isNan(x)) 1 else 0;
257
+ return @intFromBool(math.isNan(x));
250
258
  }
251
259
 
252
260
  fn lrint(x: f64) callconv(.c) c_long {
@@ -290,7 +298,10 @@ fn modff(x: f32, iptr: *f32) callconv(.c) f32 {
290
298
  }
291
299
 
292
300
  fn modfl(x: c_longdouble, iptr: *c_longdouble) callconv(.c) c_longdouble {
293
- return modfGeneric(c_longdouble, x, iptr);
301
+ return switch (@typeInfo(c_longdouble).float.bits) {
302
+ 64 => std.c.modf(x, iptr),
303
+ else => modfGeneric(c_longdouble, x, iptr),
304
+ };
294
305
  }
295
306
 
296
307
  fn testModf(comptime T: type) !void {
@@ -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" },
@@ -173,8 +173,6 @@ pub fn cosq(x: f128) callconv(.c) f128 {
173
173
 
174
174
  pub fn cosl(x: c_longdouble) callconv(.c) c_longdouble {
175
175
  switch (@typeInfo(c_longdouble).float.bits) {
176
- 16 => return cosh(x),
177
- 32 => return cosf(x),
178
176
  64 => return cos(x),
179
177
  80 => return cosx(x),
180
178
  128 => return cosq(x),
@@ -198,8 +198,6 @@ const expq = @import("exp_f128.zig").exp;
198
198
 
199
199
  pub fn expl(x: c_longdouble) callconv(.c) c_longdouble {
200
200
  switch (@typeInfo(c_longdouble).float.bits) {
201
- 16 => return __exph(x),
202
- 32 => return expf(x),
203
201
  64 => return exp(x),
204
202
  80 => return __expx(x),
205
203
  128 => return expq(x),
@@ -165,8 +165,6 @@ pub const exp2q = @import("exp_f128.zig").exp2;
165
165
 
166
166
  pub fn exp2l(x: c_longdouble) callconv(.c) c_longdouble {
167
167
  switch (@typeInfo(c_longdouble).float.bits) {
168
- 16 => return __exp2h(x),
169
- 32 => return exp2f(x),
170
168
  64 => return exp2(x),
171
169
  80 => return __exp2x(x),
172
170
  128 => return exp2q(x),
@@ -38,8 +38,6 @@ pub fn fabsq(a: f128) callconv(.c) f128 {
38
38
 
39
39
  pub fn fabsl(x: c_longdouble) callconv(.c) c_longdouble {
40
40
  switch (@typeInfo(c_longdouble).float.bits) {
41
- 16 => return __fabsh(x),
42
- 32 => return fabsf(x),
43
41
  64 => return fabs(x),
44
42
  80 => return __fabsx(x),
45
43
  128 => return fabsq(x),
@@ -151,8 +151,6 @@ pub fn fmaq(x: f128, y: f128, z: f128) callconv(.c) f128 {
151
151
 
152
152
  pub fn fmal(x: c_longdouble, y: c_longdouble, z: c_longdouble) callconv(.c) c_longdouble {
153
153
  switch (@typeInfo(c_longdouble).float.bits) {
154
- 16 => return __fmah(x, y, z),
155
- 32 => return fmaf(x, y, z),
156
154
  64 => return fma(x, y, z),
157
155
  80 => return __fmax(x, y, z),
158
156
  128 => return fmaq(x, y, z),
@@ -39,8 +39,6 @@ pub fn fmaxq(x: f128, y: f128) callconv(.c) f128 {
39
39
 
40
40
  pub fn fmaxl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
41
41
  switch (@typeInfo(c_longdouble).float.bits) {
42
- 16 => return __fmaxh(x, y),
43
- 32 => return fmaxf(x, y),
44
42
  64 => return fmax(x, y),
45
43
  80 => return __fmaxx(x, y),
46
44
  128 => return fmaxq(x, y),
@@ -39,8 +39,6 @@ pub fn fminq(x: f128, y: f128) callconv(.c) f128 {
39
39
 
40
40
  pub fn fminl(x: c_longdouble, y: c_longdouble) callconv(.c) c_longdouble {
41
41
  switch (@typeInfo(c_longdouble).float.bits) {
42
- 16 => return __fminh(x, y),
43
- 32 => return fminf(x, y),
44
42
  64 => return fmin(x, y),
45
43
  80 => return __fminx(x, y),
46
44
  128 => return fminq(x, y),
@@ -251,8 +251,6 @@ pub fn fmodq(a: f128, b: f128) callconv(.c) f128 {
251
251
 
252
252
  pub fn fmodl(a: c_longdouble, b: c_longdouble) callconv(.c) c_longdouble {
253
253
  switch (@typeInfo(c_longdouble).float.bits) {
254
- 16 => return __fmodh(a, b),
255
- 32 => return fmodf(a, b),
256
254
  64 => return fmod(a, b),
257
255
  80 => return __fmodx(a, b),
258
256
  128 => return fmodq(a, b),
@@ -443,8 +443,6 @@ pub fn logq(a: f128) callconv(.c) f128 {
443
443
 
444
444
  pub fn logl(x: c_longdouble) callconv(.c) c_longdouble {
445
445
  switch (@typeInfo(c_longdouble).float.bits) {
446
- 16 => return __logh(x),
447
- 32 => return logf(x),
448
446
  64 => return log(x),
449
447
  80 => return __logx(x),
450
448
  128 => return logq(x),
@@ -177,8 +177,6 @@ pub fn log10q(a: f128) callconv(.c) f128 {
177
177
 
178
178
  pub fn log10l(x: c_longdouble) callconv(.c) c_longdouble {
179
179
  switch (@typeInfo(c_longdouble).float.bits) {
180
- 16 => return __log10h(x),
181
- 32 => return log10f(x),
182
180
  64 => return log10(x),
183
181
  80 => return __log10x(x),
184
182
  128 => return log10q(x),
@@ -170,8 +170,6 @@ pub fn log2q(a: f128) callconv(.c) f128 {
170
170
 
171
171
  pub fn log2l(x: c_longdouble) callconv(.c) c_longdouble {
172
172
  switch (@typeInfo(c_longdouble).float.bits) {
173
- 16 => return __log2h(x),
174
- 32 => return log2f(x),
175
173
  64 => return log2(x),
176
174
  80 => return __log2x(x),
177
175
  128 => return log2q(x),
@@ -142,8 +142,6 @@ pub fn roundq(x_: f128) callconv(.c) f128 {
142
142
 
143
143
  pub fn roundl(x: c_longdouble) callconv(.c) c_longdouble {
144
144
  switch (@typeInfo(c_longdouble).float.bits) {
145
- 16 => return __roundh(x),
146
- 32 => return roundf(x),
147
145
  64 => return round(x),
148
146
  80 => return __roundx(x),
149
147
  128 => return roundq(x),
@@ -189,8 +189,6 @@ pub fn sinq(x: f128) callconv(.c) f128 {
189
189
 
190
190
  pub fn sinl(x: c_longdouble) callconv(.c) c_longdouble {
191
191
  switch (@typeInfo(c_longdouble).float.bits) {
192
- 16 => return sinh(x),
193
- 32 => return sinf(x),
194
192
  64 => return sin(x),
195
193
  80 => return sinx(x),
196
194
  128 => return sinq(x),
@@ -292,8 +292,6 @@ pub fn sincosq(x: f128, r_sin: *f128, r_cos: *f128) callconv(.c) void {
292
292
 
293
293
  pub fn sincosl(x: c_longdouble, r_sin: *c_longdouble, r_cos: *c_longdouble) callconv(.c) void {
294
294
  switch (@typeInfo(c_longdouble).float.bits) {
295
- 16 => return sincosh(x, r_sin, r_cos),
296
- 32 => return sincosf(x, r_sin, r_cos),
297
295
  64 => return sincos(x, r_sin, r_cos),
298
296
  80 => return sincosx(x, r_sin, r_cos),
299
297
  128 => return sincosq(x, r_sin, r_cos),
@@ -481,8 +481,6 @@ fn _Qp_sqrt(c: *f128, a: *f128) callconv(.c) void {
481
481
 
482
482
  pub fn sqrtl(x: c_longdouble) callconv(.c) c_longdouble {
483
483
  switch (@typeInfo(c_longdouble).float.bits) {
484
- 16 => return __sqrth(x),
485
- 32 => return sqrtf(x),
486
484
  64 => return sqrt(x),
487
485
  80 => return __sqrtx(x),
488
486
  128 => return sqrtq(x),
@@ -164,8 +164,6 @@ pub fn tanq(x: f128) callconv(.c) f128 {
164
164
 
165
165
  pub fn tanl(x: c_longdouble) callconv(.c) c_longdouble {
166
166
  switch (@typeInfo(c_longdouble).float.bits) {
167
- 16 => return tanh(x),
168
- 32 => return tanf(x),
169
167
  64 => return tan(x),
170
168
  80 => return tanx(x),
171
169
  128 => return tanq(x),
@@ -99,8 +99,6 @@ pub fn truncq(x: f128) callconv(.c) f128 {
99
99
 
100
100
  pub fn truncl(x: c_longdouble) callconv(.c) c_longdouble {
101
101
  switch (@typeInfo(c_longdouble).float.bits) {
102
- 16 => return __trunch(x),
103
- 32 => return truncf(x),
104
102
  64 => return trunc(x),
105
103
  80 => return __truncx(x),
106
104
  128 => return truncq(x),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zigc/lib",
3
- "version": "0.17.0-dev.39",
3
+ "version": "0.17.0-dev.56",
4
4
  "description": "Zig standard library and libc headers (shared across all platforms)",
5
5
  "repository": {
6
6
  "type": "git",
@@ -459,7 +459,6 @@ pub fn io(ev: *Evented) Io {
459
459
  .netConnectUnix = netConnectUnixUnavailable,
460
460
  .netSocketCreatePair = netSocketCreatePairUnavailable,
461
461
  .netSend = netSendUnavailable,
462
- .netRead = netReadUnavailable,
463
462
  .netWrite = netWriteUnavailable,
464
463
  .netWriteFile = netWriteFileUnavailable,
465
464
  .netClose = netClose,
@@ -1713,6 +1712,7 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
1713
1712
  },
1714
1713
  .device_io_control => |*o| return .{ .device_io_control = try deviceIoControl(o) },
1715
1714
  .net_receive => @panic("TODO implement net_receive operation"),
1715
+ .net_read => @panic("TODO implement net_read operation"),
1716
1716
  }
1717
1717
  }
1718
1718
 
@@ -2134,6 +2134,7 @@ fn batchDrainSubmitted(
2134
2134
  },
2135
2135
  .device_io_control => {},
2136
2136
  .net_receive => @panic("TODO implement batched net_receive"),
2137
+ .net_read => @panic("TODO implement batched net_read"),
2137
2138
  };
2138
2139
  if (concurrency) return error.ConcurrencyUnavailable;
2139
2140
  break :result try operate(ev, storage.submission.operation);
@@ -2193,6 +2194,7 @@ fn batchSourceEvent(context: ?*anyopaque) callconv(.c) void {
2193
2194
  },
2194
2195
  .device_io_control => unreachable,
2195
2196
  .net_receive => @panic("TODO implement batched net_receive"),
2197
+ .net_read => @panic("TODO implement batched net_read"),
2196
2198
  };
2197
2199
 
2198
2200
  switch (pending.node.prev) {
@@ -4877,18 +4879,6 @@ fn netSendUnavailable(
4877
4879
  return .{ error.NetworkDown, 0 };
4878
4880
  }
4879
4881
 
4880
- fn netReadUnavailable(
4881
- userdata: ?*anyopaque,
4882
- fd: net.Socket.Handle,
4883
- data: [][]u8,
4884
- ) net.Stream.Reader.Error!usize {
4885
- const ev: *Evented = @ptrCast(@alignCast(userdata));
4886
- _ = ev;
4887
- _ = fd;
4888
- _ = data;
4889
- return error.NetworkDown;
4890
- }
4891
-
4892
4882
  fn netWriteUnavailable(
4893
4883
  userdata: ?*anyopaque,
4894
4884
  handle: net.Socket.Handle,
@@ -1943,10 +1943,6 @@ pub fn io(t: *Threaded) Io {
1943
1943
  .windows => netShutdownWindows,
1944
1944
  else => netShutdownPosix,
1945
1945
  },
1946
- .netRead = switch (native_os) {
1947
- .windows => netReadWindows,
1948
- else => netReadPosix,
1949
- },
1950
1946
  .netWrite = switch (native_os) {
1951
1947
  .windows => netWriteWindows,
1952
1948
  else => netWritePosix,
@@ -2566,6 +2562,12 @@ fn operate(userdata: ?*anyopaque, operation: Io.Operation) Io.Cancelable!Io.Oper
2566
2562
  };
2567
2563
  break :o .{ null, 1 };
2568
2564
  } },
2565
+ .net_read => |o| return .{
2566
+ .net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
2567
+ error.Canceled => |e| return e,
2568
+ else => |e| e,
2569
+ },
2570
+ },
2569
2571
  }
2570
2572
  }
2571
2573
 
@@ -2621,6 +2623,14 @@ fn batchAwaitAsync(userdata: ?*anyopaque, b: *Io.Batch) Io.Cancelable!void {
2621
2623
  };
2622
2624
  poll_len += 1;
2623
2625
  },
2626
+ .net_read => |o| {
2627
+ poll_buffer[poll_len] = .{
2628
+ .fd = o.socket_handle,
2629
+ .events = posix.POLL.IN | posix.POLL.ERR,
2630
+ .revents = 0,
2631
+ };
2632
+ poll_len += 1;
2633
+ },
2624
2634
  }
2625
2635
  index = submission.node.next;
2626
2636
  }
@@ -2798,6 +2808,7 @@ fn batchAwaitConcurrent(userdata: ?*anyopaque, b: *Io.Batch, timeout: Io.Timeout
2798
2808
  storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
2799
2809
  b.completed.tail = index;
2800
2810
  },
2811
+ .net_read => |o| try poll_storage.add(o.socket_handle, posix.POLL.IN | posix.POLL.ERR),
2801
2812
  }
2802
2813
  index = submission.node.next;
2803
2814
  }
@@ -2993,6 +3004,7 @@ fn batchApc(
2993
3004
  .file_write_streaming => .{ .file_write_streaming = ntWriteFileResult(iosb) },
2994
3005
  .device_io_control => .{ .device_io_control = iosb.* },
2995
3006
  .net_receive => unreachable,
3007
+ .net_read => unreachable,
2996
3008
  };
2997
3009
  storage.* = .{ .completion = .{ .node = .{ .next = .none }, .result = result } };
2998
3010
  },
@@ -3201,6 +3213,16 @@ fn batchDrainSubmittedWindows(t: *Threaded, b: *Io.Batch, concurrency: bool) (Io
3201
3213
  .net_receive = netReceiveWindows(t, o.socket_handle, o.message_buffer, o.data_buffer, o.flags),
3202
3214
  });
3203
3215
  },
3216
+ .net_read => |*o| {
3217
+ // TODO integrate with overlapped I/O or equivalent to avoid this error
3218
+ if (concurrency) return error.ConcurrencyUnavailable;
3219
+ batchCompleteBlockingWindows(b, operation_userdata, .{
3220
+ .net_read = netRead(o.socket_handle, o.data) catch |err| switch (err) {
3221
+ error.Canceled => |e| return e,
3222
+ else => |e| e,
3223
+ },
3224
+ });
3225
+ },
3204
3226
  }
3205
3227
  index = submission.node.next;
3206
3228
  }
@@ -5345,7 +5367,7 @@ fn dirOpenDirHaiku(
5345
5367
  .NOMEM => return error.SystemResources,
5346
5368
  .NOTDIR => return error.NotDir,
5347
5369
  .PERM => return error.PermissionDenied,
5348
- .BUSY => return error.DeviceBusy,
5370
+ .BUSY => |err| return errnoBug(err),
5349
5371
  else => |err| return posix.unexpectedErrno(err),
5350
5372
  }
5351
5373
  },
@@ -5791,10 +5813,119 @@ fn dirReadIllumos(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) D
5791
5813
  }
5792
5814
 
5793
5815
  fn dirReadHaiku(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
5794
- _ = userdata;
5795
- _ = dr;
5796
- _ = buffer;
5797
- @panic("TODO implement dirReadHaiku");
5816
+ const t: *Threaded = @ptrCast(@alignCast(userdata));
5817
+ _ = t;
5818
+ var buffer_index: usize = 0;
5819
+ while (buffer.len - buffer_index != 0) {
5820
+ if (dr.end - dr.index == 0) {
5821
+ // Refill the buffer, unless we've already created references to
5822
+ // buffered data.
5823
+ if (buffer_index != 0) break;
5824
+ if (dr.state == .reset) {
5825
+ const syscall: Syscall = try .start();
5826
+ while (true) {
5827
+ const rc = posix.system._kern_rewind_dir(dr.dir.handle);
5828
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5829
+ .SUCCESS => {
5830
+ syscall.finish();
5831
+ break;
5832
+ },
5833
+ .INTR => {
5834
+ try syscall.checkCancel();
5835
+ continue;
5836
+ },
5837
+ else => |e| {
5838
+ syscall.finish();
5839
+ switch (e) {
5840
+ else => |err| return posix.unexpectedErrno(err),
5841
+ }
5842
+ },
5843
+ }
5844
+ }
5845
+ dr.state = .reading;
5846
+ }
5847
+ const syscall: Syscall = try .start();
5848
+ const n: usize = while (true) {
5849
+ const rc = posix.system._kern_read_dir(dr.dir.handle, dr.buffer.ptr, dr.buffer.len, @truncate(dr.buffer.len / @sizeOf(posix.system.DirEnt)));
5850
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5851
+ .SUCCESS => {
5852
+ syscall.finish();
5853
+ break @intCast(rc);
5854
+ },
5855
+ .INTR => {
5856
+ try syscall.checkCancel();
5857
+ continue;
5858
+ },
5859
+ else => |e| {
5860
+ syscall.finish();
5861
+ switch (e) {
5862
+ else => |err| return posix.unexpectedErrno(err),
5863
+ }
5864
+ },
5865
+ }
5866
+ };
5867
+ if (n == 0) {
5868
+ dr.state = .finished;
5869
+ return 0;
5870
+ }
5871
+ dr.index = 0;
5872
+ // _kern_read_dir returns entry count, but Dir.Reader is designed for byte count
5873
+ dr.end = 0;
5874
+ var i: usize = 0;
5875
+ while (i < n) : (i += 1) {
5876
+ const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.end]));
5877
+ dr.end += entry.reclen;
5878
+ }
5879
+ }
5880
+ const entry = @as(*align(1) posix.system.DirEnt, @ptrCast(&dr.buffer[dr.index]));
5881
+ const next_index = dr.index + entry.reclen;
5882
+ dr.index = next_index;
5883
+
5884
+ const name = std.mem.sliceTo(@as([*:0]u8, @ptrCast(&entry.name)), 0);
5885
+ if (std.mem.eql(u8, name, ".") or std.mem.eql(u8, name, "..") or entry.ino == 0) continue;
5886
+
5887
+ // haiku dirent doesn't expose type, so we have to call stat to get it.
5888
+ var stat: std.c.Stat = undefined;
5889
+ {
5890
+ const syscall: Syscall = try .start();
5891
+ while (true) {
5892
+ const rc = posix.system._kern_read_stat(dr.dir.handle, name, false, &stat, @sizeOf(std.c.Stat));
5893
+ switch (@as(posix.E, @enumFromInt(@min(rc, 0)))) {
5894
+ .SUCCESS => {
5895
+ syscall.finish();
5896
+ break;
5897
+ },
5898
+ .INTR => {
5899
+ try syscall.checkCancel();
5900
+ continue;
5901
+ },
5902
+ else => |e| {
5903
+ syscall.finish();
5904
+ switch (e) {
5905
+ else => |err| return posix.unexpectedErrno(err),
5906
+ }
5907
+ },
5908
+ }
5909
+ }
5910
+ }
5911
+
5912
+ const entry_kind: File.Kind = switch (stat.mode & posix.S.IFMT) {
5913
+ posix.S.IFBLK => .block_device,
5914
+ posix.S.IFCHR => .character_device,
5915
+ posix.S.IFDIR => .directory,
5916
+ posix.S.IFIFO => .named_pipe,
5917
+ posix.S.IFLNK => .sym_link,
5918
+ posix.S.IFREG => .file,
5919
+ else => .unknown,
5920
+ };
5921
+ buffer[buffer_index] = .{
5922
+ .name = name,
5923
+ .kind = entry_kind,
5924
+ .inode = entry.ino,
5925
+ };
5926
+ buffer_index += 1;
5927
+ }
5928
+ return buffer_index;
5798
5929
  }
5799
5930
 
5800
5931
  fn dirReadWindows(userdata: ?*anyopaque, dr: *Dir.Reader, buffer: []Dir.Entry) Dir.Reader.Error!usize {
@@ -9812,7 +9943,10 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
9812
9943
  if (have_preadv) {
9813
9944
  const syscall: Syscall = try .start();
9814
9945
  while (true) {
9815
- const rc = preadv_sym(file.handle, dest.ptr, @intCast(dest.len), @bitCast(offset));
9946
+ const rc = if (native_os == .haiku)
9947
+ posix.system.readv_pos(file.handle, @bitCast(offset), dest.ptr, @intCast(dest.len))
9948
+ else
9949
+ preadv_sym(file.handle, dest.ptr, @intCast(dest.len), @bitCast(offset));
9816
9950
  switch (posix.errno(rc)) {
9817
9951
  .SUCCESS => {
9818
9952
  syscall.finish();
@@ -9846,7 +9980,7 @@ fn fileReadPositionalPosix(file: File, data: []const []u8, offset: u64) File.Rea
9846
9980
 
9847
9981
  const syscall: Syscall = try .start();
9848
9982
  while (true) {
9849
- const rc = posix.pread(file.handle, dest[0].ptr, @intCast(dest[0].len), @bitCast(offset));
9983
+ const rc = pread_sym(file.handle, dest[0].base, @intCast(dest[0].len), @bitCast(offset));
9850
9984
  switch (posix.errno(rc)) {
9851
9985
  .SUCCESS => {
9852
9986
  syscall.finish();
@@ -10550,7 +10684,10 @@ fn fileWritePositional(
10550
10684
 
10551
10685
  const syscall: Syscall = try .start();
10552
10686
  while (true) {
10553
- const rc = pwritev_sym(file.handle, &iovecs, @intCast(iovlen), @bitCast(offset));
10687
+ const rc = if (native_os == .haiku)
10688
+ posix.system.writev_pos(file.handle, @bitCast(offset), &iovecs, @intCast(iovlen))
10689
+ else
10690
+ pwritev_sym(file.handle, &iovecs, @intCast(iovlen), @bitCast(offset));
10554
10691
  switch (posix.errno(rc)) {
10555
10692
  .SUCCESS => {
10556
10693
  syscall.finish();
@@ -12549,11 +12686,14 @@ fn deferAcceptAfd(t: *Threaded, listen_handle: net.Socket.Handle, info: windows.
12549
12686
  }
12550
12687
  }
12551
12688
 
12552
- fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12689
+ fn netRead(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12553
12690
  if (!have_networking) return error.NetworkDown;
12554
- const t: *Threaded = @ptrCast(@alignCast(userdata));
12555
- _ = t;
12556
12691
 
12692
+ if (is_windows) return netReadWindows(socket_handle, data);
12693
+ return netReadPosix(socket_handle, data);
12694
+ }
12695
+
12696
+ fn netReadPosix(fd: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12557
12697
  var iovecs_buffer: [max_iovecs_len]posix.iovec = undefined;
12558
12698
  var i: usize = 0;
12559
12699
  for (data) |buf| {
@@ -12590,7 +12730,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12590
12730
  .NOMEM => return error.SystemResources,
12591
12731
  .NOTCONN => return error.SocketUnconnected,
12592
12732
  .CONNRESET => return error.ConnectionResetByPeer,
12593
- .TIMEDOUT => return error.Timeout,
12594
12733
  .NOTCAPABLE => return error.AccessDenied,
12595
12734
  else => |err| return posix.unexpectedErrno(err),
12596
12735
  }
@@ -12622,7 +12761,6 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12622
12761
  .NOMEM => return error.SystemResources,
12623
12762
  .NOTCONN => return error.SocketUnconnected,
12624
12763
  .CONNRESET => return error.ConnectionResetByPeer,
12625
- .TIMEDOUT => return error.Timeout,
12626
12764
  .PIPE => return error.SocketUnconnected,
12627
12765
  .NETDOWN => return error.NetworkDown,
12628
12766
  else => |err| return posix.unexpectedErrno(err),
@@ -12632,11 +12770,7 @@ fn netReadPosix(userdata: ?*anyopaque, fd: net.Socket.Handle, data: [][]u8) net.
12632
12770
  }
12633
12771
  }
12634
12772
 
12635
- fn netReadWindows(userdata: ?*anyopaque, socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12636
- if (!have_networking) return error.NetworkDown;
12637
- const t: *Threaded = @ptrCast(@alignCast(userdata));
12638
- _ = t;
12639
-
12773
+ fn netReadWindows(socket_handle: net.Socket.Handle, data: [][]u8) net.Stream.Reader.Error!usize {
12640
12774
  var iovecs: [max_iovecs_len]windows.AFD.WSABUF(.@"var") = undefined;
12641
12775
  var len: u32 = 0;
12642
12776
  for (data) |buf| {
@@ -14063,7 +14197,7 @@ pub fn posixSocketModeProtocol(family: posix.sa_family_t, mode: net.Socket.Mode,
14063
14197
  .dgram => posix.SOCK.DGRAM,
14064
14198
  .seqpacket => posix.SOCK.SEQPACKET,
14065
14199
  .raw => posix.SOCK.RAW,
14066
- .rdm => posix.SOCK.RDM,
14200
+ .rdm => if (@hasDecl(posix.SOCK, "RDM")) posix.SOCK.RDM else return error.OptionUnsupported,
14067
14201
  },
14068
14202
  if (protocol) |p| @intFromEnum(p) else if (is_windows) switch (family) {
14069
14203
  posix.AF.UNIX => switch (mode) {