cleanup: protected -> hidden: cleanup symbol table
[babeltrace.git] / lib / trace-handle.c
CommitLineData
842c2b97
JD
1/*
2 * trace_handle.c
3 *
4 * Babeltrace Library
5 *
6 * Copyright 2012 EfficiOS Inc. and Linux Foundation
7 *
8 * Author: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
9 * Julien Desfossez <julien.desfossez@efficios.com>
10 *
11 * Permission is hereby granted, free of charge, to any person obtaining a copy
12 * of this software and associated documentation files (the "Software"), to deal
13 * in the Software without restriction, including without limitation the rights
14 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
15 * copies of the Software, and to permit persons to whom the Software is
16 * furnished to do so, subject to the following conditions:
17 *
18 * The above copyright notice and this permission notice shall be included in
19 * all copies or substantial portions of the Software.
20 */
21
22#include <stdint.h>
23#include <stdlib.h>
24#include <babeltrace/babeltrace.h>
25#include <babeltrace/context.h>
08c22d05 26#include <babeltrace/context-internal.h>
842c2b97
JD
27#include <babeltrace/trace-handle.h>
28#include <babeltrace/trace-handle-internal.h>
29
30struct bt_trace_handle *bt_trace_handle_create(struct bt_context *ctx)
31{
32 struct bt_trace_handle *th;
33
6cba487f 34 th = g_new0(struct bt_trace_handle, 1);
842c2b97
JD
35 th->id = ctx->last_trace_handle_id++;
36 return th;
37}
38
6cba487f
MD
39void bt_trace_handle_destroy(struct bt_trace_handle *th)
40{
41 g_free(th);
42}
43
44int bt_trace_handle_get_id(struct bt_trace_handle *th)
842c2b97 45{
6cba487f 46 return th->id;
842c2b97
JD
47}
48
e3d12cf9 49const char *bt_trace_handle_get_path(struct bt_context *ctx, int handle_id)
842c2b97 50{
e3d12cf9
JD
51 struct bt_trace_handle *handle;
52
53 handle = g_hash_table_lookup(ctx->trace_handles,
54 (gpointer) (unsigned long) handle_id);
5d95b2db
JD
55 if (!handle)
56 return NULL;
e3d12cf9 57 return handle->path;
842c2b97
JD
58}
59
03798a93
JD
60uint64_t bt_trace_handle_get_timestamp_begin(struct bt_context *ctx,
61 int handle_id, enum bt_clock_type type)
842c2b97 62{
e3d12cf9 63 struct bt_trace_handle *handle;
03798a93 64 uint64_t ret;
e3d12cf9
JD
65
66 handle = g_hash_table_lookup(ctx->trace_handles,
67 (gpointer) (unsigned long) handle_id);
03798a93
JD
68 if (!handle) {
69 ret = -1ULL;
70 goto end;
71 }
72 if (type == BT_CLOCK_REAL) {
73 ret = handle->real_timestamp_begin;
74 } else if (type == BT_CLOCK_CYCLES) {
75 ret = handle->cycles_timestamp_begin;
76 } else {
77 ret = -1ULL;
78 }
79
80end:
81 return ret;
842c2b97
JD
82}
83
03798a93
JD
84uint64_t bt_trace_handle_get_timestamp_end(struct bt_context *ctx,
85 int handle_id, enum bt_clock_type type)
842c2b97 86{
e3d12cf9 87 struct bt_trace_handle *handle;
03798a93 88 uint64_t ret;
e3d12cf9
JD
89
90 handle = g_hash_table_lookup(ctx->trace_handles,
91 (gpointer) (unsigned long) handle_id);
03798a93
JD
92 if (!handle) {
93 ret = -1ULL;
94 goto end;
95 }
96 if (type == BT_CLOCK_REAL) {
97 ret = handle->real_timestamp_end;
98 } else if (type == BT_CLOCK_CYCLES) {
99 ret = handle->cycles_timestamp_end;
100 } else {
101 ret = -1ULL;
102 }
103
104end:
105 return ret;
842c2b97 106}
This page took 0.026573 seconds and 4 git commands to generate.