Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use utimes from musl #16282

Merged
merged 15 commits into from
Feb 14, 2022
45 changes: 0 additions & 45 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -69,51 +69,6 @@ LibraryManager.library = {
return cString;
},

// ==========================================================================
// utime.h
// ==========================================================================

#if FILESYSTEM
$setFileTime__deps: ['$FS', '$setErrNo'],
$setFileTime: function(path, time) {
path = UTF8ToString(path);
try {
FS.utime(path, time, time);
return 0;
} catch (e) {
if (!(e instanceof FS.ErrnoError)) throw e + ' : ' + stackTrace();
setErrNo(e.errno);
return -1;
}
},
#else
$setFileTime__deps: ['$setErrNo'],
$setFileTime: function(path, time) {
// No filesystem support; return an error as if the file does not exist
// (which it almost certainly does not, except for standard streams).
setErrNo({{{ cDefine('ENOENT') }}});
return -1;
},
#endif

utimes__deps: ['$setFileTime'],
utimes__proxy: 'sync',
utimes__sig: 'iii',
utimes: function(path, times) {
// utimes is just like utime but take an array of 2 times: `struct timeval times[2]`
// times[0] is the new access time (which we currently ignore)
// times[1] is the new modification time.
var time;
if (times) {
var mtime = times + {{{ C_STRUCTS.timeval.__size__ }}};
time = {{{ makeGetValue('mtime', C_STRUCTS.timeval.tv_sec, 'i32') }}} * 1000;
time += {{{ makeGetValue('mtime', C_STRUCTS.timeval.tv_usec, 'i32') }}} / 1000;
} else {
time = Date.now();
}
return setFileTime(path, time);
},

exit__sig: 'vi',
#if MINIMAL_RUNTIME
// minimal runtime doesn't do any exit cleanup handling so just
Expand Down
2 changes: 1 addition & 1 deletion tools/system_libs.py
Original file line number Diff line number Diff line change
Expand Up @@ -916,7 +916,7 @@ def get_files(self):

libc_files += files_in_path(
path='system/lib/libc/musl/src/linux',
filenames=['getdents.c', 'gettid.c'])
filenames=['getdents.c', 'gettid.c', 'utimes.c'])
libc_files += files_in_path(
path='system/lib/libc/musl/src/env',
filenames=['__environ.c', 'getenv.c', 'putenv.c', 'setenv.c', 'unsetenv.c'])
Expand Down