diff options
Diffstat (limited to 'tools/build/cross-build')
-rw-r--r-- | tools/build/cross-build/capsicum_stubs.c | 67 | ||||
-rw-r--r-- | tools/build/cross-build/closefrom.c | 192 | ||||
-rw-r--r-- | tools/build/cross-build/fake_sysctl.c | 58 | ||||
-rw-r--r-- | tools/build/cross-build/fgetln_fallback.c | 84 | ||||
-rw-r--r-- | tools/build/cross-build/fgetwln_fallback.c | 93 | ||||
-rw-r--r-- | tools/build/cross-build/local-link.h | 38 | ||||
-rw-r--r-- | tools/build/cross-build/progname.c | 53 |
7 files changed, 585 insertions, 0 deletions
diff --git a/tools/build/cross-build/capsicum_stubs.c b/tools/build/cross-build/capsicum_stubs.c new file mode 100644 index 000000000000..b042796c069f --- /dev/null +++ b/tools/build/cross-build/capsicum_stubs.c @@ -0,0 +1,67 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org> + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <sys/types.h> +#include <sys/capsicum.h> + +#include <errno.h> + +int +cap_ioctls_limit(int fd, const cap_ioctl_t *cmds, size_t ncmds) +{ + return 0; /* Just pretend that it succeeded */ +} + +int +cap_fcntls_limit(int fd, uint32_t fcntlrights) +{ + return 0; /* Just pretend that it succeeded */ +} + +int +cap_rights_limit(int fd, const cap_rights_t *rights) +{ + return 0; /* Just pretend that it succeeded */ +} + +int +cap_enter(void) +{ + errno = ENOSYS; + return -1; +} diff --git a/tools/build/cross-build/closefrom.c b/tools/build/cross-build/closefrom.c new file mode 100644 index 000000000000..9d037f0efe89 --- /dev/null +++ b/tools/build/cross-build/closefrom.c @@ -0,0 +1,192 @@ +/* + * Copyright (c) 2004-2005, 2007, 2010, 2012-2014 + * Todd C. Miller <Todd.Miller@courtesan.com> + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +// #include <config.h> + +#include <sys/types.h> +#include <unistd.h> +#include <stdio.h> +#ifdef STDC_HEADERS +# include <stdlib.h> +# include <stddef.h> +#else +# ifdef HAVE_STDLIB_H +# include <stdlib.h> +# endif +#endif /* STDC_HEADERS */ +#include <fcntl.h> +#include <limits.h> +#ifdef HAVE_PSTAT_GETPROC +# include <sys/param.h> +# include <sys/pstat.h> +#else +# ifdef HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) +# else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# ifdef HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# ifdef HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# ifdef HAVE_NDIR_H +# include <ndir.h> +# endif +# endif +#endif + +#ifndef OPEN_MAX +# define OPEN_MAX 256 +#endif + +#if defined(HAVE_FCNTL_CLOSEM) && !defined(HAVE_DIRFD) +# define closefrom closefrom_fallback +#endif + +static inline void +closefrom_close(int fd) +{ +#ifdef __APPLE__ + /* Avoid potential libdispatch crash when we close its fds. */ + (void)fcntl(fd, F_SETFD, FD_CLOEXEC); +#else + (void)close(fd); +#endif +} + +/* + * Close all file descriptors greater than or equal to lowfd. + * This is the expensive (fallback) method. + */ +void +closefrom_fallback(int lowfd) +{ + long fd, maxfd; + + /* + * Fall back on sysconf() or getdtablesize(). We avoid checking + * resource limits since it is possible to open a file descriptor + * and then drop the rlimit such that it is below the open fd. + */ +#ifdef HAVE_SYSCONF + maxfd = sysconf(_SC_OPEN_MAX); +#else + maxfd = getdtablesize(); +#endif /* HAVE_SYSCONF */ + if (maxfd < 0) + maxfd = OPEN_MAX; + + for (fd = lowfd; fd < maxfd; fd++) + closefrom_close(fd); +} + +/* + * Close all file descriptors greater than or equal to lowfd. + * We try the fast way first, falling back on the slow method. + */ +#if defined(HAVE_FCNTL_CLOSEM) +void +closefrom(int lowfd) +{ + if (fcntl(lowfd, F_CLOSEM, 0) == -1) + closefrom_fallback(lowfd); +} +#elif defined(HAVE_PSTAT_GETPROC) +void +closefrom(int lowfd) +{ + struct pst_status pstat; + int fd; + + if (pstat_getproc(&pstat, sizeof(pstat), 0, getpid()) != -1) { + for (fd = lowfd; fd <= pstat.pst_highestfd; fd++) + (void)close(fd); + } else { + closefrom_fallback(lowfd); + } +} +#elif defined(HAVE_DIRFD) +static int +closefrom_procfs(int lowfd) +{ + const char *path; + DIR *dirp; + struct dirent *dent; + int *fd_array = NULL; + int fd_array_used = 0; + int fd_array_size = 0; + int ret = 0; + int i; + + /* Use /proc/self/fd (or /dev/fd on FreeBSD) if it exists. */ +# if defined(__FreeBSD__) || defined(__FreeBSD_kernel__) || defined(__APPLE__) + path = "/dev/fd"; +# else + path = "/proc/self/fd"; +# endif + dirp = opendir(path); + if (dirp == NULL) + return -1; + + while ((dent = readdir(dirp)) != NULL) { + const char *errstr; + int fd; + + fd = strtonum(dent->d_name, lowfd, INT_MAX, &errstr); + if (errstr != NULL || fd == dirfd(dirp)) + continue; + + if (fd_array_used >= fd_array_size) { + int *ptr; + + if (fd_array_size > 0) + fd_array_size *= 2; + else + fd_array_size = 32; + + ptr = reallocarray(fd_array, fd_array_size, sizeof(int)); + if (ptr == NULL) { + ret = -1; + break; + } + fd_array = ptr; + } + + fd_array[fd_array_used++] = fd; + } + + for (i = 0; i < fd_array_used; i++) + closefrom_close(fd_array[i]); + + free(fd_array); + (void)closedir(dirp); + + return ret; +} + +void +closefrom(int lowfd) +{ + if (closefrom_procfs(lowfd) == 0) + return; + + closefrom_fallback(lowfd); +} +#endif /* HAVE_FCNTL_CLOSEM */ diff --git a/tools/build/cross-build/fake_sysctl.c b/tools/build/cross-build/fake_sysctl.c new file mode 100644 index 000000000000..7b9524e1626b --- /dev/null +++ b/tools/build/cross-build/fake_sysctl.c @@ -0,0 +1,58 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org> + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +/* This file contains wrappers for sysctls used during build/install */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <err.h> +#include <string.h> +#include <sysexits.h> + +int +__freebsd_sysctlbyname( + const char *name, void *oldp, size_t *oldlenp, void *newp, size_t newlen) +{ + if (strcmp(name, "kern.vm_guest") == 0) { + if (!oldp || !oldlenp) + errx(EX_USAGE, "Missing arguments for kern.vm_guest"); + + if (newp || newlen) + errx(EX_USAGE, "kern.vm_guest is read-only"); + strlcpy(oldp, "none", *oldlenp); + *oldlenp = strlen("none"); + } + errx(EX_USAGE, "fatal: unknown sysctl %s\n", name); +} diff --git a/tools/build/cross-build/fgetln_fallback.c b/tools/build/cross-build/fgetln_fallback.c new file mode 100644 index 000000000000..9bd202c125da --- /dev/null +++ b/tools/build/cross-build/fgetln_fallback.c @@ -0,0 +1,84 @@ +/* + * Copyright © 2005 Hector Garcia Alvarez + * Copyright © 2005, 2008-2012 Guillem Jover <guillem@hadrons.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <stdio.h> +#include <sys/cdefs.h> +#include <sys/types.h> +#include <string.h> + +#include "local-link.h" + +#define HAVE_GETLINE 1 +#ifdef HAVE_GETLINE +struct filebuf { + FILE *fp; + char *buf; + size_t len; +}; + +#define FILEBUF_POOL_ITEMS 32 + +static struct filebuf fb_pool[FILEBUF_POOL_ITEMS]; +static int fb_pool_cur; + +char * +fgetln(FILE *stream, size_t *len) +{ + struct filebuf *fb; + ssize_t nread; + + flockfile(stream); + + /* Try to diminish the possibility of several fgetln() calls being + * used on different streams, by using a pool of buffers per file. */ + fb = &fb_pool[fb_pool_cur]; + if (fb->fp != stream && fb->fp != NULL) { + fb_pool_cur++; + fb_pool_cur %= FILEBUF_POOL_ITEMS; + fb = &fb_pool[fb_pool_cur]; + } + fb->fp = stream; + + nread = getline(&fb->buf, &fb->len, stream); + + funlockfile(stream); + + /* Note: the getdelim/getline API ensures nread != 0. */ + if (nread == -1) { + *len = 0; + return NULL; + } else { + *len = (size_t)nread; + return fb->buf; + } +} +libbsd_link_warning(fgetln, + "This function cannot be safely ported, use getline(3) " + "instead, as it is supported by GNU and POSIX.1-2008.") +#else +#error "Function fgetln() needs to be ported." +#endif diff --git a/tools/build/cross-build/fgetwln_fallback.c b/tools/build/cross-build/fgetwln_fallback.c new file mode 100644 index 000000000000..17254743fbc4 --- /dev/null +++ b/tools/build/cross-build/fgetwln_fallback.c @@ -0,0 +1,93 @@ +/* + * Copyright 2012 Guillem Jover <guillem@hadrons.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#include <sys/cdefs.h> + +#include <stdlib.h> +#include <stdio.h> +#include <wchar.h> + +#include "local-link.h" + +struct filewbuf { + FILE *fp; + wchar_t *wbuf; + size_t len; +}; + +#define FILEWBUF_INIT_LEN 128 +#define FILEWBUF_POOL_ITEMS 32 + +static struct filewbuf fb_pool[FILEWBUF_POOL_ITEMS]; +static int fb_pool_cur; + +wchar_t * +fgetwln(FILE *stream, size_t *lenp) +{ + struct filewbuf *fb; + wint_t wc; + size_t wused = 0; + + /* Try to diminish the possibility of several fgetwln() calls being + * used on different streams, by using a pool of buffers per file. */ + fb = &fb_pool[fb_pool_cur]; + if (fb->fp != stream && fb->fp != NULL) { + fb_pool_cur++; + fb_pool_cur %= FILEWBUF_POOL_ITEMS; + fb = &fb_pool[fb_pool_cur]; + } + fb->fp = stream; + + while ((wc = fgetwc(stream)) != WEOF) { + if (!fb->len || wused >= fb->len) { + wchar_t *wp; + + if (fb->len) + fb->len *= 2; + else + fb->len = FILEWBUF_INIT_LEN; + + wp = reallocarray(fb->wbuf, fb->len, sizeof(wchar_t)); + if (wp == NULL) { + wused = 0; + break; + } + fb->wbuf = wp; + } + + fb->wbuf[wused++] = wc; + + if (wc == L'\n') + break; + } + + *lenp = wused; + return wused ? fb->wbuf : NULL; +} + +libbsd_link_warning(fgetwln, + "This function cannot be safely ported, use fgetwc(3) " + "instead, as it is supported by C99 and POSIX.1-2001.") diff --git a/tools/build/cross-build/local-link.h b/tools/build/cross-build/local-link.h new file mode 100644 index 000000000000..a7534b22be68 --- /dev/null +++ b/tools/build/cross-build/local-link.h @@ -0,0 +1,38 @@ +/* + * Copyright © 2015 Guillem Jover <guillem@hadrons.org> + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * 3. The name of the author may not be used to endorse or promote products + * derived from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, + * INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY + * AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL + * THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; + * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +#ifndef LIBBSD_LOCAL_LINK_H +#define LIBBSD_LOCAL_LINK_H + +#ifdef notyet +#define libbsd_link_warning(symbol, msg) \ + static const char libbsd_emit_link_warning_##symbol[] \ + __attribute__((__used__,__section__(".gnu.warning." #symbol))) = msg; +#else +#define libbsd_link_warning(symbol, msg) +#endif + +#endif diff --git a/tools/build/cross-build/progname.c b/tools/build/cross-build/progname.c new file mode 100644 index 000000000000..645227df48d7 --- /dev/null +++ b/tools/build/cross-build/progname.c @@ -0,0 +1,53 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright 2018-2020 Alex Richardson <arichardson@FreeBSD.org> + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory (Department of Computer Science and + * Technology) under DARPA contract HR0011-18-C-0016 ("ECATS"), as part of the + * DARPA SSITH research programme. + * + * This software was developed by SRI International and the University of + * Cambridge Computer Laboratory under DARPA/AFRL contract (FA8750-10-C-0237) + * ("CTSRD"), as part of the DARPA CRASH research programme. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * 1. Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * 2. Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND + * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE + * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE + * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE + * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL + * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS + * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) + * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT + * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY + * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF + * SUCH DAMAGE. + */ +#include <sys/cdefs.h> +__FBSDID("$FreeBSD$"); + +#include <stdlib.h> + +#ifdef __GLIBC__ +extern const char *__progname; +const char * +getprogname(void) +{ + return (__progname); +} +void +setprogname(const char *progname) +{ + __progname = progname; +} +#endif /* __GLIBC__ */ |