Port: Fix libuuid compat on mingw
authorMichael Jeanson <mjeanson@efficios.com>
Wed, 14 Sep 2016 17:45:37 +0000 (13:45 -0400)
committerJérémie Galarneau <jeremie.galarneau@efficios.com>
Fri, 9 Jun 2017 20:58:14 +0000 (16:58 -0400)
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
compat/Makefile.am
compat/compat_uuid.c
compat/dummy.c [deleted file]
include/babeltrace/ctf-ir/clock-class-internal.h
include/babeltrace/ctf-ir/trace-internal.h
lib/ctf-ir/clock-class.c
lib/ctf-ir/trace.c
lib/ctf-writer/writer.c

index 38af18854c48084740d3145dc55a3b868da50e9b..33d49241600d7af4c21bc1e90db9749aaa457e8b 100644 (file)
@@ -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
index 03ca167592404add2993d63eb4f5a5c1cc9237a7..94511d3147b626d42e000b11aa952d72fa8e8564 100644 (file)
@@ -22,9 +22,9 @@
  * SOFTWARE.
  */
 
-/* This file is only built under MINGW32 */
+#ifdef __MINGW32__
 
-#include <windows.h>
+#include <rpc.h>
 #include <stdlib.h>
 #include <babeltrace/compat/uuid-internal.h>
 
@@ -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 (file)
index 724a457..0000000
+++ /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;
index d68796e7d15cc82324b35488510add9b5ca4d068..5ebd86ed1207cf1f832e04fdff8d70da0b782041 100644 (file)
@@ -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;
 
index 3f583065eef124520a008a3e3f7c71aacc283c86..468b72f0f712c2cc752d65e8a8872594729b5467 100644 (file)
@@ -36,7 +36,7 @@
 #include <babeltrace/types.h>
 #include <glib.h>
 #include <sys/types.h>
-#include <uuid/uuid.h>
+#include <babeltrace/compat/uuid-internal.h>
 
 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;
index 87c3d6bbf74f587d5de6709c513096e2a6a14b9d..d98807165c889cc4cb1b8627dff207f875686918 100644 (file)
@@ -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\"",
index 34b459df7137cc1b23e4592bcf9fad1cf67d197d..37fa2763f93859fb265cabdfb15c40ee50c6428b 100644 (file)
@@ -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\"",
index c005993be3ffea9937f05f32d3880ea1fe6fc111..70f22e56ebee9dffe0bde410b893b4003c83c8fb 100644 (file)
@@ -26,6 +26,9 @@
  * SOFTWARE.
  */
 
+#define BT_LOG_TAG "WRITER"
+#include <babeltrace/lib-logging-internal.h>
+
 #include <babeltrace/ctf-writer/clock-internal.h>
 #include <babeltrace/ctf-writer/writer-internal.h>
 #include <babeltrace/ctf-ir/field-types-internal.h>
@@ -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;
This page took 0.028345 seconds and 4 git commands to generate.