t_page *page_push(t_page *first, size_t size) { t_page *tmp; char type; type = ft_get_type(size); if (!first) { first = (void *)mmap(0, get_max_size(type, size) + 40, FLAGS); if (first == MAP_FAILED) print_error("MAPPING FAILED"); first = set_page(first, type); } else { tmp = first; while (tmp->next) tmp = tmp->next; tmp->next = (void *)mmap(0, get_max_size(type, size) + 40, FLAGS); if (tmp->next == MAP_FAILED) print_error("MAPPING FAILED"); tmp->next = set_page(tmp->next, type); tmp = tmp->next; return (tmp); } return (first); }
void CCONTAINER_get_max_size(void *_object, int xc, int yc, int wc, int hc, int *w, int *h) { int add; CCONTAINER_ARRANGEMENT *arr = THIS_ARRANGEMENT; bool locked; locked = arr->locked; arr->locked = false; max_w = 0; max_h = 0; _gms_x = xc; _gms_y = yc; _gms_w = wc; _gms_h = hc; get_max_size(THIS); if (arr->margin) add = arr->padding ? arr->padding : MAIN_scale; else if (!arr->spacing) add = arr->padding; else add = 0; *w = max_w + add; *h = max_h + add; arr->locked = locked; }
/** * \brief Returns the intermediate surface used for transitions and other * effects for this sprite. * * Creates this intermediate surface if it does not exist yet. * * \return The intermediate surface of this sprite. */ Surface& Sprite::get_intermediate_surface() const { if (intermediate_surface == NULL) { intermediate_surface = new Surface(get_max_size()); intermediate_surface->set_transparency_color(Color::get_black()); } return *intermediate_surface; }
extern void readbitmap(char* device, image_head image_hdr, unsigned long* bitmap, int pui){ unsigned long zones = get_nzones(); unsigned long imaps = get_nimaps(); unsigned long zmaps = get_nzmaps(); char * inode_map; char * zone_map; ssize_t rc; unsigned long test_block = 0, test_zone = 0; fs_open(device); unsigned long block_size = get_block_size(); if (fs_version == 3){ if (lseek(dev, block_size*2, SEEK_SET) != 8192) log_mesg(0, 1, 1, fs_opt.debug, "%s: seek failed", __FILE__); } inode_map = malloc(imaps * block_size); if (!inode_map) log_mesg(0, 1, 1, fs_opt.debug, "%s: Unable to allocate buffer for inode map", __FILE__); zone_map = malloc(zmaps * block_size); if (!inode_map) log_mesg(0, 1, 1, fs_opt.debug, "%s: Unable to allocate buffer for zone map", __FILE__); memset(inode_map,0,sizeof(inode_map)); memset(zone_map,0,sizeof(zone_map)); memset(bitmap,0,sizeof(unsigned long)*LONGS(image_hdr.totalblock)); rc = read(dev, inode_map, imaps * block_size); if (rc < 0 || imaps * block_size != (size_t) rc) log_mesg(0, 1, 1, fs_opt.debug, "%s: Unable to read inode map", __FILE__); rc = read(dev, zone_map, zmaps * block_size); if (rc < 0 || zmaps * block_size != (size_t) rc) log_mesg(0, 1, 1, fs_opt.debug, "%s: Unable to read zone map", __FILE__); log_mesg(0, 0, 0, fs_opt.debug, "%s: %ld blocks\n", __FILE__, zones); log_mesg(0, 0, 0, fs_opt.debug, "%s: log2 block/zone: %lu\n", __FILE__, get_zone_size()); log_mesg(0, 0, 0, fs_opt.debug, "%s: Zonesize=%d\n", __FILE__,block_size<<get_zone_size()); log_mesg(0, 0, 0, fs_opt.debug, "%s: Maxsize=%ld\n", __FILE__, get_max_size()); for (test_block = 0; test_block < zones; test_block++){ test_zone = test_block - get_first_zone()+1; if ((test_zone < 0) || (test_zone > zones+get_first_zone())) test_zone = 0; if(isset(zone_map,test_zone)){ log_mesg(3, 0, 0, fs_opt.debug, "%s: test_block %lu in use\n", __FILE__, test_block); pc_set_bit(test_block, bitmap); }else{ log_mesg(3, 0, 0, fs_opt.debug, "%s: test_block %lu not use\n", __FILE__, test_block); } } fs_close(); }
bool apple_glx_pbuffer_query(GLXPbuffer p, int attr, unsigned int *value) { bool result = false; struct apple_glx_drawable *d; struct apple_glx_pbuffer *pbuf; d = apple_glx_drawable_find_by_type(p, APPLE_GLX_DRAWABLE_PBUFFER, APPLE_GLX_DRAWABLE_LOCK); if (d) { pbuf = &d->types.pbuffer; switch (attr) { case GLX_WIDTH: *value = pbuf->width; result = true; break; case GLX_HEIGHT: *value = pbuf->height; result = true; break; case GLX_PRESERVED_CONTENTS: *value = true; result = true; break; case GLX_LARGEST_PBUFFER:{ int width, height; if (get_max_size(&width, &height)) { fprintf(stderr, "internal error: " "unable to find the largest pbuffer!\n"); } else { *value = width; result = true; } } break; case GLX_FBCONFIG_ID: *value = pbuf->fbconfigID; result = true; break; } d->unlock(d); } return result; }
RDMABuffer() : deserializer(NULL) , dest_( -1 ) , next_( 0 ) , source_( -1 ) , ack_( 0 ) , data_() , context() { static_assert( sizeof(*this) == BUFFER_SIZE, "RDMABuffer is not the size I expected for some reason." ); context.buf = (void*) this; context.size = get_max_size(); }
int32_t FileLogDevice::exec_size_split_policy(size_t len) { off_t size_will = (off_t)(_file_size + len); if (size_will > get_max_size()) { close(); char buffer[BUFSIZ]; snprintf(buffer, BUFSIZ, "%s%s", _file_path, create_filename_suffix().c_str()); rename(_file_path, buffer); if (open() != 0) { return -1; } } return 0; }
/** * reduce_across_heaps * * Do a reduction across an array of S_POINT heaps. For each S_POINT in the * array, all the seeds from the heaps on each node are combinded (using a * union function). A heap containing the best seeds from every node is then * propogated to all nodes. * */ void reduce_across_heaps( S_POINT *s_points, // an array of S_POINTS int n_nsites0 // the number of S_POINTS in the s_points array ) { static int init; static MPI_Datatype seed_packet_type; static MPI_Op union_seed_packets_op; int i_packet; // Initialise MPI stuff if (init==0){ init = 1; SEED_PACKET seed_packet; int block_lengths[4]; MPI_Aint displacements[4]; MPI_Aint address[4]; MPI_Datatype typelist[4]; // Build the derived datatype // set the types typelist[0]=MPI_DOUBLE; typelist[1]=MPI_INT; typelist[2]=MPI_INT; typelist[3]=MPI_CHAR; // set number of elements of each type block_lengths[0] = block_lengths[1] = block_lengths[2] = 1; block_lengths[3] = MAXSITE; // the maximum length of a seed // calculate the displacements MPI_Address(&seed_packet.score, &address[0]); MPI_Address(&seed_packet.width, &address[1]); MPI_Address(&seed_packet.num_seed_packets, &address[2]); MPI_Address(&seed_packet.seed, &address[3]); displacements[0]=0; displacements[1]=address[1]-address[0]; displacements[2]=address[2]-address[0]; displacements[3]=address[3]-address[0]; // create the derived type MPI_Type_struct(4, block_lengths, displacements, typelist, &seed_packet_type); // commit the derived type MPI_Type_commit(&seed_packet_type); // set the MPI reduction operation MPI_Op_create(union_seed_packets, FALSE, &union_seed_packets_op); } // initialise MPI // do a reduction for each s_point in the s_point list int sp_idx; for (sp_idx = 0; sp_idx < n_nsites0; sp_idx++){ // package the heap for the spoint at sp_idx in the s_points list HEAP *seed_heap = s_points[sp_idx].seed_heap; // get the maximum heap size and the number of seeds in the heap int max_heap_size = get_max_size(seed_heap); int num_seeds = get_num_nodes(seed_heap); // set the number of seed packets to the maximum heap size SEED_PACKET packets[max_heap_size], best_packets[max_heap_size]; // set num_seed_packets to the number of filled nodes in the heap (in // case the heap is empty) packets[0].num_seed_packets = num_seeds; // package each seed in the heap into a seed packet for (i_packet = 0; i_packet < num_seeds; i_packet++){ // set the number of seed_packets that will be filled packets[i_packet].num_seed_packets = num_seeds; // get the seed at the root SEED *curr_seed = pop_heap_root(seed_heap); // set the seed packet score packets[i_packet].score = get_seed_score(curr_seed); // set the width of the string packets[i_packet].width = get_width(curr_seed); // set the seed char *seed_str = get_str_seed(curr_seed); strcpy(packets[i_packet].seed, seed_str); } /* // print the packets before the reduction if (mpMyID() == NODE_NO){ fprintf(stdout, "BEFORE\n"); for (i_packet = 0; i_packet < max_heap_size; i_packet++) fprintf(stdout, "node %d packet %d score= %g width= %i seed= %s\n", mpMyID(), i_packet, packets[i_packet].score, packets[i_packet].width, packets[i_packet].seed); fflush(stdout); } */ // Do the reduction MPI_Allreduce((void *)&packets, (void *)&best_packets, max_heap_size, seed_packet_type, union_seed_packets_op, MPI_COMM_WORLD); /* // print the packets after the reduction if (mpMyID() == NODE_NO){ fprintf(stdout, "AFTER\n"); for (i_packet = 0; i_packet < max_heap_size; i_packet++) fprintf(stdout, "node %d packet %d score= %g width= %i seed= %s\n", mpMyID(), i_packet, best_packets[i_packet].score, best_packets[i_packet].width, best_packets[i_packet].seed); fflush(stdout); } */ // Unpack the best seed packets into the heap // Get the number of filled packets int num_seed_packets = best_packets[0].num_seed_packets; // Add the best seeds to the heap for (i_packet = 0; i_packet < num_seed_packets; i_packet++){ double score = best_packets[i_packet].score; char *seed_str = best_packets[i_packet].seed; SEED *best_seed = new_seed(seed_str, score); //SEED *bumped_seed = (SEED *)(add_node_heap(seed_heap, best_seed)); (void *)(add_node_heap(seed_heap, best_seed)); } } // end n_nsites0 } // reduce_across_heaps
static void setup_tables(void) { unsigned long inodes, zmaps, imaps, zones, i; super_block_buffer = calloc(1, MINIX_BLOCK_SIZE); if (!super_block_buffer) err(MKFS_EX_ERROR, _("%s: unable to allocate buffer for superblock"), device_name); memset(boot_block_buffer,0,512); super_set_magic(); if (fs_version == 3) { Super3.s_log_zone_size = 0; Super3.s_blocksize = MINIX_BLOCK_SIZE; } else { Super.s_log_zone_size = 0; } super_init_maxsize(); super_set_nzones(); zones = get_nzones(); /* some magic nrs: 1 inode / 3 blocks */ if ( req_nr_inodes == 0 ) inodes = BLOCKS/3; else inodes = req_nr_inodes; /* Round up inode count to fill block size */ if (fs_version == 2 || fs_version == 3) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (fs_version == 3) Super3.s_ninodes = inodes; else { Super.s_ninodes = inodes; if (inodes > MINIX_MAX_INODES) inodes = MINIX_MAX_INODES; } super_set_map_blocks(inodes); imaps = get_nimaps(); zmaps = get_nzmaps(); inode_map = malloc(imaps * MINIX_BLOCK_SIZE); zone_map = malloc(zmaps * MINIX_BLOCK_SIZE); if (!inode_map || !zone_map) err(MKFS_EX_ERROR, _("%s: unable to allocate buffers for maps"), device_name); memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE); memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE); for (i = get_first_zone() ; i<zones ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=inodes; i++) unmark_inode(i); inode_buffer = malloc(get_inode_buffer_size()); if (!inode_buffer) err(MKFS_EX_ERROR, _("%s: unable to allocate buffer for inodes"), device_name); memset(inode_buffer,0, get_inode_buffer_size()); printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes); printf(P_("%lu block\n", "%lu blocks\n", zones), zones); printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data()); printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n\n"),get_max_size()); }
static void setup_tables(const struct fs_control *ctl) { unsigned long inodes, zmaps, imaps, zones, i; super_block_buffer = xcalloc(1, MINIX_BLOCK_SIZE); memset(boot_block_buffer,0,512); super_set_magic(ctl); if (fs_version == 3) { Super3.s_log_zone_size = 0; Super3.s_blocksize = MINIX_BLOCK_SIZE; } else { Super.s_log_zone_size = 0; } super_init_maxsize(); super_set_nzones(ctl); zones = get_nzones(); /* some magic nrs: 1 inode / 3 blocks for smaller filesystems, * for one inode / 16 blocks for large ones. mkfs will eventually * crab about too far when getting close to the maximum size. */ if (ctl->fs_inodes == 0) if (2048 * 1024 < ctl->fs_blocks) /* 2GB */ inodes = ctl->fs_blocks / 16; else if (512 * 1024 < ctl->fs_blocks) /* 0.5GB */ inodes = ctl->fs_blocks / 8; else inodes = ctl->fs_blocks / 3; else inodes = ctl->fs_inodes; /* Round up inode count to fill block size */ if (fs_version == 2 || fs_version == 3) inodes = ((inodes + MINIX2_INODES_PER_BLOCK - 1) & ~(MINIX2_INODES_PER_BLOCK - 1)); else inodes = ((inodes + MINIX_INODES_PER_BLOCK - 1) & ~(MINIX_INODES_PER_BLOCK - 1)); if (fs_version == 3) Super3.s_ninodes = inodes; else { Super.s_ninodes = inodes; if (inodes > MINIX_MAX_INODES) inodes = MINIX_MAX_INODES; } super_set_map_blocks(ctl, inodes); if (MINIX_MAX_INODES < first_zone_data()) errx(MKFS_EX_ERROR, _("First data block at %jd, which is too far (max %d).\n" "Try specifying fewer inodes by passing --inodes <num>"), first_zone_data(), MINIX_MAX_INODES); imaps = get_nimaps(); zmaps = get_nzmaps(); inode_map = xmalloc(imaps * MINIX_BLOCK_SIZE); zone_map = xmalloc(zmaps * MINIX_BLOCK_SIZE); memset(inode_map,0xff,imaps * MINIX_BLOCK_SIZE); memset(zone_map,0xff,zmaps * MINIX_BLOCK_SIZE); for (i = get_first_zone() ; i<zones ; i++) unmark_zone(i); for (i = MINIX_ROOT_INO ; i<=inodes; i++) unmark_inode(i); inode_buffer = xmalloc(get_inode_buffer_size()); memset(inode_buffer,0, get_inode_buffer_size()); printf(P_("%lu inode\n", "%lu inodes\n", inodes), inodes); printf(P_("%lu block\n", "%lu blocks\n", zones), zones); printf(_("Firstdatazone=%jd (%jd)\n"), get_first_zone(), first_zone_data()); printf(_("Zonesize=%zu\n"), (size_t) MINIX_BLOCK_SIZE << get_zone_size()); printf(_("Maxsize=%zu\n\n"),get_max_size()); }
/* this is the codec entry point */ enum codec_status codec_main(void) { ov_callbacks callbacks; OggVorbis_File vf; ogg_int32_t **pcm; int error; long n; int current_section; int previous_section; int eof; ogg_int64_t vf_offsets[2]; ogg_int64_t vf_dataoffsets; ogg_uint32_t vf_serialnos; ogg_int64_t vf_pcmlengths[2]; ci->configure(DSP_SET_SAMPLE_DEPTH, 24); if (codec_init()) { error = CODEC_ERROR; goto exit; } ogg_malloc_init(); #if defined(CPU_ARM) || defined(CPU_COLDFIRE) || defined(CPU_MIPS) if (setjmp(rb_jump_buf) != 0) { /* malloc failed; skip to next track */ error = CODEC_ERROR; goto done; } #endif next_track: while (!*ci->taginfo_ready && !ci->stop_codec) ci->sleep(1); /* Create a decoder instance */ callbacks.read_func = read_handler; callbacks.seek_func = initial_seek_handler; callbacks.tell_func = tell_handler; callbacks.close_func = close_handler; /* Open a non-seekable stream */ error = ov_open_callbacks(ci, &vf, NULL, 0, callbacks); /* If the non-seekable open was successful, we need to supply the missing * data to make it seekable. This is a hack, but it's reasonable since we * don't want to run the whole file through the buffer before we start * playing. Using Tremor's seekable open routine would cause us to do * this, so we pretend not to be seekable at first. Then we fill in the * missing fields of vf with 1) information in ci->id3, and 2) info * obtained by Tremor in the above ov_open call. * * Note that this assumes there is only ONE logical Vorbis bitstream in our * physical Ogg bitstream. This is verified in metadata.c, well before we * get here. */ if (!error) { ogg_free(vf.offsets); ogg_free(vf.dataoffsets); ogg_free(vf.serialnos); vf.offsets = vf_offsets; vf.dataoffsets = &vf_dataoffsets; vf.serialnos = &vf_serialnos; vf.pcmlengths = vf_pcmlengths; vf.offsets[0] = 0; vf.offsets[1] = ci->id3->filesize; vf.dataoffsets[0] = vf.offset; vf.pcmlengths[0] = 0; vf.pcmlengths[1] = ci->id3->samples; vf.serialnos[0] = vf.current_serialno; vf.callbacks.seek_func = seek_handler; vf.seekable = 1; vf.end = ci->id3->filesize; vf.ready_state = OPENED; vf.links = 1; } else { DEBUGF("Vorbis: ov_open failed: %d", error); error = CODEC_ERROR; goto done; } if (ci->id3->offset) { ci->advance_buffer(ci->id3->offset); ov_raw_seek(&vf, ci->id3->offset); ci->set_elapsed(ov_time_tell(&vf)); ci->set_offset(ov_raw_tell(&vf)); } previous_section = -1; eof = 0; while (!eof) { ci->yield(); if (ci->stop_codec || ci->new_track) break; if (ci->seek_time) { if (ov_time_seek(&vf, ci->seek_time - 1)) { //ci->logf("ov_time_seek failed"); } ci->seek_complete(); } /* Read host-endian signed 24-bit PCM samples */ n = ov_read_fixed(&vf, &pcm, 1024, ¤t_section); /* Change DSP and buffer settings for this bitstream */ if (current_section != previous_section) { if (!vorbis_set_codec_parameters(&vf)) { error = CODEC_ERROR; goto done; } else { previous_section = current_section; } } if (n == 0) { eof = 1; } else if (n < 0) { DEBUGF("Vorbis: Error decoding frame\n"); } else { ci->pcmbuf_insert(pcm[0], pcm[1], n); ci->set_offset(ov_raw_tell(&vf)); ci->set_elapsed(ov_time_tell(&vf)); } } error = CODEC_OK; done: #if 0 /* defined(SIMULATOR) */ { size_t bufsize; void* buf = ci->codec_get_buffer(&bufsize); DEBUGF("Vorbis: Memory max: %u\n", get_max_size(buf)); } #endif if (ci->request_next_track()) { /* Clean things up for the next track */ vf.dataoffsets = NULL; vf.offsets = NULL; vf.serialnos = NULL; vf.pcmlengths = NULL; ov_clear(&vf); goto next_track; } exit: ogg_malloc_destroy(); return error; }
unsigned int get_mips_count (unsigned int width, unsigned int height, unsigned int depth) { return get_mips_count (get_max_size (width, get_max_size (height, depth))); }
unsigned int get_mips_count (unsigned int width, unsigned int height) { return get_mips_count (get_max_size (width, height)); }