6
6
//! for UTF-16LE encoding.
7
7
//! * Where operating systems share APIs, e.g. POSIX, these thin wrappers provide
8
8
//! cross platform abstracting.
9
+ //! - If operating systems API semantics can be unified without significant
10
+ //! drawback, then only the most portable abstraction or wrapper is provided.
11
+ //! This usually means, that there is no POSIX function, if Windows and POSIX
12
+ //! API can be used with the same semantics.
9
13
//! * When there exists a corresponding libc function and linking libc, the libc
10
14
//! implementation is used. Exceptions are made for known buggy areas of libc.
11
15
//! On Linux libc can be side-stepped by using `std.os.linux` directly.
15
19
//! in general EINTR is handled by trying again.
16
20
17
21
const root = @import ("root" );
18
- const std = @import ("std.zig" );
19
22
const builtin = @import ("builtin" );
23
+ const std = @import ("std.zig" );
24
+ const dl = @import ("dynamic_library.zig" );
20
25
const assert = std .debug .assert ;
21
26
const math = std .math ;
22
27
const mem = std .mem ;
23
28
const elf = std .elf ;
24
29
const fs = std .fs ;
25
- const dl = @import ("dynamic_library.zig" );
26
30
const MAX_PATH_BYTES = std .fs .MAX_PATH_BYTES ;
27
31
const is_windows = builtin .os .tag == .windows ;
28
32
const Allocator = std .mem .Allocator ;
29
33
const Preopen = std .fs .wasi .Preopen ;
30
34
const PreopenList = std .fs .wasi .PreopenList ;
31
35
32
36
pub const darwin = @import ("os/darwin.zig" );
37
+ pub const linux = @import ("os/linux.zig" );
38
+ pub const plan9 = @import ("os/plan9.zig" );
39
+ pub const uefi = @import ("os/uefi.zig" );
40
+ pub const wasi = @import ("os/wasi.zig" );
41
+ pub const windows = @import ("os/windows.zig" );
42
+
43
+ pub const posix_spawn = @import ("os/posix_spawn.zig" ); // posix
44
+ pub const ptrace = @import ("os/ptrace.zig" ); // posix
33
45
pub const dragonfly = std .c ;
34
46
pub const freebsd = std .c ;
35
47
pub const haiku = std .c ;
36
48
pub const netbsd = std .c ;
37
49
pub const openbsd = std .c ;
38
50
pub const solaris = std .c ;
39
- pub const linux = @import ("os/linux.zig" );
40
- pub const plan9 = @import ("os/plan9.zig" );
41
- pub const uefi = @import ("os/uefi.zig" );
42
- pub const wasi = @import ("os/wasi.zig" );
43
- pub const windows = @import ("os/windows.zig" );
44
- pub const posix_spawn = @import ("os/posix_spawn.zig" );
45
- pub const ptrace = @import ("os/ptrace.zig" );
46
51
47
52
comptime {
48
53
assert (@import ("std" ) == std ); // std lib tests require --zig-lib-dir
49
54
}
50
55
51
56
test {
57
+ _ = @import ("os/test.zig" );
52
58
_ = darwin ;
53
59
_ = linux ;
60
+ _ = wasi ;
61
+ _ = windows ;
54
62
if (builtin .os .tag == .uefi ) {
55
63
_ = uefi ;
56
64
}
57
- _ = wasi ;
58
- _ = windows ;
59
- _ = posix_spawn ;
60
-
61
- _ = @import ("os/test.zig" );
62
65
}
63
66
64
67
/// Applications can override the `system` API layer in their root source file.
@@ -70,8 +73,8 @@ else if (builtin.link_libc or is_windows)
70
73
std .c
71
74
else switch (builtin .os .tag ) {
72
75
.linux = > linux ,
73
- .wasi = > wasi ,
74
76
.uefi = > uefi ,
77
+ .wasi = > wasi ,
75
78
else = > struct {},
76
79
};
77
80
@@ -98,10 +101,10 @@ pub const Kevent = system.Kevent;
98
101
pub const LOCK = system .LOCK ;
99
102
pub const MADV = system .MADV ;
100
103
pub const MAP = system .MAP ;
101
- pub const MSF = system .MSF ;
102
104
pub const MAX_ADDR_LEN = system .MAX_ADDR_LEN ;
103
105
pub const MFD = system .MFD ;
104
106
pub const MMAP2_UNIT = system .MMAP2_UNIT ;
107
+ pub const MSF = system .MSF ;
105
108
pub const MSG = system .MSG ;
106
109
pub const NAME_MAX = system .NAME_MAX ;
107
110
pub const O = switch (builtin .os .tag ) {
@@ -122,7 +125,6 @@ pub const RR = system.RR;
122
125
pub const S = system .S ;
123
126
pub const SA = system .SA ;
124
127
pub const SC = system .SC ;
125
- pub const _SC = system ._SC ;
126
128
pub const SEEK = system .SEEK ;
127
129
pub const SHUT = system .SHUT ;
128
130
pub const SIG = system .SIG ;
@@ -136,10 +138,11 @@ pub const STDOUT_FILENO = system.STDOUT_FILENO;
136
138
pub const SYS = system .SYS ;
137
139
pub const Sigaction = system .Sigaction ;
138
140
pub const Stat = system .Stat ;
139
- pub const TCSA = system .TCSA ;
140
141
pub const TCP = system .TCP ;
142
+ pub const TCSA = system .TCSA ;
141
143
pub const VDSO = system .VDSO ;
142
144
pub const W = system .W ;
145
+ pub const _SC = system ._SC ;
143
146
pub const addrinfo = system .addrinfo ;
144
147
pub const blkcnt_t = system .blkcnt_t ;
145
148
pub const blksize_t = system .blksize_t ;
@@ -151,6 +154,7 @@ pub const empty_sigset = system.empty_sigset;
151
154
pub const fd_t = system .fd_t ;
152
155
pub const fdflags_t = system .fdflags_t ;
153
156
pub const fdstat_t = system .fdstat_t ;
157
+ pub const file_obj = system .file_obj ;
154
158
pub const gid_t = system .gid_t ;
155
159
pub const ifreq = system .ifreq ;
156
160
pub const ino_t = system .ino_t ;
@@ -165,10 +169,9 @@ pub const off_t = system.off_t;
165
169
pub const oflags_t = system .oflags_t ;
166
170
pub const pid_t = system .pid_t ;
167
171
pub const pollfd = system .pollfd ;
168
- pub const port_t = system .port_t ;
169
172
pub const port_event = system .port_event ;
170
173
pub const port_notify = system .port_notify ;
171
- pub const file_obj = system .file_obj ;
174
+ pub const port_t = system .port_t ;
172
175
pub const rights_t = system .rights_t ;
173
176
pub const rlim_t = system .rlim_t ;
174
177
pub const rlimit = system .rlimit ;
0 commit comments