]> granicus.if.org Git - strace/blobdiff - defs.h
travis: add x86 musl
[strace] / defs.h
diff --git a/defs.h b/defs.h
index bfe76e2d3b739bcf091724c724c847ef918ebcd7..07de67affc89d0ddcb32afa3b36a07b0c486406f 100644 (file)
--- a/defs.h
+++ b/defs.h
  * 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>
@@ -52,7 +53,7 @@
 #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"
@@ -148,130 +149,53 @@ extern char *stpcpy(char *dst, const char *src);
 # 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
 
@@ -432,6 +356,7 @@ extern const struct xlat whence_codes[];
  || defined(BFIN) \
  || defined(M68K) \
  || defined(MICROBLAZE) \
+ || defined(RISCV) \
  || defined(S390) \
  || defined(SH) || defined(SH64) \
  || defined(SPARC) || defined(SPARC64) \
@@ -704,6 +629,9 @@ extern const char *sprint_open_modes(unsigned int);
 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);
@@ -820,13 +748,23 @@ extern unsigned current_wordsize;
 #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[];
@@ -865,10 +803,13 @@ extern unsigned num_quals;
 #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) \
@@ -901,3 +842,5 @@ extern unsigned num_quals;
 #define PRI__d64 PRI__64"d"
 #define PRI__u64 PRI__64"u"
 #define PRI__x64 PRI__64"x"
+
+#endif /* !STRACE_DEFS_H */