Skip to content

Commit

Permalink
missing: Add syscall number for close_range()
Browse files Browse the repository at this point in the history
Taken from systemd, but replacing assert_cc with G_STATIC_ASSERT.

Signed-off-by: Simon McVittie <smcv@collabora.com>
  • Loading branch information
smcv committed Feb 9, 2024
1 parent f2ff19d commit 9d66aa7
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions glnx-missing-syscall.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
*/

#include "libglnx-config.h"
#include <glib.h>

#if !HAVE_DECL_RENAMEAT2
# ifndef __NR_renameat2
Expand Down Expand Up @@ -155,3 +156,71 @@ static inline ssize_t missing_copy_file_range(int fd_in, loff_t *off_in,

# define copy_file_range missing_copy_file_range
#endif

#ifndef __IGNORE_close_range
# if defined(__aarch64__)
# define systemd_NR_close_range 436
# elif defined(__alpha__)
# define systemd_NR_close_range 546
# elif defined(__arc__) || defined(__tilegx__)
# define systemd_NR_close_range 436
# elif defined(__arm__)
# define systemd_NR_close_range 436
# elif defined(__i386__)
# define systemd_NR_close_range 436
# elif defined(__ia64__)
# define systemd_NR_close_range 1460
# elif defined(__loongarch_lp64)
# define systemd_NR_close_range 436
# elif defined(__m68k__)
# define systemd_NR_close_range 436
# elif defined(_MIPS_SIM)
# if _MIPS_SIM == _MIPS_SIM_ABI32
# define systemd_NR_close_range 4436
# elif _MIPS_SIM == _MIPS_SIM_NABI32
# define systemd_NR_close_range 6436
# elif _MIPS_SIM == _MIPS_SIM_ABI64
# define systemd_NR_close_range 5436
# else
# error "Unknown MIPS ABI"
# endif
# elif defined(__hppa__)
# define systemd_NR_close_range 436
# elif defined(__powerpc__)
# define systemd_NR_close_range 436
# elif defined(__riscv)
# if __riscv_xlen == 32
# define systemd_NR_close_range 436
# elif __riscv_xlen == 64
# define systemd_NR_close_range 436
# else
# error "Unknown RISC-V ABI"
# endif
# elif defined(__s390__)
# define systemd_NR_close_range 436
# elif defined(__sparc__)
# define systemd_NR_close_range 436
# elif defined(__x86_64__)
# if defined(__ILP32__)
# define systemd_NR_close_range (436 | /* __X32_SYSCALL_BIT */ 0x40000000)
# else
# define systemd_NR_close_range 436
# endif
# elif !defined(missing_arch_template)
# warning "close_range() syscall number is unknown for your architecture"
# endif

/* may be an (invalid) negative number due to libseccomp, see PR 13319 */
# if defined __NR_close_range && __NR_close_range >= 0
# if defined systemd_NR_close_range
G_STATIC_ASSERT(__NR_close_range == systemd_NR_close_range);
# endif
# else
# if defined __NR_close_range
# undef __NR_close_range
# endif
# if defined systemd_NR_close_range && systemd_NR_close_range >= 0
# define __NR_close_range systemd_NR_close_range
# endif
# endif
#endif

0 comments on commit 9d66aa7

Please sign in to comment.