Skip to content

Commit

Permalink
Merge branch 'emscripten-core:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
hedwigz authored Dec 30, 2024
2 parents 4416f4d + 5a8d9e5 commit 341bf2b
Show file tree
Hide file tree
Showing 27 changed files with 41 additions and 65 deletions.
11 changes: 5 additions & 6 deletions src/library_syscall.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,7 @@ var SyscallsLibrary = {
return dir + '/' + path;
},

doStat(func, path, buf) {
var stat = func(path);
writeStat(buf, stat) {
{{{ makeSetValue('buf', C_STRUCTS.stat.st_dev, 'stat.dev', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_mode, 'stat.mode', 'i32') }}};
{{{ makeSetValue('buf', C_STRUCTS.stat.st_nlink, 'stat.nlink', SIZE_TYPE) }}};
Expand Down Expand Up @@ -672,15 +671,15 @@ var SyscallsLibrary = {
},
__syscall_stat64: (path, buf) => {
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.stat, path, buf);
return SYSCALLS.writeStat(buf, FS.stat(path));
},
__syscall_lstat64: (path, buf) => {
path = SYSCALLS.getStr(path);
return SYSCALLS.doStat(FS.lstat, path, buf);
return SYSCALLS.writeStat(buf, FS.lstat(path));
},
__syscall_fstat64: (fd, buf) => {
var stream = SYSCALLS.getStreamFromFD(fd);
return SYSCALLS.doStat(FS.stat, stream.path, buf);
return SYSCALLS.writeStat(buf, FS.stat(stream.path));
},
__syscall_fchown32: (fd, owner, group) => {
FS.fchown(fd, owner, group);
Expand Down Expand Up @@ -872,7 +871,7 @@ var SyscallsLibrary = {
assert(!flags, `unknown flags in __syscall_newfstatat: ${flags}`);
#endif
path = SYSCALLS.calculateAt(dirfd, path, allowEmpty);
return SYSCALLS.doStat(nofollow ? FS.lstat : FS.stat, path, buf);
return SYSCALLS.writeStat(buf, nofollow ? FS.lstat(path) : FS.stat(path));
},
__syscall_unlinkat: (dirfd, path, flags) => {
path = SYSCALLS.getStr(path);
Expand Down
32 changes: 3 additions & 29 deletions src/library_uuid.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,37 +24,11 @@ addToLibrary({
// Write a RFC4122 version 4 compliant UUID largely based on the method found in
// http://stackoverflow.com/questions/105034/how-to-create-a-guid-uuid-in-javascript
// tweaked slightly in order to use the 'compact' UUID form used by libuuid.
uuid_generate__deps: ['$writeArrayToMemory'],
uuid_generate__deps: ['$writeArrayToMemory', '$randomFill'],
uuid_generate: (out) => {
// void uuid_generate(uuid_t out);
var uuid = null;

if (ENVIRONMENT_IS_NODE) {
#if ENVIRONMENT_MAY_BE_NODE
// If Node.js try to use crypto.randomBytes
try {
var rb = require('crypto')['randomBytes'];
uuid = rb(16);
} catch(e) {}
#endif // ENVIRONMENT_MAY_BE_NODE
} else if (ENVIRONMENT_IS_WEB &&
typeof window.crypto != 'undefined' &&
typeof window.crypto.getRandomValues != 'undefined') {
// If crypto.getRandomValues is available try to use it.
uuid = new Uint8Array(16);
window.crypto.getRandomValues(uuid);
}

// Fall back to Math.random if a higher quality random number generator is not available.
if (!uuid) {
uuid = new Array(16);
var d = new Date().getTime();
for (var i = 0; i < 16; i++) {
var r = ((d + Math.random() * 256) % 256)|0;
d = (d / 256)|0;
uuid[i] = r;
}
}
var uuid = new Uint8Array(16);
randomFill(uuid);

// Makes uuid compliant to RFC-4122
uuid[6] = (uuid[6] & 0x0F) | 0x40; // uuid version
Expand Down
3 changes: 1 addition & 2 deletions src/library_wasi.js
Original file line number Diff line number Diff line change
Expand Up @@ -586,9 +586,8 @@ var WasiLibrary = {
return (view) => crypto_module['randomFillSync'](view);
}
// very old nodejs with the original crypto API
var randomBytes = crypto_module['randomBytes'];
return (view) => (
view.set(randomBytes(view.byteLength)),
view.set(crypto_module['randomBytes'](view.byteLength)),
// Return the original view to match modern native implementations.
view
);
Expand Down
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8408
8405
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors1.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20486
20468
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8392
8390
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_ctors2.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20454
20436
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9413
9412
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24255
24237
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8374
8370
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_except_wasm.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20379
20361
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8374
8370
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20379
20361
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8406
8404
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_lto.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20510
20492
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
9417
9416
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_mangle.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24255
24237
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
8408
8405
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_noexcept.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
20486
20468
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
3651
3646
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_cxx_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7910
7892
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7704
7699
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_js_fs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
18980
18962
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.gzsize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2882
2880
2 changes: 1 addition & 1 deletion test/other/codesize/test_codesize_files_wasmfs.jssize
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6198
6180
8 changes: 4 additions & 4 deletions test/test_other.py
Original file line number Diff line number Diff line change
Expand Up @@ -15243,10 +15243,10 @@ def test_uuid(self):

js_out = read_file('test_uuid.js')

# Check that test.js compiled with --closure 1 contains ").randomBytes" and
# "window.crypto.getRandomValues"
self.assertContained(").randomBytes", js_out)
self.assertContained("window.crypto.getRandomValues", js_out)
# Check that test.js compiled with --closure 1 contains ".randomBytes(" and
# ".getRandomValues("
self.assertContained(".randomBytes(", js_out)
self.assertContained(".getRandomValues(", js_out)

def test_wasm64_no_asan(self):
err = self.expect_fail([EMCC, test_file('hello_world.c'), '-sMEMORY64', '-fsanitize=address'])
Expand Down
8 changes: 6 additions & 2 deletions tools/ports/contrib/glfw3.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
import os
from typing import Union, Dict

TAG = '3.4.0.20241004'
HASH = 'd2745e9f621090b6f78e1c8122d1e6a2e7e774d27799f14945ddcfd543aedeac0e6acdecf42fe74f9ecdbc25aa3599372798ecfc55ddd941661e0628c494cda6'
TAG = '3.4.0.20241221'
HASH = 'e977fcab4747085fead33ab365ece02d6185564401f4904583095e45d3599d2be9315398f8b414b0da8ee954964a1649d2932d378fc8bf96caa986b43b3ae5e7'

# contrib port information (required)
URL = 'https://github.com/pongasoft/emscripten-glfw'
Expand Down Expand Up @@ -44,6 +44,7 @@ def get_lib_name(settings):
('-nw' if opts['disableWarning'] else '') +
('-nj' if opts['disableJoystick'] else '') +
('-sw' if opts['disableMultiWindow'] else '') +
('-mt' if settings.PTHREADS else '') +
'.a')


Expand Down Expand Up @@ -71,6 +72,9 @@ def create(final):
if opts['disableMultiWindow']:
flags += ['-DEMSCRIPTEN_GLFW3_DISABLE_MULTI_WINDOW_SUPPORT']

if settings.PTHREADS:
flags += ['-pthread']

ports.build_port(source_path, final, port_name, includes=source_include_paths, flags=flags)

return [shared.cache.get_lib(get_lib_name(settings), create, what='port')]
Expand Down

0 comments on commit 341bf2b

Please sign in to comment.