>From f4ecbf9683111d67e70fc32bfed737ac556bfaf5 Mon Sep 17 00:00:00 2001 From: Akira Yokosawa <akiyks@xxxxxxxxx> Date: Tue, 22 Oct 2019 12:53:00 +0900 Subject: [PATCH v3 5/6] defer/rcuintro: Convert snippet to new scheme This snippet was added using the verbatimbox scheme. Convert it using VerbatimL. Signed-off-by: Akira Yokosawa <akiyks@xxxxxxxxx> --- defer/rcuintro.tex | 56 ++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 29 deletions(-) diff --git a/defer/rcuintro.tex b/defer/rcuintro.tex index b9b9400e..000c61a7 100644 --- a/defer/rcuintro.tex +++ b/defer/rcuintro.tex @@ -370,49 +370,47 @@ has executed a context switch, which in turn guarantees that all pre-existing reader threads have completed. \begin{listing}[tbp] -{ \scriptsize -\begin{verbbox}[\LstLineNo] +\begin{linelabel}[ln:defer:Insertion and Deletion With Concurrent Readers] +\begin{VerbatimL}[commandchars=\\\[\]] struct route *gptr; int access_route(int (*f)(struct route *rp)) { - int ret = -1; - struct route *rp; - - rcu_read_lock(); - rp = rcu_dereference(gptr); - if (rp) - ret = f(rp); - rcu_read_unlock(); - return ret; + int ret = -1; + struct route *rp; + + rcu_read_lock(); + rp = rcu_dereference(gptr); + if (rp) + ret = f(rp); + rcu_read_unlock(); + return ret; } struct route *ins_route(struct route *rp) { - struct route *old_rp; + struct route *old_rp; - spin_lock(&route_lock); - old_rp = gptr; - rcu_assign_pointer(gptr, rp); - spin_unlock(&route_lock); + spin_lock(&route_lock); + old_rp = gptr; + rcu_assign_pointer(gptr, rp); + spin_unlock(&route_lock); } int del_route(void) { - struct route *old_rp; - - spin_lock(&route_lock); - old_rp = gptr; - RCU_INIT_POINTER(gptr, NULL); - spin_unlock(&route_lock); - synchronize_rcu(); - free(old_rp); - return !!old_rp; + struct route *old_rp; + + spin_lock(&route_lock); + old_rp = gptr; + RCU_INIT_POINTER(gptr, NULL); + spin_unlock(&route_lock); + synchronize_rcu(); + free(old_rp); + return !!old_rp; } -\end{verbbox} -} -\centering -\theverbbox +\end{VerbatimL} +\end{linelabel} \caption{Insertion and Deletion With Concurrent Readers} \label{lst:defer:Insertion and Deletion With Concurrent Readers} \end{listing} -- 2.17.1