void ciMethodData::print_data_on(outputStream* st) { ResourceMark rm; ciProfileData* data; for (data = first_data(); is_valid(data); data = next_data(data)) { st->print("%d", dp_to_di(data->dp())); st->fill_to(6); data->print_data_on(st); } st->print_cr("--- Extra data:"); DataLayout* dp = data_layout_at(data_size()); DataLayout* end = data_layout_at(data_size() + extra_data_size()); for (; dp < end; dp = methodDataOopDesc::next_extra(dp)) { if (dp->tag() == DataLayout::no_tag) continue; if (dp->tag() == DataLayout::bit_data_tag) { data = new BitData(dp); } else { assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo"); data = new ciArgInfoData(dp); dp = end; // ArgInfoData is at the end of extra data section. } st->print("%d", dp_to_di(data->dp())); st->fill_to(6); data->print_data_on(st); } }
void mc146818_device::nvram_default() { // populate from a memory region if present if (m_region != NULL) { UINT32 bytes = m_region->bytes(); if (bytes > data_size()) bytes = data_size(); memcpy(&m_data[0], m_region->base(), bytes); } else { memset(&m_data[0], 0, data_size()); } if(m_binary) m_data[REG_B] |= REG_B_DM; if(m_hour) m_data[REG_B] |= REG_B_24_12; set_base_datetime(); update_timer(); update_irq(); }
// Translate a bci to its corresponding data, or NULL. ciProfileData* ciMethodData::bci_to_data(int bci) { ciProfileData* data = data_before(bci); for ( ; is_valid(data); data = next_data(data)) { if (data->bci() == bci) { set_hint_di(dp_to_di(data->dp())); return data; } else if (data->bci() > bci) { break; } } // bci_to_extra_data(bci) ... DataLayout* dp = data_layout_at(data_size()); DataLayout* end = data_layout_at(data_size() + extra_data_size()); for (; dp < end; dp = methodDataOopDesc::next_extra(dp)) { if (dp->tag() == DataLayout::no_tag) { _saw_free_extra_data = true; // observed an empty slot (common case) return NULL; } if (dp->tag() == DataLayout::arg_info_data_tag) { break; // ArgInfoData is at the end of extra data section. } if (dp->bci() == bci) { assert(dp->tag() == DataLayout::bit_data_tag, "sane"); return new ciBitData(dp); } } return NULL; }
/////////////////////////////////////////////////////////////////////////////// // // calculates the rate of change of e^2 with each parameter in 'p' at 'p' // returning the result in 'deriv'. // // assumes e is up to date with p // /////////////////////////////////////////////////////////////////////////////// void FSolver::df(VecDoub_I &p, VecDoub_O &deriv) { coord etot(3); // total error vector int i,j,n; // std::cout << "in df" << std::endl; for(n=0; n<data_size(); ++n) { e[n] = 0.0; for(i=0; i<3; ++i) { for(j=0; j<3; ++j) { e[n] += qp[n][i] * p[3*i+j] * q[n][j]; } } } for(i = 0; i<3; ++i) { for(j = 0; j<3; ++j) { deriv[3*i+j] = 0.0; for(n=0; n<data_size(); ++n) { deriv[3*i+j] += 2.0 * e[n] * qp[n][i] * q[n][j]; } } } // --- add scale forcing // --------------------- double t; t = 4.0*(p[2]*p[2] + p[5]*p[5] + p[8]*p[8] - 0.694722); deriv[2] += t*p[2]; deriv[5] += t*p[5]; deriv[8] += t*p[8]; // --- add determinant forcing // --------------------------- /****** t = 2.0*(p[0]*p[4]*p[8] + p[1]*p[5]*p[6] + p[2]*p[3]*p[7] - p[2]*p[4]*p[6] - p[1]*p[3]*p[8] - p[0]*p[5]*p[7]); deriv[0] += t*(p[4]*p[8] - p[5]*p[7]); deriv[1] += t*(p[5]*p[6] - p[3]*p[8]); deriv[2] += t*(p[3]*p[7] - p[4]*p[6]); deriv[3] += t*(p[2]*p[7] - p[1]*p[8]); deriv[4] += t*(p[0]*p[8] - p[2]*p[6]); deriv[5] += t*(p[1]*p[6] - p[0]*p[7]); deriv[6] += t*(p[1]*p[5] - p[2]*p[4]); deriv[7] += t*(p[2]*p[3] - p[0]*p[5]); deriv[8] += t*(p[0]*p[4] - p[1]*p[3]); *****/ /**** for(n=0; n<deriv.size(); ++n) { std::cout << deriv[n] << " "; } std::cout << std::endl; ***/ }
ciArgInfoData *ciMethodData::arg_info() const { // Should be last, have to skip all traps. DataLayout* dp = data_layout_at(data_size()); DataLayout* end = data_layout_at(data_size() + extra_data_size()); for (; dp < end; dp = methodDataOopDesc::next_extra(dp)) { if (dp->tag() == DataLayout::arg_info_data_tag) return new ciArgInfoData(dp); } return NULL; }
void*data_calloc(ambixtest_presentationformat_t fmt, size_t nmembers) { size_t nmemb=nmembers*data_size(fmt)/sizeof(float64_t)+1; size_t size = sizeof(float64_t); void*data=calloc(nmemb, size); //printf("%dx%d[%d] allocated %d of %d bytes to %p\n", (int)frames, channels, fmt, (int)nmemb, (int)size, data); return data; }
R_API struct r_anal_refline_t *r_anal_reflines_get(struct r_anal_t *anal, ut64 addr, ut8 *buf, ut64 len, int nlines, int linesout, int linescall) { RAnalRefline *list2, *list = R_NEW (RAnalRefline); RAnalOp op = {0}; ut8 *ptr = buf; ut8 *end = buf + len; ut64 opc = addr; int sz = 0, index = 0; INIT_LIST_HEAD (&(list->list)); end -= 8; // XXX Fix some segfaults when r_anal backends are buggy /* analyze code block */ while (ptr<end) { if (nlines != -1 && --nlines == 0) break; #if 0 if (config.interrupted) break; int dt = data_type(config.seek+bsz); if (dt != DATA_FUN && dt != DATA_CODE) { ut64 sz = data_size (config.seek+bsz); if (sz > 0) { ptr += sz; bsz += sz; continue; } } #endif addr += sz; // This can segflauta if opcode length and buffer check fails r_anal_op_fini (&op); sz = r_anal_op (anal, &op, addr, ptr, (int)(end-ptr)); if (sz > 0) { /* store data */ switch (op.type) { case R_ANAL_OP_TYPE_CALL: if (!linescall) break; case R_ANAL_OP_TYPE_CJMP: case R_ANAL_OP_TYPE_JMP: if (!linesout && (op.jump > opc+len || op.jump < opc)) goto __next; if (op.jump == 0LL) goto __next; list2 = R_NEW (RAnalRefline); list2->from = addr; list2->to = op.jump; list2->index = index++; list_add_tail (&(list2->list), &(list->list)); break; } } else sz = 1; __next: ptr += sz; } r_anal_op_fini (&op); return list; }
void Texture::assign(const Texture& t) { _width = t._width; _height = t._height; init(); memcpy(_data, t._data, data_size()); }
JNIEXPORT void JNICALL Java_edu_asu_sma_ContentHelper_create(JNIEnv* env, jobject thiz, jobjectArray jtypes, jstring jname, jbyteArray jdata, jlong jsize) { int types_count = env->GetArrayLength(jtypes); std::vector<sma::ContentType> types; for (std::size_t i = 0; i < types_count; ++i) { jstring j_stype = (jstring)env->GetObjectArrayElement(jtypes, i); char const* c_stype = env->GetStringUTFChars(j_stype, NULL); types.emplace_back(std::string(c_stype)); env->ReleaseStringUTFChars(j_stype, c_stype); } char const* c_name = env->GetStringUTFChars(jname, NULL); std::string name(c_name); env->ReleaseStringUTFChars(jname, c_name); std::size_t data_size(jsize); std::uint8_t* data = new std::uint8_t[data_size]; jbyte* c_data = env->GetByteArrayElements(jdata, NULL); std::memcpy(data, c_data, data_size); env->ReleaseByteArrayElements(jdata, c_data, JNI_ABORT); sma::content_helper->create_new(std::move(types), sma::ContentName(name), data, data_size); delete[] data; }
int FileMapInfo::FileMapHeader::compute_crc() { char* header = data(); // start computing from the field after _crc char* buf = (char*)&_crc + sizeof(int); size_t sz = data_size() - (buf - header); int crc = ClassLoader::crc32(0, buf, (jint)sz); return crc; }
const Sector &Track::get_sector (const Header &header) const { auto it = find(header); if (it == end() || it->data_size() < header.sector_size()) throw util::exception(CylHead(header.cyl, header.head), " sector ", header.sector, " not found"); return *it; }
void mc146818_device::nvram_read(emu_file &file) { file.read(m_data, data_size()); set_base_datetime(); update_timer(); update_irq(); }
int main(int argc, char *argv[]) { int choice = 1; choice = check_model(); switch(choice) { //test the data size on kernel and application. case 1: { data_size(argc, argv); break; } //test the fasync signal handle method. case 2: { fasync_handle(argc, argv); break; } //test the input and output method by poll. case 3: { io_poll(argc, argv); break; } //test the concole which recv the kernel message. case 4: { concole_ctl(argc, argv); break; } //test the page difference by compared dev map addr. case 5: { mem_cmp(argc, argv); break; } //test the input and ouput on all dev ports. case 6: { port_io(argc, argv); break; } //default do nothing default: { break; } } return 0; }
void MapBlock::copyFrom(VoxelManipulator &dst) { v3s16 data_size(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE); VoxelArea data_area(v3s16(0,0,0), data_size - v3s16(1,1,1)); // Copy from VoxelManipulator to data dst.copyTo(data, data_area, v3s16(0,0,0), getPosRelative(), data_size); }
void MeshMakeData::fillBlockData(const v3s16 &block_offset, MapNode *data) { v3s16 data_size(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE); VoxelArea data_area(v3s16(0,0,0), data_size - v3s16(1,1,1)); v3s16 bp = m_blockpos + block_offset; v3s16 blockpos_nodes = bp * MAP_BLOCKSIZE; m_vmanip.copyFrom(data, data_area, v3s16(0,0,0), blockpos_nodes, data_size); }
ciProfileData* data_before(int bci) { // avoid SEGV on this edge case if (data_size() == 0) return NULL; int hint = hint_di(); if (data_layout_at(hint)->bci() <= bci) return data_at(hint); return first_data(); }
void mc146818_device::device_start() { m_data= auto_alloc_array(machine(), UINT8, data_size()); m_last_refresh = machine().time(); m_clock_timer = timer_alloc(TIMER_CLOCK); m_periodic_timer = timer_alloc(TIMER_PERIODIC); m_write_irq.resolve_safe(); }
void MapBlock::copyTo(VoxelManipulator &dst) { auto lock = lock_shared_rec(); v3s16 data_size(MAP_BLOCKSIZE, MAP_BLOCKSIZE, MAP_BLOCKSIZE); VoxelArea data_area(v3s16(0,0,0), data_size - v3s16(1,1,1)); // Copy from data to VoxelManipulator dst.copyFrom(data, data_area, v3s16(0,0,0), getPosRelative(), data_size); }
int test_file(const std::string & test_data_filepath, const std::string & label_prefix) { int fails = 0; std::vector<pstrudel::TreeShape> trees; pstrudel::treeio::read_from_filepath(trees, test_data_filepath, "nexus"); unsigned long tree_idx = 0; for (auto & tree : trees) { std::string label = label_prefix + ":" + std::to_string(tree_idx + 1); pstrudel::LineageThroughTimeProfileCalculator ltt_calc(tree); auto profiles = ltt_calc.build_lineage_splitting_time_profile(); auto lst_profile = profiles.first; auto scaled_lst_profile = profiles.second; std::ostringstream o; TREE_WRITER.write(o, tree); o << "\n"; assert(lst_profile.data_size() == scaled_lst_profile.data_size()); auto rds = lst_profile.data_size(); for (unsigned long idx = 0; idx < rds; ++idx) { o << std::fixed << std::setprecision(22) << lst_profile.raw_data(idx); o << "\t" << std::fixed << std::setprecision(22) << scaled_lst_profile.raw_data(idx); o << "\n"; } colugo::Subprocess ps({"python", CHECK_SCRIPT, "-f", "newick", "-l", label}); try { auto result = ps.communicate(o.str()); if (ps.returncode() != 0) { std::cerr << "(test '" << label << "' returned error: " << ps.returncode() << ")\n"; // TREE_WRITER.write(std::cerr, tree); // std::cerr << std::endl; std::cerr << result.first; std::cerr << result.second; fails += 1; // } else { // std::cerr << result.second; } } catch (const colugo::SubprocessTimeOutException & e) { std::cerr << "(test '" << label << "' timed out)\n"; exit(1); } ++tree_idx; } return fails; }
int init_data(double * x, int p, int P, int N) { int n = data_size(p, P, N); srand(p+1); for (int i = 0; i<n; i++) { x[i] = (double)rand()/((long)RAND_MAX+1); } return n; }
void mc146818_device::nvram_default() { // populate from a memory region if present if (m_region != NULL) { UINT32 bytes = m_region->bytes(); if (bytes > data_size()) bytes = data_size(); memcpy(m_data, m_region->base(), bytes); } else { memset(m_data, 0, data_size()); } set_base_datetime(); update_timer(); update_irq(); }
void dumpstat (const char * tfn) { FILE *f; object_t *ob; const char *fn; #ifdef F_SET_HIDE int display_hidden; #endif fn = check_valid_path(tfn, current_object, "dumpallobj", 1); if (!fn) { error("Invalid path '/%s' for writing.\n", tfn); return; } f = fopen(fn, "w"); if (!f) { error("Unable to open '/%s' for writing.\n", fn); return; } #ifdef F_SET_HIDE display_hidden = -1; #endif for (ob = obj_list; ob; ob = ob->next_all) { long tmp; #ifdef F_SET_HIDE if (ob->flags & O_HIDDEN) { if (display_hidden == -1) display_hidden = valid_hide(current_object); if (!display_hidden) continue; } #endif /* FIXME */ if (ob->prog && (ob->prog->ref == 1 || !(ob->flags & O_CLONE))) tmp = ob->prog->total_size; else tmp = 0; fprintf(f, "%-20s %ld ref %2d %s %s (%d)\n", ob->obname, tmp + data_size(ob) + sizeof(object_t), ob->ref, ob->flags & O_HEART_BEAT ? "HB" : " ", #ifndef NO_ENVIRONMENT ob->super ? ob->super->obname : "--", #else "--", #endif /* ob->cpu */ 0); } fclose(f); }
int huffman_benchmark(char *code) { data *d = huffman_encode(code); int result = data_size(d); /*char *dec = huffman_decode(d); if (strncmp(dec, code, strlen(code)) != 0) { printf("[HUFFMAN ERROR]\n"); printf("Original: %s\n", code); printf("Decoded : %s\n", dec); } free(dec);*/ data_free(d); return result; }
int lzw_benchmark(char *code) { char *alphabet = "!\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHI"; data *d = lzw_encode(alphabet, code); int result = data_size(d); /*char *dec = lzw_decode(alphabet, d); if (strncmp(dec, code, strlen(code)) != 0) { printf("[LZW ERROR]\n"); printf("Original: %s\n", code); printf("Decoded : %s\n", dec); } free(dec);*/ data_free(d); return result; }
/* step */ void zmq_sender_step(ubx_block_t *b) { struct zmq_sender_info *inf = (struct zmq_sender_info*) b->private_data; std::cout << "zmq_sender: Processing a port update" << std::endl; /* Read data from port */ ubx_port_t* port = inf->ports.zmq_out; assert(port != 0); ubx_data_t msg; checktype(port->block->ni, port->in_type, "unsigned char", port->name, 1); msg.type = port->in_type; msg.len = inf->buffer_length; msg.data = inf->buffer; std::cout << "zmq_sender: Reading from port" << std::endl; int read_bytes = __port_read(port, &msg); if (read_bytes <= 0) { std::cout << "zmq_sender: No data recieved from port" << std::endl; return; } /* Test message */ // unsigned long length = 4; // unsigned char buffer[length]; // buffer[0] = 0xDE; //DEAFBEAF dummy message // buffer[1] = 0xAF; // buffer[2] = 0xBE; // buffer[3] = 0xAF; // msg.len = length; // msg.data = (void*)&buffer; // int read_bytes = length; std::cout << "zmq_sender: msg.len = " << data_size(&msg) << " read bytes = " << read_bytes << std::endl; /* Setup ZMQ message*/ //hexdump((unsigned char *)msg.data, read_bytes, 16); zmq::message_t message(msg.len); memcpy(message.data(), (char *)msg.data, read_bytes); /* Send the message */ inf->publisher->send(message); }
void sort_list_descend(List_head head) { List_node *p_node = NULL; List_node *q_node = NULL; if(head == NULL || head->next == NULL){ return ; } for(p_node = head; p_node->next != NULL; p_node = p_node->next){ for(q_node = p_node->next; q_node != NULL; q_node = q_node->next){ if(p_node->data > q_node->data){ swap(p_node, q_node, data_size(*p_node)); } } } }
void BurkardtFileIOHandler::Initialize( const Teuchos::RCP<Teuchos::ParameterList>& params ) { #ifdef EPETRA_MPI Epetra_MpiComm comm( MPI_COMM_WORLD ); #else Epetra_SerialComm comm; #endif // Get the "File I/O" sublist. Teuchos::ParameterList& fileio_params = params->sublist( "File IO" ); if( fileio_params.isParameter("Burkardt Data Format File") ) { std::string format_file = Teuchos::getParameter<std::string>( fileio_params, "Burkardt Data Format File" ); // // The first processor get the number of nodes from the data format file and then broadcasts it. // if ( comm.MyPID() == 0 ) num_nodes = data_size( format_file ); comm.Broadcast( &num_nodes, 1, 0 ); // if (!num_nodes) { TO DO: THROW EXCEPTION! } isInit = true; } else { // Can't find the data size or data format file isInit = false; TEUCHOS_TEST_FOR_EXCEPTION(true, std::runtime_error, "Cannot find the data size or data format file 'Burkardt Data Format File'!"); } // Get the input path. in_path = ""; if ( fileio_params.isParameter( "Data Input Path" ) ) { in_path = Teuchos::getParameter<std::string>( fileio_params, "Data Input Path" ); } // Get the output path. out_path = ""; if ( fileio_params.isParameter( "Data Output Path" ) ) { out_path = Teuchos::getParameter<std::string>( fileio_params, "Data Output Path" ); } // This file i/o handler is not initialized. isInit = true; }
void print_lba(){ puts_attrib("================DDATA================",color_entry(COLOR_MAGENTA, COLOR_BLACK)); eol(); puts_attrib("FAT LBA:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(fat_lba(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("Root LBA:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(root_lba(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("Data LBA:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(data_lba(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("FAT Size:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(fat_size(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("Root Size:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(root_size(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("Data Size:", color_entry(COLOR_BROWN, COLOR_BLACK)); print_int(data_size(), 10, color_entry(COLOR_RED, COLOR_BLACK)); eol(); puts_attrib("================DDATA================",color_entry(COLOR_GREEN, COLOR_BLACK));eol(); }
void dumpstat P1(char *, tfn) { FILE *f; object_t *ob; char *fn; int display_hidden; fn = check_valid_path(tfn, current_object, "dumpallobj", 1); if (!fn) { error("Invalid path '%s' for writing.\n", tfn); return; } f = fopen(fn, "w"); if (!f) { error("Unable to open '/%s' for writing.\n", fn); return; } display_hidden = -1; for (ob = obj_list; ob; ob = ob->next_all) { int tmp; if (ob->flags & O_HIDDEN) { if (display_hidden == -1) display_hidden = valid_hide(current_object); if (!display_hidden) continue; } if (ob->prog && (ob->prog->ref == 1 || !(ob->flags & O_CLONE))) tmp = ob->prog->total_size; else tmp = 0; fprintf(f, "%-20s %i ref %2d %s %s (%d) %s\n", ob->name, tmp + data_size(ob) + sizeof(object_t), ob->ref, ob->flags & O_HEART_BEAT ? "HB" : " ", #ifndef NO_ENVIRONMENT ob->super ? ob->super->name : "--", #else "--", #endif /* ob->cpu */ 0, (ob->swap_num >= 0) ? ((ob->flags & O_SWAPPED) ? "SWAPPED(out)" : "SWAPPED(in)") : ""); } fclose(f); }
bool Archive::InitFiles() { // Create FileInfo structures from the data entries within the hogg if (fseek(file_, hogg::HOGG_DATAENTRIES_OFFSET, SEEK_SET) != 0) { perror("Failed to seek to the data entries section"); return false; } char* dataEntryData = new char[sizeof(hogg::DataEntry) * num_files_]; fread(dataEntryData, sizeof(hogg::DataEntry), num_files_, file_); hogg::DataEntry* dataEntry = (hogg::DataEntry*)dataEntryData; int i; for (i = 0; i < num_files_; i++) { auto fi = new FileInfo(this); fi->data_size(dataEntry->size_on_disk); fi->file_offset(dataEntry->file_offset); fi->last_updated(dataEntry->timestamp); file_infos_[i] = fi; dataEntry++; } delete [] dataEntryData; // Set the decompressed size of FileInfos which are compressed char* compressionData = new char[sizeof(hogg::CompressionInfo) * num_files_]; fread(compressionData, sizeof(hogg::CompressionInfo), num_files_, file_); hogg::CompressionInfo* compressionInfo = (hogg::CompressionInfo*)compressionData; for (i = 0; i < num_files_; i++) { auto fi = file_infos_[i]; fi->file_path_string_id(compressionInfo->file_path_id); fi->decompressed_size(compressionInfo->uncompressed_size); compressionInfo++; } delete [] compressionData; return true; }