void test_stack() { DCThunk t; printfun* fp; dcbInitThunk(&t, &my_entry); fp = (printfun*)&t; fp("stack"); }
DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata) { DCCallback* pcb; int err = dcAllocWX(sizeof(DCCallback), (void**) &pcb); if (err != 0) return 0; dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry); dcbInitCallback(pcb, signature, handler, userdata); return pcb; }
void test_stack() { DCThunk t; printfun* fp; dcbInitThunk(&t, &my_entry); fp = (printfun*)&t; if(setjmp(jbuf) != 0) printf("sigsegv\n"); else fp("stack"); }
void test_heap() { printfun* fp; DCThunk* p = (DCThunk*)malloc(sizeof(DCThunk)); if(!p) { printf("0\n"); return; } dcbInitThunk(p, &my_entry); fp = (printfun*)p; fp("heap"); free(p); }
void test_wx() { DCThunk* p; printfun* fp; int err = dcAllocWX(sizeof(DCThunk), (void**)&p); if(err || !p) { printf("0\n"); return; } dcbInitThunk(p, &my_entry); fp = (printfun*)p; fp("wx"); dcFreeWX((void*)p, sizeof(DCThunk)); }
void test_heap() { printfun* fp; DCThunk* p = (DCThunk*)malloc(sizeof(DCThunk)); if(!p) { printf("0\n"); return; } dcbInitThunk(p, &my_entry); fp = (printfun*)p; if(setjmp(jbuf) != 0) printf("sigsegv\n"); else fp("heap"); free(p); }
DCAdapterCallback* dcRawCallAdapterSkipTwoArgs(void (*handler)(), int callMode) { #ifndef DIRECT_SKIP_TWO_ARGS return NULL; #else int err; DCAdapterCallback* pcb; if (callMode != DC_CALL_C_DEFAULT) return NULL; err = dcAllocWX(sizeof(DCAdapterCallback), (void**) &pcb); if (err != 0) return 0; dcbInitThunk(&pcb->thunk, DIRECT_SKIP_TWO_ARGS); pcb->handler = handler; return pcb; #endif }
DCCallback* dcbNewCallback(const char* signature, DCCallbackHandler* handler, void* userdata) { int err; DCCallback* pcb; err = dcAllocWX(sizeof(DCCallback), (void**)&pcb); if(err) return NULL; dcbInitThunk(&pcb->thunk, dcCallbackThunkEntry); dcbInitCallback(pcb, signature, handler, userdata); err = dcInitExecWX(pcb, sizeof(DCCallback)); if(err) { dcFreeWX(pcb, sizeof(DCCallback)); return NULL; } return pcb; }
void test_wx() { DCThunk* p; printfun* fp; int err = dcAllocWX(sizeof(DCThunk), (void**)&p); if(err || !p) { printf("0\n"); return; } dcbInitThunk(p, &my_entry); err = dcInitExecWX((void*)p, sizeof(DCThunk)); if(err) { dcFreeWX((void*)p, sizeof(DCThunk)); printf("0\n"); return; } fp = (printfun*)p; if(setjmp(jbuf) != 0) printf("sigsegv\n"); else fp("wx"); dcFreeWX((void*)p, sizeof(DCThunk)); }