2 months agoDocument C99 and C++11 requirement in README.md
Mathieu Desnoyers [Tue, 14 Sep 2021 18:15:41 +0000 (14:15 -0400)] 
Document C99 and C++11 requirement in README.md

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ida30f72f57ce6a501d694c61eb9eb7fb3e3b5be3

2 months agoAlways use '__thread' for Thread local storage except on MSVC
Michael Jeanson [Tue, 14 Sep 2021 14:41:08 +0000 (10:41 -0400)] 
Always use '__thread' for Thread local storage except on MSVC

Use the GCC extension '__thread' [1] for Thread local storage on all C
and C++ compilers except MSVC.

While C11 and C++11 respectively offer '_Thread_local' and
'thread_local' as potentialy faster implementations, they offer no
guarantees of compatibility when used in a library interface which might
be used by both C and C++ client code.

[1] https://gcc.gnu.org/onlinedocs/gcc/Thread-Local.html

Change-Id: If4fe8bcdbda24b21dedf382112bd5c5f836c00c8
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agoFix: powerpc32: transparent unions alter calling convention
Mathieu Desnoyers [Mon, 13 Sep 2021 20:57:02 +0000 (16:57 -0400)] 
Fix: powerpc32: transparent unions alter calling convention

On powerpc32, transparent unions have an impact on the calling
convention used for the argument, as they use the calling convention of
the first field of the union rather than the union itself. On powerpc32,
the calling convention for a union is that the register has a pointer to
the union, which differs from the calling convention of its first field
(which is a pointer in this case).

"[...] the argument is passed to the function using the calling
conventions of the first member of the transparent union, not the
calling conventions of the union itself. All members of the union must
have the same machine representation; this is necessary for this
argument passing to work properly." [1]

Therefore, use a transparent union for c++ so c++ compilers can emit
caller code with a compatible stack layout. The "ignored attribute"
warning emitted by clang appears to be only for architectures where the
calling convention is not affected by the presence of transparent union
attribute. Therefore, simply silence this warning.

Link: https://gcc.gnu.org/onlinedocs/gcc-4.6.0/gcc/Type-Attributes.html
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I07182dd4ed37a3f61a226fb199bc98c95f83bd37

2 months agofix: don't use C++ thread_local on MacOs
Michael Jeanson [Thu, 9 Sep 2021 16:11:16 +0000 (12:11 -0400)] 
fix: don't use C++ thread_local on MacOs

Recent versions of Apple's clang++ do support 'thread_local' but the
implementation generates additional helper symbols. This is a problem
when accessing an extern TLS variable in a C++ compile unit that is
provided by a C library that doesn't have those extra symbols.

Fallback to using '__thread' on MacOs.

Change-Id: I87cb5b3c9293f7bf66f7115f453b546dd793a449
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agowfcqueue API: implement overloaded wrappers with templates
Mathieu Desnoyers [Wed, 8 Sep 2021 20:25:55 +0000 (16:25 -0400)] 
wfcqueue API: implement overloaded wrappers with templates

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I58613298f2d949fa1195efdbb9f452fd97b77eeb

2 months agowfcqueue: combine C++ API cds_wfcq_head_cast with overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 20:19:39 +0000 (16:19 -0400)] 
wfcqueue: combine C++ API cds_wfcq_head_cast with overloading

For the sake of wrapper API, implement a cds_wfcq_head_cast_cpp with
overloading, thus leaving in place the cds_wfcq_head_cast and
__cds_wfcq_head_cast C identifiers already exposed by the C++ API.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id9781d46290c47b81a57f48fc045b6307c1143de

2 months agowfstack C++ API: implement overloaded wrappers with templates
Mathieu Desnoyers [Wed, 8 Sep 2021 20:11:46 +0000 (16:11 -0400)] 
wfstack C++ API: implement overloaded wrappers with templates

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iac57f35ce31972c751d95fac7306e9729e9dfa43

2 months agolfstack C++ API: implement overloaded wrappers with templates
Mathieu Desnoyers [Wed, 8 Sep 2021 20:07:35 +0000 (16:07 -0400)] 
lfstack C++ API: implement overloaded wrappers with templates

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1bcfd8f0bab53e30778f7d20e374de750ebdf806

2 months agowfstack: combine C++ API cds_wfs_stack_cast with overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 19:59:43 +0000 (15:59 -0400)] 
wfstack: combine C++ API cds_wfs_stack_cast with overloading

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I343f85d4fab6bf11f8ed128ee4ebd332f4f3d061

2 months agolfstack: combine C++ API cds_lfs_stack_cast with overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 19:57:49 +0000 (15:57 -0400)] 
lfstack: combine C++ API cds_lfs_stack_cast with overloading

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8d9cf79a320f057176972de11e1847076ddb1330

2 months agofix: test_build tap plan
Michael Jeanson [Wed, 8 Sep 2021 19:48:35 +0000 (15:48 -0400)] 
fix: test_build tap plan

Change-Id: I83dc2343fe7c457a1ec0c94ed164c1365fce2bdb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agoTest C++ build of list head init
Simon Marchi [Wed, 8 Sep 2021 19:31:08 +0000 (15:31 -0400)] 
Test C++ build of list head init

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Iaf7655c8a8e76d004910da14343bbebc4309576e

2 months agoFix order of initializers in CDS_LIST_HEAD_INIT
Mathieu Desnoyers [Wed, 8 Sep 2021 19:30:28 +0000 (15:30 -0400)] 
Fix order of initializers in CDS_LIST_HEAD_INIT

When using CDS_LIST_HEAD_INIT in a C++ program, we get (with clang
rather than gcc, because the error message is clearer):

    /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: error: ISO C++ requires field designators to be specified in declaration order; field 'prev' will be initialized after field 'next' [-Werror,-Wreorder-init-list]
        .head = CDS_LIST_HEAD_INIT(list.head),
    /home/simark/src/urcu/include/urcu/list.h:49:53: note: expanded from macro 'CDS_LIST_HEAD_INIT'
    #define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }
    /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:73:13: note: previous initialization for field 'prev' is here
        .head = CDS_LIST_HEAD_INIT(list.head),
    /home/simark/src/urcu/include/urcu/list.h:49:44: note: expanded from macro 'CDS_LIST_HEAD_INIT'
    #define CDS_LIST_HEAD_INIT(name) { .prev = &(name), .next = &(name) }

Fix that by swapping the initializers in CDS_LIST_HEAD_INIT.

Change-Id: Ib127b9cc128fd64f5b2ae028e093be42ca10f437
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agounit tests: test wfcqueue, wfstack, lfstack empty check functions in C++
Mathieu Desnoyers [Wed, 8 Sep 2021 19:27:12 +0000 (15:27 -0400)] 
unit tests: test wfcqueue, wfstack, lfstack empty check functions in C++

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I16c2d51872c1007762a6b75aac7a21974b4b9c8b

2 months agowfcqueue: implement C++ API based on function overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 19:26:59 +0000 (15:26 -0400)] 
wfcqueue: implement C++ API based on function overloading

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8dbd00e9f2c74e9ee914906afa3e6fdece14fc27

2 months agowfstack: implement C++ API based on function overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 19:26:41 +0000 (15:26 -0400)] 
wfstack: implement C++ API based on function overloading

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I85d3f7b8b8d390363b55da634bcafe844ef67102

2 months agolfstack: implement C++ API based on function overloading
Mathieu Desnoyers [Wed, 8 Sep 2021 19:26:15 +0000 (15:26 -0400)] 
lfstack: implement C++ API based on function overloading

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I72967ad460b24f1464394620d68af868340a16ce

2 months agoFix tap.h: remove extra semicolon in pass/fail macros
Mathieu Desnoyers [Wed, 8 Sep 2021 17:54:29 +0000 (13:54 -0400)] 
Fix tap.h: remove extra semicolon in pass/fail macros

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id7df3c04f26932332063b1fed31dc7be80695755

2 months agoAdd C++ build tests
Simon Marchi [Thu, 29 Jul 2021 02:48:21 +0000 (22:48 -0400)] 
Add C++ build tests

Some urcu header files cause build failures when included in C++
programs.  Add a test file that includes all exported headers (except
those that are marked as deprecated) and build that test file as a C and
C++ program, with and without _LGPL_SOURCE defined (to test both the
static and non-static implementations).  This helps ensure that the code
in these headers works as both languages.  This alone does not ensure
full coverage, there may be code in unused macros that would need
fixing.  But by including the "static" headers, this already finds a few

The test doesn't run anything, its purpose is only to verify that things

This catches the following build failures:

 - clang++ doesn't know the __transparent_union__ attribute, place some
   pragmas to ignore this warning around where __transparent_union__ is

 - CDS_WFS_WOULDBLOCK and CDS_WFS_END are cast to a void*.  This doesn't
   work in C++ when assigning to a field them to typed pointer.  Fix
   them by casting to the appropriate type.

 - The transparent union trick doesn't work in C++:

      CXX      test_build_cxx.o
    In file included from /home/simark/src/urcu/include/urcu/wfstack.h:116,
                     from /home/simark/src/urcu/include/urcu/cds.h:35,
                     from /home/simark/src/urcu/tests/unit/test_build_cxx.cpp:34:
    /home/simark/src/urcu/include/urcu/static/wfstack.h: In function ‘cds_wfs_node* _cds_wfs_pop_with_state_blocking(cds_wfs_stack*, int*)’:
    /home/simark/src/urcu/include/urcu/static/wfstack.h:350:54: error: could not convert ‘s’ from ‘cds_wfs_stack*’ to ‘cds_wfs_stack_ptr_t’
      350 |         retnode = ___cds_wfs_pop_with_state_blocking(s, state);
          |                                                      ^
          |                                                      |
          |                                                      cds_wfs_stack*

   A C++ user can fall back to instantiating a cds_wfs_stack_ptr_t
   explicitly, assigning the right field, and passing the
   cds_wfs_stack_ptr_t to the function.  Fix a few instances in the
   static headers.

   A follow up commit will introduce C++ API wrappers based on
   function overloading to provide a C++ API similar to the C API.

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I30adc8df69414a0a019c5ec081f64cfac64843f5

2 months agoBuild and run regression and unit tests as C++ programs
Simon Marchi [Tue, 31 Aug 2021 22:12:44 +0000 (18:12 -0400)] 
Build and run regression and unit tests as C++ programs

Build and run all tests under tests/regression and tests/unit as C++
programs in addition to C.  This helps get confidence that urcu, when
used from a C++ program, behaves well.

Change-Id: Iacaa42dddbcbf59eff8e327edfd0352cce0b74b7
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 months agoAdd --enable-Werror configure switch
Simon Marchi [Tue, 31 Aug 2021 22:09:49 +0000 (18:09 -0400)] 
Add --enable-Werror configure switch

Change-Id: I514335a042b962dcb737f03e2c19c2223961b99c
Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 months agoAdd `urcu_posix_assert()` as `assert()` replacement
Francis Deslauriers [Wed, 1 Sep 2021 17:34:17 +0000 (13:34 -0400)] 
Add `urcu_posix_assert()` as `assert()` replacement

This macro acts like the regular `assert()` macro unless NDEBUG is
defined in which case it consumes the expression and becomes a no-op.

This consumption trick (see `_urcu_use_expression()` macro) prevents the
compiler from warning about unused variables even when assert() are
removed by the NDEBUG define.

This macro is also used for the existing `urcu_assert_debug()` macro.

The implementation of `_urcu_use_expression()` is inspired by the
Babeltrace 2 approach.

See `BT_USE_EXPR()` macro and documentation in Babeltrace commit [1]:
  commit 1778c2a4134647150b199b2b57130817144446b0
  Author: Philippe Proulx <eeppeliteloop@gmail.com>
  Date:   Tue Apr 21 11:15:42 2020 -0400
  lib: assign a unique ID to each pre/postcond. and report it on failure

All assertion macros are moved to the new urcu/assert.h file.

Link: https://github.com/efficios/babeltrace/commit/1778c2a4134647150b199b2b57130817144446b0
Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If60ce2d3f45ea8f5ec1dbb92fb43f83fd9f8102b

3 months agoRename `urcu_assert()` to `urcu_assert_debug()`
Francis Deslauriers [Wed, 1 Sep 2021 15:45:01 +0000 (11:45 -0400)] 
Rename `urcu_assert()` to `urcu_assert_debug()`

This is done in preparation for the addition of the `urcu_posix_assert()`
macro that will replace the vanilla `assert()` in the project.

We must continue to expose the `urcu_assert()` macro in the `urcu/debug.h`
file as it's used by at least one external project (LTTng-UST).

Signed-off-by: Francis Deslauriers <francis.deslauriers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I02f237450a35b57e37718c87a0596a5a14468f58

3 months agocleanup: spelling fixes in comments
Michael Jeanson [Thu, 29 Jul 2021 19:49:55 +0000 (15:49 -0400)] 
cleanup: spelling fixes in comments

Change-Id: I22ae33365d77abeb5f7051882e9d0fa807e38f6f
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
3 months agoMake temporary variable in _rcu_dereference non-const
Simon Marchi [Fri, 30 Jul 2021 03:06:11 +0000 (23:06 -0400)] 
Make temporary variable in _rcu_dereference non-const

When building the lttng-tools project with Ubuntu's gcc 11, I get the
following error:

      CC       agent.lo
    In file included from /tmp/lttng/include/urcu/arch.h:25,
                     from /tmp/lttng/include/urcu/uatomic.h:23,
                     from /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c:11:
    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c: In function ‘agent_update’:
    /tmp/lttng/include/urcu/static/pointer.h:96:33: error: argument 2 of ‘__atomic_load’ discards ‘const’ qualifier [-Werror=incompatible-pointer-types]
       96 |                                 __atomic_load(&(p), &_________p1, __ATOMIC_CONSUME);    \
          |                                 ^~~~~~~~~~~~~
    /tmp/lttng/include/urcu/compiler.h:69:70: note: in definition of macro ‘caa_container_of’
       69 |                 const __typeof__(((type *) NULL)->member) * __ptr = (ptr); \
          |                                                                      ^~~
    /tmp/lttng/include/urcu/rculist.h:87:20: note: in expansion of macro ‘cds_list_entry’
       87 |         for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*(pos)), member); \
          |                    ^~~~~~~~~~~~~~
    /tmp/lttng/include/urcu/pointer.h:47:33: note: in expansion of macro ‘_rcu_dereference’
       47 | #define rcu_dereference         _rcu_dereference
          |                                 ^~~~~~~~~~~~~~~~
    /tmp/lttng/include/urcu/rculist.h:87:35: note: in expansion of macro ‘rcu_dereference’
       87 |         for (pos = cds_list_entry(rcu_dereference((head)->next), __typeof__(*(pos)), member); \
          |                                   ^~~~~~~~~~~~~~~
    /home/simark/src/lttng-tools/src/bin/lttng-sessiond/agent.c:1551:9: note: in expansion of macro ‘cds_list_for_each_entry_rcu’
     1551 |         cds_list_for_each_entry_rcu(ctx, &agt->app_ctx_list, list_node) {
          |         ^~~~~~~~~~~~~~~~~~~~~~~~~~~

This is because the pointer passed to _rcu_dereference is const (the
pointer itself is const, IIUC, not necessarily the data it points to),
so the temporary _________p1 is also declared as const.  We therefore
can't pass a non-const pointer to it to a function that modifies it.

I applied the trick found here [1] with success to get rid of the
constness of the variable.  With this change, lttng-tools compiles
successfully with gcc 11.

There may be other spots in the headers where this would be needed, but
it is hard to spot them.  I think we would need to write some test file
that pass const pointers to all macros of the API and see if they

[1] https://stackoverflow.com/a/18067745

Signed-off-by: Simon Marchi <simon.marchi@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib43efa7674ecea99cec1c3fffae86829b44a97e5

5 months agoFix: x86 and s390: uatomic __hp() macro C++ support
Mathieu Desnoyers [Wed, 16 Jun 2021 14:03:48 +0000 (10:03 -0400)] 
Fix: x86 and s390: uatomic __hp() macro C++ support

C++ does not allow defining types in cast. Therefore, define the types
with typedef and use them in the __hp() macro.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I92af62924f78dc6c5f7420a6376731212fbc5a20

5 months agoFix: x86 and s390: uatomic __hp() macro clang support
Mathieu Desnoyers [Tue, 15 Jun 2021 20:00:28 +0000 (16:00 -0400)] 
Fix: x86 and s390: uatomic __hp() macro clang support

The __hp macro should receive contant size arguments to support clang,
which does not implement VLA support.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ifa3d5b5b7921f54849e0f331bef8f07c059b998f

5 months agoFix: x86 and s390 uatomic: __hp() macro warning with gcc 11
Mathieu Desnoyers [Tue, 15 Jun 2021 19:28:24 +0000 (15:28 -0400)] 
Fix: x86 and s390 uatomic: __hp() macro warning with gcc 11

The __hp() macro used in the x86 and s390 uatomic code generates the
following warning with gcc-11:

In file included from ../include/urcu/uatomic.h:27,
                 from ../include/urcu/static/wfcqueue.h:35,
                 from ../include/urcu/wfcqueue.h:133,
                 from workqueue.c:39:
workqueue.c: In function ‘workqueue_thread’:
../include/urcu/uatomic/x86.h:155:17: warning: array subscript ‘struct __uatomic_dummy[0]’ is partly outside array bounds of ‘struct cds_wfcq_tail[1]’ [-Warray-bounds]
  155 |                 __asm__ __volatile__(
      |                 ^~~~~~~
workqueue.c:184:38: note: while referencing ‘cbs_tmp_tail’
  184 |                 struct cds_wfcq_tail cbs_tmp_tail;
      |                                      ^~~~~~~~~~~~

The (previously undocumented) reason for this macro is to allow passing the
"void *" parameter as "m" or "+m" operand to the inline assembly. That
motivation was explained in commit 53b8ed6836363 ("s390 uatomic arch fix").

The out of bound access is detected by gcc because struct
__uatomic_dummy's length is quite large: an array of 10 unsigned long,
which is larger than the size pointed to by the void pointer.

So rather than using a fixed-size type, cast to a structure containing
an array of characters of a size matching the @addr input argument.

While we are at it and digging out git archeology, properly document the
__hp() macro for posterity.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I785e30661efe48be1806664a1a14fd3c9fdb0a32

6 months agoVersion 0.13.0 v0.13.0
Mathieu Desnoyers [Thu, 3 Jun 2021 20:49:02 +0000 (16:49 -0400)] 
Version 0.13.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: If88881cebb1d64b2669da0edc59e483dedc9d6b7

6 months agoDocument known ABI issue in README.md
Mathieu Desnoyers [Thu, 3 Jun 2021 18:30:40 +0000 (14:30 -0400)] 
Document known ABI issue in README.md

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ic4bc9273eb63e051eb1da122bee4f99a8eefafd3

6 months agoAdd serialized ABI definition files
Michael Jeanson [Wed, 2 Jun 2021 14:55:22 +0000 (10:55 -0400)] 
Add serialized ABI definition files

This commit contains the serialized ABI definitions for a typical build
of the liburcu librairies. This information is extracted using
libabigail (https://sourceware.org/libabigail/).

The artefacts used to generate these were built with CFLAGS="-O0 -ggdb".

You can compare the serialized ABI with a shared object to check for
breaking changes. For example, here we compare an in-tree built version
of liburcu-memb.so with the serialized ABI of stable-0.13 :

  abidiff \
    extras/abi/0.13/x86_64-pc-linux-gnu/liburcu-memb.so.7.xml \

Change-Id: Icb3145cdf9f69490981ce201ec437cc83298f0a7
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 months agobump SONAME major to 8
Michael Jeanson [Tue, 1 Jun 2021 21:01:49 +0000 (17:01 -0400)] 
bump SONAME major to 8

In URCU 0.11, we introduced new symbols to clean up the library symbol
namespacing, using the "alias" attribute to keep emitting the old
symbols, expecting to preserve ABI backward compatibility.
Unfortunately, it turns out that even though it works well for function
symbols, it is broken for public global variables due to the way ELF
copy relocation works.

When building a non-PIC executable that uses an extern variable, a .bss
symbol is emitted in the executable. This will take precedence over the
symbol implemented within the library in the Global Symbol Table.
Unfortunately, the alias within the library will not be aware that the
actual GST symbol differs from its alias within the library, and the
addresses for the symbol and its alias will differ at runtime.

Considering that this compatibility issue affects official library
releases, there is little we can do beyond documenting this issue, and
bumping the Userspace RCU major soname for the next (0.13) release.

Change-Id: I0ca8407dcffd871f025814923c6e329ec260133a
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 months agoRemove all SONAME(6) ABI aliases
Michael Jeanson [Tue, 1 Jun 2021 20:32:24 +0000 (16:32 -0400)] 
Remove all SONAME(6) ABI aliases

Those aliases become unneeded with the upcoming soname bump.

Change-Id: Id6c368526d9cb04fc92c12b3f4632b4a9443f41d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 months ago.gitignore: list ignored Makefiles
Michael Jeanson [Wed, 2 Jun 2021 15:01:03 +0000 (11:01 -0400)] 
.gitignore: list ignored Makefiles

We carry some Makefiles in the examples, remove the catchall Makefile
from gitignore and replace it by the list of automake generated

Change-Id: I06bc46d9035cade7ebecf1a51c3d1983c2734097
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 months agotests: Add a simple compile test for caa_get_cycles
Michael Jeanson [Fri, 7 May 2021 16:05:38 +0000 (12:05 -0400)] 
tests: Add a simple compile test for caa_get_cycles

Change-Id: Id2dbaf5f250a5e6e135700dabed5832e75ca7ce9
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
6 months agofix: clock_gettime on macOs
Michael Jeanson [Fri, 7 May 2021 15:34:33 +0000 (11:34 -0400)] 
fix: clock_gettime on macOs

Newer version of macOs have an implementation of clock_gettime() that
requires additionnal setup, move the platform specific code first so it
is always used.

Change-Id: I12fcdeff6c0ae59bc1a13f4e2cd7f4ebcedfc253
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agoFix: rculist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:24:26 +0000 (16:24 -0400)] 
Fix: rculist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix rculist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idcc85eef31bb8c11766e834554bfab8b6ed35864

7 months agoFix: rcuhlist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:21:53 +0000 (16:21 -0400)] 
Fix: rcuhlist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix rcuhlist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I2f7988e96ce495d68960c5f1036aa6953d3ff53b

7 months agoFix: hlist header: use parenthesis around macro parameters
Mathieu Desnoyers [Tue, 20 Apr 2021 20:20:44 +0000 (16:20 -0400)] 
Fix: hlist header: use parenthesis around macro parameters

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix hlist.h to follow this coding style.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I28425b620b7937f6b3a57d48d70ce097d0093e23

7 months agoFix: list.h: use parenthesis around macro parameters, caa_container_of()
Mathieu Desnoyers [Tue, 20 Apr 2021 20:15:39 +0000 (16:15 -0400)] 
Fix: list.h: use parenthesis around macro parameters, caa_container_of()

The coding style followed across liburcu is to use parenthesis around
macro parameters when it would otherwise lead to unexpected results due
to priority of operators. Fix list.h to follow this coding style.

Use caa_container_of() for cds_list_entry rather than open-code the
pointer arithmetic.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I17052dc0418ad205cf262a6e5b91e591c37462cb

7 months agoFix: hlist iteration relies on undefined behavior
Mathieu Desnoyers [Tue, 20 Apr 2021 20:07:54 +0000 (16:07 -0400)] 
Fix: hlist iteration relies on undefined behavior

Comparing an offset from an object with NULL is undefined behavior
and the compiler may assume that this is never true.

This is indeed what is observed with gcc-10 miscompiling

Fix this by introducing cds_hlist_entry_safe() rather than open-coding
the NULL check comparisons, and move cds_hlist_for_each_entry_2()
and cds_hlist_for_each_entry_safe_2() to this scheme as well.

Fixes: #1308
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ief3531cf04e54b6dae05eb28a6822adfa141fdeb

7 months agoFix: use __atomic_load() rather than atomic load explicit
Mathieu Desnoyers [Mon, 19 Apr 2021 15:21:52 +0000 (11:21 -0400)] 
Fix: use __atomic_load() rather than atomic load explicit

Use __atomic_load (gcc extension) rather than atomic load explict
(C11/C++11) for rcu_dereference because it does not require the input
type to be _Atomic. This fixes a regression with clang introduced by
commit 380f4b19052 ("Fix: use atomic load memory_order_consume for
rcu_dereference on C11/C++11").

Note that the cmm_smp_read_barrier_depends is removed when using
__ATOMIC_CONSUME because their memory ordering effect is redundant.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Icd5f6040e0bd2167844a8d856ae5475ceef17123

7 months agoFix: use atomic load memory_order_consume for rcu_dereference on C11/C++11
Mathieu Desnoyers [Fri, 16 Apr 2021 20:22:54 +0000 (16:22 -0400)] 
Fix: use atomic load memory_order_consume for rcu_dereference on C11/C++11

Using volatile accesses for rcu_dereference may cause compiler LTO to
generate incorrectly ordered code starting from C11/C++11.

Link: https://lists.lttng.org/pipermail/lttng-dev/2021-April/029937.html
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agofix: we used weak symbols not weak aliases
Michael Jeanson [Wed, 14 Apr 2021 15:19:00 +0000 (11:19 -0400)] 
fix: we used weak symbols not weak aliases

Remove the configure test for weak aliases since we don't use them and
they are not supported on macOs.

Change-Id: If245dfe02c9ec990e16e1a90983ba9d8f1eb9f4b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agofix: include 'sys/endian.h' on FreeBSD
Michael Jeanson [Wed, 14 Apr 2021 15:01:57 +0000 (11:01 -0400)] 
fix: include 'sys/endian.h' on FreeBSD

We need to include 'sys/endian.h' on FreeBSD to use BYTE_ORDER.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I9f6e9d522e3857304fb9556098a775d1f0d35ef9

7 months agofix: warnings on non-Linux platforms
Michael Jeanson [Wed, 14 Apr 2021 14:14:37 +0000 (10:14 -0400)] 
fix: warnings on non-Linux platforms

Add the relevent attributes in non-Linux wrapper code.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I0c50dc57f71804aa544350178793bdf280a667df

7 months agofix: HAVE_SCHED_SETAFFINITY is not defined
Michael Jeanson [Tue, 13 Apr 2021 20:19:06 +0000 (16:19 -0400)] 
fix: HAVE_SCHED_SETAFFINITY is not defined

Use '#ifdef' instead of '#if' to test if HAVE_SCHED_SETAFFINITY is
defined. Both work but using '#if' on an undefined macro will generate a
warning with '-Wundef'.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ieb46ddab9ba033a5c552dbe78ac398cea0a641e8

7 months agoconfigure: enable extended compiler warnings
Michael Jeanson [Thu, 1 Apr 2021 15:41:52 +0000 (11:41 -0400)] 
configure: enable extended compiler warnings

Import the compiler warning flag detection system from Babeltrace and
enable extended compiler warnings.

Change-Id: Ia3ef4d37640fb3384dc76778ed88d0519f9b7e25
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agocleanup: explicitly mark unused parameters (-Wunused-parameter)
Michael Jeanson [Thu, 1 Apr 2021 18:39:01 +0000 (14:39 -0400)] 
cleanup: explicitly mark unused parameters (-Wunused-parameter)

Add the 'unused' attribute to function parameters that are unused to
allow turning on -Wunused-parameter and distinguish unused parameters
that are actual errors.

Change-Id: Ie585e37f9d38718543a31aee2e7ab3428cdfd0a5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agofix: shadowed local variable (-Wshadow)
Michael Jeanson [Thu, 1 Apr 2021 17:46:18 +0000 (13:46 -0400)] 
fix: shadowed local variable (-Wshadow)

Rename local variables that are shadowed by global variables.

Change-Id: Ic60e880cb6e98d6111e6b747d9668731a156e4fa
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agocleanup: all functions have declarations (-Wmissing-prototypes)
Michael Jeanson [Thu, 1 Apr 2021 17:13:48 +0000 (13:13 -0400)] 
cleanup: all functions have declarations (-Wmissing-prototypes)

Make sure that all non-static functions have a declaration.

Change-Id: Ie1596ad4ba876183862e51508c8bd7fc0451fc5e
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
7 months agoImport libtap from babeltrace
Michael Jeanson [Thu, 1 Apr 2021 15:48:43 +0000 (11:48 -0400)] 
Import libtap from babeltrace

Import the fixes to our local copy of libtap from the babeltrace
repository. This will allow enabling stricter compiler warnings down the

Change-Id: I557ad39345dfaf6a08219109a5790d1bf12abb78
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agocleanup: add 'noreturn' attribute to '_uatomic_link_error'
Michael Jeanson [Wed, 31 Mar 2021 19:15:12 +0000 (15:15 -0400)] 
cleanup: add 'noreturn' attribute to '_uatomic_link_error'

Tell the compiler that this function never returns, may help with

Change-Id: I07e4bdc5c83436e497db02394eccfbf44063f090
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agofix: add missing 'S' to AC_CHECK_PROGS
Michael Jeanson [Fri, 19 Mar 2021 19:54:03 +0000 (15:54 -0400)] 
fix: add missing 'S' to AC_CHECK_PROGS

AC_CHECK_PROG has a different behavior to AC_CHECK_PROGS and won't set
the proper variable without further arguments.

Change-Id: Ia20c16772a42bc21d7d518095a13f4ad574cb65d
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoREADME.md: Document supported Glibc version
Michael Jeanson [Fri, 19 Mar 2021 18:45:14 +0000 (14:45 -0400)] 
README.md: Document supported Glibc version

Change-Id: I3be87d2db6be1f2a35bb2df7208b8a2d197b3d49
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoREADME: cleanup stale MacOS information
Michael Jeanson [Fri, 19 Mar 2021 00:18:17 +0000 (20:18 -0400)] 
README: cleanup stale MacOS information

Change-Id: Ife4a3b79e26731242ee89e1d25638d3907e20434
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoBump version to 0.13.0-pre
Michael Jeanson [Fri, 19 Mar 2021 14:26:01 +0000 (10:26 -0400)] 
Bump version to 0.13.0-pre

Change-Id: Ic09dcbd766b3b915615b1bb10812e8fd86c4cf0b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: standardise include path
Michael Jeanson [Fri, 19 Mar 2021 14:17:15 +0000 (10:17 -0400)] 
configure: standardise include path

Use the same include setup as our other projects, set the default
includes globally in configure.ac in AM_CPPFLAGS.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: Ia40344e22920bafca9ed34ea2867acf38a1807e3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoRemove glibc < 2.4 compat code for sched_setaffinity
Michael Jeanson [Fri, 19 Mar 2021 01:05:09 +0000 (21:05 -0400)] 
Remove glibc < 2.4 compat code for sched_setaffinity

Remove the rather large configure compat code for the version of
sched_setaffinity as present in glibc < 2.4.

Glibc 2.4 was released in 2006, we can safely assume nobody is still
building new systems based on an even older version.

Keep the normal sched_setaffinity detection and wrappers.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I62b1488849f88f56424f4d4ce570519d37c746c5
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: regroup automake conditionals
Michael Jeanson [Fri, 19 Mar 2021 00:58:47 +0000 (20:58 -0400)] 
configure: regroup automake conditionals

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I5be5e254670e2ca6c26564ab391ea1dbfea105cd
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoIntroduce AE_FEATURE to manage configure features
Michael Jeanson [Thu, 18 Mar 2021 23:53:28 +0000 (19:53 -0400)] 
Introduce AE_FEATURE to manage configure features

The new AE_FEATURE set of macros are wrappers over autoconf's
AC_ARG_ENABLE. The main objective is to make the m4sh code more readable
to the less seasoned autotools enthusiast among us and reduce the
duplication of code with its associated bugs.

The AE prefix was chosen to mean "Autotools EfficiOS" and is part of an
effort to standardize our custom macros across all our autotools based

Change-Id: Ief565473b38150fe2104492c6339bac73efba895
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: regroup library checks
Michael Jeanson [Thu, 18 Mar 2021 23:00:14 +0000 (19:00 -0400)] 
configure: regroup library checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: Iea3c5f5348426b7cbefabb60a7c9b33e179e6650
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: regroup and expand C header and program checks
Michael Jeanson [Thu, 18 Mar 2021 22:40:47 +0000 (18:40 -0400)] 
configure: regroup and expand C header and program checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I74b5664782fa67df8a2350d90d6f03a16f930fef
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: regroup and expand C compiler checks
Michael Jeanson [Thu, 18 Mar 2021 22:19:39 +0000 (18:19 -0400)] 
configure: regroup and expand C compiler checks

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I7d6f93c738334c6c0d9851924296a537cb076360
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: host specific config
Michael Jeanson [Thu, 18 Mar 2021 22:08:26 +0000 (18:08 -0400)] 
configure: host specific config

Align host specific configuration style with our other autotools

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I413b4425f9027dfcce74b40292e13df604b602a3
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agotests: Move tap-driver.sh out of the autotools aux directory
Michael Jeanson [Thu, 18 Mar 2021 21:50:48 +0000 (17:50 -0400)] 
tests: Move tap-driver.sh out of the autotools aux directory

We have made local modifications to this script, move it to the test
suite directory so it doesn't get overwritten by an updated version from

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I4bc0bdbff05d03d8e4c0f9dcda51cf6a6cf7fec4
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: Set autotools baseline
Michael Jeanson [Thu, 18 Mar 2021 21:47:39 +0000 (17:47 -0400)] 
configure: Set autotools baseline

Set autotools baseline to Autoconf >= 2.69 and Automake >= 1.12 and
enable error reporting.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I1f3487d7e610b3f6f9d710ef2d1d4b7a39d7dabb
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
8 months agoconfigure: centralize version information
Michael Jeanson [Thu, 18 Mar 2021 21:41:51 +0000 (17:41 -0400)] 
configure: centralize version information

Centralise version information at the beginning of configure.ac to
improve readability.

This is part of an effort to standardise our autotools setup across
project to simplify maintenance.

Change-Id: I394c706f71885dbc6ad22f6d315d48702825fd81
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 months agofix: exclude clang from GCC version blacklists
Michael Jeanson [Mon, 25 Jan 2021 18:36:24 +0000 (13:36 -0500)] 
fix: exclude clang from GCC version blacklists

URCU_GCC_VERSION is used to blacklist specific GCC versions with known
bugs, clang also defines these macros to an equivalent GCC version it
claims to support, so exclude it.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Idf0980fddca6533313a3367601ddda8d8e13bfdf

10 months agoaarch64: blacklist gcc prior to 5.1
Mathieu Desnoyers [Fri, 22 Jan 2021 20:27:35 +0000 (15:27 -0500)] 
aarch64: blacklist gcc prior to 5.1

Linux aarch64 requires GCC 5.1 or better because prior versions perform
unsafe access to deallocated stack.

Some Linux distributions may have backported the fix, but it was never
released into earlier upstream gcc versions.

Link: https://lwn.net/Articles/842122/
Link: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=63293
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
10 months agoFix: configure: support Autoconf 2.70
Jérémie Galarneau [Mon, 11 Jan 2021 21:49:22 +0000 (16:49 -0500)] 
Fix: configure: support Autoconf 2.70

The newly-released autoconf 2.70 introduces a number of breaking
changes [1] and is being rolled-out by some distros.

Amongst those changes, the AC_PROG_CC_STDC macro is marked as obsolete
and was merged into AC_PROG_CC, which we already use. On 2.70, this
results in a warning which we handle as an error.

A version check is added to invoke the AC_PROG_CC_STDC macro only when
running a pre-2.70 version of autoconf, fixing the issue.

Also, the AX_PTHREAD macro makes use of the $as_echo built-in shell
variable which no longer exists in 2.70. A patch was submitted to the
GNU Autoconf archive in March, but there have been no signs of life
given since then [2].

As such, our local copy is updated to the latest version and the patch
(which looks fairly straight-forward / safe) is applied. This should
minimize changes once we go back to an "official" version of the macro.

[1] https://lwn.net/Articles/839395/
[2] https://savannah.gnu.org/patch/?9906

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Id57ad87e63c2d398e3d8b81129f9b867b878e01f

11 months agoDon't force a target and optimization level on ARMv7
Michael Jeanson [Fri, 11 Dec 2020 18:52:10 +0000 (13:52 -0500)] 
Don't force a target and optimization level on ARMv7

We shouldn't force a specific target cpu for the compiler on ARMv7 but
let the system or the user choose it. If some of our code depends on a
specific target CPU features, it should be compile tested.

Also remove the default optimisation level of O1, it's potentially a
workaround to an early armv7 compiler performance problem and anyway
most builds will have an optimisation level flag set in the CFLAGS which
will override this one.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Acked-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I1d1bb5cc0fa0be8f8b1d6a9ad7bf063809be1aef

11 months agoUse DMB only on ARMv7
Michael Jeanson [Thu, 10 Dec 2020 21:52:30 +0000 (16:52 -0500)] 
Use DMB only on ARMv7

Remove the configure time CONFIG_RCU_ARM_HAVE_DMB option and replace it
by compile time detection based on the ARM ISA version. This makes sure
we unconditionnaly use the DMB instruction only on ARMv7 where it's part
of the baseline ISA.

This will change the behavior on ARMv6 platform that possibly have this
instruction but it was probably already broken since we use the 'ISH'
option which doesn't seem to be valid on this ISA.

This will also allow sharing headers in a multi-arch environment and
reduce the build system complexity.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Cc: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I8e56ada55148d8e0f198c3d2e741ea414de5fef2

11 months agoBlacklist GCC 4.4.0, 4.4.1 and 4.4.2 on ARM
Michael Jeanson [Fri, 11 Dec 2020 22:22:23 +0000 (17:22 -0500)] 
Blacklist GCC 4.4.0, 4.4.1 and 4.4.2 on ARM

GCC added __sync_synchronize() in 4.4.0 but it was broken on ARM until
4.4.3, see the GCC bug report for more details :


Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I629e3c8b4baaccb34b2311e220f30d0ad8b69a19

11 months agoCleanup: Move ARM specific code to urcu/arch/arm.h
Michael Jeanson [Fri, 11 Dec 2020 21:59:56 +0000 (16:59 -0500)] 
Cleanup: Move ARM specific code to urcu/arch/arm.h

Change-Id: I3e17308c5ae985789a2ac8361e9c9e958ff7d656
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
11 months agofix: bump tests thread limit to 4096
Michael Jeanson [Wed, 9 Dec 2020 17:05:31 +0000 (12:05 -0500)] 
fix: bump tests thread limit to 4096

Machines with more than 128 CPUs are becomming more common. A
future-proof fix here would be to dynamically allocate the array, but in
the meantime bump the limit to 4096 to fix the problem on a 160 CPUs
ppc64el system where this was reported.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Cc: Paul E. McKenney <paulmck@kernel.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: Ib3cb5d8cb4515e6f626be33c2685fa38cb081782

12 months agofix: reorder x86 arch detection
Michael Jeanson [Wed, 2 Dec 2020 17:31:46 +0000 (17:31 +0000)] 
fix: reorder x86 arch detection

Reorder the detection code from most specific to most generic as defines
for i386 can be present even when building for i686.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I81531b05318a0eaa9984075311828d87be7d46fc

12 months agofix: typo in futex syscall define check
Michael Jeanson [Mon, 30 Nov 2020 16:39:38 +0000 (11:39 -0500)] 
fix: typo in futex syscall define check

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Change-Id: I59a654e381f3ad236a6d25c67316d04c84ddcded

12 months agoCompile time futex syscall detection
Michael Jeanson [Tue, 17 Nov 2020 23:28:20 +0000 (18:28 -0500)] 
Compile time futex syscall detection

The futex syscall availability is detected at configure time using a
simple compile test. Replace this with compile time detection using the
same test. This would allow sharing headers in a multi-arch environment
and reduce the build system complexity.

Change-Id: Ief709429e8908d0fd2d268d42f4a89d9fc14b91b
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 months agoStatic arch and uatomic headers
Michael Jeanson [Tue, 17 Nov 2020 23:08:49 +0000 (18:08 -0500)] 
Static arch and uatomic headers

Replace the somewhat hackish symlinking of architecture specific headers
at configure time with compile time detection using compiler defines.
This would allow sharing headers in a multi-arch environment and reduce
the build system complexity.

Change-Id: I4900a18dab70bb0e51d1a8500581a445acd44cdf
Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 months agoAdd git-review config
Michael Jeanson [Thu, 19 Nov 2020 16:43:54 +0000 (11:43 -0500)] 
Add git-review config

Add .gitreview for contributors wishing to use gerrit for patch

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Change-Id: I7868b3fc3162246298f24bd90ac1a3bcf6083eb6
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 months agocleanup: Improve wording of CONFIG_RCU_DEBUG description
Michael Jeanson [Tue, 17 Nov 2020 20:22:46 +0000 (15:22 -0500)] 
cleanup: Improve wording of CONFIG_RCU_DEBUG description

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 months agofix: explicitly include urcu/config.h in files using CONFIG_RCU_ defines
Michael Jeanson [Tue, 17 Nov 2020 20:22:24 +0000 (15:22 -0500)] 
fix: explicitly include urcu/config.h in files using CONFIG_RCU_ defines

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
12 months agoFix typo in README.md
Shuo Wang [Mon, 16 Nov 2020 12:24:46 +0000 (20:24 +0800)] 
Fix typo in README.md

Signed-off-by: Shuo Wang <wangshuo47@huawei.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 months agofix: add -lurcu-common to pkg-config libs for each flavor
Michael Jeanson [Fri, 30 Oct 2020 19:39:56 +0000 (15:39 -0400)] 
fix: add -lurcu-common to pkg-config libs for each flavor

The urcu-common library contains common code like the write-free queue
and compat code, each urcu flavor library is dynamicly linked with it.

Most but not all toolchains will automatically link an executable with a
transitive depency of an explicitly linked library if said binary uses a
symbol from the transitive dependency.

Since this behavior is not present in all toolchains, add
'-lurcu-common' to the 'Libs' field of each flavors pkg-config file so
that executables using symbols from urcu-common can be reliably linked
using pkg-config.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
13 months agocall_rcu: Fix race between rcu_barrier() and call_rcu_data_free()
Paul E. McKenney [Thu, 22 Oct 2020 22:30:21 +0000 (15:30 -0700)] 
call_rcu: Fix race between rcu_barrier() and call_rcu_data_free()

The current code can lose RCU callbacks at shutdown time, which can
result in hangs.  This lossage can happen as follows:

o       A thread invokes call_rcu_data_free(), which executes up through
        the wake_call_rcu_thread().  At this point, the call_rcu_data
        structure has been drained of callbacks, but is still on the
        call_rcu_data_list.  Note that this thread does not hold the

o       Another thread invokes rcu_barrier(), which traverses the
        call_rcu_data_list under the protection of call_rcu_mutex,
        a list which still includes the above newly drained structure.
        This thread therefore adds a callback to the newly drained
        call_rcu_data structure.  It then releases call_rcu_mutex and
        enters a mystifying loop that does futex stuff.

o       The first thread finishes executing call_rcu_data_free(),
        which acquires call_rcu_mutex just long enough to remove the
        newly drained call_rcu_data structure from call_rcu_data_list.
        Which causes one of the rcu_barrier() invocation's callbacks to
        be leaked.

o       The second thread's rcu_barrier() invocation never returns
        resulting in a hang.

This commit therefore changes call_rcu_data_free() to acquire
call_rcu_mutex before checking the call_rcu_data structure for callbacks.
In the case where there are no callbacks, call_rcu_mutex is held across
both the check and the removal from call_rcu_data_list, thus preventing
rcu_barrier() from adding a callback in the meantime.  In the case where
there are callbacks, call_rcu_mutex must be momentarily dropped across
the call to get_default_call_rcu_data(), which can itself acquire
call_rcu_mutex.  This momentary drop is not a problem because any
callbacks that rcu_barrier() might queue during that period of time will
be moved to the default call_rcu_data structure, and the lock will be
held across the full time including moving those callbacks and removing
the call_rcu_data structure that was passed into call_rcu_data_free()
from call_rcu_data_list.

With this fix, a several-hundred-CPU test successfully completes more
than 5,000 executions.  Without this fix, it fails within a few tens
of executions.  Although the failures happen more quickly on larger
systems, in theory this could happen on a single-CPU system, courtesy
of preemption.

Signed-off-by: Paul E. McKenney <paulmck@kernel.org>
Cc: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Stephen Hemminger <stephen@networkplumber.org>
Cc: Alan Stern <stern@rowland.harvard.edu>
Cc: Lai Jiangshan <jiangshanlai@gmail.com>
Cc: <lttng-dev@lists.lttng.org>
Cc: <linux-kernel@vger.kernel.org>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
19 months agoCleanup: tls-compat.h: add parentheses around expression (coding style)
Mathieu Desnoyers [Tue, 21 Apr 2020 13:59:00 +0000 (09:59 -0400)] 
Cleanup: tls-compat.h: add parentheses around expression (coding style)

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
19 months agoFix: tls-compat.h exposes compiler-dependent public configuration
Mathieu Desnoyers [Mon, 20 Apr 2020 15:30:49 +0000 (11:30 -0400)] 
Fix: tls-compat.h exposes compiler-dependent public configuration

Exposing the storage class chosen by ax_tls.m4 in a public header is
a bad idea, because if a recent gcc is used when configuring
liburcu, thus detecting C11, it will choose _Thread_local. Then, if an
external project uses urcu/tls-compat.h with an older gcc (e.g. 4.8),
it will fail to build, because that storage class is unknown, and
__thread should be used instead.

Therefore, use a preprocessor conditional on __cplusplus to detect C++11
(and use thread_local). Else, the STDC version is used to select
_Thread_local. Else check if _MSC_VER is defined to select
__declspec(thread), or else rely on __thread as fallback.

Remove ax_tls.m4 because it is now unused.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
19 months agoFix: tap array subscript has type char warning
Mathieu Desnoyers [Fri, 10 Apr 2020 12:30:54 +0000 (08:30 -0400)] 
Fix: tap array subscript has type char warning

On architectures where "char" is signed, it should be cast to unsigned
char before being passed as parameter to isdigit or isspace. Based on
their man page:

       These  functions  check  whether  c,  which  must  have the value of an
       unsigned char or EOF, falls into a certain character class according to
       the  specified  locale.

Passing a signed char as parameter is invalid if the values fall into
the negative range of the signed char.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
19 months agoVersion 0.12.0 v0.12.0
Mathieu Desnoyers [Thu, 9 Apr 2020 18:44:10 +0000 (14:44 -0400)] 
Version 0.12.0

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
19 months agotls-compat.h: introduce DEFINE_URCU_TLS_INIT
Mathieu Desnoyers [Thu, 9 Apr 2020 15:26:31 +0000 (11:26 -0400)] 
tls-compat.h: introduce DEFINE_URCU_TLS_INIT

DEFINE_URCU_TLS() cannot be used in this way for !CONFIG_RCU_TLS:

  DEFINE_URCU_TLS(ino_t, cached_net_ns) = NS_INO_UNINITIALIZED;

Introduce a new DEFINE_URCU_TLS_INIT which allows expressing a nonzero
intial value:


Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
22 months agoUse _umtx_op for futex on FreeBSD
Alex Xu [Tue, 28 Jan 2020 01:17:22 +0000 (20:17 -0500)] 
Use _umtx_op for futex on FreeBSD

Tested with "make check", "make regtest" and a knotd slave.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
22 months agoAdd FreeBSD, DragonFly to syscall-compat.h
Alex Xu [Mon, 27 Jan 2020 20:08:29 +0000 (15:08 -0500)] 
Add FreeBSD, DragonFly to syscall-compat.h

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agourcu-bp: perform thread registration on urcu_bp_register_thread
Mathieu Desnoyers [Fri, 22 Nov 2019 16:02:36 +0000 (11:02 -0500)] 
urcu-bp: perform thread registration on urcu_bp_register_thread

Some real-time use-cases (e.g. Xenomai) require to perform urcu-bp
thread registration early in the thread life-time before it starts
performing real-time tasks.

Currently, this can be achieved by issuing a urcu_bp_read_lock() and
urcu_bp_read_unlock() pair, or by using urcu_bp_read_ongoing(), while in
the initialization phrase.

However, it seems natural to expect that calling urcu_bp_register_thread()
would have the side effect to perform the lazy thread registration
immediately rather than being a no-op.

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoRequire automake >= 1.12
Michael Jeanson [Thu, 7 Nov 2019 18:39:44 +0000 (13:39 -0500)] 
Require automake >= 1.12

The test suite LOG_DRIVER statement requires that automake >= 1.12 be used
during bootstrap.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agocds_lfht_is_node_deleted parameter can be marked const
Jérémie Galarneau [Mon, 28 Oct 2019 19:24:36 +0000 (15:24 -0400)] 
cds_lfht_is_node_deleted parameter can be marked const

Mark the cds_lfht_node pointer parameter of cds_lfht_is_node_deleted
as const. The fact that this parameter is mutable makes it harder to
use liburcu in const-correct code.

Signed-off-by: Jérémie Galarneau <jeremie.galarneau@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoFix: provide errno as argument to urcu_die()
Mathieu Desnoyers [Thu, 19 Sep 2019 14:10:31 +0000 (10:10 -0400)] 
Fix: provide errno as argument to urcu_die()

commit 1a990de3add "Fix: rculfhash worker needs to unblock to SIGRCU"
provides "ret" (-1) as argument to urcu_die(), but should rather provide

Reported by Coverity:

** CID 1405700:  Error handling issues  (NEGATIVE_RETURNS) /src/rculfhash.c: 2171 in cds_lfht_worker_init()

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoFix: rculfhash worker needs to unblock to SIGRCU
hewenliang [Tue, 17 Sep 2019 14:59:18 +0000 (10:59 -0400)] 
Fix: rculfhash worker needs to unblock to SIGRCU

In urcu-signal flavor, call_rcu_thread calls synchronize_rcu which
will send SIGRCU signal to all registed threads, and then loops to
wait need_mb to be cleared. However, the registed workqueue_thread
does not process the SIGRCU signal, and never clear the need_mb.
Based on above, call_rcu_thread and workqueue_thread will wait
forever for completion of the grace period: call_rcu_thread which holds
the rcu_registry_lock, waits for workqueue_thread to do cmm_smp_mb.
While workqueue thread never does cmm_smp_mb because of signal blocking,
and it will eventually wait to get rcu_registry_lock in do_resize_cb.

The phenomenon is as follows, which is easy to be triggered:

(gdb) t 2
[Switching to thread 2 (Thread 0xffff83c3b080 (LWP 27116))]
0  0x0000ffff845296c4 in poll () from /lib64/libc.so.6
(gdb) bt
0 0x0000ffff845296c4 in poll () from /lib64/libc.so.6
1 0x0000ffff8461b93c in force_mb_all_readers () at urcu.c:241
2 0x0000ffff8461c748 in smp_mb_master () at urcu.c:249
3 urcu_signal_synchronize_rcu () at urcu.c:445
4 0x0000ffff8461d004 in call_rcu_thread  at urcu-call-rcu-impl.h:364
5 0x0000ffff845eb8bc in start_thread () from /lib64/libpthread.so.0
6 0x0000ffff845335cc in thread_start () from /lib64/libc.so.6
(gdb) t 3
[Switching to thread 3 (Thread 0xffff8443c080 (LWP 27191))]
0 0x0000ffff845f51c4 in __lll_lock_wait () from /lib64/libpthread.so.0
(gdb) bt
0 0x0000ffff845f51c4 in __lll_lock_wait () from /lib64/libpthread.so.0
1 0x0000ffff845ee048 in pthread_mutex_lock () from /lib64/libpthread.so.0
2 0x0000ffff8461b814 in mutex_lock ( <rcu_registry_lock>) at urcu.c:157
3 0x0000ffff8461b9e4 in urcu_signal_unregister_thread () at urcu.c:564
4 0x0000ffff8463e62c in do_resize_cb (work=0x11e2e790) at rculfhash.c:2042
5 0x0000ffff8463c940 in workqueue_thread (arg=0x11e1d260) at workqueue.c:228
6 0x0000ffff845eb8bc in start_thread () from /lib64/libpthread.so.0
7 0x0000ffff845335cc in thread_start () from /lib64/libc.so.6

So we should not block SIGRCU in workqueue thread to avoid blocking
forever in the grace period awaiting on the worker thread when using
urcu-signal flavor.

Signed-off-by: hewenliang <hewenliang4@huawei.com>
Co-developed-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Cc: Paul E. McKenney <paulmck@linux.vnet.ibm.com>
2 years agoCleanup: test_perthreadlock_timing: handle pthread mutex errors
Mathieu Desnoyers [Tue, 4 Jun 2019 19:09:53 +0000 (15:09 -0400)] 
Cleanup: test_perthreadlock_timing: handle pthread mutex errors

Found by Coverity:
CID 1357055 (#1 of 1): Unchecked return value (CHECKED_RETURN)
4. check_return: Calling pthread_mutex_lock without checking return value
(as is done elsewhere 44 out of 48 times).

Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
2 years agoFix: SONAME bump to 6.1.0
Michael Jeanson [Mon, 3 Jun 2019 20:36:43 +0000 (16:36 -0400)] 
Fix: SONAME bump to 6.1.0

In commit d6c78161aed9b2d550ce201b0a8cd5b3ee515ac8 we bumped the 'age'
part of the library version with the intention of keeping the same major
SONAME because we only introduced new symbols. However by bumping the
'age' and not the 'current' we substracted 1 to the major SONAME which
we did not intend. Seems like we missed this in testing.

Fix it by bumping the 'current' to end up with an SONAME of 6.1.0 which
is what we originally intended.

From the libtool manual for reference :

  Programs using the previous version may use the new version as drop-in
  replacement, but programs using the new version may use APIs not present
  in the previous one. In other words, a program linking against the new
  version may fail with “unresolved symbols” if linking against the old
  version at runtime: set revision to 0, bump current and age.

Signed-off-by: Michael Jeanson <mjeanson@efficios.com>
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
This page took 0.074533 seconds and 4 git commands to generate.