.
[glibc-ports.git] / sysdeps / unix / sysv / aix / init-first.c
blob24ef109dd2253285bfeba129b9381e4fdbbad971
1 /* Initialization code run first thing by the XCOFF startup code. AIX version.
2 Copyright (C) 2001, 2002 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, write to the Free
17 Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA
18 02111-1307 USA. */
20 #include <stdio.h>
21 #include <stdlib.h>
22 #include <fcntl.h>
23 #include <unistd.h>
24 #include <sysdep.h>
25 #include <fpu_control.h>
26 #include <sys/param.h>
27 #include <sys/types.h>
28 #include <libc-internal.h>
30 #ifndef SHARED
31 # include <ldsodefs.h>
32 # include "dl-osinfo.h"
33 #endif
35 extern void __libc_init (int, char **, char **);
37 /* The function is called from assembly stubs the compiler can't see. */
38 static void init (int, char **, char **) __attribute__ ((unused));
40 /* Set nonzero if we have to be prepared for more then one libc being
41 used in the process. Safe assumption if initializer never runs. */
42 int __libc_multiple_libcs attribute_hidden = 1;
44 /* Remember the command line argument and enviroment contents for
45 later calls of initializers for dynamic libraries. */
46 int __libc_argc attribute_hidden;
47 char **__libc_argv attribute_hidden;
50 static void
51 init (int argc, char **argv, char **envp)
53 #ifdef USE_NONOPTION_FLAGS
54 extern void __getopt_clean_environment (char **);
55 #endif
56 /* The next variable is only here to work around a bug in gcc <= 2.7.2.2.
57 If the address would be taken inside the expression the optimizer
58 would try to be too smart and throws it away. Grrr. */
60 /* XXX disable dl for now
61 __libc_multiple_libcs = &_dl_starting_up && !_dl_starting_up; */
63 /* Save the command-line arguments. */
64 __libc_argc = argc;
65 __libc_argv = argv;
66 __environ = envp;
68 #ifndef SHARED
69 __libc_init_secure ();
70 #endif
72 __libc_init (argc, argv, envp);
74 #ifdef USE_NONOPTION_FLAGS
75 /* This is a hack to make the special getopt in GNU libc working. */
76 __getopt_clean_environment (envp);
77 #endif
79 #ifdef SHARED
80 __libc_global_ctors ();
81 #endif
84 #ifdef SHARED
86 strong_alias (init, _init);
88 extern void __libc_init_first (void);
90 void
91 __libc_init_first (void)
95 #else
96 extern void __libc_init_first (int argc, char **argv, char **envp);
98 void
99 __libc_init_first (int argc, char **argv, char **envp)
101 init (argc, argv, envp);
103 #endif