projects
/
lttng-ust.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Fix: pass private data to context callbacks
[lttng-ust.git]
/
libringbuffer
/
vatomic.h
diff --git
a/libringbuffer/vatomic.h
b/libringbuffer/vatomic.h
index eea6d049c71d995545054c5775a0b9cda43baf59..199d2c77faacc184856ba8317ba829913c3f091a 100644
(file)
--- a/
libringbuffer/vatomic.h
+++ b/
libringbuffer/vatomic.h
@@
-1,14
+1,15
@@
-#ifndef _LINUX_RING_BUFFER_VATOMIC_H
-#define _LINUX_RING_BUFFER_VATOMIC_H
-
/*
/*
- * linux/ringbuffer/vatomic.h
- *
- * Copyright (C) 2010 - Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
+ * SPDX-License-Identifier: MIT
*
*
- *
Dual LGPL v2.1/GPL v2 license.
+ *
Copyright (C) 2010-2012 Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
*/
*/
+#ifndef _LTTNG_RING_BUFFER_VATOMIC_H
+#define _LTTNG_RING_BUFFER_VATOMIC_H
+
+#include <assert.h>
+#include <urcu/uatomic.h>
+
/*
* Same data type (long) accessed differently depending on configuration.
* v field is for non-atomic access (protected by mutual exclusion).
/*
* Same data type (long) accessed differently depending on configuration.
* v field is for non-atomic access (protected by mutual exclusion).
@@
-18,65
+19,54
@@
* atomic_long_t is used for globally shared buffers.
*/
union v_atomic {
* atomic_long_t is used for globally shared buffers.
*/
union v_atomic {
- local_t l;
- atomic_long_t a;
+ long a; /* accessed through uatomic */
long v;
};
static inline
long v;
};
static inline
-long v_read(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
+long v_read(const struct l
ttng_ust_l
ib_ring_buffer_config *config, union v_atomic *v_a)
{
{
- if (config->sync == RING_BUFFER_SYNC_PER_CPU)
- return local_read(&v_a->l);
- else
- return atomic_long_read(&v_a->a);
+ assert(config->sync != RING_BUFFER_SYNC_PER_CPU);
+ return uatomic_read(&v_a->a);
}
static inline
}
static inline
-void v_set(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
+void v_set(const struct l
ttng_ust_l
ib_ring_buffer_config *config, union v_atomic *v_a,
long v)
{
long v)
{
- if (config->sync == RING_BUFFER_SYNC_PER_CPU)
- local_set(&v_a->l, v);
- else
- atomic_long_set(&v_a->a, v);
+ assert(config->sync != RING_BUFFER_SYNC_PER_CPU);
+ uatomic_set(&v_a->a, v);
}
static inline
}
static inline
-void v_add(const struct lib_ring_buffer_config *config, long v, union v_atomic *v_a)
+void v_add(const struct l
ttng_ust_l
ib_ring_buffer_config *config, long v, union v_atomic *v_a)
{
{
- if (config->sync == RING_BUFFER_SYNC_PER_CPU)
- local_add(v, &v_a->l);
- else
- atomic_long_add(v, &v_a->a);
+ assert(config->sync != RING_BUFFER_SYNC_PER_CPU);
+ uatomic_add(&v_a->a, v);
}
static inline
}
static inline
-void v_inc(const struct lib_ring_buffer_config *config, union v_atomic *v_a)
+void v_inc(const struct l
ttng_ust_l
ib_ring_buffer_config *config, union v_atomic *v_a)
{
{
- if (config->sync == RING_BUFFER_SYNC_PER_CPU)
- local_inc(&v_a->l);
- else
- atomic_long_inc(&v_a->a);
+ assert(config->sync != RING_BUFFER_SYNC_PER_CPU);
+ uatomic_inc(&v_a->a);
}
/*
* Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer.
*/
static inline
}
/*
* Non-atomic decrement. Only used by reader, apply to reader-owned subbuffer.
*/
static inline
-void _v_dec(const struct l
ib_ring_buffer_config *config
, union v_atomic *v_a)
+void _v_dec(const struct l
ttng_ust_lib_ring_buffer_config *config __attribute__((unused))
, union v_atomic *v_a)
{
--v_a->v;
}
static inline
{
--v_a->v;
}
static inline
-long v_cmpxchg(const struct lib_ring_buffer_config *config, union v_atomic *v_a,
+long v_cmpxchg(const struct l
ttng_ust_l
ib_ring_buffer_config *config, union v_atomic *v_a,
long old, long _new)
{
long old, long _new)
{
- if (config->sync == RING_BUFFER_SYNC_PER_CPU)
- return local_cmpxchg(&v_a->l, old, _new);
- else
- return atomic_long_cmpxchg(&v_a->a, old, _new);
+ assert(config->sync != RING_BUFFER_SYNC_PER_CPU);
+ return uatomic_cmpxchg(&v_a->a, old, _new);
}
}
-#endif /* _L
INUX
_RING_BUFFER_VATOMIC_H */
+#endif /* _L
TTNG
_RING_BUFFER_VATOMIC_H */
This page took
0.026335 seconds
and
4
git commands to generate.