Mercurial > emacs
annotate src/ecrt0.c @ 96947:57b80a67db7b
(recode-region): Deactivate mark at the end.
author | Chong Yidong <cyd@stupidchicken.com> |
---|---|
date | Wed, 23 Jul 2008 22:40:07 +0000 |
parents | 1307c33f5e9a |
children | ea3fb04613c1 |
rev | line source |
---|---|
25844 | 1 /* C code startup routine. |
75227
e90d04cd455a
Update copyright for years from Emacs 21 to present (mainly adding
Glenn Morris <rgm@gnu.org>
parents:
68651
diff
changeset
|
2 Copyright (C) 1985, 1986, 1992, 2001, 2002, 2003, 2004, |
79759 | 3 2005, 2006, 2007, 2008 Free Software Foundation, Inc. |
25844 | 4 |
5 This file is part of GNU Emacs. | |
6 | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
7 GNU Emacs is free software: you can redistribute it and/or modify |
25844 | 8 it under the terms of the GNU General Public License as published by |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
9 the Free Software Foundation, either version 3 of the License, or |
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
10 (at your option) any later version. |
25844 | 11 |
12 GNU Emacs is distributed in the hope that it will be useful, | |
13 but WITHOUT ANY WARRANTY; without even the implied warranty of | |
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
15 GNU General Public License for more details. | |
16 | |
17 You should have received a copy of the GNU General Public License | |
94963
8971ddf55736
Switch to recommended form of GPLv3 permissions notice.
Glenn Morris <rgm@gnu.org>
parents:
91702
diff
changeset
|
18 along with GNU Emacs. If not, see <http://www.gnu.org/licenses/>. */ |
25844 | 19 |
20 | |
21 /* The standard Vax 4.2 Unix crt0.c cannot be used for Emacs | |
22 because it makes `environ' an initialized variable. | |
23 It is easiest to have a special crt0.c on all machines | |
24 though I don't know whether other machines actually need it. */ | |
25 | |
26 /* On the vax and 68000, in BSD4.2 and USG5.2, | |
27 this is the data format on startup: | |
28 (vax) ap and fp are unpredictable as far as I know; don't use them. | |
29 sp -> word containing argc | |
30 word pointing to first arg string | |
31 [word pointing to next arg string]... 0 or more times | |
32 0 | |
33 Optionally: | |
34 [word pointing to environment variable]... 1 or more times | |
35 ... | |
36 0 | |
37 And always: | |
38 first arg string | |
39 [next arg string]... 0 or more times | |
40 */ | |
41 | |
42 #ifdef emacs | |
43 #include <config.h> | |
44 #endif | |
45 | |
46 /* ******** WARNING ******** | |
47 Do not insert any data definitions before data_start! | |
48 Since this is the first file linked, the address of the following | |
49 variable should correspond to the start of initialized data space. | |
50 On some systems this is a constant that is independent of the text | |
51 size for shared executables. On others, it is a function of the | |
52 text size. In short, this seems to be the most portable way to | |
53 discover the start of initialized data space dynamically at runtime, | |
54 for either shared or unshared executables, on either swapping or | |
55 virtual systems. It only requires that the linker allocate objects | |
56 in the order encountered, a reasonable model for most Unix systems. | |
57 Similarly, note that the address of _start() should be the start | |
58 of text space. Fred Fish, UniSoft Systems Inc. */ | |
59 | |
60 int data_start = 0; | |
61 | |
62 #ifdef NEED_ERRNO | |
63 int errno; | |
64 #endif | |
65 | |
91702
b7a5a89054dc
* configure.in (LIBX11_MACHINE, HAVE_XFREE386): Remove code
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87730
diff
changeset
|
66 #ifndef MSDOS |
25844 | 67 char **environ; |
68 #endif | |
69 | |
70 #ifndef static | |
71 /* On systems where the static storage class is usable, this function | |
72 should be declared as static. Otherwise, the static keyword has | |
73 been defined to be something else, and code for those systems must | |
74 take care of this declaration appropriately. */ | |
75 static start1 (); | |
76 #endif | |
77 | |
78 #ifdef CRT0_DUMMIES | |
79 | |
80 /* Define symbol "start": here; some systems want that symbol. */ | |
81 #ifdef DOT_GLOBAL_START | |
82 asm(" .text "); | |
83 asm(" .globl start "); | |
84 asm(" start: "); | |
85 #endif /* DOT_GLOBAL_START */ | |
86 | |
87 #ifdef NODOT_GLOBAL_START | |
88 asm(" text "); | |
89 asm(" global start "); | |
90 asm(" start: "); | |
91 #endif /* NODOT_GLOBAL_START */ | |
92 | |
93 _start () | |
94 { | |
95 /* On vax, nothing is pushed here */ | |
96 start1 (); | |
97 } | |
98 | |
99 static | |
100 start1 (CRT0_DUMMIES argc, xargv) | |
101 int argc; | |
102 char *xargv; | |
103 { | |
104 register char **argv = &xargv; | |
105 environ = argv + argc + 1; | |
106 | |
107 if ((char *)environ == xargv) | |
108 environ--; | |
109 exit (main (argc, argv, environ)); | |
110 | |
111 /* Refer to `start1' so GCC will not think it is never called | |
112 and optimize it out. */ | |
113 (void) &start1; | |
114 } | |
115 #else /* not CRT0_DUMMIES */ | |
116 | |
96764
1307c33f5e9a
* ecrt0.c: Remove code depending on m68000, not used anymore.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96545
diff
changeset
|
117 /* This is a kludge. Now that the CRT0_DUMMIES mechanism above exists, |
25844 | 118 most of these machines could use the vax code above |
119 with some suitable definition of CRT0_DUMMIES. | |
120 Then the symbol m68k could be flushed. | |
121 But I don't want to risk breaking these machines | |
122 in a version 17 patch release, so that change is being put off. */ | |
123 | |
124 #ifdef m68k /* Can't do it all from C */ | |
125 asm (" global _start"); | |
126 asm (" text"); | |
127 asm ("_start:"); | |
128 asm (" comm splimit%,4"); | |
129 asm (" global exit"); | |
130 asm (" text"); | |
131 asm (" mov.l %d0,splimit%"); | |
132 asm (" jsr start1"); | |
133 asm (" mov.l %d0,(%sp)"); | |
134 asm (" jsr exit"); | |
135 asm (" mov.l &1,%d0"); /* d0 = 1 => exit */ | |
136 asm (" trap &0"); | |
137 | |
138 /* ignore takes care of skipping the a6 value pushed in start. */ | |
139 static | |
140 start1 (argc, xargv) | |
141 int argc; | |
142 char *xargv; | |
143 { | |
144 register char **argv = &xargv; | |
145 environ = argv + argc + 1; | |
146 | |
147 if ((char *)environ == xargv) | |
148 environ--; | |
149 exit (main (argc, argv, environ)); | |
150 } | |
151 | |
96764
1307c33f5e9a
* ecrt0.c: Remove code depending on m68000, not used anymore.
Dan Nicolaescu <dann@ics.uci.edu>
parents:
96545
diff
changeset
|
152 #endif /* m68k */ |
25844 | 153 |
154 #endif /* not CRT0_DUMMIES */ | |
155 | |
96545
4cb0e945175d
Use __sparc__ rather than sparc. (Bug#507.)
Glenn Morris <rgm@gnu.org>
parents:
96303
diff
changeset
|
156 #ifdef __sparc__ |
25844 | 157 asm (".global __start"); |
158 asm (".text"); | |
159 asm ("__start:"); | |
160 asm (" mov 0, %fp"); | |
161 asm (" ld [%sp + 64], %o0"); | |
162 asm (" add %sp, 68, %o1"); | |
163 asm (" sll %o0, 2, %o2"); | |
164 asm (" add %o2, 4, %o2"); | |
165 asm (" add %o1, %o2, %o2"); | |
166 asm (" sethi %hi(_environ), %o3"); | |
167 asm (" st %o2, [%o3+%lo(_environ)]"); | |
168 asm (" andn %sp, 7, %sp"); | |
169 asm (" call _main"); | |
170 asm (" sub %sp, 24, %sp"); | |
171 asm (" call __exit"); | |
172 asm (" nop"); | |
173 | |
96545
4cb0e945175d
Use __sparc__ rather than sparc. (Bug#507.)
Glenn Morris <rgm@gnu.org>
parents:
96303
diff
changeset
|
174 #endif /* __sparc__ */ |
25844 | 175 |
176 #if __FreeBSD__ == 2 | |
177 char *__progname; | |
178 #endif | |
52401 | 179 |
180 /* arch-tag: 4025c2fb-d6b1-4d29-b1b6-8100b6bd1e74 | |
181 (do not change this comment) */ |