Address some windows issues.

This commit is contained in:
Calvin Rose 2020-07-03 20:13:49 -05:00
parent 3bb8f1ac8d
commit 2b36ed967c
2 changed files with 10 additions and 2 deletions

View File

@ -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 {

View File

@ -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;
}