00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUFLOW_CNTN_COMMON_H
00019 #define CUFLOW_CNTN_COMMON_H
00020
00021 #include <cuflow/fwd.h>
00022
00023 CU_BEGIN_DECLARATIONS
00024
00025 #include <cu/clos.h>
00026 #include <cuflow/cont.h>
00027 #include <cu/conf.h>
00028 #include <cu/debug.h>
00029 #include <string.h>
00030 #include <malloc.h>
00031 #include <assert.h>
00032 #include <stdarg.h>
00033 #include <stdio.h>
00034 #include <limits.h>
00035 #if 1
00036 #include <cu/conf.h>
00037 #ifdef CUCONF_HAVE_GC_GC_H
00038 # include <gc/gc.h>
00039 #else
00040 # include <gc.h>
00041 #endif
00042 #else
00043 # define GC_MALLOC malloc
00044 # define GC_NEW(T) malloc(sizeof(T))
00045 #endif
00046
00047 #define CUCONF_ENABLE_FLOW_CHECK 1
00048
00049 #define CUFLOW_STACK_DELTA (CUCONF_STACK_DIRECTION*sizeof(cuflowP_stack_item_t))
00050
00051 void cuflowP_fatal(char const* fmt, ...) CU_ATTR_NORETURN;
00052
00053 void cuflowP_mismatched_flow(char const *where, cuflow_mode_t org_flow)
00054 CU_ATTR_NORETURN;
00055
00056
00057
00058
00059 #ifdef CUCONF_ENABLE_THREADS
00060 #include <pthread.h>
00061 extern pthread_mutex_t cuflowP_g_mutex;
00062 # define LOCK_GSTATE() pthread_mutex_lock(&cuflowP_g_mutex)
00063 # define UNLOCK_GSTATE() pthread_mutex_unlock(&cuflowP_g_mutex);
00064 #else
00065 # define LOCK_GSTATE() ((void)0)
00066 # define UNLOCK_GSTATE() ((void)0)
00067 #endif
00068
00069 #define CUFLOW_STACK_BREAK(PURPOSE, STATE, CONT) \
00070 cuflow_tstate_t STATE = cuflow_tstate(); \
00071 cuflow_continuation_t CONT = GC_NEW(struct cuflow_continuation); \
00072 cuflowP_set_stack_mark(CONT); \
00073 CONT->kind = cuflowP_cntn_kind_##PURPOSE; \
00074 CONT->flags = 0; \
00075 CONT->level = st->onstack_cont->level + 1; \
00076 CONT->up = st->onstack_cont; \
00077 CONT->stack_data = 0;
00078
00079 cu_clos_edec(cuflowP_call_cntn,
00080 cu_prot(void, void *arg_ptr),
00081 ( struct cuflow_continuation cont;
00082 void *result_ptr;
00083 size_t result_size; ));
00084
00085 void cuflowP_save_stack(cuflow_continuation_t cont);
00086 void cuflowP_set_stack_mark(cuflow_continuation_t cont);
00087
00088 cu_clop(cuflowP_g_on_uncaught, void, void *);
00089 extern size_t cuflowP_size_copied;
00090 extern size_t cuflowP_split_count;
00091
00092 CU_END_DECLARATIONS
00093
00094 #endif