static const char* _lldpctl_atom_get_str_config(lldpctl_atom_t *atom, lldpctl_key_t key) { char *res = NULL; struct _lldpctl_atom_config_t *c = (struct _lldpctl_atom_config_t *)atom; switch (key) { case lldpctl_k_config_mgmt_pattern: res = c->config->c_mgmt_pattern; break; case lldpctl_k_config_iface_pattern: res = c->config->c_iface_pattern; break; case lldpctl_k_config_cid_pattern: res = c->config->c_cid_pattern; break; case lldpctl_k_config_description: res = c->config->c_description; break; case lldpctl_k_config_platform: res = c->config->c_platform; break; case lldpctl_k_config_hostname: res = c->config->c_hostname; break; case lldpctl_k_config_bond_slave_src_mac_type: return map_lookup(bond_slave_src_mac_map.map, c->config->c_bond_slave_src_mac_type); case lldpctl_k_config_lldp_portid_type: return map_lookup(lldp_portid_map.map, c->config->c_lldp_portid_type); default: SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); return NULL; } return res?res:""; }
int main () { //these work fine - functions given by Allen Hashable *hashable1 = make_hashable_int (1); Hashable *hashable2 = make_hashable_string ("Allen"); Hashable *hashable3 = make_hashable_int (2); // make_int_value also given Value *value1 = make_int_value (17); //failing here! Node *node1 = make_node(hashable1, value1, NULL); fprintf(stdout, "Print node:\n"); print_node (node1); Value *value2 = make_string_value ("Downey"); Node *list = prepend(hashable2, value2, node1); fprintf(stdout, "Print list:\n"); print_list (list); // run some test lookups Value *value = list_lookup (list, hashable1); fprintf(stdout, "List lookup:\n"); print_lookup(value); fprintf(stdout, "List lookup:\n"); value = list_lookup (list, hashable2); print_lookup(value); fprintf(stdout, "List lookup:\n"); value = list_lookup (list, hashable3); print_lookup(value); // make a map Map *map = make_map(10); map_add(map, hashable1, value1); map_add(map, hashable2, value2); printf ("Map\n"); print_map(map); // run some test lookups value = map_lookup(map, hashable1); print_lookup(value); value = map_lookup(map, hashable2); print_lookup(value); value = map_lookup(map, hashable3); print_lookup(value); return 0; }
/*===========================================================================* * swap_proc_dyn_data * *===========================================================================*/ int swap_proc_dyn_data(struct vmproc *src_vmp, struct vmproc *dst_vmp) { int is_vm; int r; is_vm = (dst_vmp->vm_endpoint == VM_PROC_NR); /* For VM, transfer memory regions above the stack first. */ if(is_vm) { #if LU_DEBUG printf("VM: swap_proc_dyn_data: tranferring regions above the stack from old VM (%d) to new VM (%d)\n", src_vmp->vm_endpoint, dst_vmp->vm_endpoint); #endif r = pt_map_in_range(src_vmp, dst_vmp, VM_STACKTOP, 0); if(r != OK) { printf("swap_proc_dyn_data: pt_map_in_range failed\n"); return r; } } #if LU_DEBUG printf("VM: swap_proc_dyn_data: swapping regions' parents for %d (%d) and %d (%d)\n", src_vmp->vm_endpoint, src_vmp->vm_slot, dst_vmp->vm_endpoint, dst_vmp->vm_slot); #endif /* Swap vir_regions' parents. */ map_setparent(src_vmp); map_setparent(dst_vmp); /* For regular processes, transfer regions above the stack now. * In case of rollback, we need to skip this step. To sandbox the * new instance and prevent state corruption on rollback, we share all * the regions between the two instances as COW. */ if(!is_vm) { struct vir_region *vr; vr = map_lookup(dst_vmp, VM_STACKTOP, NULL); if(vr && !map_lookup(src_vmp, VM_STACKTOP, NULL)) { #if LU_DEBUG printf("VM: swap_proc_dyn_data: tranferring regions above the stack from %d to %d\n", src_vmp->vm_endpoint, dst_vmp->vm_endpoint); #endif r = map_proc_copy_from(src_vmp, dst_vmp, vr); if(r != OK) { return r; } } } return OK; }
int main(int argc,char **argv) { #ifdef STRINGVAL long int i,lo,hi; char *j; #else long int i,j,lo,hi; #endif lo=atol(argv[1]); hi=atol(argv[2]); puts("TOP"); for (i=lo;i<=hi;i++) { j=map_lookup(i); if (j!=0) #ifdef STRINGVAL printf("%ld -> \"%s\"\n",i,j); #else printf("%ld -> %ld\n",i,j); #endif } puts("BOTTOM"); exit(0); }
const data_type * bimap_get_value_by_key_2(bimap_t bimap, const key_type * k2) { size_t * idx = map_lookup(bimap->key_2_map, k2); if (idx == NULL) return NULL; return bimap->datas + *idx * bimap->storage_size; }
size_t bimap_get_index_by_key_2(bimap_t bimap, const key_type * k2) { size_t * idx = map_lookup(bimap->key_2_map, k2); if (idx == NULL) return -1; return *idx; }
/*===========================================================================* * do_unmap_phys * *===========================================================================*/ PUBLIC int do_unmap_phys(message *m) { int r, n; struct vmproc *vmp; endpoint_t target; struct vir_region *region; target = m->VMUP_EP; if(target == SELF) target = m->m_source; if((r=vm_isokendpt(target, &n)) != OK) return EINVAL; vmp = &vmproc[n]; if(!(region = map_lookup(vmp, arch_vir2map(vmp, (vir_bytes) m->VMUM_ADDR)))) { return EINVAL; } if(!(region->flags & VR_DIRECT)) { return EINVAL; } if(map_unmap_region(vmp, region, region->length) != OK) { return EINVAL; } return OK; }
int _gnix_av_lookup(struct gnix_fid_av *gnix_av, fi_addr_t fi_addr, struct gnix_av_addr_entry **entry_ptr) { int ret = FI_SUCCESS; GNIX_TRACE(FI_LOG_AV, "\n"); if (!gnix_av) { ret = -FI_EINVAL; goto err; } switch (gnix_av->type) { case FI_AV_TABLE: ret = table_lookup(gnix_av, fi_addr, entry_ptr); break; case FI_AV_MAP: ret = map_lookup(gnix_av, fi_addr, entry_ptr); break; default: ret = -FI_EINVAL; break; } err: return ret; }
static int undef_iter2(pNode a, struct rule_closure *closure) { switch(a->type) { case symbol: { if(param_indexof(closure->rule->params, a->data)==-1) { /* this node is not a parameter */ if(rule_find(closure->rules, a->data)==NULL) { fprintf(stderr, "undefined symbol '%s' in rule '%s'\n", a->data, closure->rule->symbol); errors++; }; /* check any parameters passed */ if(a->params) undef_iter2(a->params, closure); }; }; break; case mapping: { /* I have been lazy and used global variables. Please forgive me. */ if((map_lookup(mappings, a->data)==NULL) && (trans_lookup(transformations, a->data)==NULL)) { fprintf(stderr, "undefined mapping or transformation '%s' in rule '%s'\n", a->data, closure->rule->symbol); errors++; }; /* recurse into what this mapping applies to */ undef_iter2(a->params, closure); }; }; };
static string try_fontmap P4C(const_string, font_name, unsigned, dpi, string *, glyph_paths, kpse_font_file_type *, font_file) { static hash_table_type fontmap; string *mapped_names; string ret = NULL; if (fontmap.size == 0) { /* If we wanted to complicate our lives, we could handle separate maps for GF and PK ones. I don't see that this has any practical utility, though, because if someone wants an alias, most likely the alias should apply to non-glyphs as well as glyphs (let alone to only GF format or PK format). */ const_string map_path = KPSE_GLYPH_PATH (); fontmap = map_create (map_path); } mapped_names = map_lookup (fontmap, font_name); if (mapped_names) { string mapped_name; while ((mapped_name = *mapped_names++) && !ret) { xputenv ("KPATHSEA_NAME", mapped_name); ret = try_resolution (mapped_name, dpi, glyph_paths, font_file); } } return ret; }
/** * Write value to the database file, possibly caching it and deferring write. * * Any registered value cleanup callback will be invoked right after the value * is written to disk (for immediated writes) or removed from the cache (for * deferred writes). * * @param dw the DBM wrapper * @param key the key (constant-width, determined at open time) * @param value the start of the value in memory * @param length length of the value */ void dbmw_write(dbmw_t *dw, gconstpointer key, gpointer value, size_t length) { struct cached *entry; dbmw_check(dw); g_assert(key); g_assert(length <= dw->value_size); g_assert(length || value == NULL); g_assert(length == 0 || value); dw->w_access++; entry = map_lookup(dw->values, key); if (entry) { if (entry->dirty) dw->w_hits++; else if (entry->absent) dw->count_needs_sync = TRUE; /* Key exists now */ fill_entry(dw, entry, value, length); hash_list_moveto_tail(dw->keys, key); } else if (dw->max_cached > 1) { entry = allocate_entry(dw, key, NULL); fill_entry(dw, entry, value, length); dw->count_needs_sync = TRUE; /* Does not know whether key exists */ } else { write_immediately(dw, key, value, length); } }
int _gnix_av_lookup(struct gnix_fid_av *gnix_av, fi_addr_t fi_addr, struct gnix_av_addr_entry *entry_ptr) { int ret = FI_SUCCESS; fi_addr_t addr = fi_addr & gnix_av->mask; GNIX_TRACE(FI_LOG_AV, "\n"); if (!gnix_av) { ret = -FI_EINVAL; goto err; } switch (gnix_av->type) { case FI_AV_TABLE: ret = table_lookup(gnix_av, addr, entry_ptr); break; case FI_AV_MAP: ret = map_lookup(gnix_av, addr, entry_ptr); break; default: ret = -FI_EINVAL; break; } if (fi_addr & ~gnix_av->mask) { entry_ptr->gnix_addr.cdm_id += fi_addr >> (64 - gnix_av->rx_ctx_bits); }
static const char* _lldpctl_atom_get_str_config(lldpctl_atom_t *atom, lldpctl_key_t key) { char *res = NULL; struct _lldpctl_atom_config_t *c = (struct _lldpctl_atom_config_t *)atom; switch (key) { case lldpctl_k_config_mgmt_pattern: res = c->config->c_mgmt_pattern; break; case lldpctl_k_config_iface_pattern: res = c->config->c_iface_pattern; break; case lldpctl_k_config_cid_pattern: res = c->config->c_cid_pattern; break; case lldpctl_k_config_description: res = c->config->c_description; break; case lldpctl_k_config_platform: res = c->config->c_platform; break; case lldpctl_k_config_hostname: //res = c->config->c_hostname; break; if (recv_cnt<c->config->c_custom_tlv_cnt[recv_seq] && recv_seq!=c->config->c_custom_tlv_seq){ res = c->config->c_custom_tlv_str[recv_seq][recv_cnt]; if (recv_cnt+1>=EVERTZ_MAX_CNT){ printf("warning: recv cnt returns to header"); recv_cnt = (recv_cnt+1)%EVERTZ_MAX_CNT; } else{ recv_cnt++; } break; } else if (recv_seq!=c->config->c_custom_tlv_seq){ recv_seq = (recv_seq+1)%EVERTZ_MAX_SEQ; recv_cnt = 0; } res = NULL; break; case lldpctl_k_config_bond_slave_src_mac_type: return map_lookup(bond_slave_src_mac_map.map, c->config->c_bond_slave_src_mac_type); case lldpctl_k_config_lldp_portid_type: return map_lookup(lldp_portid_map.map, c->config->c_lldp_portid_type); default: SET_ERROR(atom->conn, LLDPCTL_ERR_NOT_EXIST); return NULL; } return res?res:""; }
int main () { Hashable *hashable1 = make_hashable_int (1); Hashable *hashable2 = make_hashable_string ("Allen"); Hashable *hashable3 = make_hashable_int (2); // make a list by hand Value *value1 = make_int_value (17); Node *node1 = make_node(hashable1, value1, NULL); print_node (node1); Value *value2 = make_string_value ("Downey"); Node *list = prepend(hashable2, value2, node1); print_list (list); // run some test lookups Value *value = list_lookup (list, hashable1); print_lookup(value); value = list_lookup (list, hashable2); print_lookup(value); value = list_lookup (list, hashable3); print_lookup(value); // make a map Map *map = make_map(10); map_add(map, hashable1, value1); map_add(map, hashable2, value2); printf ("Map\n"); print_map(map); // run some test lookups value = map_lookup(map, hashable1); print_lookup(value); value = map_lookup(map, hashable2); print_lookup(value); value = map_lookup(map, hashable3); print_lookup(value); return 0; }
/*===========================================================================* * do_remap * *===========================================================================*/ PUBLIC int do_remap(message *m) { int dn, sn; vir_bytes da, sa, startv; size_t size; struct vir_region *vr, *region; struct vmproc *dvmp, *svmp; int r; da = (vir_bytes) m->VMRE_DA; sa = (vir_bytes) m->VMRE_SA; size = m->VMRE_SIZE; if ((r = vm_isokendpt((endpoint_t) m->VMRE_D, &dn)) != OK) return EINVAL; if ((r = vm_isokendpt((endpoint_t) m->VMRE_S, &sn)) != OK) return EINVAL; dvmp = &vmproc[dn]; svmp = &vmproc[sn]; /* da is not translated by arch_vir2map(), * it's handled a little differently, * since in map_remap(), we have to know * about whether the user needs to bind to * THAT address or be chosen by the system. */ sa = arch_vir2map(svmp, sa); if (!(region = map_lookup(svmp, sa))) return EINVAL; if(region->vaddr != sa) { printf("VM: do_remap: not start of region.\n"); return EFAULT; } if(!(region->flags & VR_SHARED)) { printf("VM: do_remap: not shared.\n"); return EFAULT; } if (size % VM_PAGE_SIZE) size += VM_PAGE_SIZE - size % VM_PAGE_SIZE; if(size != region->length) { printf("VM: do_remap: not size of region.\n"); return EFAULT; } if ((r = map_remap(dvmp, da, size, region, &startv)) != OK) return r; m->VMRE_RETA = (char *) arch_map2vir(dvmp, startv); return OK; }
void acc_sqlite_close(sqlite3 * db) { assert(acc_sqlite != NULL); char * filename = *(char**)map_lookup(acc_sqlite->db_files_map, &db); if (filename != NULL) { acc_sqlite_load_or_save_db(db, filename, 1); free(filename); } map_remove(acc_sqlite->db_files_map, &db); sqlite3_close(db); }
static void display_med_capability(struct writer *w, struct lldpd_chassis *chassis, int cap) { if (chassis->c_med_cap_available & cap) { tag_start(w, "capability", "Capability"); tag_attr(w, "type", "", map_lookup(lldpmed_capabilit_map, cap)); tag_end(w); } }
/*===========================================================================* * do_munmap * *===========================================================================*/ int do_munmap(message *m) { int r, n; struct vmproc *vmp; vir_bytes addr, len, offset; struct vir_region *vr; endpoint_t target = SELF; if(m->m_type == VM_UNMAP_PHYS) { target = m->VMUP_EP; } else if(m->m_type == VM_SHM_UNMAP) { target = m->VMUN_ENDPT; } if(target == SELF) target = m->m_source; if((r=vm_isokendpt(target, &n)) != OK) { panic("do_mmap: message from strange source: %d", m->m_source); } vmp = &vmproc[n]; if(m->m_type == VM_UNMAP_PHYS) { addr = (vir_bytes) m->VMUP_VADDR; } else if(m->m_type == VM_SHM_UNMAP) { addr = (vir_bytes) m->VMUN_ADDR; } else addr = (vir_bytes) m->VMUM_ADDR; if(!(vr = map_lookup(vmp, addr, NULL))) { printf("VM: unmap: virtual address 0x%lx not found in %d\n", addr, target); return EFAULT; } if(addr % VM_PAGE_SIZE) return EFAULT; if(m->m_type == VM_UNMAP_PHYS || m->m_type == VM_SHM_UNMAP) { len = vr->length; } else len = roundup(m->VMUM_LEN, VM_PAGE_SIZE); offset = addr - vr->vaddr; if(offset + len > vr->length) { printf("munmap: addr 0x%lx len 0x%lx spills out of region\n", addr, len); return EFAULT; } if(map_unmap_region(vmp, vr, offset, len) != OK) panic("do_munmap: map_unmap_region failed"); return OK; }
/* * str_check -- hs_check wrapper which works on strings */ static void str_check(const char *str) { uint64_t key; if (sscanf(str, "%lu", &key) > 0) { int r = map_lookup(mapc, map, key); printf("%d\n", r); } else { fprintf(stderr, "check: invalid syntax\n"); } }
void configurable_settings::redintegrate_ex_post (int file_version ,std::map<std::string, std::string> const& detritus_map ,std::list<std::string> const& residuary_names ) { if(class_version() == file_version) { return; } if(file_version < 2) { // Version 2 renamed these elements. LMI_ASSERT(contains(residuary_names, "custom_input_0_filename")); LMI_ASSERT(contains(residuary_names, "custom_output_0_filename")); custom_input_0_filename_ = map_lookup(detritus_map, "custom_input_filename"); custom_output_0_filename_ = map_lookup(detritus_map, "custom_output_filename"); } }
void testSymbols() { VM vm; Value a = vm.makeSymbol("a"); Value b = vm.makeSymbol("b"); Value a2 = vm.makeSymbol("a"); Value one = vm.makeInteger(1); Value two = vm.makeInteger(2); EXPECT(a == a2); EXPECT(a != b); EXPECT(a2 != b); Value map = vm.makeList( vm.makeCons(a, one), vm.makeCons(b, two)); EXPECT_INT_EQ(map_lookup(vm, map, a).asInteger(vm), 1); EXPECT_INT_EQ(map_lookup(vm, map, b).asInteger(vm), 2); }
/* * str_remove -- hs_remove wrapper which works on strings */ static void str_remove(const char *str) { uint64_t key; if (sscanf(str, "%lu", &key) > 0) { int l = map_lookup(mapc, map, key); if (l) map_remove(mapc, map, key); else fprintf(stderr, "no such value\n"); } else fprintf(stderr, "remove: invalid syntax\n"); }
void bimap_remove_by_key_2(bimap_t bimap, const key_type * k2) { size_t * idx = map_lookup(bimap->key_2_map, k2); if (idx == NULL) return; const key_type * k1 = bimap->datas + *idx * bimap->storage_size + bimap->data_size; map_remove(bimap->key_1_map, k1); map_remove(bimap->key_2_map, k2); /// \todo rm data bimap->count--; }
bool MvcController::ModelAndViewValuesEquivalent(std::string const& name) const { std::string const& view_value = map_lookup(transfer_data_, name); std::string const& model_value = model_.Entity(name).str(); bool equal = view_value == model_value; bool equivalent = equal; if(!equal && nullptr != ModelPointer<tn_range_base>(name)) { equivalent = value_cast<double>(view_value) == value_cast<double>(model_value) ; } return equivalent; }
/** * Delete key from database. */ void dbmw_delete(dbmw_t *dw, gconstpointer key) { struct cached *entry; dbmw_check(dw); g_assert(key); dw->w_access++; entry = map_lookup(dw->values, key); if (entry) { if (entry->dirty) dw->w_hits++; if (!entry->absent) { dw->count_needs_sync = TRUE; /* Deferred delete */ fill_entry(dw, entry, NULL, 0); entry->absent = TRUE; } hash_list_moveto_tail(dw->keys, key); } else { dw->ioerr = FALSE; dbmap_remove(dw->dm, key); if (dbmap_has_ioerr(dw->dm)) { dw->ioerr = TRUE; dw->error = errno; g_warning("DBMW \"%s\" I/O error whilst deleting key: %s", dw->name, dbmap_strerror(dw->dm)); } /* * If the maximum value length of the DB is 0, then it is used as a * "search table" only, meaning there will be no read to get values, * only existence checks. * * Therefore, it makes sense to cache that the key is no longer valid. * Otherwise, possibly pushing a value out of the cache to record * a deletion is not worth it. */ if (0 == dw->value_size) { WALLOC0(entry); entry->absent = TRUE; (void) allocate_entry(dw, key, entry); } } }
/** * Write value to the database file, possibly caching it and deferring write. * * Any registered value cleanup callback will be invoked right after the value * is written to disk (for immediated writes) or removed from the cache (for * deferred writes). * * @param dw the DBM wrapper * @param key the key (constant-width, determined at open time) * @param value the start of the value in memory * @param length length of the value */ void dbmw_write(dbmw_t *dw, const void *key, void *value, size_t length) { struct cached *entry; dbmw_check(dw); g_assert(key); g_assert(length <= dw->value_size); g_assert(length || value == NULL); g_assert(length == 0 || value); dw->w_access++; entry = map_lookup(dw->values, key); if (entry) { if (dbg_ds_debugging(dw->dbg, 2, DBG_DSF_CACHING | DBG_DSF_UPDATE)) { dbg_ds_log(dw->dbg, dw, "%s: %s key=%s%s", G_STRFUNC, entry->dirty ? "dirty" : "clean", dbg_ds_keystr(dw->dbg, key, (size_t) -1), entry->absent ? " (was absent)" : ""); } if (entry->dirty) dw->w_hits++; if (entry->absent) dw->cached++; /* Key exists now, in unflushed status */ fill_entry(dw, entry, value, length); hash_list_moveto_tail(dw->keys, key); } else if (dw->max_cached > 1) { if (dbg_ds_debugging(dw->dbg, 2, DBG_DSF_CACHING | DBG_DSF_UPDATE)) { dbg_ds_log(dw->dbg, dw, "%s: deferring key=%s", G_STRFUNC, dbg_ds_keystr(dw->dbg, key, (size_t) -1)); } entry = allocate_entry(dw, key, NULL); fill_entry(dw, entry, value, length); dw->count_needs_sync = TRUE; /* Does not know whether key exists */ } else { if (dbg_ds_debugging(dw->dbg, 2, DBG_DSF_CACHING | DBG_DSF_UPDATE)) { dbg_ds_log(dw->dbg, dw, "%s: writing key=%s", G_STRFUNC, dbg_ds_keystr(dw->dbg, key, (size_t) -1)); } write_immediately(dw, key, value, length); } }
void resolve_variable( val_t* val ) { double fval; if ( val->type != TYPE_VARIABLE ) { printf("Error: value is not a variable.\n"); longjmp( env, 1 ); } if ( !map_lookup( val->d.variable, &fval ) ) { printf("%s not defined.\n", val->d.variable); longjmp( env, 1 ); } val->type = TYPE_FLOAT; val->d.fval = fval; }
/** * Is key present in the database? */ gboolean dbmw_exists(dbmw_t *dw, gconstpointer key) { struct cached *entry; gboolean ret; dbmw_check(dw); g_assert(key); dw->r_access++; entry = map_lookup(dw->values, key); if (entry) { dw->r_hits++; return !entry->absent; } dw->ioerr = FALSE; ret = dbmap_contains(dw->dm, key); if (dbmap_has_ioerr(dw->dm)) { dw->ioerr = TRUE; dw->error = errno; g_warning("DBMW \"%s\" I/O error whilst checking key existence: %s", dw->name, dbmap_strerror(dw->dm)); return FALSE; } /* * If the maximum value length of the DB is 0, then it is used as a * "search table" only, meaning there will be no read to get values, * only existence checks. * * Therefore, it makes sense to cache existence checks. A data read * will also correctly return a null item from the cache. */ if (0 == dw->value_size) { WALLOC0(entry); entry->absent = !ret; (void) allocate_entry(dw, key, entry); } return ret; }
/*===========================================================================* * do_munmap * *===========================================================================*/ int do_munmap(message *m) { int r, n; struct vmproc *vmp; vir_bytes addr, len; endpoint_t target = SELF; if(m->m_type == VM_UNMAP_PHYS) { target = m->m_lsys_vm_unmap_phys.ep; } else if(m->m_type == VM_SHM_UNMAP) { target = m->m_lc_vm_shm_unmap.forwhom; } if(target == SELF) target = m->m_source; if((r=vm_isokendpt(target, &n)) != OK) { panic("do_mmap: message from strange source: %d", m->m_source); } vmp = &vmproc[n]; if(m->m_type == VM_UNMAP_PHYS) { addr = (vir_bytes) m->m_lsys_vm_unmap_phys.vaddr; } else if(m->m_type == VM_SHM_UNMAP) { addr = (vir_bytes) m->m_lc_vm_shm_unmap.addr; } else addr = (vir_bytes) m->VMUM_ADDR; if(addr % VM_PAGE_SIZE) return EFAULT; if(m->m_type == VM_UNMAP_PHYS || m->m_type == VM_SHM_UNMAP) { struct vir_region *vr; if(!(vr = map_lookup(vmp, addr, NULL))) { printf("VM: unmap: address 0x%lx not found in %d\n", addr, target); sys_diagctl_stacktrace(target); return EFAULT; } len = vr->length; } else len = roundup(m->VMUM_LEN, VM_PAGE_SIZE); return map_unmap_range(vmp, addr, len); }
static int getsrc(struct vir_region *region, struct vmproc **vmp, struct vir_region **r) { int srcproc; if(region->def_memtype != &mem_type_shared) { printf("shared region hasn't shared type but %s.\n", region->def_memtype->name); return EINVAL; } if(!region->param.shared.ep || !region->param.shared.vaddr) { printf("shared region has not defined source region.\n"); util_stacktrace(); return EINVAL; } if(vm_isokendpt((endpoint_t) region->param.shared.ep, &srcproc) != OK) { printf("VM: shared memory with missing source process.\n"); util_stacktrace(); return EINVAL; } *vmp = &vmproc[srcproc]; if(!(*r=map_lookup(*vmp, region->param.shared.vaddr, NULL))) { printf("VM: shared memory with missing vaddr 0x%lx.\n", region->param.shared.vaddr); return EINVAL; } if((*r)->def_memtype != &mem_type_anon) { printf("source region hasn't anon type but %s.\n", (*r)->def_memtype->name); return EINVAL; } if(region->param.shared.id != (*r)->id) { printf("source region has no matching id\n"); return EINVAL; } return OK; }