Subject: Re: itimer, pthreads, and checkpointing
To: Simon Burge <simonb@NetBSD.ORG>
From: Michael Graff <explorer@flame.org>
List: tech-kern
Date: 11/15/1999 18:46:53
Simon Burge <simonb@NetBSD.ORG> writes:

> Just maybe you could also leverage off how c++ constructors are called
> using ELF .init sections and the like, but I have no idea how these
> work :)

This is what I was using about a month ago or so.  It isn't using the
.init section, but it is using the .ctors one, which is the C++
constructor hook I believe.

#include <stdio.h>

int foo = 0;

void
my_init(void)
{
        printf("foo == %d\n", foo);
        foo = 2;
}

static void (*init_hook)(void)
     __attribute__((section(".ctors"))) = my_init;

int
main(int argc, char **argv)
{
        printf("foo == %d\n", foo);
}