void vhpt_mapping_insert(uintptr_t va, asid_t asid, tlb_entry_t entry) { region_register_t rr_save, rr; size_t vrn; rid_t rid; uint64_t tag; vhpt_entry_t *ventry; vrn = va >> VRN_SHIFT; rid = ASID2RID(asid, vrn); rr_save.word = rr_read(vrn); rr.word = rr_save.word; rr.map.rid = rid; rr_write(vrn, rr.word); srlz_i(); ventry = (vhpt_entry_t *) thash(va); tag = ttag(va); rr_write(vrn, rr_save.word); srlz_i(); srlz_d(); ventry->word[0] = entry.word[0]; ventry->word[1] = entry.word[1]; ventry->present.tag.tag_word = tag; }
static void type_add(char *name, char *value) { int h; stabtype *s; char sc =0; char *v; char *vr; char *split; if (!stab_type_init) { init_hash(); stab_type_init = 1; } /* Split the "value" up into a type name and a value */ split = strchr(value,'='); if (value[0] != '(') split = 0; if (split) { sc = *split; v = value; *split = 0; vr = split+1; } else { v = value; sc = 0; vr = 0; } h = thash(name); s = lnames[h]; while (s) { if (strcmp(s->name,name) == 0) { if (strcmp(s->value,v)) { s->value = wad_string_lookup(v); } goto add_more; } s = s->next; } s = deadnames[h]; if (!s) { s = (stabtype *) wad_malloc(sizeof(stabtype)); } else { deadnames[h] = s->next; } s->name = wad_string_lookup(name); s->value = wad_string_lookup(v); s->next = lnames[h]; s->visit = 0; lnames[h] = s; /* Now take a look at the value. If it is contains other types, we might be able to define more stuff */ add_more: if (vr) { /* There is a mapping to another type */ type_add(v,vr); } }
void TestDigestOrMAC(TestData &v, bool testDigest) { std::string name = GetRequiredDatum(v, "Name"); std::string test = GetRequiredDatum(v, "Test"); member_ptr<MessageAuthenticationCode> mac; member_ptr<HashTransformation> hash; HashTransformation *pHash = NULL; TestDataNameValuePairs pairs(v); if (testDigest) { hash.reset(ObjectFactoryRegistry<HashTransformation>::Registry().CreateObject(name.c_str())); pHash = hash.get(); } else { mac.reset(ObjectFactoryRegistry<MessageAuthenticationCode>::Registry().CreateObject(name.c_str())); pHash = mac.get(); ConstByteArrayParameter iv; if (pairs.GetValue(Name::IV(), iv) && iv.size() != mac->IVSize()) SignalTestFailure(); std::string key = GetDecodedDatum(v, "Key"); mac->SetKey((const byte *)key.c_str(), key.size(), pairs); } if (test == "Verify" || test == "VerifyTruncated" || test == "NotVerify") { int digestSize = pHash->DigestSize(); if (test == "VerifyTruncated") digestSize = atoi(GetRequiredDatum(v, "TruncatedSize").c_str()); TruncatedHashModule thash(*pHash, digestSize); HashVerificationFilter verifierFilter(thash, NULL, HashVerificationFilter::HASH_AT_BEGIN); PutDecodedDatumInto(v, "Digest", verifierFilter); PutDecodedDatumInto(v, "Message", verifierFilter); verifierFilter.MessageEnd(); if (verifierFilter.GetLastResult() == (test == "NotVerify")) SignalTestFailure(); } else { SignalTestError(); assert(false); } }
static char *type_resolve(char *name) { int h; stabtype *s; h = thash(name); s = lnames[h]; while(s) { if (strcmp(s->name,name) == 0) { if (!s->visit) { char *c; /* The visit flag is set so that we don't get in infinite loops */ s->visit = 1; c = type_resolve(s->value); s->visit = 0; return c; } else { return name; } } s = s->next; } return name; }
/* * Read a type and return the index of this type. */ static u_short inptype(const char *cp, const char **epp) { char c, s, *eptr; const char *ep; type_t *tp; int narg, i, osdef = 0; size_t tlen; u_short tidx, sidx; int h; /* If we have this type already, return it's index. */ tlen = gettlen(cp, &ep); h = thash(cp, tlen); if ((tidx = findtype(cp, tlen, h)) != 0) { *epp = ep; return (tidx); } /* No, we must create a new type. */ tp = xalloc(sizeof (type_t)); tidx = storetyp(tp, cp, tlen, h); c = *cp++; while (c == 'c' || c == 'v') { if (c == 'c') { tp->t_const = 1; } else { tp->t_volatile = 1; } c = *cp++; } if (c == 's' || c == 'u' || c == 'l' || c == 'e') { s = c; c = *cp++; } else { s = '\0'; } switch (c) { case 'C': tp->t_tspec = s == 's' ? SCHAR : (s == 'u' ? UCHAR : CHAR); break; case 'S': tp->t_tspec = s == 'u' ? USHORT : SHORT; break; case 'I': tp->t_tspec = s == 'u' ? UINT : INT; break; case 'L': tp->t_tspec = s == 'u' ? ULONG : LONG; break; case 'Q': tp->t_tspec = s == 'u' ? UQUAD : QUAD; break; case 'D': tp->t_tspec = s == 's' ? FLOAT : (s == 'l' ? LDOUBLE : DOUBLE); break; case 'V': tp->t_tspec = VOID; break; case 'P': tp->t_tspec = PTR; break; case 'A': tp->t_tspec = ARRAY; break; case 'F': case 'f': osdef = c == 'f'; tp->t_tspec = FUNC; break; case 'T': tp->t_tspec = s == 'e' ? ENUM : (s == 's' ? STRUCT : UNION); break; } switch (tp->t_tspec) { case ARRAY: tp->t_dim = (int)strtol(cp, &eptr, 10); cp = eptr; sidx = inptype(cp, &cp); /* force seq. point! (ditto below) */ tp->t_subt = TP(sidx); break; case PTR: sidx = inptype(cp, &cp); tp->t_subt = TP(sidx); break; case FUNC: c = *cp; if (isdigit((u_char)c)) { if (!osdef) tp->t_proto = 1; narg = (int)strtol(cp, &eptr, 10); cp = eptr; if ((tp->t_args = calloc((size_t)(narg + 1), sizeof (type_t *))) == NULL) nomem(); for (i = 0; i < narg; i++) { if (i == narg - 1 && *cp == 'E') { tp->t_vararg = 1; cp++; } else { sidx = inptype(cp, &cp); tp->t_args[i] = TP(sidx); } } } sidx = inptype(cp, &cp); tp->t_subt = TP(sidx); break; case ENUM: tp->t_tspec = INT; tp->t_isenum = 1; /* FALLTHROUGH */ case STRUCT: case UNION: switch (*cp++) { case '1': tp->t_istag = 1; tp->t_tag = hsearch(inpname(cp, &cp), 1); break; case '2': tp->t_istynam = 1; tp->t_tynam = hsearch(inpname(cp, &cp), 1); break; case '3': tp->t_isuniqpos = 1; tp->t_uniqpos.p_line = strtol(cp, &eptr, 10); cp = eptr; cp++; /* xlate to 'global' file name. */ tp->t_uniqpos.p_file = addoutfile(inpfns[strtol(cp, &eptr, 10)]); cp = eptr; cp++; tp->t_uniqpos.p_uniq = strtol(cp, &eptr, 10); cp = eptr; break; } break; case LONG: case VOID: case LDOUBLE: case DOUBLE: case FLOAT: case UQUAD: case QUAD: case ULONG: case UINT: case INT: case USHORT: case SHORT: case UCHAR: case SCHAR: case CHAR: case UNSIGN: case SIGNED: case NOTSPEC: break; } *epp = cp; return (tidx); }