blob: 777faa99e18772aff1e40734b6d96fefae917b32 [file] [log] [blame] [raw]
Use macro '__FreeBSD_kernel__' to indicate the kernel of FreeBSD.
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/conf/kern.pre.mk freebsd-11.1/sys/conf/kern.pre.mk
--- /usr/src/sys/conf/kern.pre.mk 2017-07-21 07:41:43.000000000 +0800
+++ freebsd-11.1/sys/conf/kern.pre.mk 2019-12-20 22:02:47.446203792 +0800
@@ -70,7 +70,7 @@
INCLUDES= ${NOSTDINC} ${INCLMAGIC} -I. -I$S
CFLAGS= ${COPTFLAGS} ${DEBUG}
-CFLAGS+= ${INCLUDES} -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
+CFLAGS+= ${INCLUDES} -D __FreeBSD_kernel__=1 -D_KERNEL -DHAVE_KERNEL_OPTION_HEADERS -include opt_global.h
CFLAGS_PARAM_INLINE_UNIT_GROWTH?=100
CFLAGS_PARAM_LARGE_FUNCTION_GROWTH?=1000
.if ${MACHINE_CPUARCH} == "mips"
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/conf/kmod.mk freebsd-11.1/sys/conf/kmod.mk
--- /usr/src/sys/conf/kmod.mk 2017-07-21 07:41:43.000000000 +0800
+++ freebsd-11.1/sys/conf/kmod.mk 2020-01-25 23:45:57.555379000 +0800
@@ -100,7 +100,7 @@
.endif
WERROR?= -Werror
CFLAGS+= ${WERROR}
-CFLAGS+= -D_KERNEL
+CFLAGS+= -D __FreeBSD_kernel__=1 -D_KERNEL
CFLAGS+= -DKLD_MODULE
# Don't use any standard or source-relative include directories.
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/net80211/ieee80211_var.h freebsd-11.1/sys/net80211/ieee80211_var.h
--- /usr/src/sys/net80211/ieee80211_var.h 2017-07-21 07:42:09.000000000 +0800
+++ freebsd-11.1/sys/net80211/ieee80211_var.h 2020-01-06 18:39:08.777978277 +0800
@@ -31,15 +31,18 @@
/*
* Definitions for IEEE 802.11 drivers.
*/
+#if defined __FreeBSD__ && !defined __FreeBSD_kernel__
+#define __FreeBSD_kernel__ 1
+#endif
/* NB: portability glue must go first */
#if defined(__NetBSD__)
#include <net80211/ieee80211_netbsd.h>
-#elif defined(__FreeBSD__)
+#elif defined(__FreeBSD_kernel__)
#include <net80211/ieee80211_freebsd.h>
#elif defined(__linux__)
#include <net80211/ieee80211_linux.h>
#else
-#error "No support for your operating system!"
+#error "No support for your operating system / kernel!"
#endif
#include <net80211/_ieee80211.h>
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/sys/timex.h freebsd-11.1/sys/sys/timex.h
--- /usr/src/sys/sys/timex.h 2017-07-21 07:41:55.000000000 +0800
+++ freebsd-11.1/sys/sys/timex.h 2019-12-20 17:39:23.084227505 +0800
@@ -37,7 +37,11 @@
#define NTP_API 4 /* NTP API version */
-#ifdef __FreeBSD__
+#if defined __FreeBSD__ && !defined __FreeBSD_kernel__
+#define __FreeBSD_kernel__ 1
+#endif
+
+#ifdef __FreeBSD_kernel__
#include <sys/_timespec.h>
#endif /* __FreeBSD__ */
@@ -153,7 +157,7 @@
long stbcnt; /* stability limit exceeded (ro) */
};
-#ifdef __FreeBSD__
+#ifdef __FreeBSD_kernel__
#ifdef _KERNEL
void ntp_update_second(int64_t *adjustment, time_t *newsec);
diff -ru --exclude-from freebsd-src-diff-exclude-names /usr/src/sys/teken/teken.c freebsd-11.1/sys/teken/teken.c
--- /usr/src/sys/teken/teken.c 2017-07-21 07:42:12.000000000 +0800
+++ freebsd-11.1/sys/teken/teken.c 2019-12-20 18:30:20.339769568 +0800
@@ -27,7 +27,8 @@
*/
#include <sys/cdefs.h>
-#if defined(__FreeBSD__) && defined(_KERNEL)
+#include <sys/param.h>
+#if defined(__FreeBSD_kernel__) && defined(_KERNEL)
#include <sys/param.h>
#include <sys/limits.h>
#include <sys/lock.h>