global {con,de}structors, atexit & friends

Alexandre Oliva oliva@dcc.unicamp.br
Sat Jul 25 14:29:00 GMT 1998


Ulrich Drepper <drepper@cygnus.com> writes:

> Then the only task of the constructor is to get the current stack
> pointer, fill in the destructor address and increment the pointer.
> Using the instructions to atomically increment a value we can
> implement this thread-safe.  On dumb architectures we'll maybe have
> to use spinlocks but this is a minor problem.

Perhaps we could use these locks to ensure that local static variables
are initialized only once, even in multi-threaded environments.

-- 
Alexandre Oliva
mailto:oliva@dcc.unicamp.br mailto:aoliva@acm.org
http://www.dcc.unicamp.br/~oliva
Universidade Estadual de Campinas, SP, Brasil




More information about the Gcc mailing list