diff --git a/src/core/corelib.c b/src/core/corelib.c index 52d445f3..9c03f51c 100644 --- a/src/core/corelib.c +++ b/src/core/corelib.c @@ -653,22 +653,15 @@ JANET_CORE_FN(janet_core_check_int, "(int? x)", "Check if x can be exactly represented as a 32 bit signed two's complement integer.") { janet_fixarity(argc, 1); - if (!janet_checktype(argv[0], JANET_NUMBER)) goto ret_false; - double num = janet_unwrap_number(argv[0]); - return janet_wrap_boolean(num == (double)((int32_t)num)); -ret_false: - return janet_wrap_false(); + return janet_wrap_boolean(janet_checkint(argv[0])); } JANET_CORE_FN(janet_core_check_nat, "(nat? x)", "Check if x can be exactly represented as a non-negative 32 bit signed two's complement integer.") { janet_fixarity(argc, 1); - if (!janet_checktype(argv[0], JANET_NUMBER)) goto ret_false; - double num = janet_unwrap_number(argv[0]); - return janet_wrap_boolean(num >= 0 && (num == (double)((int32_t)num))); -ret_false: - return janet_wrap_false(); + if (!janet_checkint(argv[0])) return janet_wrap_false(); + return janet_wrap_boolean(janet_unwrap_integer(argv[0]) >= 0); } JANET_CORE_FN(janet_core_is_bytes, diff --git a/src/core/ev.c b/src/core/ev.c index d0fbca56..78fe96dd 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -671,11 +671,9 @@ static DWORD WINAPI janet_timeout_body(LPVOID ptr) { JanetThreadedTimeout tto = *(JanetThreadedTimeout *)ptr; janet_free(ptr); SleepEx((DWORD)(tto.sec * 1000), TRUE); - if (janet_fiber_can_resume(tto.fiber)) { - janet_interpreter_interrupt(tto.vm); - JanetEVGenericMessage msg = {0}; - janet_ev_post_event(tto.vm, janet_timeout_cb, msg); - } + janet_interpreter_interrupt(tto.vm); + JanetEVGenericMessage msg = {0}; + janet_ev_post_event(tto.vm, janet_timeout_cb, msg); return 0; } #else @@ -696,11 +694,9 @@ static void *janet_timeout_body(void *ptr) { ? (long)((tto.sec - ((uint32_t)tto.sec)) * 1000000000) : 0; nanosleep(&ts, &ts); - if (janet_fiber_can_resume(tto.fiber)) { - janet_interpreter_interrupt(tto.vm); - JanetEVGenericMessage msg = {0}; - janet_ev_post_event(tto.vm, janet_timeout_cb, msg); - } + janet_interpreter_interrupt(tto.vm); + JanetEVGenericMessage msg = {0}; + janet_ev_post_event(tto.vm, janet_timeout_cb, msg); return NULL; } #endif