summaryrefslogtreecommitdiff
path: root/libc/stdio/stdio.c
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2002-03-12 17:33:46 +0000
committerManuel Novoa III <mjn3@codepoet.org>2002-03-12 17:33:46 +0000
commitb6d85765b07a3e843253b6be02d82947842af9d2 (patch)
treec7bf35338f413b21ff3adea4f5fe581e2576c4e3 /libc/stdio/stdio.c
parent0343687b86ed007d78615d2da191ec341aed1c4c (diff)
So much for fcntl flags being resonably consistent across archs... (hopefully)
fix O_APPEND and O_LARGEFILE handling in _stdio_fopen(). Someone else will have to check of course...
Diffstat (limited to 'libc/stdio/stdio.c')
-rw-r--r--libc/stdio/stdio.c24
1 files changed, 14 insertions, 10 deletions
diff --git a/libc/stdio/stdio.c b/libc/stdio/stdio.c
index 8c2e7afdc..6d4bf40ec 100644
--- a/libc/stdio/stdio.c
+++ b/libc/stdio/stdio.c
@@ -2071,7 +2071,7 @@ FILE *fopen(const char * __restrict filename, const char * __restrict mode)
* fopen64 : filename != NULL, stream == NULL, filedes == -2
*/
-#if O_ACCMODE != 3 || O_RDONLY != 0 || O_WRONLY != 1 || O_RDWR != 2 || O_APPEND != __FLAG_APPEND || O_LARGEFILE != __FLAG_LARGEFILE
+#if O_ACCMODE != 3 || O_RDONLY != 0 || O_WRONLY != 1 || O_RDWR != 2
#error Assumption violated - mode constants
#endif
@@ -2189,12 +2189,21 @@ FILE *_stdio_fopen(const char * __restrict filename,
return NULL;
}
+ stream->modeflags |=
#ifdef __STDIO_BUFFERS
- stream->modeflags |= (isatty(stream->filedes) * __FLAG_LBF)
- | ((((open_mode & O_ACCMODE) + 1) ^ 0x03) * __FLAG_WRITEONLY)
- | (open_mode & (O_APPEND|O_LARGEFILE));
-
+ (isatty(stream->filedes) * __FLAG_LBF) |
+#endif /* __STDIO_BUFFERS */
+#if (O_APPEND == __FLAG_APPEND) && (O_LARGEFILE == __FLAG_LARGEFILE)
+ (open_mode & (O_APPEND|O_LARGEFILE)) | /* i386 linux and elks */
+#else /* (O_APPEND == __FLAG_APPEND) && (O_LARGEFILE == __FLAG_LARGEFILE) */
+ ((open_mode & O_APPEND) ? __FLAG_APPEND : 0) |
+#ifdef __STDIO_LARGE_FILES
+ ((open_mode & O_LARGEFILE) ? __FLAG_LARGEFILE : 0) |
+#endif /* __STDIO_LARGE_FILES */
+#endif /* (O_APPEND == __FLAG_APPEND) && (O_LARGEFILE == __FLAG_LARGEFILE) */
+ ((((open_mode & O_ACCMODE) + 1) ^ 0x03) * __FLAG_WRITEONLY);
+#ifdef __STDIO_BUFFERS
#ifdef __STDIO_GETC_MACRO
stream->bufgetc =
#endif
@@ -2202,11 +2211,6 @@ FILE *_stdio_fopen(const char * __restrict filename,
stream->bufputc =
#endif
stream->bufwpos = stream->bufrpos = stream->bufstart;
-
-#else /* __STDIO_BUFFERS */
- stream->modeflags |=
- ((((open_mode & O_ACCMODE) + 1) ^ 0x03) * __FLAG_WRITEONLY)
- | (open_mode & (O_APPEND|O_LARGEFILE));
#endif /* __STDIO_BUFFERS */
#ifdef __STDIO_GLIBC_CUSTOM_STREAMS