Cleanup: Re-organise source dir Re-organise the sources, add a top level "src" and "include" dir and move relevant files. Disable autotools automated includes and define them manually. This fixes problems with collision of header names with system headers. Include the autoconf config.h in the default includes and remove it where it's explicitely included. Remove _GNU_SOURCE defines since it's detected at configure for platforms that requires it and added to the config.h. Signed-off-by: Michael Jeanson <mjeanson@efficios.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Mark braced-groups within expressions with __extension__ Braced-groups within expressions are not valid ISO C, so if a macro uses them and it's included in a project built with -pedantic, the build will fail. GCC and CLANG do support them as extension, so marking them as such allows the build to complete even with -pedantic. Signed-off-by: Luca Boccassi <lboccass@brocade.com> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix: silence gcc -Wextra warning It appears that just casting to "unsigned long" already has the semantic we are looking for (checked by reading C99 standard and experimentation): it sign-extends smaller signed integers, and does not sign-extend unsigned integers. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
compiler: use __GNUC__ instead of the undefined __GNUC_MAJOR__ gcc defines the major number with __GNUC__, not __GNUC_MAJOR__: https://gcc.gnu.org/onlinedocs/cpp/Common-Predefined-Macros.html Signed-off-by: Emilio G. Cota <cota@braap.org> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
gcc warning fixes: -Wsign-compare and -Wextra When compiling code using the rcu_xchg_pointer() family of functions, with the following define: #define URCU_INLINE_SMALL_FUNCTIONS prior to including urcu headers, when compiling with gcc with -Wsign-compare and -Wextra, gcc warns about: urcu-xchg.c: In function ‘reload’: urcu-xchg.c:19:1: warning: ordered comparison of pointer with integer zero [-Wextra] urcu-xchg.c:19:1: warning: signed and unsigned type in conditional expression [-Wsign-compare] For the "ordered comparison of pointer with integer zero" warning, fix this by comparing (type) -1 against (type) 0 instead of just 0, so if "type" is a pointer type, this pointer type will be applied to the right operand too, thus fixing the warning. For the "signed and unsigned type in conditional expression" warning, we need caa_cast_long_keep_sign() to always evaluate to the same type signedness. In order to do so, when we need to sign-extend the value, cast it to unsigned long after first casting it to long. Reported-by: Stephen Hemminger <stephen@networkplumber.org> Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
Fix uatomic sign cast Passing an unsigned int to uatomic_sub does not honor sign extend to long, as we should be allowed by assume. Fix this by introducing caa_cast_long_keep_sign(), which casts either to long or unsigned long depending on the signedness of the argument received. It is used in uatomic_sub before applying the "-" operator, since this operator needs to operate on the "long" type size (since sign extension might not be performed if the argument received is unsigned). Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
urcu-pointer: implement URCU_FORCE_CAST for C++ compatibility of urcu-pointer.h We need to be careful with those, so we do not break aliasing. Our use-case is to cast back and forth between the same type and a void * (or void **) type when we pass pointers to C functions. As we cast back to the same type when the pointer is returned from the function, aliasing should still work. Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>