]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
enosys: split audit arch detection into dedicated header
authorThomas Weißschuh <thomas@t-8ch.de>
Mon, 22 May 2023 15:25:15 +0000 (17:25 +0200)
committerThomas Weißschuh <thomas@t-8ch.de>
Tue, 23 May 2023 15:24:01 +0000 (17:24 +0200)
Signed-off-by: Thomas Weißschuh <thomas@t-8ch.de>
include/Makemodule.am
include/audit-arch.h [new file with mode: 0644]
misc-utils/enosys.c

index 7c6a7587f65a326aa892e7eee4456daa76562167..068b0f8e804f5cb59b6fc4c4cf43fbef7399ddf8 100644 (file)
@@ -1,6 +1,7 @@
 
 dist_noinst_HEADERS += \
        include/all-io.h \
+       include/audit-arch.h \
        include/bitops.h \
        include/blkdev.h \
        include/buffer.h \
diff --git a/include/audit-arch.h b/include/audit-arch.h
new file mode 100644 (file)
index 0000000..9760f2e
--- /dev/null
@@ -0,0 +1,58 @@
+/*
+ * Copyright (C) 2023 Thomas Weißschuh <thomas@t-8ch.de>
+ *
+ * This file may be distributed under the terms of the
+ * GNU Lesser General Public License.
+ */
+#ifndef UTIL_LINUX_AUDIT_ARCH_H
+#define UTIL_LINUX_AUDIT_ARCH_H
+
+#if __x86_64__
+#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_X86_64
+#elif __i386__
+#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_I386
+#elif __arm__
+#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARM
+#elif __aarch64__
+#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_AARCH64
+#elif __riscv
+#    if __riscv_xlen == 32
+#        define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV32
+#    elif __riscv_xlen == 64
+#        define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV64
+#    endif
+#elif __s390x__
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390X
+#elif __s390__
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390
+#elif __PPC64__
+#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64
+#    else
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64LE
+#    endif
+#elif __powerpc__
+#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC
+#elif __mips__
+#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPS
+#    else
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPSEL
+#    endif
+#elif __arc__
+#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2BE
+#    else
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2
+#    endif
+#elif __sparc__
+#    if __SIZEOF_POINTER__ == 4
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC
+#    else
+#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC64
+#    endif
+#else
+#    error Unknown target architecture
+#endif
+
+#endif /* UTIL_LINUX_AUDIT_ARCH_H */
index 7372f29c6670fdc8d71e074dd68b49628bedea88..ec02f454f6fa4fab908a340bc2bb9bd4f1c87b1e 100644 (file)
 #include "exitcodes.h"
 #include "nls.h"
 #include "bitops.h"
-
-#if __x86_64__
-#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_X86_64
-#elif __i386__
-#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_I386
-#elif __arm__
-#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARM
-#elif __aarch64__
-#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_AARCH64
-#elif __riscv
-#    if __riscv_xlen == 32
-#        define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV32
-#    elif __riscv_xlen == 64
-#        define SECCOMP_ARCH_NATIVE AUDIT_ARCH_RISCV64
-#    endif
-#elif __s390x__
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390X
-#elif __s390__
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_S390
-#elif __PPC64__
-#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64
-#    else
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC64LE
-#    endif
-#elif __powerpc__
-#    define SECCOMP_ARCH_NATIVE AUDIT_ARCH_PPC
-#elif __mips__
-#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPS
-#    else
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_MIPSEL
-#    endif
-#elif __arc__
-#    if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2BE
-#    else
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_ARCV2
-#    endif
-#elif __sparc__
-#    if __SIZEOF_POINTER__ == 4
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC
-#    else
-#       define SECCOMP_ARCH_NATIVE AUDIT_ARCH_SPARC64
-#    endif
-#else
-#    error Unknown target architecture
-#endif
+#include "audit-arch.h"
 
 #define UL_BPF_NOP (struct sock_filter) BPF_JUMP(BPF_JMP | BPF_JA, 0, 0, 0)
 #define IS_LITTLE_ENDIAN (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)