api-pthreads: Fold defines too wide for code snippet
PATCH 1/1 api-pthreads: Fold defines too wide for code snippet
From 33370f703c421a7537c75989d81266d48c045575 Mon Sep 17 00:00:00 2001
From: Akira Yokosawa <[email protected]>
Date: Wed, 24 Jul 2019 23:31:45 +0900
Subject: [PATCH] api-pthreads: Fold defines too wide for code snippet
Changes in commit 82b158acfedf ("api-pthreads: Prohibit using WRITE_ONCE() return value") caused Listing 4.9 to get too wide in two-column layout.
Fold the defines and add "xleftmargin=0pt" option to the "\begin{snippet}" meta-command.
---
Hi Paul,
Another option would be to use the "listing*" environment for this one. Which one do you like?
Thanks, Akira
--
CodeSamples/api-pthreads/api-pthreads.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
CodeSamples/api-pthreads/api-pthreads.h +5 -3
@@ -132,10 +132,12 @@ static __inline__ int spin_is_locked(spinlock_t *sp)#define spin_lock_irqsave (l, f) do { f = 1; spin_lock(l); } while (0)#define spin_unlock_irqrestore (l, f) do { f = 0; spin_unlock(l); } while (0) -//\begin{snippet}[labelbase=ln:api-pthreads:api-pthreads:compiler_barrier,commandchars=\@\[\],numbers=none] +//\begin{snippet}[labelbase=ln:api-pthreads:api-pthreads:compiler_barrier,commandchars=\@\[\],numbers=none,xleftmargin=0pt] #define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) -#define READ_ONCE (x) ({ typeof(x) ___x = ACCESS_ONCE(x); ___x; }) -#define WRITE_ONCE (x, val) do { ACCESS_ONCE(x) = (val); } while (0) +#define READ_ONCE (x) \ + ({ typeof(x) ___x = ACCESS_ONCE(x); ___x; }) +#define WRITE_ONCE (x, val) \ + do { ACCESS_ONCE(x) = (val); } while (0)#define barrier () __asm__ __volatile__("": : :"memory")//\end{snippet} #ifndef unlikely
Signature · 1 line
2.17.1
Quoted 12 lines · Akira Yokosawa
Quoted 1 line
From
33370f703c421a7537c75989d81266d48c045575Mon Sep 17 00:00:00 2001From: Akira Yokosawa <[email protected]>
Date: Wed, 24 Jul 2019 23:31:45 +0900
Subject: [PATCH] api-pthreads: Fold defines too wide for code snippetChanges in commit
82b158acfedf("api-pthreads: Prohibit usingWRITE_ONCE()return value") caused Listing 4.9 to get too wide in two-column layout.Fold the defines and add "xleftmargin=0pt" option to the "\begin{snippet}" meta-command.
Quoted 6 lines
Signed-off-by Akira Yokosawa <[email protected]>---
Hi Paul,Another option would be to use the "listing*" environment for this one. Which one do you like?
The "listing*" environment would be overkill for this one, so I took this patch instead, thank you!
CCing my gmail account due to local email issues. (The perfbook email list still finds me.)
Thanx, Paul
Quoted 29 lines
Thanks, Akira
--CodeSamples/api-pthreads/api-pthreads.h | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)CodeSamples/api-pthreads/api-pthreads.h +5
-3@@ -132,10 +132,12 @@ static __inline__ int spin_is_locked(spinlock_t *sp)#define spin_lock_irqsave (l, f) do { f = 1; spin_lock(l); } while (0)#define spin_unlock_irqrestore (l, f) do { f = 0; spin_unlock(l); } while (0) -//\begin{snippet}[labelbase=ln:api-pthreads:api-pthreads:compiler_barrier,commandchars=\@\[\],numbers=none] +//\begin{snippet}[labelbase=ln:api-pthreads:api-pthreads:compiler_barrier,commandchars=\@\[\],numbers=none,xleftmargin=0pt] #define ACCESS_ONCE (x) (*(volatile typeof(x) *)&(x)) -#define READ_ONCE (x) ({ typeof(x) ___x = ACCESS_ONCE(x); ___x; }) -#define WRITE_ONCE (x, val) do { ACCESS_ONCE(x) = (val); } while (0) +#define READ_ONCE (x) \ + ({ typeof(x) ___x = ACCESS_ONCE(x); ___x; }) +#define WRITE_ONCE (x, val) \ + do { ACCESS_ONCE(x) = (val); } while (0)#define barrier () __asm__ __volatile__("": : :"memory")//\end{snippet} #ifndef unlikelySignature · 1 line
2.17.1