authorgravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-07 19:10:24+00:00
committergravatar for mlugg@mlugg.co.ukMatthew Lugg <mlugg@mlugg.co.uk> 2024-03-08 08:02:45+00:00
logf4bf061d8a8023ec2188f3ffdc861317da56fd44
tree98ae025f5f9fc9c468279c3918f344152bec97df
parent508a8739e25e5f4ddf75df336b7315949aa3201b
signaturelock-open Commit is signed but in an unrecognized format.

std.c: remove unnecessary use of `usingnamespace`

Thanks to Zig's lazy analysis, it's fine for these symbols to be declared on platform they won't exist on. This is already done in several places in this file; e.g. `pthread` functions are declared unconditionally. Eliminates one more usage of `usingnamespace` from the standard library. 4 remain.

1 files changed, 20 insertions(+), 25 deletions(-)

lib/std/c.zig+20-25
...@@ -1494,38 +1494,33 @@ pub const speed_t = switch (native_os) {...@@ -1494,38 +1494,33 @@ pub const speed_t = switch (native_os) {
1494pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;1494pub const whence_t = if (native_os == .wasi) std.os.wasi.whence_t else c_int;
14951495
1496// Unix-like systems1496// Unix-like systems
1497pub usingnamespace switch (native_os) {1497pub const DIR = opaque {};
1498 .netbsd, .windows => struct {},1498pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR;
1499 else => struct {1499pub extern "c" fn fdopendir(fd: c_int) ?*DIR;
1500 pub const DIR = opaque {};1500pub extern "c" fn rewinddir(dp: *DIR) void;
1501 pub extern "c" fn opendir(pathname: [*:0]const u8) ?*DIR;1501pub extern "c" fn closedir(dp: *DIR) c_int;
1502 pub extern "c" fn fdopendir(fd: c_int) ?*DIR;1502pub extern "c" fn telldir(dp: *DIR) c_long;
1503 pub extern "c" fn rewinddir(dp: *DIR) void;1503pub extern "c" fn seekdir(dp: *DIR, loc: c_long) 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;
15071504
1508 pub extern "c" fn clock_gettime(clk_id: c_int, tp: *c.timespec) c_int;1505pub 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;1506pub 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;1507pub 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;1508pub 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;1510pub extern "c" fn getrusage(who: c_int, usage: *c.rusage) c_int;
15141511
1515 pub extern "c" fn sched_yield() c_int;1512pub 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;1514pub 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;1515pub 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;1516pub extern "c" fn sigfillset(set: ?*c.sigset_t) void;
1520 pub extern "c" fn sigwait(set: ?*c.sigset_t, sig: ?*c_int) c_int;1517pub 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;1519pub 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;1521pub 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;1523pub extern "c" fn msync(addr: *align(page_size) const anyopaque, len: usize, flags: c_int) c_int;
1527 },
1528};
15291524
1530pub const fstat = switch (native_os) {1525pub const fstat = switch (native_os) {
1531 .macos => switch (native_arch) {1526 .macos => switch (native_arch) {