diff --git a/Makefile.inc1 b/Makefile.inc1 index a7b61aa9630..596af0c4c2b 100644 --- a/Makefile.inc1 +++ b/Makefile.inc1 @@ -853,6 +853,14 @@ BFLAGS+= -B${WORLDTMP}/usr/bin (defined(X_COMPILER_TYPE) && ${X_COMPILER_TYPE} == clang) XCFLAGS+= -target ${TARGET_TRIPLE} .endif +# An external compiler (e.g. upstream clang on Linux/macOS) only knows the +# freebsd triple, so it predefines __FreeBSD__ but not __MidnightBSD__. The +# tree keys on __MidnightBSD__ everywhere, so supply it ourselves with the same +# value our own clang derives from the triple's OS major version. +.if defined(X_COMPILER_MIDNIGHTBSD_VERSION) && \ + ${X_COMPILER_MIDNIGHTBSD_VERSION} == "unknown" +XCFLAGS+= -D__MidnightBSD__=${TARGET_TRIPLE:C/.*freebsd([0-9]+).*/\1/} +.endif XCFLAGS+= --sysroot=${WORLDTMP} .if !empty(BFLAGS) diff --git a/sys/compat/linuxkpi/common/include/linux/kernel.h b/sys/compat/linuxkpi/common/include/linux/kernel.h index e60191414e6..309b987e369 100644 --- a/sys/compat/linuxkpi/common/include/linux/kernel.h +++ b/sys/compat/linuxkpi/common/include/linux/kernel.h @@ -593,12 +593,6 @@ mult_frac(uintmax_t x, uintmax_t multiplier, uintmax_t divisor) return ((q * multiplier) + ((r * multiplier) / divisor)); } -static inline int64_t -abs64(int64_t x) -{ - return (x < 0 ? -x : x); -} - typedef struct linux_ratelimit { struct timeval lasttime; int counter; diff --git a/sys/dev/drm2/drm_os_freebsd.h b/sys/dev/drm2/drm_os_freebsd.h index 7f5bb22aff0..0ce0dede6d7 100644 --- a/sys/dev/drm2/drm_os_freebsd.h +++ b/sys/dev/drm2/drm_os_freebsd.h @@ -304,13 +304,6 @@ ilog2(unsigned long x) return (flsl(x) - 1); } -static inline int64_t -abs64(int64_t x) -{ - - return (x < 0 ? -x : x); -} - int64_t timeval_to_ns(const struct timeval *tv); struct timeval ns_to_timeval(const int64_t nsec); diff --git a/sys/sys/libkern.h b/sys/sys/libkern.h index 570caac448c..def05a6466a 100644 --- a/sys/sys/libkern.h +++ b/sys/sys/libkern.h @@ -114,6 +114,7 @@ static __inline off_t omin(off_t a, off_t b) { return (a < b ? a : b); } static __inline int abs(int a) { return (a < 0 ? -a : a); } static __inline long labs(long a) { return (a < 0 ? -a : a); } static __inline quad_t qabs(quad_t a) { return (a < 0 ? -a : a); } +static __inline int64_t abs64(int64_t a) { return (a < 0 ? -a : a); } #ifndef RANDOM_FENESTRASX #define ARC4_ENTR_NONE 0 /* Don't have entropy yet. */