diff --git a/system/lib/libc/emscripten_time.c b/system/lib/libc/emscripten_time.c index 6f150c1229dfd..88c9c4853db2a 100644 --- a/system/lib/libc/emscripten_time.c +++ b/system/lib/libc/emscripten_time.c @@ -19,8 +19,8 @@ __attribute__((__weak__)) int daylight = 0; __attribute__((__weak__)) char *tzname[2] = { 0, 0 }; void _tzset_js(long* timezone, int* daylight, char** tzname); -time_t _timegm_js(struct tm *tm); -time_t _mktime_js(struct tm *tm); +int _timegm_js(struct tm *tm); +int _mktime_js(struct tm *tm); void _localtime_js(const time_t *restrict t, struct tm *restrict tm); void _gmtime_js(const time_t *restrict t, struct tm *restrict tm); double _emscripten_date_now(); diff --git a/system/lib/libc/musl/arch/emscripten/bits/alltypes.h b/system/lib/libc/musl/arch/emscripten/bits/alltypes.h index e90252190f63c..f239859acacb6 100644 --- a/system/lib/libc/musl/arch/emscripten/bits/alltypes.h +++ b/system/lib/libc/musl/arch/emscripten/bits/alltypes.h @@ -78,12 +78,12 @@ typedef long double double_t; #endif #if defined(__NEED_time_t) && !defined(__DEFINED_time_t) -typedef int time_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */ +typedef _Int64 time_t; #define __DEFINED_time_t #endif #if defined(__NEED_suseconds_t) && !defined(__DEFINED_suseconds_t) -typedef int suseconds_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */ +typedef _Int64 suseconds_t; #define __DEFINED_suseconds_t #endif @@ -248,27 +248,27 @@ typedef unsigned _Int64 ino_t; #endif #if defined(__NEED_dev_t) && !defined(__DEFINED_dev_t) -typedef unsigned int dev_t; +typedef unsigned _Int64 dev_t; #define __DEFINED_dev_t #endif #if defined(__NEED_blksize_t) && !defined(__DEFINED_blksize_t) -typedef int blksize_t; /* XXX EMSCRIPTEN: ensure it's always 32-bits even in wasm64 */ -#define __DEFINED_blksize_t +typedef long blksize_t; +#define __DEF_Int64 #endif #if defined(__NEED_blkcnt_t) && !defined(__DEFINED_blkcnt_t) -typedef int blkcnt_t; +typedef _Int64 blkcnt_t; #define __DEFINED_blkcnt_t #endif #if defined(__NEED_fsblkcnt_t) && !defined(__DEFINED_fsblkcnt_t) -typedef unsigned int fsblkcnt_t; +typedef unsigned _Int64 fsblkcnt_t; #define __DEFINED_fsblkcnt_t #endif #if defined(__NEED_fsfilcnt_t) && !defined(__DEFINED_fsfilcnt_t) -typedef unsigned int fsfilcnt_t; +typedef unsigned _Int64 fsfilcnt_t; #define __DEFINED_fsfilcnt_t #endif diff --git a/system/lib/libc/musl/include/inttypes.h b/system/lib/libc/musl/include/inttypes.h index fd012b0f33964..90c35c8664ae8 100644 --- a/system/lib/libc/musl/include/inttypes.h +++ b/system/lib/libc/musl/include/inttypes.h @@ -22,14 +22,14 @@ uintmax_t strtoumax(const char *__restrict, char **__restrict, int); intmax_t wcstoimax(const wchar_t *__restrict, wchar_t **__restrict, int); uintmax_t wcstoumax(const wchar_t *__restrict, wchar_t **__restrict, int); -#if UINTPTR_MAX == UINT64_MAX -#define __PRI64 "l" -#define __PRIPTR "l" -#elif defined(__EMSCRIPTEN__) +#if defined(__EMSCRIPTEN__) // Under emscripten __PTRDIFF_TYPE__ and therefor intptr_t are defined to // be `long int` even on wasm32. #define __PRI64 "ll" #define __PRIPTR "l" +#elif UINTPTR_MAX == UINT64_MAX +#define __PRI64 "l" +#define __PRIPTR "l" #else #define __PRI64 "ll" #define __PRIPTR "" diff --git a/tests/core/test_statvfs.c b/tests/core/test_statvfs.c index 2de11485b03ff..f1cc925d4974a 100644 --- a/tests/core/test_statvfs.c +++ b/tests/core/test_statvfs.c @@ -7,6 +7,7 @@ #include #include +#include #include int main() { @@ -17,12 +18,12 @@ int main() { printf("f_bsize: %lu\n", s.f_bsize); printf("f_frsize: %lu\n", s.f_frsize); - printf("f_blocks: %u\n", s.f_blocks); - printf("f_bfree: %u\n", s.f_bfree); - printf("f_bavail: %u\n", s.f_bavail); + printf("f_blocks: %" PRId64 "\n", s.f_blocks); + printf("f_bfree: %" PRId64 "\n", s.f_bfree); + printf("f_bavail: %" PRId64 "\n", s.f_bavail); printf("f_files: %d\n", s.f_files > 5); - printf("f_ffree: %u\n", s.f_ffree); - printf("f_favail: %u\n", s.f_favail); + printf("f_ffree: %" PRId64 "\n", s.f_ffree); + printf("f_favail: %" PRId64 "\n", s.f_favail); printf("f_fsid: %lu\n", s.f_fsid); printf("f_flag: %lu\n", s.f_flag); printf("f_namemax: %lu\n", s.f_namemax); diff --git a/tests/utime/test_utime.c b/tests/utime/test_utime.c index ebc78c5dc6656..76c37e56953e1 100644 --- a/tests/utime/test_utime.c +++ b/tests/utime/test_utime.c @@ -7,6 +7,7 @@ #include #include +#include #include #include #include @@ -51,9 +52,9 @@ void test() { stat("writeable", &s); assert(s.st_atime == s.st_mtime); time_t diff = s.st_atime - now; - if (abs(diff) > 5) { - fprintf(stderr, "st_atime: %i, now: %i, diff: %i\n ", s.st_atime, now, diff); - assert(abs(diff) <= 5); + if (llabs(diff) > 5) { + fprintf(stderr, "st_atime: %" PRId64 ", now: %" PRId64 ", diff: %" PRId64 "\n ", s.st_atime, now, diff); + assert(llabs(diff) <= 5); } // write permissions aren't checked when setting node