]> git.ozlabs.org Git - ccan/blob - ccan/time/_info
time: remove unused var warning in example.
[ccan] / ccan / time / _info
1 #include <string.h>
2 #include "config.h"
3
4 /**
5  * time - routines for dealing with time
6  *
7  * This code provides convenient functions for working with time, in the
8  * form of 'struct timespec'.
9  *
10  * Author: Rusty Russell <rusty@rustcorp.com.au>
11  * License: BSD-MIT
12  *
13  * Example:
14  *      #include <ccan/time/time.h>
15  *      #include <stdlib.h>
16  *      #include <stdio.h>
17  *      #include <err.h>
18  *
19  *      int main(int argc, char *argv[])
20  *      {
21  *              struct timespec t;
22  *
23  *              if (argc != 2)
24  *                      errx(1, "Usage: %s <diff in millisec>", argv[0]);
25  *
26  *              t = time_now();
27  *              if (argv[1][0] == '-')
28  *                      t = time_sub(t, time_from_msec(atol(argv[1]+1)));
29  *              else
30  *                      t = time_add(t, time_from_msec(atol(argv[1])));
31  *
32  *              printf("%lu.%09u\n",
33  *                     (unsigned long)t.tv_sec, (unsigned)t.tv_nsec);
34  *              return 0;
35  *      }
36  */
37 int main(int argc, char *argv[])
38 {
39         /* Expect exactly one argument */
40         if (argc != 2)
41                 return 1;
42
43         if (strcmp(argv[1], "depends") == 0) {
44                 return 0;
45         }
46
47 #if HAVE_CLOCK_GETTIME_IN_LIBRT
48         if (strcmp(argv[1], "libs") == 0) {
49                 printf("rt\n");
50                 return 0;
51         }
52 #endif
53
54         return 1;
55 }