diff options
Diffstat (limited to 'libc/sysdeps/linux/common/bits/uClibc_stdio.h')
-rw-r--r-- | libc/sysdeps/linux/common/bits/uClibc_stdio.h | 118 |
1 files changed, 53 insertions, 65 deletions
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h index d73da9de7..a75f971eb 100644 --- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h +++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h @@ -1,21 +1,8 @@ /* Copyright (C) 2002-2004 Manuel Novoa III <mjn3@codepoet.org> * - * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. - * - * This library is free software; you can redistribute it and/or - * modify it under the terms of the GNU Lesser General Public - * License as published by the Free Software Foundation; either - * version 2.1 of the License, or (at your option) any later version. - * - * The GNU C Library is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU - * Lesser General Public License for more details. + * GNU Library General Public License (LGPL) version 2 or later. * - * You should have received a copy of the GNU Lesser General Public - * License along with the GNU C Library; if not, write to the Free - * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA - * 02111-1307 USA. + * Dedicated to Toni. See uClibc/DEDICATION.mjn3 for details. */ #ifndef _STDIO_H @@ -242,7 +229,7 @@ typedef struct { /**********************************************************************/ #ifdef __UCLIBC_HAS_LFS__ -typedef __off64_t __offmax_t; /* TODO -- rename this? */ +typedef __off64_t __offmax_t; /* TODO -- rename this? */ #else typedef __off_t __offmax_t; /* TODO -- rename this? */ #endif @@ -252,7 +239,7 @@ typedef __off_t __offmax_t; /* TODO -- rename this? */ typedef __ssize_t __io_read_fn(void *__cookie, char *__buf, size_t __bufsize); typedef __ssize_t __io_write_fn(void *__cookie, - __const char *__buf, size_t __bufsize); + __const char *__buf, size_t __bufsize); /* NOTE: GLIBC difference!!! -- fopencookie seek function * For glibc, the type of pos is always (__off64_t *) but in our case * it is type (__off_t *) when the lib is built without large file support. @@ -359,24 +346,25 @@ struct __STDIO_FILE_STRUCT { #define __MASK_READING 0x0003U /* (0x0001 | 0x0002) */ #define __FLAG_READING 0x0001U -#define __FLAG_UNGOT 0x0002U -#define __FLAG_EOF 0x0004U +#define __FLAG_UNGOT 0x0002U +#define __FLAG_EOF 0x0004U #define __FLAG_ERROR 0x0008U -#define __FLAG_WRITEONLY 0x0010U -#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */ +#define __FLAG_WRITEONLY 0x0010U +#define __FLAG_READONLY 0x0020U /* (__FLAG_WRITEONLY << 1) */ #define __FLAG_WRITING 0x0040U -#define __FLAG_NARROW 0x0080U - -#define __FLAG_FBF 0x0000U /* must be 0 */ -#define __FLAG_LBF 0x0100U -#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */ -#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */ -#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */ -#define __FLAG_WIDE 0x0800U -/* available slot 0x1000U */ +#define __FLAG_NARROW 0x0080U + +#define __FLAG_FBF 0x0000U /* must be 0 */ +#define __FLAG_LBF 0x0100U +#define __FLAG_NBF 0x0200U /* (__FLAG_LBF << 1) */ +#define __MASK_BUFMODE 0x0300U /* (__FLAG_LBF|__FLAG_NBF) */ +#define __FLAG_APPEND 0x0400U /* fixed! == O_APPEND for linux */ +#define __FLAG_WIDE 0x0800U +/* available slot 0x1000U */ #define __FLAG_FREEFILE 0x2000U #define __FLAG_FREEBUF 0x4000U -#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */ +#define __FLAG_LARGEFILE 0x8000U /* fixed! == 0_LARGEFILE for linux */ +#define __FLAG_FAILED_FREOPEN __FLAG_LARGEFILE /* Note: In no-buffer mode, it would be possible to pack the necessary * flags into one byte. Since we wouldn't be buffering and there would @@ -422,17 +410,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden; #endif /**********************************************************************/ -#define __CLEARERR_UNLOCKED(__stream) \ +#define __CLEARERR_UNLOCKED(__stream) \ ((void)((__stream)->__modeflags &= ~(__FLAG_EOF|__FLAG_ERROR))) #define __FEOF_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_EOF) #define __FERROR_UNLOCKED(__stream) ((__stream)->__modeflags & __FLAG_ERROR) #ifdef __UCLIBC_HAS_THREADS__ -# define __CLEARERR(__stream) (clearerr)(__stream) +# define __CLEARERR(__stream) (clearerr)(__stream) # define __FERROR(__stream) (ferror)(__stream) # define __FEOF(__stream) (feof)(__stream) #else -# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream) +# define __CLEARERR(__stream) __CLEARERR_UNLOCKED(__stream) # define __FERROR(__stream) __FERROR_UNLOCKED(__stream) # define __FEOF(__stream) __FEOF_UNLOCKED(__stream) #endif @@ -440,17 +428,17 @@ extern void __stdio_init_mutex(pthread_mutex_t *m) attribute_hidden; extern int __fgetc_unlocked(FILE *__stream); extern int __fputc_unlocked(int __c, FILE *__stream); -/* First define the default definitions. They will be overwritten below as necessary. */ +/* First define the default definitions. They overriden below as necessary. */ #define __FGETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) -#define __FGETC(__stream) (fgetc)((__stream)) -#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) +#define __FGETC(__stream) (fgetc)((__stream)) +#define __GETC_UNLOCKED_MACRO(__stream) (__fgetc_unlocked)((__stream)) #define __GETC_UNLOCKED(__stream) (__fgetc_unlocked)((__stream)) -#define __GETC(__stream) (fgetc)((__stream)) +#define __GETC(__stream) (fgetc)((__stream)) -#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __FPUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) #define __FPUTC(__c, __stream) (fputc)((__c),(__stream)) -#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream)) -#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC_UNLOCKED_MACRO(__c, __stream) (__fputc_unlocked)((__c),(__stream)) +#define __PUTC_UNLOCKED(__c, __stream) (__fputc_unlocked)((__c),(__stream)) #define __PUTC(__c, __stream) (fputc)((__c),(__stream)) @@ -459,9 +447,9 @@ extern int __fputc_unlocked(int __c, FILE *__stream); extern FILE *__stdin; /* For getchar() macro. */ # undef __GETC_UNLOCKED_MACRO -# define __GETC_UNLOCKED_MACRO(__stream) \ +# define __GETC_UNLOCKED_MACRO(__stream) \ ( ((__stream)->__bufpos < (__stream)->__bufgetc_u) \ - ? (*(__stream)->__bufpos++) \ + ? (*(__stream)->__bufpos++) \ : __fgetc_unlocked(__stream) ) # if 0 @@ -476,10 +464,10 @@ extern FILE *__stdin; /* For getchar() macro. */ # else /* Using gcc extension for safety and additional inlining. */ # undef __FGETC_UNLOCKED -# define __FGETC_UNLOCKED(__stream) \ +# define __FGETC_UNLOCKED(__stream) \ (__extension__ ({ \ - FILE *__S = (__stream); \ - __GETC_UNLOCKED_MACRO(__S); \ + FILE *__S = (__stream); \ + __GETC_UNLOCKED_MACRO(__S); \ }) ) # undef __GETC_UNLOCKED @@ -487,23 +475,23 @@ extern FILE *__stdin; /* For getchar() macro. */ # ifdef __UCLIBC_HAS_THREADS__ # undef __FGETC -# define __FGETC(__stream) \ +# define __FGETC(__stream) \ (__extension__ ({ \ - FILE *__S = (__stream); \ - ((__S->__user_locking ) \ - ? __GETC_UNLOCKED_MACRO(__S) \ + FILE *__S = (__stream); \ + ((__S->__user_locking ) \ + ? __GETC_UNLOCKED_MACRO(__S) \ : (fgetc)(__S)); \ }) ) # undef __GETC -# define __GETC(__stream) __FGETC((__stream)) +# define __GETC(__stream) __FGETC((__stream)) -# else +# else # undef __FGETC # define __FGETC(__stream) __FGETC_UNLOCKED((__stream)) # undef __GETC -# define __GETC(__stream) __FGETC_UNLOCKED((__stream)) +# define __GETC(__stream) __FGETC_UNLOCKED((__stream)) # endif # endif @@ -518,16 +506,16 @@ extern FILE *__stdin; /* For getchar() macro. */ extern FILE *__stdout; /* For putchar() macro. */ # undef __PUTC_UNLOCKED_MACRO -# define __PUTC_UNLOCKED_MACRO(__c, __stream) \ +# define __PUTC_UNLOCKED_MACRO(__c, __stream) \ ( ((__stream)->__bufpos < (__stream)->__bufputc_u) \ - ? (*(__stream)->__bufpos++) = (__c) \ + ? (*(__stream)->__bufpos++) = (__c) \ : __fputc_unlocked((__c),(__stream)) ) # if 0 /* Classic macro approach. putc{_unlocked} can have side effects.*/ # undef __PUTC_UNLOCKED -# define __PUTC_UNLOCKED(__c, __stream) \ - __PUTC_UNLOCKED_MACRO((__c), (__stream)) +# define __PUTC_UNLOCKED(__c, __stream) \ + __PUTC_UNLOCKED_MACRO((__c), (__stream)) # ifndef __UCLIBC_HAS_THREADS__ # undef __PUTC # define __PUTC(__c, __stream) __PUTC_UNLOCKED_MACRO((__c), (__stream)) @@ -537,10 +525,10 @@ extern FILE *__stdout; /* For putchar() macro. */ /* Using gcc extension for safety and additional inlining. */ # undef __FPUTC_UNLOCKED -# define __FPUTC_UNLOCKED(__c, __stream) \ - (__extension__ ({ \ +# define __FPUTC_UNLOCKED(__c, __stream) \ + (__extension__ ({ \ FILE *__S = (__stream); \ - __PUTC_UNLOCKED_MACRO((__c),__S); \ + __PUTC_UNLOCKED_MACRO((__c),__S); \ }) ) # undef __PUTC_UNLOCKED @@ -548,11 +536,11 @@ extern FILE *__stdout; /* For putchar() macro. */ # ifdef __UCLIBC_HAS_THREADS__ # undef __FPUTC -# define __FPUTC(__c, __stream) \ - (__extension__ ({ \ +# define __FPUTC(__c, __stream) \ + (__extension__ ({ \ FILE *__S = (__stream); \ ((__S->__user_locking) \ - ? __PUTC_UNLOCKED_MACRO((__c),__S) \ + ? __PUTC_UNLOCKED_MACRO((__c),__S) \ : (fputc)((__c),__S)); \ }) ) @@ -562,9 +550,9 @@ extern FILE *__stdout; /* For putchar() macro. */ # else # undef __FPUTC -# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) +# define __FPUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) # undef __PUTC -# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) +# define __PUTC(__c, __stream) __FPUTC_UNLOCKED((__c),(__stream)) # endif # endif |