Skip to content

Commit 63036a7

Browse files
authored
Avoid setErrNo in _time_js. NFC (#21069)
This avoids the export of __errno_location.
1 parent 528bedf commit 63036a7

File tree

2 files changed

+7
-3
lines changed

2 files changed

+7
-3
lines changed

src/library.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,7 @@ addToLibrary({
437437
// ==========================================================================
438438

439439
_mktime_js__i53abi: true,
440-
_mktime_js__deps: ['$ydayFromDate', '$setErrNo'],
440+
_mktime_js__deps: ['$ydayFromDate'],
441441
_mktime_js: (tmPtr) => {
442442
var date = new Date({{{ makeGetValue('tmPtr', C_STRUCTS.tm.tm_year, 'i32') }}} + 1900,
443443
{{{ makeGetValue('tmPtr', C_STRUCTS.tm.tm_mon, 'i32') }}},
@@ -479,7 +479,6 @@ addToLibrary({
479479

480480
var timeMs = date.getTime();
481481
if (isNaN(timeMs)) {
482-
setErrNo({{{ cDefs.EOVERFLOW }}});
483482
return -1;
484483
}
485484
// Return time in microseconds

system/lib/libc/mktime.c

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
* University of Illinois/NCSA Open Source License. Both these licenses can be
55
* found in the LICENSE file.
66
*/
7+
#include <errno.h>
78
#include <time.h>
89

910
#include "emscripten_internal.h"
@@ -15,7 +16,11 @@ weak time_t timegm(struct tm *tm) {
1516

1617
weak time_t mktime(struct tm *tm) {
1718
tzset();
18-
return _mktime_js(tm);
19+
time_t t = _mktime_js(tm);
20+
if (t == -1) {
21+
errno = EOVERFLOW;
22+
}
23+
return t;
1924
}
2025

2126
weak struct tm *__localtime_r(const time_t *restrict t, struct tm *restrict tm) {

0 commit comments

Comments
 (0)