Simplify the FreeBSD check using __FreeBSD__ compiler macro.

Rather than rely on __FreeBSD_version, defined in sys/param.h, use
__FreeBSD__ defined by the compiler.

Reported by:	emaste
MFC after:	1 week
This commit is contained in:
Cy Schubert 2021-02-06 19:22:52 -08:00
parent d20f7a5a3d
commit 57785538c6
23 changed files with 64 additions and 64 deletions

View File

@ -41,7 +41,7 @@
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif

View File

@ -14,7 +14,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/file.h>
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
# include <sys/fcntl.h>
# include <sys/filio.h>
#else

View File

@ -172,7 +172,7 @@ typedef struct proxyrule {
} proxyrule_t;
#if defined(__NetBSD__) || defined(__FreeBSD_version) || \
#if defined(__NetBSD__) || defined(__FreeBSD__) || \
SOLARIS
# include <stdarg.h>
typedef int (* ioctlfunc_t)(int, ioctlcmd_t, ...);

View File

@ -12,7 +12,7 @@
#include <sys/socket.h>
#include <sys/file.h>
#include <sys/ioctl.h>
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/dirent.h>
#else
# include <sys/dir.h>

View File

@ -168,7 +168,7 @@ struct tcpcb *find_tcp(tfd, ti)
fd = (struct filedesc *)malloc(sizeof(*fd));
if (fd == NULL)
return NULL;
#if defined( __FreeBSD_version)
#if defined( __FreeBSD__)
if (KMCPY(fd, p->ki_fd, sizeof(*fd)) == -1)
{
fprintf(stderr, "read(%#lx,%#lx) failed\n",

View File

@ -20,7 +20,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/time.h>
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# if !defined(IPFILTER_LKM)
# include "opt_inet6.h"
# endif
@ -91,7 +91,7 @@
#if defined(IPFILTER_BPF) && defined(_KERNEL)
# include <net/bpf.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif
#include "netinet/ipl.h"
@ -2886,7 +2886,7 @@ ipf_check(ctx, ip, hlen, ifp, out
*/
m->m_flags &= ~M_CANFASTFWD;
# endif /* M_CANFASTFWD */
# if defined(CSUM_DELAY_DATA) && !defined(__FreeBSD_version)
# if defined(CSUM_DELAY_DATA) && !defined(__FreeBSD__)
/*
* disable delayed checksums.
*/

View File

@ -27,7 +27,7 @@
# include <sys/uio.h>
# undef _KERNEL
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -50,7 +50,7 @@
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/queue.h>
#endif
#if defined(__NetBSD__)
@ -81,7 +81,7 @@
# undef KERNEL
#endif
#include <netinet/tcp.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <net/if_var.h>
# define IF_QFULL _IF_QFULL
# define IF_DROP _IF_DROP
@ -100,7 +100,7 @@
# include <machine/cpufunc.h>
# endif
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
# if defined(_KERNEL) && !defined(IPFILTER_LKM)
# include <sys/libkern.h>

View File

@ -101,7 +101,7 @@
* There may be other, safe, kernels but this is not extensively tested yet.
*/
# define HAVE_M_PULLDOWN
# if !defined(IPFILTER_LKM) && defined(__FreeBSD_version)
# if !defined(IPFILTER_LKM) && defined(__FreeBSD__)
# include "opt_ipfilter.h"
# endif
# define COPYIN(a,b,c) copyin((caddr_t)(a), (caddr_t)(b), (c))
@ -282,7 +282,7 @@ typedef union {
#define ipf_isw ipf_lkun_s.ipf_sw
#define ipf_magic ipf_lkun_s.ipf_magic
#if !defined(__GNUC__) || defined(__FreeBSD_version)
#if !defined(__GNUC__) || defined(__FreeBSD__)
# ifndef INLINE
# define INLINE
# endif
@ -290,7 +290,7 @@ typedef union {
# define INLINE __inline__
#endif
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
CTASSERT(sizeof(ipfrwlock_t) == KRWLOCK_FILL_SZ);
CTASSERT(sizeof(ipfmutex_t) == KMUTEX_FILL_SZ);
#endif

View File

@ -41,7 +41,7 @@
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif

View File

@ -1374,7 +1374,7 @@ typedef struct ipftune {
** HPUX Port
*/
#if !defined(CDEV_MAJOR) && defined (__FreeBSD_version)
#if !defined(CDEV_MAJOR) && defined (__FreeBSD__)
# define CDEV_MAJOR 79
#endif
@ -1567,7 +1567,7 @@ typedef struct ipf_main_softc_s {
frentry_t *ipf_rule_explist[2];
ipftoken_t *ipf_token_head;
ipftoken_t **ipf_token_tail;
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
struct callout ipf_slow_ch;
#endif
#if NETBSD_GE_REV(104040000)
@ -1641,14 +1641,14 @@ extern size_t mbufchainlen(mb_t *);
# ifdef IPFILTER_LKM
extern int ipf_identify(char *);
# endif
# if defined(__FreeBSD_version)
# if defined(__FreeBSD__)
extern int ipfioctl(struct cdev*, u_long, caddr_t, int, struct thread *);
# elif defined(__NetBSD__)
extern int ipfioctl(dev_t, u_long, void *, int, struct lwp *);
# endif
# endif /* SOLARIS */
# if defined(__FreeBSD_version)
# if defined(__FreeBSD__)
extern int ipf_pfil_hook(void);
extern int ipf_pfil_unhook(void);
extern void ipf_event_reg(void);

View File

@ -16,11 +16,11 @@ static const char rcsid[] = "@(#)$Id$";
# define KERNEL 1
# define _KERNEL 1
#endif
#if defined(__FreeBSD_version) && \
#if defined(__FreeBSD__) && \
!defined(KLD_MODULE) && !defined(IPFILTER_LKM)
# include "opt_inet6.h"
#endif
#if defined(__FreeBSD_version) && \
#if defined(__FreeBSD__) && \
!defined(KLD_MODULE) && !defined(IPFILTER_LKM)
# include "opt_random_ip_id.h"
#endif
@ -35,7 +35,7 @@ static const char rcsid[] = "@(#)$Id$";
#include <sys/time.h>
#include <sys/systm.h>
#include <sys/dirent.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/jail.h>
#endif
#include <sys/malloc.h>

View File

@ -24,7 +24,7 @@
# include <sys/uio.h>
# undef _KERNEL
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else

View File

@ -24,7 +24,7 @@
# undef _KERNEL
#endif
#include <sys/socket.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif
#if defined(__FreeBSD__)

View File

@ -39,7 +39,7 @@
# undef _KERNEL
# undef KERNEL
#endif
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
# include <sys/fcntl.h>
# include <sys/filio.h>
#else
@ -52,12 +52,12 @@
# include <sys/proc.h>
# endif
#endif /* _KERNEL */
# if defined(NetBSD) || defined(__FreeBSD_version)
# if defined(NetBSD) || defined(__FreeBSD__)
# include <sys/dirent.h>
# include <sys/mbuf.h>
# include <sys/select.h>
# endif
# if defined(__FreeBSD_version)
# if defined(__FreeBSD__)
# include <sys/selinfo.h>
# endif
#if SOLARIS && defined(_KERNEL)
@ -78,7 +78,7 @@
#ifdef sun
# include <net/af.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <net/if_var.h>
#endif
#include <netinet/in.h>
@ -102,7 +102,7 @@
#include "netinet/ip_frag.h"
#include "netinet/ip_state.h"
#include "netinet/ip_auth.h"
#if defined(__FreeBSD_version) || defined(__NetBSD__)
#if defined(__FreeBSD__) || defined(__NetBSD__)
# include <sys/malloc.h>
#endif
/* END OF INCLUDES */
@ -443,7 +443,7 @@ ipf_log_pkt(fin, flags)
COPYIFNAME(fin->fin_v, ifp, ipfl.fl_ifname);
# else
# if (defined(NetBSD) && (NetBSD <= 1991011) && (NetBSD >= 199603)) || \
defined(__FreeBSD_version)
defined(__FreeBSD__)
COPYIFNAME(fin->fin_v, ifp, ipfl.fl_ifname);
# else
ipfl.fl_unit = (u_int)ifp->if_unit;

View File

@ -15,7 +15,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/file.h>
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
# include <sys/fcntl.h>
# include <sys/filio.h>
#else

View File

@ -31,7 +31,7 @@ struct file;
# include <sys/uio.h>
# undef KERNEL
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -55,11 +55,11 @@ struct file;
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/queue.h>
#endif
#include <net/if.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <net/if_var.h>
#endif
#ifdef sun
@ -90,7 +90,7 @@ extern struct ifnet vpnif;
#include "netinet/ip_lookup.h"
#include "netinet/ip_dstlist.h"
#include "netinet/ip_sync.h"
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif
#ifdef HAS_SYS_MD5_H
@ -1017,7 +1017,7 @@ ipf_nat_ioctl(softc, data, cmd, mode, uid, ctx)
KAUTH_REQ_NETWORK_FIREWALL_FW,
NULL, NULL, NULL))
# else
# if defined(__FreeBSD_version)
# if defined(__FreeBSD__)
if (securelevel_ge(curthread->td_ucred, 3) && (mode & FWRITE))
# else
if ((securelevel >= 3) && (mode & FWRITE))

View File

@ -29,7 +29,7 @@ struct file;
# include <sys/uio.h>
# undef _KERNEL
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -53,11 +53,11 @@ struct file;
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/queue.h>
#endif
#include <net/if.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <net/if_var.h>
#endif
#ifdef sun
@ -88,7 +88,7 @@ extern struct ifnet vpnif;
#include "netinet/ip_lookup.h"
#include "netinet/ip_dstlist.h"
#include "netinet/ip_sync.h"
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif
#ifdef HAS_SYS_MD5_H

View File

@ -38,7 +38,7 @@
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif

View File

@ -29,7 +29,7 @@
# include <sys/protosw.h>
#include <sys/socket.h>
#if defined(_KERNEL)
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/ctype.h>
# endif
# include <sys/systm.h>
@ -37,7 +37,7 @@
# include <sys/mbuf.h>
# endif
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -51,11 +51,11 @@
# include <sys/stream.h>
# include <sys/kmem.h>
#endif
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/queue.h>
#endif
#include <net/if.h>
#if defined(__FreeBSD_version) && defined(_KERNEL)
#if defined(__FreeBSD__) && defined(_KERNEL)
#include <net/vnet.h>
#else
#define CURVNET_SET(arg)
@ -80,7 +80,7 @@
#include "netinet/ip_nat.h"
#include "netinet/ip_state.h"
#include "netinet/ip_proxy.h"
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
#endif

View File

@ -12,7 +12,7 @@
#include <sys/types.h>
#include <sys/time.h>
#include <sys/socket.h>
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# if defined(_KERNEL)
# include <sys/libkern.h>
# else

View File

@ -19,7 +19,7 @@
#include <sys/types.h>
#include <sys/param.h>
#include <sys/file.h>
#if defined(_KERNEL) && defined(__FreeBSD_version) && \
#if defined(_KERNEL) && defined(__FreeBSD__) && \
!defined(KLD_MODULE)
#include "opt_inet6.h"
#endif
@ -31,7 +31,7 @@
# include <sys/uio.h>
# undef _KERNEL
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -82,7 +82,7 @@
#ifdef USE_INET6
#include <netinet/icmp6.h>
#endif
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/malloc.h>
# if defined(_KERNEL) && !defined(IPFILTER_LKM)
# include <sys/libkern.h>
@ -307,7 +307,7 @@ ipf_state_seed_alloc(u_int state_size, u_int state_max)
/*
* XXX - ipf_state_seed[X] should be a random number of sorts.
*/
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
state_seed[i] = arc4random();
#else
state_seed[i] = ((u_long)state_seed + i) * state_size;

View File

@ -30,14 +30,14 @@
# include <sys/mbuf.h>
# endif
# include <sys/select.h>
# ifdef __FreeBSD_version
# ifdef __FreeBSD__
# include <sys/selinfo.h>
# endif
#endif
#if defined(__NetBSD__) && (__NetBSD_Version__ >= 104000000)
# include <sys/proc.h>
#endif
#if defined(_KERNEL) && defined(__FreeBSD_version)
#if defined(_KERNEL) && defined(__FreeBSD__)
# include <sys/filio.h>
# include <sys/fcntl.h>
#else
@ -79,7 +79,7 @@
#ifdef USE_INET6
#include <netinet/icmp6.h>
#endif
#if defined(__FreeBSD_version)
#if defined(__FreeBSD__)
# include <sys/malloc.h>
# if defined(_KERNEL) && !defined(IPFILTER_LKM)
# include <sys/libkern.h>

View File

@ -22,7 +22,7 @@
#include <sys/socket.h>
#include <sys/sysctl.h>
#include <sys/select.h>
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/selinfo.h>
# include <sys/jail.h>
# ifdef _KERNEL
@ -52,7 +52,7 @@
VNET_DECLARE(ipf_main_softc_t, ipfmain);
#define V_ipfmain VNET(ipfmain)
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
static struct cdev *ipf_devs[IPL_LOGSIZE];
#else
static dev_t ipf_devs[IPL_LOGSIZE];
@ -68,7 +68,7 @@ static int ipf_modunload(void);
static int ipf_fbsd_sysctl_create(void);
static int ipf_fbsd_sysctl_destroy(void);
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
static int ipfopen(struct cdev*, int, int, struct thread *);
static int ipfclose(struct cdev*, int, int, struct thread *);
static int ipfread(struct cdev*, struct uio *, int);
@ -135,7 +135,7 @@ SYSCTL_IPF(_net_inet_ipf, OID_AUTO, fr_minttl, CTLFLAG_RW, &VNET_NAME(ipfmain.ip
#define CDEV_MAJOR 79
#include <sys/poll.h>
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
# include <sys/select.h>
static int ipfpoll(struct cdev *dev, int events, struct thread *td);
@ -417,7 +417,7 @@ sysctl_ipf_int_frag ( SYSCTL_HANDLER_ARGS )
static int
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
ipfpoll(struct cdev *dev, int events, struct thread *td)
#else
ipfpoll(dev_t dev, int events, struct proc *td)
@ -470,7 +470,7 @@ ipfpoll(dev_t dev, int events, struct proc *td)
* routines below for saving IP headers to buffer
*/
static int ipfopen(dev, flags
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
, devtype, p)
int devtype;
struct thread *p;
@ -510,7 +510,7 @@ static int ipfopen(dev, flags
static int ipfclose(dev, flags
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
, devtype, p)
int devtype;
struct thread *p;
@ -538,7 +538,7 @@ static int ipfclose(dev, flags
*/
static int ipfread(dev, uio, ioflag)
int ioflag;
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
struct cdev *dev;
#else
dev_t dev;
@ -581,7 +581,7 @@ static int ipfread(dev, uio, ioflag)
*/
static int ipfwrite(dev, uio, ioflag)
int ioflag;
#ifdef __FreeBSD_version
#ifdef __FreeBSD__
struct cdev *dev;
#else
dev_t dev;