Esempio n. 1
0
void set_emptyset(set_type set)
/* Set set to be the emptyset  */
{
	long i,forlim;
	
	forlim=set_blocks(set[0])-1;
	for (i=1; i<=forlim; i++)
		set[i]=0U;
}
Esempio n. 2
0
void set_copy(set_type setcopy,set_type set)
/* Copy the set set[] to setcopy[] with setcopy[] length */
{
	long i,forlim;

	forlim=set_blocks(setcopy[0])-1;
	for (i=1; i<=forlim; i++)
		setcopy[i]=set[i];
}
Esempio n. 3
0
void set_diff(set_type set,set_type set1,set_type set2)
/* Set difference se1/set2, assuming set1 and set2 have the same length as set */
{
	long  i,forlim;

	forlim=set_blocks(set[0])-1;	
	for (i=1;i<=forlim;i++)
		set[i]=set1[i] & (~set2[i]);
}
Esempio n. 4
0
void set_uni(set_type set,set_type set1,set_type set2)
/* Set union,assuming set1 and set2 have the same length as set */
{
	long  i,forlim;

	forlim=set_blocks(set[0])-1;	
	for (i=1;i<=forlim;i++)
		set[i]=set1[i] | set2[i];
}
Esempio n. 5
0
void set_int(set_type set,set_type set1,set_type set2)
/* Set intersection, assuming set1 and set2 have the same length as set */
{
	long  i,forlim;
	
	forlim=set_blocks(set[0])-1;
	for (i=1;i<=forlim;i++)
		set[i]=(set1[i] & set2[i]);
}
Esempio n. 6
0
static void *__smalloc_pool(struct pool *pool, size_t size)
{
	size_t nr_blocks;
	unsigned int i;
	unsigned int offset;
	unsigned int last_idx;
	void *ret = NULL;

	fio_mutex_down(pool->lock);

	nr_blocks = size_to_blocks(size);
	if (nr_blocks > pool->free_blocks)
		goto fail;

	i = pool->next_non_full;
	last_idx = 0;
	offset = -1U;
	while (i < pool->nr_blocks) {
		unsigned int idx;

		if (pool->bitmap[i] == -1U) {
			i++;
			pool->next_non_full = i;
			last_idx = 0;
			continue;
		}

		idx = find_next_zero(pool->bitmap[i], last_idx);
		if (!blocks_free(pool, i, idx, nr_blocks)) {
			idx += nr_blocks;
			if (idx < SMALLOC_BPI)
				last_idx = idx;
			else {
				last_idx = 0;
				while (idx >= SMALLOC_BPI) {
					i++;
					idx -= SMALLOC_BPI;
				}
			}
			continue;
		}
		set_blocks(pool, i, idx, nr_blocks);
		offset = i * SMALLOC_BPL + idx * SMALLOC_BPB;
		break;
	}

	if (i < pool->nr_blocks) {
		pool->free_blocks -= nr_blocks;
		ret = pool->map + offset;
	}
fail:
	fio_mutex_up(pool->lock);
	return ret;
}
Esempio n. 7
0
CursorSuperObject* GameTemplate::create_from_template() {
    printf("Publishing template!\n");
    if (!block_counter && entities.size() <= 1) {
        printf("no blocks/entities to publish...\n");
        return 0;
    }
    this->print_debug();
    Player* player = get_player();
    // package our blocks into a cursorsuperobject
    CursorItemInfo* info = new CursorItemInfo((uint32_t)player->getID(),
                                              (uint32_t)player->assignID(),
                                              CursorType::CURSOR_SUPEROBJECT);
    CursorSuperObject* object = new CursorSuperObject(info);// all templates are made on the bar
    printf("publishing template %d\n", object->vid);
    // TODO giraffes (center chunk and set position to box.lower + box.upper)
    if (makes_vehicle) {
        // set angle depending on where we've been pointing, and set pos differently
        Rotation vehicle_pointing = get_vehicle_orientation();
        
        BlockOrientation vehiclebox_orientation = get_orientation_from_rotation(vehicle_pointing);
        fvec3 rwc_center_pos = calculate_center_position(vehiclebox_orientation) + bounds.lower;
        
        // find bounds rotated into my rotation, from the world, rotating around rwc center pos
        bounding_box oac_bounding_box;
        oac_bounding_box.lower = vehicle_pointing.transform_point_into_my_rotation(bounds.lower - rwc_center_pos);
        oac_bounding_box.upper = vehicle_pointing.transform_point_into_my_rotation(bounds.upper - rwc_center_pos);
        oac_bounding_box.refit_for_rotation();
        //object->center_pos = -oac_bounding_box.lower;
        //object->pos = rwc_center_pos + oac_bounding_box.lower;
        //object->angle = vehicle_pointing;
        //rwc_center_pos + oac_bounding_box.lower
        object->set_pos_and_angle(rwc_center_pos + oac_bounding_box.lower, vehicle_pointing);
    }
    else {
        //object->pos = bounds.lower;
        //object->center_pos = calculate_center_position(BlockOrientation::FRONT);
        object->set_pos(bounds.lower);
    }
    
    if (set_blocks(player, object)) {
        // save the object to disk
        // this doesn't actually delete the object from memory
        object->save_selfs();
        // tell object to publish to the world, the position/orientation should already be good
        object->set_blocks(player, parent);
        object->print_debug();
        
        player->inventory->add_custom(info);
        return object;
    }
    delete object;
    return 0;
}
Esempio n. 8
0
int set_subset(set_type set1,set_type set2)
/* Set containment check, set1 <= set2 */
{
	int  yes=1;
	long i,forlim;
	
	forlim=set_blocks(set2[0])-1;
	for (i=1;i<=forlim && yes;i++)
		if ((set1[i] | set2[i])!=set2[i])
			yes=0;
	return yes;
}
Esempio n. 9
0
void set_initialize(set_type *setp, long length)
/* Make a set with a given bit lengths  */
{
	long i,forlim1,len;
	
    if (length<=0) len=1;else len=length; 
     /* if negative length is requested, it generates the shortest length */

	forlim1=set_blocks(len);
        /* clang static analyzer complained, so changed by CjG */
	*setp=(unsigned long *) calloc(forlim1, sizeof(unsigned long));
	(*setp)[0]=(unsigned long) len;  /* size of the ground set */
	for (i=1; i<forlim1; i++)
		(*setp)[i]=0U;
}
Esempio n. 10
0
void set_compl(set_type set,set_type set1)
/* set[] will be set to the complement of set1[] */
{
	long  i,j,l,forlim;
	unsigned long change;
	unsigned long one=1U;	 

	forlim=set_blocks(set[0])-1;	
	for (i=1;i<=forlim;i++)
		set[i]= ~set1[i];

/* the following is necessary to remove 1's in the unused bits.
   Bremner's trick counts these bits as well.  (000601KF)
*/
	l=(set[0]-1)%SETBITS; /* the position of the last elem in the last block */
    	for (j=l+1; j<=SETBITS-1; j++){
		change=one << j;
		set[forlim]=(set[forlim] | change) ^ change;
    	}
}
Esempio n. 11
0
void set_fbinwrite(FILE *f,set_type set)
{
	int i,j;
	long forlim;
	long e1,e2;
	
	printf("max element = %ld,\n",set[0]);
	forlim=set_blocks(set[0])-1;
	for (i=forlim;i>=1;i--)
	{
		e1=e2=set[i];
		for (j=SETBITS-1;j>=0;j--)
		{
			e1=(e1>>j);
			fprintf(f,"%1ld",e1);
			e1=e2-(e1<<j);
			e2=e1;
		}
		fprintf(f," ");
	}
	fprintf(f,"\n");
}
Esempio n. 12
0
void Misc::quality_changed(int idx) {
	assert((unsigned int)(idx) < Count);
	emit set_blocks(Blocks[idx]);
	emit set_samples(Samples[idx]);
}