/* Copyright (C) 2008 Emmanuel Varoquaux This file is part of XOS. This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . */ #include "init-self.h" typedef void (*init_t)(int, char **, char **); typedef void (*fini_t)(); extern init_t __preinit_array_start[]; extern init_t __preinit_array_end[]; extern init_t __init_array_start[]; extern init_t __init_array_end[]; extern fini_t __fini_array_start[]; extern fini_t __fini_array_end[]; void _init(int argc, char **argv, char **envp); void _fini(); void __init(int argc, char **argv, char **envp) { int i; for (i = 0; i < __preinit_array_end - __preinit_array_start; i++) (*__preinit_array_start[i])(argc, argv, envp); _init(argc, argv, envp); for (i = 0; i < __init_array_end - __init_array_start; i++) (*__init_array_start[i])(argc, argv, envp); } void __fini() { int i; for (i = __fini_array_end - __fini_array_start; i-- > 0;) (*__fini_array_start[i])(); _fini(); }