int mman_release_page(spdid_t spd, vaddr_t addr, int flags) { struct mapping *m; int ret = 0; LOCK(); m = mapping_lookup(spd, addr); if (!m) { ret = -1; /* -EINVAL */ goto done; } mapping_del(m); done: UNLOCK(); return ret; }
vaddr_t mman_alias_page(spdid_t s_spd, vaddr_t s_addr, spdid_t d_spd, vaddr_t d_addr) { struct mapping *m, *n; vaddr_t ret = 0; LOCK(); mm_init(); m = mapping_lookup(s_spd, s_addr); if (!m) goto done; /* -EINVAL */ n = mapping_crt(m, m->f, d_spd, d_addr); if (!n) goto done; assert(n->addr == d_addr); assert(n->spdid == d_spd); assert(n->p == m); ret = d_addr; done: UNLOCK(); return ret; }
vaddr_t __mman_alias_page(spdid_t s_spd, vaddr_t s_addr, u32_t d_spd_flags, vaddr_t d_addr) { struct mapping *m, *n; vaddr_t ret = 0; spdid_t d_spd; int flags; d_spd = d_spd_flags >> 16; flags = d_spd_flags & 0xFFFF; LOCK(); m = mapping_lookup(s_spd, s_addr); if (!m) goto done; /* -EINVAL */ n = mapping_crt(m, m->f, d_spd, d_addr, flags); if (!n) goto done; assert(n->addr == d_addr); assert(n->spdid == d_spd); assert(n->p == m); ret = d_addr; done: UNLOCK(); return ret; }
vaddr_t mman_get_page(spdid_t spd, vaddr_t addr, int flags) { struct frame *f; struct mapping *m = NULL; vaddr_t ret = -1; LOCK(); mm_init(); f = frame_alloc(); if (!f) goto done; /* -ENOMEM */ frame_ref(f); m = mapping_crt(NULL, f, spd, addr); if (!m) goto dealloc; assert(m->addr == addr); assert(m->spdid == spd); assert(m == mapping_lookup(spd, addr)); ret = m->addr; done: UNLOCK(); return ret; dealloc: frame_deref(f); goto done; /* -EINVAL */ }
iconv_t rpl_iconv_open (const char *tocode, const char *fromcode) #undef iconv_open { char fromcode_upper[32]; char tocode_upper[32]; char *fromcode_upper_end; char *tocode_upper_end; #if REPLACE_ICONV_UTF /* Special handling of conversion between UTF-8 and UTF-{16,32}{BE,LE}. Do this here, before calling the real iconv_open(), because OSF/1 5.1 iconv() to these encoding inserts a BOM, which is wrong. We do not need to handle conversion between arbitrary encodings and UTF-{16,32}{BE,LE}, because the 'striconveh' module implements two-step conversion through UTF-8. The _ICONV_* constants are chosen to be disjoint from any iconv_t returned by the system's iconv_open() functions. Recall that iconv_t is a scalar type. */ if (c_toupper (fromcode[0]) == 'U' && c_toupper (fromcode[1]) == 'T' && c_toupper (fromcode[2]) == 'F' && fromcode[3] == '-') { if (c_toupper (tocode[0]) == 'U' && c_toupper (tocode[1]) == 'T' && c_toupper (tocode[2]) == 'F' && tocode[3] == '-') { if (strcmp (fromcode + 4, "8") == 0) { if (c_strcasecmp (tocode + 4, "16BE") == 0) return _ICONV_UTF8_UTF16BE; if (c_strcasecmp (tocode + 4, "16LE") == 0) return _ICONV_UTF8_UTF16LE; if (c_strcasecmp (tocode + 4, "32BE") == 0) return _ICONV_UTF8_UTF32BE; if (c_strcasecmp (tocode + 4, "32LE") == 0) return _ICONV_UTF8_UTF32LE; } else if (strcmp (tocode + 4, "8") == 0) { if (c_strcasecmp (fromcode + 4, "16BE") == 0) return _ICONV_UTF16BE_UTF8; if (c_strcasecmp (fromcode + 4, "16LE") == 0) return _ICONV_UTF16LE_UTF8; if (c_strcasecmp (fromcode + 4, "32BE") == 0) return _ICONV_UTF32BE_UTF8; if (c_strcasecmp (fromcode + 4, "32LE") == 0) return _ICONV_UTF32LE_UTF8; } } } #endif /* Do *not* add special support for 8-bit encodings like ASCII or ISO-8859-1 here. This would lead to programs that work in some locales (such as the "C" or "en_US" locales) but do not work in East Asian locales. It is better if programmers make their programs depend on GNU libiconv (except on glibc systems), e.g. by using the AM_ICONV macro and documenting the dependency in an INSTALL or DEPENDENCIES file. */ /* Try with the original names first. This covers the case when fromcode or tocode is a lowercase encoding name that is understood by the system's iconv_open but not listed in our mappings table. */ { iconv_t cd = iconv_open (tocode, fromcode); if (cd != (iconv_t)(-1)) return cd; } /* Convert the encodings to upper case, because 1. in the arguments of iconv_open() on AIX, HP-UX, and OSF/1 the case matters, 2. it makes searching in the table faster. */ { const char *p = fromcode; char *q = fromcode_upper; while ((*q = c_toupper (*p)) != '\0') { p++; q++; if (q == &fromcode_upper[SIZEOF (fromcode_upper)]) { errno = EINVAL; return (iconv_t)(-1); } } fromcode_upper_end = q; } { const char *p = tocode; char *q = tocode_upper; while ((*q = c_toupper (*p)) != '\0') { p++; q++; if (q == &tocode_upper[SIZEOF (tocode_upper)]) { errno = EINVAL; return (iconv_t)(-1); } } tocode_upper_end = q; } #ifdef ICONV_FLAVOR /* Apply the mappings. */ { const struct mapping *m = mapping_lookup (fromcode_upper, fromcode_upper_end - fromcode_upper); fromcode = (m != NULL ? m->vendor_name : fromcode_upper); } { const struct mapping *m = mapping_lookup (tocode_upper, tocode_upper_end - tocode_upper); tocode = (m != NULL ? m->vendor_name : tocode_upper); } #else fromcode = fromcode_upper; tocode = tocode_upper; #endif return iconv_open (tocode, fromcode); }