Adapt test to the srp_swap() area.
authormpi <mpi@openbsd.org>
Tue, 19 Jul 2016 10:52:56 +0000 (10:52 +0000)
committermpi <mpi@openbsd.org>
Tue, 19 Jul 2016 10:52:56 +0000 (10:52 +0000)
regress/sys/net/rtable/delete/main.c
regress/sys/net/rtable/srp_compat.h

index b0dfb7b..7e17a9b 100644 (file)
@@ -1,4 +1,4 @@
-/*     $OpenBSD: main.c,v 1.3 2015/12/03 15:15:04 mpi Exp $ */
+/*     $OpenBSD: main.c,v 1.4 2016/07/19 10:52:56 mpi Exp $ */
 
 /*
  * Copyright (c) 2015 Martin Pieuchot
@@ -68,7 +68,7 @@ main(int argc, char *argv[])
        struct art_root *ar;
        ar = rtable_get(0, AF_INET6);
        assert(ar != NULL);
-       assert(ar->ar_root == NULL);
+       assert(ar->ar_root.ref == NULL);
 #endif /* ART */
 
        return (0);
index 458575c..27cf38b 100644 (file)
@@ -6,23 +6,42 @@
 #include <sys/queue.h>
 
 /*
- * SRPL glue.
+ * SRP glue.
  */
 
-#define srp_get_locked(_s)     ((_s)->ref)
-#define srp_enter(_sr, _s)     srp_get_locked(_s)
-#define srp_leave(_sr)         ((void)_sr)
+#define srp_enter(_sr, _s)             ((_s)->ref)
+#define srp_follow(_sr, _s)            ((_s)->ref)
+#define srp_leave(_sr)                 do { } while (0)
+#define srp_swap(_srp, _v)             srp_swap_locked((_srp), (_v))
+#define srp_update(_gc, _srp, _v)      srp_update_locked((_gc), (_srp), (_v))
+#define srp_finalize(_v, _wchan)       ((void)0)
+
+#define srp_get_locked(_s)             ((_s)->ref)
+
+static inline void *
+srp_swap_locked(struct srp *srp, void *nv)
+{
+       void *ov;
+
+       ov = srp->ref;
+       srp->ref = nv;
+
+       return (ov);
+}
 
 #define srp_update_locked(_gc, _s, _v) do {                            \
        void *ov;                                                       \
                                                                        \
-       ov = (_s)->ref;                                                 \
-       (_s)->ref = _v;                                                 \
+       ov = srp_swap_locked(_s, _v);                                   \
                                                                        \
        if (ov != NULL)                                                 \
                ((_gc)->srp_gc_dtor)((_gc)->srp_gc_cookie, ov);         \
 } while (0)
 
+/*
+ * SRPL glue.
+ */
+
 #define SRPL_INIT(_sl)                 SLIST_INIT(_sl)
 #define SRPL_HEAD(name, entry)         SLIST_HEAD(name, entry)
 #define SRPL_ENTRY(type)               SLIST_ENTRY(type)
@@ -31,6 +50,9 @@
 #define SRPL_NEXT(_sr, _e, _ENTRY)     SLIST_NEXT(_e, _ENTRY)
 #define SRPL_LEAVE(_sr)                        ((void)_sr)
 
+#define SRPL_FOREACH(_c, _srp, _sl, _ENTRY)                            \
+               SLIST_FOREACH(_c, _sl, _ENTRY)
+
 #define SRPL_EMPTY_LOCKED(_sl) SLIST_EMPTY(_sl)
 #define SRPL_FOREACH_SAFE_LOCKED(_c, _sl, _ENTRY, _tc)                 \
                SLIST_FOREACH_SAFE(_c, _sl, _ENTRY, _tc)