From 6d0528abdfecb0a45eec1ee51b594803b1e11866 Mon Sep 17 00:00:00 2001 From: tjr Date: Mon, 16 Aug 2004 07:28:16 +0000 Subject: Changes to MI Linux emulation code necessary to run 32-bit Linux binaries on AMD64, and the general case where the emulated platform has different size pointers than we use natively: - declare certain structure members as l_uintptr_t and use the new PTRIN and PTROUT macros to convert to and from native pointers. - declare some structures __packed on amd64 when the layout would differ from that used on i386. - include instead of if compiling with COMPAT_LINUX32. This will need to be revisited before 32-bit and 64-bit Linux emulation support can coexist in the same kernel. - other small scattered changes. This should be a no-op on i386 and Alpha. --- sys/compat/linux/linux_file.c | 27 +++++++++++++++++++++------ 1 file changed, 21 insertions(+), 6 deletions(-) (limited to 'sys/compat/linux/linux_file.c') diff --git a/sys/compat/linux/linux_file.c b/sys/compat/linux/linux_file.c index 8200faf..8102b18 100644 --- a/sys/compat/linux/linux_file.c +++ b/sys/compat/linux/linux_file.c @@ -54,8 +54,15 @@ __FBSDID("$FreeBSD$"); #include #include +#include "opt_compat.h" + +#if !COMPAT_LINUX32 #include #include +#else +#include +#include +#endif #include #ifndef __alpha__ @@ -827,7 +834,11 @@ struct l_flock { l_off_t l_start; l_off_t l_len; l_pid_t l_pid; -}; +} +#if __amd64__ && COMPAT_LINUX32 +__packed +#endif +; static void linux_to_bsd_flock(struct l_flock *linux_flock, struct flock *bsd_flock) @@ -872,14 +883,18 @@ bsd_to_linux_flock(struct flock *bsd_flock, struct l_flock *linux_flock) linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid; } -#if defined(__i386__) +#if defined(__i386__) || (defined(__amd64__) && COMPAT_LINUX32) struct l_flock64 { l_short l_type; l_short l_whence; l_loff_t l_start; l_loff_t l_len; l_pid_t l_pid; -}; +} +#if __amd64__ && COMPAT_LINUX32 +__packed +#endif +; static void linux_to_bsd_flock64(struct l_flock64 *linux_flock, struct flock *bsd_flock) @@ -923,7 +938,7 @@ bsd_to_linux_flock64(struct flock *bsd_flock, struct l_flock64 *linux_flock) linux_flock->l_len = (l_loff_t)bsd_flock->l_len; linux_flock->l_pid = (l_pid_t)bsd_flock->l_pid; } -#endif /* __i386__ */ +#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ #if defined(__alpha__) #define linux_fcntl64_args linux_fcntl_args @@ -1051,7 +1066,7 @@ linux_fcntl(struct thread *td, struct linux_fcntl_args *args) return (fcntl_common(td, &args64)); } -#if defined(__i386__) +#if defined(__i386__) || (defined(__amd64__) && COMPAT_LINUX32) int linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args) { @@ -1099,7 +1114,7 @@ linux_fcntl64(struct thread *td, struct linux_fcntl64_args *args) return (fcntl_common(td, args)); } -#endif /* __i386__ */ +#endif /* __i386__ || (__amd64__ && COMPAT_LINUX32) */ int linux_chown(struct thread *td, struct linux_chown_args *args) -- cgit v1.1