From: Michael Jeanson Date: Wed, 14 Sep 2016 17:45:37 +0000 (-0400) Subject: Port: Fix libuuid compat on mingw X-Git-Tag: v2.0.0-pre1~96 X-Git-Url: http://git.efficios.com/?p=babeltrace.git;a=commitdiff_plain;h=20eee76ef91ef70be2cf302a90f16899f01793cb Port: Fix libuuid compat on mingw Signed-off-by: Michael Jeanson Signed-off-by: Jérémie Galarneau --- diff --git a/compat/Makefile.am b/compat/Makefile.am index 38af1885..33d49241 100644 --- a/compat/Makefile.am +++ b/compat/Makefile.am @@ -2,11 +2,7 @@ AM_CFLAGS = $(PACKAGE_CFLAGS) -I$(top_srcdir)/include noinst_LTLIBRARIES = libcompat.la -libcompat_la_SOURCES = dummy.c +libcompat_la_SOURCES = compat_uuid.c libcompat_la_LDFLAGS = \ $(LD_NO_AS_NEEDED) - -if BABELTRACE_BUILD_WITH_MINGW -libcompat_la_SOURCES += compat_uuid.c -endif diff --git a/compat/compat_uuid.c b/compat/compat_uuid.c index 03ca1675..94511d31 100644 --- a/compat/compat_uuid.c +++ b/compat/compat_uuid.c @@ -22,9 +22,9 @@ * SOFTWARE. */ -/* This file is only built under MINGW32 */ +#ifdef __MINGW32__ -#include +#include #include #include @@ -42,17 +42,17 @@ void swap(unsigned char *ptr, unsigned int i, unsigned int j) static void fix_uuid_endian(unsigned char * ptr) { - swap(ptr, 0, 3) - swap(ptr, 1, 2) - swap(ptr, 4, 5) - swap(ptr, 6, 7) + swap(ptr, 0, 3); + swap(ptr, 1, 2); + swap(ptr, 4, 5); + swap(ptr, 6, 7); } int bt_uuid_generate(unsigned char *uuid_out) { RPC_STATUS status; - status = UuidCreate((struct UUID *)uuid_out); + status = UuidCreate((UUID *) uuid_out); if (status == RPC_S_OK) return 0; else @@ -70,7 +70,7 @@ int bt_uuid_unparse(const unsigned char *uuid_in, char *str_out) memcpy(copy_of_uuid_in, uuid_in, BABELTRACE_UUID_LEN); fix_uuid_endian(copy_of_uuid_in); - status = UuidToString((struct UUID *) copy_of_uuid_in, &alloc_str); + status = UuidToString((UUID *) copy_of_uuid_in, &alloc_str); if (status == RPC_S_OK) { strncpy(str_out, (char *) alloc_str, BABELTRACE_UUID_STR_LEN); @@ -88,7 +88,7 @@ int bt_uuid_parse(const char *str_in, unsigned char *uuid_out) RPC_STATUS status; status = UuidFromString((unsigned char *) str_in, - (struct UUID *) uuid_out); + (UUID *) uuid_out); fix_uuid_endian(uuid_out); if (status == RPC_S_OK) @@ -102,10 +102,7 @@ int bt_uuid_compare(const unsigned char *uuid_a, { RPC_STATUS status; - if (!UuidCompare((struct UUID *) uuid_a, (struct UUID *) uuid_b, - &status)) { - return 0; - } else { - return -1; - } + return !UuidCompare((UUID *) uuid_a, (UUID *) uuid_b, &status) ? 0 : -1; } + +#endif diff --git a/compat/dummy.c b/compat/dummy.c deleted file mode 100644 index 724a4578..00000000 --- a/compat/dummy.c +++ /dev/null @@ -1,2 +0,0 @@ -/* BSD versions of ar won't accept an empty file list */ -int bt_looks_like_iso_requires_this = 23; diff --git a/include/babeltrace/ctf-ir/clock-class-internal.h b/include/babeltrace/ctf-ir/clock-class-internal.h index d68796e7..5ebd86ed 100644 --- a/include/babeltrace/ctf-ir/clock-class-internal.h +++ b/include/babeltrace/ctf-ir/clock-class-internal.h @@ -43,7 +43,7 @@ struct bt_ctf_clock_class { uint64_t precision; int64_t offset_s; /* Offset in seconds */ int64_t offset; /* Offset in ticks */ - uuid_t uuid; + unsigned char uuid[BABELTRACE_UUID_LEN]; int uuid_set; int absolute; diff --git a/include/babeltrace/ctf-ir/trace-internal.h b/include/babeltrace/ctf-ir/trace-internal.h index 3f583065..468b72f0 100644 --- a/include/babeltrace/ctf-ir/trace-internal.h +++ b/include/babeltrace/ctf-ir/trace-internal.h @@ -36,7 +36,7 @@ #include #include #include -#include +#include enum field_type_alias { FIELD_TYPE_ALIAS_UINT5_T = 0, @@ -52,7 +52,7 @@ struct bt_ctf_trace { struct bt_object base; GString *name; int frozen; - uuid_t uuid; + unsigned char uuid[BABELTRACE_UUID_LEN]; bt_bool uuid_set; enum bt_ctf_byte_order native_byte_order; struct bt_value *environment; diff --git a/lib/ctf-ir/clock-class.c b/lib/ctf-ir/clock-class.c index 87c3d6bb..d9880716 100644 --- a/lib/ctf-ir/clock-class.c +++ b/lib/ctf-ir/clock-class.c @@ -456,7 +456,7 @@ int bt_ctf_clock_class_set_uuid(struct bt_ctf_clock_class *clock_class, goto end; } - memcpy(clock_class->uuid, uuid, sizeof(uuid_t)); + memcpy(clock_class->uuid, uuid, BABELTRACE_UUID_LEN); clock_class->uuid_set = 1; BT_LOGV("Set clock class's UUID: addr=%p, name=\"%s\", " "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", diff --git a/lib/ctf-ir/trace.c b/lib/ctf-ir/trace.c index 34b459df..37fa2763 100644 --- a/lib/ctf-ir/trace.c +++ b/lib/ctf-ir/trace.c @@ -238,7 +238,7 @@ int bt_ctf_trace_set_uuid(struct bt_ctf_trace *trace, const unsigned char *uuid) goto end; } - memcpy(trace->uuid, uuid, sizeof(uuid_t)); + memcpy(trace->uuid, uuid, BABELTRACE_UUID_LEN); trace->uuid_set = BT_TRUE; BT_LOGV("Set trace's UUID: addr=%p, name=\"%s\", " "uuid=\"%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x\"", diff --git a/lib/ctf-writer/writer.c b/lib/ctf-writer/writer.c index c005993b..70f22e56 100644 --- a/lib/ctf-writer/writer.c +++ b/lib/ctf-writer/writer.c @@ -26,6 +26,9 @@ * SOFTWARE. */ +#define BT_LOG_TAG "WRITER" +#include + #include #include #include @@ -133,7 +136,12 @@ struct bt_ctf_writer *bt_ctf_writer_create(const char *path) } /* Generate a UUID for this writer's trace */ - uuid_generate(uuid); + ret = bt_uuid_generate(uuid); + if (ret) { + BT_LOGE_STR("Cannot generate UUID for CTF writer's trace."); + goto error_destroy; + } + ret = bt_ctf_trace_set_uuid(writer->trace, uuid); if (ret) { goto error_destroy;