* sysdeps/powerpc/powerpc32/elf/start.S: Ensure .data is non-empty.
[glibc/history.git] / sysdeps / mach / start.c
blob92d2a827373a31fdbbf6ce0deaf53cd71d15d92e
1 /* Copyright (C) 1992, 1993, 1994, 1995, 1997 Free Software Foundation, Inc.
2 This file is part of the GNU C Library.
4 The GNU C Library is free software; you can redistribute it and/or
5 modify it under the terms of the GNU Lesser General Public
6 License as published by the Free Software Foundation; either
7 version 2.1 of the License, or (at your option) any later version.
9 In addition to the permissions in the GNU Lesser General Public
10 License, the Free Software Foundation gives you unlimited
11 permission to link the compiled version of this file with other
12 programs, and to distribute those programs without any restriction
13 coming from the use of this file. (The GNU Lesser General Public
14 License restrictions do apply in other respects; for example, they
15 cover modification of the file, and distribution when not linked
16 into another program.)
18 Note that people who make modified versions of this file are not
19 obligated to grant this special exception for their modified
20 versions; it is their choice whether to do so. The GNU Lesser
21 General Public License gives permission to release a modified
22 version without this exception; this exception also makes it
23 possible to release a modified version which carries forward this
24 exception.
26 The GNU C Library is distributed in the hope that it will be useful,
27 but WITHOUT ANY WARRANTY; without even the implied warranty of
28 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
29 Lesser General Public License for more details.
31 You should have received a copy of the GNU Lesser General Public
32 License along with the GNU C Library; if not, write to the Free
33 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
34 02111-1307 USA. */
36 #include <stddef.h>
37 #include <stdlib.h>
38 #include <errno.h>
39 #include <unistd.h>
40 #include <sysdep.h>
42 #ifndef __GNUC__
43 #error This file uses GNU C extensions; you must compile with GCC.
44 #endif
46 /* The first piece of initialized data. */
47 int __data_start = 0;
49 #ifndef _HURD_THREADVAR_H
50 volatile int errno;
51 #endif
53 extern void __mach_init (void);
54 extern void __libc_init (int argc, char **argv, char **envp);
55 extern int main (int argc, char **argv, char **envp);
57 /* These are uninitialized common definitions so they will be zero
58 by default. If the user links in C threads, that will provide initialized
59 definitions that override these. */
60 void *(*_cthread_init_routine) (void); /* Returns new SP to use. */
61 void (*_cthread_exit_routine) (int status);
64 /* These are for communication from _start to start1,
65 where we cannot use the stack for anything. */
66 static int start_argc;
67 static char **start_argv;
69 /* _start calls this on the new stack. */
70 static volatile void
71 start1 (void)
73 __libc_init (start_argc, start_argv, __environ);
75 (_cthread_exit_routine != NULL ? *_cthread_exit_routine : exit)
76 (main (start_argc, start_argv, __environ));
78 /* Should never get here. */
79 LOSE;
82 #ifndef START_ARGS
83 #define START_ARGS void
84 #endif
85 #ifdef START_MACHDEP
86 START_MACHDEP
87 #define _start _start0
88 #endif
90 void
91 _start (START_ARGS)
93 SNARF_ARGS (start_argc, start_argv, __environ);
95 __mach_init ();
97 if (_cthread_init_routine != NULL)
98 CALL_WITH_SP (start1, (*_cthread_init_routine) ());
99 else
100 start1 ();
102 /* Should never get here. */
103 LOSE;