]>
Commit | Line | Data |
---|---|---|
11c981a9 RM |
1 | /* Code to enable profiling at program startup. |
2 | Copyright (C) 1995 Free Software Foundation, Inc. | |
3 | This file is part of the GNU C Library. | |
4 | ||
5 | The GNU C Library is free software; you can redistribute it and/or | |
6 | modify it under the terms of the GNU Library General Public License as | |
7 | published by the Free Software Foundation; either version 2 of the | |
8 | License, or (at your option) any later version. | |
9 | ||
10 | The GNU C Library is distributed in the hope that it will be useful, | |
11 | but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
13 | Library General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Library General Public | |
16 | License along with the GNU C Library; see the file COPYING.LIB. If | |
17 | not, write to the Free Software Foundation, Inc., 675 Mass Ave, | |
18 | Cambridge, MA 02139, USA. */ | |
19 | ||
20 | #include <sys/types.h> | |
21 | #include <sys/gmon.h> | |
22 | #include <stdlib.h> | |
23 | #include <unistd.h> | |
24 | ||
25 | /* Beginning and end of our code segment. */ | |
26 | extern void _start (), etext (); | |
27 | ||
28 | /* These functions are defined in gmon/gmon.c; | |
29 | they do all the work of setting up and cleaning up profiling. */ | |
30 | extern void monstartup (u_long, u_long); | |
31 | extern void _mcleanup (void); | |
32 | ||
33 | /* This function gets called at startup by the normal constructor | |
34 | mechanism. We link this file together with start.o to produce gcrt1.o, | |
35 | so this constructor will be first in the list. */ | |
36 | static void gmon_start (void) __attribute__ ((constructor)); | |
37 | static void | |
38 | gmon_start (void) | |
39 | { | |
40 | /* Start keeping profiling records. */ | |
41 | monstartup ((u_long) &_start, (u_long) &etext); | |
42 | ||
43 | /* Call _mcleanup before exitting; it will write out gmon.out from the | |
44 | collected data. */ | |
45 | atexit (&_mcleanup); | |
46 | } | |
47 |