netware-crt0.c revision 169689
184865Sobrien/* Startup routines for NetWare. 2218822Sdim Contributed by Jan Beulich (jbeulich@novell.com) 3218822Sdim Copyright (C) 2004 Free Software Foundation, Inc. 484865Sobrien 584865SobrienThis file is part of GCC. 6104834Sobrien 784865SobrienGCC is free software; you can redistribute it and/or modify 8104834Sobrienit under the terms of the GNU General Public License as published by 9104834Sobrienthe Free Software Foundation; either version 2, or (at your option) 10104834Sobrienany later version. 11104834Sobrien 1284865SobrienGCC is distributed in the hope that it will be useful, 13104834Sobrienbut WITHOUT ANY WARRANTY; without even the implied warranty of 14104834SobrienMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15104834SobrienGNU General Public License for more details. 16104834Sobrien 1784865SobrienYou should have received a copy of the GNU General Public License 18104834Sobrienalong with GCC; see the file COPYING. If not, write to 19104834Sobrienthe Free Software Foundation, 51 Franklin Street, Fifth Floor, 20218822SdimBoston, MA 02110-1301, USA. */ 2184865Sobrien 22218822Sdim#include <stddef.h> 2384865Sobrien#include <stdint.h> 2484865Sobrien#include "unwind-dw2-fde.h" 2584865Sobrien 2684865Sobrienint __init_environment (void *); 2794536Sobrienint __deinit_environment (void *); 2884865Sobrien 2994536Sobrien 3084865Sobrien#define SECTION_DECL(name, decl) decl __attribute__((__section__(name))) 3184865Sobrien 3284865SobrienSECTION_DECL(".ctors", void(*const __CTOR_LIST__)(void)) 33218822Sdim = (void(*)(void))(intptr_t)-1; 34218822SdimSECTION_DECL(".ctors$_", void(*const __CTOR_END__)(void)) = NULL; 3584865Sobrien 3684865SobrienSECTION_DECL(".dtors", void(*const __DTOR_LIST__)(void)) 3784865Sobrien = (void(*)(void))(intptr_t)-1; 3884865SobrienSECTION_DECL(".dtors$_", void(*const __DTOR_END__)(void)) = NULL; 3984865Sobrien 4084865Sobrien/* No need to use the __[de]register_frame_info_bases functions since 4184865Sobrien for us the bases are NULL always anyway. */ 4284865Sobrienvoid __register_frame_info (const void *, struct object *) 4394536Sobrien __attribute__((__weak__)); 4494536Sobrienvoid *__deregister_frame_info (const void *) __attribute__((__weak__)); 4584865Sobrien 4684865SobrienSECTION_DECL(".eh_frame", /*const*/ uint32_t __EH_FRAME_BEGIN__[]) = { }; 4784865SobrienSECTION_DECL(".eh_frame$_", /*const*/ uint32_t __EH_FRAME_END__[]) = {0}; 4884865Sobrien 4984865Sobrienint 5084865Sobrien__init_environment (void *unused __attribute__((__unused__))) 5184865Sobrien{ 5284865Sobrien void (* const * pctor)(void); 5384865Sobrien static struct object object; 5484865Sobrien 5584865Sobrien if (__register_frame_info) 5684865Sobrien __register_frame_info (__EH_FRAME_BEGIN__, &object); 5784865Sobrien 5894536Sobrien for (pctor = &__CTOR_END__ - 1; pctor > &__CTOR_LIST__; --pctor) 5994536Sobrien if (*pctor != NULL) 6084865Sobrien (*pctor)(); 6184865Sobrien 6284865Sobrien return 0; 6384865Sobrien} 6484865Sobrien 6584865Sobrienint 6684865Sobrien__deinit_environment (void *unused __attribute__((__unused__))) 6784865Sobrien{ 6884865Sobrien /* This should be static to prevent calling the same destructor 69218822Sdim twice (just in case where we get here multiple times). */ 70218822Sdim static void (* const * pdtor)(void) = &__DTOR_LIST__ + 1; 7184865Sobrien 7284865Sobrien while (pdtor < &__DTOR_END__) 7384865Sobrien if (*pdtor++ != NULL) 7484865Sobrien pdtor[-1] (); 7584865Sobrien 7684865Sobrien if (__deregister_frame_info) 7784865Sobrien __deregister_frame_info(__EH_FRAME_BEGIN__); 7884865Sobrien 7994536Sobrien return 0; 8094536Sobrien} 8184865Sobrien