]>
iEval git - linux-seccomp.git/blob - libseccomp/tools/util.c
2 * Tool utility functions
4 * Copyright (c) 2014 Red Hat <pmoore@redhat.com>
5 * Author: Paul Moore <paul@paul-moore.com>
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.
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
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>.
25 #include <linux/audit.h>
34 /* determine the native architecture */
36 #define ARCH_NATIVE AUDIT_ARCH_I386
39 #define ARCH_NATIVE AUDIT_ARCH_X86_64
41 #define ARCH_NATIVE AUDIT_ARCH_X86_64
42 #endif /* __ILP32__ */
44 #define ARCH_NATIVE AUDIT_ARCH_ARM
46 #define ARCH_NATIVE AUDIT_ARCH_AARCH64
47 #elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI32
49 #define ARCH_NATIVE AUDIT_ARCH_MIPS
51 #define ARCH_NATIVE AUDIT_ARCH_MIPSEL
52 #endif /* _MIPS_SIM_ABI32 */
53 #elif __mips__ && _MIPS_SIM == _MIPS_SIM_ABI64
55 #define ARCH_NATIVE AUDIT_ARCH_MIPS64
57 #define ARCH_NATIVE AUDIT_ARCH_MIPSEL64
58 #endif /* _MIPS_SIM_ABI64 */
59 #elif __mips__ && _MIPS_SIM == _MIPS_SIM_NABI32
61 #define ARCH_NATIVE AUDIT_ARCH_MIPS64N32
63 #define ARCH_NATIVE AUDIT_ARCH_MIPSEL64N32
64 #endif /* _MIPS_SIM_NABI32 */
67 #define ARCH_NATIVE AUDIT_ARCH_PPC64
69 #define ARCH_NATIVE AUDIT_ARCH_PPC64LE
72 #define ARCH_NATIVE AUDIT_ARCH_PPC
73 #elif __s390x__ /* s390x must be checked before s390 */
74 #define ARCH_NATIVE AUDIT_ARCH_S390X
76 #define ARCH_NATIVE AUDIT_ARCH_S390
78 #error the simulator code needs to know about your machine type
81 /* default to the native arch */
82 uint32_t arch
= ARCH_NATIVE
;
85 * Convert a 16-bit target integer into the host's endianess
86 * @param arch the architecture token
87 * @param val the 16-bit integer
89 * Convert the endianess of the supplied value and return it to the caller.
92 uint16_t ttoh16(uint32_t arch
, uint16_t val
)
94 if (arch
& __AUDIT_ARCH_LE
)
101 * Convert a 32-bit target integer into the host's endianess
102 * @param arch the architecture token
103 * @param val the 32-bit integer
105 * Convert the endianess of the supplied value and return it to the caller.
108 uint32_t ttoh32(uint32_t arch
, uint32_t val
)
110 if (arch
& __AUDIT_ARCH_LE
)
117 * Convert a 32-bit host integer into the target's endianess
118 * @param arch the architecture token
119 * @param val the 32-bit integer
121 * Convert the endianess of the supplied value and return it to the caller.
124 uint32_t htot32(uint32_t arch
, uint32_t val
)
126 if (arch
& __AUDIT_ARCH_LE
)
133 * Convert a 64-bit host integer into the target's endianess
134 * @param arch the architecture token
135 * @param val the 64-bit integer
137 * Convert the endianess of the supplied value and return it to the caller.
140 uint64_t htot64(uint32_t arch
, uint64_t val
)
142 if (arch
& __AUDIT_ARCH_LE
)
This page took 0.051283 seconds and 4 git commands to generate.