mirror of
https://github.com/ziglang/zig.git
synced 2025-12-24 07:03:11 +00:00
The main purpose of this branch is to explore avoiding the `usingnamespace` feature of the zig language, specifically with regards to `std.os` and related functionality. If this experiment is successful, it will provide a data point on whether or not it would be practical to entirely remove `usingnamespace` from the language. In this commit, `usingnamespace` has been completely eliminated from the Linux x86_64 compilation path, aside from io_uring. The behavior tests pass, however that's as far as this branch goes. It is very breaking, and a lot more work is needed before it could be considered mergeable. I wanted to put a pull requset up early so that zig programmers have time to provide feedback. This is progress towards closing #6600 since it clarifies where the actual "owner" of each declaration is, and reduces the number of different ways to import the same declarations. One of the main organizational strategies used here is to do namespacing with real namespaces (e.g. structs) rather than by having declarations share a common prefix (the C strategy). It's no coincidence that `usingnamespace` has similar semantics to `#include` and becomes much less necessary when using proper namespaces.
54 lines
1023 B
Zig
54 lines
1023 B
Zig
extern threadlocal var errno: c_int;
|
|
|
|
pub fn _errno() *c_int {
|
|
return &errno;
|
|
}
|
|
|
|
pub const pid_t = c_int;
|
|
pub const uid_t = u32;
|
|
pub const gid_t = u32;
|
|
pub const off_t = i64;
|
|
|
|
pub const libc_stat = extern struct {
|
|
dev: i32,
|
|
ino: ino_t,
|
|
nlink: u64,
|
|
|
|
mode: mode_t,
|
|
uid: uid_t,
|
|
gid: gid_t,
|
|
__pad0: isize,
|
|
rdev: i32,
|
|
size: off_t,
|
|
blksize: i32,
|
|
blocks: i64,
|
|
|
|
atimesec: time_t,
|
|
atimensec: isize,
|
|
mtimesec: time_t,
|
|
mtimensec: isize,
|
|
ctimesec: time_t,
|
|
ctimensec: isize,
|
|
|
|
pub fn atime(self: @This()) timespec {
|
|
return timespec{
|
|
.tv_sec = self.atimesec,
|
|
.tv_nsec = self.atimensec,
|
|
};
|
|
}
|
|
|
|
pub fn mtime(self: @This()) timespec {
|
|
return timespec{
|
|
.tv_sec = self.mtimesec,
|
|
.tv_nsec = self.mtimensec,
|
|
};
|
|
}
|
|
|
|
pub fn ctime(self: @This()) timespec {
|
|
return timespec{
|
|
.tv_sec = self.ctimesec,
|
|
.tv_nsec = self.ctimensec,
|
|
};
|
|
}
|
|
};
|