summary refs log tree commit diff
path: root/sysdeps
diff options
context:
space:
mode:
authorRoland McGrath <roland@gnu.org>1998-10-18 22:53:04 +0000
committerRoland McGrath <roland@gnu.org>1998-10-18 22:53:04 +0000
commita13d5ca5e475ba92fa1aaf909f2f24bc88f3f205 (patch)
tree07c6644c4208569bdb39eb6ea064af2535346ab2 /sysdeps
parent4f6bfa8090a2465d450fc3b3be1ae2d30b0e53c7 (diff)
downloadglibc-a13d5ca5e475ba92fa1aaf909f2f24bc88f3f205.tar.gz
glibc-a13d5ca5e475ba92fa1aaf909f2f24bc88f3f205.tar.xz
glibc-a13d5ca5e475ba92fa1aaf909f2f24bc88f3f205.zip
* sysdeps/mach/hurd/i386/init-first.c (posixland_init): New function,
	broken out of init1.
	(init1) [PIC]: Call it.
	(__libc_init_first) [! PIC]: Call it.
Diffstat (limited to 'sysdeps')
-rw-r--r--sysdeps/mach/hurd/i386/init-first.c50
1 files changed, 34 insertions, 16 deletions
diff --git a/sysdeps/mach/hurd/i386/init-first.c b/sysdeps/mach/hurd/i386/init-first.c
index 85091c4c6b..bfc2ff5b57 100644
--- a/sysdeps/mach/hurd/i386/init-first.c
+++ b/sysdeps/mach/hurd/i386/init-first.c
@@ -48,6 +48,23 @@ void (*_cthread_exit_routine) (int status) __attribute__ ((__noreturn__));
    Importantly, these are called before anything tries to use malloc.  */
 DEFINE_HOOK (_hurd_preinit_hook, (void));
 
+
+/* We call this once the Hurd magic is all set up and we are ready to be a
+   Posixoid program.  This does the same things the generic version does.  */
+static void internal_function
+posixland_init (int argc, char **argv)
+{
+  __libc_init (argc, argv, __environ);
+
+  /* This is a hack to make the special getopt in GNU libc working.  */
+  __getopt_clean_environment (__environ);
+
+#ifdef PIC
+  __libc_global_ctors ();
+#endif
+}
+
+
 static void
 init1 (int argc, char *arg0, ...)
 {
@@ -107,20 +124,14 @@ init1 (int argc, char *arg0, ...)
 		d->intarray, d->intarraysize);
 
 #ifndef PIC
-  __libc_enable_secure = _dl_hurd_data->flags & EXEC_SECURE;
-#endif
-
-  __libc_init (argc, argv, __environ);
-
-  /* This is a hack to make the special getopt in GNU libc working.  */
-  __getopt_clean_environment (__environ);
-
-#ifdef PIC
-  __libc_global_ctors ();
+  __libc_enable_secure = d->flags & EXEC_SECURE;
+#else
+  posixland_init(argc, argv);
 #endif
 }
 
-static void
+
+static inline void
 init (int *data)
 {
   int argc = *data;
@@ -232,15 +243,22 @@ _init (int argc, ...)
 
 
 void
-__libc_init_first (int argc __attribute__ ((unused)), ...)
+__libc_init_first (int argc, char **argv, char **envp)
+#ifdef PIC
 {
+  /* Everything was done in the shared library initializer, _init.  */
+}
+#else
+{
+  posixland_init(argc, argv);
 }
 
-
+/* XXX This is all a crock and I am not happy with it.
+   This poorly-named function is called by static-start.S,
+   which should not exist at all.  */
 void
 _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
 {
-#ifndef PIC
   void doinit (int *data)
     {
       /* This function gets called with the argument data at TOS.  */
@@ -252,7 +270,7 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
       /* Push the user return address after the argument data, and then
 	 jump to `doinit1' (above), so it is as if __libc_init_first's
 	 caller had called `doinit1' with the argument data already on the
-	 stack.  */
+      stack.  */
       *--data = (&argc)[-1];
       asm volatile ("movl %0, %%esp\n" /* Switch to new outermost stack.  */
 		    "movl $0, %%ebp\n" /* Clear outermost frame pointer.  */
@@ -266,8 +284,8 @@ _hurd_stack_setup (int argc __attribute__ ((unused)), ...)
   RUN_HOOK (_hurd_preinit_hook, ());
 
   _hurd_startup ((void **) &argc, &doinit);
-#endif
 }
+#endif
 
 
 /* This function is defined here so that if this file ever gets into