X-Git-Url: http://git.efficios.com/?a=blobdiff_plain;f=include%2Fbabeltrace%2Fctf-ir%2Fclock.h;h=d9e3eb06567b969d813cb16f60fac7f016a60f7d;hb=98a4cbefe4c162067144bf5e1b7341c8dd8767bb;hp=fe6e9537dae4425984d3c996b971f7c63f0ef12d;hpb=87d76bb1f3202bcdd577df14bbbf2231a26c244c;p=babeltrace.git diff --git a/include/babeltrace/ctf-ir/clock.h b/include/babeltrace/ctf-ir/clock.h index fe6e9537..d9e3eb06 100644 --- a/include/babeltrace/ctf-ir/clock.h +++ b/include/babeltrace/ctf-ir/clock.h @@ -4,7 +4,7 @@ /* * BabelTrace - CTF IR: Clock * - * Copyright 2013 EfficiOS Inc. + * Copyright 2013, 2014 Jérémie Galarneau * * Author: Jérémie Galarneau * @@ -37,13 +37,15 @@ extern "C" { #endif struct bt_ctf_clock; +struct bt_ctf_clock_value; /* * bt_ctf_clock_create: create a clock. * * Allocate a new clock setting its reference count to 1. * - * @param name Name of the clock (will be copied). + * @param name Name of the clock (will be copied); can be set to NULL + * for nameless clocks. * * Returns an allocated clock on success, NULL on error. */ @@ -60,6 +62,17 @@ extern struct bt_ctf_clock *bt_ctf_clock_create(const char *name); */ extern const char *bt_ctf_clock_get_name(struct bt_ctf_clock *clock); +/* + * bt_ctf_clock_set_name: set a clock's name. + * + * Set a clock's name. + * + * @param name Name of the clock (will be copied). + * + * Returns 0 on success, a negative value on error. + */ +extern int bt_ctf_clock_set_name(struct bt_ctf_clock *clock, const char *name); + /* * bt_ctf_clock_get_description: get a clock's description. * @@ -139,10 +152,12 @@ extern int bt_ctf_clock_set_precision(struct bt_ctf_clock *clock, * Get the clock's offset in seconds from POSIX.1 Epoch, 1970-01-01. * * @param clock Clock instance. + * @param offset_s Pointer to clock offset in seconds (output). * - * Returns the clock's offset in seconds, -1ULL on error. + * Returns 0 on success, a negative value on error. */ -extern uint64_t bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock); +extern int bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock, + int64_t *offset_s); /* * bt_ctf_clock_set_offset_s: set a clock's offset in seconds. @@ -156,18 +171,20 @@ extern uint64_t bt_ctf_clock_get_offset_s(struct bt_ctf_clock *clock); * Returns 0 on success, a negative value on error. */ extern int bt_ctf_clock_set_offset_s(struct bt_ctf_clock *clock, - uint64_t offset_s); + int64_t offset_s); /* - * bt_ctf_clock_get_offset_s: get a clock's offset in ticks. + * bt_ctf_clock_get_offset: get a clock's offset in ticks. * * Get the clock's offset in ticks from Epoch + offset_t. * * @param clock Clock instance. + * @param offset Clock offset in ticks from Epoch + offset_s (output). * - * Returns the clock's offset in ticks from Epoch + offset_s, -1ULL on error. + * Returns 0 on success, a negative value on error. */ -extern uint64_t bt_ctf_clock_get_offset(struct bt_ctf_clock *clock); +extern int bt_ctf_clock_get_offset(struct bt_ctf_clock *clock, + int64_t *offset); /* * bt_ctf_clock_set_offset: set a clock's offset in ticks. @@ -180,7 +197,7 @@ extern uint64_t bt_ctf_clock_get_offset(struct bt_ctf_clock *clock); * Returns 0 on success, a negative value on error. */ extern int bt_ctf_clock_set_offset(struct bt_ctf_clock *clock, - uint64_t offset); + int64_t offset); /* * bt_ctf_clock_get_is_absolute: get a clock's absolute attribute. @@ -209,42 +226,38 @@ extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute); /* - * bt_ctf_clock_get_time: get a clock's current time value. + * bt_ctf_clock_get_uuid: get a clock's UUID. * - * Get the current time in nanoseconds since the clock's origin (offset and - * offset_s attributes). + * Get the clock's UUID. * - * Returns the clock's current time value, -1ULL on error. - */ -extern uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock); - -/* - * bt_ctf_clock_set_time: set a clock's current time value. - * - * Set the current time in nanoseconds since the clock's origin (offset and - * offset_s attributes). Defaults to 0. + * @param clock Clock instance. * - * Returns 0 on success, a negative value on error. + * Returns a pointer to the clock's UUID (16 byte array) on success, + * NULL on error. */ -extern int bt_ctf_clock_set_time(struct bt_ctf_clock *clock, - uint64_t time); +extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock); /* - * bt_ctf_clock_get and bt_ctf_clock_put: increment and decrement the - * refcount of the clock - * - * These functions ensure that the clock won't be destroyed when it - * is in use. The same number of get and put (plus one extra put to - * release the initial reference done at creation) has to be done to - * destroy a clock. + * bt_ctf_clock_set_uuid: set a clock's UUID. * - * When the clock refcount is decremented to 0 by a bt_ctf_clock_put, - * the clock is freed. + * Set a clock's UUID. * * @param clock Clock instance. + * @param uuid A 16-byte array containing a UUID. + * + * Returns 0 on success, a negative value on error. */ -extern void bt_ctf_clock_get(struct bt_ctf_clock *clock); -extern void bt_ctf_clock_put(struct bt_ctf_clock *clock); +extern int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock, + const unsigned char *uuid); + +extern struct bt_ctf_clock_value *bt_ctf_clock_value_create( + struct bt_ctf_clock *clock, uint64_t value); + +extern int bt_ctf_clock_value_get_value( + struct bt_ctf_clock_value *clock_value, uint64_t *raw_value); + +extern int bt_ctf_clock_value_get_value_ns_from_epoch( + struct bt_ctf_clock_value *clock_value, int64_t *value_ns); #ifdef __cplusplus }