Centralize compatability translation macros.
Copy the CP, PTRIN, etc macros from freebsd32.h into a sys/abi_compat.h and replace existing definitation with includes where required. This eliminates duplicate code and allows Linux and FreeBSD compatability headers to be included in the same files. Input from: cem, jhb Obtained from: CheriBSD MFC after: 2 weeks Sponsored by: DARPA Differential Revision: https://reviews.freebsd.org/D24275
This commit is contained in:
parent
c23ca622a2
commit
562894f0dc
@ -32,6 +32,8 @@
|
|||||||
#ifndef _AMD64_LINUX_H_
|
#ifndef _AMD64_LINUX_H_
|
||||||
#define _AMD64_LINUX_H_
|
#define _AMD64_LINUX_H_
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
|
||||||
#include <compat/linux/linux.h>
|
#include <compat/linux/linux.h>
|
||||||
#include <amd64/linux/linux_syscall.h>
|
#include <amd64/linux/linux_syscall.h>
|
||||||
|
|
||||||
@ -39,14 +41,6 @@
|
|||||||
|
|
||||||
#define LINUX_DTRACE linuxulator
|
#define LINUX_DTRACE linuxulator
|
||||||
|
|
||||||
#define PTRIN(v) (void *)(v)
|
|
||||||
#define PTROUT(v) (uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provide a separate set of types for the Linux types.
|
* Provide a separate set of types for the Linux types.
|
||||||
*/
|
*/
|
||||||
|
@ -35,6 +35,8 @@
|
|||||||
#ifndef _AMD64_LINUX_H_
|
#ifndef _AMD64_LINUX_H_
|
||||||
#define _AMD64_LINUX_H_
|
#define _AMD64_LINUX_H_
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
|
||||||
#include <compat/linux/linux.h>
|
#include <compat/linux/linux.h>
|
||||||
#include <amd64/linux32/linux32_syscall.h>
|
#include <amd64/linux32/linux32_syscall.h>
|
||||||
|
|
||||||
@ -52,14 +54,6 @@
|
|||||||
#define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */
|
#define LINUX32_MAXSSIZ (64 * 1024 * 1024) /* 64MB */
|
||||||
#define LINUX32_MAXVMEM 0 /* Unlimited */
|
#define LINUX32_MAXVMEM 0 /* Unlimited */
|
||||||
|
|
||||||
#define PTRIN(v) (void *)(uintptr_t)(v)
|
|
||||||
#define PTROUT(v) (l_uintptr_t)(uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provide a separate set of types for the Linux types.
|
* Provide a separate set of types for the Linux types.
|
||||||
*/
|
*/
|
||||||
|
@ -31,19 +31,13 @@
|
|||||||
#ifndef _ARM64_LINUX_H_
|
#ifndef _ARM64_LINUX_H_
|
||||||
#define _ARM64_LINUX_H_
|
#define _ARM64_LINUX_H_
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
|
||||||
#include <compat/linux/linux.h>
|
#include <compat/linux/linux.h>
|
||||||
#include <arm64/linux/linux_syscall.h>
|
#include <arm64/linux/linux_syscall.h>
|
||||||
|
|
||||||
#define LINUX_DTRACE linuxulator
|
#define LINUX_DTRACE linuxulator
|
||||||
|
|
||||||
#define PTRIN(v) (void *)(v)
|
|
||||||
#define PTROUT(v) (uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
|
|
||||||
/* Provide a separate set of types for the Linux types */
|
/* Provide a separate set of types for the Linux types */
|
||||||
typedef int32_t l_int;
|
typedef int32_t l_int;
|
||||||
typedef int64_t l_long;
|
typedef int64_t l_long;
|
||||||
|
@ -31,19 +31,11 @@
|
|||||||
#ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
|
#ifndef _COMPAT_FREEBSD32_FREEBSD32_H_
|
||||||
#define _COMPAT_FREEBSD32_FREEBSD32_H_
|
#define _COMPAT_FREEBSD32_FREEBSD32_H_
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/procfs.h>
|
#include <sys/procfs.h>
|
||||||
#include <sys/socket.h>
|
#include <sys/socket.h>
|
||||||
#include <sys/user.h>
|
#include <sys/user.h>
|
||||||
|
|
||||||
#define PTRIN(v) (void *)(uintptr_t) (v)
|
|
||||||
#define PTROUT(v) (u_int32_t)(uintptr_t) (v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
#define PTROUT_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTROUT((src).fld); } while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* i386 is the only arch with a 32-bit time_t
|
* i386 is the only arch with a 32-bit time_t
|
||||||
*/
|
*/
|
||||||
@ -57,37 +49,21 @@ struct timeval32 {
|
|||||||
time32_t tv_sec;
|
time32_t tv_sec;
|
||||||
int32_t tv_usec;
|
int32_t tv_usec;
|
||||||
};
|
};
|
||||||
#define TV_CP(src,dst,fld) do { \
|
|
||||||
CP((src).fld,(dst).fld,tv_sec); \
|
|
||||||
CP((src).fld,(dst).fld,tv_usec); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct timespec32 {
|
struct timespec32 {
|
||||||
time32_t tv_sec;
|
time32_t tv_sec;
|
||||||
int32_t tv_nsec;
|
int32_t tv_nsec;
|
||||||
};
|
};
|
||||||
#define TS_CP(src,dst,fld) do { \
|
|
||||||
CP((src).fld,(dst).fld,tv_sec); \
|
|
||||||
CP((src).fld,(dst).fld,tv_nsec); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct itimerspec32 {
|
struct itimerspec32 {
|
||||||
struct timespec32 it_interval;
|
struct timespec32 it_interval;
|
||||||
struct timespec32 it_value;
|
struct timespec32 it_value;
|
||||||
};
|
};
|
||||||
#define ITS_CP(src, dst) do { \
|
|
||||||
TS_CP((src), (dst), it_interval); \
|
|
||||||
TS_CP((src), (dst), it_value); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct bintime32 {
|
struct bintime32 {
|
||||||
time32_t sec;
|
time32_t sec;
|
||||||
uint32_t frac[2];
|
uint32_t frac[2];
|
||||||
};
|
};
|
||||||
#define BT_CP(src, dst, fld) do { \
|
|
||||||
CP((src).fld, (dst).fld, sec); \
|
|
||||||
*(uint64_t *)&(dst).fld.frac[0] = (src).fld.frac; \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct rusage32 {
|
struct rusage32 {
|
||||||
struct timeval32 ru_utime;
|
struct timeval32 ru_utime;
|
||||||
|
@ -34,6 +34,9 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/sysproto.h>
|
#include <sys/sysproto.h>
|
||||||
|
#ifdef COMPAT_LINUX32
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
#endif
|
||||||
#include <sys/capsicum.h>
|
#include <sys/capsicum.h>
|
||||||
#include <sys/cdio.h>
|
#include <sys/cdio.h>
|
||||||
#include <sys/dvdio.h>
|
#include <sys/dvdio.h>
|
||||||
@ -2543,12 +2546,6 @@ linux_ioctl_drm(struct thread *td, struct linux_ioctl_args *args)
|
|||||||
}
|
}
|
||||||
|
|
||||||
#ifdef COMPAT_LINUX32
|
#ifdef COMPAT_LINUX32
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
#define PTROUT_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTROUT((src).fld); } while (0)
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
linux_ioctl_sg_io(struct thread *td, struct linux_ioctl_args *args)
|
linux_ioctl_sg_io(struct thread *td, struct linux_ioctl_args *args)
|
||||||
{
|
{
|
||||||
|
@ -33,6 +33,8 @@
|
|||||||
#ifndef _LINUX_TIMER_H
|
#ifndef _LINUX_TIMER_H
|
||||||
#define _LINUX_TIMER_H
|
#define _LINUX_TIMER_H
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
|
||||||
#ifndef __LINUX_ARCH_SIGEV_PREAMBLE_SIZE
|
#ifndef __LINUX_ARCH_SIGEV_PREAMBLE_SIZE
|
||||||
#define __LINUX_ARCH_SIGEV_PREAMBLE_SIZE \
|
#define __LINUX_ARCH_SIGEV_PREAMBLE_SIZE \
|
||||||
(sizeof(l_int) * 2 + sizeof(l_sigval_t))
|
(sizeof(l_int) * 2 + sizeof(l_sigval_t))
|
||||||
@ -79,16 +81,6 @@
|
|||||||
#define L_SIGEV_THREAD 2
|
#define L_SIGEV_THREAD 2
|
||||||
#define L_SIGEV_THREAD_ID 4
|
#define L_SIGEV_THREAD_ID 4
|
||||||
|
|
||||||
#define TS_CP(src,dst,fld) do { \
|
|
||||||
CP((src).fld,(dst).fld,tv_sec); \
|
|
||||||
CP((src).fld,(dst).fld,tv_nsec); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
#define ITS_CP(src, dst) do { \
|
|
||||||
TS_CP((src), (dst), it_interval); \
|
|
||||||
TS_CP((src), (dst), it_value); \
|
|
||||||
} while (0)
|
|
||||||
|
|
||||||
struct l_sigevent {
|
struct l_sigevent {
|
||||||
l_sigval_t sigev_value;
|
l_sigval_t sigev_value;
|
||||||
l_int sigev_signo;
|
l_int sigev_signo;
|
||||||
|
@ -55,6 +55,10 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <dev/ipmi/ipmivars.h>
|
#include <dev/ipmi/ipmivars.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#ifdef IPMICTL_SEND_COMMAND_32
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
#endif
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Driver request structures are allocated on the stack via alloca() to
|
* Driver request structures are allocated on the stack via alloca() to
|
||||||
* avoid calling malloc(), especially for the watchdog handler.
|
* avoid calling malloc(), especially for the watchdog handler.
|
||||||
@ -315,11 +319,6 @@ ipmi_handle_attn(struct ipmi_softc *sc)
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#ifdef IPMICTL_SEND_COMMAND_32
|
|
||||||
#define PTRIN(p) ((void *)(uintptr_t)(p))
|
|
||||||
#define PTROUT(p) ((uintptr_t)(p))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
ipmi_ioctl(struct cdev *cdev, u_long cmd, caddr_t data,
|
ipmi_ioctl(struct cdev *cdev, u_long cmd, caddr_t data,
|
||||||
int flags, struct thread *td)
|
int flags, struct thread *td)
|
||||||
|
@ -74,6 +74,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -178,16 +179,6 @@ static int mpr_user_btdh(struct mpr_softc *sc, mpr_btdh_mapping_t *data);
|
|||||||
|
|
||||||
static MALLOC_DEFINE(M_MPRUSER, "mpr_user", "Buffers for mpr(4) ioctls");
|
static MALLOC_DEFINE(M_MPRUSER, "mpr_user", "Buffers for mpr(4) ioctls");
|
||||||
|
|
||||||
/* Macros from compat/freebsd32/freebsd32.h */
|
|
||||||
#define PTRIN(v) (void *)(uintptr_t)(v)
|
|
||||||
#define PTROUT(v) (uint32_t)(uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
#define PTROUT_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTROUT((src).fld); } while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* MPI functions that support IEEE SGLs for SAS3.
|
* MPI functions that support IEEE SGLs for SAS3.
|
||||||
*/
|
*/
|
||||||
|
@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/bus.h>
|
#include <sys/bus.h>
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
#include <sys/bio.h>
|
#include <sys/bio.h>
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/malloc.h>
|
#include <sys/malloc.h>
|
||||||
#include <sys/uio.h>
|
#include <sys/uio.h>
|
||||||
#include <sys/sysctl.h>
|
#include <sys/sysctl.h>
|
||||||
@ -180,16 +181,6 @@ static int mps_user_btdh(struct mps_softc *sc, mps_btdh_mapping_t *data);
|
|||||||
|
|
||||||
MALLOC_DEFINE(M_MPSUSER, "mps_user", "Buffers for mps(4) ioctls");
|
MALLOC_DEFINE(M_MPSUSER, "mps_user", "Buffers for mps(4) ioctls");
|
||||||
|
|
||||||
/* Macros from compat/freebsd32/freebsd32.h */
|
|
||||||
#define PTRIN(v) (void *)(uintptr_t)(v)
|
|
||||||
#define PTROUT(v) (uint32_t)(uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
#define PTROUT_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTROUT((src).fld); } while (0)
|
|
||||||
|
|
||||||
int
|
int
|
||||||
mps_attach_user(struct mps_softc *sc)
|
mps_attach_user(struct mps_softc *sc)
|
||||||
{
|
{
|
||||||
|
@ -36,6 +36,9 @@
|
|||||||
__FBSDID("$FreeBSD$");
|
__FBSDID("$FreeBSD$");
|
||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
|
#ifdef __amd64__
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
|
#endif
|
||||||
#include <sys/conf.h>
|
#include <sys/conf.h>
|
||||||
#include <sys/errno.h>
|
#include <sys/errno.h>
|
||||||
#include <sys/ioccom.h>
|
#include <sys/ioccom.h>
|
||||||
@ -588,11 +591,6 @@ mpt_user_raid_action(struct mpt_softc *mpt, struct mpt_raid_action *raid_act,
|
|||||||
return (0);
|
return (0);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef __amd64__
|
|
||||||
#define PTRIN(p) ((void *)(uintptr_t)(p))
|
|
||||||
#define PTROUT(v) ((u_int32_t)(uintptr_t)(v))
|
|
||||||
#endif
|
|
||||||
|
|
||||||
static int
|
static int
|
||||||
mpt_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
|
mpt_ioctl(struct cdev *dev, u_long cmd, caddr_t arg, int flag, struct thread *td)
|
||||||
{
|
{
|
||||||
|
@ -30,6 +30,7 @@
|
|||||||
#ifndef _I386_LINUX_H_
|
#ifndef _I386_LINUX_H_
|
||||||
#define _I386_LINUX_H_
|
#define _I386_LINUX_H_
|
||||||
|
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/signal.h> /* for sigval union */
|
#include <sys/signal.h> /* for sigval union */
|
||||||
|
|
||||||
#include <compat/linux/linux.h>
|
#include <compat/linux/linux.h>
|
||||||
@ -42,14 +43,6 @@
|
|||||||
#define LINUX_SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
|
#define LINUX_SHAREDPAGE (VM_MAXUSER_ADDRESS - PAGE_SIZE)
|
||||||
#define LINUX_USRSTACK LINUX_SHAREDPAGE
|
#define LINUX_USRSTACK LINUX_SHAREDPAGE
|
||||||
|
|
||||||
#define PTRIN(v) (void *)(v)
|
|
||||||
#define PTROUT(v) (l_uintptr_t)(v)
|
|
||||||
|
|
||||||
#define CP(src,dst,fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#define CP2(src,dst,sfld,dfld) do { (dst).dfld = (src).sfld; } while (0)
|
|
||||||
#define PTRIN_CP(src,dst,fld) \
|
|
||||||
do { (dst).fld = PTRIN((src).fld); } while (0)
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Provide a separate set of types for the Linux types.
|
* Provide a separate set of types for the Linux types.
|
||||||
*/
|
*/
|
||||||
|
@ -52,6 +52,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
#include <sys/sysproto.h>
|
#include <sys/sysproto.h>
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/eventhandler.h>
|
#include <sys/eventhandler.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/proc.h>
|
#include <sys/proc.h>
|
||||||
@ -1752,10 +1753,6 @@ sys_semsys(td, uap)
|
|||||||
return (error);
|
return (error);
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifndef CP
|
|
||||||
#define CP(src, dst, fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _SYS_SYSPROTO_H_
|
#ifndef _SYS_SYSPROTO_H_
|
||||||
struct freebsd7___semctl_args {
|
struct freebsd7___semctl_args {
|
||||||
int semid;
|
int semid;
|
||||||
|
@ -75,6 +75,7 @@ __FBSDID("$FreeBSD$");
|
|||||||
|
|
||||||
#include <sys/param.h>
|
#include <sys/param.h>
|
||||||
#include <sys/systm.h>
|
#include <sys/systm.h>
|
||||||
|
#include <sys/abi_compat.h>
|
||||||
#include <sys/kernel.h>
|
#include <sys/kernel.h>
|
||||||
#include <sys/limits.h>
|
#include <sys/limits.h>
|
||||||
#include <sys/lock.h>
|
#include <sys/lock.h>
|
||||||
@ -1593,10 +1594,6 @@ done:
|
|||||||
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
|
#if defined(COMPAT_FREEBSD4) || defined(COMPAT_FREEBSD5) || \
|
||||||
defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
|
defined(COMPAT_FREEBSD6) || defined(COMPAT_FREEBSD7)
|
||||||
|
|
||||||
#ifndef CP
|
|
||||||
#define CP(src, dst, fld) do { (dst).fld = (src).fld; } while (0)
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifndef _SYS_SYSPROTO_H_
|
#ifndef _SYS_SYSPROTO_H_
|
||||||
struct freebsd7_shmctl_args {
|
struct freebsd7_shmctl_args {
|
||||||
int shmid;
|
int shmid;
|
||||||
|
77
sys/sys/abi_compat.h
Normal file
77
sys/sys/abi_compat.h
Normal file
@ -0,0 +1,77 @@
|
|||||||
|
/*-
|
||||||
|
* SPDX-License-Identifier: BSD-2-Clause-FreeBSD
|
||||||
|
*
|
||||||
|
* Copyright (c) 2001 Doug Rabson
|
||||||
|
* All rights reserved.
|
||||||
|
*
|
||||||
|
* 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.
|
||||||
|
*
|
||||||
|
* $FreeBSD$
|
||||||
|
*/
|
||||||
|
|
||||||
|
#ifndef _COMPAT_H_
|
||||||
|
#define _COMPAT_H_
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Helper macros for translating objects between different ABIs.
|
||||||
|
*/
|
||||||
|
|
||||||
|
#define PTRIN(v) (void *)(uintptr_t)(v)
|
||||||
|
#define PTROUT(v) (uintptr_t)(v)
|
||||||
|
|
||||||
|
#define CP(src, dst, fld) do { \
|
||||||
|
(dst).fld = (src).fld; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define CP2(src, dst, sfld, dfld) do { \
|
||||||
|
(dst).dfld = (src).sfld; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define PTRIN_CP(src, dst, fld) do { \
|
||||||
|
(dst).fld = PTRIN((src).fld); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define PTROUT_CP(src, dst, fld) do { \
|
||||||
|
(dst).fld = PTROUT((src).fld); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define TV_CP(src, dst, fld) do { \
|
||||||
|
CP((src).fld, (dst).fld, tv_sec); \
|
||||||
|
CP((src).fld, (dst).fld, tv_usec); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define TS_CP(src, dst, fld) do { \
|
||||||
|
CP((src).fld, (dst).fld, tv_sec); \
|
||||||
|
CP((src).fld, (dst).fld, tv_nsec); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define ITS_CP(src, dst) do { \
|
||||||
|
TS_CP((src), (dst), it_interval); \
|
||||||
|
TS_CP((src), (dst), it_value); \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#define BT_CP(src, dst, fld) do { \
|
||||||
|
CP((src).fld, (dst).fld, sec); \
|
||||||
|
*(uint64_t *)&(dst).fld.frac[0] = (src).fld.frac; \
|
||||||
|
} while (0)
|
||||||
|
|
||||||
|
#endif /* !_COMPAT_H_ */
|
Loading…
x
Reference in New Issue
Block a user