]> granicus.if.org Git - strace/commitdiff
tests: add F8ILL_KULONG_* and f8ill_ptr_to_kulong to tests.h
authorDmitry V. Levin <ldv@altlinux.org>
Fri, 23 Dec 2016 18:44:37 +0000 (18:44 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Sun, 25 Dec 2016 11:32:45 +0000 (11:32 +0000)
* tests/tests.h (F8ILL_KULONG_SUPPORTED, F8ILL_KULONG_MASK): New macros.
(f8ill_ptr_to_kulong): New static inline function.

tests/tests.h

index 1724124b8879e61d33c38b4baebc49396e2f6651..202b2224230c508212355ebb15f3373354d92e57 100644 (file)
@@ -141,6 +141,22 @@ int send_mmsg(int, struct mmsghdr *, unsigned int, unsigned int);
 /* Create a pipe with maximized descriptor numbers. */
 void pipe_maxfd(int pipefd[2]);
 
+#define F8ILL_KULONG_SUPPORTED (sizeof(void *) < sizeof(kernel_ulong_t))
+#define F8ILL_KULONG_MASK      ((kernel_ulong_t) 0xffffffff00000000ULL)
+
+/*
+ * For 64-bit kernel_ulong_t and 32-bit pointer,
+ * return a kernel_ulong_t value by filling higher bits.
+ * For other architertures, return the original pointer.
+ */
+static inline kernel_ulong_t
+f8ill_ptr_to_kulong(const void *const ptr)
+{
+       const unsigned long uptr = (unsigned long) ptr;
+       return F8ILL_KULONG_SUPPORTED
+              ? F8ILL_KULONG_MASK | uptr : (kernel_ulong_t) uptr;
+}
+
 # define ARRAY_SIZE(arg) ((unsigned int) (sizeof(arg) / sizeof((arg)[0])))
 # define LENGTH_OF(arg) ((unsigned int) sizeof(arg) - 1)