diff options
Diffstat (limited to 'tools/build/cross-build')
85 files changed, 341 insertions, 208 deletions
diff --git a/tools/build/cross-build/Makefile b/tools/build/cross-build/Makefile index 69c1e9c49844..3c51dae472ef 100644 --- a/tools/build/cross-build/Makefile +++ b/tools/build/cross-build/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - NO_OBJ= SCRIPTS= date.sh hostname.sh BINDIR= /usr/bin diff --git a/tools/build/cross-build/capsicum_stubs.c b/tools/build/cross-build/capsicum_stubs.c index 227ef3496b09..75eff8534fc4 100644 --- a/tools/build/cross-build/capsicum_stubs.c +++ b/tools/build/cross-build/capsicum_stubs.c @@ -33,8 +33,6 @@ * 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> diff --git a/tools/build/cross-build/date.sh b/tools/build/cross-build/date.sh index f697a7f0cd54..4e8cd150147a 100644 --- a/tools/build/cross-build/date.sh +++ b/tools/build/cross-build/date.sh @@ -1,6 +1,5 @@ #!/bin/sh # -# $FreeBSD$ # exec /bin/date -r0 "$@" diff --git a/tools/build/cross-build/fake_chflags/Makefile b/tools/build/cross-build/fake_chflags/Makefile index c4559be0e778..f5b867d50939 100644 --- a/tools/build/cross-build/fake_chflags/Makefile +++ b/tools/build/cross-build/fake_chflags/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - NO_OBJ= SCRIPTS= chflags BINDIR= /usr/bin diff --git a/tools/build/cross-build/fake_chflags/chflags b/tools/build/cross-build/fake_chflags/chflags index cd9becba5112..7baa4712636f 100644 --- a/tools/build/cross-build/fake_chflags/chflags +++ b/tools/build/cross-build/fake_chflags/chflags @@ -34,7 +34,6 @@ # OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF # SUCH DAMAGE. # -# $FreeBSD$ # # chflags doesn't exist on Linux, just skip the calls for now # TODO: we could also create a wrapper that calls `chattr +i` for `chflags schg`, etc diff --git a/tools/build/cross-build/fake_sysctl.c b/tools/build/cross-build/fake_sysctl.c index 289fb83652f6..c4e40ebb9e72 100644 --- a/tools/build/cross-build/fake_sysctl.c +++ b/tools/build/cross-build/fake_sysctl.c @@ -35,8 +35,6 @@ */ /* This file contains wrappers for sysctls used during build/install */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <sys/sysctl.h> #include <err.h> @@ -55,6 +53,7 @@ __freebsd_sysctlbyname(const char *name, void *oldp, size_t *oldlenp, errx(EX_USAGE, "kern.vm_guest is read-only"); strlcpy(oldp, "none", *oldlenp); *oldlenp = strlen("none"); + return (0); } 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 index 9bd202c125da..000cd38ce596 100644 --- a/tools/build/cross-build/fgetln_fallback.c +++ b/tools/build/cross-build/fgetln_fallback.c @@ -26,7 +26,7 @@ */ #include <stdio.h> -#include <sys/cdefs.h> + #include <sys/types.h> #include <string.h> diff --git a/tools/build/cross-build/hostname.sh b/tools/build/cross-build/hostname.sh index 855741beca85..24aaeb8e2a29 100644 --- a/tools/build/cross-build/hostname.sh +++ b/tools/build/cross-build/hostname.sh @@ -1,6 +1,5 @@ #!/bin/sh # -# $FreeBSD$ # echo dummy diff --git a/tools/build/cross-build/include/common/db.h b/tools/build/cross-build/include/common/db.h index 8e429abc792f..ac00000cda6e 100644 --- a/tools/build/cross-build/include/common/db.h +++ b/tools/build/cross-build/include/common/db.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/exterr.h b/tools/build/cross-build/include/common/exterr.h new file mode 100644 index 000000000000..62482841c7b2 --- /dev/null +++ b/tools/build/cross-build/include/common/exterr.h @@ -0,0 +1,14 @@ +#ifndef _EXTERR_H_ +#define _EXTERR_H_ + +#include <sys/types.h> + +static inline int +uexterr_gettext(char *buf, size_t bufsz) +{ + if (bufsz > 0) + buf[0] = '\0'; + return (0); +} + +#endif diff --git a/tools/build/cross-build/include/common/getopt.h b/tools/build/cross-build/include/common/getopt.h index 621011d69c1c..9db08597351e 100644 --- a/tools/build/cross-build/include/common/getopt.h +++ b/tools/build/cross-build/include/common/getopt.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/grp.h b/tools/build/cross-build/include/common/grp.h index 750e1e9a49f6..b666209d928b 100644 --- a/tools/build/cross-build/include/common/grp.h +++ b/tools/build/cross-build/include/common/grp.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/libcasper.h b/tools/build/cross-build/include/common/libcasper.h index dd5afa9a0573..b41b212d3085 100644 --- a/tools/build/cross-build/include/common/libcasper.h +++ b/tools/build/cross-build/include/common/libcasper.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/libelf.h b/tools/build/cross-build/include/common/libelf.h index 5bbd34777648..be77a08eb3e2 100644 --- a/tools/build/cross-build/include/common/libelf.h +++ b/tools/build/cross-build/include/common/libelf.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once /* Needed to get opensolaris stuff to compile */ diff --git a/tools/build/cross-build/include/common/libutil.h b/tools/build/cross-build/include/common/libutil.h index 5e4e0422d3b2..3cda32379965 100644 --- a/tools/build/cross-build/include/common/libutil.h +++ b/tools/build/cross-build/include/common/libutil.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once @@ -41,4 +39,4 @@ #include_next <libutil.h> #endif -int expand_number(const char *_buf, uint64_t *_num); +int expand_number(const char *_buf, int64_t *_num); diff --git a/tools/build/cross-build/include/common/machine/endian.h b/tools/build/cross-build/include/common/machine/endian.h index d70b60ca39f7..8a05f636d1f7 100644 --- a/tools/build/cross-build/include/common/machine/endian.h +++ b/tools/build/cross-build/include/common/machine/endian.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #if __has_include_next(<machine/endian.h>) #include_next <machine/endian.h> diff --git a/tools/build/cross-build/include/common/netconfig.h b/tools/build/cross-build/include/common/netconfig.h index 95f3bb94d2f4..c592b4076bb6 100644 --- a/tools/build/cross-build/include/common/netconfig.h +++ b/tools/build/cross-build/include/common/netconfig.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/netdb.h b/tools/build/cross-build/include/common/netdb.h index 350174ebde9b..b2cf0b6fb305 100644 --- a/tools/build/cross-build/include/common/netdb.h +++ b/tools/build/cross-build/include/common/netdb.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <netdb.h> diff --git a/tools/build/cross-build/include/common/osreldate.h b/tools/build/cross-build/include/common/osreldate.h index 801cc5e41210..714351e9cb59 100644 --- a/tools/build/cross-build/include/common/osreldate.h +++ b/tools/build/cross-build/include/common/osreldate.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/pwd.h b/tools/build/cross-build/include/common/pwd.h index 109119e9bfe3..a34955a63780 100644 --- a/tools/build/cross-build/include/common/pwd.h +++ b/tools/build/cross-build/include/common/pwd.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/ssp/ssp.h b/tools/build/cross-build/include/common/ssp/ssp.h new file mode 100644 index 000000000000..2d8b43235baf --- /dev/null +++ b/tools/build/cross-build/include/common/ssp/ssp.h @@ -0,0 +1,34 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2024 Jessica Clarke <jrtc27@FreeBSD.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. + * + * 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. + */ + +#ifndef _SSP_SSP_H_ +#define _SSP_SSP_H_ + +#define __ssp_real_(fun) fun +#define __ssp_real(fun) __ssp_real_(fun) + +#endif diff --git a/tools/build/cross-build/include/common/string.h b/tools/build/cross-build/include/common/string.h index 8a33f4d4ff19..56909e9bca0a 100644 --- a/tools/build/cross-build/include/common/string.h +++ b/tools/build/cross-build/include/common/string.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/_iovec.h b/tools/build/cross-build/include/common/sys/_iovec.h index 89f09c7c7d27..35b290bd3dbf 100644 --- a/tools/build/cross-build/include/common/sys/_iovec.h +++ b/tools/build/cross-build/include/common/sys/_iovec.h @@ -32,7 +32,5 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/_null.h b/tools/build/cross-build/include/common/sys/_null.h index 5b65c8c3ebf8..8be996a8fbde 100644 --- a/tools/build/cross-build/include/common/sys/_null.h +++ b/tools/build/cross-build/include/common/sys/_null.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/_types.h b/tools/build/cross-build/include/common/sys/_types.h index 129eaf52357d..dc1b76f25063 100644 --- a/tools/build/cross-build/include/common/sys/_types.h +++ b/tools/build/cross-build/include/common/sys/_types.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once @@ -47,3 +45,9 @@ * Neither GLibc nor macOS define __va_list but many FreeBSD headers require it. */ typedef __builtin_va_list __va_list; + +/* Needed for opensolaris compat. */ +typedef __int64_t off64_t; + +/* Needed for sys/_callout.h */ +typedef __int64_t __sbintime_t; diff --git a/tools/build/cross-build/include/common/sys/cdefs.h b/tools/build/cross-build/include/common/sys/cdefs.h index d69e4369e01e..faad5eccb3af 100644 --- a/tools/build/cross-build/include/common/sys/cdefs.h +++ b/tools/build/cross-build/include/common/sys/cdefs.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once /* musl libc does not provide a sys/cdefs.h header */ @@ -123,6 +121,12 @@ #endif #endif +#ifndef __WEAK +#ifdef __ELF__ +#define __WEAK(sym) __asm__(".weak " __XSTRING(sym)) +#endif +#endif + /* Some files built as part of the bootstrap libegacy use these macros, but * since we aren't actually building libc.so, we can defined them to be empty */ #ifndef __sym_compat @@ -251,6 +255,13 @@ #define __DEQUALIFY(type, var) ((type)(__uintptr_t)(const volatile void *)(var)) #endif +#ifndef __nosanitizeaddress +#if __has_attribute(no_sanitize) && defined(__clang__) +#define __nosanitizeaddress __attribute__((no_sanitize("address"))) +#else +#define __nosanitizeaddress +#endif +#endif /* Expose all declarations when using FreeBSD headers */ #define __POSIX_VISIBLE 200809 @@ -259,6 +270,16 @@ #define __ISO_C_VISIBLE 2011 #define __EXT1_VISIBLE 1 +/* + * Macro to test if we're using a specific version of gcc or later. + */ +#if defined(__GNUC__) +#define __GNUC_PREREQ__(ma, mi) \ + (__GNUC__ > (ma) || __GNUC__ == (ma) && __GNUC_MINOR__ >= (mi)) +#else +#define __GNUC_PREREQ__(ma, mi) 0 +#endif + /* Alignment builtins for better type checking and improved code generation. */ /* Provide fallback versions for other compilers (GCC/Clang < 10): */ #if !__has_builtin(__builtin_is_aligned) diff --git a/tools/build/cross-build/include/common/sys/ctype.h b/tools/build/cross-build/include/common/sys/ctype.h index 68a4f9807ca7..ed218e19ffc7 100644 --- a/tools/build/cross-build/include/common/sys/ctype.h +++ b/tools/build/cross-build/include/common/sys/ctype.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include <ctype.h> diff --git a/tools/build/cross-build/include/common/sys/exterrvar.h b/tools/build/cross-build/include/common/sys/exterrvar.h new file mode 100644 index 000000000000..0ba821aadef2 --- /dev/null +++ b/tools/build/cross-build/include/common/sys/exterrvar.h @@ -0,0 +1,6 @@ +#ifndef _SYS_EXTERRVAR_H_ +#define _SYS_EXTERRVAR_H_ + +#define UEXTERROR_MAXLEN 256 + +#endif diff --git a/tools/build/cross-build/include/common/sys/limits.h b/tools/build/cross-build/include/common/sys/limits.h index 01fbe99c863a..04c422ed426f 100644 --- a/tools/build/cross-build/include/common/sys/limits.h +++ b/tools/build/cross-build/include/common/sys/limits.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #include <limits.h> #if __has_include_next(<sys/limits.h>) diff --git a/tools/build/cross-build/include/common/sys/mman.h b/tools/build/cross-build/include/common/sys/mman.h index f3ce83fd1df8..de8657aff304 100644 --- a/tools/build/cross-build/include/common/sys/mman.h +++ b/tools/build/cross-build/include/common/sys/mman.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/param.h b/tools/build/cross-build/include/common/sys/param.h index f672b1067d46..c09cd9865a93 100644 --- a/tools/build/cross-build/include/common/sys/param.h +++ b/tools/build/cross-build/include/common/sys/param.h @@ -35,8 +35,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/stdint.h b/tools/build/cross-build/include/common/sys/stdint.h index 98f7010b308d..a97052244343 100644 --- a/tools/build/cross-build/include/common/sys/stdint.h +++ b/tools/build/cross-build/include/common/sys/stdint.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #if defined(__has_include_next) && __has_include_next(<sys/stdint.h>) diff --git a/tools/build/cross-build/include/common/sys/sysctl.h b/tools/build/cross-build/include/common/sys/sysctl.h index 6d6f5438c557..3d7ecc7a5b02 100644 --- a/tools/build/cross-build/include/common/sys/sysctl.h +++ b/tools/build/cross-build/include/common/sys/sysctl.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/common/sys/types.h b/tools/build/cross-build/include/common/sys/types.h index 044ca6bed4f8..18b607ed82d2 100644 --- a/tools/build/cross-build/include/common/sys/types.h +++ b/tools/build/cross-build/include/common/sys/types.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <sys/types.h> @@ -68,4 +66,8 @@ typedef unsigned long cap_ioctl_t; struct cap_rights; typedef struct cap_rights cap_rights_t; + +/* Needed for bitstring */ +#include <sys/bitcount.h> + #endif diff --git a/tools/build/cross-build/include/common/unistd.h b/tools/build/cross-build/include/common/unistd.h index fbcc0cc31795..19efc57005bd 100644 --- a/tools/build/cross-build/include/common/unistd.h +++ b/tools/build/cross-build/include/common/unistd.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <unistd.h> diff --git a/tools/build/cross-build/include/linux/__unused_workaround_end.h b/tools/build/cross-build/include/linux/__unused_workaround_end.h index eaf3d3a8f836..728e25ead9b0 100644 --- a/tools/build/cross-build/include/linux/__unused_workaround_end.h +++ b/tools/build/cross-build/include/linux/__unused_workaround_end.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ /* Used to workaround system headers with struct members called __unused */ #ifdef __unused_undefd diff --git a/tools/build/cross-build/include/linux/__unused_workaround_start.h b/tools/build/cross-build/include/linux/__unused_workaround_start.h index 2f0ab003ad24..e01d5fc9971d 100644 --- a/tools/build/cross-build/include/linux/__unused_workaround_start.h +++ b/tools/build/cross-build/include/linux/__unused_workaround_start.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ /* Used to workaround system headers with struct members called __unused */ #ifdef __unused diff --git a/tools/build/cross-build/include/linux/__used_workaround_end.h b/tools/build/cross-build/include/linux/__used_workaround_end.h index 99cc6c16ac26..d38c5711a30d 100644 --- a/tools/build/cross-build/include/linux/__used_workaround_end.h +++ b/tools/build/cross-build/include/linux/__used_workaround_end.h @@ -33,8 +33,6 @@ * 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. - * - * $FreeBSD$ */ /* Used to workaround system headers with struct members called __used */ #ifdef __used_undefd diff --git a/tools/build/cross-build/include/linux/__used_workaround_start.h b/tools/build/cross-build/include/linux/__used_workaround_start.h index ee290ce30169..c81e9c67248e 100644 --- a/tools/build/cross-build/include/linux/__used_workaround_start.h +++ b/tools/build/cross-build/include/linux/__used_workaround_start.h @@ -33,8 +33,6 @@ * 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. - * - * $FreeBSD$ */ /* Used to workaround system headers with struct members called __used */ #ifdef __used diff --git a/tools/build/cross-build/include/linux/ctype.h b/tools/build/cross-build/include/linux/ctype.h index fbd30580d1a9..afacebfbad91 100644 --- a/tools/build/cross-build/include/linux/ctype.h +++ b/tools/build/cross-build/include/linux/ctype.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <ctype.h> diff --git a/tools/build/cross-build/include/linux/endian.h b/tools/build/cross-build/include/linux/endian.h index 92adf095636a..f4fc6855b398 100644 --- a/tools/build/cross-build/include/linux/endian.h +++ b/tools/build/cross-build/include/linux/endian.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <endian.h> diff --git a/tools/build/cross-build/include/linux/errno.h b/tools/build/cross-build/include/linux/errno.h index 37f166aebabf..b05c6bb02aae 100644 --- a/tools/build/cross-build/include/linux/errno.h +++ b/tools/build/cross-build/include/linux/errno.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <errno.h> diff --git a/tools/build/cross-build/include/linux/fcntl.h b/tools/build/cross-build/include/linux/fcntl.h index 4fa169d4ed4c..e5718ce5e3ed 100644 --- a/tools/build/cross-build/include/linux/fcntl.h +++ b/tools/build/cross-build/include/linux/fcntl.h @@ -35,8 +35,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once @@ -46,3 +44,10 @@ #include "__unused_workaround_end.h" #include <sys/file.h> + +/* + * On FreeBSD fcntl.h indirectly brings in cdefs.h. On Linux with musl, it does + * not. It's needed in our fcntl.h for the cross build since we use + * __BEGIN_DECLS and __END_DECLS from it there. + */ +#include <sys/cdefs.h> diff --git a/tools/build/cross-build/include/linux/libutil.h b/tools/build/cross-build/include/linux/libutil.h index 7a448babb9a8..a1d6508be82d 100644 --- a/tools/build/cross-build/include/linux/libutil.h +++ b/tools/build/cross-build/include/linux/libutil.h @@ -32,12 +32,9 @@ * 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. - * - * $FreeBSD$ */ #pragma once -#include <sys/cdefs.h> #include <sys/types.h> #include <sys/socket.h> @@ -49,7 +46,7 @@ struct pidfh; __BEGIN_DECLS int humanize_number(char *buf, size_t len, int64_t bytes, const char *suffix, int scale, int flags); -int expand_number(const char *_buf, uint64_t *_num); +int expand_number(const char *_buf, int64_t *_num); int flopen(const char *_path, int _flags, ...); int flopenat(int dirfd, const char *path, int flags, ...); diff --git a/tools/build/cross-build/include/linux/limits.h b/tools/build/cross-build/include/linux/limits.h index 833b49b49348..4631cabb1104 100644 --- a/tools/build/cross-build/include/linux/limits.h +++ b/tools/build/cross-build/include/linux/limits.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #if __has_include_next(<limits.h>) #include_next <limits.h> @@ -47,13 +45,11 @@ #if !defined(_GNU_SOURCE) #warning "Attempting to use limits.h with -std=c89/without _GNU_SOURCE, many macros will be missing" #endif +#endif /* C89 */ -#else /* Not C89 */ -/* Not C89 -> check that all macros that we expect are defined */ #ifndef IOV_MAX #error IOV_MAX should be defined #endif -#endif /* C89 */ #ifndef MAXBSIZE #define MAXBSIZE 65536 /* must be power of 2 */ @@ -85,7 +81,6 @@ #endif #include <sys/types.h> -#include <sys/uio.h> /* For IOV_MAX */ /* Sanity checks for glibc */ #ifndef _GNU_SOURCE diff --git a/tools/build/cross-build/include/linux/nbtool_config.h b/tools/build/cross-build/include/linux/nbtool_config.h index a3c39308a62f..d99b39739a48 100644 --- a/tools/build/cross-build/include/linux/nbtool_config.h +++ b/tools/build/cross-build/include/linux/nbtool_config.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/netdb.h b/tools/build/cross-build/include/linux/netdb.h index e1832cca3efa..2680b4736982 100644 --- a/tools/build/cross-build/include/linux/netdb.h +++ b/tools/build/cross-build/include/linux/netdb.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/regex.h b/tools/build/cross-build/include/linux/regex.h index a27053750c3e..858e26386653 100644 --- a/tools/build/cross-build/include/linux/regex.h +++ b/tools/build/cross-build/include/linux/regex.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <regex.h> diff --git a/tools/build/cross-build/include/linux/resolv.h b/tools/build/cross-build/include/linux/resolv.h index 99652b78825b..4d075a05ffa5 100644 --- a/tools/build/cross-build/include/linux/resolv.h +++ b/tools/build/cross-build/include/linux/resolv.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <resolv.h> diff --git a/tools/build/cross-build/include/linux/signal.h b/tools/build/cross-build/include/linux/signal.h index 5d4cdcd19fab..177c7f6169f0 100644 --- a/tools/build/cross-build/include/linux/signal.h +++ b/tools/build/cross-build/include/linux/signal.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/spawn.h b/tools/build/cross-build/include/linux/spawn.h index 873add3275af..a9b9f8de97a0 100644 --- a/tools/build/cross-build/include/linux/spawn.h +++ b/tools/build/cross-build/include/linux/spawn.h @@ -36,8 +36,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/stdio.h b/tools/build/cross-build/include/linux/stdio.h index c5aa893b320c..202b65508aeb 100644 --- a/tools/build/cross-build/include/linux/stdio.h +++ b/tools/build/cross-build/include/linux/stdio.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ /* No #pragam once since glibc can include this multiple times */ diff --git a/tools/build/cross-build/include/linux/stdlib.h b/tools/build/cross-build/include/linux/stdlib.h index 1e559ce1158c..66ac46239a41 100644 --- a/tools/build/cross-build/include/linux/stdlib.h +++ b/tools/build/cross-build/include/linux/stdlib.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include <sys/cdefs.h> diff --git a/tools/build/cross-build/include/linux/string.h b/tools/build/cross-build/include/linux/string.h index 1d173974a5bd..b6d2fe488d40 100644 --- a/tools/build/cross-build/include/linux/string.h +++ b/tools/build/cross-build/include/linux/string.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once @@ -46,11 +44,14 @@ */ #include <stdlib.h> -#include <sys/cdefs.h> +#include <sys/types.h> __BEGIN_DECLS +#if !defined(__GLIBC__) || \ + (defined(__GLIBC__) && (!__GLIBC_PREREQ(2, 38) || !defined(_GNU_SOURCE))) size_t strlcpy(char *dst, const char *src, size_t siz); size_t strlcat(char *dst, const char *src, size_t siz); +#endif char *strnstr(const char *str, const char *find, size_t str_len); void strmode(mode_t mode, char *str); diff --git a/tools/build/cross-build/fflags.c b/tools/build/cross-build/include/linux/strings.h index f1d23c3637b6..36e451f277eb 100644 --- a/tools/build/cross-build/fflags.c +++ b/tools/build/cross-build/include/linux/strings.h @@ -1,19 +1,7 @@ /*- * 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. - * - * This work was supported by Innovate UK project 105694, "Digital Security by - * Design (DSbD) Technology Platform Prototype". + * Copyright 2022 Jessica Clarke <jrtc27@FreeBSD.org> * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions @@ -36,27 +24,15 @@ * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF * SUCH DAMAGE. */ +#pragma once +#include <sys/cdefs.h> + +#include_next <strings.h> -#include <string.h> -#include <unistd.h> +__BEGIN_DECLS -char * -fflagstostr(u_long flags __unused) -{ - return strdup(""); -} +int fls(int) __pure2; +int flsl(long) __pure2; +int flsll(long long) __pure2; -int -strtofflags(char **stringp __unused, u_long *setp, u_long *clrp) -{ - /* On linux just ignore the file flags for now */ - /* - * XXX: this will prevent makefs from setting noschg on libc, etc. - * so we should really find a way to support flags in disk images. - */ - if (setp) - *setp = 0; - if (clrp) - *clrp = 0; - return (0); /* success */ -} +__END_DECLS diff --git a/tools/build/cross-build/include/linux/sys/disk.h b/tools/build/cross-build/include/linux/sys/disk.h index d4dc46768756..b0cd0ef16609 100644 --- a/tools/build/cross-build/include/linux/sys/disk.h +++ b/tools/build/cross-build/include/linux/sys/disk.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include <sys/mount.h> diff --git a/tools/build/cross-build/include/linux/sys/endian.h b/tools/build/cross-build/include/linux/sys/endian.h index 0c068a4793d5..085b3616c742 100644 --- a/tools/build/cross-build/include/linux/sys/endian.h +++ b/tools/build/cross-build/include/linux/sys/endian.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/sys/filio.h b/tools/build/cross-build/include/linux/sys/filio.h index 9433875ca5ec..7f9ffb8f92a2 100644 --- a/tools/build/cross-build/include/linux/sys/filio.h +++ b/tools/build/cross-build/include/linux/sys/filio.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/sys/ioccom.h b/tools/build/cross-build/include/linux/sys/ioccom.h index a70e20312940..021377abe471 100644 --- a/tools/build/cross-build/include/linux/sys/ioccom.h +++ b/tools/build/cross-build/include/linux/sys/ioccom.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include <sys/ioctl.h> diff --git a/tools/build/cross-build/include/linux/sys/mount.h b/tools/build/cross-build/include/linux/sys/mount.h index be66e8ca5b62..edd8e29da91a 100644 --- a/tools/build/cross-build/include/linux/sys/mount.h +++ b/tools/build/cross-build/include/linux/sys/mount.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <sys/mount.h> diff --git a/tools/build/cross-build/include/linux/sys/param.h b/tools/build/cross-build/include/linux/sys/param.h index 305d2767ae7e..3b29b9ef8430 100644 --- a/tools/build/cross-build/include/linux/sys/param.h +++ b/tools/build/cross-build/include/linux/sys/param.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <sys/param.h> @@ -47,3 +45,5 @@ * let's use 32 since that will work across all systems */ #define MAXLOGNAME 33 /* max login name length (incl. NUL) */ + +#include <sys/types.h> diff --git a/tools/build/cross-build/include/linux/sys/stat.h b/tools/build/cross-build/include/linux/sys/stat.h index 72c6bb950ce9..1a69e127c2e1 100644 --- a/tools/build/cross-build/include/linux/sys/stat.h +++ b/tools/build/cross-build/include/linux/sys/stat.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once /* @@ -60,5 +58,33 @@ #define S_ISTXT S_ISVTX #endif +#ifndef DEFFILEMODE +#define DEFFILEMODE (S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH) +#endif + +#ifndef ALLPERMS +#define ALLPERMS (S_ISUID | S_ISGID | S_ISTXT | S_IRWXU | S_IRWXG | S_IRWXO) +#endif + +#define UF_SETTABLE 0x0000ffff +#define UF_NODUMP 0x00000001 +#define UF_IMMUTABLE 0x00000002 +#define UF_APPEND 0x00000004 +#define UF_OPAQUE 0x00000008 +#define UF_NOUNLINK 0x00000010 +#define UF_SYSTEM 0x00000080 +#define UF_SPARSE 0x00000100 +#define UF_OFFLINE 0x00000200 +#define UF_REPARSE 0x00000400 +#define UF_ARCHIVE 0x00000800 +#define UF_READONLY 0x00001000 +#define UF_HIDDEN 0x00008000 +#define SF_SETTABLE 0xffff0000 +#define SF_ARCHIVED 0x00010000 +#define SF_IMMUTABLE 0x00020000 +#define SF_APPEND 0x00040000 +#define SF_NOUNLINK 0x00100000 +#define SF_SNAPSHOT 0x00200000 + /* This include is needed for OpenZFS bootstrap */ #include <sys/mount.h> diff --git a/tools/build/cross-build/include/linux/sys/time.h b/tools/build/cross-build/include/linux/sys/time.h index 1c86bb9ba85d..d78dd401545a 100644 --- a/tools/build/cross-build/include/linux/sys/time.h +++ b/tools/build/cross-build/include/linux/sys/time.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/sys/ttycom.h b/tools/build/cross-build/include/linux/sys/ttycom.h index 8a1f7cf7c3d6..8f2cbf121e42 100644 --- a/tools/build/cross-build/include/linux/sys/ttycom.h +++ b/tools/build/cross-build/include/linux/sys/ttycom.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/sys/types.h b/tools/build/cross-build/include/linux/sys/types.h index b3bb61c1f1fd..2e09cbb62271 100644 --- a/tools/build/cross-build/include/linux/sys/types.h +++ b/tools/build/cross-build/include/linux/sys/types.h @@ -32,13 +32,39 @@ * 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. - * - * $FreeBSD$ */ #pragma once +#include <sys/cdefs.h> /* FreeBSD source assumes sys/types.h includes this */ +/* + * MUSL doesn't define the __intXX_t that FreeBSD does, but many of our headers + * assume that will always be present. Define them here. We assume !defined + * __GLIBC__ is musl since musl doesn't have a define to key off of. Thesee + * typedefs look backwards, but it's not circular because MUSL never defines the + * __*int*_t. Also, we don't have to work in the kernel, so it's OK to include + * stdint.h here. + */ +#ifndef __GLIBC__ +#include <stdint.h> +typedef int64_t __int64_t; +typedef int32_t __int32_t; +typedef int16_t __int16_t; +typedef int8_t __int8_t; +typedef uint64_t __uint64_t; +typedef uint32_t __uint32_t; +typedef uint16_t __uint16_t; +typedef uint8_t __uint8_t; +#endif + #include_next <sys/types.h> +/* + * stddef.h for both gcc and clang will define __size_t when size_t has + * been defined (except on *BSD where it doesn't touch __size_t). So if + * we're building on Linux, we know that if that's not defined, we have + * to typedef __size_t for FreeBSD's use of __size_t in places to work + * during bootstrapping. + */ #ifndef __size_t typedef __SIZE_TYPE__ __size_t; #endif diff --git a/tools/build/cross-build/include/linux/sys/ucred.h b/tools/build/cross-build/include/linux/sys/ucred.h index 89f09c7c7d27..35b290bd3dbf 100644 --- a/tools/build/cross-build/include/linux/sys/ucred.h +++ b/tools/build/cross-build/include/linux/sys/ucred.h @@ -32,7 +32,5 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/linux/time.h b/tools/build/cross-build/include/linux/time.h index 189f1f266916..bc3c4c81021b 100644 --- a/tools/build/cross-build/include/linux/time.h +++ b/tools/build/cross-build/include/linux/time.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ /* We can't use #pragma once here since at least the version of time.h * shipped with glibc must be included more than once with different diff --git a/tools/build/cross-build/include/linux/unistd.h b/tools/build/cross-build/include/linux/unistd.h index f518df2ac9ae..ce179724e17b 100644 --- a/tools/build/cross-build/include/linux/unistd.h +++ b/tools/build/cross-build/include/linux/unistd.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once @@ -41,17 +39,9 @@ /* Ensure that unistd.h pulls in getopt */ #define __USE_POSIX2 #endif -/* - * Before version 2.25, glibc's unistd.h would define the POSIX subset of - * getopt.h by defining __need_getopt, including getopt.h (which would - * disable the header guard) and then undefining it so later including - * getopt.h explicitly would define the extensions. However, we wrap getopt, - * and so the wrapper's #pragma once breaks that. Thus getopt.h must be - * included before the real unistd.h to ensure we get all the extensions. - */ -#include <getopt.h> #include_next <unistd.h> #include <fcntl.h> +#include <getopt.h> #include <stdlib.h> #include <string.h> #include <sys/syscall.h> diff --git a/tools/build/cross-build/include/linux/wctype.h b/tools/build/cross-build/include/linux/wctype.h index 8c4a44d8bbe3..044a34fbd16b 100644 --- a/tools/build/cross-build/include/linux/wctype.h +++ b/tools/build/cross-build/include/linux/wctype.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <wctype.h> diff --git a/tools/build/cross-build/include/mac/endian.h b/tools/build/cross-build/include/mac/endian.h new file mode 100644 index 000000000000..11788044f05a --- /dev/null +++ b/tools/build/cross-build/include/mac/endian.h @@ -0,0 +1,7 @@ +/* + * Copyright (c) 2025 John Baldwin <jhb@FreeBSD.org> + * + * SPDX-License-Identifier: BSD-2-Clause + */ + +#include <sys/endian.h> diff --git a/tools/build/cross-build/include/mac/libutil.h b/tools/build/cross-build/include/mac/libutil.h index 5812e58ed39f..2f654986a06f 100644 --- a/tools/build/cross-build/include/mac/libutil.h +++ b/tools/build/cross-build/include/mac/libutil.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/mac/nbtool_config.h b/tools/build/cross-build/include/mac/nbtool_config.h index cb1bf1a0b655..db5903b9adf3 100644 --- a/tools/build/cross-build/include/mac/nbtool_config.h +++ b/tools/build/cross-build/include/mac/nbtool_config.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/mac/signal.h b/tools/build/cross-build/include/mac/signal.h index cdcaab75f326..9c2ccca21da2 100644 --- a/tools/build/cross-build/include/mac/signal.h +++ b/tools/build/cross-build/include/mac/signal.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <signal.h> diff --git a/tools/build/cross-build/include/mac/stdlib.h b/tools/build/cross-build/include/mac/stdlib.h index 314ae0d1dca6..7e84039d29ad 100644 --- a/tools/build/cross-build/include/mac/stdlib.h +++ b/tools/build/cross-build/include/mac/stdlib.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <stdlib.h> @@ -42,6 +40,7 @@ __BEGIN_DECLS int rpmatch(const char *response); +char *secure_getenv(const char *name); long long strtonum(const char *numstr, long long minval, long long maxval, const char **errstrp); diff --git a/tools/build/cross-build/include/mac/string.h b/tools/build/cross-build/include/mac/string.h index 3f9ec4935a37..58464f1f9834 100644 --- a/tools/build/cross-build/include/mac/string.h +++ b/tools/build/cross-build/include/mac/string.h @@ -32,17 +32,18 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <string.h> /* - * strchrnul is not provided by macOS and the strchrnul.c implementation - * can not be compiled on macOS so just provide it inline here + * strchrnul is provided by macOS 15.4 and later. However, there is + * no good way to detect the current host version at compile time, so + * provide an inline definition under an alternate name. */ +#define strchrnul(p, ch) __freebsd_strchrnul(p, ch) + static inline char * strchrnul(const char *p, int ch) { diff --git a/tools/build/cross-build/include/mac/sys/_types.h b/tools/build/cross-build/include/mac/sys/_types.h index fd14a7836792..8d39fc39f087 100644 --- a/tools/build/cross-build/include/mac/sys/_types.h +++ b/tools/build/cross-build/include/mac/sys/_types.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <sys/_types.h> @@ -43,5 +41,3 @@ * __darwin_ct_rune_t exists. */ typedef __darwin_ct_rune_t __ct_rune_t; -/* Needed for opensolaris compat. */ -typedef __int64_t off64_t; diff --git a/tools/build/cross-build/include/mac/sys/endian.h b/tools/build/cross-build/include/mac/sys/endian.h index f64a6d47beaf..64f548e6dc50 100644 --- a/tools/build/cross-build/include/mac/sys/endian.h +++ b/tools/build/cross-build/include/mac/sys/endian.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/include/mac/sys/linker_set.h b/tools/build/cross-build/include/mac/sys/linker_set.h new file mode 100644 index 000000000000..c0b81747c78b --- /dev/null +++ b/tools/build/cross-build/include/mac/sys/linker_set.h @@ -0,0 +1,140 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 1999 John D. Polstra + * Copyright (c) 1999,2001 Peter Wemm <peter@FreeBSD.org> + * All rights reserved. + * Copyright (c) 2023 Jessica Clarke <jrtc27@FreeBSD.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. + * + * 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. + */ + +#ifndef _SYS_LINKER_SET_H_ +#define _SYS_LINKER_SET_H_ + +#include <mach-o/dyld.h> +#include <mach-o/getsect.h> + +/* + * The following macros are used to declare global sets of objects, which + * are collected by the linker into a `linker_set' as defined below. + * For Mach-O, this is done by constructing a separate section for each set. + */ + +#define __MAKE_SET_CONST const + +/* + * Private macros, not to be used outside this header file. + */ + +/* + * The userspace address sanitizer inserts redzones around global variables, + * violating the assumption that linker set elements are packed. + */ +#define __NOASAN __nosanitizeaddress + +#define __MAKE_SET_QV(set, sym, qv) \ + static void const * qv \ + __NOASAN \ + __set_##set##_sym_##sym __section("__DATA,set_" #set) \ + __used = &(sym) +#define __MAKE_SET(set, sym) __MAKE_SET_QV(set, sym, __MAKE_SET_CONST) + +static inline __pure2 uint8_t * +__set_getsectiondata(const char *segname, const char *sectname, + unsigned long *size) +{ + uint32_t image_count, image_index; + const struct mach_header *mh; + uint8_t *ret; + + image_count = _dyld_image_count(); + for (image_index = 0; image_index < image_count; ++image_index) { + mh = _dyld_get_image_header(image_index); + if (mh == NULL) + continue; + + ret = getsectiondata((const struct mach_header_64 *)mh, + segname, sectname, size); + if (ret != NULL) + return (ret); + } + + return (NULL); +} + +#define __SET_RANGE(set) ({ \ + unsigned long __set_size; \ + char *__set_data; \ + __set_data = __set_getsectiondata("__DATA", \ + "set_" #set, &__set_size); \ + (struct { \ + __CONCAT(__typeof_set_,set) **begin; \ + __CONCAT(__typeof_set_,set) **limit; \ + }){ \ + .begin = (__CONCAT(__typeof_set_,set) **)__set_data, \ + .limit = (__CONCAT(__typeof_set_,set) **)(__set_data + \ + __set_size) \ + }; \ +}) + +/* + * Public macros. + */ +#define TEXT_SET(set, sym) __MAKE_SET(set, sym) +#define DATA_SET(set, sym) __MAKE_SET(set, sym) +#define DATA_WSET(set, sym) __MAKE_SET_QV(set, sym, ) +#define BSS_SET(set, sym) __MAKE_SET(set, sym) +#define ABS_SET(set, sym) __MAKE_SET(set, sym) +#define SET_ENTRY(set, sym) __MAKE_SET(set, sym) + +/* + * Initialize before referring to a given linker set. + */ +#define SET_DECLARE(set, ptype) \ + typedef ptype __CONCAT(__typeof_set_,set) + +#define SET_BEGIN(set) \ + (__SET_RANGE(set).begin) +#define SET_LIMIT(set) \ + (__SET_RANGE(set).limit) + +/* + * Iterate over all the elements of a set. + * + * Sets always contain addresses of things, and "pvar" points to words + * containing those addresses. Thus is must be declared as "type **pvar", + * and the address of each set item is obtained inside the loop by "*pvar". + */ +#define SET_FOREACH(pvar, set) \ + for (pvar = SET_BEGIN(set); pvar < SET_LIMIT(set); pvar++) + +#define SET_ITEM(set, i) \ + ((SET_BEGIN(set))[i]) + +/* + * Provide a count of the items in a set. + */ +#define SET_COUNT(set) \ + (SET_LIMIT(set) - SET_BEGIN(set)) + +#endif /* _SYS_LINKER_SET_H_ */ diff --git a/tools/build/cross-build/include/mac/sys/stat.h b/tools/build/cross-build/include/mac/sys/stat.h index 0ff5ac929d06..95a9d0ce4764 100644 --- a/tools/build/cross-build/include/mac/sys/stat.h +++ b/tools/build/cross-build/include/mac/sys/stat.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #include_next <sys/stat.h> diff --git a/tools/build/cross-build/include/mac/sys/time.h b/tools/build/cross-build/include/mac/sys/time.h index 094764b8888c..6a0526c552e1 100644 --- a/tools/build/cross-build/include/mac/sys/time.h +++ b/tools/build/cross-build/include/mac/sys/time.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once #include_next <sys/time.h> diff --git a/tools/build/cross-build/include/mac/unistd.h b/tools/build/cross-build/include/mac/unistd.h index 3a4010e0d013..8af6af93821e 100644 --- a/tools/build/cross-build/include/mac/unistd.h +++ b/tools/build/cross-build/include/mac/unistd.h @@ -32,8 +32,6 @@ * 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. - * - * $FreeBSD$ */ #pragma once diff --git a/tools/build/cross-build/mkimg/Makefile b/tools/build/cross-build/mkimg/Makefile index 932f6150f118..cbef4a9f36ea 100644 --- a/tools/build/cross-build/mkimg/Makefile +++ b/tools/build/cross-build/mkimg/Makefile @@ -1,5 +1,3 @@ -# $FreeBSD$ - # allow building mkimg as a host tool. MKIMG_SRC = ${SRCTOP}/usr.bin/mkimg diff --git a/tools/build/cross-build/mkimg/Makefile.depend b/tools/build/cross-build/mkimg/Makefile.depend index f80275d86ab1..11aba52f82cf 100644 --- a/tools/build/cross-build/mkimg/Makefile.depend +++ b/tools/build/cross-build/mkimg/Makefile.depend @@ -1,4 +1,3 @@ -# $FreeBSD$ # Autogenerated - do NOT edit! DIRDEPS = \ diff --git a/tools/build/cross-build/progname.c b/tools/build/cross-build/progname.c index 645227df48d7..b7163f23fb2a 100644 --- a/tools/build/cross-build/progname.c +++ b/tools/build/cross-build/progname.c @@ -34,11 +34,8 @@ * SUCH DAMAGE. */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); - #include <stdlib.h> -#ifdef __GLIBC__ extern const char *__progname; const char * getprogname(void) @@ -50,4 +47,3 @@ setprogname(const char *progname) { __progname = progname; } -#endif /* __GLIBC__ */ diff --git a/tools/build/cross-build/secure_getenv.c b/tools/build/cross-build/secure_getenv.c new file mode 100644 index 000000000000..466035f31a40 --- /dev/null +++ b/tools/build/cross-build/secure_getenv.c @@ -0,0 +1,16 @@ +/*- + * SPDX-License-Identifier: BSD-2-Clause + * + * Copyright (c) 2023 Mark Johnston <markj@FreeBSD.org> + */ + +#include <stdlib.h> +#include <unistd.h> + +char * +secure_getenv(const char *name) +{ + if (issetugid() != 0) + return (NULL); + return (getenv(name)); +} |