MIRROR: javascript for ๐Ÿœ's, a tiny runtime with big ambitions
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

migrate to macro for posix

+17 -10
+17 -10
src/modules/fs.c
··· 625 625 return (double)ts.tv_sec * 1000.0 + (double)ts.tv_nsec / 1e6; 626 626 } 627 627 628 + static double posix_ts_to_ms(struct timespec ts) { 629 + return (double)ts.tv_sec * 1000.0 + (double)ts.tv_nsec / 1e6; 630 + } 631 + 628 632 #ifdef __APPLE__ 629 - #define POSIX_TS_MS(st, field) \ 630 - ((double)(st)->st_##field##spec.tv_sec * 1000.0 + (double)(st)->st_##field##spec.tv_nsec / 1e6) 631 - #define POSIX_BIRTH_MS(st) POSIX_TS_MS(st, birthtime) 633 + #define POSIX_ATIME_MS(st) posix_ts_to_ms((st)->st_atimespec) 634 + #define POSIX_MTIME_MS(st) posix_ts_to_ms((st)->st_mtimespec) 635 + #define POSIX_CTIME_MS(st) posix_ts_to_ms((st)->st_ctimespec) 636 + #define POSIX_BIRTH_MS(st) posix_ts_to_ms((st)->st_birthtimespec) 632 637 #elif defined(__linux__) 633 - #define POSIX_TS_MS(st, field) \ 634 - ((double)(st)->st_##field##im.tv_sec * 1000.0 + (double)(st)->st_##field##im.tv_nsec / 1e6) 638 + #define POSIX_ATIME_MS(st) posix_ts_to_ms((st)->st_atim) 639 + #define POSIX_MTIME_MS(st) posix_ts_to_ms((st)->st_mtim) 640 + #define POSIX_CTIME_MS(st) posix_ts_to_ms((st)->st_ctim) 635 641 #define POSIX_BIRTH_MS(st) 0.0 636 642 #else 637 - #define POSIX_TS_MS(st, field) \ 638 - ((double)(st)->st_##field.tv_sec * 1000.0 + (double)(st)->st_##field.tv_nsec / 1e6) 643 + #define POSIX_ATIME_MS(st) posix_ts_to_ms((st)->st_atim) 644 + #define POSIX_MTIME_MS(st) posix_ts_to_ms((st)->st_mtim) 645 + #define POSIX_CTIME_MS(st) posix_ts_to_ms((st)->st_ctim) 639 646 #define POSIX_BIRTH_MS(st) 0.0 640 647 #endif 641 648 ··· 662 669 .size = (double)st->st_size, 663 670 .uid = (double)st->st_uid, 664 671 .gid = (double)st->st_gid, 665 - .atime_ms = POSIX_TS_MS(st, atime), 666 - .mtime_ms = POSIX_TS_MS(st, mtime), 667 - .ctime_ms = POSIX_TS_MS(st, ctime), 672 + .atime_ms = POSIX_ATIME_MS(st), 673 + .mtime_ms = POSIX_MTIME_MS(st), 674 + .ctime_ms = POSIX_CTIME_MS(st), 668 675 .birthtime_ms = POSIX_BIRTH_MS(st), 669 676 }); 670 677 }