X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=src%2Fbasic%2Fmissing_syscall.h;h=f9a541af809a8c5d541ea8a663668a0e97232cc7;hb=4f6d0cf8078962c89b54128be902a24de266c3ec;hp=89ca1f062a92eac46b08ec3c500ce1350c29ba95;hpb=56b00d0028894c078fcbd617a5f2a589137bcf95;p=thirdparty%2Fsystemd.git diff --git a/src/basic/missing_syscall.h b/src/basic/missing_syscall.h index 89ca1f062a9..f9a541af809 100644 --- a/src/basic/missing_syscall.h +++ b/src/basic/missing_syscall.h @@ -1,16 +1,25 @@ /* SPDX-License-Identifier: LGPL-2.1+ */ #pragma once -/*** - This file is part of systemd. - - Copyright 2010 Lennart Poettering - Copyright 2016 Zbigniew Jędrzejewski-Szmek -***/ - /* Missing glibc definitions to access certain kernel APIs */ +#include +#include +#include #include +#include + +#ifdef ARCH_MIPS +#include +#endif + +#include "missing_keyctl.h" +#include "missing_stat.h" + +/* linux/kcmp.h */ +#ifndef KCMP_FILE /* 3f4994cfc15f38a3159c6e3a4b3ab2e1481a6b02 (3.19) */ +#define KCMP_FILE 0 +#endif #if !HAVE_PIVOT_ROOT static inline int missing_pivot_root(const char *new_root, const char *put_old) { @@ -259,7 +268,7 @@ static inline int missing_kcmp(pid_t pid1, pid_t pid2, int type, unsigned long i /* ======================================================================= */ #if !HAVE_KEYCTL -static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4,unsigned long arg5) { +static inline long missing_keyctl(int cmd, unsigned long arg2, unsigned long arg3, unsigned long arg4, unsigned long arg5) { # ifdef __NR_keyctl return syscall(__NR_keyctl, cmd, arg2, arg3, arg4, arg5); # else @@ -382,6 +391,8 @@ static inline int missing_bpf(int cmd, union bpf_attr *attr, size_t size) { # define __NR_pkey_mprotect 394 # elif defined __powerpc__ # define __NR_pkey_mprotect 386 +# elif defined __s390__ +# define __NR_pkey_mprotect 384 # elif defined _MIPS_SIM # if _MIPS_SIM == _MIPS_SIM_ABI32 # define __NR_pkey_mprotect 4363 @@ -435,3 +446,45 @@ static inline ssize_t missing_statx(int dfd, const char *filename, unsigned flag # define statx missing_statx #endif + +#if !HAVE_SET_MEMPOLICY + +enum { + MPOL_DEFAULT, + MPOL_PREFERRED, + MPOL_BIND, + MPOL_INTERLEAVE, + MPOL_LOCAL, +}; + +static inline long missing_set_mempolicy(int mode, const unsigned long *nodemask, + unsigned long maxnode) { + long i; +# ifdef __NR_set_mempolicy + i = syscall(__NR_set_mempolicy, mode, nodemask, maxnode); +# else + errno = ENOSYS; + i = -1; +# endif + return i; +} + +# define set_mempolicy missing_set_mempolicy +#endif + +#if !HAVE_GET_MEMPOLICY +static inline long missing_get_mempolicy(int *mode, unsigned long *nodemask, + unsigned long maxnode, void *addr, + unsigned long flags) { + long i; +# ifdef __NR_get_mempolicy + i = syscall(__NR_get_mempolicy, mode, nodemask, maxnode, addr, flags); +# else + errno = ENOSYS; + i = -1; +# endif + return i; +} + +#define get_mempolicy missing_get_mempolicy +#endif