]> granicus.if.org Git - strace/blobdiff - print_timespec.c
CREDITS.in: use UTF-8 consistently
[strace] / print_timespec.c
index 795a183c2e4cdb1eb4f2df5df34ae8762b71c71c..c8ab5b7bb68bbaf485e31ea3434edca34bffbcf5 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2015-2016 Dmitry V. Levin <ldv@altlinux.org>
+ * Copyright (c) 2016-2017 The strace developers.
  * All rights reserved.
  *
  * Redistribution and use in source and binary forms, with or without
@@ -67,6 +68,42 @@ print_timespec_t_utime(const timespec_t *t)
        }
 }
 
+MPERS_PRINTER_DECL(bool, print_struct_timespec_data_size,
+                  const void *arg, const size_t size)
+{
+       if (size < sizeof(timespec_t)) {
+               tprints("?");
+               return false;
+       }
+
+       print_timespec_t(arg);
+       return true;
+}
+
+MPERS_PRINTER_DECL(bool, print_struct_timespec_array_data_size,
+                  const void *arg, const unsigned int nmemb,
+                  const size_t size)
+{
+       const timespec_t *ts = arg;
+       unsigned int i;
+
+       if (nmemb > size / sizeof(timespec_t)) {
+               tprints("?");
+               return false;
+       }
+
+       tprints("[");
+
+       for (i = 0; i < nmemb; i++) {
+               if (i)
+                       tprints(", ");
+               print_timespec_t(&ts[i]);
+       }
+
+       tprints("]");
+       return true;
+}
+
 MPERS_PRINTER_DECL(void, print_timespec,
                   struct tcb *const tcp, const kernel_ulong_t addr)
 {