Bundle libseccomp 2.3.1
[linux-seccomp.git] / libseccomp / tools / util.h
CommitLineData
8befd5cc
MG
1/**
2 * Tool utility functions
3 *
4 * Copyright (c) 2014 Red Hat <pmoore@redhat.com>
5 * Author: Paul Moore <paul@paul-moore.com>
6 */
7
8/*
9 * This library is free software; you can redistribute it and/or modify it
10 * under the terms of version 2.1 of the GNU Lesser General Public License as
11 * published by the Free Software Foundation.
12 *
13 * This library is distributed in the hope that it will be useful, but WITHOUT
14 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
15 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License
16 * for more details.
17 *
18 * You should have received a copy of the GNU Lesser General Public License
19 * along with this library; if not, see <http://www.gnu.org/licenses>.
20 */
21
22#ifndef _UTIL_H
23#define _UTIL_H
24
25#include <elf.h>
26#include <inttypes.h>
27#include <linux/audit.h>
28
29/**
30 * The ARM architecture tokens
31 */
32/* AArch64 support for audit was merged in 3.17-rc1 */
33#ifndef AUDIT_ARCH_AARCH64
34#ifndef EM_AARCH64
35#define EM_AARCH64 183
36#endif /* EM_AARCH64 */
37#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
38#endif /* AUDIT_ARCH_AARCH64 */
39
40/**
41 * The MIPS architecture tokens
42 */
43#ifndef __AUDIT_ARCH_CONVENTION_MIPS64_N32
44#define __AUDIT_ARCH_CONVENTION_MIPS64_N32 0x20000000
45#endif
46#ifndef EM_MIPS
47#define EM_MIPS 8
48#endif
49#ifndef AUDIT_ARCH_MIPS
50#define AUDIT_ARCH_MIPS (EM_MIPS)
51#endif
52#ifndef AUDIT_ARCH_MIPS64
53#define AUDIT_ARCH_MIPS64 (EM_MIPS|__AUDIT_ARCH_64BIT)
54#endif
55/* MIPS64N32 support was merged in 3.15 */
56#ifndef AUDIT_ARCH_MIPS64N32
57#define AUDIT_ARCH_MIPS64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|\
58 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
59#endif
60/* MIPSEL64N32 support was merged in 3.15 */
61#ifndef AUDIT_ARCH_MIPSEL64N32
62#define AUDIT_ARCH_MIPSEL64N32 (EM_MIPS|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE|\
63 __AUDIT_ARCH_CONVENTION_MIPS64_N32)
64#endif
65
66#ifndef AUDIT_ARCH_AARCH64
67/* AArch64 support for audit was merged in 3.17-rc1 */
68#define AUDIT_ARCH_AARCH64 (EM_AARCH64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
69#endif
70
71#ifndef AUDIT_ARCH_PPC64LE
72#define AUDIT_ARCH_PPC64LE (EM_PPC64|__AUDIT_ARCH_64BIT|__AUDIT_ARCH_LE)
73#endif
74
75extern uint32_t arch;
76
77uint16_t ttoh16(uint32_t arch, uint16_t val);
78uint32_t ttoh32(uint32_t arch, uint32_t val);
79
80uint32_t htot32(uint32_t arch, uint32_t val);
81uint64_t htot64(uint32_t arch, uint64_t val);
82
83#endif
This page took 0.012876 seconds and 4 git commands to generate.