Page MenuHomeFreeBSD

D14316.id39175.diff
No OneTemporary

D14316.id39175.diff

Index: share/mk/sys.mk
===================================================================
--- share/mk/sys.mk
+++ share/mk/sys.mk
@@ -332,6 +332,21 @@
path=${__MAKE_SHELL}
.endif
+.if ${.MAKE.OS} != "FreeBSD"
+# Use bash with -o pipefail to make sure that all commands exist
+# somehow bmake won't use the check string so lets use a wrapper script
+# instead
+.if !exists(/tmp/bash-with-pipefail)
+_FOOOOO!= echo '\#!/bin/sh' > /tmp/bash-with-pipefail
+_FOOOOO!= echo 'exec /bin/bash -o pipefail "$$@"' >> /tmp/bash-with-pipefail
+_FOOOOO!= chmod +x /tmp/bash-with-pipefail
+.endif
+.SHELL: name=bash path=/tmp/bash-with-pipefail hasErrCtl=true \
+ check="set -uo pipefail" ignore="set +euo pipefail" \
+ echo="set -xv" quiet="set +x" filter="set +x" \
+ echoFlag=xv errFlag="e" newline="'\n'"
+.endif
+
# Hack for ports compatibility. Historically, ports makefiles have
# assumed they can examine MACHINE_CPU without including anything
# because this was automatically included in sys.mk. For /usr/src,
Index: tools/build/Makefile
===================================================================
--- tools/build/Makefile
+++ tools/build/Makefile
@@ -4,17 +4,21 @@
LIB= egacy
SRC=
-INCSGROUPS= INCS SYSINCS
+INCSGROUPS= INCS SYSINCS MACHINESYSINCS UFSINCS FFSINCS X86INCS
INCS=
SYSINCSDIR= ${INCLUDEDIR}/sys
+MACHINESYSINCSDIR= ${INCLUDEDIR}/machine
+UFSINCSDIR= ${INCLUDEDIR}/ufs/ufs
+FFSINCSDIR= ${INCLUDEDIR}/ufs/ffs
+X86INCSDIR= ${INCLUDEDIR}/x86
BOOTSTRAPPING?= 0
_WITH_PWCACHEDB!= grep -c pwcache_groupdb /usr/include/grp.h || true
.if ${_WITH_PWCACHEDB} == 0
.PATH: ${.CURDIR}/../../contrib/libc-pwcache
-CFLAGS+= -I${.CURDIR}/../../contrib/libc-pwcache \
+CFLAGS.pwcache.c+= -I${.CURDIR}/../../contrib/libc-pwcache \
-I${.CURDIR}/../../lib/libc/include
SRCS+= pwcache.c
.endif
@@ -23,7 +27,7 @@
.if ${_WITH_STRSVIS} == 0
.PATH: ${.CURDIR}/../../contrib/libc-vis
SRCS+= vis.c
-CFLAGS+= -I${.CURDIR}/../../contrib/libc-vis \
+CFLAGS.vis.c+= -I${.CURDIR}/../../contrib/libc-vis \
-I${.CURDIR}/../../lib/libc/include
.endif
@@ -32,7 +36,7 @@
.PATH: ${.CURDIR}/../../lib/libc/stdlib
INCS+= stdlib.h
SRCS+= reallocarray.c
-CFLAGS+= -I${.CURDIR}/../../lib/libc/include
+CFLAGS.reallocarray.c+= -I${.CURDIR}/../../lib/libc/include
.endif
_WITH_UTIMENS!= grep -c utimensat /usr/include/sys/stat.h || true
@@ -41,6 +45,58 @@
SRCS+= futimens.c utimensat.c
.endif
+.if ${.MAKE.OS} != "FreeBSD"
+# don't copy stdlib.h when cross-building since it will cause
+# conflicts with the host system's headers
+INCS:= ${INCS:Nstdlib.h}
+SYSINCS+= ${SRCTOP}/sys/sys/md5.h
+SYSINCS+= ${SRCTOP}/sys/sys/sbuf.h
+SYSINCS+= ${SRCTOP}/sys/sys/elf32.h
+SYSINCS+= ${SRCTOP}/sys/sys/elf64.h
+SYSINCS+= ${SRCTOP}/sys/sys/elf_common.h
+SYSINCS+= ${SRCTOP}/sys/sys/elf_generic.h
+_host_arch=${MACHINE}
+.if ${_host_arch} == "x86_64"
+# bmake on Linux/mac often prints that instead of amd64
+_host_arch=amd64
+.endif
+MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/elf.h
+.if ${_host_arch} == "amd64" || ${_host_arch} == "i386"
+X86INCS+= ${SRCTOP}/sys/x86/include/elf.h
+.endif
+
+.PATH: ${.CURDIR}/../../lib/libc/stdlib
+SRCS+= strtonum.c
+.PATH: ${.CURDIR}/../../lib/libc/locale
+SRCS+= rpmatch.c
+
+# needed for btxld:
+MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/exec.h
+MACHINESYSINCS+= ${SRCTOP}/sys/${_host_arch}/include/reloc.h
+INCS+= ${SRCTOP}/include/a.out.h
+SYSINCS+= ${SRCTOP}/sys/sys/imgact_aout.h
+
+# For mkscrfil.c:
+SYSINCS+= ${SRCTOP}/sys/sys/consio.h ${SRCTOP}/sys/sys/ioccom.h
+# for gencat:
+INCS+= ${SRCTOP}/include/nl_types.h
+
+#for makefs:
+UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dinode.h
+UFSINCS+= ${SRCTOP}/sys/ufs/ufs/dir.h
+FFSINCS+= ${SRCTOP}/sys/ufs/ffs/fs.h
+
+# for tzsetup:
+SRCS+= fake_sysctl.c
+
+# for vtfontcvt:
+SYSINCS+= ${SRCTOP}/sys/sys/fnv_hash.h
+
+# opensolaris stuff
+INCS+= ${SRCTOP}/include/elf.h
+
+.endif
+
.if empty(SRCS)
SRCS= dummy.c
.endif
Index: tools/build/cross-build/include/common/grp.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/grp.h
@@ -0,0 +1,31 @@
+#pragma once
+
+#include_next <grp.h>
+
+#define group_from_gid __nbcompat_group_from_gid
+
+int
+pwcache_groupdb(
+ int (*a_setgroupent)(int),
+ void (*a_endgrent)(void),
+ struct group * (*a_getgrnam)(const char *),
+ struct group * (*a_getgrgid)(gid_t));
+
+int
+gid_from_group(const char *name, gid_t *gid);
+
+int
+gid_from_group(const char *name, gid_t *gid);
+
+const char *
+group_from_gid(gid_t gid, int noname);
+
+#ifdef __linux__
+static inline int
+setgroupent(int stayopen)
+{
+ setgrent();
+ return 1;
+}
+#endif
+
Index: tools/build/cross-build/include/common/libelf.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/libelf.h
@@ -0,0 +1,6 @@
+#pragma once
+/* Needed to get opensolaris stuff to compile */
+#ifdef _OPENSOLARIS_SYS_TYPES_H_
+#include <sys/endian.h>
+#include_next <libelf.h>
+#endif
Index: tools/build/cross-build/include/common/netdb.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/netdb.h
@@ -0,0 +1,4 @@
+#pragma once
+#include_next <netdb.h>
+
+#define _PATH_SERVICES_DB "/var/db/services.db"
Index: tools/build/cross-build/include/common/osreldate.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/osreldate.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#define __FreeBSD_version 0
Index: tools/build/cross-build/include/common/pwd.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/pwd.h
@@ -0,0 +1,39 @@
+#pragma once
+
+#ifdef NEED_FREEBSD_STRUCT_PASSWD
+/* When building pwd_mkdb we need to use the FreeBSD definition of struct passwd */
+#define _GID_T_DECLARED
+#define _TIME_T_DECLARED
+#define _UID_T_DECLARED
+#define _SIZE_T_DECLARED
+#include "../../../../../include/pwd.h"
+#else
+#include_next <pwd.h>
+
+#define user_from_uid __nbcompat_user_from_uid
+
+int
+pwcache_userdb(
+ int (*a_setpassent)(int),
+ void (*a_endpwent)(void),
+ struct passwd * (*a_getpwnam)(const char *),
+ struct passwd * (*a_getpwuid)(uid_t));
+
+int
+uid_from_user(const char *name, uid_t *uid);
+
+int
+uid_from_user(const char *name, uid_t *uid);
+const char *
+user_from_uid(uid_t uid, int noname);
+
+#ifdef __linux__
+static inline int
+setpassent(int stayopen)
+{
+ setpwent();
+ return 1;
+}
+#endif
+
+#endif
Index: tools/build/cross-build/include/common/sys/_iovec.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/_iovec.h
@@ -0,0 +1,2 @@
+#pragma once
+
Index: tools/build/cross-build/include/common/sys/cdefs.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/cdefs.h
@@ -0,0 +1,90 @@
+#pragma once
+#include_next <sys/cdefs.h>
+
+#ifndef __FBSDID
+#define __FBSDID(id)
+#endif
+
+#ifndef __IDSTRING
+#define __IDSTRING(name,string)
+#endif
+
+#ifndef rounddown
+// needed by libsbuf
+#define rounddown(x, y) (((x)/(y))*(y))
+#define rounddown2(x, y) ((x)&(~((y)-1))) /* if y is power of two */
+#define roundup(x, y) ((((x)+((y)-1))/(y))*(y)) /* to any y */
+#define roundup2(x, y) (((x)+((y)-1))&(~((y)-1))) /* if y is powers of two */
+#define powerof2(x) ((((x)-1)&(x))==0)
+#endif
+
+#ifndef __va_list
+#include <stdarg.h>
+#define __va_list va_list
+#endif
+
+#ifndef __pure
+#define __pure __attribute__((__pure__))
+#endif
+
+#ifndef __packed
+#define __packed __attribute__((__packed__))
+#endif
+
+#ifndef __printf0like
+#define __printf0like(fmtarg, firstvararg) \
+ __attribute__((__format__ (__printf0__, fmtarg, firstvararg)))
+#endif
+
+#ifndef __weak_reference
+#define __weak_reference(sym,alias) \
+ static int alias() __attribute__ ((weakref (#sym)));
+#endif
+
+#ifndef __malloc_like
+#define __malloc_like __attribute__((__malloc__))
+#endif
+
+#ifndef nitems
+// https://stackoverflow.com/questions/1598773/is-there-a-standard-function-in-c-that-would-return-the-length-of-an-array/1598827#1598827
+#define nitems(x) ((sizeof(x)/sizeof(0[x])) / ((size_t)(!(sizeof(x) % sizeof(0[x])))))
+#endif
+
+#ifndef __min_size
+#if !defined(__cplusplus)
+#define __min_size(x) static (x)
+#else
+#define __min_size(x) (x)
+#endif
+#endif
+
+#ifndef __unused
+#define __unused __attribute__((unused))
+#endif
+#define __format_arg(fmtarg) __attribute__((__format_arg__ (fmtarg)))
+
+#ifndef __exported
+#define __exported __attribute__((__visibility__("default")))
+#endif
+#ifndef __hidden
+#define __hidden __attribute__((__visibility__("hidden")))
+#endif
+
+/*
+ * These should probably be in sys/types.h but mtree expects them to exist
+ * without including <sys/types.h>
+ */
+typedef unsigned char u_char;
+typedef unsigned short u_short;
+typedef unsigned int u_int;
+typedef unsigned long u_long;
+
+/* This is needed so that BSNMP doesn't redeclare an incompatible version */
+#define HAVE_STRLCPY 1
+/* The compiler supports __func__ */
+#define HAVE_DECL___FUNC__ 1
+
+/* On MacOS __CONCAT is defined as x ## y, which won't expand macros */
+#undef __CONCAT
+#define __CONCAT1(x,y) x ## y
+#define __CONCAT(x,y) __CONCAT1(x,y)
Index: tools/build/cross-build/include/common/sys/ctype.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/ctype.h
@@ -0,0 +1,2 @@
+#pragma once
+#include <ctype.h>
Index: tools/build/cross-build/include/common/sys/elf.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/elf.h
@@ -0,0 +1,5 @@
+#pragma once
+#include <machine/elf.h>
+#ifndef _CTF_API_H
+#include "../../../../../sys/sys/elf.h"
+#endif
Index: tools/build/cross-build/include/common/sys/limits.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/limits.h
@@ -0,0 +1,2 @@
+#pragma once
+#include <limits.h>
Index: tools/build/cross-build/include/common/sys/mman.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/mman.h
@@ -0,0 +1,11 @@
+#pragma once
+
+#include_next <sys/mman.h>
+
+#ifndef MAP_NOCORE
+#define MAP_NOCORE 0
+#endif
+
+#ifndef MAP_NOSYNC
+#define MAP_NOSYNC 0
+#endif
Index: tools/build/cross-build/include/common/sys/param.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/param.h
@@ -0,0 +1,20 @@
+#pragma once
+
+#include_next <sys/param.h>
+
+#ifndef BLKDEV_IOSIZE
+#define BLKDEV_IOSIZE PAGE_SIZE /* default block device I/O size */
+#endif
+#ifndef DFLTPHYS
+#define DFLTPHYS (64 * 1024) /* default max raw I/O transfer size */
+#endif
+#ifndef MAXPHYS
+#define MAXPHYS (128 * 1024) /* max raw I/O transfer size */
+#endif
+#ifndef MAXDUMPPGS
+#define MAXDUMPPGS (DFLTPHYS/PAGE_SIZE)
+#endif
+
+#ifndef __PAST_END
+#define __PAST_END(array, offset) (((__typeof__(*(array)) *)(array))[offset])
+#endif
Index: tools/build/cross-build/include/common/sys/stdint.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/stdint.h
@@ -0,0 +1,11 @@
+#if defined(__has_include_next) && __has_include_next(<sys/stdint.h>)
+#include_next <sys/stdint.h>
+#else
+#include <stdint.h>
+#endif
+
+
+/* opensolaris weirdness: */
+typedef long long longlong_t;
+typedef unsigned long ulong_t;
+typedef uint64_t u_int64_t;
Index: tools/build/cross-build/include/common/sys/sysctl.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/sysctl.h
@@ -0,0 +1,9 @@
+#pragma once
+
+#include <sys/types.h>
+
+#define sysctlbyname __freebsd_sysctlbyname
+#define sysctl __freebsd_sysctl
+
+int sysctl(const int *, u_int, void *, size_t *, const void *, size_t);
+int sysctlbyname(const char *, void *, size_t *, const void *, size_t);
Index: tools/build/cross-build/include/common/sys/types.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/types.h
@@ -0,0 +1,16 @@
+#pragma once
+#include_next <sys/types.h>
+/*
+ * elftoolchain includes sys/elf32.h which expects that uint32_t is defined
+ * However, it only includes <sys/types.h> and not <stdint.h>
+ */
+#include <stdint.h>
+
+#ifdef __linux__
+typedef uintptr_t __uintptr_t;
+#endif
+
+/* needed for gencat */
+typedef int __nl_item;
+
+typedef size_t u_register_t;
Index: tools/build/cross-build/include/common/sys/uio.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/sys/uio.h
@@ -0,0 +1,14 @@
+#pragma once
+#include_next <sys/uio.h>
+
+/* needed by opensolaris: */
+#ifdef __linux__
+enum uio_rw { UIO_READ, UIO_WRITE };
+
+/* Segment flag values. */
+enum uio_seg {
+ UIO_USERSPACE, /* from user data space */
+ UIO_SYSSPACE, /* from system space */
+ UIO_NOCOPY /* don't copy, already in object */
+};
+#endif
Index: tools/build/cross-build/include/common/unistd.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/common/unistd.h
@@ -0,0 +1,16 @@
+#pragma once
+#include_next <unistd.h>
+
+static inline int
+check_utility_compat(const char *utility)
+{
+ /*
+ * The check_utility_compat() function returns zero if utility should
+ * implement strict IEEE Std 1003.1-2001 (“POSIX.1”) behavior, and
+ * nonzero otherwise.
+ *
+ * During bootstrapping from another host system always returning 1
+ * is probably the best.
+ */
+ return (1);
+}
\ No newline at end of file
Index: tools/build/cross-build/include/linux/ctype.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/ctype.h
@@ -0,0 +1,12 @@
+#pragma once
+#include_next <ctype.h>
+#include <stdlib.h>
+
+#ifndef digittoint
+static inline int digittoint(char c) {
+ if (!isxdigit(c))
+ return 0;
+ char buffer[] = {c, '\0' };
+ return strtol(buffer, 0, 16);
+}
+#endif
Index: tools/build/cross-build/include/linux/errno.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/errno.h
@@ -0,0 +1,10 @@
+#pragma once
+#include_next <errno.h>
+
+#ifndef EFTYPE
+#define EFTYPE EINVAL
+#endif
+
+#ifndef EPROCLIM
+#define EPROCLIM EAGAIN
+#endif
Index: tools/build/cross-build/include/linux/fcntl.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/fcntl.h
@@ -0,0 +1,21 @@
+#pragma once
+
+#define open __open
+#include_next <fcntl.h>
+#include <sys/file.h>
+
+
+#ifndef O_EXLOCK
+#define O_EXLOCK (1 << 30)
+#endif
+#ifndef O_SHLOCK
+#define O_SHLOCK (1 << 31)
+#endif
+
+
+#undef open
+#define open(path, flags, ...) ({ \
+ int __fd = __open(path, flags, ##__VA_ARGS__); \
+ if (flags & O_EXLOCK) flock(__fd, LOCK_EX); \
+ if (flags & O_SHLOCK) flock(__fd, LOCK_SH); \
+ __fd; })
Index: tools/build/cross-build/include/linux/libutil.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/libutil.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include_next <libutil.h>
+#include <stdio.h>
+#include <sys/socket.h>
Index: tools/build/cross-build/include/linux/limits.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/limits.h
@@ -0,0 +1,19 @@
+#pragma once
+#include_next <limits.h>
+#include <sys/types.h>
+
+#define MAXBSIZE 65536 /* must be power of 2 */
+#ifndef __OFF_T_MATCHES_OFF64_T
+#error "Expected 64-bit off_t"
+#endif
+#define OFF_MAX UINT64_MAX
+#define QUAD_MAX INT64_MAX
+
+#ifndef GID_MAX
+#define GID_MAX ((gid_t)-1)
+#endif
+
+
+#ifndef UID_MAX
+#define UID_MAX ((uid_t)-1)
+#endif
Index: tools/build/cross-build/include/linux/machine/endian.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/machine/endian.h
@@ -0,0 +1 @@
+#pragma once
Index: tools/build/cross-build/include/linux/nbtool_config.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/nbtool_config.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#define HAVE_ERR_H 1
+#define HAVE_STRUCT_STAT_ST_FLAGS 0
+#define HAVE_STRUCT_STATFS_F_FSTYPENAME 0
+#define HAVE_PWCACHE_USERDB 0
+#define HAVE_NETDB_H 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRUCT_STAT_BIRTHTIME 0
+#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
+#define HAVE_FSTATVFS 1
+#define HAVE_STRUCT_STATVFS_F_IOSIZE 0
Index: tools/build/cross-build/include/linux/netdb.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/netdb.h
@@ -0,0 +1,6 @@
+#pragma once
+
+#include_next <netdb.h>
+
+void freehostent(struct hostent *ip);
+
Index: tools/build/cross-build/include/linux/regex.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/regex.h
@@ -0,0 +1,4 @@
+#pragma once
+#include_next <regex.h>
+
+#define REG_BASIC 0
Index: tools/build/cross-build/include/linux/stdlib.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/stdlib.h
@@ -0,0 +1,16 @@
+#pragma once
+#include_next <stdlib.h>
+
+__BEGIN_DECLS
+/* Add the getcap functions */
+char *cgetcap(char *, const char *, int);
+int cgetclose(void);
+int cgetent(char **, char **, const char *);
+int cgetfirst(char **, char **);
+int cgetmatch(const char *, const char *);
+int cgetnext(char **, char **);
+int cgetnum(char *, const char *, long *);
+int cgetset(const char *);
+int cgetstr(char *, const char *, char **);
+int cgetustr(char *, const char *, char **);
+__END_DECLS
Index: tools/build/cross-build/include/linux/string.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/string.h
@@ -0,0 +1,10 @@
+#pragma once
+
+/* one some version of glibc including string.h before stdlib.h won't work.
+ * This happens when building anything that uses the libnetbsd stdlib.h override.
+ * This is because string.h will include stdlib.h with a flag set to define
+ * only a subset of the functions (which will then not set the _STDLIB_H
+ * macro. libnetbsd stdlib.h can only be included once so this will not work.
+ */
+#include <stdlib.h>
+#include_next <string.h>
Index: tools/build/cross-build/include/linux/sys/_types.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/_types.h
@@ -0,0 +1,3 @@
+#pragma once
+
+#include <sys/types.h>
Index: tools/build/cross-build/include/linux/sys/disk.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/disk.h
@@ -0,0 +1,4 @@
+#pragma once
+#include <sys/mount.h>
+
+#define DIOCGMEDIASIZE BLKGETSIZE64
\ No newline at end of file
Index: tools/build/cross-build/include/linux/sys/endian.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/endian.h
@@ -0,0 +1,14 @@
+#pragma once
+#include_next <sys/endian.h>
+
+#ifndef bswap64
+#define bswap64(a) __builtin_bswap64(a)
+#endif
+
+#ifndef bswap32
+#define bswap32(a) __builtin_bswap32(a)
+#endif
+
+#ifndef bswap16
+#define bswap16(a) __builtin_bswap16(a)
+#endif
Index: tools/build/cross-build/include/linux/sys/mount.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/mount.h
@@ -0,0 +1,3 @@
+#pragma once
+#include_next <sys/mount.h>
+#include <sys/statfs.h>
Index: tools/build/cross-build/include/linux/sys/param.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/param.h
@@ -0,0 +1,7 @@
+#pragma once
+#include_next <sys/param.h>
+
+/* `getconf LOGIN_NAME_MAX` prints 256 on Ubuntu 16.04 but
+ * let's use 32 since that will work across all systems
+ */
+#define MAXLOGNAME 33 /* max login name length (incl. NUL) */
Index: tools/build/cross-build/include/linux/sys/stat.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/stat.h
@@ -0,0 +1,16 @@
+#pragma once
+/*
+ * glibc shipped with Ubuntu 16.04 doesn't include a definition of
+ * struct timespec when sys/stat.h is included
+ * */
+#define __need_timespec
+#include <time.h>
+#include_next <sys/stat.h>
+
+#define st_atimensec st_atim.tv_nsec
+#define st_mtimensec st_mtim.tv_nsec
+#define st_ctimensec st_ctim.tv_nsec
+
+#define st_atimespec st_atim
+#define st_mtimespec st_mtim
+#define st_ctimespec st_ctim
Index: tools/build/cross-build/include/linux/sys/sysct.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/sysct.h
@@ -0,0 +1,5 @@
+#pragma once
+/* The Linux sysctl struct has a member called __unused */
+#undef __unused
+#include_next <sys/sysctl.h>
+#define __unused __attribute__((unused))
Index: tools/build/cross-build/include/linux/sys/time.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/time.h
@@ -0,0 +1,8 @@
+#pragma once
+
+#include_next <sys/time.h>
+#include <time.h>
+/* Not quite the same but should be good enough */
+#ifdef _OPENSOLARIS_SYS_TIME_H_
+#define CLOCK_UPTIME CLOCK_BOOTTIME
+#endif
Index: tools/build/cross-build/include/linux/sys/ucred.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/sys/ucred.h
@@ -0,0 +1 @@
+#pragma once
Index: tools/build/cross-build/include/linux/time.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/time.h
@@ -0,0 +1,18 @@
+/* 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
+ * defines set */
+/* #pragma once*/
+
+/* GLIBC sets this when multiple-including time.h */
+#ifdef __need_time_t
+#include_next <time.h>
+#else
+/* In addtion to time.h we also need to include sys/time.h and utime.h to
+ * be compatible with FreeBSD */
+#include_next <time.h>
+/* On Linux utimes() is not defined in time.h */
+#include <utime.h>
+/* sys/types.h is needed for opensolaris compat */
+#include <sys/types.h>
+#include <sys/time.h>
+#endif
Index: tools/build/cross-build/include/linux/unistd.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/unistd.h
@@ -0,0 +1,57 @@
+#pragma once
+
+#include_next <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#undef getopt
+
+__BEGIN_DECLS
+
+// Force POSIX compatibility in glibc getopt
+static inline int getopt_real(int argc, char * const argv[], const char *optstring)
+{
+#ifdef __GLIBC__
+ // If the first character of optstring is '+' or the environment variable
+ // POSIXLY_CORRECT is set, then option processing stops as soon as a
+ // nonoption argument is encountered.
+ char* newoptstring = NULL;
+ asprintf(&newoptstring, "+%s", optstring);
+ int ret = bsd_getopt(argc, argv, newoptstring);
+ free(newoptstring);
+ return ret;
+#else
+ return bsd_getopt(argc, argv, optstring)
+#endif
+}
+
+static inline int issetugid(void) {
+ return 0;
+}
+
+static inline char *
+fflagstostr(u_long flags)
+{
+ return strdup("");
+}
+
+static inline int
+strtofflags(char **stringp, u_long *setp, u_long *clrp) {
+ /* On linux just ignore the file flags for now */
+ /*
+ * XXXAR: this will prevent makefs from setting noschg on libc, etc
+ * so we should really build the version from libc
+ */
+ if (setp)
+ *setp = 0;
+ if (clrp)
+ *clrp = 0;
+ return 0; /* success */
+}
+
+#define getopt getopt_real
+
+/* Used by elftoolchain: */
+extern char *program_invocation_name;
+extern char *program_invocation_short_name;
+
+__END_DECLS
Index: tools/build/cross-build/include/linux/vis.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/vis.h
@@ -0,0 +1,4 @@
+#pragma once
+#include_next <vis.h>
+// libbsd shippend with Ubuntu 16.04 is missing some prototypes:1
+int strsvis(char *dst, const char *src, int flag, const char *extra);
Index: tools/build/cross-build/include/linux/wctype.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/linux/wctype.h
@@ -0,0 +1,6 @@
+#pragma once
+#include_next <wctype.h>
+
+#ifndef iswascii
+#define iswascii(c) isascii(c)
+#endif
Index: tools/build/cross-build/include/mac/libutil.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/libutil.h
@@ -0,0 +1,5 @@
+#pragma once
+
+#include <stdio.h>
+#include <sys/socket.h>
+#include </usr/include/util.h>
Index: tools/build/cross-build/include/mac/nbtool_config.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/nbtool_config.h
@@ -0,0 +1,12 @@
+#pragma once
+
+#define HAVE_ERR_H 1
+#define HAVE_STRUCT_STAT_ST_FLAGS 1
+#define HAVE_STRUCT_STATFS_F_FSTYPENAME 1
+#define HAVE_PWCACHE_USERDB 0
+#define HAVE_NETDB_H 1
+#define HAVE_STRLCPY 1
+#define HAVE_STRUCT_STAT_BIRTHTIME 1
+#define HAVE_STRUCT_STAT_ST_MTIMENSEC 1
+#define HAVE_FSTATVFS 1
+#define HAVE_STRUCT_STATVFS_F_IOSIZE 0
Index: tools/build/cross-build/include/mac/stdlib.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/stdlib.h
@@ -0,0 +1,11 @@
+#pragma once
+#include_next <stdlib.h>
+
+int rpmatch(const char *response);
+
+long long
+strtonum(const char *numstr, long long minval, long long maxval,
+ const char **errstrp);
+
+void *
+reallocarray(void *optr, size_t nmemb, size_t size);
Index: tools/build/cross-build/include/mac/sys/disk.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/sys/disk.h
@@ -0,0 +1,3 @@
+#pragma once
+/* Emtpy file needed by opensolaris compat stat.h */
+/* TODO: find macos equivalent for DIOCGMEDIASIZE */
\ No newline at end of file
Index: tools/build/cross-build/include/mac/sys/endian.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/sys/endian.h
@@ -0,0 +1,156 @@
+#pragma once
+
+#include <machine/endian.h>
+#include <stdint.h>
+
+/*
+ * General byte order swapping functions.
+ */
+#define bswap16(x) __builtin_bswap16(x)
+#define bswap32(x) __builtin_bswap32(x)
+#define bswap64(x) __builtin_bswap64(x)
+
+#define _BYTE_ORDER __DARWIN_BYTE_ORDER
+#define _LITTLE_ENDIAN __DARWIN_LITTLE_ENDIAN
+#define _BIG_ENDIAN __DARWIN_BIG_ENDIAN
+/*
+ * Host to big endian, host to little endian, big endian to host, and little
+ * endian to host byte order functions as detailed in byteorder(9).
+ */
+#if _BYTE_ORDER == _LITTLE_ENDIAN
+#define htobe16(x) bswap16((x))
+#define htobe32(x) bswap32((x))
+#define htobe64(x) bswap64((x))
+#define htole16(x) ((uint16_t)(x))
+#define htole32(x) ((uint32_t)(x))
+#define htole64(x) ((uint64_t)(x))
+
+#define be16toh(x) bswap16((x))
+#define be32toh(x) bswap32((x))
+#define be64toh(x) bswap64((x))
+#define le16toh(x) ((uint16_t)(x))
+#define le32toh(x) ((uint32_t)(x))
+#define le64toh(x) ((uint64_t)(x))
+#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
+#define htobe16(x) ((uint16_t)(x))
+#define htobe32(x) ((uint32_t)(x))
+#define htobe64(x) ((uint64_t)(x))
+#define htole16(x) bswap16((x))
+#define htole32(x) bswap32((x))
+#define htole64(x) bswap64((x))
+
+#define be16toh(x) ((uint16_t)(x))
+#define be32toh(x) ((uint32_t)(x))
+#define be64toh(x) ((uint64_t)(x))
+#define le16toh(x) bswap16((x))
+#define le32toh(x) bswap32((x))
+#define le64toh(x) bswap64((x))
+#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
+
+/* Alignment-agnostic encode/decode bytestream to/from little/big endian. */
+
+static __inline uint16_t
+be16dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return ((p[0] << 8) | p[1]);
+}
+
+static __inline uint32_t
+be32dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return (((unsigned)p[0] << 24) | (p[1] << 16) | (p[2] << 8) | p[3]);
+}
+
+static __inline uint64_t
+be64dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return (((uint64_t)be32dec(p) << 32) | be32dec(p + 4));
+}
+
+static __inline uint16_t
+le16dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return ((p[1] << 8) | p[0]);
+}
+
+static __inline uint32_t
+le32dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return (((unsigned)p[3] << 24) | (p[2] << 16) | (p[1] << 8) | p[0]);
+}
+
+static __inline uint64_t
+le64dec(const void *pp)
+{
+ uint8_t const *p = (uint8_t const *)pp;
+
+ return (((uint64_t)le32dec(p + 4) << 32) | le32dec(p));
+}
+
+static __inline void
+be16enc(void *pp, uint16_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ p[0] = (u >> 8) & 0xff;
+ p[1] = u & 0xff;
+}
+
+static __inline void
+be32enc(void *pp, uint32_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ p[0] = (u >> 24) & 0xff;
+ p[1] = (u >> 16) & 0xff;
+ p[2] = (u >> 8) & 0xff;
+ p[3] = u & 0xff;
+}
+
+static __inline void
+be64enc(void *pp, uint64_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ be32enc(p, (uint32_t)(u >> 32));
+ be32enc(p + 4, (uint32_t)(u & 0xffffffffU));
+}
+
+static __inline void
+le16enc(void *pp, uint16_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ p[0] = u & 0xff;
+ p[1] = (u >> 8) & 0xff;
+}
+
+static __inline void
+le32enc(void *pp, uint32_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ p[0] = u & 0xff;
+ p[1] = (u >> 8) & 0xff;
+ p[2] = (u >> 16) & 0xff;
+ p[3] = (u >> 24) & 0xff;
+}
+
+static __inline void
+le64enc(void *pp, uint64_t u)
+{
+ uint8_t *p = (uint8_t *)pp;
+
+ le32enc(p, (uint32_t)(u & 0xffffffffU));
+ le32enc(p + 4, (uint32_t)(u >> 32));
+}
Index: tools/build/cross-build/include/mac/sys/stat.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/sys/stat.h
@@ -0,0 +1,15 @@
+#include_next <sys/stat.h>
+
+#ifndef UTIME_NOW
+int utimensat(int fd, const char *file, const struct timespec *ts, int flag)
+#endif
+
+#define st_atim st_atimespec
+#define st_mtim st_mtimespec
+#define st_ctim st_ctimespec
+#define st_btim st_birthtimespec
+#define st_birthtim st_birthtimespec
+#define st_atimensec st_atimespec.tv_nsec
+#define st_mtimensec st_mtimespec.tv_nsec
+#define st_ctimensec st_ctimespec.tv_nsec
+#define st_birthtimensec st_birthtimespec.tv_nsec
Index: tools/build/cross-build/include/mac/sys/time.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/sys/time.h
@@ -0,0 +1,7 @@
+#pragma once
+#include <sys/stdint.h>
+#include_next <sys/time.h>
+
+#ifndef CLOCK_UPTIME
+#define CLOCK_UPTIME CLOCK_UPTIME_RAW
+#endif
\ No newline at end of file
Index: tools/build/cross-build/include/mac/unistd.h
===================================================================
--- /dev/null
+++ tools/build/cross-build/include/mac/unistd.h
@@ -0,0 +1,15 @@
+#pragma once
+
+#include_next <unistd.h>
+#include <fcntl.h>
+#include <sys/signal.h>
+#include <sys/time.h>
+#include <sys/types.h>
+
+
+static inline int
+eaccess(const char *path, int mode) {
+ return faccessat(AT_FDCWD, path, mode, AT_EACCESS);
+}
+/* Just needs to be declared, doesn't actually have to be implemented */
+void closefrom(int lowfd);
Index: tools/build/fake_sysctl.c
===================================================================
--- /dev/null
+++ tools/build/fake_sysctl.c
@@ -0,0 +1,20 @@
+/* This file contains wrappers for sysctl that behave like the FreeBSD version */
+#include <string.h>
+#include <err.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);
+}

File Metadata

Mime Type
text/plain
Expires
Sun, May 17, 3:02 AM (3 h, 51 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
33170135
Default Alt Text
D14316.id39175.diff (32 KB)

Event Timeline