CAMLprim value unix_mkfifo(value path, value mode) { invalid_argument("mkfifo not implemented"); }
CAMLprim value unix_getprotobynumber(value proto) { invalid_argument("getprotobynumber not implemented"); }
bfelf64_sword bfelf_loader_get_info(struct bfelf_loader_t *loader, struct bfelf_file_t *ef, struct section_info_t *info) { bfelf64_sword ret = 0; struct bfelf_shdr *shdr = 0; struct e_string_t name_ctors = {".ctors", 6}; struct e_string_t name_dtors = {".dtors", 6}; struct e_string_t name_eh_frame = {".eh_frame", 9}; if (!loader) return invalid_argument("loader == NULL"); if (!ef) return invalid_argument("ef == NULL"); if (!info) return invalid_argument("info == NULL"); if (loader->relocated == 0) return out_of_order("you need to call bfelf_loader_relocate first"); ret = private_get_section_by_name(ef, &name_ctors, &shdr); if (ret != BFELF_SUCCESS) goto failure; if (shdr != 0) { ret = private_check_section(shdr, bfsht_progbits, bfshf_wa, 8, 0); if (ret != BFELF_SUCCESS) goto failure; info->ctors_addr = shdr->sh_addr + ef->exec; info->ctors_size = shdr->sh_size; } ret = private_get_section_by_name(ef, &name_dtors, &shdr); if (ret != BFELF_SUCCESS) goto failure; if (shdr != 0) { ret = private_check_section(shdr, bfsht_progbits, bfshf_wa, 8, 0); if (ret != BFELF_SUCCESS) goto failure; info->dtors_addr = shdr->sh_addr + ef->exec; info->dtors_size = shdr->sh_size; } ret = private_get_section_by_name(ef, &name_eh_frame, &shdr); if (ret != BFELF_SUCCESS) goto failure; if (shdr != 0) { ret = private_check_section(shdr, bfsht_progbits, bfshf_wa, 8, 0); if (ret != BFELF_SUCCESS) goto failure; info->eh_frame_addr = shdr->sh_addr + ef->exec; info->eh_frame_size = shdr->sh_size; } return BFELF_SUCCESS; failure: info->ctors_addr = 0; info->ctors_size = 0; info->dtors_addr = 0; info->dtors_size = 0; info->eh_frame_addr = 0; info->eh_frame_size = 0; return ret; }
CAMLprim value unix_mktime(value t) { invalid_argument("mktime not implemented"); }
bool FileGenerator::generate(std::string& msg){ throw invalid_argument("Calling abstract FileGenerator::generate() does not make sense."); }
CAMLprim value unix_shutdown(value sock, value cmd) { invalid_argument("shutdown not implemented"); }
void BaseAtlas::load (const char *current, const char *end) { if (!current) throw invalid_argument("current cannot be null."); if (!end) throw invalid_argument("end cannot be null."); string value; string tuple[4]; BaseAtlasPage *page; while (current != end) { readLine(current, end, value); trim(value); if (value.length() == 0) { page = 0; } else if (!page) { page = newAtlasPage(value); pages.push_back(page); page->name = value; page->format = static_cast<Format>(indexOf(formatNames, 7, readValue(current, end, value))); readTuple(current, end, value, tuple); page->minFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[0])); page->magFilter = static_cast<TextureFilter>(indexOf(textureFilterNames, 7, tuple[1])); readValue(current, end, value); if (value == "x") { page->uWrap = repeat; page->vWrap = clampToEdge; } else if (value == "y") { page->uWrap = clampToEdge; page->vWrap = repeat; } else if (value == "xy") { page->uWrap = repeat; page->vWrap = repeat; } } else { BaseAtlasRegion *region = newAtlasRegion(page); regions.push_back(region); region->name = value; region->rotate = readValue(current, end, value) == "true"; readTuple(current, end, value, tuple); region->x = atoi(tuple[0].c_str()); region->y = atoi(tuple[1].c_str()); readTuple(current, end, value, tuple); region->width = atoi(tuple[0].c_str()); region->height = atoi(tuple[1].c_str()); if (readTuple(current, end, value, tuple) == 4) { // split is optional region->splits = new int[4]; region->splits[0] = atoi(tuple[0].c_str()); region->splits[1] = atoi(tuple[1].c_str()); region->splits[2] = atoi(tuple[2].c_str()); region->splits[3] = atoi(tuple[3].c_str()); if (readTuple(current, end, value, tuple) == 4) { // pad is optional, but only present with splits region->pads = new int[4]; region->pads[0] = atoi(tuple[0].c_str()); region->pads[1] = atoi(tuple[1].c_str()); region->pads[2] = atoi(tuple[2].c_str()); region->pads[3] = atoi(tuple[3].c_str()); readTuple(current, end, value, tuple); } } region->originalWidth = atoi(tuple[0].c_str()); region->originalHeight = atoi(tuple[1].c_str()); readTuple(current, end, value, tuple); region->offsetX = atoi(tuple[0].c_str()); region->offsetY = atoi(tuple[1].c_str()); region->index = atoi(readValue(current, end, value).c_str()); } } }
CAMLprim value unix_getcwd(value unit) { invalid_argument("getcwd not implemented"); }
CAMLprim value unix_symlink(value path1, value path2) { invalid_argument("symlink not implemented"); }
int TBitField::GetBit(const int n) const // получить значение бита { if ((n<0)||(n>BitLen)) throw invalid_argument("--"); if ((pMem[GetMemIndex(n)] & GetMemMask(n))>0 ) return 1; else return 0; }
void BigNum::divmod(vector<long long>& numbers, vector<long long>& o_numbers, vector<long long>& quo, vector<long long>& rem, long long base) { long n = o_numbers.size(); long m = numbers.size() - n; vector<long long> vec_d; vec_d.push_back(base / ( *(o_numbers.end() - 1) + 1 )); vector<long long> u = full_mul(numbers, vec_d, base); vector<long long> v = full_mul(o_numbers, vec_d, base); vector<long long> bn1; bn1.push_back(1); lshift(&bn1, n+1); quo.reserve(m+1); for ( int i = 0; i < m+1; ++i ) quo.push_back(0); long j = m; while ( j >= 0 ) { long long qs = (u[j + n] * base + u[j + n - 1]) / v[n - 1]; long long rs = (u[j + n] * base + u[j + n - 1]) % v[n - 1]; while ( rs < base ) if ( qs == base || qs * v[n - 2] > base * rs + u[j + n - 2] ) { qs -= 1; rs += v[n - 1]; } else break; vector<long long> vec_qs; vec_qs.push_back(qs); vector<long long> part_u; vector<long long> summand = full_mul(v, vec_qs, base); part_u = add(u, u.begin() + j, u.begin() + j + n + 1, bn1, bn1.begin(), bn1.end(), base); part_u = full_sub(part_u, summand, base); trim_num_zeroes(part_u); quo[j] = qs; bool neg_flag; if ( part_u.size() > n + 1 ) { neg_flag = false; part_u = full_sub(part_u, bn1, base); } else neg_flag = true; if ( neg_flag ) { --quo[j]; part_u = full_add(part_u, v, base); } for ( int i = j; i < j + n; ++i ) u[i] = part_u[i - j]; --j; } for ( long j = m + n - 1; j > n - 1; --j ) u[j] = 0; long long chk; rem.reserve(m + n); for ( long i = 0; i < n; ++i ) rem.push_back(0); short_divmod(u, vec_d[0], rem, &chk, base); if ( chk != 0 ) throw invalid_argument("error while scaling back to 1/d"); }
void TBitField::ClrBit(const int n) // очистить бит { if ((n<0)||(n>BitLen)) throw invalid_argument("--"); pMem[GetMemIndex(n)]=pMem[GetMemIndex(n)]&(~GetMemMask(n)); }
void TBitField::SetBit(const int n) // установить бит { if ((n<0)||(n>BitLen)) throw invalid_argument("--"); pMem[GetMemIndex(n)]=pMem[GetMemIndex(n)]|GetMemMask(n); }
TELEM TBitField::GetMemMask(const int n) const // битовая маска для бита n { if (n<0) throw invalid_argument("--"); return 1<<n%sz; }
CAMLprim value unix_bind(value socket, value address) { invalid_argument("bind not implemented"); }
CAMLprim value caml_ba_map_file(value vfd, value vkind, value vlayout, value vshared, value vdim, value vstart) { HANDLE fd, fmap; int flags, major_dim, mode, perm; intnat num_dims, i; intnat dim[MAX_NUM_DIMS]; __int64 currpos, startpos, file_size, data_size; uintnat array_size, page, delta; char c; void * addr; LARGE_INTEGER li; SYSTEM_INFO sysinfo; fd = Handle_val(vfd); flags = Int_val(vkind) | Int_val(vlayout); startpos = Int64_val(vstart); num_dims = Wosize_val(vdim); major_dim = flags & BIGARRAY_FORTRAN_LAYOUT ? num_dims - 1 : 0; /* Extract dimensions from Caml array */ num_dims = Wosize_val(vdim); if (num_dims < 1 || num_dims > MAX_NUM_DIMS) invalid_argument("Bigarray.mmap: bad number of dimensions"); for (i = 0; i < num_dims; i++) { dim[i] = Long_val(Field(vdim, i)); if (dim[i] == -1 && i == major_dim) continue; if (dim[i] < 0 || dim[i] > 0x7FFFFFFFL) invalid_argument("Bigarray.create: negative dimension"); } /* Determine file size */ currpos = caml_ba_set_file_pointer(fd, 0, FILE_CURRENT); if (currpos == -1) caml_ba_sys_error(); file_size = caml_ba_set_file_pointer(fd, 0, FILE_END); if (file_size == -1) caml_ba_sys_error(); /* Determine array size in bytes (or size of array without the major dimension if that dimension wasn't specified) */ array_size = bigarray_element_size[flags & BIGARRAY_KIND_MASK]; for (i = 0; i < num_dims; i++) if (dim[i] != -1) array_size *= dim[i]; /* Check if the first/last dimension is unknown */ if (dim[major_dim] == -1) { /* Determine first/last dimension from file size */ if (file_size < startpos) failwith("Bigarray.mmap: file position exceeds file size"); data_size = file_size - startpos; dim[major_dim] = (uintnat) (data_size / array_size); array_size = dim[major_dim] * array_size; if (array_size != data_size) failwith("Bigarray.mmap: file size doesn't match array dimensions"); } /* Restore original file position */ caml_ba_set_file_pointer(fd, currpos, FILE_BEGIN); /* Create the file mapping */ if (Bool_val(vshared)) { perm = PAGE_READWRITE; mode = FILE_MAP_WRITE; } else { perm = PAGE_READONLY; /* doesn't work under Win98 */ mode = FILE_MAP_COPY; } li.QuadPart = startpos + array_size; fmap = CreateFileMapping(fd, NULL, perm, li.HighPart, li.LowPart, NULL); if (fmap == NULL) caml_ba_sys_error(); /* Determine offset so that the mapping starts at the given file pos */ GetSystemInfo(&sysinfo); delta = (uintnat) (startpos % sysinfo.dwPageSize); /* Map the mapping in memory */ li.QuadPart = startpos - delta; addr = MapViewOfFile(fmap, mode, li.HighPart, li.LowPart, array_size + delta); if (addr == NULL) caml_ba_sys_error(); addr = (void *) ((uintnat) addr + delta); /* Close the file mapping */ CloseHandle(fmap); /* Build and return the Caml bigarray */ return alloc_bigarray(flags | BIGARRAY_MAPPED_FILE, num_dims, addr, dim); }
CAMLprim value unix_accept(value sock) { invalid_argument("accept not implemented"); }
CAMLprim value unix_select(value readfds, value writefds, value exceptfds, value timeout) { invalid_argument("select not implemented"); }
CAMLprim value unix_getsockname(value sock) { invalid_argument("getsockname not implemented"); }
CAMLprim value unix_initgroups(value user, value group) { invalid_argument("initgroups not implemented"); }
void BaseAtlas::load (std::ifstream &file) { if (!file) throw invalid_argument("file cannot be null."); if (!file.is_open()) throw runtime_error("Atlas file is not open."); load((std::istream&)file); }
StatementNode *SymbolTable::GetFuncionRegisterType(string name) { if(variables.find(name)!=variables.end()) throw invalid_argument(name +" no existe."); return registrofunciones[name]; }
GroupElement * CryptoPpDlogZpSafePrime::reconstructElement(bool bCheckMembership, GroupElementSendableData * data) { ZpElementSendableData * zp_data = dynamic_cast<ZpElementSendableData *>(data); if (!(zp_data)) throw invalid_argument("data type doesn't match the group type"); return generateElement(bCheckMembership, vector<biginteger>({ zp_data->getX() })); }
TypeNode *SymbolTable::GetVariableType(string name) { if(variables.find(name) == variables.end() ) throw invalid_argument("Variable "+ name +" no existe."); return variables.at(name); }
CAMLprim value unix_inet_addr_of_string(value s) { invalid_argument("inet_addr_of_string not implemented"); }
CAMLprim value caml_thread_self(value unit) { if (curr_thread == NULL) invalid_argument("Thread.self: not initialized"); return curr_thread->descr; }
CAMLprim value unix_gethostbyname(value name) { invalid_argument("gethostbyname not implemented"); }
streambuf::streambuf( std::streambuf *orig ) : orig_buf_( orig ) { if ( !orig ) throw invalid_argument( "null streambuf" ); clear(); }
bfelf64_sword bfelf_file_init(char *file, uint64_t fsize, struct bfelf_file_t *ef) { bfelf64_word i = 0; bfelf64_sword ret = 0; if (!file) return invalid_argument("file == NULL"); if (!ef) return invalid_argument("ef == NULL"); if (fsize == 0 || fsize < sizeof(struct bfelf64_ehdr)) return invalid_argument("fsize invalid"); for (i = 0; i < sizeof(struct bfelf_file_t); i++) ((char *)ef)[i] = 0; ef->file = file; ef->fsize = fsize; ef->ehdr = (struct bfelf64_ehdr *)file; ef->shdrtab = (struct bfelf_shdr *)(file + ef->ehdr->e_shoff); ef->phdrtab = (struct bfelf_phdr *)(file + ef->ehdr->e_phoff); ret = private_check_signature(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_check_support(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_validate_bounds(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_check_segments(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_check_sections(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_check_entry(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_symbol_table_sections(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_get_string_table_sections(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_get_symbol_tables(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_get_relocation_tables(ef); if (ret != BFELF_SUCCESS) goto failure; ret = private_get_hash_table(ef); if (ret != BFELF_SUCCESS) goto failure; return BFELF_SUCCESS; failure: for (i = 0; i < sizeof(struct bfelf_file_t); i++) ((char *)ef)[i] = 0; return ret; }
CAMLprim value unix_rewinddir(value d) { invalid_argument("rewinddir not implemented"); }