Back to index

lightning-sunbird  0.9+nobinonly
Classes | Defines | Typedefs | Functions | Variables
gcc_support.c File Reference
#include <stddef.h>
#include "gc.h"

Go to the source code of this file.

Classes

struct  BI_header
struct  Descriptor
class  WeakPointer< T >
struct  EqualClosure
struct  Closure
struct  QueueElem

Defines

#define PROTO(args)   ()
#define BITSPERBYTE   8
#define NUM_ARRAY_ELEMENTS(o)   (((BI_header*) o)->nelts)
#define FIRST_ELEMENT_P(o)   ((char*) o + sizeof( BI_header ))
#define DESCRIPTOR(o)   ((Descriptor*) ((char*)(o) + GC_size( o ) - sizeof( Descriptor )))

Typedefs

typedef void vfp PROTO ((void))
typedef struct BI_header BI_header
typedef struct Descriptor Descriptor
typedef struct WeakPointer WeakPointer
typedef struct EqualClosure EqualClosure
typedef struct Closure Closure
typedef struct QueueElem QueueElem

Functions

void __default_new_handler PROTO ((void))
void__builtin_new (size_t size)
void__builtin_vec_new (size_t size)
void__builtin_new_gc (size_t size)
void__builtin_new_gc_a (size_t size)
void__builtin_vec_new_gc (size_t size)
void__builtin_vec_new_gc_a (size_t size)
static void call_destructor (void *o, void *data)
void__builtin_new_gc_dtor (void *o, destructor_proc d)
static void call_array_destructor (void *o, void *data)
void__builtin_vec_new_gc_dtor (void *first_elem, destructor_proc d, size_t element_size)
void __builtin_delete (void *o)
void __builtin_vec_delete (void *o)
void_WeakPointer_New (void *t)
static voidPointerWithLock (WeakPointer *wp)
void_WeakPointer_Pointer (WeakPointer *wp)
static voidEqualWithLock (EqualClosure *ec)
int _WeakPointer_Equal (WeakPointer *wp1, WeakPointer *wp2)
int _WeakPointer_Hash (WeakPointer *wp)
static void _CleanUp_CallClosure (void *obj, void *data)
void _CleanUp_Set (void *t, void *c, void *d)
void _CleanUp_Call (void *t)
void_CleanUp_Queue_NewHead ()
static void _CleanUp_Queue_Enqueue (void *obj, void *data)
void _CleanUp_Queue_Set (void *h, void *t)
int _CleanUp_Queue_Call (void *h)

Variables

vfp __new_handler

Class Documentation

struct BI_header

Definition at line 72 of file gcc_support.c.

Collaboration diagram for BI_header:
Class Members
int nelts
char padding
struct Descriptor

Definition at line 141 of file gcc_support.c.

Class Members
unsigned element_size: BITSPERBYTE * sizeof( unsigned ) - 2
unsigned has_finalizer: 1
unsigned has_weak_pointers: 1
struct EqualClosure

Definition at line 373 of file gcc_support.c.

Collaboration diagram for EqualClosure:
Class Members
WeakPointer * wp1
WeakPointer * wp2
struct QueueElem

Definition at line 460 of file gcc_support.c.

Collaboration diagram for QueueElem:
Class Members
void * d
GC_finalization_proc f
struct QueueElem * next
void * o

Define Documentation

Definition at line 41 of file gcc_support.c.

#define DESCRIPTOR (   o)    ((Descriptor*) ((char*)(o) + GC_size( o ) - sizeof( Descriptor )))

Definition at line 147 of file gcc_support.c.

#define FIRST_ELEMENT_P (   o)    ((char*) o + sizeof( BI_header ))

Definition at line 81 of file gcc_support.c.

#define NUM_ARRAY_ELEMENTS (   o)    (((BI_header*) o)->nelts)

Definition at line 78 of file gcc_support.c.

#define PROTO (   args)    ()

Definition at line 38 of file gcc_support.c.


Typedef Documentation

typedef struct BI_header BI_header
typedef struct Closure Closure
typedef struct Descriptor Descriptor
typedef struct EqualClosure EqualClosure
typedef destructor_proc PROTO((void *this, int flag))

Definition at line 45 of file gcc_support.c.

typedef struct QueueElem QueueElem
typedef struct WeakPointer WeakPointer

Function Documentation

Definition at line 306 of file gcc_support.c.

{
  if (o != 0) { 
      Descriptor* desc = DESCRIPTOR( o );
      if (desc->has_finalizer) GC_REGISTER_FINALIZER( o, 0, 0, 0, 0 );
      if (! desc->has_weak_pointers) GC_FREE( o );}}

Here is the caller graph for this function:

void* __builtin_new ( size_t  size)

Definition at line 158 of file gcc_support.c.

{
    vfp handler = __new_handler ? __new_handler : __default_new_handler;

    while (1) {
        void* o = GC_MALLOC_UNCOLLECTABLE( size + sizeof( Descriptor ) );
        if (o != 0) return o;
        (*handler) ();}}

Here is the caller graph for this function:

void* __builtin_new_gc ( size_t  size)

Definition at line 184 of file gcc_support.c.

{
    vfp handler = __new_handler ? __new_handler : __default_new_handler;

    while (1) {
        void* o = GC_MALLOC( size + sizeof( Descriptor ) );
        if (o != 0) return o;
        (*handler) ();}}

Here is the caller graph for this function:

void* __builtin_new_gc_a ( size_t  size)

Definition at line 199 of file gcc_support.c.

{
    vfp handler = __new_handler ? __new_handler : __default_new_handler;

    while (1) {
        void* o = GC_MALLOC_ATOMIC( size + sizeof( Descriptor ) );
        if (o != 0) return o;
        (*handler) ();}}

Here is the caller graph for this function:

void* __builtin_new_gc_dtor ( void o,
destructor_proc  d 
)

Definition at line 244 of file gcc_support.c.

Here is the call graph for this function:

Definition at line 321 of file gcc_support.c.

Here is the call graph for this function:

void* __builtin_vec_new ( size_t  size)

Definition at line 175 of file gcc_support.c.

{
    return __builtin_new( size );}

Here is the call graph for this function:

void* __builtin_vec_new_gc ( size_t  size)

Definition at line 214 of file gcc_support.c.

{
    return __builtin_new_gc( size );}

Here is the call graph for this function:

void* __builtin_vec_new_gc_a ( size_t  size)

Definition at line 223 of file gcc_support.c.

{
    return __builtin_new_gc_a( size );}

Here is the call graph for this function:

void* __builtin_vec_new_gc_dtor ( void first_elem,
destructor_proc  d,
size_t  element_size 
)

Definition at line 285 of file gcc_support.c.

{
    void* o = (char*) first_elem - sizeof( BI_header );
    Descriptor* desc = DESCRIPTOR( o );

    GC_REGISTER_FINALIZER_IGNORE_SELF( o, call_array_destructor, d, 0, 0 );
    desc->element_size = element_size;
    desc->has_finalizer = 1;}

Here is the call graph for this function:

Definition at line 447 of file gcc_support.c.

{
      /* ? Aren't we supposed to deactivate weak pointers to t too? 
         Why? */
    void* base = GC_base( t );
    void* d;
    GC_finalization_proc f;

    GC_REGISTER_FINALIZER( base, 0, 0, &f, &d );
    f( base, d );}

Here is the call graph for this function:

Here is the caller graph for this function:

static void _CleanUp_CallClosure ( void obj,
void data 
) [static]

Definition at line 418 of file gcc_support.c.

{
    Closure* closure = (Closure*) data;
    closure->c( closure->d, (char*) obj + closure->t_offset );}

Here is the caller graph for this function:

Definition at line 501 of file gcc_support.c.

{
    QueueElem* head = (QueueElem*) h;
    QueueElem* q = head->next;

    if (q == 0) {
        return 0;}
    else {
        head->next = q->next;
        q->next = 0;
        if (q->f != 0) q->f( q->o, q->d );
        return 1;}}

Here is the caller graph for this function:

static void _CleanUp_Queue_Enqueue ( void obj,
void data 
) [static]

Definition at line 473 of file gcc_support.c.

{
    QueueElem* q = (QueueElem*) data;
    QueueElem* head = q->next;

    q->o = obj;
    q->next = head->next;
    head->next = q;}

Here is the caller graph for this function:

Definition at line 468 of file gcc_support.c.

{
    return GC_MALLOC( sizeof( QueueElem ) );}

Here is the caller graph for this function:

void _CleanUp_Queue_Set ( void h,
void t 
)

Definition at line 485 of file gcc_support.c.

{
    QueueElem* head = (QueueElem*) h;
    void* base = GC_base( t );
    void* d;
    GC_finalization_proc f;
    QueueElem* q = (QueueElem*) GC_MALLOC( sizeof( QueueElem ) );
     
    GC_REGISTER_FINALIZER( base, _CleanUp_Queue_Enqueue, q, &f, &d );
    q->f = f;
    q->d = d;
    q->next = head;}

Here is the call graph for this function:

Here is the caller graph for this function:

void _CleanUp_Set ( void t,
void c,
void d 
)

Definition at line 426 of file gcc_support.c.

{
    void* base = GC_base( t );
    Descriptor* desc = DESCRIPTOR( t );

    if (c == 0) {
        GC_REGISTER_FINALIZER_IGNORE_SELF( base, 0, 0, 0, 0 );
        desc->has_finalizer = 0;}
    else {
        Closure* closure = (Closure*) GC_MALLOC( sizeof( Closure ) );
        closure->c = c;
        closure->t_offset = (char*) t - (char*) base;
        closure->d = d;
        GC_REGISTER_FINALIZER_IGNORE_SELF( base, _CleanUp_CallClosure, 
                                           closure, 0, 0 );
        desc->has_finalizer = 1;}}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 388 of file gcc_support.c.

{
    EqualClosure ec;

    ec.wp1 = wp1;
    ec.wp2 = wp2;
    return (int) GC_call_with_alloc_lock( EqualWithLock, &ec );}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 399 of file gcc_support.c.

{
    return (int) _WeakPointer_Pointer( wp );}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 341 of file gcc_support.c.

{
    if (t == 0) {
        return 0;}
    else {
        void* base = GC_base( t );
        WeakPointer* wp = 
            (WeakPointer*) GC_MALLOC_ATOMIC( sizeof( WeakPointer ) );
        Descriptor* desc = DESCRIPTOR( base );

        wp->pointer = t;
        desc->has_weak_pointers = 1;
        GC_general_register_disappearing_link( &wp->pointer, base );
        return wp;}}

Here is the call graph for this function:

Here is the caller graph for this function:

Definition at line 367 of file gcc_support.c.

{
    return (void*) GC_call_with_alloc_lock( PointerWithLock, wp );}

Here is the call graph for this function:

Here is the caller graph for this function:

static void call_array_destructor ( void o,
void data 
) [static]

Definition at line 263 of file gcc_support.c.

{
    int num = NUM_ARRAY_ELEMENTS( o );
    Descriptor* desc = DESCRIPTOR( o );
    size_t size = desc->element_size;
    char* first_p = FIRST_ELEMENT_P( o );
    char* p = first_p + (num - 1) * size;

    if (num > 0) {
        while (1) {
            ((destructor_proc) data)( p, 2 );
            if (p == first_p) break;
            p -= size;}}}

Here is the caller graph for this function:

static void call_destructor ( void o,
void data 
) [static]

Definition at line 232 of file gcc_support.c.

{
    ((destructor_proc) data)( o, 2 );}

Here is the caller graph for this function:

static void* EqualWithLock ( EqualClosure ec) [static]

Definition at line 379 of file gcc_support.c.

{
    if (ec->wp1 == 0 || ec->wp2 == 0) {
        return (void*) (ec->wp1 == ec->wp2);}
    else {
      return (void*) (ec->wp1->pointer == ec->wp2->pointer);}}

Here is the caller graph for this function:

static void* PointerWithLock ( WeakPointer wp) [static]

Definition at line 358 of file gcc_support.c.

{
    if (wp == 0 || wp->pointer == 0) {
      return 0;}
    else {
        return (void*) wp->pointer;}}

Here is the caller graph for this function:

void __default_new_handler PROTO ( (void )

Variable Documentation