clock.h 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147
  1. #ifndef BABELTRACE_CTF_IR_CLOCK_H
  2. #define BABELTRACE_CTF_IR_CLOCK_H
  3. /*
  4. * BabelTrace - CTF IR: Clock
  5. *
  6. * Copyright 2013, 2014 Jérémie Galarneau <jeremie.galarneau@efficios.com>
  7. *
  8. * Author: Jérémie Galarneau <jeremie.galarneau@efficios.com>
  9. *
  10. * Permission is hereby granted, free of charge, to any person obtaining a copy
  11. * of this software and associated documentation files (the "Software"), to deal
  12. * in the Software without restriction, including without limitation the rights
  13. * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
  14. * copies of the Software, and to permit persons to whom the Software is
  15. * furnished to do so, subject to the following conditions:
  16. *
  17. * The above copyright notice and this permission notice shall be included in
  18. * all copies or substantial portions of the Software.
  19. *
  20. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  21. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  22. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
  23. * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
  24. * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
  25. * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
  26. * SOFTWARE.
  27. *
  28. * The Common Trace Format (CTF) Specification is available at
  29. * http://www.efficios.com/ctf
  30. */
  31. #include <stdint.h>
  32. #ifdef __cplusplus
  33. extern "C" {
  34. #endif
  35. struct bt_ctf_clock;
  36. /*
  37. * bt_ctf_clock_create: create a clock.
  38. *
  39. * Allocate a new clock setting its reference count to 1.
  40. *
  41. * @param name Name of the clock (will be copied).
  42. *
  43. * Returns an allocated clock on success, NULL on error.
  44. */
  45. extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name);
  46. /*
  47. * bt_ctf_clock_set_description: set a clock's description.
  48. *
  49. * Set the clock's description. The description appears in the clock's TSDL
  50. * meta-data.
  51. *
  52. * @param clock Clock instance.
  53. * @param desc Description of the clock.
  54. *
  55. * Returns 0 on success, a negative value on error.
  56. */
  57. extern int bt_ctf_clock_set_description(struct bt_ctf_clock *clock,
  58. const char *desc);
  59. /*
  60. * bt_ctf_clock_set_frequency: set a clock's frequency.
  61. *
  62. * Set the clock's frequency (Hz).
  63. *
  64. * @param clock Clock instance.
  65. * @param freq Clock's frequency in Hz, defaults to 1 000 000 000 Hz (1ns).
  66. *
  67. * Returns 0 on success, a negative value on error.
  68. */
  69. extern int bt_ctf_clock_set_frequency(struct bt_ctf_clock *clock,
  70. uint64_t freq);
  71. /*
  72. * bt_ctf_clock_set_precision: set a clock's precision.
  73. *
  74. * Set the clock's precision.
  75. *
  76. * @param clock Clock instance.
  77. * @param precision Clock's precision in clock ticks, defaults to 1.
  78. *
  79. * Returns 0 on success, a negative value on error.
  80. */
  81. extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock,
  82. uint64_t precision);
  83. /*
  84. * bt_ctf_clock_set_offset_s: set a clock's offset in seconds.
  85. *
  86. * Set the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01,
  87. * defaults to 0.
  88. *
  89. * @param clock Clock instance.
  90. * @param offset_s Clock's offset in seconds, defaults to 0.
  91. *
  92. * Returns 0 on success, a negative value on error.
  93. */
  94. extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock,
  95. int64_t offset_s);
  96. /*
  97. * bt_ctf_clock_set_offset: set a clock's offset in ticks.
  98. *
  99. * Set the clock's offset in ticks from Epoch + offset_s.
  100. *
  101. * @param clock Clock instance.
  102. * @param offset Clock's offset in ticks from Epoch + offset_s, defaults to 0.
  103. *
  104. * Returns 0 on success, a negative value on error.
  105. */
  106. extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock,
  107. int64_t offset);
  108. /*
  109. * bt_ctf_clock_set_is_absolute: set a clock's absolute attribute.
  110. *
  111. * Set the clock's absolute attribute. A clock is absolute if the clock is a
  112. * global reference across the trace's other clocks.
  113. *
  114. * @param clock Clock instance.
  115. * @param is_absolute Clock's absolute attribute, defaults to FALSE.
  116. *
  117. * Returns 0 on success, a negative value on error.
  118. */
  119. extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock,
  120. int is_absolute);
  121. /*
  122. * bt_ctf_clock_set_time: set a clock's current time value.
  123. *
  124. * Set the current time in nanoseconds since the clock's origin (offset and
  125. * offset_s attributes). Defaults to 0.
  126. *
  127. * Returns 0 on success, a negative value on error.
  128. */
  129. extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, int64_t time);
  130. #ifdef __cplusplus
  131. }
  132. #endif
  133. #endif /* BABELTRACE_CTF_IR_CLOCK_H */