Move to kernel style SPDX license identifiers
[lttng-ust.git] / liblttng-ust / lttng-context-provider.c
index b5ae3075c075d1c70a797e5014f98ccb92a20d2d..ea7965c863636624cfa47c9bf757c646b0346bc6 100644 (file)
@@ -1,30 +1,22 @@
 /*
- * lttng-context-provider.c
- *
- * LTTng UST application context provider.
+ * SPDX-License-Identifier: LGPL-2.1-only
  *
  * Copyright (C) 2016 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
  *
- * This library is free software; you can redistribute it and/or
- * modify it under the terms of the GNU Lesser General Public
- * License as published by the Free Software Foundation; only
- * version 2.1 of the License.
- *
- * This library is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
- * Lesser General Public License for more details.
- *
- * You should have received a copy of the GNU Lesser General Public
- * License along with this library; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
+ * LTTng UST application context provider.
  */
 
+#define _LGPL_SOURCE
+#include <stddef.h>
+#include <stdint.h>
 #include <sys/types.h>
 #include <unistd.h>
+
 #include <lttng/ust-context-provider.h>
+
 #include "lttng-tracer-core.h"
 #include "jhash.h"
+#include "context-provider-internal.h"
 #include <helper.h>
 
 #define CONTEXT_PROVIDER_HT_BITS       12
@@ -67,10 +59,12 @@ int lttng_ust_context_provider_register(struct lttng_ust_context_provider *provi
        uint32_t hash;
        int ret = 0;
 
+       lttng_ust_fixup_tls();
+
        /* Provider name starts with "$app.". */
-       if (strncmp("$app.", provider->name, strlen("$app.") != 0))
+       if (strncmp("$app.", provider->name, strlen("$app.")) != 0)
                return -EINVAL;
-       /* Provider name cannot contain a column character. */
+       /* Provider name cannot contain a colon character. */
        if (strchr(provider->name, ':'))
                return -EINVAL;
        if (ust_lock()) {
@@ -84,46 +78,33 @@ int lttng_ust_context_provider_register(struct lttng_ust_context_provider *provi
        hash = jhash(provider->name, name_len, 0);
        head = &context_provider_ht.table[hash & (CONTEXT_PROVIDER_HT_SIZE - 1)];
        cds_hlist_add_head(&provider->node, head);
+
        lttng_ust_context_set_session_provider(provider->name,
                provider->get_size, provider->record,
                provider->get_value);
+
+       lttng_ust_context_set_event_notifier_group_provider(provider->name,
+               provider->get_size, provider->record,
+               provider->get_value);
 end:
        ust_unlock();
        return ret;
 }
 
-size_t lttng_ust_dummy_get_size(struct lttng_ctx_field *field, size_t offset)
-{
-       size_t size = 0;
-
-       size += lib_ring_buffer_align(offset, lttng_alignof(char));
-       size += sizeof(char);           /* tag */
-       return size;
-}
-
-void lttng_ust_dummy_record(struct lttng_ctx_field *field,
-                struct lttng_ust_lib_ring_buffer_ctx *ctx,
-                struct lttng_channel *chan)
-{
-       char sel_char = (char) LTTNG_UST_DYNAMIC_TYPE_NONE;
-
-       lib_ring_buffer_align_ctx(ctx, lttng_alignof(sel_char));
-       chan->ops->event_write(ctx, &sel_char, sizeof(sel_char));
-}
-
-void lttng_ust_dummy_get_value(struct lttng_ctx_field *field,
-               struct lttng_ctx_value *value)
-{
-       value->sel = LTTNG_UST_DYNAMIC_TYPE_NONE;
-}
-
 void lttng_ust_context_provider_unregister(struct lttng_ust_context_provider *provider)
 {
+       lttng_ust_fixup_tls();
+
        if (ust_lock())
                goto end;
        lttng_ust_context_set_session_provider(provider->name,
                lttng_ust_dummy_get_size, lttng_ust_dummy_record,
                lttng_ust_dummy_get_value);
+
+       lttng_ust_context_set_event_notifier_group_provider(provider->name,
+               lttng_ust_dummy_get_size, lttng_ust_dummy_record,
+               lttng_ust_dummy_get_value);
+
        cds_hlist_del(&provider->node);
 end:
        ust_unlock();
This page took 0.024846 seconds and 4 git commands to generate.