Skip to content

Remove __tm_timezone static allocation in JS #12042

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

Merged
merged 3 commits into from
Aug 26, 2020
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions src/library.js
Original file line number Diff line number Diff line change
Expand Up @@ -1060,8 +1060,6 @@ LibraryManager.library = {
return time1 - time0;
},

// Statically allocated copy of the string "GMT" for gmtime() to point to
__tm_timezone: '{{{ makeStaticString("GMT") }}}',
mktime__deps: ['tzset'],
mktime__sig: 'ii',
mktime: function(tmPtr) {
Expand Down Expand Up @@ -1101,7 +1099,9 @@ LibraryManager.library = {
},
timelocal: 'mktime',

gmtime_r__deps: ['__tm_timezone'],
#if MINIMAL_RUNTIME
gmtime_r__deps: ['allocateUTF8'],
#endif
gmtime_r__sig: 'iii',
gmtime_r: function(time, tmPtr) {
var date = new Date({{{ makeGetValue('time', 0, 'i32') }}}*1000);
Expand All @@ -1117,8 +1117,9 @@ LibraryManager.library = {
var start = Date.UTC(date.getUTCFullYear(), 0, 1, 0, 0, 0, 0);
var yday = ((date.getTime() - start) / (1000 * 60 * 60 * 24))|0;
{{{ makeSetValue('tmPtr', C_STRUCTS.tm.tm_yday, 'yday', 'i32') }}};
{{{ makeSetValue('tmPtr', C_STRUCTS.tm.tm_zone, '___tm_timezone', 'i32') }}};

// Allocate a string "GMT" for us to point to.
if (!_gmtime_r.GMTString) _gmtime_r.GMTString = allocateUTF8("GMT");
{{{ makeSetValue('tmPtr', C_STRUCTS.tm.tm_zone, '_gmtime_r.GMTString', 'i32') }}};
return tmPtr;
},
__gmtime_r: 'gmtime_r',
Expand All @@ -1143,7 +1144,7 @@ LibraryManager.library = {
return (date.getTime() / 1000)|0;
},

localtime_r__deps: ['__tm_timezone', 'tzset'],
localtime_r__deps: ['tzset'],
localtime_r__sig: 'iii',
localtime_r: function(time, tmPtr) {
_tzset();
Expand Down