Browse Source

stdio.h: update partially, mainly for POSIX 2008

Guard some UCLIBC specific parts.
Add comment about bits/getopt.h.
open_memstream.c: remove __restrict according to SuSv4.

Signed-off-by: Peter S. Mazinger <ps.m@gmx.net>
Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com>
Peter S. Mazinger 13 years ago
parent
commit
3663803c5e
2 changed files with 20 additions and 7 deletions
  1. 19 6
      include/stdio.h
  2. 1 1
      libc/stdio/open_memstream.c

+ 19 - 6
include/stdio.h

@@ -282,15 +282,17 @@ extern FILE *fdopen (int __fd, __const char *__modes) __THROW __wur;
 libc_hidden_proto(fdopen)
 libc_hidden_proto(fdopen)
 #endif
 #endif
 
 
-#ifdef	__USE_GNU
 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
 #ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
+#ifdef	__USE_GNU
 /* Create a new stream that refers to the given magic cookie,
 /* Create a new stream that refers to the given magic cookie,
    and uses the given functions for input and output.  */
    and uses the given functions for input and output.  */
 extern FILE *fopencookie (void *__restrict __magic_cookie,
 extern FILE *fopencookie (void *__restrict __magic_cookie,
 			  __const char *__restrict __modes,
 			  __const char *__restrict __modes,
 			  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
 			  _IO_cookie_io_functions_t __io_funcs) __THROW __wur;
 libc_hidden_proto(fopencookie)
 libc_hidden_proto(fopencookie)
+#endif
 
 
+#ifdef __USE_XOPEN2K8
 /* Create a new stream that refers to a memory buffer.  */
 /* Create a new stream that refers to a memory buffer.  */
 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
 extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
   __THROW __wur;
   __THROW __wur;
@@ -298,8 +300,7 @@ extern FILE *fmemopen (void *__s, size_t __len, __const char *__modes)
 /* Open a stream that writes into a malloc'd buffer that is expanded as
 /* Open a stream that writes into a malloc'd buffer that is expanded as
    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
    necessary.  *BUFLOC and *SIZELOC are updated with the buffer's location
    and the number of characters written on fflush or fclose.  */
    and the number of characters written on fflush or fclose.  */
-extern FILE *open_memstream (char **__restrict __bufloc,
-			     size_t *__restrict __sizeloc) __THROW __wur;
+extern FILE *open_memstream (char **__bufloc, size_t *__sizeloc) __THROW __wur;
 libc_hidden_proto(open_memstream)
 libc_hidden_proto(open_memstream)
 #endif
 #endif
 #endif
 #endif
@@ -397,7 +398,9 @@ extern int asprintf (char **__restrict __ptr,
 		     __const char *__restrict __fmt, ...)
 		     __const char *__restrict __fmt, ...)
      __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
      __THROW __attribute__ ((__format__ (__printf__, 2, 3))) __wur;
 libc_hidden_proto(asprintf)
 libc_hidden_proto(asprintf)
+#endif
 
 
+#ifdef __USE_XOPEN2K8
 /* Write formatted output to a file descriptor.
 /* Write formatted output to a file descriptor.
 
 
    These functions are not part of POSIX and therefore no official
    These functions are not part of POSIX and therefore no official
@@ -492,8 +495,10 @@ libc_hidden_proto(getc_unlocked)
 extern int getchar_unlocked (void);
 extern int getchar_unlocked (void);
 libc_hidden_proto(getchar_unlocked)
 libc_hidden_proto(getchar_unlocked)
 
 
+# ifdef __UCLIBC__
 /* SUSv3 allows getc_unlocked to be a macro */
 /* SUSv3 allows getc_unlocked to be a macro */
-#define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
+#  define getc_unlocked(_fp) __GETC_UNLOCKED(_fp)
+# endif
 #endif /* Use POSIX or MISC.  */
 #endif /* Use POSIX or MISC.  */
 
 
 #ifdef __USE_MISC
 #ifdef __USE_MISC
@@ -549,8 +554,10 @@ extern int fputc_unlocked (int __c, FILE *__stream);
 extern int putc_unlocked (int __c, FILE *__stream);
 extern int putc_unlocked (int __c, FILE *__stream);
 extern int putchar_unlocked (int __c);
 extern int putchar_unlocked (int __c);
 
 
+# ifdef __UCLIBC__
 /* SUSv3 allows putc_unlocked to be a macro */
 /* SUSv3 allows putc_unlocked to be a macro */
-#define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
+#  define putc_unlocked(_ch, _fp) __PUTC_UNLOCKED(_ch, _fp)
+# endif
 #endif /* Use POSIX or MISC.  */
 #endif /* Use POSIX or MISC.  */
 
 
 
 
@@ -594,7 +601,7 @@ libc_hidden_proto(fgets_unlocked)
 #endif
 #endif
 
 
 
 
-#ifdef	__USE_GNU
+#ifdef	__USE_XOPEN2K8
 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
 /* Read up to (and including) a DELIMITER from STREAM into *LINEPTR
    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
    (and null-terminate it). *LINEPTR is a pointer returned from malloc (or
    NULL), pointing to *N characters of space.  It is realloc'd as
    NULL), pointing to *N characters of space.  It is realloc'd as
@@ -890,11 +897,15 @@ extern void funlockfile (FILE *__stream) __THROW;
    declared here which do not belong into this header.  But we have to
    declared here which do not belong into this header.  But we have to
    follow.  In GNU mode we don't do this nonsense.  */
    follow.  In GNU mode we don't do this nonsense.  */
 # define __need_getopt
 # define __need_getopt
+/* keep this on uClibc in bits/, we need it when GNU_GETOPT is disabled */
 # include <bits/getopt.h>
 # include <bits/getopt.h>
 #endif	/* X/Open, but not issue 6 and not for GNU.  */
 #endif	/* X/Open, but not issue 6 and not for GNU.  */
 
 
 /* If we are compiling with optimizing read this file.  It contains
 /* If we are compiling with optimizing read this file.  It contains
    several optimizing inline functions and macros.  */
    several optimizing inline functions and macros.  */
+
+#ifdef __UCLIBC__
+
 #define fgetc(_fp)                   __FGETC(_fp)
 #define fgetc(_fp)                   __FGETC(_fp)
 #define fputc(_ch, _fp)              __FPUTC(_ch, _fp)
 #define fputc(_ch, _fp)              __FPUTC(_ch, _fp)
 
 
@@ -929,6 +940,8 @@ extern void funlockfile (FILE *__stream) __THROW;
 #define ferror_unlocked(_fp)         __FERROR_UNLOCKED(_fp)
 #define ferror_unlocked(_fp)         __FERROR_UNLOCKED(_fp)
 #endif
 #endif
 
 
+#endif
+
 __END_DECLS
 __END_DECLS
 
 
 #endif /* <stdio.h> included.  */
 #endif /* <stdio.h> included.  */

+ 1 - 1
libc/stdio/open_memstream.c

@@ -128,7 +128,7 @@ static const cookie_io_functions_t _oms_io_funcs = {
  * (ie replace the FILE buffer with the cookie buffer and update FILE bufstart,
  * (ie replace the FILE buffer with the cookie buffer and update FILE bufstart,
  * etc. whenever we seek). */
  * etc. whenever we seek). */
 
 
-FILE *open_memstream(char **__restrict bufloc, size_t *__restrict sizeloc)
+FILE *open_memstream(char **bufloc, size_t *sizeloc)
 {
 {
 	register __oms_cookie *cookie;
 	register __oms_cookie *cookie;
 	register FILE *fp;
 	register FILE *fp;