int vm_event(vm_t* vm, seL4_MessageInfo_t tag) { seL4_Word label; seL4_Word length; label = seL4_MessageInfo_get_label(tag); length = seL4_MessageInfo_get_length(tag); switch (label) { case SEL4_PFIPC_LABEL: { int err; fault_t* fault; fault = vm->fault; err = new_fault(fault); assert(!err); do { err = handle_page_fault(vm, fault); if (err) { return -1; } } while (!fault_handled(fault)); } break; case SEL4_EXCEPT_IPC_LABEL: { int err; assert(length == SEL4_EXCEPT_IPC_LENGTH); err = handle_syscall(vm, length); assert(!err); if (!err) { seL4_MessageInfo_t reply; reply = seL4_MessageInfo_new(0, 0, 0, 0); seL4_Reply(reply); } } break; case SEL4_USER_EXCEPTION_LABEL: { seL4_Word ip; int err; assert(length == SEL4_USER_EXCEPTION_LENGTH); ip = seL4_GetMR(0); err = handle_exception(vm, ip); assert(!err); if (!err) { seL4_MessageInfo_t reply; reply = seL4_MessageInfo_new(0, 0, 0, 0); seL4_Reply(reply); } } break; case SEL4_VGIC_MAINTENANCE_LABEL: { int idx; int err; assert(length == SEL4_VGIC_MAINTENANCE_LENGTH); idx = seL4_GetMR(EXCEPT_IPC_SYS_MR_R0); /* Currently not handling spurious IRQs */ assert(idx >= 0); err = handle_vgic_maintenance(vm, idx); assert(!err); if (!err) { seL4_MessageInfo_t reply; reply = seL4_MessageInfo_new(0, 0, 0, 0); seL4_Reply(reply); } } break; case SEL4_VCPU_FAULT_LABEL: { seL4_MessageInfo_t reply; seL4_UserContext regs; seL4_CPtr tcb; uint32_t hsr; int err; assert(length == SEL4_VCPU_FAULT_LENGTH); hsr = seL4_GetMR(EXCEPT_IPC_SYS_MR_R0); /* Increment the PC and ignore the fault */ tcb = vm_get_tcb(vm); err = seL4_TCB_ReadRegisters(tcb, false, 0, sizeof(regs) / sizeof(regs.pc), ®s); assert(!err); switch (hsr) { case HSR_WFI: case HSR_WFE: regs.pc += (regs.cpsr & BIT(5)) ? 2 : 4; err = seL4_TCB_WriteRegisters(tcb, false, 0, sizeof(regs) / sizeof(regs.pc), ®s); assert(!err); reply = seL4_MessageInfo_new(0, 0, 0, 0); seL4_Reply(reply); return 0; default: printf("Unhandled VCPU fault from [%s]: HSR 0x%08x\n", vm->name, hsr); print_ctx_regs(®s); return -1; } } break; default: /* What? Why are we here? What just happened? */ printf("Unknown fault from [%s]: label=0x%x length=0x%x\n", vm->name, label, length); return -1; } return 0; }
zimg_filter *zimg2_colorspace_create(const zimg_colorspace_params *params) { assert(params); API_VERSION_ASSERT(params->version); try { std::unique_ptr<zimg::IZimgFilter> colorspace_filter; zimg::colorspace::ColorspaceDefinition csp_in{}; zimg::colorspace::ColorspaceDefinition csp_out{}; zimg::PixelType pixel_type{}; unsigned width = 0; unsigned height = 0; unsigned depth = 0; bool range_in = false; bool range_out = false; if (params->version >= 2) { width = params->width; height = params->height; csp_in.matrix = translate_matrix(params->matrix_in); csp_in.transfer = translate_transfer(params->transfer_in); csp_in.primaries = translate_primaries(params->primaries_in); csp_out.matrix = translate_matrix(params->matrix_out); csp_out.transfer = translate_transfer(params->transfer_out); csp_out.primaries = translate_primaries(params->primaries_out); pixel_type = translate_pixel_type(params->pixel_type); depth = params->depth; range_in = translate_pixel_range(params->range_in); range_out = translate_pixel_range(params->range_out); } colorspace_filter.reset(new zimg::colorspace::ColorspaceConversion2{ width, height, csp_in, csp_out, g_cpu_type }); if (pixel_type != zimg::PixelType::FLOAT) { std::unique_ptr<zimg::IZimgFilter> to_float; std::unique_ptr<zimg::IZimgFilter> from_float; std::unique_ptr<zimg::IZimgFilter> pair_filter1; std::unique_ptr<zimg::IZimgFilter> pair_filter2; zimg::PixelFormat pixel_format = zimg::default_pixel_format(pixel_type); zimg::PixelFormat float_format = zimg::default_pixel_format(zimg::PixelType::FLOAT); bool yuv_in = csp_in.matrix != zimg::colorspace::MatrixCoefficients::MATRIX_RGB; bool yuv_out = csp_out.matrix != zimg::colorspace::MatrixCoefficients::MATRIX_RGB; pixel_format.depth = depth; pixel_format.fullrange = range_in; to_float.reset(create_depth_color_filter(width, height, pixel_format, float_format, yuv_in)); pixel_format.fullrange = range_out; from_float.reset(create_depth_color_filter(width, height, float_format, pixel_format, yuv_out)); pair_filter1.reset(new zimg::PairFilter{ to_float.get(), colorspace_filter.get() }); to_float.release(); colorspace_filter.release(); pair_filter2.reset(new zimg::PairFilter{ pair_filter1.get(), from_float.get() }); pair_filter1.release(); from_float.release(); return pair_filter2.release(); } else { return colorspace_filter.release(); } } catch (const zimg::ZimgException &e) { handle_exception(e); return nullptr; } catch (const std::bad_alloc &e) { handle_exception(e); return nullptr; } }
TEST_F(accuracy_test_mixed_double, another_targeted_real_to_hermitian_transform) { try { another_targeted_real_to_hermitian_transform< double, cl_double, fftw_complex >(); } catch( const std::exception& err ) { handle_exception(err); } }
TEST_F(accuracy_test_mixed_double, possible_driver_bug_1D_length_375_fails) { try { possible_driver_bug_1D_length_375_fails< double, cl_double, fftw_complex >(); } catch( const std::exception& err ) { handle_exception(err); } }
static void callback_invoke(JNIEnv* env, callback *cb, ffi_cif* cif, void *resp, void **cbargs) { jobject self; void *oldresp = resp; self = (*env)->NewLocalRef(env, cb->object); // Avoid calling back to a GC'd object if ((*env)->IsSameObject(env, self, NULL)) { fprintf(stderr, "JNA: callback object has been garbage collected\n"); if (cif->rtype->type != FFI_TYPE_VOID) { memset(resp, 0, cif->rtype->size); } } else if (cb->direct) { unsigned int i; void **args = alloca((cif->nargs + 3) * sizeof(void *)); args[0] = (void *)&env; args[1] = &self; args[2] = &cb->methodID; memcpy(&args[3], cbargs, cif->nargs * sizeof(void *)); if (cb->flags) { for (i=0;i < cif->nargs;i++) { switch(cb->flags[i]) { case CVT_INTEGER_TYPE: case CVT_POINTER_TYPE: case CVT_NATIVE_MAPPED: *((void **)args[i+3]) = fromNative(env, cb->arg_classes[i], cif->arg_types[i], args[i+3], JNI_FALSE); break; case CVT_POINTER: *((void **)args[i+3]) = newJavaPointer(env, *(void **)args[i+3]); break; case CVT_STRING: *((void **)args[i+3]) = newJavaString(env, *(void **)args[i+3], JNI_FALSE); break; case CVT_WSTRING: *((void **)args[i+3]) = newJavaWString(env, *(void **)args[i+3]); break; case CVT_STRUCTURE: *((void **)args[i+3]) = newJavaStructure(env, *(void **)args[i+3], cb->arg_classes[i], JNI_FALSE); break; case CVT_STRUCTURE_BYVAL: { void *ptr = args[i+3]; args[i+3] = alloca(sizeof(void *)); *((void **)args[i+3]) = newJavaStructure(env, ptr, cb->arg_classes[i], JNI_TRUE); } break; case CVT_CALLBACK: *((void **)args[i+3]) = newJavaCallback(env, *(void **)args[i+3], cb->arg_classes[i]); break; case CVT_FLOAT: { void *ptr = alloca(sizeof(double)); *(double *)ptr = *(float*)args[i+3]; args[i+3] = ptr; } break; } } } if (cb->rflag == CVT_STRUCTURE_BYVAL) { resp = alloca(sizeof(jobject)); } else if (cb->cif.rtype->size > cif->rtype->size) { resp = alloca(cb->cif.rtype->size); } ffi_call(&cb->java_cif, FFI_FN(cb->fptr), resp, args); if ((*env)->ExceptionCheck(env)) { jthrowable throwable = (*env)->ExceptionOccurred(env); (*env)->ExceptionClear(env); if (!handle_exception(env, self, throwable)) { fprintf(stderr, "JNA: error handling callback exception, continuing\n"); } if (cif->rtype->type != FFI_TYPE_VOID) memset(oldresp, 0, cif->rtype->size); } else switch(cb->rflag) { case CVT_INTEGER_TYPE: if (cb->cif.rtype->size > sizeof(ffi_arg)) { *(jlong *)oldresp = getIntegerTypeValue(env, *(void **)resp); } else { *(ffi_arg *)oldresp = (ffi_arg)getIntegerTypeValue(env, *(void **)resp); } break; case CVT_POINTER_TYPE: *(void **)resp = getPointerTypeAddress(env, *(void **)resp); break; case CVT_NATIVE_MAPPED: toNative(env, *(void **)resp, oldresp, cb->cif.rtype->size, JNI_TRUE); break; case CVT_POINTER: *(void **)resp = getNativeAddress(env, *(void **)resp); break; case CVT_STRING: *(void **)resp = getNativeString(env, *(void **)resp, JNI_FALSE); break; case CVT_WSTRING: *(void **)resp = getNativeString(env, *(void **)resp, JNI_TRUE); break; case CVT_STRUCTURE: writeStructure(env, *(void **)resp); *(void **)resp = getStructureAddress(env, *(void **)resp); break; case CVT_STRUCTURE_BYVAL: writeStructure(env, *(void **)resp); memcpy(oldresp, getStructureAddress(env, *(void **)resp), cb->cif.rtype->size); break; case CVT_CALLBACK: *(void **)resp = getCallbackAddress(env, *(void **)resp); break; default: break; } if (cb->flags) { for (i=0;i < cif->nargs;i++) { if (cb->flags[i] == CVT_STRUCTURE) { writeStructure(env, *(void **)args[i+3]); } } } } else { jobject result; jobjectArray array = (*env)->NewObjectArray(env, cif->nargs, classObject, NULL); unsigned int i; for (i=0;i < cif->nargs;i++) { jobject arg = new_object(env, cb->arg_jtypes[i], cbargs[i], JNI_FALSE); (*env)->SetObjectArrayElement(env, array, i, arg); } result = (*env)->CallObjectMethod(env, self, cb->methodID, array); if ((*env)->ExceptionCheck(env)) { jthrowable throwable = (*env)->ExceptionOccurred(env); (*env)->ExceptionClear(env); if (!handle_exception(env, self, throwable)) { fprintf(stderr, "JNA: error handling callback exception, continuing\n"); } if (cif->rtype->type != FFI_TYPE_VOID) memset(resp, 0, cif->rtype->size); } else { extract_value(env, result, resp, cif->rtype->size, JNI_TRUE); } } }
TEST_F(accuracy_test_mixed_single, larger_targeted_real_to_hermitian_transform) { try { larger_targeted_real_to_hermitian_transform< float, cl_float, fftwf_complex >(); } catch( const std::exception& err ) { handle_exception(err); } }
jvalue *get_value_by_sig_type(char *sig, char *pval) { char *endptr; char scptr; int siptr; long slptr; short ssptr; double sdptr; float sfptr; jstring sjptr; jvalue *ret; ret = (jvalue *)pkg_malloc(sizeof(jvalue)); if (!ret) { LM_ERR("pkg_malloc() has failed. Not enouph memory!\n"); return NULL; } if (sig == NULL || strlen(sig) <= 0) { LM_ERR("app_java: Can't process empty or NULL signature.\n"); pkg_free(ret); return NULL; } if (pval == NULL || strlen(pval) <= 0) { LM_ERR("app_java: Can't process empty or NULL parameter value.\n"); pkg_free(ret); return NULL; } // boolean if (!strncmp(sig, "Z", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_BOOLEAN) || !strcmp(sig, "Ljava/lang/Boolean;") #endif ) { if (!strncasecmp(pval, "true", 4)) (*ret).z = (jboolean)JNI_TRUE; /* comment this block to avoid conversation '1' to 'true' */ else if (!strncmp(pval, "1", 1)) (*ret).z = (jboolean)JNI_TRUE; else if (!strncasecmp(pval, "false", 5)) (*ret).z = (jboolean)JNI_FALSE; /* comment this block to avoid conversation '0' to 'false' */ else if (!strncmp(pval, "0", 1)) (*ret).z = (jboolean)JNI_FALSE; else { LM_ERR("app_java: Can't cast '%s' to type '%s'.\n", pval, sig); pkg_free(ret); return NULL; } return ret; } else // byte if (!strncmp(sig, "B", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_BYTE) || !strcmp(sig, "Ljava/lang/Byte;") #endif ) { // skptr = (signed char)char2jbyte(pval); sscanf(pval, "%x", &siptr); if (siptr == 0 && errno != 0) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (siptr < SCHAR_MAX || siptr > SCHAR_MAX) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).b = (jbyte)siptr; return ret; } else // char if (!strncmp(sig, "C", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_CHARACTER) || !strcmp(sig, "Ljava/lang/Character;") #endif ) { sscanf(pval, "%c", &scptr); if (scptr == 0 && errno != 0) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (scptr < CHAR_MIN || scptr > CHAR_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).c = (jchar)scptr; return ret; } else // double if (!strncmp(sig, "D", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_DOUBLE) || !strcmp(sig, "Ljava/lang/Double;") #endif ) { sdptr = (double)strtod(pval, &endptr); if ((sdptr == 0 && errno != 0) || (pval == endptr)) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (sdptr < LLONG_MIN || sdptr > LLONG_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).d = (jdouble)sdptr; return ret; } else // float if (!strncmp(sig, "F", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_FLOAT) || !strcmp(sig, "Ljava/lang/Float;") #endif ) { sfptr = (float)strtof(pval, &endptr); if ((sfptr == 0 && errno != 0) || (pval == endptr)) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (sfptr < FLT_MIN || sfptr > FLT_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).f = (jfloat)sfptr; return ret; } else // integer if (!strncmp(sig, "I", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_INTEGER) || !strcmp(sig, "Ljava/lang/Integer;") #endif ) { slptr = strtol(pval, &endptr, 10); if ((slptr == 0 && errno != 0) || (pval == endptr)) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (slptr < INT_MIN || slptr > INT_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).i = (jint)slptr; return ret; } else // long if (!strncmp(sig, "J", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_LONG) || !strcmp(sig, "Ljava/lang/Long;") #endif ) { slptr = (long)strtol(pval, &endptr, 10); if ((slptr == 0 && errno != 0) || (pval == endptr)) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (slptr < LONG_MIN || slptr > LONG_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).j = (jlong)slptr; return ret; } else // short if (!strncmp(sig, "S", 1) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_SHORT) || !strcmp(sig, "Ljava/lang/Short;") #endif ) { ssptr = (short)strtod(pval, &endptr); if ((ssptr == 0 && errno != 0) || (pval == endptr)) { LM_ERR("app_java: Can't cast '%s' to type '%s'. Error: %s.\n", pval, sig, get_conv_err_str(errno)); pkg_free(ret); return NULL; } if (ssptr < SHRT_MIN || ssptr > SHRT_MAX) // overflow { LM_ERR("app_java: Can't cast '%s' to type '%s'. Reason: overflow.", pval, sig); pkg_free(ret); return NULL; } (*ret).s = (jshort)ssptr; return ret; } // String (object) #if defined(JAVA_INV_SUPP_TYPE_OBJECTS) && defined(JAVA_INV_SUPP_TYPE_STRING) else if (!strcmp(sig, "Ljava/lang/String;")) { sjptr = (*env)->NewStringUTF(env, pval); if ((*env)->ExceptionCheck(env)) { pkg_free(ret); handle_exception(); return NULL; } /* if (pval != NULL && sjptr == NULL) { pkg_free(ret); return NULL; } */ (*ret).l = (jstring)sjptr; return ret; } #endif #ifdef JAVA_INV_SUPP_TYPE_VOID else if (!strncmp(sig, "V", 1)) { pkg_free(ret); return NULL; } #endif else { // unknown sig LM_ERR("app_java: Can't cast '%s' to signature '%s'\n", pval, sig); pkg_free(ret); return NULL; } return NULL; }
static int get_child_debug_event (struct target_waitstatus *ourstatus) { ptid_t ptid; last_sig = GDB_SIGNAL_0; ourstatus->kind = TARGET_WAITKIND_SPURIOUS; /* Check if GDB sent us an interrupt request. */ check_remote_input_interrupt_request (); if (soft_interrupt_requested) { soft_interrupt_requested = 0; fake_breakpoint_event (); goto gotevent; } #ifndef _WIN32_WCE attaching = 0; #else if (attaching) { /* WinCE doesn't set an initial breakpoint automatically. To stop the inferior, we flush all currently pending debug events -- the thread list and the dll list are always reported immediatelly without delay, then, we suspend all threads and pretend we saw a trap at the current PC of the main thread. Contrary to desktop Windows, Windows CE *does* report the dll names on LOAD_DLL_DEBUG_EVENTs resulting from a DebugActiveProcess call. This limits the way we can detect if all the dlls have already been reported. If we get a real debug event before leaving attaching, the worst that will happen is the user will see a spurious breakpoint. */ current_event.dwDebugEventCode = 0; if (!WaitForDebugEvent (¤t_event, 0)) { OUTMSG2(("no attach events left\n")); fake_breakpoint_event (); attaching = 0; } else OUTMSG2(("got attach event\n")); } else #endif { /* Keep the wait time low enough for confortable remote interruption, but high enough so gdbserver doesn't become a bottleneck. */ if (!WaitForDebugEvent (¤t_event, 250)) { DWORD e = GetLastError(); if (e == ERROR_PIPE_NOT_CONNECTED) { /* This will happen if the loader fails to succesfully load the application, e.g., if the main executable tries to pull in a non-existing export from a DLL. */ ourstatus->kind = TARGET_WAITKIND_EXITED; ourstatus->value.integer = 1; return 1; } return 0; } } gotevent: switch (current_event.dwDebugEventCode) { case CREATE_THREAD_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event CREATE_THREAD_DEBUG_EVENT " "for pid=%u tid=%x)\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); /* Record the existence of this thread. */ child_add_thread (current_event.dwProcessId, current_event.dwThreadId, current_event.u.CreateThread.hThread, current_event.u.CreateThread.lpThreadLocalBase); break; case EXIT_THREAD_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event EXIT_THREAD_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); child_delete_thread (current_event.dwProcessId, current_event.dwThreadId); current_thread = (struct thread_info *) all_threads.head; return 1; case CREATE_PROCESS_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event CREATE_PROCESS_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); CloseHandle (current_event.u.CreateProcessInfo.hFile); current_process_handle = current_event.u.CreateProcessInfo.hProcess; main_thread_id = current_event.dwThreadId; ourstatus->kind = TARGET_WAITKIND_EXECD; ourstatus->value.execd_pathname = "Main executable"; /* Add the main thread. */ child_add_thread (current_event.dwProcessId, main_thread_id, current_event.u.CreateProcessInfo.hThread, current_event.u.CreateProcessInfo.lpThreadLocalBase); ourstatus->value.related_pid = debug_event_ptid (¤t_event); #ifdef _WIN32_WCE if (!attaching) { /* Windows CE doesn't set the initial breakpoint automatically like the desktop versions of Windows do. We add it explicitly here. It will be removed as soon as it is hit. */ set_breakpoint_at ((CORE_ADDR) (long) current_event.u .CreateProcessInfo.lpStartAddress, auto_delete_breakpoint); } #endif break; case EXIT_PROCESS_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event EXIT_PROCESS_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); ourstatus->kind = TARGET_WAITKIND_EXITED; ourstatus->value.integer = current_event.u.ExitProcess.dwExitCode; child_continue (DBG_CONTINUE, -1); CloseHandle (current_process_handle); current_process_handle = NULL; break; case LOAD_DLL_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event LOAD_DLL_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); CloseHandle (current_event.u.LoadDll.hFile); if (! child_initialization_done) break; handle_load_dll (); ourstatus->kind = TARGET_WAITKIND_LOADED; ourstatus->value.sig = GDB_SIGNAL_TRAP; break; case UNLOAD_DLL_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event UNLOAD_DLL_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); if (! child_initialization_done) break; handle_unload_dll (); ourstatus->kind = TARGET_WAITKIND_LOADED; ourstatus->value.sig = GDB_SIGNAL_TRAP; break; case EXCEPTION_DEBUG_EVENT: OUTMSG2 (("gdbserver: kernel event EXCEPTION_DEBUG_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); handle_exception (ourstatus); break; case OUTPUT_DEBUG_STRING_EVENT: /* A message from the kernel (or Cygwin). */ OUTMSG2 (("gdbserver: kernel event OUTPUT_DEBUG_STRING_EVENT " "for pid=%u tid=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId)); handle_output_debug_string (ourstatus); break; default: OUTMSG2 (("gdbserver: kernel event unknown " "for pid=%u tid=%x code=%x\n", (unsigned) current_event.dwProcessId, (unsigned) current_event.dwThreadId, (unsigned) current_event.dwDebugEventCode)); break; } ptid = debug_event_ptid (¤t_event); current_thread = (struct thread_info *) find_inferior_id (&all_threads, ptid); return 1; }
virtual void accuracy_test_directed_packed_real_inplace_interleaved() { try { DirectedTest::ParametersPackedRealInplaceInterleaved params = GetParam(); RecordProperty("batch_size", (int)params.batch_size); RecordProperty("precision", params.precision); RecordProperty("direction", params.direction); RecordProperty("dimensions", params.dimensions); RecordProperty("length_x", (int)params.lengths[0]); if (params.dimensions >= CLFFT_2D) RecordProperty("length_y", (int)params.lengths[1]); if (params.dimensions >= CLFFT_3D) RecordProperty("length_z", (int)params.lengths[2]); if (params.input_strides.empty()) { RecordProperty("input_strides", 0); } else { RecordProperty("input_stride_x", (int)params.input_strides[0]); if (params.dimensions >= CLFFT_2D) RecordProperty("input_stride_y", (int)params.input_strides[1]); if (params.dimensions >= CLFFT_3D) RecordProperty("input_stride_z", (int)params.input_strides[2]); } if (params.output_strides.empty()) { RecordProperty("output_strides", 0); } else { RecordProperty("output_stride_x", (int)params.output_strides[0]); if (params.dimensions >= CLFFT_2D) RecordProperty("output_stride_y", (int)params.output_strides[1]); if (params.dimensions >= CLFFT_3D) RecordProperty("output_stride_z", (int)params.output_strides[2]); } RecordProperty("input_distance", (int)params.input_distance); RecordProperty("output_distance", (int)params.output_distance); RecordProperty("input_layout", params.input_layout); RecordProperty("output_layout", params.output_layout); if (params.precision == CLFFT_SINGLE) { if (params.input_layout == CLFFT_REAL) { real_to_complex<float, cl_float, fftwf_complex>(erratic, params.lengths, params.batch_size, params.input_strides, params.output_strides, params.input_distance, params.output_distance, DirectedTest::cl_layout_to_buffer_layout(params.output_layout), placeness::in_place); } else if (params.output_layout == CLFFT_REAL) { complex_to_real<float, cl_float, fftwf_complex>(erratic, params.lengths, params.batch_size, params.input_strides, params.output_strides, params.input_distance, params.output_distance, DirectedTest::cl_layout_to_buffer_layout(params.input_layout), placeness::in_place); } else { throw std::runtime_error("bad layout combination"); } } else if (params.precision == CLFFT_DOUBLE) { if (params.input_layout == CLFFT_REAL) { real_to_complex<double, cl_double, fftw_complex>(erratic, params.lengths, params.batch_size, params.input_strides, params.output_strides, params.input_distance, params.output_distance, DirectedTest::cl_layout_to_buffer_layout(params.output_layout), placeness::in_place); } else if (params.output_layout == CLFFT_REAL) { complex_to_real<double, cl_double, fftw_complex>(erratic, params.lengths, params.batch_size, params.input_strides, params.output_strides, params.input_distance, params.output_distance, DirectedTest::cl_layout_to_buffer_layout(params.input_layout), placeness::in_place); } else { throw std::runtime_error("bad layout combination"); } } else { throw std::runtime_error("Random test: this code path should never be executed"); } } catch (const std::exception& err) { handle_exception(err); } }
ParametersPackedRealInplaceInterleaved( clfftPrecision precision_in, clfftDirection direction_in, clfftDim dimensions_in, const std::vector<size_t> &lengths_in, size_t batch_size_in) : precision(precision_in) , direction(direction_in) , dimensions(dimensions_in) , batch_size(batch_size_in) { try { for (size_t i = 0; i < lengths_in.size(); i++) lengths.push_back(lengths_in[i]); input_strides.push_back(1); output_strides.push_back(1); if ((direction_in == CLFFT_FORWARD) || (direction_in == CLFFT_MINUS)) { input_layout = CLFFT_REAL; output_layout = CLFFT_HERMITIAN_INTERLEAVED; input_distance = 2 * (1 + lengths[0]/2); output_distance = 1 + lengths[0] / 2; } else { input_layout = CLFFT_HERMITIAN_INTERLEAVED; output_layout = CLFFT_REAL; input_distance = 1 + lengths[0] / 2; output_distance = 2 * (1 + lengths[0] / 2); } for (size_t i = 1; i < lengths.size(); i++) { input_strides.push_back(input_distance); output_strides.push_back(output_distance); input_distance *= lengths[i]; output_distance *= lengths[i]; } if( is_r2c() ) { // check for ok if( dimensions >= 2 ) if( input_strides[1] != 2 * output_strides[1] ) throw std::runtime_error( "invalid stride y generated for r2c" ); if( dimensions >= 3 ) if( input_strides[2] != 2 * output_strides[2] ) throw std::runtime_error( "invalid stride z generated for r2c" ); if( input_distance != 2 * output_distance ) throw std::runtime_error( "invalid distance generated for r2c" ); } if( is_c2r() ) { // check for ok if( dimensions >= 2 ) if( output_strides[1] != 2 * input_strides[1] ) throw std::runtime_error( "invalid stride y generated for c2r" ); if( dimensions >= 3 ) if( output_strides[2] != 2 * input_strides[2] ) throw std::runtime_error( "invalid stride z generated for c2r" ); if( output_distance != 2 * input_distance ) throw std::runtime_error( "invalid distance generated for c2r" ); } } catch( const std::exception& err ) { handle_exception(err); } }
int main(int argc, char* argv[]) try { g_thread_init(NULL); Gio::init(); setlocale(LC_ALL, ""); bindtextdomain(GETTEXT_PACKAGE, gobby_localedir().c_str()); bind_textdomain_codeset(GETTEXT_PACKAGE, "UTF-8"); bool new_instance = false; bool display_version = false; std::vector<Glib::ustring> hostnames; Glib::OptionGroup opt_group_gobby("gobby", _("Gobby options"), _("Options related to Gobby")); Glib::OptionEntry opt_version; opt_version.set_short_name('v'); opt_version.set_long_name("version"); opt_version.set_description( _("Display version information and exit")); opt_group_gobby.add_entry(opt_version, display_version); Glib::OptionEntry opt_new_instance; opt_new_instance.set_short_name('n'); opt_new_instance.set_long_name("new-instance"); opt_new_instance.set_description( _("Also start a new Gobby instance when there is one " "running already")); opt_group_gobby.add_entry(opt_new_instance, new_instance); Glib::OptionEntry opt_connect; opt_connect.set_short_name('c'); opt_connect.set_long_name("connect"); opt_connect.set_description( _("Connect to given host on startup, can be given multiple times")); opt_connect.set_arg_description(_("HOSTNAME")); opt_group_gobby.add_entry(opt_connect, hostnames); Glib::OptionContext opt_ctx; opt_ctx.set_help_enabled(true); opt_ctx.set_ignore_unknown_options(false); opt_ctx.set_main_group(opt_group_gobby); // I would rather like to have Gtk::Main on the stack, but I see // no other chance to catch exceptions from the command line option // parsing. armin. // TODO: Maybe we should parse before initializing GTK+, using // Gtk::Main::add_gtk_option_group() with open_default_display set // to false. std::auto_ptr<Gtk::Main> kit; try { kit.reset(new Gtk::Main(argc, argv, opt_ctx)); } catch(Glib::Exception& e) { // Protect for non-UTF8 command lines (GTK probably already // converts to UTF-8 in case the system locale is not UTF-8, // but it can happen that input is given not in the system // locale, or simply invalid UTF-8. In that case, printing // e.what() on stdout would throw another exception, which we // want to avoid here, because otherwise we would want to // show that exception in an error dialog, but GTK+ failed // to initialize. if(e.what().validate()) std::cerr << e.what() << std::endl; else std::cerr << "Invalid input on command line" << std::endl; return EXIT_FAILURE; } if(display_version) { std::cout << "Gobby " << PACKAGE_VERSION << std::endl; return EXIT_SUCCESS; } #ifdef WITH_UNIQUE UniqueApp* app = unique_app_new_with_commands( "de._0x539.gobby", NULL, "UNIQUE_GOBBY_CONNECT", Gobby::UNIQUE_GOBBY_CONNECT, NULL); if(!new_instance && unique_app_is_running(app)) { int exit_code = my_unique_check_other( app, argc - 1, argv + 1, hostnames); g_object_unref(app); return exit_code; } #endif // WITH_UNIQUE GError* error = NULL; if(!inf_init(&error)) { std::string message = error->message; g_error_free(error); throw std::runtime_error(message); } // Read the configuration Gobby::Config config(Gobby::config_filename("config.xml")); Gobby::Preferences preferences(config); Gobby::CertificateManager cert_manager(preferences); Gobby::IconManager icon_manager; // Set default icon Gtk::Window::set_default_icon_name("gobby-0.5"); // Open a scope here, so that the main window is destructed // before we serialize the preferences, so that if the window // sets options at destruction time, they are stored correctly. { // Create window Gobby::Window wnd( argc-1, argv+1, config, preferences, icon_manager, cert_manager #ifdef WITH_UNIQUE , app #endif ); #ifdef WITH_UNIQUE g_object_unref(app); #endif wnd.show(); for(std::vector<Glib::ustring>::const_iterator i = hostnames.begin(); i != hostnames.end(); ++ i) { wnd.connect_to_host(*i); } wnd.signal_hide().connect(sigc::ptr_fun(&Gtk::Main::quit) ); kit->run(); } preferences.serialize(config); //inf_deinit(); return 0; } catch(Glib::Exception& e) { handle_exception(e.what() ); } catch(std::exception& e) { handle_exception(e.what() ); }
int java_exec(struct sip_msg *msgp, int is_static, int is_synchronized, char *method_name, char *signature, char *param) { char *retval_sig; char *cs; size_t cslen; jint retval; int locked; jfieldID fid; jclass cls; jmethodID invk_method, invk_method_ref; jvalue *jparam; if (signature == NULL || !strcmp(signature, "")) { LM_ERR("%s: java_method_exec(): signature is empty or invalid.\n", APP_NAME); return -1; } if (param == NULL && strcmp(signature, "V")) { LM_ERR("%s: java_method_exec(): no parameter (parameter is NULL) but signature '%s' is not equals to 'V'.\n", APP_NAME, signature); return -1; } if (is_sig_allowed(signature) == 0) { LM_ERR("%s: java_method_exec(): error: signature '%s' isn't supported yet.\n", APP_NAME, signature); return -1; } if (!strcmp(signature, "V")) { signature = ""; } retval_sig = "I"; cslen = strlen(signature) + 2 + 1 + 1; // '(' + 'signature' + ')' + 'return signature' + null terminator cs = (char *)pkg_malloc(cslen * sizeof(char)); if (!cs) { LM_ERR("%s: pkg_malloc() has failed. Can't allocate %lu bytes. Not enough memory!\n", APP_NAME, (unsigned long)cslen); return -1; } snprintf(cs, cslen, "(%s)%s", signature, retval_sig); cs[cslen] = '\0'; // attach to current thread (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); if ((*env)->ExceptionCheck(env)) { handle_exception(); return -1; } cls = (*env)->GetObjectClass(env, KamailioClassInstance); if ((*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } fid = (*env)->GetFieldID(env, cls, "mop", "I"); if (!fid) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } msg = msgp; // find a method by signature invk_method = is_static ? (*env)->GetStaticMethodID(env, KamailioClassRef, method_name, cs) : (*env)->GetMethodID(env, KamailioClassRef, method_name, cs); if (!invk_method || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } pkg_free(cs); // keep local reference to method invk_method_ref = (*env)->NewLocalRef(env, invk_method); if (!invk_method_ref || (*env)->ExceptionCheck(env)) { handle_exception(); (*env)->DeleteLocalRef(env, invk_method_ref); (*jvm)->DetachCurrentThread(jvm); return -1; } retval = -1; if (is_synchronized) { if ((*env)->MonitorEnter(env, invk_method_ref) != JNI_OK) { locked = 0; LM_ERR("%s: MonitorEnter() has failed! Can't synchronize!\n", APP_NAME); } else { locked = 1; } } if (param == NULL) { retval = is_static ? (int)(*env)->CallStaticIntMethod(env, KamailioClassRef, invk_method_ref) : (int)(*env)->CallIntMethod(env, KamailioClassInstanceRef, invk_method_ref); } else { jparam = get_value_by_sig_type(signature, param); if (jparam == NULL) { (*env)->DeleteLocalRef(env, invk_method_ref); (*env)->DeleteLocalRef(env, invk_method); (*jvm)->DetachCurrentThread(jvm); return -1; } retval = is_static ? (int)(*env)->CallStaticIntMethod(env, KamailioClassRef, invk_method_ref, *jparam) : (int)(*env)->CallIntMethod(env, KamailioClassInstanceRef, invk_method_ref, *jparam); } if ((*env)->ExceptionCheck(env)) { LM_ERR("%s: %s(): %s() has failed. See exception below.\n", APP_NAME, (is_static ? (is_synchronized ? "java_s_staticmethod_exec" : "java_staticmethod_exec") : (is_synchronized ? "java_s_method_exec" : "java_method_exec") ), is_static ? "CallStaticIntMethod" : "CallIntMethod" ); handle_exception(); (*env)->DeleteLocalRef(env, invk_method_ref); (*env)->DeleteLocalRef(env, invk_method); (*jvm)->DetachCurrentThread(jvm); return -1; } if (is_synchronized && locked) { if ((*env)->MonitorExit(env, invk_method_ref) != JNI_OK) { LM_ERR("%s: MonitorExit() has failed! Can't synchronize!\n", APP_NAME); } } (*env)->DeleteLocalRef(env, invk_method_ref); (*env)->DeleteLocalRef(env, invk_method); (*jvm)->DetachCurrentThread(jvm); return retval; }
inline void handle_exception() { handle_exception(detail::rethrow); }
zimg_filter *zimg2_resize_create(const zimg_resize_params *params) { assert(params); API_VERSION_ASSERT(params->version); try { std::unique_ptr<zimg::resize::Filter> filter; zimg::PixelType pixel_type{}; unsigned depth = 0; int src_width = 0; int src_height = 0; int dst_width = 0; int dst_height = 0; double shift_w = 0; double shift_h = 0; double subwidth = NAN; double subheight = NAN; if (params->version >= 2) { src_width = params->src_width; src_height = params->src_height; dst_width = params->dst_width; dst_height = params->dst_height; pixel_type = translate_pixel_type(params->pixel_type); depth = params->depth; shift_w = params->shift_w; shift_h = params->shift_h; subwidth = std::isnan(params->subwidth) ? src_width : params->subwidth; subheight = std::isnan(params->subheight) ? src_height : params->subheight; filter.reset(translate_resize_filter(params->filter_type, params->filter_param_a, params->filter_param_b)); } if (pixel_type == zimg::PixelType::BYTE || pixel_type == zimg::PixelType::HALF) { zimg::PixelType working_pixel_type = pixel_type == zimg::PixelType::BYTE ? zimg::PixelType::WORD : zimg::PixelType::FLOAT; zimg::PixelFormat inout_format = zimg::default_pixel_format(pixel_type); zimg::PixelFormat working_format = zimg::default_pixel_format(working_pixel_type); std::unique_ptr<zimg::IZimgFilter> resize_filter; std::unique_ptr<zimg::IZimgFilter> adapter_in; std::unique_ptr<zimg::IZimgFilter> adapter_out; std::unique_ptr<zimg::IZimgFilter> pair_filter1; std::unique_ptr<zimg::IZimgFilter> pair_filter2; resize_filter.reset(zimg::resize::create_resize2(*filter, working_pixel_type, working_format.depth, src_width, src_height, dst_width, dst_height, shift_w, shift_h, subwidth, subheight, g_cpu_type)); adapter_in.reset(zimg::depth::create_depth2(zimg::depth::DitherType::DITHER_NONE, src_width, src_height, inout_format, working_format, g_cpu_type)); adapter_out.reset(zimg::depth::create_depth2(zimg::depth::DitherType::DITHER_NONE, dst_width, dst_height, working_format, inout_format, g_cpu_type)); pair_filter1.reset(new zimg::PairFilter{ adapter_in.get(), resize_filter.get() }); adapter_in.release(); resize_filter.release(); pair_filter2.reset(new zimg::PairFilter{ pair_filter1.get(), adapter_out.get() }); pair_filter1.release(); adapter_out.release(); return pair_filter2.release(); } else { return zimg::resize::create_resize2(*filter, pixel_type, depth, src_width, src_height, dst_width, dst_height, shift_w, shift_h, subwidth, subheight, g_cpu_type); } } catch (const zimg::ZimgException &e) { handle_exception(e); return nullptr; } catch (const std::bad_alloc &e) { handle_exception(e); return nullptr; } }
TEST_F(accuracy_test_mixed_single, hermitian_to_real_transforms_with_non_unit_output_strides_should_pass) { try { hermitian_to_real_transforms_with_non_unit_output_strides_should_pass< float, cl_float, fftwf_complex >(); } catch( const std::exception& err ) { handle_exception(err); } }
static int yylex1(void) { register char *yyp; register int c; register int c1, c2; for (;;) { if (lex_fatal) { return -1; } switch(c = mygetc()) { case EOF: if (inctop) { struct incstate *p; p = inctop; (void)fclose(yyin); /*(void)fprintf(stderr, "popping to %s\n", p->file);*/ free(current_file); nexpands = 0; current_file = p->file; current_line = p->line + 1; current_incfile = p->incfnum; pragma_strict_types = p->pragma_strict_types; yyin = p->yyin; slast = p->slast; lastchar = p->lastchar; inctop = p->next; if (p->nbuf) { nbuf = p->nbuf; outp = defbuf + DEFMAX - nbuf; memcpy(outp, p->outp, nbuf); free((char *)p->outp); } else { nbuf = 0; outp = defbuf + DEFMAX; } store_line_number_info(current_incfile, current_line); incdepth--; free((char *)p); break; } if (iftop) { struct ifstate *p = iftop; lexerror(p->state == EXPECT_ENDIF ? "Missing #endif" : "Missing #else"); while (iftop) { p = iftop; iftop = p->next; free((char *)p); } } return -1; case '\n': { nexpands=0; store_line_number_info(current_incfile, current_line); current_line++; total_lines++; } /* FALLTHROUGH */ case ' ': case '\t': case '\f': case '\v': break; case '+': TRY('+', F_INC); TRY('=', F_ADD_EQ); return c; case '-': TRY('>', F_ARROW); TRY('-', F_DEC); TRY('=', F_SUB_EQ); return c; case '&': TRY('&', F_LAND); TRY('=', F_AND_EQ); return c; case '|': TRY('|', F_LOR); TRY('=', F_OR_EQ); return c; case '^': TRY('=', F_XOR_EQ); return c; case '<': if (gobble('<')) { TRY('=', F_LSH_EQ); return F_LSH; } TRY('=', F_LE); return c; case '>': if (gobble('>')) { TRY('=', F_RSH_EQ); return F_RSH; } TRY('=', F_GE); return c; case '*': TRY('=', F_MULT_EQ); return c; case '%': TRY('=', F_MOD_EQ); return F_MOD; case '/': if (gobble('*')) { skip_comment(); break; } else if (gobble('/')) { skip_comment2(); break; } TRY('=', F_DIV_EQ); return c; case '=': TRY('=', F_EQ); return c; case ';': case '(': case ')': case ',': case '{': case '}': case '~': case '[': case ']': case '?': case '@': return c; case '!': TRY('=', F_NE); return F_NOT; case ':': TRY(':', F_COLON_COLON); return ':'; case '.': if (gobble('.')) { if (gobble('.')) return F_VARARG; else return F_RANGE; } return c; case '#': if (lastchar == '\n') { char *ssp = 0; int quote; yyp = yytext; do { c = mygetc(); } while (isspace(c)); for (quote = 0;;) { if (c == '"') quote ^= 1; /*gc - handle comments cpp-like! 1.6.91 @@@*/ while (!quote && c == '/') { if (gobble('*')) { skip_comment(); c = mygetc(); } else break; } if (!ssp && isspace(c)) ssp = yyp; if (c == '\n' || c == EOF) break; SAVEC; c = mygetc(); } if (ssp) { *ssp++ = 0; while (isspace(*ssp)) ssp++; } else { ssp = yyp; } *yyp = 0; if (strcmp("define", yytext) == 0) { handle_define(ssp); } else if (strcmp("if", yytext) == 0) { #if 0 short int nega=0; /*@@@ allow #if !VAR gc 1.6.91*/ if (*ssp=='!'){ ssp++; nega=1;} if (isdigit(*ssp)) { char *p; long l; l = strtol(ssp, &p, 10); while (isspace(*p)) p++; if (*p) lexerror("Condition too complex in #if"); else handle_cond(nega ? !(int)l : (int)l); } else if (isalunum(*ssp)) { char *p = ssp; while (isalunum(*p)) p++; if (*p) { *p++ = 0; while (isspace(*p)) p++; } if (*p) lexerror("Condition too complex in #if"); else { struct defn *d; d = lookup_define(ssp); if (d) { handle_cond(nega ? !atoi(d->exps) : atoi(d->exps));/* a hack! */ } else { handle_cond(nega?1:0); /* cpp-like gc*/ } } } else lexerror("Condition too complex in #if"); #else int cond; myungetc(0); add_input(ssp); cond = cond_get_exp(0); if (mygetc()) { lexerror("Condition too complex in #if"); while (mygetc()) ; } else handle_cond(cond); #endif } else if (strcmp("ifdef", yytext) == 0) { deltrail(ssp); handle_cond(lookup_define(ssp) != 0); } else if (strcmp("ifndef", yytext) == 0) { deltrail(ssp); handle_cond(lookup_define(ssp) == 0); } else if (strcmp("else", yytext) == 0) { if (iftop && iftop->state == EXPECT_ELSE) { struct ifstate *p = iftop; /*(void)fprintf(stderr, "found else\n");*/ iftop = p->next; free((char *)p); (void)skip_to("endif", (char *)0); store_line_number_info(current_incfile, current_line); current_line++; total_lines++; } else { lexerror("Unexpected #else"); } } else if (strcmp("endif", yytext) == 0) { if (iftop && (iftop->state == EXPECT_ENDIF || iftop->state == EXPECT_ELSE)) { struct ifstate *p = iftop; /*(void)fprintf(stderr, "found endif\n");*/ iftop = p->next; free((char *)p); } else { lexerror("Unexpected #endif"); } } else if (strcmp("undef", yytext) == 0) { struct defn *d; deltrail(ssp); if ((d = lookup_define(ssp)) != NULL ) d->undef++; } else if (strcmp("echo", yytext) == 0) { (void)fprintf(stderr, "%s\n", ssp); } else if (strcmp("include", yytext) == 0) { /*(void)fprintf(stderr, "including %s\n", ssp); */ handle_include(ssp, 0); } else if (strcmp("pragma", yytext) == 0) { deltrail(ssp); handle_pragma(ssp); } else if (strcmp("error", yytext) == 0) { handle_exception(ERROR, ssp); } else if (strcmp("warning", yytext) == 0) { handle_exception(WARNING, ssp); } else { lexerror("Unrecognised # directive"); } myungetc('\n'); break; } else goto badlex; case '\'': yylval.number = mygetc(); if (yylval.number == '\\') { int tmp = mygetc(); switch (tmp) { case 'n': yylval.number = '\n'; break; case 't': yylval.number = '\t'; break; case 'b': yylval.number = '\b'; break; case 'a': yylval.number = '\a'; break; case 'v': yylval.number = '\v'; break; case '\'': case '\\': case '"': yylval.number = tmp; break; default: lexwarning("Bad character escape sequence"); yylval.number = tmp; break; } } if (!gobble('\'')) lexerror("Illegal character constant"); return F_NUMBER; case '"': yyp = yytext; *yyp++ = c; for (;;) { c = mygetc(); if (c == EOF) { lexerror("End of file in string"); return string("\"\""); } else if (c == '\n') { lexerror("Newline in string"); return string("\"\""); } SAVEC; if (c == '"') break; if (c == '\\') { c = mygetc(); if ( c == '\n' ) { yyp--; store_line_number_info(current_incfile, current_line); current_line++; total_lines++; } else if ( c == EOF ) { /* some operating systems give EOF only once */ myungetc(c); } else *yyp++ = c; } } *yyp = 0; return string(yytext); case '0': c = mygetc(); if ( c == 'X' || c == 'x' || c == 'o') { char *endptr; long long value; int base = 16; if (c == 'o') base = 8; yyp = yytext; for (;;) { c = mygetc(); if (!isxdigit(c)) break; SAVEC; } myungetc(c); *yyp = '\0'; value = strtoll(yytext, &endptr, base); if (*endptr != '\0') { fprintf(stderr, "%s\n", yytext); lexwarning("Invalid digits in octal number number"); } return number(value); } myungetc(c); c = '0'; /* FALLTHROUGH */ case '1': case '2': case '3': case '4': case '5': case '6': case '7': case '8': case '9': yyp = yytext; *yyp++ = c; for (;;) { c = mygetc(); if (!isdigit(c)) break; SAVEC; } if (c == '.') { if (isdigit(c1 = mygetc())) { SAVEC; c = c1; SAVEC; for (c = mygetc(); isdigit(c); c = mygetc()) SAVEC; if (c == 'e' || c == 'E') { c1 = mygetc(); if (c1 == '-' || c1 == '+') { c2 = mygetc(); if (isdigit(c2)) { SAVEC; c = c1; SAVEC; c = c2; SAVEC; for (c = mygetc(); isdigit(c); c = mygetc()) SAVEC; } else { myungetc(c2); myungetc(c1); } } else if (isdigit(c1)) { SAVEC; c = c1; SAVEC; for (c = mygetc(); isdigit(c); c = mygetc()) SAVEC; } else myungetc(c1); } myungetc(c); *yyp = 0; return real(strtod(yytext, NULL)); } myungetc(c1); } myungetc(c); *yyp = 0; if (*yytext == '0') { /* OCTALS */ char *endptr; long long value; value = strtoll(yytext, &endptr, 010); if (*endptr != '\0') lexwarning("Invalid digits in octal number"); if (value != 0) lexwarning("Obsolete octal format used. Use 0o111 syntax"); return number(value); } return number(atoll(yytext)); default: if (isalpha(c) || c == '_') { int r; yyp = yytext; *yyp++ = c; for (;;) { c = mygetc(); if (!isalunum(c)) break; SAVEC; } *yyp = 0; myungetc(c); if (!expand_define()) { r = lookup_resword(yytext); if (r >= 0) { return r; } else return ident(yytext); } break; } goto badlex; } } badlex: { lexerror("Illegal character (hex %02x) '%c'", c, c); return ' '; } }
TEST_F(accuracy_test_mixed_double, hermitian_to_real_transforms_with_non_unit_input_strides_should_pass) { try { hermitian_to_real_transforms_with_non_unit_input_strides_should_pass< double, cl_double, fftw_complex >(); } catch( const std::exception& err ) { handle_exception(err); } }
static int mod_init(void) { JavaVMInitArgs vm_args; jint res; JavaVMOption *options; char **opts; int nOptions; if (force_cmd_exec < 0 || force_cmd_exec > 1) { LM_ERR("Parameter force_cmd_exec should be either 0 or 1\n"); return -1; } if (force_cmd_exec) { LM_NOTICE("%s: Parameter force_cmd_exec may cause a memory leaks if used from embedded languages\n", APP_NAME); } options = (JavaVMOption *)pkg_malloc(sizeof(JavaVMOption)); if (!options) { LM_ERR("pkg_malloc() failed: Couldn't initialize Java VM: Not enough memory\n"); return -1; } memset(options, 0, sizeof(JavaVMOption)); LM_INFO("Initializing Java VM with options: %s\n", java_options_str); opts = split(java_options_str, " "); for (nOptions=0; opts[nOptions] != NULL; nOptions++) { options[nOptions].optionString = opts[nOptions]; } /* IMPORTANT: specify vm_args version # if you use JDK1.1.2 and beyond */ vm_args.version = JNI_VERSION_1_2; vm_args.nOptions = nOptions; vm_args.ignoreUnrecognized = JNI_FALSE; vm_args.options = options; res = JNI_CreateJavaVM(&jvm, (void **)&env, &vm_args); if (res < 0) { handle_VM_init_failure(res); return -1; } LM_INFO("%s: Java VM initialization OK\n", APP_NAME); // attach to current thread (*jvm)->AttachCurrentThread(jvm, (void **)&env, NULL); if ((*env)->ExceptionCheck(env)) { handle_exception(); return -1; } KamailioClass = (*env)->FindClass(env, class_name); if (!KamailioClass || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } KamailioClassRef = (*env)->NewGlobalRef(env, KamailioClass); if (!KamailioClassRef || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } KamailioID = (*env)->GetMethodID(env, KamailioClass, "<init>", "()V"); if (!KamailioID || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } // calling constructor KamailioClassInstance = (*env)->NewObject(env, KamailioClass, KamailioID); if (!KamailioClassInstance || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } // keep a reference to kamailio class instance KamailioClassInstanceRef = (*env)->NewGlobalRef(env, KamailioClassInstance); if (!KamailioClassInstanceRef || (*env)->ExceptionCheck(env)) { handle_exception(); (*jvm)->DetachCurrentThread(jvm); return -1; } LM_INFO("%s: module initialization OK\n", APP_NAME); if (jvm != NULL) (*jvm)->DetachCurrentThread(jvm); return 0; }
int main(int argc, char **argv) { int ntimes = 0; tpztest_payload_slice *pld; enum WHATTODO whattodo = NOTHING; CORBA_ORB orb = 0; CORBA_Environment ev; CORBA_Object obj; int i; for (i = 1; i < argc; i++) { switch (argv[i][0]) { case '-': switch (argv[i][1]) { case 'b': if (whattodo != NOTHING) { fprintf(stderr, ("Specify only one: " "-r or -b.\n")); return 1; } whattodo = BANDWIDTH; break; case 'r': if (whattodo != NOTHING) { fprintf(stderr, ("Specify only one: " "-r or -b.\n")); return 1; } whattodo = RQST_RSPN; break; case 'h': printhelp: printf("%s [-h] {-b|-r} -n num obj\n" " -h:\tPrint this help.\n" " -b:\tBandwidth test (cannot specify -r).\n" " -r:\tRequest/response test " "(cannot specify -b).\n" " -n:\tPerform test num times.\n" " obj:\tServer object reference.\n", argv[0]); return 0; case 'n': ++i; if (i >= argc) goto printhelp; ntimes = atoi(argv[i]); break; default: fprintf(stderr, "Invalid switch '-%c'.\n", argv[i][1]); goto printhelp; } break; default: if (i == argc - 1) break; /* Last parameter -- object ref */ fprintf(stderr, "Invalid parameter '%s'.\n", argv[i]); goto printhelp; } } /* Make sure `ntimes' is a valid value! */ if (ntimes <=0) { fprintf(stderr, "Must specify number of tests > 0.\n"); return 1; } /* Create the object reference. */ obj = CORBA_ORB_string_to_object(orb, argv[argc-1], &ev); if (ev._major != CORBA_NO_EXCEPTION) { printf("Problem in string to object conversion...\n"); handle_exception(&ev); return 1; } if (whattodo == BANDWIDTH) { struct timeval start, end; printf("** BANDWIDTH **\n"); gettimeofday(&start, 0); ntimes--; pld = flick_trapeze_client_array__alloc(); for (i = 0; i < ntimes; i++) { tpztest_bandwidth(obj, pld, &ev); assert(ev._major == CORBA_NO_EXCEPTION); } tpztest_bandwidth_pingback(obj, pld, &ev); assert(ev._major == CORBA_NO_EXCEPTION); flick_trapeze_client_array__free(pld); gettimeofday(&end, 0); /* Print the results: */ print_stats(sizeof(tpztest_payload), start, end, ntimes + 1); } else if (whattodo == RQST_RSPN) { struct timeval start, end; printf("** REQUEST-RESPONSE **\n"); gettimeofday(&start, 0); for (i = 0; i < ntimes; i++) { pld = tpztest_rqst_rspn(obj, &ev); assert(ev._major == CORBA_NO_EXCEPTION); flick_trapeze_client_array__free(pld); } gettimeofday(&end, 0); /* Print the results: */ print_stats(sizeof(tpztest_payload), start, end, ntimes + 1); } else { fprintf(stderr, "Nothing to do!\n"); return 2; } return 0; }