| 1 |
/* gcrt0.c |
| 2 |
|
| 3 |
Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc. |
| 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 |
/* |
| 12 |
* This file is taken from Cygwin distribution. Please keep it in sync. |
| 13 |
* The differences should be within __MINGW32__ guard. |
| 14 |
*/ |
| 15 |
|
| 16 |
#include <sys/types.h> |
| 17 |
#include <stdlib.h> |
| 18 |
|
| 19 |
#ifdef __MINGW32__ |
| 20 |
#include <_bsd_types.h> |
| 21 |
#endif |
| 22 |
|
| 23 |
extern u_char etext asm ("etext"); |
| 24 |
extern u_char eprol asm ("__eprol"); |
| 25 |
extern void _mcleanup (void); |
| 26 |
extern void monstartup (size_t, size_t); |
| 27 |
void _monstartup (void) __attribute__((__constructor__)); |
| 28 |
|
| 29 |
/* startup initialization for -pg support */ |
| 30 |
|
| 31 |
void |
| 32 |
_monstartup (void) |
| 33 |
{ |
| 34 |
static int called; |
| 35 |
|
| 36 |
/* Guard against multiple calls that may happen if DLLs are linked |
| 37 |
with profile option set as well. Addede side benefit is that it |
| 38 |
makes profiling backward compatible (GCC used to emit a call to |
| 39 |
_monstartup when compiling main with profiling enabled). */ |
| 40 |
if (called++) |
| 41 |
return; |
| 42 |
|
| 43 |
monstartup ((size_t) &eprol, (size_t) &etext); |
| 44 |
atexit (&_mcleanup); |
| 45 |
} |
| 46 |
|
| 47 |
asm (".text"); |
| 48 |
asm ("__eprol:"); |
| 49 |
|