mbox series

[0/3] linux: Update the mremap C implementation [BZ #31968]

Message ID 20240712223147.1809816-1-hjl.tools@gmail.com
Headers show
Series linux: Update the mremap C implementation [BZ #31968] | expand

Message

H.J. Lu July 12, 2024, 10:31 p.m. UTC
1. Update the mremap C implementation to support the optional argument for
MREMAP_DONTUNMAP added in Linux 5.7 since it may not always be correct
to implement a variadic function as a non-variadic function on all Linux
targets.  Return MAP_FAILED and set errno to EINVAL for unknown flag bits.

2. Add linux-support.h with

/* Return an unsigned int from version, patch level and sub level of
   Linux kernel.  */
extern unsigned int make_linux_kernel_version (unsigned int __version,
					       unsigned int __patch,
					       unsigned int __sub);

/* Similar to make_linux_kernel_version, but version, patch level and
   sub level are retrieved from the uname system call.  */
extern unsigned int get_linux_kernel_version (void);

3. Add tests for MREMAP_MAYMOVE, MREMAP_FIXED and MREMAP_DONTUNMAP.  On
Linux, enable MREMAP_FIXED test for Linux kernel 2.3.31 and above.
Enable MREMAP_DONTUNMAP test for Linux kernel 5.7 and above.

H.J. Lu (3):
  linux: Update the mremap C implementation [BZ #31968]
  Support: Add linux-support.h
  Add mremap tests

 misc/Makefile                                 |  1 +
 misc/tst-mremap.c                             | 73 +++++++++++++++++++
 sysdeps/generic/tst-mremap.h                  | 24 ++++++
 sysdeps/unix/sysv/linux/Makefile              |  8 ++
 .../unix/sysv/linux/linux-kernel-version.c    | 62 ++++++++++++++++
 sysdeps/unix/sysv/linux/linux-support.h       | 38 ++++++++++
 sysdeps/unix/sysv/linux/mremap.c              | 14 +++-
 sysdeps/unix/sysv/linux/tst-mremap.h          | 67 +++++++++++++++++
 8 files changed, 286 insertions(+), 1 deletion(-)
 create mode 100644 misc/tst-mremap.c
 create mode 100644 sysdeps/generic/tst-mremap.h
 create mode 100644 sysdeps/unix/sysv/linux/linux-kernel-version.c
 create mode 100644 sysdeps/unix/sysv/linux/linux-support.h
 create mode 100644 sysdeps/unix/sysv/linux/tst-mremap.h