Example #1
0
File: boehm_gc.c Project: phs75/gap
void RetypeBag(Bag bag, UInt new_type)
{
    BagHeader * header = BAG_HEADER(bag);
    UInt        old_type = header->type;

    /* change the size-type word                                           */
    header->type = new_type;
    {
        int   old_gctype, new_gctype;
        UInt  size;
        void *new_mem, *old_mem;
        old_gctype = TabMarkTypeBags[old_type];
        new_gctype = TabMarkTypeBags[new_type];
        if (old_gctype != new_gctype) {
            size = SIZE_BAG(bag) + sizeof(BagHeader);
            new_mem = AllocateBagMemory(new_gctype, new_type, size);
            old_mem = PTR_BAG(bag);
            old_mem = ((char *)old_mem) - sizeof(BagHeader);
            memcpy(new_mem, old_mem, size);
            SET_PTR_BAG(bag, (void *)(((char *)new_mem) + sizeof(BagHeader)));
        }
    }
#ifdef HPCGAP
    switch (DSInfoBags[new_type]) {
    case DSI_PUBLIC:
        REGION(bag) = NULL;
        break;
    }
#endif // HPCGAP
}
Example #2
0
/* exported function documented in fbtk.h */
bool
fbtk_clip_rect(const bbox_t *  clip, bbox_t *  box)
{
    uint8_t region1;
    uint8_t region2;

    /* ensure co-ordinates are in ascending order */
    if (box->x1 < box->x0)
        SWAP(box->x0, box->x1);
    if (box->y1 < box->y0)
        SWAP(box->y0, box->y1);

    region1 = REGION(box->x0, box->y0, clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);
    region2 = REGION(box->x1, box->y1, clip->x0, clip->x1 - 1, clip->y0, clip->y1 - 1);

    /* area lies entirely outside the clipping rectangle */
    if ((region1 | region2) && (region1 & region2))
        return false;

    if (box->x0 < clip->x0)
        box->x0 = clip->x0;
    if (box->x0 > clip->x1)
        box->x0 = clip->x1;

    if (box->x1 < clip->x0)
        box->x1 = clip->x0;
    if (box->x1 > clip->x1)
        box->x1 = clip->x1;

    if (box->y0 < clip->y0)
        box->y0 = clip->y0;
    if (box->y0 > clip->y1)
        box->y0 = clip->y1;

    if (box->y1 < clip->y0)
        box->y1 = clip->y0;
    if (box->y1 > clip->y1)
        box->y1 = clip->y1;

    return true;
}
Example #3
0
Coordsys *vob_coords_trans(Scene *vs, Coordsys *into, 
			   float x, float y, float z)
{
	TransCS *ret = REGION(vs->reg, "vob.coords.Trans", TransCS); 
	ret->base.type = CS_TRANS;
	ret->parent = into;
	ret->x = x;
	ret->y = y;
	ret->z = z;
	//printf("box %f %f %fx%f\n", x,y,w,h);
	return (Coordsys*) ret;
}
Example #4
0
Coordsys *vob_coords_box(Scene *vs, Coordsys *into, 
			 float x, float y, float w, float h) 
{
	BoxCS *ret = REGION(vs->reg, "vob.coords.Box", BoxCS); 
	ret->base.type = CS_BOX;
	ret->parent = into;
	ret->x = x;
	ret->y = y;
	ret->w = w;
	ret->h = h;
	//printf("box2 %f %f %fx%f\n", ret->x,ret->y,ret->w,ret->h);
	return (Coordsys*) ret;
}
Example #5
0
void main ( void ) {
  int i = 0;

  cli();

  DDRA = 0xFF; // B out
  DDRB = 0xFF; // B out
  DDRC = 0xFF; // C out
  DDRD = 0xFF; // C out

  HSYNC_HIGH;
  VSYNC_HIGH;

  PORTD = 37;

  LED_ON;

  while ( 1 ) {

    // -------------------------------------------------------------------------------
    // Horizontal line business
    // -------------------------------------------------------------------------------

    REGION(150,VGA_ON,VGA_OFF);
    REGION(150,VGA_ON,VGA_OFF);
    REGION(150,VGA_ON,VGA_OFF);
    REGION(150,VGA_ON,VGA_OFF);

    // -------------------------------------------------------------------------------
    // Vertical sync business
    // -------------------------------------------------------------------------------

    REGION(1,NOP,NOP); /* front porch -> 1 line */
    VSYNC_LOW;
    REGION(4,NOP,NOP); /* sync pulse -> 4 lines */
    VSYNC_HIGH;
    VBLANK_HIGH;
    REGION(23,NOP,NOP); /* back porch -> 23 lines */
    VBLANK_LOW;

  } // while forever

} // main
Example #6
0
File: boehm_gc.c Project: phs75/gap
Region * RegionBag(Bag bag)
{
    Region * result = REGION(bag);
    MEMBAR_READ();
    return result;
}
Example #7
0
File: boehm_gc.c Project: phs75/gap
Bag MakeBagReadOnly(Bag bag)
{
    MEMBAR_WRITE();
    REGION(bag) = ReadOnlyRegion;
    return bag;
}
Example #8
0
File: boehm_gc.c Project: phs75/gap
Bag MakeBagPublic(Bag bag)
{
    MEMBAR_WRITE();
    REGION(bag) = 0;
    return bag;
}
Example #9
0
File: boehm_gc.c Project: phs75/gap
Bag NewBag(UInt type, UInt size)
{
    Bag  bag; /* identifier of the new bag       */
    UInt alloc_size;

    alloc_size = sizeof(BagHeader) + size;
#ifndef DISABLE_GC
#ifndef TRACK_CREATOR
    bag = GC_malloc(2 * sizeof(Bag *));
#else
    bag = GC_malloc(4 * sizeof(Bag *));
    if (STATE(PtrLVars)) {
        bag[2] = (void *)CURR_FUNC();
        if (STATE(CurrLVars) != STATE(BottomLVars)) {
            Obj plvars = PARENT_LVARS(STATE(CurrLVars));
            bag[3] = (void *)(FUNC_LVARS(plvars));
        }
    }
#endif

    SizeAllBags += size;

    /* If the size of an object is zero (such as an empty permutation),
     * and the header size is a multiple of twice the word size of the
     * architecture, then the master pointer will actually point past
     * the allocated area. Because this would result in the object
     * being freed prematurely, we will allocate at least one extra
     * byte so that the master pointer actually points to within an
     * allocated memory area.
     */
    if (size == 0)
        alloc_size++;
    /* While we use the Boehm GC without the "all interior pointers"
     * option, stack references to the interior of an object will
     * still be valid from any reference on the stack. This can lead,
     * for example, to a 1GB string never being freed if there's an
     * integer on the stack that happens to also be a reference to
     * any character inside that string. The garbage collector does
     * this because after compiler optimizations (especially reduction
     * in strength) references to the beginning of an object may be
     * lost.
     *
     * However, this is not generally a risk with GAP objects, because
     * master pointers on the heap will always retain a reference to
     * the start of the object (or, more precisely, to the first byte
     * past the header area). Hence, compiler optimizations pose no
     * actual risk unless the master pointer is destroyed also.
     *
     * To avoid the scenario where large objects do not get deallocated,
     * we therefore use the _ignore_off_page() calls. One caveat here
     * is that these calls do not use thread-local allocation, making
     * them somewhat slower. Hence, we only use them for sufficiently
     * large objects.
     */
    BagHeader * header =
        AllocateBagMemory(TabMarkTypeBags[type], type, alloc_size);
#else
    bag = malloc(2 * sizeof(Bag *));
    BagHeader * header = calloc(1, alloc_size);
#endif /* DISABLE_GC */

    header->type = type;
    header->flags = 0;
    header->size = size;

    /* set the masterpointer                                               */
    SET_PTR_BAG(bag, DATA(header));
#ifdef HPCGAP
    switch (DSInfoBags[type]) {
    case DSI_TL:
        REGION(bag) = CurrentRegion();
        break;
    case DSI_PUBLIC:
        REGION(bag) = NULL;
        break;
    }
#endif

    /* return the identifier of the new bag                                */
    return bag;
}