Skip to content

Commit a583b58

Browse files
authored
Use native version of ctime_r. NFC (#16117)
The native code in musl is pretty much a transliteration of the JS code here, but should be smaller and faster and avoid the extra import (and work in standalone mode). See https://github.com/emscripten-core/emscripten/blob/main/system/lib/libc/musl/src/time/ctime_r.c
1 parent 24d63c2 commit a583b58

File tree

2 files changed

+1
-9
lines changed

2 files changed

+1
-9
lines changed

src/library.js

-8
Original file line numberDiff line numberDiff line change
@@ -615,14 +615,6 @@ LibraryManager.library = {
615615
return ret;
616616
},
617617

618-
ctime_r__deps: ['localtime_r', '__asctime_r', '$withStackSave'],
619-
ctime_r__sig: 'iii',
620-
ctime_r: function(time, buf) {
621-
return withStackSave(function() {
622-
return ___asctime_r(_localtime_r(time, stackAlloc({{{ C_STRUCTS.tm.__size__ }}})), buf);
623-
});
624-
},
625-
626618
dysize: function(year) {
627619
var leap = ((year % 4 == 0) && ((year % 100 != 0) || (year % 400 == 0)));
628620
return leap ? 366 : 365;

tools/system_libs.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -910,6 +910,7 @@ def get_files(self):
910910
'localtime.c',
911911
'nanosleep.c',
912912
'clock_nanosleep.c',
913+
'ctime_r.c',
913914
])
914915
libc_files += files_in_path(
915916
path='system/lib/libc/musl/src/legacy',
@@ -1573,7 +1574,6 @@ def get_files(self):
15731574
'__year_to_secs.c',
15741575
'clock.c',
15751576
'clock_gettime.c',
1576-
'ctime_r.c',
15771577
'difftime.c',
15781578
'gettimeofday.c',
15791579
'localtime_r.c',

0 commit comments

Comments
 (0)