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>.
This commit is contained in:
parent
34ec205604
commit
25f04a68a1
22 changed files with 80 additions and 38 deletions
|
@ -2,7 +2,8 @@
|
|||
#define __ERRNO
|
||||
#pragma lib "/$M/lib/ape/libap.a"
|
||||
|
||||
extern int errno;
|
||||
extern int *_errnoloc;
|
||||
#define errno (*_errnoloc)
|
||||
|
||||
#define EDOM 1000
|
||||
#define ERANGE 1001
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -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)
|
||||
|
||||
|
|
|
@ -1,15 +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)
|
||||
MOVL $a6base(SB), A6
|
||||
|
||||
/* _tos = arg */
|
||||
MOVL R0, _tos(SB) /* return value of sys exec!! */
|
||||
LEA private+8(SP), _privates(SB)
|
||||
LEA errno+12(SB), _errnoloc(SB)
|
||||
LEA private+16(SP), _privates(SB)
|
||||
MOVL $NPRIVATES, _nprivates(SB)
|
||||
|
||||
PEA inargv+0(FP)
|
||||
|
|
|
@ -1,15 +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)
|
||||
MOVL $a6base(SB), A6
|
||||
|
||||
/* _tos = arg */
|
||||
MOVL R0, _tos(SB) /* return value of sys exec!! */
|
||||
LEA private+8(SP), _privates(SB)
|
||||
LEA errno+12(SP), _errnoloc(SB)
|
||||
LEA private+16(SP), _privates(SB)
|
||||
MOVL $NPRIVATES, _nprivates(SB)
|
||||
|
||||
/* _profmain(); */
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#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)
|
||||
MOVQ $setSB(SB), R29
|
||||
|
||||
/* _tos = arg */
|
||||
MOVL R0, _tos(SB)
|
||||
MOVQ $8(SP), R1
|
||||
MOVQ $12(SP), R1
|
||||
MOVL R1, _errnoloc(SB)
|
||||
MOVQ $16(SP), R1
|
||||
MOVL R1, _privates(SB)
|
||||
MOVQ $NPRIVATES, R1
|
||||
MOVL R1, _nprivates(SB)
|
||||
|
|
|
@ -1,15 +1,18 @@
|
|||
#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)
|
||||
MOVQ $setSB(SB), R29
|
||||
|
||||
/* _tos = arg */
|
||||
MOVL R0, _tos(SB)
|
||||
MOVQ $8(SP), R1
|
||||
MOVQ $12(SP), R1
|
||||
MOVL R1, _errnoloc(SB)
|
||||
MOVQ $16(SP), R1
|
||||
MOVL R1, _privates(SB)
|
||||
MOVQ $NPRIVATES, R1
|
||||
MOVL R1, _nprivates(SB)
|
||||
|
|
|
@ -5,16 +5,19 @@ sb=12
|
|||
#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)
|
||||
|
||||
MOVW $setR12(SB), R(sb)
|
||||
|
||||
/* _tos = arg */
|
||||
MOVW R(arg), _tos(SB)
|
||||
MOVW $private+8(SP), R1
|
||||
MOVW $errno+12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $private+16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -5,16 +5,19 @@ sb=12
|
|||
#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)
|
||||
|
||||
MOVW $setR12(SB), R(sb)
|
||||
|
||||
/* _tos = arg */
|
||||
MOVW R(arg), _tos(SB)
|
||||
MOVW $private+8(SP), R1
|
||||
MOVW $errno+12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $private+16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#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)
|
||||
MOVW $setR30(SB), R30
|
||||
|
||||
/* _tos = arg */
|
||||
|
@ -17,7 +18,9 @@ TEXT _main(SB), 1, $(3*4+NPRIVATES*4)
|
|||
ADDD F26, F26, F28
|
||||
ADDD F28, F28, F30
|
||||
*/
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#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)
|
||||
MOVW $setR30(SB), R30
|
||||
|
||||
/* _tos = arg */
|
||||
|
@ -17,7 +18,9 @@ TEXT _mainp(SB), 1, $(3*4+NPRIVATES*4)
|
|||
ADDD F26, F26, F28
|
||||
ADDD F28, F28, F30
|
||||
*/
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
*/
|
||||
|
||||
char **environ;
|
||||
int errno;
|
||||
int *_errnoloc;
|
||||
unsigned long _clock;
|
||||
static void fdsetup(char *, char *);
|
||||
static void sigsetup(char *, char *);
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
char _plan9err[ERRMAX];
|
||||
|
||||
static struct errmap {
|
||||
int errno;
|
||||
int num;
|
||||
char *ename;
|
||||
} map[] = {
|
||||
/* from /sys/src/9/port/errstr.h */
|
||||
|
@ -119,6 +119,6 @@ _syserrno(void)
|
|||
if(strstr(_plan9err, map[i].ename) != 0)
|
||||
break;
|
||||
_ERRSTR(_plan9err, sizeof _plan9err);
|
||||
errno = (i < NERRMAP)? map[i].errno : EINVAL;
|
||||
errno = (i < NERRMAP)? map[i].num : EINVAL;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#define _BSDTIME_EXTENSION
|
||||
#include "lib.h"
|
||||
#include <sys/stat.h>
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <errno.h>
|
||||
#include <stdlib.h>
|
||||
#include "sys9.h"
|
||||
#include <string.h>
|
||||
|
||||
extern int errno;
|
||||
Fdinfo _fdinfo[OPEN_MAX];
|
||||
|
||||
/*
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#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)
|
||||
|
||||
MOVW $setSB(SB), R2
|
||||
|
||||
/* _tos = arg */
|
||||
MOVW R3, _tos(SB)
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -1,16 +1,19 @@
|
|||
#define NPRIVATES 16
|
||||
|
||||
GLOBL _tos(SB), $4
|
||||
GLOBAL _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)
|
||||
|
||||
MOVW $setSB(SB), R2
|
||||
|
||||
/* _tos = arg */
|
||||
MOVW R3, _tos(SB)
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#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)
|
||||
MOVW $setSB(SB), R2
|
||||
|
||||
/* _tos = arg */
|
||||
|
@ -16,7 +17,9 @@ TEXT _main(SB), 1, $(3*4+NPRIVATES*4)
|
|||
FADDD F26, F26, F28
|
||||
FADDD F28, F28, F30
|
||||
*/
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -1,10 +1,11 @@
|
|||
#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)
|
||||
MOVW $setSB(SB), R2
|
||||
|
||||
/* _tos = arg */
|
||||
|
@ -16,7 +17,9 @@ TEXT _mainp(SB), 1, $(3*4+NPRIVATES*4)
|
|||
FADDD F26, F26, F28
|
||||
FADDD F28, F28, F30
|
||||
*/
|
||||
MOVW $8(SP), R1
|
||||
MOVW $12(SP), R1
|
||||
MOVW R1, _errnoloc(SB)
|
||||
MOVW $16(SP), R1
|
||||
MOVW R1, _privates(SB)
|
||||
MOVW $NPRIVATES, R1
|
||||
MOVW R1, _nprivates(SB)
|
||||
|
|
|
@ -37,7 +37,7 @@
|
|||
#define WR 4 /* open, buffer allocated, ok to write but not read */
|
||||
#define ERR 5 /* open, but an uncleared error occurred */
|
||||
#define END 6 /* open, but at eof */
|
||||
char *strerror(int errno);
|
||||
char *strerror(int);
|
||||
int _IO_setvbuf(FILE *);
|
||||
FILE *_IO_sopenr(const char*);
|
||||
FILE *_IO_sopenw(void);
|
||||
|
|
|
@ -2,8 +2,9 @@
|
|||
* pANS stdio -- perror
|
||||
*/
|
||||
#include "iolib.h"
|
||||
#include <errno.h>
|
||||
|
||||
void perror(const char *s){
|
||||
extern int errno;
|
||||
if(s!=NULL && *s != '\0') fputs(s, stderr), fputs(": ", stderr);
|
||||
fputs(strerror(errno), stderr);
|
||||
putc('\n', stderr);
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "e.h"
|
||||
#include "y.tab.h"
|
||||
#include <ctype.h>
|
||||
#include <errno.h>
|
||||
|
||||
#define SSIZE 1000
|
||||
char token[SSIZE];
|
||||
|
@ -234,7 +235,6 @@ void include(void)
|
|||
char name[100];
|
||||
FILE *fin;
|
||||
int c;
|
||||
extern int errno;
|
||||
|
||||
while ((c = input()) == ' ')
|
||||
;
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "e.h"
|
||||
#include <errno.h>
|
||||
|
||||
#define MAXLINE 3600 /* maximum input line */
|
||||
|
||||
|
@ -92,7 +93,6 @@ getdata(void)
|
|||
{
|
||||
int i, type, ln;
|
||||
char fname[100];
|
||||
extern int errno;
|
||||
|
||||
errno = 0;
|
||||
curfile->lineno = 0;
|
||||
|
|
Loading…
Reference in a new issue