Skip to content

Commit 9cf28d1

Browse files
authored
Merge pull request #19214 from mlugg/fuck-usingnamespace
std: fuck usingnamespace
2 parents f322759 + 265f42d commit 9cf28d1

File tree

9 files changed

+3230
-3326
lines changed

9 files changed

+3230
-3326
lines changed

CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -291,7 +291,8 @@ set(ZIG_STAGE2_SOURCES
291291
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/errno/generic.zig"
292292
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
293293
"${CMAKE_SOURCE_DIR}/lib/std/os/linux.zig"
294-
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring.zig"
294+
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/IoUring.zig"
295+
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/io_uring_sqe.zig"
295296
"${CMAKE_SOURCE_DIR}/lib/std/os/linux/x86_64.zig"
296297
"${CMAKE_SOURCE_DIR}/lib/std/os/windows.zig"
297298
"${CMAKE_SOURCE_DIR}/lib/std/os/windows/ntstatus.zig"

lib/std/c.zig

Lines changed: 28 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1494,38 +1494,33 @@ pub const speed_t = switch (native_os) {
14941494
pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
14951495

14961496
// Unix-like systems
1497-
pub usingnamespace switch (native_os) {
1498-
.netbsd, .windows => struct {},
1499-
else => struct {
1500-
pub const DIR = opaque {};
1501-
pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR;
1502-
pub extern "c" fn fdopendir(fd: c_int) ?*DIR;
1503-
pub extern "c" fn rewinddir(dp: *DIR) void;
1504-
pub extern "c" fn closedir(dp: *DIR) c_int;
1505-
pub extern "c" fn telldir(dp: *DIR) c_long;
1506-
pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;
1497+
pub const DIR = opaque {};
1498+
pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR;
1499+
pub extern "c" fn fdopendir(fd: c_int) ?*DIR;
1500+
pub extern "c" fn rewinddir(dp: *DIR) void;
1501+
pub extern "c" fn closedir(dp: *DIR) c_int;
1502+
pub extern "c" fn telldir(dp: *DIR) c_long;
1503+
pub extern "c" fn seekdir(dp: *DIR, loc: c_long) void;
15071504

1508-
pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
1509-
pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
1510-
pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
1511-
pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
1505+
pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;
1506+
pub extern "c" fn clock_getres(clk_id: c_int, tp: *c.timespec) c_int;
1507+
pub extern "c" fn gettimeofday(noalias tv: ?*c.timeval, noalias tz: ?*c.timezone) c_int;
1508+
pub extern "c" fn nanosleep(rqtp: *const c.timespec, rmtp: ?*c.timespec) c_int;
15121509

1513-
pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
1510+
pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
15141511

1515-
pub extern "c" fn sched_yield() c_int;
1512+
pub extern "c" fn sched_yield() c_int;
15161513

1517-
pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
1518-
pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
1519-
pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
1520-
pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
1514+
pub extern "c" fn sigaction(sig: c_int, noalias act: ?*const c.Sigaction, noalias oact: ?*c.Sigaction) c_int;
1515+
pub extern "c" fn sigprocmask(how: c_int, noalias set: ?*const c.sigset_t, noalias oset: ?*c.sigset_t) c_int;
1516+
pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
1517+
pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;
15211518

1522-
pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
1519+
pub extern "c" fn socket(domain: c_uint, sock_type: c_uint, protocol: c_uint) c_int;
15231520

1524-
pub extern "c" fn alarm(seconds: c_uint) c_uint;
1521+
pub extern "c" fn alarm(seconds: c_uint) c_uint;
15251522

1526-
pub extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
1527-
},
1528-
};
1523+
pub extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
15291524

15301525
pub const fstat = switch (native_os) {
15311526
.macos => switch (native_arch) {
@@ -1863,16 +1858,14 @@ pub extern "c" fn setlogmask(maskpri: c_int) c_int;
18631858

18641859
pub extern "c" fn if_nametoindex([*:0]const u8) c_int;
18651860

1866-
pub usingnamespace if (builtin.target.isAndroid()) struct {
1867-
// android bionic libc does not implement getcontext,
1868-
// and std.os.linux.getcontext also cannot be built for
1869-
// bionic libc currently.
1870-
} else if (native_os == .linux and builtin.target.isMusl()) struct {
1871-
// musl does not implement getcontext
1872-
pub const getcontext = std.os.linux.getcontext;
1873-
} else struct {
1874-
pub extern "c" fn getcontext(ucp: *std.os.ucontext_t) c_int;
1875-
};
1861+
pub const getcontext = if (builtin.target.isAndroid())
1862+
@compileError("android bionic libc does not implement getcontext")
1863+
else if (native_os == .linux and builtin.target.isMusl())
1864+
std.os.linux.getcontext
1865+
else
1866+
struct {
1867+
extern fn getcontext(ucp: *std.os.ucontext_t) c_int;
1868+
}.getcontext;
18761869

18771870
pub const max_align_t = if (native_abi == .msvc)
18781871
f64

lib/std/c/openbsd.zig

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -894,11 +894,6 @@ comptime {
894894
std.debug.assert(@sizeOf(siginfo_t) == 136);
895895
}
896896

897-
pub usingnamespace switch (builtin.cpu.arch) {
898-
.x86_64 => struct {},
899-
else => struct {},
900-
};
901-
902897
pub const ucontext_t = switch (builtin.cpu.arch) {
903898
.x86_64 => extern struct {
904899
sc_rdi: c_long,

0 commit comments

Comments
 (0)