Add convenience macros for raising exceptions in C functions which may run on future threads
This commit is contained in:
parent
1978002312
commit
783ee2cf88
|
@ -285,11 +285,6 @@ static void future_do_runtimecall(struct Scheme_Future_Thread_State *fts,
|
|||
int is_atomic,
|
||||
int can_suspend);
|
||||
static int capture_future_continuation(future_t *ft, void **storage);
|
||||
static void future_raise_wrong_type_exn(const char *who,
|
||||
const char *expected_type,
|
||||
int what,
|
||||
int argc,
|
||||
Scheme_Object **argv);
|
||||
|
||||
#define INITIAL_C_STACK_SIZE 500000
|
||||
#define FUTURE_RUNSTACK_SIZE 2000
|
||||
|
@ -1297,13 +1292,7 @@ Scheme_Object *scheme_fsemaphore_count(int argc, Scheme_Object **argv)
|
|||
fsemaphore_t *sema;
|
||||
|
||||
if (!SAME_TYPE(SCHEME_TYPE(argv[0]), scheme_fsemaphore_type)) {
|
||||
Scheme_Future_Thread_State *fts = scheme_future_thread_state;
|
||||
if (!fts) {
|
||||
scheme_wrong_type("fsemaphore-count", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
/* On a future thread -- ask the runtime to raise an exception for us */
|
||||
future_raise_wrong_type_exn("fsemaphore-count", "fsemaphore", 0, argc, argv);
|
||||
SCHEME_WRONG_TYPE_MAYBE_IN_FT("fsemaphore-count", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
sema = (fsemaphore_t*)argv[0];
|
||||
|
@ -1362,13 +1351,7 @@ Scheme_Object *scheme_fsemaphore_post(int argc, Scheme_Object **argv)
|
|||
int old_count;
|
||||
|
||||
if (!SAME_TYPE(SCHEME_TYPE(argv[0]), scheme_fsemaphore_type)) {
|
||||
Scheme_Future_Thread_State *fts = scheme_future_thread_state;
|
||||
if (!fts) {
|
||||
scheme_wrong_type("fsemaphore-post", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
/* On a future thread -- ask the runtime to raise an exception for us */
|
||||
future_raise_wrong_type_exn("fsemaphore-post", "fsemaphore", 0, argc, argv);
|
||||
SCHEME_WRONG_TYPE_MAYBE_IN_FT("fsemaphore-post", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
sema = (fsemaphore_t*)argv[0];
|
||||
|
@ -1428,13 +1411,7 @@ Scheme_Object *scheme_fsemaphore_wait(int argc, Scheme_Object **argv)
|
|||
void *storage[3];
|
||||
|
||||
if (!SAME_TYPE(SCHEME_TYPE(argv[0]), scheme_fsemaphore_type)) {
|
||||
Scheme_Future_Thread_State *fts = scheme_future_thread_state;
|
||||
if (!fts) {
|
||||
scheme_wrong_type("fsemaphore-wait", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
/* On a future thread -- ask the runtime to raise an exception for us */
|
||||
future_raise_wrong_type_exn("fsemaphore-wait", "fsemaphore", 0, argc, argv);
|
||||
SCHEME_WRONG_TYPE_MAYBE_IN_FT("fsemaphore-wait", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
sema = (fsemaphore_t*)argv[0];
|
||||
|
@ -1546,13 +1523,7 @@ Scheme_Object *scheme_fsemaphore_try_wait(int argc, Scheme_Object **argv)
|
|||
Scheme_Object *ret;
|
||||
|
||||
if (!SAME_TYPE(SCHEME_TYPE(argv[0]), scheme_fsemaphore_type)) {
|
||||
Scheme_Future_Thread_State *fts = scheme_future_thread_state;
|
||||
if (!fts) {
|
||||
scheme_wrong_type("fsemaphore-try-wait?", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
/* On a future thread -- ask the runtime to raise an exception for us */
|
||||
future_raise_wrong_type_exn("fsemaphore-try-wait?", "fsemaphore", 0, argc, argv);
|
||||
SCHEME_WRONG_TYPE_MAYBE_IN_FT("fsemaphore-try-wait?", "fsemaphore", 0, argc, argv);
|
||||
}
|
||||
|
||||
sema = (fsemaphore_t*)argv[0];
|
||||
|
@ -2510,7 +2481,7 @@ static void future_do_runtimecall(Scheme_Future_Thread_State *fts,
|
|||
/**********************************************************************/
|
||||
/* Functions for primitive invocation */
|
||||
/**********************************************************************/
|
||||
static void future_raise_wrong_type_exn(const char *who, const char *expected_type, int what, int argc, Scheme_Object **argv)
|
||||
void scheme_wrong_type_from_ft(const char *who, const char *expected_type, int what, int argc, Scheme_Object **argv)
|
||||
XFORM_SKIP_PROC
|
||||
/* Called in future thread */
|
||||
{
|
||||
|
|
|
@ -158,6 +158,15 @@ typedef struct fsemaphore_t {
|
|||
|
||||
/* Primitive instrumentation stuff */
|
||||
|
||||
/* Exceptions */
|
||||
void scheme_wrong_type_from_ft(const char *who, const char *expected_type, int what, int argc, Scheme_Object **argv);
|
||||
|
||||
#define SCHEME_WRONG_TYPE_MAYBE_IN_FT(who, expected_type, what, argc, argv) \
|
||||
if (scheme_use_rtcall) \
|
||||
scheme_wrong_type_from_ft(who, expected_type, what, argc, argv); \
|
||||
else \
|
||||
scheme_wrong_type(who, expected_type, what, argc, argv);
|
||||
|
||||
/* Signature flags for primitive invocations */
|
||||
#define SIG_ON_DEMAND 1
|
||||
#define SIG_ALLOC 2
|
||||
|
|
Loading…
Reference in New Issue
Block a user