Skip to content

Commit 585a339

Browse files
committed
- Cast the struct stat sb.st_ino field to machine_int_t explicitly to avoid a
cast error in MP_OBJ_NEW_SMALL_INT(). This is necessary for FreeBSD, where st_ino is of different size - If MP_CLOCKS_PER_SEC is defined on the target host, simply define CLOCK_DIV as a fraction, regardless of the value of MP_CLOCKS_PER_SEC. FreeBSD uses a non-POSIX compliant value of 128 for CLOCKS_PER_SEC
1 parent c61be8e commit 585a339

2 files changed

Lines changed: 3 additions & 5 deletions

File tree

unix/modos.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
5252

5353
mp_obj_tuple_t *t = mp_obj_new_tuple(10, NULL);
5454
t->items[0] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_mode);
55-
t->items[1] = MP_OBJ_NEW_SMALL_INT(sb.st_ino);
55+
t->items[1] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_ino);
5656
t->items[2] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_dev);
5757
t->items[3] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_nlink);
5858
t->items[4] = MP_OBJ_NEW_SMALL_INT((machine_int_t)sb.st_uid);

unix/modtime.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -55,10 +55,8 @@ void msec_sleep_tv(struct timeval *tv) {
5555
#define MP_CLOCKS_PER_SEC CLOCKS_PER_SEC
5656
#endif
5757

58-
#if defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000000) // POSIX
59-
#define CLOCK_DIV 1000.0
60-
#elif defined(MP_CLOCKS_PER_SEC) && (MP_CLOCKS_PER_SEC == 1000) // WIN32
61-
#define CLOCK_DIV 1.0
58+
#if defined(MP_CLOCKS_PER_SEC)
59+
#define CLOCK_DIV (MP_CLOCKS_PER_SEC / 1000.0)
6260
#else
6361
#error Unsupported clock() implementation
6462
#endif

0 commit comments

Comments
 (0)