cleanup: explicitly mark unused parameters (-Wunused-parameter)
[lttng-ust.git] / liblttng-ust / lttng-context-ip.c
... / ...
CommitLineData
1/*
2 * SPDX-License-Identifier: LGPL-2.1-only
3 *
4 * Copyright (C) 2009-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
5 *
6 * LTTng UST Instruction Pointer Context.
7 */
8
9#define _LGPL_SOURCE
10#include <limits.h>
11#include <stddef.h>
12#include <sys/types.h>
13#include <unistd.h>
14#include <lttng/ust-events.h>
15#include <lttng/ust-tracer.h>
16#include <lttng/ringbuffer-context.h>
17
18#include "context-internal.h"
19
20static
21size_t ip_get_size(struct lttng_ust_ctx_field *field __attribute__((unused)),
22 size_t offset)
23{
24 size_t size = 0;
25
26 size += lttng_ust_lib_ring_buffer_align(offset, lttng_ust_rb_alignof(void *));
27 size += sizeof(void *);
28 return size;
29}
30
31static
32void ip_record(struct lttng_ust_ctx_field *field __attribute__((unused)),
33 struct lttng_ust_lib_ring_buffer_ctx *ctx,
34 struct lttng_ust_channel_buffer *chan)
35{
36 void *ip;
37
38 ip = ctx->ip;
39 chan->ops->event_write(ctx, &ip, sizeof(ip), lttng_ust_rb_alignof(ip));
40}
41
42int lttng_add_ip_to_ctx(struct lttng_ust_ctx **ctx)
43{
44 struct lttng_ust_ctx_field *field;
45 struct lttng_ust_type_common *type;
46 int ret;
47
48 type = lttng_ust_create_type_integer(sizeof(void *) * CHAR_BIT,
49 lttng_ust_rb_alignof(void *) * CHAR_BIT,
50 lttng_ust_is_signed_type(void *),
51 BYTE_ORDER, 16);
52 if (!type)
53 return -ENOMEM;
54 field = lttng_append_context(ctx);
55 if (!field) {
56 ret = -ENOMEM;
57 goto error_context;
58 }
59 if (lttng_find_context(*ctx, "ip")) {
60 ret = -EEXIST;
61 goto error_find_context;
62 }
63 field->event_field->name = strdup("ip");
64 if (!field->event_field->name) {
65 ret = -ENOMEM;
66 goto error_name;
67 }
68 field->event_field->type = type;
69 field->get_size = ip_get_size;
70 field->record = ip_record;
71 lttng_context_update(*ctx);
72 return 0;
73
74error_name:
75error_find_context:
76 lttng_remove_context_field(ctx, field);
77error_context:
78 lttng_ust_destroy_type(type);
79 return ret;
80}
This page took 0.0225 seconds and 4 git commands to generate.