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