OSDN Git Service

Initial revision
[pf3gnuchains/pf3gnuchains3x.git] / winsup / cygwin / gcrt0.c
1 /* gcrt0.c
2
3    Copyright 1998 Cygnus Solutions.
4
5 This file is part of Cygwin.
6
7 This software is a copyrighted work licensed under the terms of the
8 Cygwin license.  Please consult the file "CYGWIN_LICENSE" for
9 details. */
10
11 #include <sys/types.h>
12 #include <stdlib.h>
13
14 extern u_char etext asm ("etext");
15 extern u_char eprol asm ("__eprol");
16 extern void _mcleanup (void);
17 extern void monstartup (u_long, u_long);
18
19 void _monstartup (void) __attribute__((__constructor__));
20
21 /* startup initialization for -pg support */
22
23 void
24 _monstartup (void)
25 {
26   static int called;
27
28   /* Guard against multiple calls that may happen if DLLs are linked
29      with profile option set as well. Addede side benefit is that it
30      makes profiling backward compatible (GCC used to emit a call to
31      _monstartup when compiling main with profiling enabled).  */
32   if (called++)
33     return;
34
35   monstartup ((u_long) &eprol, (u_long) &etext);
36   atexit (&_mcleanup);
37 }
38
39 asm (".text");
40 asm ("__eprol:");
41