AC_FUNC_MMAP
AC_CHECK_FUNCS([bzero gettimeofday munmap strtoul])
-# Check libuuid
-AC_CHECK_LIB([uuid], [uuid_generate], [],
- [AC_MSG_ERROR([Cannot find libuuid. Use [LDFLAGS]=-Ldir to specify its location.])]
+# Check for libuuid
+AC_CHECK_LIB([uuid], [uuid_generate],
+[
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBUUID], 1, [Has libuuid support.])
+ have_libuuid=yes
+],
+[
+ # libuuid not found, check for uuid_create in libc.
+ AC_CHECK_LIB([c], [uuid_create],
+ [
+ AC_DEFINE_UNQUOTED([BABELTRACE_HAVE_LIBC_UUID], 1, [Has libc uuid support.])
+ have_libc_uuid=yes
+ ],
+ [
+ AC_MSG_ERROR([Cannot find libuuid uuid_generate nor libc uuid_create. Use [LDFLAGS]=-Ldir to specify their location.])
+ ])
+]
)
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBUUID], [test "x$have_libuuid" = "xyes"])
+AM_CONDITIONAL([BABELTRACE_BUILD_WITH_LIBC_UUID], [test "x$have_libc_uuid" = "xyes"])
AC_CHECK_LIB([popt], [poptGetContext], [],
[AC_MSG_ERROR([Cannot find popt.])]
babeltrace_log_LDADD = \
$(top_builddir)/lib/libbabeltrace.la \
$(top_builddir)/formats/ctf/libbabeltrace-ctf.la
+
+if BABELTRACE_BUILD_WITH_LIBUUID
+babeltrace_log_LDADD += -luuid
+endif
+if BABELTRACE_BUILD_WITH_LIBC_UUID
+babeltrace_log_LDADD += -lc
+endif
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/types.h>
+#include <babeltrace/uuid.h>
#define USEC_PER_SEC 1000000UL
-#ifndef UUID_STR_LEN
-#define UUID_STR_LEN 37 /* With \0 */
-#endif
-
int babeltrace_debug, babeltrace_verbose;
static char *s_outputname;
static
void print_metadata(FILE *fp)
{
- char uuid_str[UUID_STR_LEN];
+ char uuid_str[BABELTRACE_UUID_STR_LEN];
unsigned int major = 0, minor = 0;
int ret;
ret = sscanf(VERSION, "%u.%u", &major, &minor);
if (ret != 2)
fprintf(stderr, "[warning] Incorrect babeltrace version format\n.");
- uuid_unparse(s_uuid, uuid_str);
+ babeltrace_uuid_unparse(s_uuid, uuid_str);
fprintf(fp, metadata_fmt,
major,
minor,
libctf_ast_la_LIBADD = \
$(top_builddir)/lib/libbabeltrace.la
+if BABELTRACE_BUILD_WITH_LIBUUID
+libctf_ast_la_LIBADD += -luuid
+endif
+if BABELTRACE_BUILD_WITH_LIBC_UUID
+libctf_ast_la_LIBADD += -lc
+endif
+
noinst_PROGRAMS = ctf-parser-test
ctf_parser_test_SOURCES = ctf-parser-test.c
#include <babeltrace/list.h>
#include <babeltrace/types.h>
#include <babeltrace/ctf/metadata.h>
-#include <uuid/uuid.h>
+#include <babeltrace/uuid.h>
#include "ctf-scanner.h"
#include "ctf-parser.h"
#include "ctf-ast.h"
assert(node->u.unary_expression.link == UNARY_LINK_UNKNOWN);
assert(i == 0);
src_string = node->u.unary_expression.u.string;
- ret = uuid_parse(src_string, *uuid);
+ ret = babeltrace_uuid_parse(src_string, *uuid);
}
return ret;
}
goto error;
}
if (CTF_TRACE_FIELD_IS_SET(trace, uuid)
- && uuid_compare(uuid, trace->uuid)) {
+ && babeltrace_uuid_compare(uuid, trace->uuid)) {
fprintf(fd, "[error] %s: uuid mismatch\n", __func__);
ret = -EPERM;
goto error;
babeltrace/ctf-text/types.h \
babeltrace/ctf/types.h \
babeltrace/ctf/callbacks-internal.h \
- babeltrace/trace-handle-internal.h
+ babeltrace/trace-handle-internal.h \
+ babeltrace/uuid.h
--- /dev/null
+#ifndef _BABELTRACE_UUID_H
+#define _BABELTRACE_UUID_H
+
+/*
+ * Copyright (C) 2011 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ *
+ * THIS MATERIAL IS PROVIDED AS IS, WITH ABSOLUTELY NO WARRANTY EXPRESSED
+ * OR IMPLIED. ANY USE IS AT YOUR OWN RISK.
+ *
+ * Permission is hereby granted to use or copy this program
+ * for any purpose, provided the above notices are retained on all copies.
+ * Permission to modify the code and to distribute modified code is granted,
+ * provided the above notices are retained, and a notice that the code was
+ * modified is included with the above copyright notice.
+ */
+
+#include <config.h>
+
+/* Includes final \0. */
+#define BABELTRACE_UUID_STR_LEN 37
+#define BABELTRACE_UUID_LEN 16
+
+#ifdef BABELTRACE_HAVE_LIBUUID
+#include <uuid/uuid.h>
+
+static inline
+int babeltrace_uuid_generate(unsigned char *uuid_out)
+{
+ uuid_generate(uuid_out);
+ return 0;
+}
+
+static inline
+void babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ return uuid_unparse(uuid_in, str_out);
+}
+
+static inline
+int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ return uuid_parse(str_in, uuid_out);
+}
+
+static inline
+int babeltrace_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ return uuid_compare(uuid_a, uuid_b);
+}
+
+#elif defined(BABELTRACE_HAVE_LIBC_UUID)
+#include <uuid.h>
+#include <stdint.h>
+
+static inline
+int babeltrace_uuid_generate(unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_create((uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+void babeltrace_uuid_unparse(const unsigned char *uuid_in, char *str_out)
+{
+ uint32_t status;
+
+ uuid_to_string((uuid_t *) uuid_in, str_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int babeltrace_uuid_parse(const char *str_in, unsigned char *uuid_out)
+{
+ uint32_t status;
+
+ uuid_from_string(str_in, (uuid_t *) uuid_out, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+static inline
+int babeltrace_uuid_compare(const unsigned char *uuid_a,
+ const unsigned char *uuid_b)
+{
+ uint32_t status;
+
+ uuid_compare((uuid_t *) uuid_a, (uuid_t *) uuid_b, &status);
+ if (status == uuid_s_ok)
+ return 0;
+ else
+ return -1;
+}
+
+#else
+#error "Babeltrace needs to have a UUID generator configured."
+#endif
+
+#endif /* _BABELTRACE_UUID_H */