void irept::move_to_sub(irept &irep) { #ifdef SHARING detatch(); #endif get_sub().push_back(get_nil_irep()); get_sub().back().swap(irep); }
int irept::compare(const irept &i) const { int r; r=id().compare(i.id()); if(r!=0) return r; const subt::size_type size=get_sub().size(), i_size=i.get_sub().size(); if(size<i_size) return -1; if(size>i_size) return 1; { irept::subt::const_iterator it1, it2; for(it1=get_sub().begin(), it2=i.get_sub().begin(); it1!=get_sub().end() && it2!=i.get_sub().end(); it1++, it2++) { r=it1->compare(*it2); if(r!=0) return r; } assert(it1==get_sub().end() && it2==i.get_sub().end()); } const named_subt::size_type n_size=get_named_sub().size(), i_n_size=i.get_named_sub().size(); if(n_size<i_n_size) return -1; if(n_size>i_n_size) return 1; { irept::named_subt::const_iterator it1, it2; for(it1=get_named_sub().begin(), it2=i.get_named_sub().begin(); it1!=get_named_sub().end() && it2!=i.get_named_sub().end(); it1++, it2++) { r=it1->first.compare(it2->first); if(r!=0) return r; r=it1->second.compare(it2->second); if(r!=0) return r; } assert(it1==get_named_sub().end() && it2==i.get_named_sub().end()); } // equal return 0; }
static void print_health_info(struct mlx5_core_dev *dev) { struct mlx5_core_health *health = &dev->priv.health; struct health_buffer __iomem *h = health->health; char fw_str[18]; u32 fw; int i; /* If the syndrom is 0, the device is OK and no need to print buffer */ if (!ioread8(&h->synd)) return; for (i = 0; i < ARRAY_SIZE(h->assert_var); i++) dev_err(&dev->pdev->dev, "assert_var[%d] 0x%08x\n", i, ioread32be(h->assert_var + i)); dev_err(&dev->pdev->dev, "assert_exit_ptr 0x%08x\n", ioread32be(&h->assert_exit_ptr)); dev_err(&dev->pdev->dev, "assert_callra 0x%08x\n", ioread32be(&h->assert_callra)); fw = ioread32be(&h->fw_ver); sprintf(fw_str, "%d.%d.%d", get_maj(fw), get_min(fw), get_sub(fw)); dev_err(&dev->pdev->dev, "fw_ver %s\n", fw_str); dev_err(&dev->pdev->dev, "hw_id 0x%08x\n", ioread32be(&h->hw_id)); dev_err(&dev->pdev->dev, "irisc_index %d\n", ioread8(&h->irisc_index)); dev_err(&dev->pdev->dev, "synd 0x%x: %s\n", ioread8(&h->synd), hsynd_str(ioread8(&h->synd))); dev_err(&dev->pdev->dev, "ext_synd 0x%04x\n", ioread16be(&h->ext_synd)); }
irep_idt cpp_namet::get_base_name() const { const subt &sub=get_sub(); // find last "::" unsigned base=0; for(unsigned i=0; i<sub.size(); i++) { if(sub[i].id()=="::") base=i+1; } if(base>=sub.size()) return irep_idt(); if(sub[base].id()==ID_name) return sub[base].get(ID_identifier); else if(base+1<sub.size() && sub[base].id()==ID_operator) return "operator"+sub[base+1].id_string(); else if(base+1<sub.size() && sub[base].id()=="~" && sub[base+1].id()==ID_name) return "~"+sub[base+1].get_string(ID_identifier); return irep_idt(); }
size_t irept::hash() const { size_t result=hash_string(id()); forall_irep(it, get_sub()) result=result^it->hash(); forall_named_irep(it, get_named_sub()) { result=result^hash_string(it->first); result=result^it->second.hash(); }
std::size_t to_be_merged_irept::hash() const { std::size_t result=hash_string(id()); const irept::subt &sub=get_sub(); const irept::named_subt &named_sub=get_named_sub(); forall_irep(it, sub) result=hash_combine(result, static_cast<const merged_irept &>(*it).hash()); forall_named_irep(it, named_sub) { result=hash_combine(result, hash_string(it->first)); result=hash_combine(result, static_cast<const merged_irept &>(it->second).hash()); }
irep_idt cpp_namet::get_base_name() const { assert(is_simple_name()); const subt &sub=get_sub(); if(sub.size()==1 && sub.front().id()==ID_name) return sub.front().get(ID_identifier); else if(sub.size()==2 && sub.front().id()==ID_operator) return "operator"+sub[1].id_string(); else if(sub.size()==2 && sub[0].id()=="~" && sub[1].id()==ID_name) return sub[0].id_string()+sub[1].get_string(ID_identifier); else assert(false); return irep_idt(); }
std::size_t irept::hash() const { #ifdef HASH_CODE if(read().hash_code!=0) return read().hash_code; #endif const irept::subt &sub=get_sub(); const irept::named_subt &named_sub=get_named_sub(); std::size_t result=hash_string(id()); forall_irep(it, sub) result=hash_combine(result, it->hash()); forall_named_irep(it, named_sub) { result=hash_combine(result, hash_string(it->first)); result=hash_combine(result, it->second.hash()); }
/* * Module: _walk_module * * Description: * Recursively walks modinfo tree * Scope: local * * Returns: none. */ static void _walk_module(Module * m, List* list, Wsreg_component* parent) { Module * newmod; Wsreg_component* comp; Module* n; do { if (_convert_module(m, &comp, parent) == 0) { list->add_element(list, comp); } else { comp = NULL; } n = m->sub; for (; n != NULL; n = get_sub(n)) { _walk_module(n, list, comp); } } while (m = get_next(m)); }
/* * Module: _walk_module * * Description: * Recursively walks modinfo tree * Scope: local * * Returns: none. */ static void _walk_module(Module * m, TList* list, Wsreg_component* parent) { Module * newmod; Wsreg_component* comp; TLink* link; Module* n; do { if (_convert_module(m, &comp, parent) == 0) { link = _make_link(comp); LLAddLink(*list, link, LLTail); } else { comp = NULL; } n = m->sub; for (; n != NULL; n = get_sub(n)) { _walk_module(n, list, comp); } } while (m = get_next(m)); }
LOCAL VOID *get_address (WORD type, WORD index) { VOID *the_addr = (VOID *)NULL; union { VOID *dummy; BYTE *string; OBJECT **dpobject; OBJECT *object; TEDINFO *tedinfo; ICONBLK *iconblk; BITBLK *bitblk; } all_ptr; switch (type) { case R_TREE: all_ptr.dpobject = (OBJECT **)(*(long **)&rs_global[5]); the_addr = all_ptr.dpobject[index]; break; case R_OBJECT: the_addr = get_sub (index, hdr_buf->rsh_object, sizeof(OBJECT)); break; case R_TEDINFO: case R_TEPTEXT: the_addr = get_sub (index, hdr_buf->rsh_tedinfo, sizeof(TEDINFO)); break; case R_ICONBLK: case R_IBPMASK: the_addr = get_sub (index, hdr_buf->rsh_iconblk, sizeof(ICONBLK)); break; case R_BITBLK: case R_BIPDATA: the_addr = get_sub (index, hdr_buf->rsh_bitblk, sizeof(BITBLK)); break; case R_OBSPEC: all_ptr.object = get_address(R_OBJECT, index); the_addr = &all_ptr.object->ob_spec; break; case R_TEPVALID: case R_TEPTMPLT: all_ptr.tedinfo = get_address(R_TEDINFO, index); if (type == R_TEPVALID) the_addr = &all_ptr.tedinfo->te_pvalid; else the_addr = &all_ptr.tedinfo->te_ptmplt; break; case R_IBPDATA: case R_IBPTEXT: all_ptr.iconblk = get_address(R_ICONBLK, index); if (type == R_IBPDATA) the_addr = &all_ptr.iconblk->ib_pdata; else the_addr = &all_ptr.iconblk->ib_ptext; break; case R_STRING: the_addr = get_sub (index, hdr_buf->rsh_frstr, sizeof (BYTE *)); break; case R_IMAGEDATA: the_addr = get_sub (index, hdr_buf->rsh_imdata, sizeof (BYTE *)); the_addr = (VOID *)*(BYTE *)the_addr; break; case R_FRIMG: the_addr = get_sub (index, hdr_buf->rsh_frimg, sizeof (BYTE *)); break; case R_FRSTR: the_addr = get_sub (index, hdr_buf->rsh_frstr, sizeof (BYTE *)); break; } return (the_addr); }
/* * Break up a string into literal and substitition tokens. The string * is not modified or copied and will need to be available for the lifetime * of the subst_vec. */ int subst_tokenize(const char *str, struct subst_vec **vecp) { struct subst_vec *subv = NULL; struct subst *sub = NULL; const char *cur = str; int count = 0; int deep = 0; while (*cur) { if (!sub) { sub = get_sub(&subv); sub->value = cur; } if (cur[0] == '\\' && cur[1] == '$') { cur += 2; continue; } else if (cur[0] == '$' && cur[1] == '{') { if (cur == sub->value) { sub->value += 2; deep = 1; } else if (!deep++) { sub->len = cur - sub->value; sub->literal = true; sub = NULL; } else { log_err("syntax error at position %u: nested variables are not allowed.", cur - str); goto fail; } cur += 2; continue; } else if (*cur == '}') { /* * We actually could handle nested variables but * we don't currently have a way to order them * properly. */ if (deep > 0) { sub->len = cur - sub->value; sub->literal = false; sub = NULL; --deep; } } else if (*cur == ' ' && deep) { log_err("syntax error at position %u: spaces not allowed in variable names.", cur - str); goto fail; } cur++; } if (sub) { if (deep) { log_err("parse error at end of input: missing closing `}' for variable substitution."); goto fail; } sub->literal = true; sub->len = cur - sub->value; } *vecp = resize_subv(subv, subv->count); if (global_state.verbose > 2) for (count = 0; count < subv->count; count++) { log_debug("subv->vec[%d] = \"%s%.*s\" [%u]", count, subv->vec[count].literal ? "" : "$", subv->vec[count].len, subv->vec[count].value, subv->vec[count].len); } return 0; fail: subst_release(subv); *vecp = NULL; return -EINVAL; }