/* * version_cmp(pkg1, pkg2) returns -1, 0 or 1 depending on if the version * components of pkg1 is less than, equal to or greater than pkg2. No * comparison of the basenames is done. * * The port version is defined by: * ${PORTVERSION}[_${PORTREVISION}][,${PORTEPOCH}] * ${PORTEPOCH} supersedes ${PORTVERSION} supersedes ${PORTREVISION}. * See the commit log for revision 1.349 of ports/Mk/bsd.port.mk * for more information. * * The epoch and revision are defined to be a single number, while the rest * of the version should conform to the porting guidelines. It can contain * multiple components, separated by a period, including letters. * * The tests allow for significantly more latitude in the version numbers * than is allowed in the guidelines. No point in enforcing them here. * That's what portlint is for. * * Jeremy D. Lea. * reimplemented by Oliver Eikemeier */ int pkg_version_cmp(const char * const pkg1, const char * const pkg2) { const char *v1, *v2, *ve1, *ve2; unsigned long e1, e2, r1, r2; int result = 0; v1 = split_version(pkg1, &ve1, &e1, &r1); v2 = split_version(pkg2, &ve2, &e2, &r2); /* Check epoch, port version, and port revision, in that order. */ if (e1 != e2) { result = (e1 < e2 ? -1 : 1); } /* Shortcut check for equality before invoking the parsing routines. */ if (result == 0 && (ve1 - v1 != ve2 - v2 || strncasecmp(v1, v2, ve1 - v1) != 0)) { /* Loop over different components (the parts separated by dots). * If any component differs, we have the basis for an inequality. */ while(result == 0 && (v1 < ve1 || v2 < ve2)) { int block_v1 = 0; int block_v2 = 0; version_component vc1 = {0, 0, 0}; version_component vc2 = {0, 0, 0}; if (v1 < ve1 && *v1 != '+') { v1 = get_component(v1, &vc1); } else { block_v1 = 1; } if (v2 < ve2 && *v2 != '+') { v2 = get_component(v2, &vc2); } else { block_v2 = 1; } if (block_v1 && block_v2) { if (v1 < ve1) v1++; if (v2 < ve2) v2++; } else if (vc1.n != vc2.n) { result = (vc1.n < vc2.n ? -1 : 1); } else if (vc1.a != vc2.a) { result = (vc1.a < vc2.a ? -1 : 1); } else if (vc1.pl != vc2.pl) { result = (vc1.pl < vc2.pl ? -1 : 1); } } } /* Compare FreeBSD revision numbers. */ if (result == 0 && r1 != r2) { result = (r1 < r2 ? -1 : 1); } return result; }
std::future<Item> get_item() { std::packaged_task<Item()> task([=]{ return Item(get_component().get()); }); std::thread(std::move(task)).detach(); return task.get_future(); }
typet struct_union_typet::component_type( const irep_idt &component_name) const { const exprt c=get_component(component_name); assert(c.is_not_nil()); return c.type(); }
bool glMolecule::find_component_by_id( long mObject_id, vector<VerbalObject*>* object_hier ) { bool retval=false; VerbalObject* ptr=NULL; bool match = false; for (int i=0; i<m_components.size(); i++) { ptr = get_component(i); match = mObject_id == ptr->m_object_id; if (match) { object_hier->push_back(ptr); return true; } if (ptr->is_a_molecule()) { retval = ((glMolecule*)ptr)->find_component_by_id( mObject_id, object_hier ); if (retval) { object_hier->push_back(ptr); return true; } } } return false; }
bool glMolecule::find_component( string& mRequestedName, string& mTypeName, vector<VerbalObject*>* object_hier, bool mTypeMustMatch ) { bool retval=false; VerbalObject* ptr=NULL; bool match = false; for (int i=0; i<m_components.size(); i++) { ptr = get_component(i); bool is_initd = (ptr->m_name.length() > 0); int compare_result = ptr->m_name.compare( mRequestedName ); match = is_initd && (compare_result==0); if (match) { if (mTypeMustMatch) { if (mTypeName.compare( ptr->m_object_type_name )==0 ) { object_hier->push_back(ptr); return true; } } } if (ptr->is_a_molecule()) { retval = ((glMolecule*)ptr)->find_component( mRequestedName, mTypeName, object_hier, mTypeMustMatch ); if (retval) { object_hier->push_back(ptr); return true; } } } return false; }
void resolve_derived_copies(CommPtr comm, Read<GO> verts2globs, Int deg, LOs* p_ent_verts2verts, Remotes* p_ents2owners) { auto ev2v = *p_ent_verts2verts; auto ev2vg = unmap(ev2v, verts2globs, 1); auto canon_codes = get_codes_to_canonical(deg, ev2vg); auto ev2v_canon = align_ev2v(deg, ev2v, canon_codes); *p_ent_verts2verts = ev2v_canon; auto ev2vg_canon = align_ev2v(deg, ev2vg, canon_codes); auto e2fv = get_component(ev2v_canon, deg, 0); auto total_verts = find_total_globals(comm, verts2globs); auto v2ov = globals_to_linear_owners(comm, verts2globs, total_verts); auto e2ov = unmap(e2fv, v2ov); auto linsize = linear_partition_size(comm, total_verts); auto in_dist = Dist(comm, e2ov, linsize); auto sev2vg = in_dist.exch(ev2vg_canon, deg); auto out_dist = in_dist.invert(); auto sv2svse = out_dist.roots2items(); auto nse = out_dist.nitems(); auto svse2se = LOs(nse, 0, 1); auto sv2se_codes = Read<I8>(nse, make_code(false, 0, 0)); auto sv2se = Adj(sv2svse, svse2se, sv2se_codes); auto se2fsv = invert_fan(sv2svse); LOs se2ose; Read<I8> se2ose_codes; find_matches_ex(deg, se2fsv, sev2vg, sev2vg, sv2se, &se2ose, &se2ose_codes); auto ose2oe = out_dist.items2dests(); auto se2oe = unmap(se2ose, ose2oe); out_dist.set_roots2items(LOs()); auto e2oe = out_dist.exch(se2oe, 1); *p_ents2owners = e2oe; }
void Sender_exec_i::ccm_activate (void) { if (get_component()== 0) { GetComponent = true; } }
int main(int argc, char * argv[]){ double averg, sd; double knee_height_hint = 0.5; motion_vector mv1, mv2; motion_vector_itr m; unidimentional_series tmp, knee_h1, knee_h2; unidimentional_series_init( &tmp, 100); unidimentional_series_init( &knee_h1, 100); unidimentional_series_init( &knee_h2, 100); bvh_load_directory( argv[1], &mv1 ); bvh_load_directory( argv[2], &mv2 ); for(m = mv1.begin; m != mv1.end; ++m){ get_component( (*m) -> data.get( (*m) -> data_ptr, "RightLeg"), &tmp, 'y'); calc_mean_std_dev( &tmp, &averg, &sd, 0); knee_h1.append( &knee_h1, averg); } for(m = mv2.begin; m != mv2.end; ++m){ get_component( (*m) -> data.get( (*m) -> data_ptr, "RightLeg"), &tmp, 'y'); calc_mean_std_dev( &tmp, &averg, &sd, 0); knee_h2.append( &knee_h2, averg); } printf("T-Test at %lf m = %lf\n", knee_height_hint, t_test_one_sample( &knee_h1, knee_height_hint) ); printf("T-test two samples %lf\n", t_test_two_samples( &knee_h1, &knee_h2) ); printf("T-test Welch %lf\n", t_test_Welch( &knee_h1, &knee_h2) ); printf("Anova test %lf\n", anova_one_way(2, &knee_h1, &knee_h2) ); bvh_unload_directory( &mv1 ); bvh_unload_directory( &mv2 ); tmp.destroy( &tmp ); knee_h1.destroy( &knee_h1 ); knee_h2.destroy( &knee_h2 ); return 0; }
void remove_metrics(const DiscoveryContext& dc, const std::string& resource_uuid) { const auto resource = agent_framework::module::get_manager<ModelType<TYPE>>() .get_entry(resource_uuid); const auto metrics = agent_framework::module::get_manager<agent_framework::model::Metric>().get_entries( [&](const agent_framework::model::Metric& metric) -> bool { return metric.get_component_type() == resource.get_component() && metric.get_component_uuid() == resource_uuid; } ); for (const auto& metric : metrics) { telemetry::remove(metric, dc.event_collector); } }
bool VerificationType::is_reference_assignable_from( const VerificationType& from, ClassVerifier* context, bool from_field_is_protected, TRAPS) const { instanceKlassHandle klass = context->current_class(); if (from.is_null()) { // null is assignable to any reference return true; } else if (is_null()) { return false; } else if (name() == from.name()) { return true; } else if (is_object()) { // We need check the class hierarchy to check assignability if (name() == vmSymbols::java_lang_Object()) { // any object or array is assignable to java.lang.Object return true; } Klass* obj = SystemDictionary::resolve_or_fail( name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (TraceClassResolution) { Verifier::trace_class_resolution(obj, klass()); } KlassHandle this_class(THREAD, obj); if (this_class->is_interface() && (!from_field_is_protected || from.name() != vmSymbols::java_lang_Object())) { // If we are not trying to access a protected field or method in // java.lang.Object then we treat interfaces as java.lang.Object, // including java.lang.Cloneable and java.io.Serializable. return true; } else if (from.is_object()) { Klass* from_class = SystemDictionary::resolve_or_fail( from.name(), Handle(THREAD, klass->class_loader()), Handle(THREAD, klass->protection_domain()), true, CHECK_false); if (TraceClassResolution) { Verifier::trace_class_resolution(from_class, klass()); } return InstanceKlass::cast(from_class)->is_subclass_of(this_class()); } } else if (is_array() && from.is_array()) { VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_from = from.get_component(context, CHECK_false); if (!comp_this.is_bogus() && !comp_from.is_bogus()) { return comp_this.is_component_assignable_from(comp_from, context, from_field_is_protected, CHECK_false); } } return false; }
void MonomialInfo::showAlpha(const_packed_monomial m) const { long comp = get_component(m); m += 2 + nweights; // get by: hashcode, component, weightvals for (int i=0; i<nvars; i++) { long e = *m++; if (e == 0) continue; fprintf(stdout, "%c", 'a' + i); if (e > 1) fprintf(stdout, "%ld", e); } fprintf(stdout, "<%ld>", comp); }
component *get_component(component *parent, int id) { component *p = parent; while (1) { p = p->next; if (p == NULL) return NULL; if (p->id == id) { return p; } } if (parent->child != NULL) { return get_component(parent->child, id); } return NULL; }
io_status short_list::asciiOut(ostream& out) { out << "OID_T:\n"; my_oid().asciiOut(out); out << "\n"; for ( int i=1; i<=v_sz; i++ ) { handler* hd_ptr = get_component(i); (*hd_ptr) -> asciiOut(out); out << "\n"; delete hd_ptr; } return done; }
int main(int argc, char * argv[]){ FILE * signal, * peaks; int i, j; time_series * ankle_joint; motion m; unidimentional_series ankle, ankle_peaks; bvh_load_data( argv[1], &m ); unidimentional_series_init( &ankle, 1000); unidimentional_series_init( &ankle_peaks, 100); ankle_joint = m.data.get( m.data_ptr, "RightFoot"); get_component( ankle_joint, &ankle, 'y'); detect_peaks( &ankle, &ankle_peaks, 5); signal = fopen("signal.txt", "w"); peaks = fopen("peaks.txt", "w"); for(i = 0; i < ankle_joint -> length; ++i) fprintf(signal, "%d %lf\n", i, ankle_joint -> begin[i].y); for(i = 0; i < ankle_peaks.length; ++i){ j = ankle_peaks.begin[i]; fprintf(peaks, "%d %lf\n", j, ankle_joint -> begin[j].y); } fclose(signal); fclose(peaks); bvh_unload_data( &m ); ankle.destroy( &ankle ); ankle_peaks.destroy( &ankle_peaks ); return 0; }
bool VerificationType::is_reference_assignable_from( const VerificationType& from, ClassVerifier* context, bool from_field_is_protected, TRAPS) const { instanceKlassHandle klass = context->current_class(); if (from.is_null()) { // null is assignable to any reference return true; } else if (is_null()) { return false; } else if (name() == from.name()) { return true; } else if (is_object()) { // We need check the class hierarchy to check assignability if (name() == vmSymbols::java_lang_Object()) { // any object or array is assignable to java.lang.Object return true; } if (DumpSharedSpaces && SystemDictionaryShared::add_verification_constraint(klass(), name(), from.name(), from_field_is_protected, from.is_array(), from.is_object())) { // If add_verification_constraint() returns true, the resolution/check should be // delayed until runtime. return true; } return resolve_and_check_assignability(klass(), name(), from.name(), from_field_is_protected, from.is_array(), from.is_object(), THREAD); } else if (is_array() && from.is_array()) { VerificationType comp_this = get_component(context, CHECK_false); VerificationType comp_from = from.get_component(context, CHECK_false); if (!comp_this.is_bogus() && !comp_from.is_bogus()) { return comp_this.is_component_assignable_from(comp_from, context, from_field_is_protected, CHECK_false); } } return false; }
void build_metrics(const std::string& resource_uuid, const DiscoveryContext& dc, const DiscoveryParams<TYPE>&) { const auto resource = agent_framework::module::get_manager<ModelType<TYPE>>() .get_entry(resource_uuid); const auto resource_key = ::telemetry::get_resource_key(resource); for (auto& resource_sensor : dc.telemetry_service->get_resource_sensors()) { if (resource_sensor->get_resource() == resource_key) { auto& definition = resource_sensor->get_definition(); if (!definition.has_persistent_uuid()) { telemetry::stabilize(definition, definition.to_json().dump()); } telemetry::add(definition, dc.event_collector); agent_framework::model::Metric metric; metric.set_component_uuid(resource.get_uuid()); metric.set_component_type(resource.get_component()); metric.set_metric_definition_uuid(definition.get_uuid()); metric.set_name(definition.get_metric_jsonptr()); telemetry::stabilize(metric, static_cast<const agent_framework::model::Resource&>(resource)); telemetry::add(metric, dc.event_collector); } } }
io_status tuple::asciiOut(ostream& out) { out << "OID_T:\n"; my_oid().asciiOut(out); out << "\n"; // debug(cerr, v_sz); for ( unsigned int i=1; i<=v_sz; i++ ) { handler* hd_ptr = get_component(i); if ( hd_ptr == 0 ) continue; (*hd_ptr) -> asciiOut(out); out << "\n"; delete hd_ptr; } return done; }
/* * Add pseudo device target to the set of pseudo devices. Pseudo_dev * describes the pseudo device attributes. */ struct pseudo *add_pseudo(struct pseudo *pseudo, struct pseudo_dev *pseudo_dev, char *target, char *alltarget) { char targname[1024]; int i; target = get_component(target, targname); if(pseudo == NULL) { if((pseudo = malloc(sizeof(struct pseudo))) == NULL) BAD_ERROR("failed to allocate pseudo file\n"); pseudo->names = 0; pseudo->count = 0; pseudo->name = NULL; } for(i = 0; i < pseudo->names; i++) if(strcmp(pseudo->name[i].name, targname) == 0) break; if(i == pseudo->names) { /* allocate new name entry */ pseudo->names ++; pseudo->name = realloc(pseudo->name, (i + 1) * sizeof(struct pseudo_entry)); if(pseudo->name == NULL) BAD_ERROR("failed to allocate pseudo file\n"); pseudo->name[i].name = strdup(targname); if(target[0] == '\0') { /* at leaf pathname component */ pseudo->name[i].pseudo = NULL; pseudo->name[i].pathname = strdup(alltarget); pseudo->name[i].dev = pseudo_dev; } else { /* recurse adding child components */ pseudo->name[i].dev = NULL; pseudo->name[i].pseudo = add_pseudo(NULL, pseudo_dev, target, alltarget); } } else { /* existing matching entry */ if(pseudo->name[i].pseudo == NULL) { /* No sub-directory which means this is the leaf * component of a pre-existing pseudo file. */ if(target[0] != '\0') { /* entry must exist as a 'd' type pseudo file */ if(pseudo->name[i].dev->type == 'd') /* recurse adding child components */ pseudo->name[i].pseudo = add_pseudo(NULL, pseudo_dev, target, alltarget); else ERROR("%s already exists as a non " "directory. Ignoring %s!\n", targname, alltarget); } else if(memcmp(pseudo_dev, pseudo->name[i].dev, sizeof(struct pseudo_dev)) != 0) ERROR("%s already exists as a different pseudo " "definition. Ignoring!\n", alltarget); else ERROR("%s already exists as an identical " "pseudo definition!\n", alltarget); } else { /* sub-directory exists which means this can only be a * 'd' type pseudo file */ if(target[0] == '\0') { if(pseudo->name[i].dev == NULL && pseudo_dev->type == 'd') { pseudo->name[i].pathname = strdup(alltarget); pseudo->name[i].dev = pseudo_dev; } else ERROR("%s already exists as a " "directory. Ignoring %s!\n", targname, alltarget); } else /* recurse adding child components */ add_pseudo(pseudo->name[i].pseudo, pseudo_dev, target, alltarget); } } return pseudo; }
static GstVaapiDecoderStatus decode_scan (GstVaapiDecoderJpeg * decoder, GstJpegSegment * seg) { GstVaapiDecoderJpegPrivate *const priv = &decoder->priv; GstVaapiPicture *const picture = priv->current_picture; GstVaapiSlice *slice; VASliceParameterBufferJPEGBaseline *slice_param; GstJpegScanHdr scan_hdr; guint scan_hdr_size, scan_data_size; guint i, h_max, v_max, mcu_width, mcu_height; if (!VALID_STATE (decoder, GOT_SOF)) return GST_VAAPI_DECODER_STATUS_SUCCESS; scan_hdr_size = (seg->data[seg->offset] << 8) | seg->data[seg->offset + 1]; scan_data_size = seg->size - scan_hdr_size; memset (&scan_hdr, 0, sizeof (scan_hdr)); if (!gst_jpeg_segment_parse_scan_header (seg, &scan_hdr)) { GST_ERROR ("failed to parse scan header"); return GST_VAAPI_DECODER_STATUS_ERROR_BITSTREAM_PARSER; } slice = GST_VAAPI_SLICE_NEW (JPEGBaseline, decoder, seg->data + seg->offset + scan_hdr_size, scan_data_size); if (!slice) { GST_ERROR ("failed to allocate slice"); return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; } gst_vaapi_picture_add_slice (picture, slice); if (!VALID_STATE (decoder, GOT_HUF_TABLE)) gst_jpeg_get_default_huffman_tables (&priv->huf_tables); // Update VA Huffman table if it changed for this scan if (huffman_tables_updated (&priv->huf_tables)) { slice->huf_table = GST_VAAPI_HUFFMAN_TABLE_NEW (JPEGBaseline, decoder); if (!slice->huf_table) { GST_ERROR ("failed to allocate Huffman tables"); huffman_tables_reset (&priv->huf_tables); return GST_VAAPI_DECODER_STATUS_ERROR_ALLOCATION_FAILED; } fill_huffman_table (slice->huf_table, &priv->huf_tables); huffman_tables_reset (&priv->huf_tables); } slice_param = slice->param; slice_param->num_components = scan_hdr.num_components; for (i = 0; i < scan_hdr.num_components; i++) { slice_param->components[i].component_selector = scan_hdr.components[i].component_selector; slice_param->components[i].dc_table_selector = scan_hdr.components[i].dc_selector; slice_param->components[i].ac_table_selector = scan_hdr.components[i].ac_selector; } slice_param->restart_interval = priv->mcu_restart; slice_param->slice_horizontal_position = 0; slice_param->slice_vertical_position = 0; get_max_sampling_factors (&priv->frame_hdr, &h_max, &v_max); mcu_width = 8 * h_max; mcu_height = 8 * v_max; if (scan_hdr.num_components == 1) { // Non-interleaved const guint Csj = slice_param->components[0].component_selector; const GstJpegFrameComponent *const fcp = get_component (&priv->frame_hdr, Csj); if (!fcp || fcp->horizontal_factor == 0 || fcp->vertical_factor == 0) { GST_ERROR ("failed to validate image component %u", Csj); return GST_VAAPI_DECODER_STATUS_ERROR_INVALID_PARAMETER; } mcu_width /= fcp->horizontal_factor; mcu_height /= fcp->vertical_factor; } slice_param->num_mcus = ((priv->frame_hdr.width + mcu_width - 1) / mcu_width) * ((priv->frame_hdr.height + mcu_height - 1) / mcu_height); priv->decoder_state |= GST_JPEG_VIDEO_STATE_GOT_SOS; return GST_VAAPI_DECODER_STATUS_SUCCESS; }
/* * Add pseudo device target to the set of pseudo devices. Pseudo_dev * describes the pseudo device attributes. */ struct pseudo *add_pseudo(struct pseudo *pseudo, struct pseudo_dev *pseudo_dev, char *target, char *alltarget) { char *targname; int i; target = get_component(target, &targname); if(pseudo == NULL) { pseudo = malloc(sizeof(struct pseudo)); if(pseudo == NULL) MEM_ERROR(); pseudo->names = 0; pseudo->count = 0; pseudo->name = NULL; } for(i = 0; i < pseudo->names; i++) if(strcmp(pseudo->name[i].name, targname) == 0) break; if(i == pseudo->names) { /* allocate new name entry */ pseudo->names ++; pseudo->name = realloc(pseudo->name, (i + 1) * sizeof(struct pseudo_entry)); if(pseudo->name == NULL) MEM_ERROR(); pseudo->name[i].name = targname; if(target[0] == '\0') { /* at leaf pathname component */ pseudo->name[i].pseudo = NULL; pseudo->name[i].pathname = strdup(alltarget); pseudo->name[i].dev = pseudo_dev; } else { /* recurse adding child components */ pseudo->name[i].dev = NULL; pseudo->name[i].pseudo = add_pseudo(NULL, pseudo_dev, target, alltarget); } } else { /* existing matching entry */ free(targname); if(pseudo->name[i].pseudo == NULL) { /* No sub-directory which means this is the leaf * component of a pre-existing pseudo file. */ if(target[0] != '\0') { /* * entry must exist as either a 'd' type or * 'm' type pseudo file */ if(pseudo->name[i].dev->type == 'd' || pseudo->name[i].dev->type == 'm') /* recurse adding child components */ pseudo->name[i].pseudo = add_pseudo(NULL, pseudo_dev, target, alltarget); else { ERROR_START("%s already exists as a " "non directory.", pseudo->name[i].name); ERROR_EXIT(". Ignoring %s!\n", alltarget); } } else if(memcmp(pseudo_dev, pseudo->name[i].dev, sizeof(struct pseudo_dev)) != 0) { ERROR_START("%s already exists as a different " "pseudo definition.", alltarget); ERROR_EXIT(" Ignoring!\n"); } else { ERROR_START("%s already exists as an identical " "pseudo definition!", alltarget); ERROR_EXIT(" Ignoring!\n"); } } else { if(target[0] == '\0') { /* * sub-directory exists, which means we can only * add a pseudo file of type 'd' or type 'm' */ if(pseudo->name[i].dev == NULL && (pseudo_dev->type == 'd' || pseudo_dev->type == 'm')) { pseudo->name[i].pathname = strdup(alltarget); pseudo->name[i].dev = pseudo_dev; } else { ERROR_START("%s already exists as a " "different pseudo definition.", pseudo->name[i].name); ERROR_EXIT(" Ignoring %s!\n", alltarget); } } else /* recurse adding child components */ add_pseudo(pseudo->name[i].pseudo, pseudo_dev, target, alltarget); } } return pseudo; }