File:  [DVB] / dietlibc / dyn_stop.c
Revision 1.1: download - view: text, annotated - select for diffs
Wed May 16 13:43:57 2001 UTC (23 years ago) by olaf
Branches: MAIN
CVS tags: HEAD
added dynamic con- and destructor, start/stop code...
this is used in:
 - other libs with pre- and post-main-code
 - shared objects pre- and post-main-code
 - c++ (static initialiser of instanced classes)
   (little test c++ program written :) )

typedef void(*structor)(void);

#if 0
/* dirty trick to force gcc to be in the data section (see dyn_start) */
static structor force_to_data[0] = {};

/* terminate the Construc/DestrucTORS with a NULL element */
asm ( ".section .ctors,\"aw\" ");
static structor __CTOR_END__[1]={((structor)0)};

asm ( ".section .dtors,\"aw\" ");
static structor __DTOR_END__[1]={((structor)0)};
#else
__attribute__((section(".ctors")))
static structor __CTOR_END__[1]={((structor)0)};

__attribute__((section(".dtors")))
static structor __DTOR_END__[1]={((structor)0)};
#endif

static void __do_global_ctors_aux(void)
{
  structor *cf=__DTOR_END__;	/* ugly trick to prevent warning */;
  for(cf=((__CTOR_END__)-1); (*cf) != (structor)-1; cf--) (*cf)();
}

__attribute__((section(".init"))) void _init()
{
  __do_global_ctors_aux();
}


LinuxTV legacy CVS <linuxtv.org/cvs>