static cx_errThreadData* cx_getThreadData(void){ cx_errThreadData* result; if (!cx_errKey) { cx_threadTlsKey(&cx_errKey, cx_lasterrorFree); } result = cx_threadTlsGet(cx_errKey); if (!result) { result = cx_malloc(sizeof(cx_errThreadData)); memset(result, 0, sizeof(cx_errThreadData)); result->echo = TRUE; cx_threadTlsSet(cx_errKey, result); } return result; }
/* This function is the entrypoint for the library and * loads definitions of the 'ic' scope */ int cortexmain(int argc, char* argv[]) { CX_UNUSED(argc); CX_UNUSED(argv); int result = ic_load(); /* $begin(cortexmain) */ if (cx_threadTlsKey(&IC_PROGRAM_KEY, NULL)) { return -1; } /* $end */ return result; }
int idlMain(int argc, char* argv[]) { /* $begin(main) */ /* Insert code that must be run when component is loaded */ CX_UNUSED(argc); CX_UNUSED(argv); if (cx_threadTlsKey(&idl_PARSER_KEY, NULL)) { return -1; } /* Register corto extension */ cx_loaderRegister("idl", idl_loadFile, NULL); return 0; /* $end */ }
int cx_start(void) { /* Initialize threadkeys */ cx_threadTlsKey(&CX_KEY_OBSERVER_ADMIN, NULL); cx_threadTlsKey(&CX_KEY_WAIT_ADMIN, NULL); /* Init admin-lock */ cx_mutexNew(&cx_adminLock); /* Bootstrap sizes of types used in parameters, these are used to determine * argument-stack sizes for functions during function::bind. */ cx_type(cx_string_o)->size = sizeof(cx_string); cx_type(cx_int32_o)->size = sizeof(cx_int32); cx_type(cx_uint32_o)->size = sizeof(cx_uint32); cx_type(cx_any_o)->size = sizeof(cx_any); cx_type(cx_state_o)->size = sizeof(cx_state); cx_type(cx_attr_o)->size = sizeof(cx_attr); /* Initialize builtin scopes */ cx_initObject(root_o); cx_initObject(cortex_o); cx_initObject(cortex_lang_o); /* Define builtin scopes */ cx_defineObject(root_o); cx_defineObject(cortex_o); cx_defineObject(cortex_lang_o); /* Init objects */ SSO_OP_TYPE(cx_initType); SSO_OP_OBJECT(cx_initObject); SSO_OP_OBJECT_2ND(cx_initObject); /* Construct objects */ SSO_OP_OBJECT_2ND(cx_defineObject); SSO_OP_OBJECT(cx_defineObject); SSO_OP_TYPE(cx_defineType); /* Update refcounts of public members */ SSO_OP_TYPE(cx_updateRefType); SSO_OP_OBJECT(cx_updateRef); SSO_OP_OBJECT_2ND(cx_updateRef); /* Initialize conversions and operators */ cx_convertInit(); cx_operatorInit(); /* Register C-binding and vm-binding */ { cx_uint32 id; id = cx_callRegisterBinding(NULL, NULL, NULL, NULL); cx_assert(id == 1, "C-binding did not receive binding-id 1."); id = cx_callRegisterBinding(cx_call_vm, NULL, NULL, (cx_callDestructHandler)cx_callDestruct_vm); cx_assert(id == 2, "Vm-binding did not receive binding-id 2."); } /* Always randomize seed */ srand (time(NULL)); /* Init CRC table */ cx_crcInit(); return 0; }