1 /****************************************************************************
3 * GNAT COMPILER COMPONENTS *
5 * I N I T I A L I Z E *
7 * C Implementation File *
9 * Copyright (C) 1992-2005, Free Software Foundation, Inc. *
11 * GNAT is free software; you can redistribute it and/or modify it under *
12 * terms of the GNU General Public License as published by the Free Soft- *
13 * ware Foundation; either version 2, or (at your option) any later ver- *
14 * sion. GNAT is distributed in the hope that it will be useful, but WITH- *
15 * OUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY *
16 * or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License *
17 * for more details. You should have received a copy of the GNU General *
18 * Public License distributed with GNAT; see file COPYING. If not, write *
19 * to the Free Software Foundation, 51 Franklin Street, Fifth Floor, *
20 * Boston, MA 02110-1301, USA. *
22 * As a special exception, if you link this file with other files to *
23 * produce an executable, this file does not by itself cause the resulting *
24 * executable to be covered by the GNU General Public License. This except- *
25 * ion does not however invalidate any other reasons why the executable *
26 * file might be covered by the GNU Public License. *
28 * GNAT was originally developed by the GNAT team at New York University. *
29 * Extensive contributions were provided by Ada Core Technologies Inc. *
31 ****************************************************************************/
33 /* This unit provides default implementation for __gnat_initialize ()
34 which is called before the elaboration of the partition. It is provided
35 in a separate file/object so that users can replace it easily.
36 The default implementation should be null on most targets. */
38 /* The following include is here to meet the published VxWorks requirement
39 that the __vxworks header appear before any other include. */
54 /******************************************/
55 /* __gnat_initialize (NT-mingw32 Version) */
56 /******************************************/
58 #if defined (__MINGW32__)
61 extern void __gnat_init_float (void);
62 extern void __gnat_plist_init (void);
63 extern void __gnat_install_SEH_handler (void *);
66 __gnat_initialize (void *eh
)
68 /* Initialize floating-point coprocessor. This call is needed because
69 the MS libraries default to 64-bit precision instead of 80-bit
70 precision, and we require the full precision for proper operation,
71 given that we have set Max_Digits etc with this in mind */
74 /* Initialize a lock for a process handle list - see adaint.c for the
75 implementation of __gnat_portable_no_block_spawn, __gnat_portable_wait */
78 /* Note that we do not activate this for the compiler itself to avoid a
79 bootstrap path problem. Older version of gnatbind will generate a call
80 to __gnat_initialize() without argument. Therefore we cannot use eh in
81 this case. It will be possible to remove the following #ifdef at some
84 /* Install the Structured Exception handler. */
86 __gnat_install_SEH_handler (eh
);
90 /******************************************/
91 /* __gnat_initialize (init_float version) */
92 /******************************************/
94 #elif defined (__INTERIX) || defined (__Lynx__) || \
95 defined (__FreeBSD__) || defined(__NetBSD__)
97 extern void __gnat_init_float (void);
100 __gnat_initialize (void *eh ATTRIBUTE_UNUSED
)
102 __gnat_init_float ();
105 /***************************************/
106 /* __gnat_initialize (VxWorks Version) */
107 /***************************************/
109 #elif defined(__vxworks)
111 extern void __gnat_init_float (void);
114 __gnat_initialize (void *eh
)
116 __gnat_init_float ();
118 /* On targets where we might be using the ZCX scheme, we need to register
121 For applications loaded as a set of "modules", the crtstuff objects
122 linked in (crtbegin/end) are tailored to provide this service a-la C++
123 constructor fashion, typically triggered by the VxWorks loader. This is
124 achieved by way of a special variable declaration in the crt object, the
125 name of which has been deduced by analyzing the output of the "munching"
126 step documented for C++. The de-registration is handled symetrically,
127 a-la C++ destructor fashion and typically triggered by the dynamic
128 unloader. Note that since the tables shall be registered against a
129 common datastructure, libgcc should be one of the modules (vs beeing
130 partially linked against all the others at build time) and shall be
133 For applications linked with the kernel, the scheme above would lead to
134 duplicated symbols because the VxWorks kernel build "munches" by default.
135 To prevent those conflicts, we link against crtbegin/endS objects that
136 don't include the special variable and directly call the appropriate
137 function here. We'll never unload that, so there is no de-registration to
140 For whole applications loaded as a single module, we may use one scheme
141 or the other, except for the mixed Ada/C++ case in which the first scheme
142 would fail for the same reason as in the linked-with-kernel situation.
144 We can differentiate by looking at the __module_has_ctors value provided
145 by each class of crt objects. As of today, selecting the crt set with the
146 ctors/dtors capabilities (first scheme above) is triggered by adding
147 "-dynamic" to the gcc *link* command line options. Selecting the other
148 set of crt objects is achieved by "-static" instead.
150 This is a first approach, tightly synchronized with a number of GCC
151 configuration and crtstuff changes. We need to ensure that those changes
152 are there to activate this circuitry. */
154 #if (__GNUC__ >= 3) && (defined (_ARCH_PPC) || defined (__ppc))
156 /* The scheme described above is only useful for the actual ZCX case, and
157 we don't want any reference to the crt provided symbols otherwise. We
158 may not link with any of the crt objects in the non-ZCX case, e.g. from
159 documented procedures instructing the use of -nostdlib, and references
160 to the ctors symbols here would just remain unsatisfied.
162 We have no way to avoid those references in the right conditions in this
163 C module, because we have nothing like a IN_ZCX_RTS macro. This aspect
164 is then deferred to an Ada routine, which can do that based on a test
165 against a constant System flag value. */
167 extern void __gnat_vxw_setup_for_eh (void);
168 __gnat_vxw_setup_for_eh ();
175 /* For all other versions of GNAT, the initialize routine and handler
176 installation do nothing */
178 /***************************************/
179 /* __gnat_initialize (Default Version) */
180 /***************************************/
183 __gnat_initialize (void *eh ATTRIBUTE_UNUSED
)