summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorjake <jake@FreeBSD.org>2000-12-04 12:38:03 +0000
committerjake <jake@FreeBSD.org>2000-12-04 12:38:03 +0000
commitd511c47ae91f13e32c3f5aee72471fe47bca2fbf (patch)
tree0c2397e68927a3cea5681c2c6d74b5d73a1d83a4
parentcca5d18fee67d6863f7e35c9b525019f4285c736 (diff)
downloadFreeBSD-src-d511c47ae91f13e32c3f5aee72471fe47bca2fbf.zip
FreeBSD-src-d511c47ae91f13e32c3f5aee72471fe47bca2fbf.tar.gz
(1) Allow a stray lock prefix to be compiled out with the
MPLOCKED macro (2) Use decimal 12 rather than hex 0xc in an addl (3) Implement MTX_ENTER for the I386_CPU case (4) Use semi-colons between instructions to allow MTX_ENTER and MTX_ENTER_WITH_RECURSION to be assembled (5) Use incl instead of incw to increment the recusion count (6) 10 is not a valid label, use 7, 8 and 9 rather than 8, 9 and 10 (7) Sort numeric labels Submitted by: bde (2, 4, and 5)
-rw-r--r--sys/amd64/include/mutex.h40
-rw-r--r--sys/i386/include/mutex.h40
2 files changed, 48 insertions, 32 deletions
diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h
index b960993..4b9fe2c8 100644
--- a/sys/amd64/include/mutex.h
+++ b/sys/amd64/include/mutex.h
@@ -92,7 +92,9 @@ extern char STR_SIEN[];
" call mtx_enter_hard;" \
" addl $8,%%esp;" \
" jmp 1f;" \
-"2: lock; orl $" _V(MTX_RECURSE) ",%1;" \
+"2:" \
+" " MPLOCKED "" \
+" orl $" _V(MTX_RECURSE) ",%1;" \
" incl %2;" \
"1:" \
"# getlock_sleep" \
@@ -119,7 +121,7 @@ extern char STR_SIEN[];
" pushl %4;" \
" pushl %5;" \
" call mtx_enter_hard;" /* mtx_enter_hard(mtxp, type, oflags) */ \
-" addl $0xc,%%esp;" \
+" addl $12,%%esp;" \
" jmp 1f;" \
"2: popl %2;" /* save flags */ \
"1:" \
@@ -260,6 +262,12 @@ extern char STR_SIEN[];
#if defined(I386_CPU)
+#define MTX_ENTER(reg, lck) \
+ pushf; \
+ cli; \
+ movl reg,lck+MTX_LOCK; \
+ popl lck+MTX_SAVEINTR
+
#define MTX_EXIT(lck, reg) \
pushl lck+MTX_SAVEINTR; \
movl $ MTX_UNOWNED,lck+MTX_LOCK; \
@@ -268,8 +276,8 @@ extern char STR_SIEN[];
#else /* I386_CPU */
#define MTX_ENTER(reg, lck) \
- pushf \
- cli \
+ pushf; \
+ cli; \
9: movl $ MTX_UNOWNED,%eax; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
@@ -286,35 +294,35 @@ extern char STR_SIEN[];
popf
#define MTX_ENTER_WITH_RECURSION(reg, lck) \
- pushf \
- cli \
+ pushf; \
+ cli; \
movl lck+MTX_LOCK,%eax; \
cmpl _curproc,%eax; \
- jne 9f; \
- incw lck+MTX_RECURS; \
+ jne 7f; \
+ incl lck+MTX_RECURSE; \
jmp 8f; \
-9: movl $ MTX_UNOWNED,%eax; \
+7: movl $ MTX_UNOWNED,%eax; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
jnz 9b; \
popl lck+MTX_SAVEINTR; \
- jmp 10f; \
+ jmp 9f; \
8: add $4,%esp; \
-10:
+9:
#define MTX_EXIT_WITH_RECURSION(lck,reg) \
movl lck+MTX_RECURSE,%eax; \
decl %eax; \
- js 9f; \
+ js 8f; \
movl %eax,lck+MTX_RECURSE; \
- jmp 8f; \
-9: pushl lck+MTX_SAVEINTR; \
+ jmp 9f; \
+8: pushl lck+MTX_SAVEINTR; \
movl lck+MTX_LOCK,%eax; \
movl $ MTX_UNOWNED,reg; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
- popf \
-8:
+ popf; \
+9:
#endif /* I386_CPU */
#endif /* !LOCORE */
diff --git a/sys/i386/include/mutex.h b/sys/i386/include/mutex.h
index b960993..4b9fe2c8 100644
--- a/sys/i386/include/mutex.h
+++ b/sys/i386/include/mutex.h
@@ -92,7 +92,9 @@ extern char STR_SIEN[];
" call mtx_enter_hard;" \
" addl $8,%%esp;" \
" jmp 1f;" \
-"2: lock; orl $" _V(MTX_RECURSE) ",%1;" \
+"2:" \
+" " MPLOCKED "" \
+" orl $" _V(MTX_RECURSE) ",%1;" \
" incl %2;" \
"1:" \
"# getlock_sleep" \
@@ -119,7 +121,7 @@ extern char STR_SIEN[];
" pushl %4;" \
" pushl %5;" \
" call mtx_enter_hard;" /* mtx_enter_hard(mtxp, type, oflags) */ \
-" addl $0xc,%%esp;" \
+" addl $12,%%esp;" \
" jmp 1f;" \
"2: popl %2;" /* save flags */ \
"1:" \
@@ -260,6 +262,12 @@ extern char STR_SIEN[];
#if defined(I386_CPU)
+#define MTX_ENTER(reg, lck) \
+ pushf; \
+ cli; \
+ movl reg,lck+MTX_LOCK; \
+ popl lck+MTX_SAVEINTR
+
#define MTX_EXIT(lck, reg) \
pushl lck+MTX_SAVEINTR; \
movl $ MTX_UNOWNED,lck+MTX_LOCK; \
@@ -268,8 +276,8 @@ extern char STR_SIEN[];
#else /* I386_CPU */
#define MTX_ENTER(reg, lck) \
- pushf \
- cli \
+ pushf; \
+ cli; \
9: movl $ MTX_UNOWNED,%eax; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
@@ -286,35 +294,35 @@ extern char STR_SIEN[];
popf
#define MTX_ENTER_WITH_RECURSION(reg, lck) \
- pushf \
- cli \
+ pushf; \
+ cli; \
movl lck+MTX_LOCK,%eax; \
cmpl _curproc,%eax; \
- jne 9f; \
- incw lck+MTX_RECURS; \
+ jne 7f; \
+ incl lck+MTX_RECURSE; \
jmp 8f; \
-9: movl $ MTX_UNOWNED,%eax; \
+7: movl $ MTX_UNOWNED,%eax; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
jnz 9b; \
popl lck+MTX_SAVEINTR; \
- jmp 10f; \
+ jmp 9f; \
8: add $4,%esp; \
-10:
+9:
#define MTX_EXIT_WITH_RECURSION(lck,reg) \
movl lck+MTX_RECURSE,%eax; \
decl %eax; \
- js 9f; \
+ js 8f; \
movl %eax,lck+MTX_RECURSE; \
- jmp 8f; \
-9: pushl lck+MTX_SAVEINTR; \
+ jmp 9f; \
+8: pushl lck+MTX_SAVEINTR; \
movl lck+MTX_LOCK,%eax; \
movl $ MTX_UNOWNED,reg; \
MPLOCKED \
cmpxchgl reg,lck+MTX_LOCK; \
- popf \
-8:
+ popf; \
+9:
#endif /* I386_CPU */
#endif /* !LOCORE */
OpenPOWER on IntegriCloud