Blame libglnx/glnx-missing-syscall.h

Packit Service 2a3f3d
/***
Packit Service 2a3f3d
  This file was originally part of systemd.
Packit Service 2a3f3d
Packit Service 2a3f3d
  Copyright 2010 Lennart Poettering
Packit Service 2a3f3d
  Copyright 2016 Zbigniew Jędrzejewski-Szmek
Packit Service 2a3f3d
Packit Service 2a3f3d
  systemd is free software; you can redistribute it and/or modify it
Packit Service 2a3f3d
  under the terms of the GNU Lesser General Public License as published by
Packit Service 2a3f3d
  the Free Software Foundation; either version 2.1 of the License, or
Packit Service 2a3f3d
  (at your option) any later version.
Packit Service 2a3f3d
Packit Service 2a3f3d
  systemd is distributed in the hope that it will be useful, but
Packit Service 2a3f3d
  WITHOUT ANY WARRANTY; without even the implied warranty of
Packit Service 2a3f3d
  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Packit Service 2a3f3d
  Lesser General Public License for more details.
Packit Service 2a3f3d
Packit Service 2a3f3d
  You should have received a copy of the GNU Lesser General Public License
Packit Service 2a3f3d
  along with systemd; If not, see <http://www.gnu.org/licenses/>.
Packit Service 2a3f3d
***/
Packit Service 2a3f3d
Packit Service 2a3f3d
/* Missing glibc definitions to access certain kernel APIs.
Packit Service 2a3f3d
   This file is last updated from systemd git:
Packit Service 2a3f3d
Packit Service 2a3f3d
   commit 71e5200f94b22589922704aa4abdf95d4fe2e528
Packit Service 2a3f3d
   Author:     Daniel Mack <daniel@zonque.org>
Packit Service 2a3f3d
   AuthorDate: Tue Oct 18 17:57:10 2016 +0200
Packit Service 2a3f3d
   Commit:     Lennart Poettering <lennart@poettering.net>
Packit Service 2a3f3d
   CommitDate: Fri Sep 22 15:24:54 2017 +0200
Packit Service 2a3f3d
Packit Service 2a3f3d
   Add abstraction model for BPF programs
Packit Service 2a3f3d
*/
Packit Service 2a3f3d
Packit Service 2a3f3d
#include "config.h"
Packit Service 2a3f3d
Packit Service 2a3f3d
#if !HAVE_DECL_RENAMEAT2
Packit Service 2a3f3d
#  ifndef __NR_renameat2
Packit Service 2a3f3d
#    if defined __x86_64__
Packit Service 2a3f3d
#      define __NR_renameat2 316
Packit Service 2a3f3d
#    elif defined __arm__
Packit Service 2a3f3d
#      define __NR_renameat2 382
Packit Service 2a3f3d
#    elif defined __aarch64__
Packit Service 2a3f3d
#      define __NR_renameat2 276
Packit Service 2a3f3d
#    elif defined _MIPS_SIM
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_ABI32
Packit Service 2a3f3d
#        define __NR_renameat2 4351
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_NABI32
Packit Service 2a3f3d
#        define __NR_renameat2 6315
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_ABI64
Packit Service 2a3f3d
#        define __NR_renameat2 5311
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#    elif defined __i386__
Packit Service 2a3f3d
#      define __NR_renameat2 353
Packit Service 2a3f3d
#    elif defined __powerpc64__
Packit Service 2a3f3d
#      define __NR_renameat2 357
Packit Service 2a3f3d
#    elif defined __s390__ || defined __s390x__
Packit Service 2a3f3d
#      define __NR_renameat2 347
Packit Service 2a3f3d
#    elif defined __arc__
Packit Service 2a3f3d
#      define __NR_renameat2 276
Packit Service 2a3f3d
#    else
Packit Service 2a3f3d
#      warning "__NR_renameat2 unknown for your architecture"
Packit Service 2a3f3d
#    endif
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
Packit Service 2a3f3d
static inline int renameat2(int oldfd, const char *oldname, int newfd, const char *newname, unsigned flags) {
Packit Service 2a3f3d
#  ifdef __NR_renameat2
Packit Service 2a3f3d
        return syscall(__NR_renameat2, oldfd, oldname, newfd, newname, flags);
Packit Service 2a3f3d
#  else
Packit Service 2a3f3d
        errno = ENOSYS;
Packit Service 2a3f3d
        return -1;
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
}
Packit Service 2a3f3d
#endif
Packit Service 2a3f3d
Packit Service 2a3f3d
#if !HAVE_DECL_MEMFD_CREATE
Packit Service 2a3f3d
#  ifndef __NR_memfd_create
Packit Service 2a3f3d
#    if defined __x86_64__
Packit Service 2a3f3d
#      define __NR_memfd_create 319
Packit Service 2a3f3d
#    elif defined __arm__
Packit Service 2a3f3d
#      define __NR_memfd_create 385
Packit Service 2a3f3d
#    elif defined __aarch64__
Packit Service 2a3f3d
#      define __NR_memfd_create 279
Packit Service 2a3f3d
#    elif defined __s390__
Packit Service 2a3f3d
#      define __NR_memfd_create 350
Packit Service 2a3f3d
#    elif defined _MIPS_SIM
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_ABI32
Packit Service 2a3f3d
#        define __NR_memfd_create 4354
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_NABI32
Packit Service 2a3f3d
#        define __NR_memfd_create 6318
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#      if _MIPS_SIM == _MIPS_SIM_ABI64
Packit Service 2a3f3d
#        define __NR_memfd_create 5314
Packit Service 2a3f3d
#      endif
Packit Service 2a3f3d
#    elif defined __i386__
Packit Service 2a3f3d
#      define __NR_memfd_create 356
Packit Service 2a3f3d
#    elif defined __arc__
Packit Service 2a3f3d
#      define __NR_memfd_create 279
Packit Service 2a3f3d
#    else
Packit Service 2a3f3d
#      warning "__NR_memfd_create unknown for your architecture"
Packit Service 2a3f3d
#    endif
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
Packit Service 2a3f3d
static inline int memfd_create(const char *name, unsigned int flags) {
Packit Service 2a3f3d
#  ifdef __NR_memfd_create
Packit Service 2a3f3d
        return syscall(__NR_memfd_create, name, flags);
Packit Service 2a3f3d
#  else
Packit Service 2a3f3d
        errno = ENOSYS;
Packit Service 2a3f3d
        return -1;
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
}
Packit Service 2a3f3d
#endif
Packit Service 2a3f3d
Packit Service 2a3f3d
/* Copied from systemd git:
Packit Service 2a3f3d
   commit 6bda23dd6aaba50cf8e3e6024248cf736cc443ca
Packit Service 2a3f3d
   Author:     Yu Watanabe <watanabe.yu+github@gmail.com>
Packit Service 2a3f3d
   AuthorDate: Thu Jul 27 20:22:54 2017 +0900
Packit Service 2a3f3d
   Commit:     Zbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Packit Service 2a3f3d
   CommitDate: Thu Jul 27 07:22:54 2017 -0400
Packit Service 2a3f3d
*/
Packit Service 2a3f3d
#if !HAVE_DECL_COPY_FILE_RANGE
Packit Service 2a3f3d
#  ifndef __NR_copy_file_range
Packit Service 2a3f3d
#    if defined(__x86_64__)
Packit Service 2a3f3d
#      define __NR_copy_file_range 326
Packit Service 2a3f3d
#    elif defined(__i386__)
Packit Service 2a3f3d
#      define __NR_copy_file_range 377
Packit Service 2a3f3d
#    elif defined __s390__
Packit Service 2a3f3d
#      define __NR_copy_file_range 375
Packit Service 2a3f3d
#    elif defined __arm__
Packit Service 2a3f3d
#      define __NR_copy_file_range 391
Packit Service 2a3f3d
#    elif defined __aarch64__
Packit Service 2a3f3d
#      define __NR_copy_file_range 285
Packit Service 2a3f3d
#    elif defined __powerpc__
Packit Service 2a3f3d
#      define __NR_copy_file_range 379
Packit Service 2a3f3d
#    elif defined __arc__
Packit Service 2a3f3d
#      define __NR_copy_file_range 285
Packit Service 2a3f3d
#    else
Packit Service 2a3f3d
#      warning "__NR_copy_file_range not defined for your architecture"
Packit Service 2a3f3d
#    endif
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
Packit Service 2a3f3d
static inline ssize_t missing_copy_file_range(int fd_in, loff_t *off_in,
Packit Service 2a3f3d
                                              int fd_out, loff_t *off_out,
Packit Service 2a3f3d
                                              size_t len,
Packit Service 2a3f3d
                                              unsigned int flags) {
Packit Service 2a3f3d
#  ifdef __NR_copy_file_range
Packit Service 2a3f3d
        return syscall(__NR_copy_file_range, fd_in, off_in, fd_out, off_out, len, flags);
Packit Service 2a3f3d
#  else
Packit Service 2a3f3d
        errno = ENOSYS;
Packit Service 2a3f3d
        return -1;
Packit Service 2a3f3d
#  endif
Packit Service 2a3f3d
}
Packit Service 2a3f3d
Packit Service 2a3f3d
#  define copy_file_range missing_copy_file_range
Packit Service 2a3f3d
#endif