@@ -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 {
@@ -6389,7 +6396,7 @@ pub const Stat = switch (native_os) {
6389
6396
},
6390
6397
.emscripten = > emscripten .Stat ,
6391
6398
.wasi = > extern struct {
6392
- // Matches wasi-libc's libc-bottom-half/headers/public /__struct_stat.h
6399
+ // Matches wasi-libc's struct stat in lib/ libc/include/wasm-wasi-musl /__struct_stat.h
6393
6400
dev : dev_t ,
6394
6401
ino : ino_t ,
6395
6402
nlink : nlink_t ,
@@ -7089,7 +7096,7 @@ pub const AT = switch (native_os) {
7089
7096
pub const RECURSIVE = 0x8000 ;
7090
7097
},
7091
7098
.wasi = > struct {
7092
- // Match AT_* constants in wasi- libc libc-bottom-half/headers/public /__header_fcntl.h
7099
+ // Match AT_* constants in lib/ libc/include/wasm-wasi-musl /__header_fcntl.h
7093
7100
pub const FDCWD = -2 ;
7094
7101
pub const EACCESS = 0x0 ;
7095
7102
pub const SYMLINK_NOFOLLOW = 0x1 ;
@@ -7124,7 +7131,7 @@ pub const O = switch (native_os) {
7124
7131
_ : u9 = 0 ,
7125
7132
},
7126
7133
.wasi = > packed struct (u32 ) {
7127
- // Match layout from wasi- libc libc-bottom-half/headers/public /__header_fcntl.h
7134
+ // Match O_* bits from lib/ libc/include/wasm-wasi-musl /__header_fcntl.h
7128
7135
APPEND : bool = false ,
7129
7136
DSYNC : bool = false ,
7130
7137
NONBLOCK : bool = false ,
0 commit comments