diff --git a/src/core/io.c b/src/core/io.c index 270d4f00..4dbcee58 100644 --- a/src/core/io.c +++ b/src/core/io.c @@ -339,7 +339,11 @@ static int io_file_get(void *p, Janet key, Janet *out) { static void io_file_marshal(void *p, JanetMarshalContext *ctx) { JanetFile *iof = (JanetFile *)p; if (ctx->flags & JANET_MARSHAL_UNSAFE) { +#ifdef JANET_WINDOWS + janet_marshal_int(ctx, _fileno(iof->file)); +#else janet_marshal_int(ctx, fileno(iof->file)); +#endif janet_marshal_int(ctx, iof->flags); } else { janet_panic("cannot marshal file in safe mode"); @@ -359,7 +363,11 @@ static void *io_file_unmarshal(JanetMarshalContext *ctx) { } else if (flags & JANET_FILE_WRITE) { fmt[index++] = 'w'; } +#ifdef JANET_WINDOWS + iof->file = _fdopen(fd, fmt); +#else iof->file = fdopen(fd, fmt); +#endif if (iof->file == NULL) { iof->flags = JANET_FILE_CLOSED; } else { diff --git a/src/core/marsh.c b/src/core/marsh.c index fac32663..ebef9239 100644 --- a/src/core/marsh.c +++ b/src/core/marsh.c @@ -898,8 +898,8 @@ static const uint8_t *unmarshal_one_def( /* Unmarshal closure bitset if needed */ if (def->flags & JANET_FUNCDEF_FLAG_HASCLOBITSET) { - size_t n = (size_t)(def->slotcount + 31) >> 5; - def->closure_bitset = malloc(sizeof(uint32_t) * n); + int32_t n = (def->slotcount + 31) >> 5; + def->closure_bitset = malloc(sizeof(uint32_t) * (size_t) n); if (NULL == def->closure_bitset) { JANET_OUT_OF_MEMORY; }