diff options
author | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-11 18:57:22 +0100 |
---|---|---|
committer | cinap_lenrek <cinap_lenrek@gmx.de> | 2013-03-11 18:57:22 +0100 |
commit | 25f04a68a168a948783618910e115316eb0ed3fc (patch) | |
tree | b3cb88e49ef21b5855569918634937bdbf78b19e /sys/src/ape/lib/ap/386 | |
parent | 34ec2056041a193a471701dd50e2032dc300fb0e (diff) |
ape: threadsafe errno
store errno on the private process stack so its always per process
and not just per memory space. errno itself becomes a macro
dereferencing int *_errnoloc; which is initialized from main9.s
pointing to the private stack location.
various fixes in programs that just imported errno variable with
"extern int errno;" instead of including <errno.h>.
Diffstat (limited to 'sys/src/ape/lib/ap/386')
-rw-r--r-- | sys/src/ape/lib/ap/386/main9.s | 7 | ||||
-rw-r--r-- | sys/src/ape/lib/ap/386/main9p.s | 7 |
2 files changed, 10 insertions, 4 deletions
diff --git a/sys/src/ape/lib/ap/386/main9.s b/sys/src/ape/lib/ap/386/main9.s index 04ee73dd1..a5f351df9 100644 --- a/sys/src/ape/lib/ap/386/main9.s +++ b/sys/src/ape/lib/ap/386/main9.s @@ -1,14 +1,17 @@ #define NPRIVATES 16 GLOBL _tos(SB), $4 +GLOBL _errnoloc(SB), $4 GLOBL _privates(SB), $4 GLOBL _nprivates(SB), $4 -TEXT _main(SB), 1, $(3*4+NPRIVATES*4) +TEXT _main(SB), 1, $(16+NPRIVATES*4) /* _tos = arg */ MOVL AX, _tos(SB) - LEAL 8(SP), AX + LEAL 12(SP), AX + MOVL AX, _errnoloc(SB) + LEAL 16(SP), AX MOVL AX, _privates(SB) MOVL $NPRIVATES, _nprivates(SB) diff --git a/sys/src/ape/lib/ap/386/main9p.s b/sys/src/ape/lib/ap/386/main9p.s index 0ca3004a4..1cd317eba 100644 --- a/sys/src/ape/lib/ap/386/main9p.s +++ b/sys/src/ape/lib/ap/386/main9p.s @@ -1,14 +1,17 @@ #define NPRIVATES 16 GLOBL _tos(SB), $4 +GLOBL _errnoloc(SB), $4 GLOBL _privates(SB), $4 GLOBL _nprivates(SB), $4 -TEXT _mainp(SB), 1, $(3*4+NPRIVATES*4) +TEXT _mainp(SB), 1, $(16+NPRIVATES*4) /* _tos = arg */ MOVL AX, _tos(SB) - LEAL 8(SP), AX + LEAL 12(SP), AX + MOVL AX, _errnoloc(SB) + LEAL 16(SP), AX MOVL AX, _privates(SB) MOVL $NPRIVATES, _nprivates(SB) |