move interrupt check to its own header
This commit is contained in:
parent
7a21f9ef73
commit
572bc04459
@ -4,6 +4,7 @@
|
||||
#include "utils/utf.h"
|
||||
#include "utils/file.h"
|
||||
#include "utils/time.h"
|
||||
#include "utils/interrupt.h"
|
||||
|
||||
static B replPath;
|
||||
static Scope* gsc;
|
||||
|
||||
14
src/utils/interrupt.h
Normal file
14
src/utils/interrupt.h
Normal file
@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
#if REPL_INTERRUPT && !__has_include(<signal.h>)
|
||||
#undef REPL_INTERRUPT
|
||||
#endif
|
||||
|
||||
bool cbqn_takeInterrupts(bool b);
|
||||
|
||||
#if REPL_INTERRUPT
|
||||
extern volatile int cbqn_interrupted;
|
||||
NOINLINE NORETURN void cbqn_onInterrupt();
|
||||
#define CHECK_INTERRUPT ({ if (cbqn_interrupted) cbqn_onInterrupt(); })
|
||||
#else
|
||||
#define CHECK_INTERRUPT
|
||||
#endif
|
||||
8
src/vm.c
8
src/vm.c
@ -5,6 +5,7 @@
|
||||
#include "utils/utf.h"
|
||||
#include "utils/talloc.h"
|
||||
#include "utils/mut.h"
|
||||
#include "utils/interrupt.h"
|
||||
|
||||
#ifndef UNWIND_COMPILER // whether to hide stackframes of the compiler in compiling errors
|
||||
#define UNWIND_COMPILER 1
|
||||
@ -843,10 +844,9 @@ B mnvmExecBodyInline(Body* body, Scope* sc) {
|
||||
|
||||
|
||||
|
||||
#if __has_include(<signal.h>) && REPL_INTERRUPT
|
||||
volatile int cbqn_interrupted;
|
||||
#if REPL_INTERRUPT
|
||||
#include <signal.h>
|
||||
bool cbqn_takeInterrupts(bool b);
|
||||
volatile int cbqn_interrupted;
|
||||
static void interrupt_sigHandler(int x) {
|
||||
if (cbqn_interrupted) abort(); // shouldn't happen
|
||||
cbqn_takeInterrupts(false);
|
||||
@ -863,10 +863,8 @@ NOINLINE NORETURN void cbqn_onInterrupt() {
|
||||
cbqn_interrupted = 0;
|
||||
thrM("interrupted");
|
||||
}
|
||||
#define CHECK_INTERRUPT ({ if (cbqn_interrupted) cbqn_onInterrupt(); })
|
||||
#else
|
||||
bool cbqn_takeInterrupts(bool b) { return false; }
|
||||
#define CHECK_INTERRUPT
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
1
src/vm.h
1
src/vm.h
@ -236,7 +236,6 @@ NOINLINE B vm_fmtPoint(B src, B prepend, B path, usz cs, usz ce); // consumes pr
|
||||
NOINLINE void printErrMsg(B msg);
|
||||
NOINLINE void unwindEnv(Env* envNew); // envNew==envStart-1 for emptying the env stack
|
||||
NOINLINE void unwindCompiler(void); // unwind to the env of the invocation of the compiler; UB when not in compiler!
|
||||
bool cbqn_takeInterrupts(bool b);
|
||||
usz getPageSize(void);
|
||||
|
||||
|
||||
|
||||
@ -25,3 +25,5 @@ make f='-DLOG_GC' c && ./BQN -p 2+2 || exit
|
||||
make f='-DWRITE_ASM' c && ./BQN -p 2+2 || exit
|
||||
make f='-DUSE_PERF' c && ./BQN -p 2+2 || exit
|
||||
make f='-DUSZ_64' c && ./BQN -p 2+2 || exit
|
||||
make f='-DREPL_INTERRUPT=0' c && ./BQN -p 2+2 || exit
|
||||
make f='-DREPL_INTERRUPT=1' c && ./BQN -p 2+2 || exit
|
||||
|
||||
Loading…
Reference in New Issue
Block a user