aboutsummaryrefslogtreecommitdiff
path: root/sys/amd64/include/mutex.h
diff options
context:
space:
mode:
authorJake Burkholder <jake@FreeBSD.org>2000-12-04 12:38:03 +0000
committerJake Burkholder <jake@FreeBSD.org>2000-12-04 12:38:03 +0000
commitf315dbdbd454d1ac67b75e0d500f2f7e390617c3 (patch)
tree2f5296c84cd2df389acd481edb91fbc5d84c69f4 /sys/amd64/include/mutex.h
parent8dd431fcf711c7d6082d1169a7f2b9bf53e84d3b (diff)
downloadsrc-f315dbdbd454d1ac67b75e0d500f2f7e390617c3.tar.gz
src-f315dbdbd454d1ac67b75e0d500f2f7e390617c3.zip
(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)
Notes
Notes: svn path=/head/; revision=69570
Diffstat (limited to 'sys/amd64/include/mutex.h')
-rw-r--r--sys/amd64/include/mutex.h40
1 files changed, 24 insertions, 16 deletions
diff --git a/sys/amd64/include/mutex.h b/sys/amd64/include/mutex.h
index b9609931aeeb..4b9fe2c87560 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 */