From 85b743f4fb661eec7cf76b546564f62ceaf22a34 Mon Sep 17 00:00:00 2001 From: =?utf8?q?J=C3=A9r=C3=A9mie=20Galarneau?= Date: Sun, 5 Oct 2014 21:20:25 -0400 Subject: [PATCH] Add UUID accessors to CTF-IR clock MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Jérémie Galarneau --- formats/ctf/ir/clock.c | 28 ++++++++++++++++++++++++++++ include/babeltrace/ctf-ir/clock.h | 25 +++++++++++++++++++++++++ 2 files changed, 53 insertions(+) diff --git a/formats/ctf/ir/clock.c b/formats/ctf/ir/clock.c index 2a55857f..a883f53e 100644 --- a/formats/ctf/ir/clock.c +++ b/formats/ctf/ir/clock.c @@ -245,6 +245,34 @@ end: return ret; } +const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock) +{ + const unsigned char *ret; + + if (!clock) { + ret = NULL; + goto end; + } + + ret = clock->uuid; +end: + return ret; +} + +int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock, const unsigned char *uuid) +{ + int ret = 0; + + if (!clock || !uuid) { + ret = -1; + goto end; + } + + memcpy(clock->uuid, uuid, sizeof(uuid_t)); +end: + return ret; +} + uint64_t bt_ctf_clock_get_time(struct bt_ctf_clock *clock) { uint64_t ret = -1ULL; diff --git a/include/babeltrace/ctf-ir/clock.h b/include/babeltrace/ctf-ir/clock.h index c1ae948a..dea3f2b6 100644 --- a/include/babeltrace/ctf-ir/clock.h +++ b/include/babeltrace/ctf-ir/clock.h @@ -208,6 +208,31 @@ extern int bt_ctf_clock_get_is_absolute(struct bt_ctf_clock *clock); extern int bt_ctf_clock_set_is_absolute(struct bt_ctf_clock *clock, int is_absolute); +/* + * bt_ctf_clock_get_uuid: get a clock's UUID. + * + * Get the clock's UUID. + * + * @param clock Clock instance. + * + * Returns a pointer to the clock's UUID (16 byte array) on success, + * NULL on error. + */ +extern const unsigned char *bt_ctf_clock_get_uuid(struct bt_ctf_clock *clock); + +/* + * bt_ctf_clock_set_uuid: set a clock's UUID. + * + * 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 int bt_ctf_clock_set_uuid(struct bt_ctf_clock *clock, + const unsigned char *uuid); + /* * bt_ctf_clock_get_time: get a clock's current time value. * -- 2.34.1