_info 1.2 KB

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