Skip to contentSkip to conversation

SMPdesign: Fix command characters in code snippets

PATCH In review Akira Yokosawa 3 participants 3 messages Sep 13, 2022

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 SMPdesign: Fix command characters in code snippets

Some of listings in Chapter 6 use the command character option of "commandchars=\\\[\]".
This collides with "[" and "]" in the code snippets and removes them in the resulting listings.

Fix the issue by using "commandchars=\\\@\$" instead and adjusting the \lnlbl commands.

Fixes 2c8eae0b8c65 ("SMPdesign: Employ new scheme for inline snippets")
Fixes 05d62c297542 ("SMPdesign: Apply \clnref{} scheme to Listing 6.5")
---
 SMPdesign/SMPdesign.tex | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
SMPdesign/SMPdesign.tex +8 -8
index 05b86ec7271b..70936c12ce7e 100644
@@ -134,7 +134,7 @@ careful choice of data structure, can be arbitrarily large.
 On the other hand, if you are not in this happy situation, read on!
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
 	long nbuckets;
@@ -209,7 +209,7 @@ lock before returning.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Code-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 spinlock_t hash_lock;
 
 struct hash_table
@@ -228,17 +228,17 @@ int hash_search(struct hash_table *h, long key)
 	struct node *cur;
 	int retval;
 
-	spin_lock(&hash_lock);				\lnlbl[acq]
+	spin_lock(&hash_lock);				\lnlbl@acq$
 	cur = h->buckets[key % h->nbuckets];
 	while (cur != NULL) {
 		if (cur->key >= key) {
 			retval = (cur->key == key);
-			spin_unlock(&hash_lock);	\lnlbl[rel1]
+			spin_unlock(&hash_lock);	\lnlbl@rel1$
 			return retval;
 		}
 		cur = cur->next;
 	}
-	spin_unlock(&hash_lock);			\lnlbl[rel2]
+	spin_unlock(&hash_lock);			\lnlbl@rel2$
 	return 0;
 }
 \end{VerbatimL}
@@ -912,7 +912,7 @@ the POSIX implementation described in
 shows how the hash search might be implemented using reader-writer locking.
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 rwlock_t hash_lock;
 
 struct hash_table
@@ -972,7 +972,7 @@ and likely perform better.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Hierarchical-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
 	long nbuckets;
@@ -1003,7 +1003,7 @@ int hash_search(struct hash_table *h, long key)
 		if (cur->key >= key) {
 			spin_lock(&cur->node_lock);
 			spin_unlock(&bp->bucket_lock);
-			retval = (cur->key == key);\lnlbl[retval]
+			retval = (cur->key == key);\lnlbl@retval$
 			spin_unlock(&cur->node_lock);
 			return retval;
 		}

base-commit: 34400fe10ca37b884ee64f7bd2b93d5cccfe675d

Signature · 1 line
2.25.1
#1 lore raw
Quoted 5 lines · Akira Yokosawa

Some of listings in Chapter 6 use the command character option of "commandchars=\\\[\]".
This collides with "[" and "]" in the code snippets and removes them in the resulting listings.

Quoted 7 lines

Fix the issue by using "commandchars=\\\@\$" instead and adjusting the \lnlbl commands.

Fixes 2c8eae0b8c65 ("SMPdesign: Employ new scheme for inline snippets")
Fixes 05d62c297542 ("SMPdesign: Apply \clnref{} scheme to Listing 6.5")

This fixes it for me, so queued and pushed, and thank you both!

Elad, does this fix it for you as well?

Thanx, Paul

Quoted 79 lines
---
 SMPdesign/SMPdesign.tex | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
SMPdesign/SMPdesign.tex +8 -8
index 05b86ec7271b..70936c12ce7e 100644
@@ -134,7 +134,7 @@ careful choice of data structure, can be arbitrarily large.
 On the other hand, if you are not in this happy situation, read on!
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
 	long nbuckets;
@@ -209,7 +209,7 @@ lock before returning.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Code-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 spinlock_t hash_lock;
 
 struct hash_table
@@ -228,17 +228,17 @@ int hash_search(struct hash_table *h, long key)
 	struct node *cur;
 	int retval;
 
-	spin_lock(&hash_lock);				\lnlbl[acq]
+	spin_lock(&hash_lock);				\lnlbl@acq$
 	cur = h->buckets[key % h->nbuckets];
 	while (cur != NULL) {
 		if (cur->key >= key) {
 			retval = (cur->key == key);
-			spin_unlock(&hash_lock);	\lnlbl[rel1]
+			spin_unlock(&hash_lock);	\lnlbl@rel1$
 			return retval;
 		}
 		cur = cur->next;
 	}
-	spin_unlock(&hash_lock);			\lnlbl[rel2]
+	spin_unlock(&hash_lock);			\lnlbl@rel2$
 	return 0;
 }
 \end{VerbatimL}
@@ -912,7 +912,7 @@ the POSIX implementation described in
 shows how the hash search might be implemented using reader-writer locking.
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 rwlock_t hash_lock;
 
 struct hash_table
@@ -972,7 +972,7 @@ and likely perform better.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Hierarchical-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
 	long nbuckets;
@@ -1003,7 +1003,7 @@ int hash_search(struct hash_table *h, long key)
 		if (cur->key >= key) {
 			spin_lock(&cur->node_lock);
 			spin_unlock(&bp->bucket_lock);
-			retval = (cur->key == key);\lnlbl[retval]
+			retval = (cur->key == key);\lnlbl@retval$
 			spin_unlock(&cur->node_lock);
 			return retval;
 		}

base-commit: 34400fe10ca37b884ee64f7bd2b93d5cccfe675d

Signature · 1 line
2.25.1
#2 lore raw

Yes, it does. Thanks.

--Elad

Quoted 100 lines · Paul E. McKenney
Quoted 5 lines · Akira Yokosawa

Some of listings in Chapter 6 use the command character option of "commandchars=\\\[\]".
This collides with "[" and "]" in the code snippets and removes them in the resulting listings.

Quoted 7 lines

Fix the issue by using "commandchars=\\\@\$" instead and adjusting the \lnlbl commands.

Fixes 2c8eae0b8c65 ("SMPdesign: Employ new scheme for inline snippets")
Fixes 05d62c297542 ("SMPdesign: Apply \clnref{} scheme to Listing 6.5")

This fixes it for me, so queued and pushed, and thank you both!

Elad, does this fix it for you as well?

Thanx, Paul

Quoted 79 lines
---
 SMPdesign/SMPdesign.tex | 16 ++++++++--------
 1 file changed, 8 insertions(+), 8 deletions(-)
SMPdesign/SMPdesign.tex +8 -8
index 05b86ec7271b..70936c12ce7e 100644
@@ -134,7 +134,7 @@ careful choice of data structure, can be arbitrarily large.
 On the other hand, if you are not in this happy situation, read on!
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
      long nbuckets;
@@ -209,7 +209,7 @@ lock before returning.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Code-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 spinlock_t hash_lock;
 
 struct hash_table
@@ -228,17 +228,17 @@ int hash_search(struct hash_table *h, long key)
      struct node *cur;
      int retval;
 
-     spin_lock(&hash_lock);                          \lnlbl[acq]
+     spin_lock(&hash_lock);                          \lnlbl@acq$
      cur = h->buckets[key % h->nbuckets];
      while (cur != NULL) {
              if (cur->key >= key) {
                      retval = (cur->key == key);
-                     spin_unlock(&hash_lock);        \lnlbl[rel1]
+                     spin_unlock(&hash_lock);        \lnlbl@rel1$
                      return retval;
              }
              cur = cur->next;
      }
-     spin_unlock(&hash_lock);                        \lnlbl[rel2]
+     spin_unlock(&hash_lock);                        \lnlbl@rel2$
      return 0;
 }
 \end{VerbatimL}
@@ -912,7 +912,7 @@ the POSIX implementation described in
 shows how the hash search might be implemented using reader-writer locking.
 
 \begin{listing}
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 rwlock_t hash_lock;
 
 struct hash_table
@@ -972,7 +972,7 @@ and likely perform better.
 
 \begin{listing}
 \begin{fcvlabel}[ln:SMPdesign:Hierarchical-Locking Hash Table Search]
-\begin{VerbatimL}[commandchars=\\\[\]]
+\begin{VerbatimL}[commandchars=\\\@\$]
 struct hash_table
 {
      long nbuckets;
@@ -1003,7 +1003,7 @@ int hash_search(struct hash_table *h, long key)
              if (cur->key >= key) {
                      spin_lock(&cur->node_lock);
                      spin_unlock(&bp->bucket_lock);
-                     retval = (cur->key == key);\lnlbl[retval]
+                     retval = (cur->key == key);\lnlbl@retval$
                      spin_unlock(&cur->node_lock);
                      return retval;
              }

base-commit: 34400fe10ca37b884ee64f7bd2b93d5cccfe675d --
2.25.1