[PATCH v4 5/8] print_timespec: Add support for printing the kernel timespec
Alistair Francis
alistair.francis at wdc.com
Tue Mar 10 00:43:01 UTC 2020
Add support for printing the newly added kernel_timespec_t.
Signed-off-by: Alistair Francis <alistair.francis at wdc.com>
---
Makefile.am | 3 ++-
defs.h | 5 +++++
print_timespec.c | 47 +++++++++----------------------------------
print_timespec_gen.c | 48 ++++++++++++++++++++++++++++++++++++++++++++
4 files changed, 64 insertions(+), 39 deletions(-)
create mode 100644 print_timespec_gen.c
diff --git a/Makefile.am b/Makefile.am
index fe3a2c1a..650ec546 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -255,8 +255,9 @@ strace_SOURCES = \
print_statfs.c \
print_struct_stat.c \
print_time.c \
- print_timespec.c \
+ print_timespec_gen.c \
print_timespec.h \
+ print_timespec.c \
print_timespec32.c \
print_timespec64.c \
print_timeval.c \
diff --git a/defs.h b/defs.h
index 7afd9506..ffedeabb 100644
--- a/defs.h
+++ b/defs.h
@@ -1286,6 +1286,11 @@ extern int print_itimerspec32(struct tcb *, kernel_ulong_t);
extern int print_timex32(struct tcb *, kernel_ulong_t);
# endif /* HAVE_ARCH_TIME32_SYSCALLS */
+extern bool print_timespec_data_size(const void *arg, size_t size);
+extern bool print_timespec_array_data_size(const void *arg,
+ unsigned int nmemb,
+ size_t size);
+
extern bool print_timespec64_data_size(const void *arg, size_t size);
extern bool print_timespec64_array_data_size(const void *arg,
unsigned int nmemb,
diff --git a/print_timespec.c b/print_timespec.c
index 4df2a4f4..b52b7919 100644
--- a/print_timespec.c
+++ b/print_timespec.c
@@ -1,6 +1,5 @@
/*
- * Copyright (c) 2015-2016 Dmitry V. Levin <ldv at altlinux.org>
- * Copyright (c) 2016-2019 The strace developers.
+ * Copyright (c) 2020 The strace developers.
* All rights reserved.
*
* SPDX-License-Identifier: LGPL-2.1-or-later
@@ -8,41 +7,13 @@
#include "defs.h"
-#include DEF_MPERS_TYPE(timespec_t)
+#define TIMESPEC_T kernel_timespec_t
+#define PRINT_TIMESPEC_DATA_SIZE print_timespec_data_size
+#define PRINT_TIMESPEC_ARRAY_DATA_SIZE print_timespec_array_data_size
+#define PRINT_TIMESPEC print_timespec
+#define SPRINT_TIMESPEC sprint_timespec
+#define PRINT_TIMESPEC_UTIME_PAIR print_timespec_utime_pair
+#define PRINT_ITIMERSPEC print_itimerspec
#include "kernel_timespec.h"
-
-#if defined MPERS_IS_mx32
-# define TIMESPEC_IS_32BIT 0
-#elif defined MPERS_IS_m32
-# define TIMESPEC_IS_32BIT 1
-#elif ARCH_TIMESIZE == 4
-# define TIMESPEC_IS_32BIT 1
-#else
-# define TIMESPEC_IS_32BIT 0
-#endif
-
-#if TIMESPEC_IS_32BIT
-typedef kernel_old_timespec32_t timespec_t;
-# define PRINT_TIMESPEC_DATA_SIZE print_old_timespec32_data_size
-# define PRINT_TIMESPEC_ARRAY_DATA_SIZE print_old_timespec32_array_data_size
-#else
-typedef kernel_timespec64_t timespec_t;
-# define PRINT_TIMESPEC_DATA_SIZE print_timespec64_data_size
-# define PRINT_TIMESPEC_ARRAY_DATA_SIZE print_timespec64_array_data_size
-#endif
-
-#include MPERS_DEFS
-
-MPERS_PRINTER_DECL(bool, print_struct_timespec_data_size,
- const void *arg, const size_t size)
-{
- return PRINT_TIMESPEC_DATA_SIZE(arg, size);
-}
-
-MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
- const void *arg, const unsigned int nmemb,
- const size_t size)
-{
- return PRINT_TIMESPEC_ARRAY_DATA_SIZE(arg, nmemb, size);
-}
+#include "print_timespec.h"
diff --git a/print_timespec_gen.c b/print_timespec_gen.c
new file mode 100644
index 00000000..4df2a4f4
--- /dev/null
+++ b/print_timespec_gen.c
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2015-2016 Dmitry V. Levin <ldv at altlinux.org>
+ * Copyright (c) 2016-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "defs.h"
+
+#include DEF_MPERS_TYPE(timespec_t)
+
+#include "kernel_timespec.h"
+
+#if defined MPERS_IS_mx32
+# define TIMESPEC_IS_32BIT 0
+#elif defined MPERS_IS_m32
+# define TIMESPEC_IS_32BIT 1
+#elif ARCH_TIMESIZE == 4
+# define TIMESPEC_IS_32BIT 1
+#else
+# define TIMESPEC_IS_32BIT 0
+#endif
+
+#if TIMESPEC_IS_32BIT
+typedef kernel_old_timespec32_t timespec_t;
+# define PRINT_TIMESPEC_DATA_SIZE print_old_timespec32_data_size
+# define PRINT_TIMESPEC_ARRAY_DATA_SIZE print_old_timespec32_array_data_size
+#else
+typedef kernel_timespec64_t timespec_t;
+# define PRINT_TIMESPEC_DATA_SIZE print_timespec64_data_size
+# define PRINT_TIMESPEC_ARRAY_DATA_SIZE print_timespec64_array_data_size
+#endif
+
+#include MPERS_DEFS
+
+MPERS_PRINTER_DECL(bool, print_struct_timespec_data_size,
+ const void *arg, const size_t size)
+{
+ return PRINT_TIMESPEC_DATA_SIZE(arg, size);
+}
+
+MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
+ const void *arg, const unsigned int nmemb,
+ const size_t size)
+{
+ return PRINT_TIMESPEC_ARRAY_DATA_SIZE(arg, nmemb, size);
+}
--
2.25.1
More information about the Strace-devel
mailing list