* THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
+#ifndef STRACE_DEFS_H
+#define STRACE_DEFS_H
+
#ifdef HAVE_CONFIG_H
# include "config.h"
#endif
#include <features.h>
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h>
-#endif
+#include <stdbool.h>
#include <stdint.h>
#include <inttypes.h>
#include <sys/types.h>
#include <errno.h>
#include <time.h>
#include <sys/time.h>
-#include <sys/syscall.h>
+#include <asm/unistd.h>
#include "mpers_type.h"
#include "gcc_compat.h"
# define ERESTART_RESTARTBLOCK 516
#endif
-#if defined(SPARC) || defined(SPARC64)
-# define PERSONALITY0_WORDSIZE 4
-# if defined(SPARC64)
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY1_WORDSIZE 8
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-# endif
-#endif
-
-#ifdef X86_64
+#if defined X86_64
# define SUPPORTED_PERSONALITIES 3
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
# define PERSONALITY2_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-# ifdef HAVE_MX32_MPERS
-# define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h"
-# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h"
-# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h"
-# define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h"
-# endif
-#endif
-
-#ifdef X32
+#elif defined AARCH64 \
+ || defined POWERPC64 \
+ || defined RISCV \
+ || defined SPARC64 \
+ || defined TILE \
+ || defined X32
# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 4
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-#endif
-
-#ifdef ARM
-/* one personality */
+#else
+# define SUPPORTED_PERSONALITIES 1
#endif
-#ifdef AARCH64
-/* The existing ARM personality, then AArch64 */
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
+#if defined TILE && defined __tilepro__
+# define DEFAULT_PERSONALITY 1
+#else
+# define DEFAULT_PERSONALITY 0
#endif
-#ifdef POWERPC64
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
-# define PERSONALITY1_WORDSIZE 4
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
-#endif
+#define PERSONALITY0_WORDSIZE SIZEOF_LONG
+#define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
+#define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#ifdef TILE
-# define SUPPORTED_PERSONALITIES 2
-# define PERSONALITY0_WORDSIZE 8
+#if SUPPORTED_PERSONALITIES > 1
# define PERSONALITY1_WORDSIZE 4
-# ifdef __tilepro__
-# define DEFAULT_PERSONALITY 1
-# endif
-# ifdef HAVE_M32_MPERS
-# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
-# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
-# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
-# endif
#endif
-#ifndef SUPPORTED_PERSONALITIES
-# define SUPPORTED_PERSONALITIES 1
-#endif
-#ifndef DEFAULT_PERSONALITY
-# define DEFAULT_PERSONALITY 0
-#endif
-#ifndef PERSONALITY0_WORDSIZE
-# define PERSONALITY0_WORDSIZE SIZEOF_LONG
-#endif
-
-#ifndef PERSONALITY0_INCLUDE_PRINTERS_DECLS
-# define PERSONALITY0_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY0_INCLUDE_PRINTERS_DEFS
-# define PERSONALITY0_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#endif
-
-#ifndef PERSONALITY1_INCLUDE_PRINTERS_DECLS
+#if SUPPORTED_PERSONALITIES > 1 && defined HAVE_M32_MPERS
+# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "m32_printer_decls.h"
+# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "m32_printer_defs.h"
+# define PERSONALITY1_INCLUDE_FUNCS "m32_funcs.h"
+# define MPERS_m32_IOCTL_MACROS "ioctl_redefs1.h"
+#else
# define PERSONALITY1_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY1_INCLUDE_PRINTERS_DEFS
# define PERSONALITY1_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
+# define PERSONALITY1_INCLUDE_FUNCS "empty.h"
#endif
-#ifndef PERSONALITY2_INCLUDE_PRINTERS_DECLS
+#if SUPPORTED_PERSONALITIES > 2 && defined HAVE_MX32_MPERS
+# define PERSONALITY2_INCLUDE_FUNCS "mx32_funcs.h"
+# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "mx32_printer_decls.h"
+# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "mx32_printer_defs.h"
+# define MPERS_mx32_IOCTL_MACROS "ioctl_redefs2.h"
+#else
# define PERSONALITY2_INCLUDE_PRINTERS_DECLS "native_printer_decls.h"
-#endif
-#ifndef PERSONALITY2_INCLUDE_PRINTERS_DEFS
# define PERSONALITY2_INCLUDE_PRINTERS_DEFS "native_printer_defs.h"
-#endif
-
-#ifndef PERSONALITY1_INCLUDE_FUNCS
-# define PERSONALITY1_INCLUDE_FUNCS "empty.h"
-#endif
-#ifndef PERSONALITY2_INCLUDE_FUNCS
# define PERSONALITY2_INCLUDE_FUNCS "empty.h"
#endif
|| defined(BFIN) \
|| defined(M68K) \
|| defined(MICROBLAZE) \
+ || defined(RISCV) \
|| defined(S390) \
|| defined(SH) || defined(SH64) \
|| defined(SPARC) || defined(SPARC64) \
extern void print_seccomp_filter(struct tcb *, unsigned long);
extern void print_seccomp_fprog(struct tcb *, unsigned long, unsigned short);
+struct strace_stat;
+extern void print_struct_stat(struct tcb *tcp, const struct strace_stat *const st);
+
struct strace_statfs;
extern void print_struct_statfs(struct tcb *tcp, long);
extern void print_struct_statfs64(struct tcb *tcp, long, unsigned long);
#endif
/*
- * Widen without sign-extension a signed integer type to unsigned long long.
+ * Zero-extend a signed integer type to unsigned long long.
*/
-#define widen_to_ull(v) \
- (sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \
+#define zero_extend_signed_to_ull(v) \
+ (sizeof(v) == sizeof(short) ? (unsigned long long) (unsigned short) (v) : \
+ sizeof(v) == sizeof(int) ? (unsigned long long) (unsigned int) (v) : \
sizeof(v) == sizeof(long) ? (unsigned long long) (unsigned long) (v) : \
(unsigned long long) (v))
+/*
+ * Sign-extend an unsigned integer type to long long.
+ */
+#define sign_extend_unsigned_to_ll(v) \
+ (sizeof(v) == sizeof(short) ? (long long) (short) (v) : \
+ sizeof(v) == sizeof(int) ? (long long) (int) (v) : \
+ sizeof(v) == sizeof(long) ? (long long) (long) (v) : \
+ (long long) (v))
+
extern const struct_sysent sysent0[];
extern const char *const errnoent0[];
extern const char *const signalent0[];
#endif /* !IN_MPERS_BOOTSTRAP */
/*
- * If you need non-NULL sysent[scno].sys_func and sysent[scno].sys_name
+ * If you need non-NULL sysent[scno].sys_func, non-NULL sysent[scno].sys_name,
+ * and non-indirect sysent[scno].sys_flags.
*/
#define SCNO_IS_VALID(scno) \
- ((unsigned long)(scno) < nsyscalls && sysent[scno].sys_func)
+ ((unsigned long)(scno) < nsyscalls \
+ && sysent[scno].sys_func \
+ && !(sysent[scno].sys_flags & TRACE_INDIRECT_SUBCALL))
/* Only ensures that sysent[scno] isn't out of range */
#define SCNO_IN_RANGE(scno) \
#define PRI__d64 PRI__64"d"
#define PRI__u64 PRI__64"u"
#define PRI__x64 PRI__64"x"
+
+#endif /* !STRACE_DEFS_H */