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; }
int main() { int err; void* ptr; dcTest_initPlatform(); err = dcAllocWX(23, &ptr); if(!err) dcFreeWX(ptr, 23); printf("result: test_alloc_wx: %d\n", (!err) ? 1 : 0 ); dcTest_deInitPlatform(); return err; }
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)); }
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)); }