#include <stdio.h>
#include <stdlib.h>
void glx_highpc(void) { }
#if defined(__GNUC__) && defined(__linux__)
void monstartup( char *lowpc, char *highpc );
void _mcleanup( void );
void glx_lowpc( void );
static int profile = 0;
void __attribute__ ((constructor))
glx_init_prof( void )
{
FILE *fp;
char *s = getenv("GLX_SO_MON");
fprintf(stderr, "\n\n\nIn glx_init_prof\n\n\n");
if (!s) return;
if (profile) return;
profile = 1;
monstartup( (char *)glx_lowpc, (char *)glx_highpc );
fprintf(stderr, "Starting profiling, %lx %lx\n",
(unsigned long)glx_lowpc,
(unsigned long)glx_highpc);
if ((fp = fopen( "glx_lowpc", "w" )) != NULL) {
fprintf( fp, "0x%08lx ", (unsigned long)glx_lowpc );
fclose( fp );
}
}
void __attribute__ ((destructor))
glx_fini_prof( void )
{
fprintf(stderr, "in glx_fini_prof\n");
if (profile) {
_mcleanup();
profile = 0;
fprintf(stderr, "Finished profiling\n");
}
}
#else
void force_init_prof( void )
{
}
#endif