bufhelp: use one-byte aligned type for unaligned memory accesses
[libgcrypt.git] / cipher / test-getrusage.c
index 87a404d..7f586dd 100644 (file)
@@ -27,7 +27,7 @@ main (int argc, char **argv)
     }
 
   printf ("ru_utime   = %ld.%06ld\n",
-          buf.ru_utime.tv_sec, buf.ru_utime.tv_usec); 
+          buf.ru_utime.tv_sec, buf.ru_utime.tv_usec);
   printf ("ru_stime   = %ld.%06ld\n",
           buf.ru_stime.tv_sec, buf.ru_stime.tv_usec);
   printf ("ru_maxrss  = %ld\n", buf.ru_maxrss   );
@@ -47,3 +47,53 @@ main (int argc, char **argv)
 
   return 0;
 }
+
+
+/* Codesnippet for debugging in random.c. */
+#if 0
+static void
+collect_rusage_stats (struct rusage *rb)
+{
+  static int idx;
+  static struct rusage buf[100];
+
+  if (!rb)
+    {
+      int i;
+
+      fprintf (stderr, "ru_utime   ru_stime   ru_minflt  ru_nvcsw  ru_nivcsw\n");
+      for (i=0; i < idx; i++)
+        fprintf (stderr, "%ld.%06ld   %ld.%06ld %5ld       %5ld      %5ld\n",
+                 buf[i].ru_utime.tv_sec, buf[i].ru_utime.tv_usec,
+                 buf[i].ru_stime.tv_sec, buf[i].ru_stime.tv_usec,
+                 buf[i].ru_minflt,
+                 buf[i].ru_nvcsw,
+                 buf[i].ru_nivcsw);
+    }
+  else if (idx < DIM(buf))
+    {
+      buf[idx++] = *rb;
+    }
+}
+#endif
+/*
+ void
+ _gcry_random_dump_stats()
+ {
+@@ -233,8 +261,11 @@
+                  rndstats.naddbytes, rndstats.addbytes,
+        rndstats.mixkey, rndstats.ngetbytes1, rndstats.getbytes1,
+                    rndstats.ngetbytes2, rndstats.getbytes2 );
++
++    collect_rusage_stats (NULL);
+ }
+
+========
+
+     getrusage (RUSAGE_SELF, &buf );
++    collect_rusage_stats (&buf);
+     add_randomness( &buf, sizeof buf, 1 );
+     memset( &buf, 0, sizeof buf );
+   }
+
+*/