/* 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 #include "xos.h" #include "misc.h" #include static int execve_internal(const char *path, char *const argv[], char *const envp[]) { return __syscall_exec(path, argv, envp); } int __attribute__ ((weak, visibility ("default"))) execve(const char *path, char *const argv[], char *const envp[]) { return execve_internal(path, argv, envp); } int __attribute__ ((weak, visibility ("default"))) execv(const char *path, char *const argv[]) { return execve_internal(path, argv, environ); } int __attribute__ ((weak, visibility ("default"))) execle(const char *path, ...) { const char *argv[1024], *const *envp; unsigned int i; va_list ap; va_start(ap, path); i = 0; do argv[i] = va_arg(ap, const char *); while (argv[i++]); envp = va_arg(ap, const char *const *); va_end(ap); return execve_internal(path, const_cast(char *const *, argv), const_cast(char *const *, envp)); } int __attribute__ ((weak, visibility ("default"))) execl(const char *path, ...) { const char *argv[1024]; unsigned int i; va_list ap; va_start(ap, path); i = 0; do argv[i] = va_arg(ap, const char *); while (argv[i++]); va_end(ap); return execve_internal(path, const_cast(char *const *, argv), environ); }