double neuron_network_fitness::fitness_of (const neuron_network & n) const { double acc[4]; acc[0] = n.accumulate (neuron_network::FALSE_FALSE); acc[1] = n.accumulate (neuron_network::FALSE_TRUE); acc[2] = n.accumulate (neuron_network::TRUE_FALSE); acc[3] = n.accumulate (neuron_network::TRUE_TRUE); acc[0] = error_value (_table.result (false, false), acc[0]); acc[1] = error_value (_table.result (false, true), acc[1]); acc[2] = error_value (_table.result (true, false), acc[2]); acc[3] = error_value (_table.result (true, true), acc[3]); double error = mean_error (acc); return error; }
/*ARGSUSED*/ VALUE custom(char *name, int count, VALUE **vals) { #if defined(CUSTOM) CONST struct custom *p; /* current function */ /* * search the custom interface table for a function */ for (p = cust; p->name != NULL; ++p) { /* look for the first match */ if (strcmp(name, p->name) == 0) { /* arg count check */ if (count < p->minargs) { math_error("Too few arguments for custom " "function \"%s\"", p->name); /*NOTREACHED*/ } if (count > p->maxargs) { math_error("Too many arguments for custom " "function \"%s\"", p->name); /*NOTREACHED*/ } /* call the custom function */ return p->func(name, count, vals); } } /* * no such custom function */ return error_value(E_UNK_CUSTOM); #else /* CUSTOM */ fprintf(stderr, "%sCalc was built with custom functions disabled\n", (conf->tab_ok ? "\t" : "")); return error_value(E_NO_CUSTOM); #endif /* CUSTOM */ }
/* * internalThread - This is the actual function called by thread when * created a new pthread. */ static void * InternalThread(void *data) { /* We save our thread id into the thread specific memory location */ pthread_setspecific(key,data); printf("Tid: %d\n", *(int*)data); /* Initialize memory for this thread */ memoryInit(); int tid = *(int *)data; int result = eval(ThreadQueue[tid].expr,ThreadQueue[tid].env); if (isThrow(result) || isError(result)) { P_P(); if(StackDebugging) { printStack(); } if(Debugging) { T_P(); printf("Error in thread %d (%d)\n" ,tid,WorkingThreads); T_V(); ShuttingDown = 1; QueueCount = 0; debug("EXCEPTION",error_code(result)); scamPPFile(stdout,error_value(result)); printf("\n"); } else { if(ThreadError == -1) { ThreadError = tid; } } P_V(); } T_P(); --WorkingThreads; T_V(); memoryShutdown(); free(data); Thread[tid] = (pthread_t)NULL; pthread_exit(NULL); return NULL; }
void CompiledScript::report_errors(REPORT_ERROR_CALLBACK report_error_callback) { v8::HandleScope handle_scope; v8::Context::Scope local(get_context()); if (!last_exception.IsEmpty()) { v8::String::Value error_value(last_exception); //TODO: define error codes report_error_callback(1, *error_value); } }
unsigned int svc_dbg_handler(unsigned int num, unsigned int param1, unsigned int param2) { CHECK_CONTEXT(SUPERVISOR_CONTEXT | IRQ_CONTEXT | SYSTEM_CONTEXT); unsigned int res = 0; switch (num) { case DBG_WRITE: if (_dbg_console) console_write(_dbg_console, (char*)param1, (int)param2); break; case DBG_PUSH: if (_dbg_console) console_push(_dbg_console); break; default: error_value(ERROR_GENERAL_INVALID_SYS_CALL, num); } return res; }
unsigned int svc_sys_time_handler(unsigned int num, unsigned int param1) { CHECK_CONTEXT(SYSTEM_CONTEXT | SUPERVISOR_CONTEXT | IRQ_CONTEXT); unsigned int res = 0; switch (num) { case TIME_GET_SYS_TIME: res = (unsigned int)svc_get_sys_time(); break; case TIME_SET_SYS_TIME: svc_set_sys_time((time_t)param1); break; case TIME_GET_UPTIME: res = (unsigned int)svc_get_uptime((TIME*)param1); break; default: error_value(ERROR_GENERAL_INVALID_SYS_CALL, num); } return res; }
unsigned int sys_handler(unsigned int num, unsigned int param1, unsigned int param2, unsigned int param3) { unsigned int res = 0; switch (num & CALL_GROUP_MASK) { case SYS_CALL_THREAD: res = (unsigned int)svc_thread_handler(num, param1, param2); break; case SYS_CALL_MUTEX: res = (unsigned int)svc_mutex_handler(num, param1, param2); break; case SYS_CALL_EVENT: res = (unsigned int)svc_event_handler(num, param1, param2); break; case SYS_CALL_SEMAPHORE: res = (unsigned int)svc_semaphore_handler(num, param1, param2); break; case SYS_CALL_QUEUE: res = (unsigned int)svc_queue_handler(num, param1, param2, param3); break; case SYS_CALL_SYS_TIMER: res = (unsigned int)svc_sys_timer_handler(num, param1); break; case SYS_CALL_TIME: res = (unsigned int)svc_sys_time_handler(num, param1); break; case SYS_CALL_MEM: res = (unsigned int)svc_mem_handler(num, param1, param2); break; case SYS_CALL_DBG: res = (unsigned int)svc_dbg_handler(num, param1, param2); break; default: error_value(ERROR_GENERAL_INVALID_SYS_CALL, num); } return res; }
unsigned int svc_queue_handler(unsigned int num, unsigned int param1, unsigned int param2, unsigned int param3) { CHECK_CONTEXT(SUPERVISOR_CONTEXT | IRQ_CONTEXT); CRITICAL_ENTER; unsigned int res = 0; switch (num) { case QUEUE_CREATE: res = (unsigned int)svc_queue_create(param1, param2, param3); break; case QUEUE_ALLOCATE_BUFFER: res = (unsigned int)svc_queue_allocate_buffer((QUEUE*)param1, (TIME*)param2); break; case QUEUE_PUSH: svc_queue_push((QUEUE*)param1, (void*)param2); break; case QUEUE_PULL: res = (unsigned int)svc_queue_pull((QUEUE*)param1, (TIME*)param2); break; case QUEUE_RELEASE_BUFFER: svc_queue_release_buffer((QUEUE*)param1, (void*)param2); break; case QUEUE_IS_EMPTY: res = (unsigned int)svc_queue_is_empty((QUEUE*)param1); break; case QUEUE_IS_FULL: res = (unsigned int)svc_queue_is_full((QUEUE*)param1); break; case QUEUE_DESTROY: svc_queue_destroy((QUEUE*)param1); break; default: error_value(ERROR_GENERAL_INVALID_SYS_CALL, num); } CRITICAL_LEAVE; return res; }
ir_rvalue * ir_rvalue::clone(void *mem_ctx, struct hash_table *) const { /* The only possible instantiation is the generic error value. */ return error_value(mem_ctx); }