summaryrefslogtreecommitdiff
path: root/sys/src/ape/lib/ap/stdio
diff options
context:
space:
mode:
authorcinap_lenrek <cinap_lenrek@gmx.de>2013-03-11 18:57:22 +0100
committercinap_lenrek <cinap_lenrek@gmx.de>2013-03-11 18:57:22 +0100
commit25f04a68a168a948783618910e115316eb0ed3fc (patch)
treeb3cb88e49ef21b5855569918634937bdbf78b19e /sys/src/ape/lib/ap/stdio
parent34ec2056041a193a471701dd50e2032dc300fb0e (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/stdio')
-rw-r--r--sys/src/ape/lib/ap/stdio/iolib.h2
-rw-r--r--sys/src/ape/lib/ap/stdio/perror.c3
2 files changed, 3 insertions, 2 deletions
diff --git a/sys/src/ape/lib/ap/stdio/iolib.h b/sys/src/ape/lib/ap/stdio/iolib.h
index 57eb96085..564ddff24 100644
--- a/sys/src/ape/lib/ap/stdio/iolib.h
+++ b/sys/src/ape/lib/ap/stdio/iolib.h
@@ -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);
diff --git a/sys/src/ape/lib/ap/stdio/perror.c b/sys/src/ape/lib/ap/stdio/perror.c
index 71f5c41f0..19a078b39 100644
--- a/sys/src/ape/lib/ap/stdio/perror.c
+++ b/sys/src/ape/lib/ap/stdio/perror.c
@@ -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);