Currently, OVSRCU_TYPE_INITIALIZER always initializes the RCU pointer
as NULL.  There is no reason why the RCU pointer could not be
initialized with a non-NULL value, however, as statically allocated
memory is even more stable than required for RCU.

This patch changes the initializer to OVSRCU_INITIALIZER(VALUE), which
can take any pointer value as a parameter.

This allows rculist, which is introduced in a following patch, to
provide an initializer similar to the one in the normal list.

Signed-off-by: Jarno Rajahalme <jrajaha...@nicira.com>
---
 lib/ovs-rcu.h                |    4 ++--
 ofproto/ofproto-dpif-xlate.c |    2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/lib/ovs-rcu.h b/lib/ovs-rcu.h
index 96b3233..1d79976 100644
--- a/lib/ovs-rcu.h
+++ b/lib/ovs-rcu.h
@@ -119,7 +119,7 @@
 
 #if __GNUC__
 #define OVSRCU_TYPE(TYPE) struct { ATOMIC(TYPE) p; }
-#define OVSRCU_TYPE_INITIALIZER { NULL }
+#define OVSRCU_INITIALIZER(VALUE) { ATOMIC_VAR_INIT(VALUE) }
 #define ovsrcu_get__(TYPE, VAR, ORDER)                                  \
     ({                                                                  \
         TYPE value__;                                                   \
@@ -151,7 +151,7 @@
 #else  /* not GNU C */
 struct ovsrcu_pointer { ATOMIC(void *) p; };
 #define OVSRCU_TYPE(TYPE) struct ovsrcu_pointer
-#define OVSRCU_TYPE_INITIALIZER { NULL }
+#define OVSRCU_INITIALIZER(VALUE) { ATOMIC_VAR_INIT(VALUE) }
 static inline void *
 ovsrcu_get__(const struct ovsrcu_pointer *pointer, memory_order order)
 {
diff --git a/ofproto/ofproto-dpif-xlate.c b/ofproto/ofproto-dpif-xlate.c
index d3ad62a..e9bb4ff 100644
--- a/ofproto/ofproto-dpif-xlate.c
+++ b/ofproto/ofproto-dpif-xlate.c
@@ -325,7 +325,7 @@ struct xlate_cfg {
     struct hmap xbundles;
     struct hmap xports;
 };
-static OVSRCU_TYPE(struct xlate_cfg *) xcfgp = OVSRCU_TYPE_INITIALIZER;
+static OVSRCU_TYPE(struct xlate_cfg *) xcfgp = OVSRCU_INITIALIZER(NULL);
 static struct xlate_cfg *new_xcfg = NULL;
 
 static bool may_receive(const struct xport *, struct xlate_ctx *);
-- 
1.7.10.4

_______________________________________________
dev mailing list
dev@openvswitch.org
http://openvswitch.org/mailman/listinfo/dev

Reply via email to