@@ -397,21 +397,6 @@ LibraryManager.library = {
397
397
return ( ( Date . now ( ) - _clock . start ) * ( { { { cDefine ( 'CLOCKS_PER_SEC' ) } } } / 1000 ) ) | 0 ;
398
398
} ,
399
399
400
- time__sig : 'ii ',
401
- time : function ( ptr ) {
402
- { { { from64 ( 'ptr' ) } } } ;
403
- var ret = ( Date . now ( ) / 1000 ) | 0 ;
404
- if ( ptr ) {
405
- { { { makeSetValue ( 'ptr' , 0 , 'ret' , 'i32' ) } } } ;
406
- }
407
- return ret ;
408
- } ,
409
-
410
- difftime__sig : 'dii ',
411
- difftime : function ( time1 , time0 ) {
412
- return time1 - time0 ;
413
- } ,
414
-
415
400
_mktime_js__sig : 'ii ',
416
401
_mktime_js : function ( tmPtr ) {
417
402
var date = new Date ( { { { makeGetValue ( 'tmPtr' , C_STRUCTS . tm . tm_year , 'i32' ) } } } + 1900 ,
@@ -1275,7 +1260,8 @@ LibraryManager.library = {
1275
1260
setErrNo ( { { { cDefine ( 'EINVAL' ) } } } ) ;
1276
1261
return - 1 ;
1277
1262
}
1278
- { { { makeSetValue ( 'tp' , C_STRUCTS . timespec . tv_sec , '(now/1000)|0' , 'i32' ) } } } ; // seconds
1263
+ // struct timespec { time_t tv_sec; long tv_nsec; };
1264
+ { { { makeSetValue ( 'tp' , C_STRUCTS . timespec . tv_sec , 'Math.floor(now/1000)' , 'i64' ) } } } ; // seconds
1279
1265
{ { { makeSetValue ( 'tp' , C_STRUCTS . timespec . tv_nsec , '((now % 1000)*1000*1000)|0' , 'i32' ) } } } ; // nanoseconds
1280
1266
return 0 ;
1281
1267
} ,
@@ -1293,16 +1279,18 @@ LibraryManager.library = {
1293
1279
setErrNo ( { { { cDefine ( 'EINVAL' ) } } } ) ;
1294
1280
return - 1 ;
1295
1281
}
1296
- { { { makeSetValue ( 'res' , C_STRUCTS . timespec . tv_sec , '(nsec/1000000000)|0' , 'i32' ) } } } ;
1282
+ // struct timespec { time_t tv_sec; long tv_nsec; };
1283
+ { { { makeSetValue ( 'res' , C_STRUCTS . timespec . tv_sec , 'Math.floor(nsec/1000000000)' , 'i64' ) } } } ;
1297
1284
{ { { makeSetValue ( 'res' , C_STRUCTS . timespec . tv_nsec , 'nsec' , 'i32' ) } } } // resolution is nanoseconds
1298
1285
return 0 ;
1299
1286
} ,
1300
1287
gettimeofday__sig : 'iii ',
1301
1288
// http://pubs.opengroup.org/onlinepubs/000095399/basedefs/sys/time.h.html
1302
1289
gettimeofday : function ( ptr ) {
1303
1290
var now = Date . now ( ) ;
1304
- { { { makeSetValue ( 'ptr' , C_STRUCTS . timeval . tv_sec , '(now/1000)|0' , 'i32' ) } } } ; // seconds
1305
- { { { makeSetValue ( 'ptr' , C_STRUCTS . timeval . tv_usec , '((now % 1000)*1000)|0' , 'i32' ) } } } ; // microseconds
1291
+ // struct timeval { time_t tv_sec; suseconds_t tv_usec; };
1292
+ { { { makeSetValue ( 'ptr' , C_STRUCTS . timeval . tv_sec , 'Math.floor(now/1000)' , 'i64' ) } } } ; // seconds
1293
+ { { { makeSetValue ( 'ptr' , C_STRUCTS . timeval . tv_usec , 'Math.floor((now % 1000)*1000)' , 'i64' ) } } } ; // microseconds
1306
1294
return 0 ;
1307
1295
} ,
1308
1296
@@ -1312,7 +1300,8 @@ LibraryManager.library = {
1312
1300
1313
1301
ftime : function ( p ) {
1314
1302
var millis = Date . now ( ) ;
1315
- { { { makeSetValue ( 'p' , C_STRUCTS . timeb . time , '(millis/1000)|0' , 'i32' ) } } } ;
1303
+ // struct timeb { time_t time; unsigned short millitm; short timezone; short dstflag; };
1304
+ { { { makeSetValue ( 'p' , C_STRUCTS . timeb . time , 'Math.floor(millis/1000)' , 'i64' ) } } } ;
1316
1305
{ { { makeSetValue ( 'p' , C_STRUCTS . timeb . millitm , 'millis % 1000' , 'i16' ) } } } ;
1317
1306
{ { { makeSetValue ( 'p' , C_STRUCTS . timeb . timezone , '0' , 'i16' ) } } } ; // Obsolete field
1318
1307
{ { { makeSetValue ( 'p' , C_STRUCTS . timeb . dstflag , '0' , 'i16' ) } } } ; // Obsolete field
0 commit comments