Applied, thanks!

Luca Dariz, le sam. 09 mars 2024 15:02:44 +0100, a ecrit:
> From: LD <l...@orpolo.org>
> 
> ---
>  Makefrag.am                    |  2 ++
>  i386/Makefrag.am               |  1 -
>  {x86_64 => ipc}/copy_user.c    |  7 +++++--
>  {i386/i386 => ipc}/copy_user.h | 18 +++++++++---------
>  ipc/ipc_kmsg.c                 |  2 +-
>  ipc/ipc_mqueue.c               |  2 +-
>  ipc/mach_msg.c                 |  2 +-
>  kern/ipc_mig.c                 |  2 +-
>  x86_64/Makefrag.am             |  1 -
>  9 files changed, 20 insertions(+), 17 deletions(-)
>  rename {x86_64 => ipc}/copy_user.c (99%)
>  rename {i386/i386 => ipc}/copy_user.h (90%)
> 
> diff --git a/Makefrag.am b/Makefrag.am
> index 5b61a1d6..82fce628 100644
> --- a/Makefrag.am
> +++ b/Makefrag.am
> @@ -76,6 +76,8 @@ endif
>  #
>  
>  libkernel_a_SOURCES += \
> +     ipc/copy_user.c \
> +     ipc/copy_user.h \
>       ipc/ipc_entry.c \
>       ipc/ipc_entry.h \
>       ipc/ipc_init.c \
> diff --git a/i386/Makefrag.am b/i386/Makefrag.am
> index 58ee3273..5e7d4740 100644
> --- a/i386/Makefrag.am
> +++ b/i386/Makefrag.am
> @@ -91,7 +91,6 @@ endif
>  #
>  
>  libkernel_a_SOURCES += \
> -     i386/i386/copy_user.h \
>       i386/i386/cswitch.S \
>       i386/i386/debug_trace.S \
>       i386/i386/idt_inittab.S \
> diff --git a/x86_64/copy_user.c b/ipc/copy_user.c
> similarity index 99%
> rename from x86_64/copy_user.c
> rename to ipc/copy_user.c
> index c6e125d9..5c6329d3 100644
> --- a/x86_64/copy_user.c
> +++ b/ipc/copy_user.c
> @@ -16,14 +16,15 @@
>   * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
>   */
>  
> +#ifdef __LP64__
> +
>  #include <stddef.h>
>  #include <string.h>
>  
> +#include <ipc/copy_user.h>
>  #include <kern/debug.h>
>  #include <mach/boolean.h>
>  
> -#include <copy_user.h>
> -
>  
>  /* Mach field descriptors measure size in bits */
>  #define descsize_to_bytes(n) (n / 8)
> @@ -611,3 +612,5 @@ int copyoutmsg (const void *kernelbuf, void *userbuf, 
> const size_t ksize)
>    return 0;
>  
>  }
> +
> +#endif /* __LP64__ */
> diff --git a/i386/i386/copy_user.h b/ipc/copy_user.h
> similarity index 90%
> rename from i386/i386/copy_user.h
> rename to ipc/copy_user.h
> index 3d1c7278..a57b3ee5 100644
> --- a/i386/i386/copy_user.h
> +++ b/ipc/copy_user.h
> @@ -28,7 +28,7 @@
>  /*
>   * The copyin_32to64() and copyout_64to32() routines are meant for data types
>   * that have different size in kernel and user space. They should be 
> independent
> - * of endianness and hopefully can be reused in the future on other archs.
> + * of endianness and hopefully can be reused on all archs.
>   * These types are e.g.:
>   * - port names vs port pointers, on a 64-bit kernel
>   * - memory addresses, on a 64-bit kernel and 32-bit user
> @@ -71,23 +71,23 @@ static inline int copyout_address(const vm_offset_t 
> *kaddr, rpc_vm_offset_t *uad
>  
>  static inline int copyin_port(const mach_port_name_t *uaddr, mach_port_t 
> *kaddr)
>  {
> -#ifdef __x86_64__
> +#ifdef __LP64__
>    return copyin_32to64(uaddr, kaddr);
> -#else /* __x86_64__ */
> +#else /* __LP64__ */
>    return copyin(uaddr, kaddr, sizeof(*uaddr));
> -#endif /* __x86_64__ */
> +#endif /* __LP64__ */
>  }
>  
>  static inline int copyout_port(const mach_port_t *kaddr, mach_port_name_t 
> *uaddr)
>  {
> -#ifdef __x86_64__
> +#ifdef __LP64__
>    return copyout_64to32(kaddr, uaddr);
> -#else /* __x86_64__ */
> +#else /* __LP64__ */
>    return copyout(kaddr, uaddr, sizeof(*kaddr));
> -#endif /* __x86_64__ */
> +#endif /* __LP64__ */
>  }
>  
> -#if defined(__x86_64__) && defined(USER32)
> +#if defined(__LP64__) && defined(USER32)
>  /* For 32 bit userland, kernel and user land messages are not the same size. 
> */
>  size_t msg_usize(const mach_msg_header_t *kmsg);
>  #else
> @@ -95,6 +95,6 @@ static inline size_t msg_usize(const mach_msg_header_t 
> *kmsg)
>  {
>    return kmsg->msgh_size;
>  }
> -#endif /* __x86_64__ && USER32 */
> +#endif /* __LP64__ && USER32 */
>  
>  #endif /* COPY_USER_H */
> diff --git a/ipc/ipc_kmsg.c b/ipc/ipc_kmsg.c
> index bd843804..8bd645ff 100644
> --- a/ipc/ipc_kmsg.c
> +++ b/ipc/ipc_kmsg.c
> @@ -42,7 +42,6 @@
>  #include <mach/message.h>
>  #include <mach/port.h>
>  #include <machine/locore.h>
> -#include <machine/copy_user.h>
>  #include <kern/assert.h>
>  #include <kern/debug.h>
>  #include <kern/kalloc.h>
> @@ -51,6 +50,7 @@
>  #include <vm/vm_kern.h>
>  #include <vm/vm_user.h>
>  #include <ipc/port.h>
> +#include <ipc/copy_user.h>
>  #include <ipc/ipc_entry.h>
>  #include <ipc/ipc_kmsg.h>
>  #include <ipc/ipc_thread.h>
> diff --git a/ipc/ipc_mqueue.c b/ipc/ipc_mqueue.c
> index 44e1eb98..95308f35 100644
> --- a/ipc/ipc_mqueue.c
> +++ b/ipc/ipc_mqueue.c
> @@ -36,13 +36,13 @@
>  
>  #include <mach/port.h>
>  #include <mach/message.h>
> -#include <machine/copy_user.h>
>  #include <kern/assert.h>
>  #include <kern/counters.h>
>  #include <kern/debug.h>
>  #include <kern/sched_prim.h>
>  #include <kern/ipc_sched.h>
>  #include <kern/ipc_kobject.h>
> +#include <ipc/copy_user.h>
>  #include <ipc/ipc_mqueue.h>
>  #include <ipc/ipc_thread.h>
>  #include <ipc/ipc_kmsg.h>
> diff --git a/ipc/mach_msg.c b/ipc/mach_msg.c
> index 6194ef7b..ff5e5b09 100644
> --- a/ipc/mach_msg.c
> +++ b/ipc/mach_msg.c
> @@ -39,7 +39,6 @@
>  #include <mach/kern_return.h>
>  #include <mach/port.h>
>  #include <mach/message.h>
> -#include <machine/copy_user.h>
>  #include <kern/assert.h>
>  #include <kern/counters.h>
>  #include <kern/debug.h>
> @@ -49,6 +48,7 @@
>  #include <kern/ipc_sched.h>
>  #include <kern/exception.h>
>  #include <vm/vm_map.h>
> +#include <ipc/copy_user.h>
>  #include <ipc/ipc_kmsg.h>
>  #include <ipc/ipc_marequest.h>
>  #include <ipc/ipc_mqueue.h>
> diff --git a/kern/ipc_mig.c b/kern/ipc_mig.c
> index d26d2c6d..b753a25f 100644
> --- a/kern/ipc_mig.c
> +++ b/kern/ipc_mig.c
> @@ -30,7 +30,6 @@
>  #include <mach/mig_support.h>
>  #include <mach/thread_status.h>
>  #include <machine/locore.h>
> -#include <machine/copy_user.h>
>  #include <kern/ast.h>
>  #include <kern/debug.h>
>  #include <kern/ipc_tt.h>
> @@ -42,6 +41,7 @@
>  #include <kern/ipc_mig.h>
>  #include <vm/vm_map.h>
>  #include <vm/vm_user.h>
> +#include <ipc/copy_user.h>
>  #include <ipc/port.h>
>  #include <ipc/ipc_kmsg.h>
>  #include <ipc/ipc_entry.h>
> diff --git a/x86_64/Makefrag.am b/x86_64/Makefrag.am
> index b0bc45c2..2bbed986 100644
> --- a/x86_64/Makefrag.am
> +++ b/x86_64/Makefrag.am
> @@ -90,7 +90,6 @@ libkernel_a_SOURCES += \
>       i386/i386/percpu.h \
>       i386/i386/percpu.c \
>       x86_64/cswitch.S \
> -     x86_64/copy_user.c \
>       x86_64/debug_trace.S \
>       x86_64/idt_inittab.S \
>       x86_64/locore.S \
> -- 
> 2.39.2
> 
> 

-- 
Samuel
---
Pour une évaluation indépendante, transparente et rigoureuse !
Je soutiens la Commission d'Évaluation de l'Inria.

Reply via email to