Skip to content

Commit 04e08ea

Browse files
authored
Merge pull request #20304 from ifreund/std-abi-fixes
std: fix a few ABI issues in the OS layer
2 parents 254a3ba + a1777cb commit 04e08ea

File tree

7 files changed

+21
-21
lines changed

7 files changed

+21
-21
lines changed

lib/std/Thread.zig

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
7575
}
7676
} else {
7777
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr);
78-
switch (err) {
78+
switch (@as(posix.E, @enumFromInt(err))) {
7979
.SUCCESS => return,
8080
.RANGE => unreachable,
8181
else => |e| return posix.unexpectedErrno(e),
@@ -119,14 +119,14 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
119119
if (self.getHandle() != std.c.pthread_self()) return error.Unsupported;
120120

121121
const err = std.c.pthread_setname_np(name_with_terminator.ptr);
122-
switch (err) {
122+
switch (@as(posix.E, @enumFromInt(err))) {
123123
.SUCCESS => return,
124124
else => |e| return posix.unexpectedErrno(e),
125125
}
126126
},
127127
.netbsd, .solaris, .illumos => if (use_pthreads) {
128128
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr, null);
129-
switch (err) {
129+
switch (@as(posix.E, @enumFromInt(err))) {
130130
.SUCCESS => return,
131131
.INVAL => unreachable,
132132
.SRCH => unreachable,
@@ -144,7 +144,7 @@ pub fn setName(self: Thread, name: []const u8) SetNameError!void {
144144
},
145145
.dragonfly => if (use_pthreads) {
146146
const err = std.c.pthread_setname_np(self.getHandle(), name_with_terminator.ptr);
147-
switch (err) {
147+
switch (@as(posix.E, @enumFromInt(err))) {
148148
.SUCCESS => return,
149149
.INVAL => unreachable,
150150
.FAULT => unreachable,
@@ -180,7 +180,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
180180
}
181181
} else {
182182
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
183-
switch (err) {
183+
switch (@as(posix.E, @enumFromInt(err))) {
184184
.SUCCESS => return std.mem.sliceTo(buffer, 0),
185185
.RANGE => unreachable,
186186
else => |e| return posix.unexpectedErrno(e),
@@ -219,15 +219,15 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
219219
},
220220
.macos, .ios, .watchos, .tvos, .visionos => if (use_pthreads) {
221221
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
222-
switch (err) {
222+
switch (@as(posix.E, @enumFromInt(err))) {
223223
.SUCCESS => return std.mem.sliceTo(buffer, 0),
224224
.SRCH => unreachable,
225225
else => |e| return posix.unexpectedErrno(e),
226226
}
227227
},
228228
.netbsd, .solaris, .illumos => if (use_pthreads) {
229229
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
230-
switch (err) {
230+
switch (@as(posix.E, @enumFromInt(err))) {
231231
.SUCCESS => return std.mem.sliceTo(buffer, 0),
232232
.INVAL => unreachable,
233233
.SRCH => unreachable,
@@ -243,7 +243,7 @@ pub fn getName(self: Thread, buffer_ptr: *[max_name_len:0]u8) GetNameError!?[]co
243243
},
244244
.dragonfly => if (use_pthreads) {
245245
const err = std.c.pthread_getname_np(self.getHandle(), buffer.ptr, max_name_len + 1);
246-
switch (err) {
246+
switch (@as(posix.E, @enumFromInt(err))) {
247247
.SUCCESS => return std.mem.sliceTo(buffer, 0),
248248
.INVAL => unreachable,
249249
.FAULT => unreachable,

lib/std/c/darwin.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -851,8 +851,8 @@ pub const pthread_attr_t = extern struct {
851851
};
852852

853853
pub extern "c" fn pthread_threadid_np(thread: ?std.c.pthread_t, thread_id: *u64) c_int;
854-
pub extern "c" fn pthread_setname_np(name: [*:0]const u8) E;
855-
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
854+
pub extern "c" fn pthread_setname_np(name: [*:0]const u8) c_int;
855+
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
856856
pub extern "c" fn pthread_attr_set_qos_class_np(attr: *pthread_attr_t, qos_class: qos_class_t, relative_priority: c_int) c_int;
857857
pub extern "c" fn pthread_attr_get_qos_class_np(attr: *pthread_attr_t, qos_class: *qos_class_t, relative_priority: *c_int) c_int;
858858
pub extern "c" fn pthread_set_qos_class_self_np(qos_class: qos_class_t, relative_priority: c_int) c_int;

lib/std/c/dragonfly.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@ pub const pthread_attr_t = extern struct { // copied from freebsd
2929

3030
pub const sem_t = ?*opaque {};
3131

32-
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E;
33-
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
32+
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int;
33+
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
3434

3535
pub extern "c" fn umtx_sleep(ptr: *const volatile c_int, value: c_int, timeout: c_int) c_int;
3636
pub extern "c" fn umtx_wakeup(ptr: *const volatile c_int, count: c_int) c_int;

lib/std/c/emscripten.zig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ pub const RTLD = struct {
171171
pub const LOCAL = 0;
172172
};
173173

174-
pub const dirent = struct {
174+
pub const dirent = extern struct {
175175
ino: c_uint,
176176
off: c_uint,
177177
reclen: c_ushort,

lib/std/c/linux.zig

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -318,8 +318,8 @@ pub const sem_t = extern struct {
318318

319319
const __SIZEOF_SEM_T = 4 * @sizeOf(usize);
320320

321-
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) E;
322-
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
321+
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8) c_int;
322+
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
323323

324324
pub const RTLD = struct {
325325
pub const LAZY = 1;
@@ -330,14 +330,14 @@ pub const RTLD = struct {
330330
pub const LOCAL = 0;
331331
};
332332

333-
pub const dirent = struct {
333+
pub const dirent = extern struct {
334334
ino: c_uint,
335335
off: c_uint,
336336
reclen: c_ushort,
337337
type: u8,
338338
name: [256]u8,
339339
};
340-
pub const dirent64 = struct {
340+
pub const dirent64 = extern struct {
341341
ino: c_ulong,
342342
off: c_ulong,
343343
reclen: c_ushort,

lib/std/c/netbsd.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,8 @@ pub const pthread_attr_t = extern struct {
5151

5252
pub const sem_t = ?*opaque {};
5353

54-
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) E;
55-
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
54+
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int;
55+
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
5656

5757
pub const blkcnt_t = i64;
5858
pub const blksize_t = i32;

lib/std/c/solaris.zig

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ pub const sem_t = extern struct {
3434
__pad2: [2]u64 = [_]u64{0} ** 2,
3535
};
3636

37-
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) E;
38-
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) E;
37+
pub extern "c" fn pthread_setname_np(thread: std.c.pthread_t, name: [*:0]const u8, arg: ?*anyopaque) c_int;
38+
pub extern "c" fn pthread_getname_np(thread: std.c.pthread_t, name: [*:0]u8, len: usize) c_int;
3939

4040
pub const blkcnt_t = i64;
4141
pub const blksize_t = i32;

0 commit comments

Comments
 (0)