From: Michael Jeanson Date: Thu, 25 Feb 2021 20:52:52 +0000 (-0500) Subject: Make 'lttng/bitmap.h' a private header X-Git-Tag: v2.13.0-rc1~354 X-Git-Url: https://git.lttng.org./?a=commitdiff_plain;h=b7b5cf30de14bbfa2ceeb303a5983aab6ad78806;p=lttng-ust.git Make 'lttng/bitmap.h' a private header This header only defines static inline utils functions, make it private. Change-Id: I88bb29532bfb24e7e418ddec1e410850df3480b2 Signed-off-by: Michael Jeanson Signed-off-by: Mathieu Desnoyers --- diff --git a/include/Makefile.am b/include/Makefile.am index 9e03290c..101e8ac7 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -33,7 +33,6 @@ nobase_include_HEADERS = \ lttng/ust-getcpu.h \ lttng/ust-elf.h \ lttng/counter-config.h \ - lttng/bitmap.h \ lttng/urcu/pointer.h \ lttng/urcu/urcu-ust.h \ lttng/urcu/static/pointer.h \ @@ -54,6 +53,7 @@ nobase_nodist_include_HEADERS = \ noinst_HEADERS = \ usterr-signal-safe.h \ ust-snprintf.h \ + ust-bitmap.h \ ust-comm.h \ ust-fd.h \ ust-tid.h \ diff --git a/include/lttng/bitmap.h b/include/lttng/bitmap.h deleted file mode 100644 index 29cc22e0..00000000 --- a/include/lttng/bitmap.h +++ /dev/null @@ -1,52 +0,0 @@ -/* - * SPDX-License-Identifier: MIT - * - * Copyright (C) 2020 Mathieu Desnoyers - * - * LTTng Bitmap API - */ - -#ifndef _LTTNG_BITMAP_H -#define _LTTNG_BITMAP_H - -#include -#include -#include -#include - -static inline void lttng_bitmap_index(unsigned int index, unsigned int *word, - unsigned int *bit) -{ - *word = index / CAA_BITS_PER_LONG; - *bit = index % CAA_BITS_PER_LONG; -} - -static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p) -{ - unsigned int word, bit; - unsigned long val; - - lttng_bitmap_index(index, &word, &bit); - val = 1U << bit; - uatomic_or(p + word, val); -} - -static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p) -{ - unsigned int word, bit; - unsigned long val; - - lttng_bitmap_index(index, &word, &bit); - val = ~(1U << bit); - uatomic_and(p + word, val); -} - -static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p) -{ - unsigned int word, bit; - - lttng_bitmap_index(index, &word, &bit); - return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1; -} - -#endif /* _LTTNG_BITMAP_H */ diff --git a/include/ust-bitmap.h b/include/ust-bitmap.h new file mode 100644 index 00000000..29cc22e0 --- /dev/null +++ b/include/ust-bitmap.h @@ -0,0 +1,52 @@ +/* + * SPDX-License-Identifier: MIT + * + * Copyright (C) 2020 Mathieu Desnoyers + * + * LTTng Bitmap API + */ + +#ifndef _LTTNG_BITMAP_H +#define _LTTNG_BITMAP_H + +#include +#include +#include +#include + +static inline void lttng_bitmap_index(unsigned int index, unsigned int *word, + unsigned int *bit) +{ + *word = index / CAA_BITS_PER_LONG; + *bit = index % CAA_BITS_PER_LONG; +} + +static inline void lttng_bitmap_set_bit(unsigned int index, unsigned long *p) +{ + unsigned int word, bit; + unsigned long val; + + lttng_bitmap_index(index, &word, &bit); + val = 1U << bit; + uatomic_or(p + word, val); +} + +static inline void lttng_bitmap_clear_bit(unsigned int index, unsigned long *p) +{ + unsigned int word, bit; + unsigned long val; + + lttng_bitmap_index(index, &word, &bit); + val = ~(1U << bit); + uatomic_and(p + word, val); +} + +static inline bool lttng_bitmap_test_bit(unsigned int index, unsigned long *p) +{ + unsigned int word, bit; + + lttng_bitmap_index(index, &word, &bit); + return (CMM_LOAD_SHARED(p[word]) >> bit) & 0x1; +} + +#endif /* _LTTNG_BITMAP_H */ diff --git a/libcounter/counter-api.h b/libcounter/counter-api.h index cfce44d9..540bd11f 100644 --- a/libcounter/counter-api.h +++ b/libcounter/counter-api.h @@ -15,7 +15,7 @@ #include "counter-internal.h" #include #include -#include +#include "ust-bitmap.h" #include "../libringbuffer/getcpu.h" /* diff --git a/libcounter/counter.c b/libcounter/counter.c index ca25bda6..c98589db 100644 --- a/libcounter/counter.c +++ b/libcounter/counter.c @@ -9,7 +9,6 @@ #include #include "counter.h" #include "counter-internal.h" -#include #include #include #include @@ -18,6 +17,8 @@ #include "smp.h" #include "shm.h" +#include "ust-bitmap.h" + static size_t lttng_counter_get_dimension_nr_elements(struct lib_counter_dimension *dimension) { return dimension->max_nr_elem;