#include <babeltrace/ctf/metadata.h>
#include <babeltrace/babeltrace-internal.h>
#include <babeltrace/ctf/events-internal.h>
+#include <babeltrace/uuid.h>
+#include <babeltrace/endian.h>
#include <inttypes.h>
#include <stdio.h>
-#include <uuid/uuid.h>
#include <sys/mman.h>
#include <errno.h>
-#include <endian.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include "metadata/ctf-scanner.h"
#include "metadata/ctf-parser.h"
#include "metadata/ctf-ast.h"
+#include "events-private.h"
+#include "memstream.h"
/*
* We currently simply map a page to read the packet header and packet
*/
#define MAX_PACKET_HEADER_LEN (getpagesize() * CHAR_BIT)
#define WRITE_PACKET_LEN (getpagesize() * 8 * CHAR_BIT)
-#define UUID_LEN 16 /* uuid by value len */
#ifndef min
#define min(a, b) (((a) < (b)) ? (a) : (b))
uint64_t timestamp)
{
uint64_t ts_sec = 0, ts_nsec;
- struct ctf_trace *trace = stream->stream_class->trace;
- struct trace_collection *tc = trace->collection;
- uint64_t tc_offset = tc->single_clock_offset_avg;
- if (stream->current_clock->freq == 1000000000ULL) {
- ts_nsec = timestamp;
+ if (opt_clock_raw) {
+ ts_nsec = ctf_get_timestamp_raw(stream, timestamp);
} else {
- ts_nsec = (uint64_t) ((double) timestamp * 1000000000.0
- / (double) stream->current_clock->freq);
+ ts_nsec = ctf_get_timestamp(stream, timestamp);
}
- /* Add offsets */
- if (!opt_clock_raw) {
- ts_nsec += tc_offset;
- }
+ /* Add command-line offset */
ts_sec += opt_clock_offset;
ts_sec += ts_nsec / NSEC_PER_SEC;
memcpy(td->uuid, header.uuid, sizeof(header.uuid));
CTF_TRACE_SET_FIELD(td, uuid);
} else {
- if (uuid_compare(header.uuid, td->uuid))
+ if (babeltrace_uuid_compare(header.uuid, td->uuid))
return -EINVAL;
}
* because its size includes garbage at the end (after final
* \0). This is the allocated size, not the actual string size.
*/
- out = open_memstream(buf, &size);
+ out = babeltrace_open_memstream(buf, &size);
if (out == NULL) {
perror("Metadata open_memstream");
return -errno;
break;
}
}
- fclose(out); /* flush the buffer */
+ /* close to flush the buffer */
+ ret = babeltrace_close_memstream(buf, &size, out);
+ if (ret < 0) {
+ perror("babeltrace_flush_memstream");
+ fclose(in);
+ return -errno;
+ }
fclose(in);
/* open for reading */
- *fp = fmemopen(*buf, strlen(*buf), "rb");
+ *fp = babeltrace_fmemopen(*buf, strlen(*buf), "rb");
if (!*fp) {
perror("Metadata fmemopen");
return -errno;
struct definition_array *defarray;
struct definition *field;
uint64_t i;
- uint8_t uuidval[UUID_LEN];
+ uint8_t uuidval[BABELTRACE_UUID_LEN];
field = struct_definition_get_field_from_index(file_stream->parent.trace_packet_header, len_index);
assert(field->declaration->id == CTF_TYPE_ARRAY);
defarray = container_of(field, struct definition_array, p);
- assert(array_len(defarray) == UUID_LEN);
+ assert(array_len(defarray) == BABELTRACE_UUID_LEN);
- for (i = 0; i < UUID_LEN; i++) {
+ for (i = 0; i < BABELTRACE_UUID_LEN; i++) {
struct definition *elem;
elem = array_index(defarray, i);
uuidval[i] = get_unsigned_int(elem);
}
- ret = uuid_compare(td->uuid, uuidval);
+ ret = babeltrace_uuid_compare(td->uuid, uuidval);
if (ret) {
fprintf(stderr, "[error] Unique Universal Identifiers do not match.\n");
return -EINVAL;