Skip to content

Commit

Permalink
Merge branch 'main' into lookup-path-nonrecursive
Browse files Browse the repository at this point in the history
  • Loading branch information
hoodmane committed Nov 26, 2024
2 parents f0a353c + e191834 commit 8dd57fa
Show file tree
Hide file tree
Showing 98 changed files with 2,638 additions and 2,078 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ See docs/process.md for more on how version tagging works.
- mimalloc was updated to 2.1.7. (#21548)
- The file system was updated to independently track atime, mtime and ctime
instead of using the same time for all three.
- mimalloc was updated to 2.1.7. (#21548)

3.1.72 - 11/19/24
-----------------
Expand Down
2 changes: 1 addition & 1 deletion src/cpuprofiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -593,7 +593,7 @@ var emscriptenCpuProfiler = {
detectWebGLContext() {
if (Module['canvas']?.GLctxObject?.GLctx) return Module['canvas'].GLctxObject.GLctx;
else if (typeof GLctx != 'undefined') return GLctx;
else if (Module.ctx) return Module.ctx;
else if (Module['ctx']) return Module['ctx'];
return null;
},

Expand Down
4 changes: 2 additions & 2 deletions src/library_browser.js
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ var LibraryBrowser = {
},

createContext(/** @type {HTMLCanvasElement} */ canvas, useWebGL, setInModule, webGLContextAttributes) {
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.
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.

var ctx;
var contextHandle;
Expand Down Expand Up @@ -235,7 +235,7 @@ var LibraryBrowser = {
#if ASSERTIONS
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');
#endif
Module.ctx = ctx;
Module['ctx'] = ctx;
if (useWebGL) GL.makeContextCurrent(contextHandle);
Browser.useWebGL = useWebGL;
Browser.moduleContextCreatedCallbacks.forEach((callback) => callback());
Expand Down
2 changes: 1 addition & 1 deletion src/library_eventloop.js
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ LibraryJSEventLoop = {
}

#if ASSERTIONS
if (MainLoop.method === 'timeout' && Module.ctx) {
if (MainLoop.method === 'timeout' && Module['ctx']) {
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!');
MainLoop.method = ''; // just warn once per call to set main loop
}
Expand Down
13 changes: 5 additions & 8 deletions src/library_fs.js
Original file line number Diff line number Diff line change
Expand Up @@ -653,14 +653,12 @@ FS.staticInit();
return parent.node_ops.mknod(parent, name, mode, dev);
},
// helpers to create specific types of nodes
create(path, mode) {
mode = mode !== undefined ? mode : 438 /* 0666 */;
create(path, mode = 0o666) {
mode &= {{{ cDefs.S_IALLUGO }}};
mode |= {{{ cDefs.S_IFREG }}};
return FS.mknod(path, mode, 0);
},
mkdir(path, mode) {
mode = mode !== undefined ? mode : 511 /* 0777 */;
mkdir(path, mode = 0o777) {
mode &= {{{ cDefs.S_IRWXUGO }}} | {{{ cDefs.S_ISVTX }}};
mode |= {{{ cDefs.S_IFDIR }}};
#if FS_DEBUG
Expand All @@ -687,7 +685,7 @@ FS.staticInit();
mkdev(path, mode, dev) {
if (typeof dev == 'undefined') {
dev = mode;
mode = 438 /* 0666 */;
mode = 0o666;
}
mode |= {{{ cDefs.S_IFCHR }}};
return FS.mknod(path, mode, dev);
Expand Down Expand Up @@ -995,13 +993,12 @@ FS.staticInit();
timestamp: Math.max(atime, mtime)
});
},
open(path, flags, mode) {
open(path, flags, mode = 0o666) {
if (path === "") {
throw new FS.ErrnoError({{{ cDefs.ENOENT }}});
}
flags = typeof flags == 'string' ? FS_modeStringToFlags(flags) : flags;
if ((flags & {{{ cDefs.O_CREAT }}})) {
mode = typeof mode == 'undefined' ? 438 /* 0666 */ : mode;
mode = (mode & {{{ cDefs.S_IALLUGO }}}) | {{{ cDefs.S_IFREG }}};
} else {
mode = 0;
Expand Down Expand Up @@ -1367,7 +1364,7 @@ FS.staticInit();
FS.mkdir('/proc/self/fd');
FS.mount({
mount() {
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR }}} | 511 /* 0777 */, {{{ cDefs.S_IXUGO }}});
var node = FS.createNode(proc_self, 'fd', {{{ cDefs.S_IFDIR }}} | {{{ 0777 }}}, {{{ cDefs.S_IXUGO }}});
node.node_ops = {
lookup(parent, name) {
var fd = +name;
Expand Down
4 changes: 2 additions & 2 deletions src/library_glfw.js
Original file line number Diff line number Diff line change
Expand Up @@ -1108,7 +1108,7 @@ var LibraryGLFW = {
}

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

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

delete Module.ctx;
delete Module['ctx'];
},

swapBuffers: (winid) => {
Expand Down
2 changes: 1 addition & 1 deletion src/library_glut.js
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ var LibraryGLUT = {
glutDestroyWindow__proxy: 'sync',
glutDestroyWindow__deps: ['$Browser'],
glutDestroyWindow: (name) => {
delete Module.ctx;
delete Module['ctx'];
return 1;
},

Expand Down
2 changes: 1 addition & 1 deletion src/library_html5_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ var LibraryHtml5WebGL = {
});`,
#endif
_emscripten_proxied_gl_context_activated_from_main_browser_thread: (contextHandle) => {
GLctx = Module.ctx = GL.currentContext = contextHandle;
GLctx = Module['ctx'] = GL.currentContext = contextHandle;
GL.currentContextIsProxied = true;
},
#else
Expand Down
25 changes: 15 additions & 10 deletions src/library_nodefs.js
Original file line number Diff line number Diff line change
Expand Up @@ -76,15 +76,14 @@ addToLibrary({
return node;
},
getMode(path) {
var stat;
return NODEFS.tryFSOperation(() => {
stat = fs.lstatSync(path);
var mode = fs.lstatSync(path).mode;
if (NODEFS.isWindows) {
// Node.js on Windows never represents permission bit 'x', so
// propagate read bits to execute bits
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
// Windows does not report the 'x' permission bit, so propagate read
// bits to execute bits.
mode |= (mode & {{{ cDefs.S_IRUGO }}}) >> 2;
}
return stat.mode;
return mode;
});
},
realPath(node) {
Expand Down Expand Up @@ -133,9 +132,9 @@ addToLibrary({
if (!stat.blocks) {
stat.blocks = (stat.size+stat.blksize-1)/stat.blksize|0;
}
// Node.js on Windows never represents permission bit 'x', so
// propagate read bits to execute bits.
stat.mode |= (stat.mode & {{{ cDefs.S_IRUSR | cDefs.S_IRGRP | cDefs.S_IROTH }}}) >> 2;
// Windows does not report the 'x' permission bit, so propagate read
// bits to execute bits.
stat.mode |= (stat.mode & {{{ cDefs.S_IRUGO }}}) >> 2;
}
return {
dev: stat.dev,
Expand All @@ -157,7 +156,13 @@ addToLibrary({
var path = NODEFS.realPath(node);
NODEFS.tryFSOperation(() => {
if (attr.mode !== undefined) {
fs.chmodSync(path, attr.mode);
var mode = attr.mode;
if (NODEFS.isWindows) {
// Windows only supports S_IREAD / S_IWRITE (S_IRUSR / S_IWUSR)
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod
mode &= {{{ cDefs.S_IRUSR | cDefs.S_IWUSR }}};
}
fs.chmodSync(path, mode);
// update the common node structure mode as well
node.mode = attr.mode;
}
Expand Down
26 changes: 23 additions & 3 deletions src/library_noderawfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,9 +70,29 @@ addToLibrary({
readdir(...args) { return ['.', '..'].concat(fs.readdirSync(...args)); },
unlink(...args) { fs.unlinkSync(...args); },
readlink(...args) { return fs.readlinkSync(...args); },
stat(...args) { return fs.statSync(...args); },
lstat(...args) { return fs.lstatSync(...args); },
chmod(...args) { fs.chmodSync(...args); },
stat(path, dontFollow) {
var stat = dontFollow ? fs.lstatSync(path) : fs.statSync(path);
if (NODEFS.isWindows) {
// Windows does not report the 'x' permission bit, so propagate read
// bits to execute bits.
stat.mode |= (stat.mode & {{{ cDefs.S_IRUGO }}}) >> 2;
}
return stat;
},
chmod(path, mode, dontFollow) {
mode &= {{{ cDefs.S_IALLUGO }}};
if (NODEFS.isWindows) {
// Windows only supports S_IREAD / S_IWRITE (S_IRUSR / S_IWUSR)
// https://learn.microsoft.com/en-us/cpp/c-runtime-library/reference/chmod-wchmod
mode &= {{{ cDefs.S_IRUSR | cDefs.S_IWUSR }}};
}
if (dontFollow && fs.lstatSync(path).isSymbolicLink()) {
// Node (and indeed linux) does not support chmod on symlinks
// https://nodejs.org/api/fs.html#fslchmodsyncpath-mode
throw new FS.ErrnoError({{{ cDefs.EOPNOTSUPP }}});
}
fs.chmodSync(path, mode);
},
fchmod(fd, mode) {
var stream = FS.getStreamChecked(fd);
fs.fchmodSync(stream.nfd, mode);
Expand Down
1 change: 0 additions & 1 deletion src/library_sigs.js
Original file line number Diff line number Diff line change
Expand Up @@ -273,7 +273,6 @@ sigs = {
__syscall_socket__sig: 'iiiiiii',
__syscall_stat64__sig: 'ipp',
__syscall_statfs64__sig: 'ippp',
__syscall_symlink__sig: 'ipp',
__syscall_symlinkat__sig: 'ipip',
__syscall_truncate64__sig: 'ipj',
__syscall_unlinkat__sig: 'iipi',
Expand Down
15 changes: 6 additions & 9 deletions src/library_sockfs.js
Original file line number Diff line number Diff line change
Expand Up @@ -619,16 +619,13 @@ addToLibrary({
buffer = buffer.buffer;
}

var data;
#if PTHREADS
// WebSockets .send() does not allow passing a SharedArrayBuffer, so clone the portion of the SharedArrayBuffer as a regular
// ArrayBuffer that we want to send.
if (buffer instanceof SharedArrayBuffer) {
data = new Uint8Array(new Uint8Array(buffer.slice(offset, offset + length))).buffer;
} else {
#endif
data = buffer.slice(offset, offset + length);
var data = buffer.slice(offset, offset + length);
#if PTHREADS
// WebSockets .send() does not allow passing a SharedArrayBuffer, so
// clone the the SharedArrayBuffer as regular ArrayBuffer before
// sending.
if (data instanceof SharedArrayBuffer) {
data = new Uint8Array(new Uint8Array(data)).buffer;
}
#endif

Expand Down
27 changes: 4 additions & 23 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -300,12 +300,6 @@ var SyscallsLibrary = {
}
#endif // SYSCALLS_REQUIRE_FILESYSTEM
},
__syscall_symlink: (target, linkpath) => {
target = SYSCALLS.getStr(target);
linkpath = SYSCALLS.getStr(linkpath);
FS.symlink(target, linkpath);
return 0;
},
__syscall_fchmod: (fd, mode) => {
FS.fchmod(fd, mode);
return 0;
Expand Down Expand Up @@ -830,9 +824,6 @@ var SyscallsLibrary = {
return FS.open(path, flags, mode).fd;
},
__syscall_mkdirat: (dirfd, path, mode) => {
#if SYSCALL_DEBUG
dbg('warning: untested syscall');
#endif
path = SYSCALLS.getStr(path);
path = SYSCALLS.calculateAt(dirfd, path);
// remove a trailing slash, if one - /a/b/ has basename of '', but
Expand All @@ -843,9 +834,6 @@ var SyscallsLibrary = {
return 0;
},
__syscall_mknodat: (dirfd, path, mode, dev) => {
#if SYSCALL_DEBUG
dbg('warning: untested syscall');
#endif
path = SYSCALLS.getStr(path);
path = SYSCALLS.calculateAt(dirfd, path);
// we don't want this in the JS API as it uses mknod to create all nodes.
Expand All @@ -862,9 +850,6 @@ var SyscallsLibrary = {
return 0;
},
__syscall_fchownat: (dirfd, path, owner, group, flags) => {
#if SYSCALL_DEBUG
dbg('warning: untested syscall');
#endif
path = SYSCALLS.getStr(path);
var nofollow = flags & {{{ cDefs.AT_SYMLINK_NOFOLLOW }}};
flags = flags & (~{{{ cDefs.AT_SYMLINK_NOFOLLOW }}});
Expand Down Expand Up @@ -906,11 +891,10 @@ var SyscallsLibrary = {
FS.rename(oldpath, newpath);
return 0;
},
__syscall_symlinkat: (target, newdirfd, linkpath) => {
#if SYSCALL_DEBUG
dbg('warning: untested syscall');
#endif
linkpath = SYSCALLS.calculateAt(newdirfd, linkpath);
__syscall_symlinkat: (target, dirfd, linkpath) => {
target = SYSCALLS.getStr(target);
linkpath = SYSCALLS.getStr(linkpath);
linkpath = SYSCALLS.calculateAt(dirfd, linkpath);
FS.symlink(target, linkpath);
return 0;
},
Expand All @@ -937,9 +921,6 @@ var SyscallsLibrary = {
return 0;
},
__syscall_faccessat: (dirfd, path, amode, flags) => {
#if SYSCALL_DEBUG
dbg('warning: untested syscall');
#endif
path = SYSCALLS.getStr(path);
#if ASSERTIONS
assert(flags === 0 || flags == {{{ cDefs.AT_EACCESS }}});
Expand Down
2 changes: 1 addition & 1 deletion src/library_webgl.js
Original file line number Diff line number Diff line change
Expand Up @@ -1170,7 +1170,7 @@ for (/**@suppress{duplicate}*/var i = 0; i <= {{{ GL_POOL_TEMP_BUFFERS_SIZE }}};
// Active Emscripten GL layer context object.
GL.currentContext = GL.contexts[contextHandle];
// Active WebGL context object.
Module.ctx = GLctx = GL.currentContext?.GLctx;
Module['ctx'] = GLctx = GL.currentContext?.GLctx;
return !(contextHandle && !GLctx);
},

Expand Down
8 changes: 4 additions & 4 deletions src/proxyClient.js
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ function renderFrame() {
dst[i] = renderFrameData[i];
}
}
Module.ctx.putImageData(Module.canvasData, 0, 0);
Module['ctx'].putImageData(Module.canvasData, 0, 0);
renderFrameData = null;
}

Expand Down Expand Up @@ -190,17 +190,17 @@ worker.onmessage = (event) => {
case 'canvas': {
switch (data.op) {
case 'getContext': {
Module.ctx = Module['canvas'].getContext(data.type, data.attributes);
Module['ctx'] = Module['canvas'].getContext(data.type, data.attributes);
if (data.type !== '2d') {
// possible GL_DEBUG entry point: Module.ctx = wrapDebugGL(Module.ctx);
// possible GL_DEBUG entry point: Module['ctx'] = wrapDebugGL(Module['ctx']);
Module.glClient = new WebGLClient();
}
break;
}
case 'resize': {
Module['canvas'].width = data.width;
Module['canvas'].height = data.height;
if (Module.ctx?.getImageData) Module.canvasData = Module.ctx.getImageData(0, 0, data.width, data.height);
if (Module['ctx']?.getImageData) Module.canvasData = Module['ctx'].getImageData(0, 0, data.width, data.height);
worker.postMessage({ target: 'canvas', boundingClientRect: cloneObject(Module['canvas'].getBoundingClientRect()) });
break;
}
Expand Down
6 changes: 2 additions & 4 deletions src/shell.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,9 @@
#if MODULARIZE
var Module = moduleArg;
#elif USE_CLOSURE_COMPILER
/** @type{Object} */
var Module;
// if (!Module)` is crucial for Closure Compiler here as it will otherwise replace every `Module` occurrence with a string
var /** @type {{
ctx: Object,
}}
*/ Module;
if (!Module) /** @suppress{checkTypes}*/Module = {"__EMSCRIPTEN_PRIVATE_MODULE_EXPORT_NAME_SUBSTITUTION__":1};
#elif AUDIO_WORKLET
var Module = globalThis.Module || (typeof {{{ EXPORT_NAME }}} != 'undefined' ? {{{ EXPORT_NAME }}} : {});
Expand Down
3 changes: 2 additions & 1 deletion src/shell_minimal.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,10 @@
#if MODULARIZE
var Module = moduleArg;
#elif USE_CLOSURE_COMPILER
/** @type{Object} */
var Module;
// if (!Module)` is crucial for Closure Compiler here as it will
// otherwise replace every `Module` occurrence with the object below
var /** @type{Object} */ Module;
if (!Module) /** @suppress{checkTypes}*/Module =
#if AUDIO_WORKLET
globalThis.{{{ EXPORT_NAME }}} ||
Expand Down
Loading

0 comments on commit 8dd57fa

Please sign in to comment.