Skip to content

Commit 4ca23c4

Browse files
committed
Hardcode cDefs not provided by Emscripten
1 parent 5023a71 commit 4ca23c4

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

packages/php-wasm/compile/php/phpwasm-emscripten-library.js

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -36,9 +36,6 @@ const LibraryExample = {
3636
pid: PHPLoader.processId ?? 42,
3737
// TODO: When receiving this context, validate that all these fields exist.
3838
constants: {
39-
F_RDLCK: Number('{{{cDefs.F_RDLCK}}}'),
40-
F_WRLCK: Number('{{{cDefs.F_WRLCK}}}'),
41-
F_UNLCK: Number('{{{cDefs.F_UNLCK}}}'),
4239
F_GETFL: Number('{{{cDefs.F_GETFL}}}'),
4340
O_ACCMODE: Number('{{{cDefs.O_ACCMODE}}}'),
4441
O_RDONLY: Number('{{{cDefs.O_RDONLY}}}'),
@@ -65,10 +62,17 @@ const LibraryExample = {
6562
SEEK_SET: Number('{{{cDefs.SEEK_SET}}}'),
6663
SEEK_CUR: Number('{{{cDefs.SEEK_CUR}}}'),
6764
SEEK_END: Number('{{{cDefs.SEEK_END}}}'),
65+
// From:
66+
// https://github.com/emscripten-core/emscripten/blob/66d2137b0381ac35f7e2346b2d6a90abd0f1211a/system/lib/libc/musl/include/fcntl.h#L58-L60
67+
F_RDLCK: 0,
68+
F_WRLCK: 1,
69+
F_UNLCK: 2,
70+
// From:
71+
// https://github.com/emscripten-core/emscripten/blob/81bbaa42a7827d88a71bd89701245052c622428c/system/lib/libc/musl/include/sys/file.h#L7-L10
6872
LOCK_SH: 1,
6973
LOCK_EX: 2,
70-
LOCK_NB: 4,
71-
LOCK_UN: 8,
74+
LOCK_NB: 4, // Non-blocking lock
75+
LOCK_UN: 8, // Unlock
7276
},
7377
errnoCodes: ERRNO_CODES,
7478
memory: {

0 commit comments

Comments
 (0)