Skip to content

Commit 88fdf91

Browse files
committed
Merge branch 'main' into chmod-not-update-mtim
2 parents 1ef8734 + e191834 commit 88fdf91

File tree

98 files changed

+2638
-2078
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

98 files changed

+2638
-2078
lines changed

ChangeLog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ See docs/process.md for more on how version tagging works.
2121
3.1.73 (in development)
2222
-----------------------
2323
- libunwind was updated to LLVM 19.1.4. (#22394)
24+
- mimalloc was updated to 2.1.7. (#21548)
2425

2526
3.1.72 - 11/19/24
2627
-----------------

src/cpuprofiler.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -593,7 +593,7 @@ var emscriptenCpuProfiler = {
593593
detectWebGLContext() {
594594
if (Module['canvas']?.GLctxObject?.GLctx) return Module['canvas'].GLctxObject.GLctx;
595595
else if (typeof GLctx != 'undefined') return GLctx;
596-
else if (Module.ctx) return Module.ctx;
596+
else if (Module['ctx']) return Module['ctx'];
597597
return null;
598598
},
599599

src/library_browser.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ var LibraryBrowser = {
192192
},
193193

194194
createContext(/** @type {HTMLCanvasElement} */ canvas, useWebGL, setInModule, webGLContextAttributes) {
195-
if (useWebGL && Module.ctx && canvas == Module['canvas']) return Module.ctx; // no need to recreate GL context if it's already been created for this canvas.
195+
if (useWebGL && Module['ctx'] && canvas == Module['canvas']) return Module['ctx']; // no need to recreate GL context if it's already been created for this canvas.
196196

197197
var ctx;
198198
var contextHandle;
@@ -235,7 +235,7 @@ var LibraryBrowser = {
235235
#if ASSERTIONS
236236
if (!useWebGL) assert(typeof GLctx == 'undefined', 'cannot set in module if GLctx is used, but we are a non-GL context that would replace it');
237237
#endif
238-
Module.ctx = ctx;
238+
Module['ctx'] = ctx;
239239
if (useWebGL) GL.makeContextCurrent(contextHandle);
240240
Browser.useWebGL = useWebGL;
241241
Browser.moduleContextCreatedCallbacks.forEach((callback) => callback());

src/library_eventloop.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -472,7 +472,7 @@ LibraryJSEventLoop = {
472472
}
473473

474474
#if ASSERTIONS
475-
if (MainLoop.method === 'timeout' && Module.ctx) {
475+
if (MainLoop.method === 'timeout' && Module['ctx']) {
476476
warnOnce('Looks like you are rendering without using requestAnimationFrame for the main loop. You should use 0 for the frame rate in emscripten_set_main_loop in order to use requestAnimationFrame, as that can greatly improve your frame rates!');
477477
MainLoop.method = ''; // just warn once per call to set main loop
478478
}

src/library_fs.js

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -674,14 +674,12 @@ FS.staticInit();
674674
return parent.node_ops.mknod(parent, name, mode, dev);
675675
},
676676
// helpers to create specific types of nodes
677-
create(path, mode) {
678-
mode = mode !== undefined ? mode : 438 /* 0666 */;
677+
create(path, mode = 0o666) {
679678
mode &= {{{ cDefs.S_IALLUGO }}};
680679
mode |= {{{ cDefs.S_IFREG }}};
681680
return FS.mknod(path, mode, 0);
682681
},
683-
mkdir(path, mode) {
684-
mode = mode !== undefined ? mode : 511 /* 0777 */;
682+
mkdir(path, mode = 0o777) {
685683
mode &= {{{ cDefs.S_IRWXUGO }}} | {{{ cDefs.S_ISVTX }}};
686684
mode |= {{{ cDefs.S_IFDIR }}};
687685
#if FS_DEBUG
@@ -708,7 +706,7 @@ FS.staticInit();
708706
mkdev(path, mode, dev) {
709707
if (typeof dev == 'undefined') {
710708
dev = mode;
711-
mode = 438 /* 0666 */;
709+
mode = 0o666;
712710
}
713711
mode |= {{{ cDefs.S_IFCHR }}};
714712
return FS.mknod(path, mode, dev);
@@ -1017,13 +1015,12 @@ FS.staticInit();
10171015
mtime: mtime
10181016
});
10191017
},
1020-
open(path, flags, mode) {
1018+
open(path, flags, mode = 0o666) {
10211019
if (path === "") {
10221020
throw new FS.ErrnoError({{{ cDefs.ENOENT }}});
10231021
}
10241022
flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags;
10251023
if ((flags & {{{ cDefs.O_CREAT }}})) {
1026-
mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode;
10271024
mode = (mode & {{{ cDefs.S_IALLUGO }}}) | {{{ cDefs.S_IFREG }}};
10281025
} else {
10291026
mode = 0;
@@ -1389,7 +1386,7 @@ FS.staticInit();
13891386
FS.mkdir('/proc/self/fd');
13901387
FS.mount({
13911388
mount() {
1392-
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, {{{ cDefs.S_IXUGO }}});
1389+
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR }}} | {{{ 0777 }}}, {{{ cDefs.S_IXUGO }}});
13931390
node.node_ops = {
13941391
lookup(parent, name) {
13951392
var fd = +name;

src/library_glfw.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1108,7 +1108,7 @@ var LibraryGLFW = {
11081108
}
11091109

11101110
// If context creation failed, do not return a valid window
1111-
if (!Module.ctx && useWebGL) return 0;
1111+
if (!Module['ctx'] && useWebGL) return 0;
11121112

11131113
// Initializes the framebuffer size from the canvas
11141114
const canvas = Module['canvas'];
@@ -1144,7 +1144,7 @@ var LibraryGLFW = {
11441144
for (var i = 0; i < GLFW.windows.length; i++)
11451145
if (GLFW.windows[i] !== null) return;
11461146

1147-
delete Module.ctx;
1147+
delete Module['ctx'];
11481148
},
11491149

11501150
swapBuffers: (winid) => {

src/library_glut.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -575,7 +575,7 @@ var LibraryGLUT = {
575575
glutDestroyWindow__proxy: 'sync',
576576
glutDestroyWindow__deps: ['$Browser'],
577577
glutDestroyWindow: (name) => {
578-
delete Module.ctx;
578+
delete Module['ctx'];
579579
return 1;
580580
},
581581

src/library_html5_webgl.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,7 @@ var LibraryHtml5WebGL = {
223223
});`,
224224
#endif
225225
_emscripten_proxied_gl_context_activated_from_main_browser_thread: (contextHandle) => {
226-
GLctx = Module.ctx = GL.currentContext = contextHandle;
226+
GLctx = Module['ctx'] = GL.currentContext = contextHandle;
227227
GL.currentContextIsProxied = true;
228228
},
229229
#else

src/library_nodefs.js

Lines changed: 15 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -76,15 +76,14 @@ addToLibrary({
7676
return node;
7777
},
7878
getMode(path) {
79-
var stat;
8079
return NODEFS.tryFSOperation(() => {
81-
stat = fs.lstatSync(path);
80+
var mode = fs.lstatSync(path).mode;
8281
if (NODEFS.isWindows) {
83-
// Node.js on Windows never represents permission bit 'x', so
84-
// propagate read bits to execute bits
85-
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
82+
// Windows does not report the 'x' permission bit, so propagate read
83+
// bits to execute bits.
84+
mode |= (mode & {{{ cDefs.S_IRUGO }}}) >> 2;
8685
}
87-
return stat.mode;
86+
return mode;
8887
});
8988
},
9089
realPath(node) {
@@ -133,9 +132,9 @@ addToLibrary({
133132
if (!stat.blocks) {
134133
stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
135134
}
136-
// Node.js on Windows never represents permission bit 'x', so
137-
// propagate read bits to execute bits.
138-
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
135+
// Windows does not report the 'x' permission bit, so propagate read
136+
// bits to execute bits.
137+
stat.mode |= (stat.mode & {{{ cDefs.S_IRUGO }}}) >> 2;
139138
}
140139
return {
141140
dev: stat.dev,
@@ -157,7 +156,13 @@ addToLibrary({
157156
var path = NODEFS.realPath(node);
158157
NODEFS.tryFSOperation(() => {
159158
if (attr.mode !== undefined) {
160-
fs.chmodSync(path, attr.mode);
159+
var mode = attr.mode;
160+
if (NODEFS.isWindows) {
161+
// Windows only supports S_IREAD / S_IWRITE (S_IRUSR / S_IWUSR)
162+
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod
163+
mode &= {{{ cDefs.S_IRUSR | cDefs.S_IWUSR }}};
164+
}
165+
fs.chmodSync(path, mode);
161166
// update the common node structure mode as well
162167
node.mode = attr.mode;
163168
}

src/library_noderawfs.js

Lines changed: 23 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,9 +70,29 @@ addToLibrary({
7070
readdir(...args) { return ['.', '..'].concat(fs.readdirSync(...args)); },
7171
unlink(...args) { fs.unlinkSync(...args); },
7272
readlink(...args) { return fs.readlinkSync(...args); },
73-
stat(...args) { return fs.statSync(...args); },
74-
lstat(...args) { return fs.lstatSync(...args); },
75-
chmod(...args) { fs.chmodSync(...args); },
73+
stat(path, dontFollow) {
74+
var stat = dontFollow ? fs.lstatSync(path) : fs.statSync(path);
75+
if (NODEFS.isWindows) {
76+
// Windows does not report the 'x' permission bit, so propagate read
77+
// bits to execute bits.
78+
stat.mode |= (stat.mode & {{{ cDefs.S_IRUGO }}}) >> 2;
79+
}
80+
return stat;
81+
},
82+
chmod(path, mode, dontFollow) {
83+
mode &= {{{ cDefs.S_IALLUGO }}};
84+
if (NODEFS.isWindows) {
85+
// Windows only supports S_IREAD / S_IWRITE (S_IRUSR / S_IWUSR)
86+
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod
87+
mode &= {{{ cDefs.S_IRUSR | cDefs.S_IWUSR }}};
88+
}
89+
if (dontFollow && fs.lstatSync(path).isSymbolicLink()) {
90+
// Node (and indeed linux) does not support chmod on symlinks
91+
// https://nodejs.org/api/fs.html#fslchmodsyncpath-mode
92+
throw new FS.ErrnoError({{{ cDefs.EOPNOTSUPP }}});
93+
}
94+
fs.chmodSync(path, mode);
95+
},
7696
fchmod(fd, mode) {
7797
var stream = FS.getStreamChecked(fd);
7898
fs.fchmodSync(stream.nfd, mode);

0 commit comments

Comments
 (0)