@@ -672,6 +672,7 @@ pub const F = switch (native_os) {
672
672
.linux = > linux .F ,
673
673
.emscripten = > emscripten .F ,
674
674
.wasi = > struct {
675
+ // Match F_* constants from lib/libc/include/wasm-wasi-musl/__header_fcntl.h
675
676
pub const GETFD = 1 ;
676
677
pub const SETFD = 2 ;
677
678
pub const GETFL = 3 ;
@@ -1703,14 +1704,20 @@ pub const S = switch (native_os) {
1703
1704
.linux = > linux .S ,
1704
1705
.emscripten = > emscripten .S ,
1705
1706
.wasi = > struct {
1706
- // Match wasi-libc's libc-bottom-half/headers/public/__mode_t.h
1707
+ // Match S_* constants from lib/libc/include/wasm-wasi-musl/__mode_t.h
1708
+ //
1709
+ // Note, a bug in wasi-libc means both IFIFO and IFSOCK have the same value (0xc000).
1710
+ // IFIFO should be 0x1000 (see https://github.com/WebAssembly/wasi-libc/pull/463), and
1711
+ // 0x1000 is used by the wasi-libc bottom-half. So we use 0x1000 here. But the actual bit
1712
+ // values we get back from a wasi-libc may get masked with the wrong values, or may get
1713
+ // mistranslated. So the FIFO and Socket file-type bits are not trustworthy.
1707
1714
pub const IFBLK = 0x6000 ;
1708
1715
pub const IFCHR = 0x2000 ;
1709
1716
pub const IFDIR = 0x4000 ;
1710
- pub const IFIFO = 0x1000 ;
1717
+ pub const IFIFO = 0x1000 ; // buggy
1711
1718
pub const IFLNK = 0xa000 ;
1712
1719
pub const IFREG = 0x8000 ;
1713
- pub const IFSOCK = 0xc000 ;
1720
+ pub const IFSOCK = 0xc000 ; // buggy
1714
1721
pub const IFMT = IFBLK | IFCHR | IFDIR | IFIFO | IFLNK | IFREG | IFSOCK ;
1715
1722
1716
1723
pub fn ISBLK (m : u32 ) bool {
@@ -6513,7 +6520,7 @@ pub const Stat = switch (native_os) {
6513
6520
},
6514
6521
.emscripten = > emscripten .Stat ,
6515
6522
.wasi = > extern struct {
6516
- // Matches wasi-libc's libc-bottom-half/headers/public /__struct_stat.h
6523
+ // Matches wasi-libc's struct stat in lib/ libc/include/wasm-wasi-musl /__struct_stat.h
6517
6524
dev : dev_t ,
6518
6525
ino : ino_t ,
6519
6526
nlink : nlink_t ,
@@ -7213,7 +7220,7 @@ pub const AT = switch (native_os) {
7213
7220
pub const RECURSIVE = 0x8000 ;
7214
7221
},
7215
7222
.wasi = > struct {
7216
- // Match AT_* constants in wasi- libc libc-bottom-half/headers/public /__header_fcntl.h
7223
+ // Match AT_* constants in lib/ libc/include/wasm-wasi-musl /__header_fcntl.h
7217
7224
pub const FDCWD = -2 ;
7218
7225
pub const EACCESS = 0x0 ;
7219
7226
pub const SYMLINK_NOFOLLOW = 0x1 ;
@@ -7248,7 +7255,7 @@ pub const O = switch (native_os) {
7248
7255
_ : u9 = 0 ,
7249
7256
},
7250
7257
.wasi = > packed struct (u32 ) {
7251
- // Match layout from wasi- libc libc-bottom-half/headers/public /__header_fcntl.h
7258
+ // Match O_* bits from lib/ libc/include/wasm-wasi-musl /__header_fcntl.h
7252
7259
APPEND : bool = false ,
7253
7260
DSYNC : bool = false ,
7254
7261
NONBLOCK : bool = false ,
0 commit comments