Cleanup: tls-compat.h: add parentheses around expression (coding style) master
authorMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Apr 2020 13:59:00 +0000 (09:59 -0400)
committerMathieu Desnoyers <mathieu.desnoyers@efficios.com>
Tue, 21 Apr 2020 13:59:44 +0000 (09:59 -0400)
Signed-off-by: Mathieu Desnoyers <mathieu.desnoyers@efficios.com>
ChangeLog
README.md
configure.ac
include/urcu/futex.h
include/urcu/syscall-compat.h
include/urcu/tls-compat.h
include/urcu/urcu-bp.h
m4/ax_tls.m4 [deleted file]
src/urcu-bp.c
tests/utils/tap.c

index 5605205baa3c171646638a66e3d14cd057c947db..cc7a7d7de41a527fa1183f578e5d36cac737133a 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,17 @@
+2020-04-09 Userspace RCU 0.12.0
+       * tls-compat.h: introduce DEFINE_URCU_TLS_INIT
+       * Use _umtx_op for futex on FreeBSD
+       * Add FreeBSD, DragonFly to syscall-compat.h
+       * urcu-bp: perform thread registration on urcu_bp_register_thread
+       * Require automake >= 1.12
+       * cds_lfht_is_node_deleted parameter can be marked const
+       * Fix: provide errno as argument to urcu_die()
+       * Fix: rculfhash worker needs to unblock to SIGRCU
+       * Cleanup: test_perthreadlock_timing: handle pthread mutex errors
+       * Fix: SONAME bump to 6.1.0
+       * Cleanup: remove unused variable from configure.ac check
+       * Fix: urcu/futex.h: users of struct timespec should include time.h
+
 2019-05-06 Userspace RCU 0.11.0
        * Bump library version to 6:0:1
        * Cleanup: update code layout to fix old gcc warning
index 601703bdf6209af39c9e27e47a9d0c9d3e2d6b13..2d6dcaa2a4bfba1199c7dee5bcad5ec743acebf8 100644 (file)
--- a/README.md
+++ b/README.md
@@ -224,10 +224,11 @@ be overridden with `-DSIGRCU` by modifying `Makefile.build.inc`.
 
 The BP library flavor stands for "bulletproof". It is specifically
 designed to help tracing library to hook on applications without
-requiring to modify these applications. `urcu_bp_init()`,
-`urcu_bp_register_thread()` and `urcu_bp_unregister_thread()` all become
-nops. The state is dealt with by the library internally at the expense
-of read-side and write-side performance.
+requiring to modify these applications. `urcu_bp_init()`, and
+`urcu_bp_unregister_thread()` all become nops, whereas calling
+`urcu_bp_register_thread()` becomes optional. The state is dealt with by
+the library internally at the expense of read-side and write-side
+performance.
 
 
 ### Initialization
index 1d13ea38b0dee4c01052367205a1eae71dfec9a9..b62f587e8d8e42de3394beb74ad0f1819eb47bfb 100644 (file)
@@ -1,5 +1,5 @@
 AC_PREREQ(2.59)
-AC_INIT([userspace-rcu],[0.11.0],[mathieu dot desnoyers at efficios dot com], [], [http://liburcu.org/])
+AC_INIT([userspace-rcu],[0.12.0],[mathieu dot desnoyers at efficios dot com], [], [http://liburcu.org/])
 
 # Following the numbering scheme proposed by libtool for the library version
 # http://www.gnu.org/software/libtool/manual/html_node/Updating-version-info.html
@@ -12,7 +12,7 @@ AC_CONFIG_MACRO_DIR([m4])
 AC_CANONICAL_TARGET
 AC_CANONICAL_HOST
 
-AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip nostdinc])
+AM_INIT_AUTOMAKE([1.12 foreign dist-bzip2 no-dist-gzip nostdinc])
 AM_MAINTAINER_MODE([enable])
 
 # Enable silent rules if available (Introduced in AM 1.11)
@@ -50,14 +50,7 @@ AC_USE_SYSTEM_EXTENSIONS
 AC_PROG_CC
 AC_PROG_CC_STDC
 
-# If not overridden, use ax_tls.m4 to check if TLS is available.
-AS_IF([test "x$def_compiler_tls" = "xyes"],
-       [AX_TLS([def_tls_detect=$ac_cv_tls], [:])],
-       [:])
-
-AS_IF([test "x$def_tls_detect" = "x"],
-       [:],
-       [AC_DEFINE_UNQUOTED([CONFIG_RCU_TLS], $def_tls_detect)])
+AS_IF([test "x$def_compiler_tls" = "xyes"], AC_DEFINE([CONFIG_RCU_TLS], [1]), [:])
 
 # Checks for programs.
 AC_PROG_AWK
@@ -501,7 +494,7 @@ test "x$compat_futex_test" = "x0" && value=1 || value=0
 PPRINT_PROP_BOOL([Futex support], $value)
 
 # TLS
-test "x$def_tls_detect" = "x" && value="pthread_getspecific()" || value="$def_tls_detect"
+test "x$def_compiler_tls" = "xyes" && value="compiler TLS" || value="pthread_getspecific()"
 PPRINT_PROP_STRING([Thread Local Storage (TLS)], [$value])
 
 # clock_gettime() available
index c206c6fce0d373c4a6dcffbdb7df4e5b37144194..f720cdc0db52ed41cd391bec9b570464492a026e 100644 (file)
@@ -24,6 +24,7 @@
  */
 
 #include <urcu/config.h>
+#include <errno.h>
 #include <stdint.h>
 #include <time.h>
 
@@ -103,6 +104,49 @@ static inline int futex_async(int32_t *uaddr, int op, int32_t val,
        return ret;
 }
 
+#elif defined(__FreeBSD__)
+
+#include <sys/types.h>
+#include <sys/umtx.h>
+
+static inline int futex_async(int32_t *uaddr, int op, int32_t val,
+               const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
+{
+       int umtx_op;
+       void *umtx_uaddr = NULL, *umtx_uaddr2 = NULL;
+       struct _umtx_time umtx_timeout = {
+               ._flags = UMTX_ABSTIME,
+               ._clockid = CLOCK_MONOTONIC,
+       };
+
+       switch (op) {
+       case FUTEX_WAIT:
+               /* On FreeBSD, a "u_int" is a 32-bit integer. */
+               umtx_op = UMTX_OP_WAIT_UINT;
+               if (timeout != NULL) {
+                       umtx_timeout._timeout = *timeout;
+                       umtx_uaddr = (void *) sizeof(umtx_timeout);
+                       umtx_uaddr2 = (void *) &umtx_timeout;
+               }
+               break;
+       case FUTEX_WAKE:
+               umtx_op = UMTX_OP_WAKE;
+               break;
+       default:
+               errno = EINVAL;
+               return -1;
+       }
+
+       return _umtx_op(uaddr, umtx_op, (uint32_t) val, umtx_uaddr,
+                       umtx_uaddr2);
+}
+
+static inline int futex_noasync(int32_t *uaddr, int op, int32_t val,
+               const struct timespec *timeout, int32_t *uaddr2, int32_t val3)
+{
+       return futex_async(uaddr, op, val, timeout, uaddr2, val3);
+}
+
 #elif defined(__CYGWIN__)
 
 /*
index fa63a7bbee8eda960dfaf4d1709ca0595189ccc2..23b266ef561875a59e4bba9e2dfc83c7a44a3928 100644 (file)
@@ -32,8 +32,9 @@
 #elif defined(__linux__) || defined(__GLIBC__)
 #include <syscall.h>
 
-#elif defined(__CYGWIN__) || defined(__APPLE__)
-/* Don't include anything on Cygwin or MacOSX. */
+#elif defined(__CYGWIN__) || defined(__APPLE__) || \
+       defined(__FreeBSD__) || defined(__DragonFly__)
+/* Don't include anything on these platforms. */
 
 #else
 #error "Add platform support to urcu/syscall-compat.h"
index 8ac1ea0615ddc2eb91ee51e9e15b89bd094d4c81..24ef1b9a42b6dccad0f4864dc574654fffc3b60e 100644 (file)
 extern "C" {
 #endif
 
-#ifdef CONFIG_RCU_TLS  /* Based on ax_tls.m4 */
+#ifdef CONFIG_RCU_TLS
+
+#if defined (__cplusplus) && (__cplusplus >= 201103L)
+# define URCU_TLS_STORAGE_CLASS        thread_local
+#elif defined (__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
+# define URCU_TLS_STORAGE_CLASS        _Thread_local
+#elif defined (_MSC_VER)
+# define URCU_TLS_STORAGE_CLASS        __declspec(thread)
+#else
+# define URCU_TLS_STORAGE_CLASS        __thread
+#endif
 
 /*
  * Hint: How to define/declare TLS variables of compound types
@@ -65,10 +75,13 @@ extern "C" {
  */
 
 # define DECLARE_URCU_TLS(type, name)  \
-       CONFIG_RCU_TLS type name
+       URCU_TLS_STORAGE_CLASS type name
 
 # define DEFINE_URCU_TLS(type, name)   \
-       CONFIG_RCU_TLS type name
+       URCU_TLS_STORAGE_CLASS type name
+
+# define DEFINE_URCU_TLS_INIT(type, name, init)        \
+       URCU_TLS_STORAGE_CLASS type name = (init)
 
 # define URCU_TLS(name)                (name)
 
@@ -95,14 +108,14 @@ struct urcu_tls {
  * Note: we don't free memory at process exit, since it will be dealt
  * with by the OS.
  */
-# define DEFINE_URCU_TLS_1(type, name)                         \
+# define DEFINE_URCU_TLS_INIT_1(type, name, do_init)           \
        type *__tls_access_ ## name(void)                       \
        {                                                       \
                static struct urcu_tls __tls_ ## name = {       \
                        .init_mutex = PTHREAD_MUTEX_INITIALIZER,\
                        .init_done = 0,                         \
                };                                              \
-               void *__tls_p;                                  \
+               __typeof__(type) *__tls_p;                      \
                if (!__tls_ ## name.init_done) {                \
                        /* Mutex to protect concurrent init */  \
                        pthread_mutex_lock(&__tls_ ## name.init_mutex); \
@@ -118,14 +131,21 @@ struct urcu_tls {
                __tls_p = pthread_getspecific(__tls_ ## name.key); \
                if (caa_unlikely(__tls_p == NULL)) {            \
                        __tls_p = calloc(1, sizeof(type));      \
+                       do_init                                 \
                        (void) pthread_setspecific(__tls_ ## name.key,  \
                                __tls_p);                       \
                }                                               \
                return __tls_p;                                 \
        }
 
+# define _URCU_TLS_INIT(init)                                  \
+       *__tls_p = (init);
+
+# define DEFINE_URCU_TLS_INIT(type, name, init)                        \
+       DEFINE_URCU_TLS_INIT_1(type, name, _URCU_TLS_INIT(init))
+
 # define DEFINE_URCU_TLS(type, name)                           \
-       DEFINE_URCU_TLS_1(type, name)
+       DEFINE_URCU_TLS_INIT_1(type, name, /* empty */)
 
 # define URCU_TLS_1(name)      (*__tls_access_ ## name())
 
index d3d122d0f71df610a0276af0e3e5043a6adf4ee7..2ea17e6397391fae5e081118215ac717efbc0ae0 100644 (file)
@@ -151,12 +151,14 @@ extern void urcu_bp_after_fork_parent(void);
 extern void urcu_bp_after_fork_child(void);
 
 /*
- * In the bulletproof version, the following functions are no-ops.
+ * In the bulletproof version, thread registration is performed lazily,
+ * but it can be forced by issuing an explicit urcu_bp_register_thread().
  */
-static inline void urcu_bp_register_thread(void)
-{
-}
+extern void urcu_bp_register_thread(void);
 
+/*
+ * In the bulletproof version, the following functions are no-ops.
+ */
 static inline void urcu_bp_unregister_thread(void)
 {
 }
diff --git a/m4/ax_tls.m4 b/m4/ax_tls.m4
deleted file mode 100644 (file)
index 51edee8..0000000
+++ /dev/null
@@ -1,74 +0,0 @@
-# ===========================================================================
-#          https://www.gnu.org/software/autoconf-archive/ax_tls.html
-# ===========================================================================
-#
-# SYNOPSIS
-#
-#   AX_TLS([action-if-found], [action-if-not-found])
-#
-# DESCRIPTION
-#
-#   Provides a test for the compiler support of thread local storage (TLS)
-#   extensions. Defines TLS if it is found. Currently knows about C++11,
-#   GCC/ICC, and MSVC. I think SunPro uses the same as GCC, and Borland
-#   apparently supports either.
-#
-# LICENSE
-#
-#   Copyright (c) 2008 Alan Woodland <ajw05@aber.ac.uk>
-#   Copyright (c) 2010 Diego Elio Petteno` <flameeyes@gmail.com>
-#
-#   This program is free software: you can redistribute it and/or modify it
-#   under the terms of the GNU General Public License as published by the
-#   Free Software Foundation, either version 3 of the License, or (at your
-#   option) any later version.
-#
-#   This program 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 General
-#   Public License for more details.
-#
-#   You should have received a copy of the GNU General Public License along
-#   with this program. If not, see <https://www.gnu.org/licenses/>.
-#
-#   As a special exception, the respective Autoconf Macro's copyright owner
-#   gives unlimited permission to copy, distribute and modify the configure
-#   scripts that are the output of Autoconf when processing the Macro. You
-#   need not follow the terms of the GNU General Public License when using
-#   or distributing such scripts, even though portions of the text of the
-#   Macro appear in them. The GNU General Public License (GPL) does govern
-#   all other use of the material that constitutes the Autoconf Macro.
-#
-#   This special exception to the GPL applies to versions of the Autoconf
-#   Macro released by the Autoconf Archive. When you make and distribute a
-#   modified version of the Autoconf Macro, you may extend this special
-#   exception to the GPL to apply to your modified version as well.
-
-#serial 14
-
-AC_DEFUN([AX_TLS], [
-  AC_MSG_CHECKING([for thread local storage (TLS) class])
-  AC_CACHE_VAL([ac_cv_tls],
-   [for ax_tls_keyword in thread_local _Thread_local __thread '__declspec(thread)' none; do
-       AS_CASE([$ax_tls_keyword],
-          [none], [ac_cv_tls=none ; break],
-          [AC_TRY_COMPILE(
-              [#include <stdlib.h>
-               static void
-               foo(void) {
-               static ] $ax_tls_keyword [ int bar;
-               exit(1);
-               }],
-               [],
-               [ac_cv_tls=$ax_tls_keyword ; break],
-               ac_cv_tls=none
-           )])
-    done
-  ])
-  AC_MSG_RESULT([$ac_cv_tls])
-
-  AS_IF([test "$ac_cv_tls" != "none"],
-    [AC_DEFINE_UNQUOTED([TLS],[$ac_cv_tls],[If the compiler supports a TLS storage class define it to that here])
-     m4_ifnblank([$1],[$1])],
-    [m4_ifnblank([$2],[$2])])
-])
index 33f280799208c66f0337e25acfeaf8adce213aa1..05efd97eb67a2c05c99a09dfb5c6e29e888ff81e 100644 (file)
@@ -566,6 +566,12 @@ end:
 }
 URCU_ATTR_ALIAS("urcu_bp_register") void rcu_bp_register();
 
+void urcu_bp_register_thread(void)
+{
+       if (caa_unlikely(!URCU_TLS(urcu_bp_reader)))
+               urcu_bp_register(); /* If not yet registered. */
+}
+
 /* Disable signals, take mutex, remove from registry */
 static
 void urcu_bp_unregister(struct rcu_reader *rcu_reader_reg)
index 573ae3366faca1a2a8b51957ff42df4eb2252819..3e384d6077c74fe2943a24afe90091d733c81b1b 100644 (file)
@@ -94,7 +94,8 @@ _gen_result(int ok, const char *func, char *file, unsigned int line,
                if(local_test_name) {
                        name_is_digits = 1;
                        for(c = local_test_name; *c != '\0'; c++) {
-                               if(!isdigit(*c) && !isspace(*c)) {
+                               if(!isdigit((unsigned char)*c) &&
+                                               !isspace((unsigned char)*c)) {
                                        name_is_digits = 0;
                                        break;
                                }
This page took 0.045417 seconds and 4 git commands to generate.