summaryrefslogtreecommitdiff
path: root/libc/stdio
diff options
context:
space:
mode:
authorEric Andersen <andersen@codepoet.org>2001-04-06 20:28:45 +0000
committerEric Andersen <andersen@codepoet.org>2001-04-06 20:28:45 +0000
commit6278781655261a5011376b2fa2600996e32ca889 (patch)
tree11783e71b36c8c546c4dc02dff355b0f2478978b /libc/stdio
parenta704ccaa5232184844cd67315951b39f85a6ba04 (diff)
Fix include/errno.h to not use kernel header, and instead use bits/errno.h.
This required we use _LIBC instead of __LIBC__ to be consistent with glibc. This had some sideffects in sys/syscalls.h. While fixing things, I made everything use __set_errno() for (eventual) thread support. -Erik
Diffstat (limited to 'libc/stdio')
-rw-r--r--libc/stdio/getdelim.c6
-rw-r--r--libc/stdio/popen.c2
-rw-r--r--libc/stdio/remove.c2
-rw-r--r--libc/stdio/stdio.c14
4 files changed, 12 insertions, 12 deletions
diff --git a/libc/stdio/getdelim.c b/libc/stdio/getdelim.c
index 6f9ebb4fb..9181f9aa0 100644
--- a/libc/stdio/getdelim.c
+++ b/libc/stdio/getdelim.c
@@ -43,14 +43,14 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file)
if ((file == NULL || linebuf==NULL || *linebuf == NULL || *linebufsz == 0)
&& !(*linebuf == NULL && *linebufsz ==0 )) {
- errno=EINVAL;
+ __set_errno(EINVAL);
return -1;
}
if (*linebuf == NULL && *linebufsz == 0){
*linebuf = malloc(GROWBY);
if (!*linebuf) {
- errno=ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
*linebufsz += GROWBY;
@@ -64,7 +64,7 @@ ssize_t getdelim(char **linebuf, size_t *linebufsz, int delimiter, FILE *file)
while (idx > *linebufsz-2) {
*linebuf = realloc(*linebuf, *linebufsz += GROWBY);
if (!*linebuf) {
- errno=ENOMEM;
+ __set_errno(ENOMEM);
return -1;
}
}
diff --git a/libc/stdio/popen.c b/libc/stdio/popen.c
index bc91bb73b..0a91f0e22 100644
--- a/libc/stdio/popen.c
+++ b/libc/stdio/popen.c
@@ -21,7 +21,7 @@ FILE *popen (const char *command, const char *mode)
reading = (mode[0] == 'r');
if ((!reading && (mode[0] != 'w')) || mode[1]) {
- errno = EINVAL; /* Invalid mode arg. */
+ __set_errno(EINVAL); /* Invalid mode arg. */
} else if (pipe(pipe_fd) == 0) {
pr = pipe_fd[reading];
pnr = pipe_fd[1-reading];
diff --git a/libc/stdio/remove.c b/libc/stdio/remove.c
index 115b871bb..af256e4aa 100644
--- a/libc/stdio/remove.c
+++ b/libc/stdio/remove.c
@@ -17,7 +17,7 @@ __const char *src;
if (rv < 0 && errno == EISDIR)
rv = rmdir(src);
if (rv >= 0)
- errno = er;
+ __set_errno(er);
return rv;
}
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index fe1c6a073..954318d39 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -279,7 +279,7 @@ int fflush(FILE *fp)
* ANSI says behavior in this case is undefined but also says you
* shouldn't flush a stream you were reading from.
*/
- errno = EBADF; /* Should we set stream error indicator? */
+ __set_errno(EBADF); /* Should we set stream error indicator? */
rv = -1;
}
@@ -560,7 +560,7 @@ int fseek(FILE *fp, long int offset, int ref)
#endif
if ((ref < 0) || (ref > 2)) {
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -610,7 +610,7 @@ FILE *fp;
--pos;
}
if (pos < 0) { /* ungetcs at start of file? */
- errno = EIO;
+ __set_errno(EIO);
pos = -1;
}
}
@@ -666,7 +666,7 @@ const char *mode;
open_mode = (O_WRONLY | O_CREAT | O_APPEND);
break;
default: /* illegal mode */
- errno = EINVAL;
+ __set_errno(EINVAL);
goto _fopen_ERROR;
}
@@ -709,7 +709,7 @@ const char *mode;
fd = -1;
} else if (!(cur_mode & O_RDWR)
&& ((cur_mode ^ open_mode) & O_ACCMODE)) {
- errno = EINVAL;
+ __set_errno(EINVAL);
fd = -1;
}
}
@@ -1037,7 +1037,7 @@ int fgetpos(FILE *fp, fpos_t *pos)
fpos_t p;
if (!pos) { /* NULL pointer. */
- errno = EINVAL;
+ __set_errno(EINVAL);
return -1;
}
@@ -1056,7 +1056,7 @@ int fsetpos(FILE *fp, __const fpos_t *pos)
if (pos) { /* Pointer ok. */
return fseek(fp, *pos, SEEK_SET);
}
- errno = EINVAL; /* NULL pointer. */
+ __set_errno(EINVAL); /* NULL pointer. */
return EOF;
}
#endif