12 |
because currently GNU ld doesn't deal well with a.out targets and |
because currently GNU ld doesn't deal well with a.out targets and |
13 |
the -wrap option. When GNU ld is fixed, this should definitely be |
the -wrap option. When GNU ld is fixed, this should definitely be |
14 |
removed. Note that we actually wrap __exit, not _exit on a target |
removed. Note that we actually wrap __exit, not _exit on a target |
15 |
that has UNDERSCORES defined. */ |
that has UNDERSCORES defined. On non-UNDERSCORE targets, we |
16 |
|
wrap _exit separately; it's actually a different function. */ |
17 |
|
|
18 |
#ifdef WRAP_M68K_AOUT |
#ifdef WRAP_M68K_AOUT |
19 |
#define REAL_EXIT(code) asm ( "trap %0" : : "i" (0) ); |
#define REAL_EXIT(code) asm ( "trap %0" : : "i" (0) ); |
30 |
#define ORIG_MAIN _wrap__main |
#define ORIG_MAIN _wrap__main |
31 |
#else |
#else |
32 |
#define REAL_EXIT __real_exit |
#define REAL_EXIT __real_exit |
33 |
|
#ifndef VXWORKS |
34 |
|
#define REAL__EXIT __real__exit |
35 |
|
#endif |
36 |
#define REAL_MAIN __real_main |
#define REAL_MAIN __real_main |
37 |
#define REAL_ABORT __real_abort |
#define REAL_ABORT __real_abort |
38 |
#define ORIG_EXIT __wrap_exit |
#define ORIG_EXIT __wrap_exit |
39 |
|
#define ORIG__EXIT __wrap__exit |
40 |
#define ORIG_ABORT __wrap_abort |
#define ORIG_ABORT __wrap_abort |
41 |
#define ORIG_MAIN __wrap_main |
#define ORIG_MAIN __wrap_main |
42 |
#endif |
#endif |
47 |
extern void REAL_ABORT (); |
extern void REAL_ABORT (); |
48 |
extern int REAL_MAIN (int argc, char **argv, char **envp); |
extern int REAL_MAIN (int argc, char **argv, char **envp); |
49 |
#endif |
#endif |
50 |
|
#ifdef REAL__EXIT |
51 |
|
extern void REAL__EXIT (); |
52 |
|
#endif |
53 |
|
|
54 |
|
static int done_exit_message = 0; |
55 |
int ___constval = 1; |
int ___constval = 1; |
56 |
|
|
57 |
#ifdef VXWORKS |
#ifdef VXWORKS |
90 |
ptr = write_int (code, buf + strlen(buf)); |
ptr = write_int (code, buf + strlen(buf)); |
91 |
*(ptr++) = '\n'; |
*(ptr++) = '\n'; |
92 |
write (1, buf, ptr-buf); |
write (1, buf, ptr-buf); |
93 |
|
done_exit_message = 1; |
94 |
REAL_EXIT (code); |
REAL_EXIT (code); |
95 |
while (___constval); |
while (___constval); |
96 |
} |
} |
97 |
|
|
98 |
|
#ifdef ORIG__EXIT |
99 |
|
void |
100 |
|
ORIG__EXIT (code) |
101 |
|
int code; |
102 |
|
{ |
103 |
|
char buf[30]; |
104 |
|
char *ptr; |
105 |
|
|
106 |
|
/* Since exit may call _exit, we need to avoid a second message. */ |
107 |
|
if (! done_exit_message) |
108 |
|
{ |
109 |
|
strcpy (buf, "\n*** EXIT code "); |
110 |
|
ptr = write_int (code, buf + strlen(buf)); |
111 |
|
*(ptr++) = '\n'; |
112 |
|
write (1, buf, ptr-buf); |
113 |
|
} |
114 |
|
|
115 |
|
REAL__EXIT (code); |
116 |
|
while (___constval); |
117 |
|
} |
118 |
|
#endif |
119 |
|
|
120 |
void |
void |
121 |
ORIG_ABORT () |
ORIG_ABORT () |
122 |
{ |
{ |