Mercurial > emacs
annotate src/ecrt0.c @ 96294:f12e581d977f
(completion-basic-try-completion): Use the text after
point to consrain the completion candidates.
(completion-basic-all-completions): Adjust accordingly.
author | Stefan Monnier <monnier@iro.umontreal.ca> |
---|---|
date | Thu, 26 Jun 2008 02:48:56 +0000 |
parents | 8971ddf55736 |
children | ddedcecb18ef |
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 /* On the 16000, at least in the one 4.2 system I know about, | |
43 the initial data format is | |
44 sp -> word containing argc | |
45 word containing argp | |
46 word pointing to first arg string, and so on as above | |
47 */ | |
48 | |
49 #ifdef emacs | |
50 #include <config.h> | |
51 #endif | |
52 | |
53 /* ******** WARNING ******** | |
54 Do not insert any data definitions before data_start! | |
55 Since this is the first file linked, the address of the following | |
56 variable should correspond to the start of initialized data space. | |
57 On some systems this is a constant that is independent of the text | |
58 size for shared executables. On others, it is a function of the | |
59 text size. In short, this seems to be the most portable way to | |
60 discover the start of initialized data space dynamically at runtime, | |
61 for either shared or unshared executables, on either swapping or | |
62 virtual systems. It only requires that the linker allocate objects | |
63 in the order encountered, a reasonable model for most Unix systems. | |
64 Similarly, note that the address of _start() should be the start | |
65 of text space. Fred Fish, UniSoft Systems Inc. */ | |
66 | |
67 int data_start = 0; | |
68 | |
69 #ifdef NEED_ERRNO | |
70 int errno; | |
71 #endif | |
72 | |
91702
b7a5a89054dc
* configure.in (LIBX11_MACHINE, HAVE_XFREE386): Remove code
Dan Nicolaescu <dann@ics.uci.edu>
parents:
87730
diff
changeset
|
73 #ifndef MSDOS |
25844 | 74 char **environ; |
75 #endif | |
76 | |
77 #ifndef static | |
78 /* On systems where the static storage class is usable, this function | |
79 should be declared as static. Otherwise, the static keyword has | |
80 been defined to be something else, and code for those systems must | |
81 take care of this declaration appropriately. */ | |
82 static start1 (); | |
83 #endif | |
84 | |
85 #ifdef CRT0_DUMMIES | |
86 | |
87 /* Define symbol "start": here; some systems want that symbol. */ | |
88 #ifdef DOT_GLOBAL_START | |
89 asm(" .text "); | |
90 asm(" .globl start "); | |
91 asm(" start: "); | |
92 #endif /* DOT_GLOBAL_START */ | |
93 | |
94 #ifdef NODOT_GLOBAL_START | |
95 asm(" text "); | |
96 asm(" global start "); | |
97 asm(" start: "); | |
98 #endif /* NODOT_GLOBAL_START */ | |
99 | |
100 #ifdef m68000 | |
101 | |
102 /* GCC 2.1, when optimization is turned off, seems to want to push a | |
103 word of garbage on the stack, which screws up the CRT0_DUMMIES | |
104 hack. So we hand-code _start in assembly language. */ | |
105 asm(".text "); | |
106 asm(" .even "); | |
107 asm(".globl __start "); | |
108 asm("__start: "); | |
109 asm(" link a6,#0 "); | |
110 asm(" jbsr _start1 "); | |
111 asm(" unlk a6 "); | |
112 asm(" rts "); | |
113 | |
114 #else /* not m68000 */ | |
115 | |
116 _start () | |
117 { | |
118 /* On vax, nothing is pushed here */ | |
119 /* On sequent, bogus fp is pushed here */ | |
120 start1 (); | |
121 } | |
122 | |
123 #endif /* possibly m68000 */ | |
124 | |
125 static | |
126 start1 (CRT0_DUMMIES argc, xargv) | |
127 int argc; | |
128 char *xargv; | |
129 { | |
130 register char **argv = &xargv; | |
131 environ = argv + argc + 1; | |
132 | |
133 if ((char *)environ == xargv) | |
134 environ--; | |
135 exit (main (argc, argv, environ)); | |
136 | |
137 /* Refer to `start1' so GCC will not think it is never called | |
138 and optimize it out. */ | |
139 (void) &start1; | |
140 } | |
141 #else /* not CRT0_DUMMIES */ | |
142 | |
143 /* "m68k" and "m68000" both stand for m68000 processors, | |
144 but with different program-entry conventions. | |
145 This is a kludge. Now that the CRT0_DUMMIES mechanism above exists, | |
146 most of these machines could use the vax code above | |
147 with some suitable definition of CRT0_DUMMIES. | |
148 Then the symbol m68k could be flushed. | |
149 But I don't want to risk breaking these machines | |
150 in a version 17 patch release, so that change is being put off. */ | |
151 | |
152 #ifdef m68k /* Can't do it all from C */ | |
153 asm (" global _start"); | |
154 asm (" text"); | |
155 asm ("_start:"); | |
156 asm (" comm splimit%,4"); | |
157 asm (" global exit"); | |
158 asm (" text"); | |
159 asm (" mov.l %d0,splimit%"); | |
160 asm (" jsr start1"); | |
161 asm (" mov.l %d0,(%sp)"); | |
162 asm (" jsr exit"); | |
163 asm (" mov.l &1,%d0"); /* d0 = 1 => exit */ | |
164 asm (" trap &0"); | |
165 #else /* m68000, not m68k */ | |
166 | |
167 #ifdef m68000 | |
168 | |
169 _start () | |
170 { | |
171 #ifdef sun | |
172 finitfp_(); | |
49600
23a1cea22d13
Trailing whitespace deleted.
Juanma Barranquero <lekktu@gmail.com>
parents:
27727
diff
changeset
|
173 #endif |
25844 | 174 /* On 68000, _start pushes a6 onto stack */ |
175 start1 (); | |
176 } | |
177 #endif /* m68000 */ | |
178 #endif /* m68k */ | |
179 | |
180 #if defined(m68k) || defined(m68000) | |
181 /* ignore takes care of skipping the a6 value pushed in start. */ | |
182 static | |
183 #if defined(m68k) | |
184 start1 (argc, xargv) | |
185 #else | |
186 start1 (ignore, argc, xargv) | |
187 #endif | |
188 int argc; | |
189 char *xargv; | |
190 { | |
191 register char **argv = &xargv; | |
192 environ = argv + argc + 1; | |
193 | |
194 if ((char *)environ == xargv) | |
195 environ--; | |
196 exit (main (argc, argv, environ)); | |
197 } | |
198 | |
199 #endif /* m68k or m68000 */ | |
200 | |
201 #endif /* not CRT0_DUMMIES */ | |
202 | |
203 #ifdef hp9000s300 | |
204 int argc_value; | |
205 char **argv_value; | |
206 #ifdef OLD_HP_ASSEMBLER | |
207 asm(" text"); | |
208 asm(" globl __start"); | |
209 asm(" globl _exit"); | |
210 asm(" globl _main"); | |
211 asm("__start"); | |
212 asm(" dc.l 0"); | |
213 asm(" subq.w #0x1,d0"); | |
214 asm(" move.w d0,float_soft"); | |
215 asm(" move.l 0x4(a7),d0"); | |
216 asm(" beq.s skip_1"); | |
217 asm(" move.l d0,a0"); | |
218 asm(" clr.l -0x4(a0)"); | |
219 asm("skip_1"); | |
220 asm(" move.l a7,a0"); | |
221 asm(" subq.l #0x8,a7"); | |
222 asm(" move.l (a0),(a7)"); | |
223 asm(" move.l (a0),_argc_value"); | |
224 asm(" addq.l #0x4,a0"); | |
225 asm(" move.l a0,0x4(a7)"); | |
226 asm(" move.l a0,_argv_value"); | |
227 asm("incr_loop"); | |
228 asm(" tst.l (a0)+"); | |
229 asm(" bne.s incr_loop"); | |
230 asm(" move.l 0x4(a7),a1"); | |
231 asm(" cmp.l (a1),a0"); | |
232 asm(" blt.s skip_2"); | |
233 asm(" subq.l #0x4,a0"); | |
234 asm("skip_2"); | |
235 asm(" move.l a0,0x8(a7)"); | |
236 asm(" move.l a0,_environ"); | |
237 asm(" jsr _main"); | |
238 asm(" addq.l #0x8,a7"); | |
239 asm(" move.l d0,-(a7)"); | |
240 asm(" jsr _exit"); | |
241 asm(" move.w #0x1,d0"); | |
242 asm(" trap #0x0"); | |
243 asm(" comm float_soft,4"); | |
244 /* float_soft is allocated in this way because C would | |
245 put an underscore character in its name otherwise. */ | |
246 | |
247 #else /* new hp assembler */ | |
248 | |
249 asm(" text"); | |
250 asm(" global float_loc"); | |
251 asm(" set float_loc,0xFFFFB000"); | |
252 asm(" global fpa_loc"); | |
253 asm(" set fpa_loc,0xfff08000"); | |
254 asm(" global __start"); | |
255 asm(" global _exit"); | |
256 asm(" global _main"); | |
257 asm("__start:"); | |
258 asm(" byte 0,0,0,0"); | |
259 asm(" subq.w &1,%d0"); | |
260 asm(" mov.w %d0,float_soft"); | |
261 asm(" mov.w %d1,flag_68881"); | |
262 #ifndef HPUX_68010 | |
263 asm(" beq.b skip_float"); | |
264 asm(" fmov.l &0x7400,%fpcr"); | |
265 /* asm(" fmov.l &0x7480,%fpcr"); */ | |
266 #endif /* HPUX_68010 */ | |
267 asm("skip_float:"); | |
268 asm(" mov.l %a0,%d0"); | |
269 asm(" add.l %d0,%d0"); | |
270 asm(" subx.w %d1,%d1"); | |
271 asm(" mov.w %d1,flag_68010"); | |
272 asm(" add.l %d0,%d0"); | |
273 asm(" subx.w %d1,%d1"); | |
274 asm(" mov.w %d1,flag_fpa"); | |
275 asm(" tst.l %d2"); | |
276 asm(" ble.b skip_3"); | |
277 asm(" lsl flag_68881"); | |
278 asm(" lsl flag_fpa"); | |
279 asm("skip_3:"); | |
280 asm(" mov.l 4(%a7),%d0"); | |
281 asm(" beq.b skip_1"); | |
282 asm(" mov.l %d0,%a0"); | |
283 asm(" clr.l -4(%a0)"); | |
284 asm("skip_1:"); | |
285 asm(" mov.l %a7,%a0"); | |
286 asm(" subq.l &8,%a7"); | |
287 asm(" mov.l (%a0),(%a7)"); | |
288 asm(" mov.l (%a0),_argc_value"); | |
289 asm(" addq.l &4,%a0"); | |
290 asm(" mov.l %a0,4(%a7)"); | |
291 asm(" mov.l %a0,_argv_value"); | |
292 asm("incr_loop:"); | |
293 asm(" tst.l (%a0)+"); | |
294 asm(" bne.b incr_loop"); | |
295 asm(" mov.l 4(%a7),%a1"); | |
296 asm(" cmp.l %a0,(%a1)"); | |
297 asm(" blt.b skip_2"); | |
298 asm(" subq.l &4,%a0"); | |
299 asm("skip_2:"); | |
300 asm(" mov.l %a0,8(%a7)"); | |
301 asm(" mov.l %a0,_environ"); | |
302 asm(" jsr _main"); | |
303 asm(" addq.l &8,%a7"); | |
304 asm(" mov.l %d0,-(%a7)"); | |
305 asm(" jsr _exit"); | |
306 asm(" mov.w &1,%d0"); | |
307 asm(" trap &0"); | |
308 asm(" comm float_soft, 4"); | |
309 asm(" comm flag_68881, 4"); | |
310 asm(" comm flag_68010, 4"); | |
311 asm(" comm flag_68040, 4"); | |
312 asm(" comm flag_fpa, 4"); | |
313 | |
314 #endif /* new hp assembler */ | |
315 #endif /* hp9000s300 */ | |
316 | |
317 #ifdef sparc | |
318 asm (".global __start"); | |
319 asm (".text"); | |
320 asm ("__start:"); | |
321 asm (" mov 0, %fp"); | |
322 asm (" ld [%sp + 64], %o0"); | |
323 asm (" add %sp, 68, %o1"); | |
324 asm (" sll %o0, 2, %o2"); | |
325 asm (" add %o2, 4, %o2"); | |
326 asm (" add %o1, %o2, %o2"); | |
327 asm (" sethi %hi(_environ), %o3"); | |
328 asm (" st %o2, [%o3+%lo(_environ)]"); | |
329 asm (" andn %sp, 7, %sp"); | |
330 asm (" call _main"); | |
331 asm (" sub %sp, 24, %sp"); | |
332 asm (" call __exit"); | |
333 asm (" nop"); | |
334 | |
335 #endif /* sparc */ | |
336 | |
337 #if __FreeBSD__ == 2 | |
338 char *__progname; | |
339 #endif | |
340 #ifdef __bsdi__ | |
341 #include <sys/param.h> /* for version number */ | |
342 #if defined(_BSDI_VERSION) && (_BSDI_VERSION >= 199501) | |
343 char *__progname; | |
344 #endif | |
345 #endif /* __bsdi__ */ | |
52401 | 346 |
347 /* arch-tag: 4025c2fb-d6b1-4d29-b1b6-8100b6bd1e74 | |
348 (do not change this comment) */ |