summaryrefslogtreecommitdiff
path: root/libc/sysdeps/linux/common/bits/uClibc_stdio.h
diff options
context:
space:
mode:
authorManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
committerManuel Novoa III <mjn3@codepoet.org>2003-08-01 20:08:59 +0000
commit1217289737588e65b088b3535428b27c7287d699 (patch)
tree6a292ac767d219702e26a6a2111737f84a96900c /libc/sysdeps/linux/common/bits/uClibc_stdio.h
parent32b76c5ec3c257b7287913d0d1a96e0cbb2e9c6a (diff)
Add a new *scanf implementation, includeing the *wscanf functions.
Should be standards compliant and with several optional features, including support for hexadecimal float notation, locale awareness, glibc-like locale-specific digit grouping with the `'' flag, and positional arg support. I tested it pretty well (finding several bugs in glibc's scanf in the process), but it is brand new so be aware. The *wprintf functions now support floating point output. Also, a couple of bugs were squashed. Finally, %a/%A conversions are now implemented. Implement the glibc xlocale interface for thread-specific locale support. Also add the various *_l(args, locale_t loc_arg) funcs. NOTE!!! setlocale() is NOT threadsafe! NOTE!!! The strto{floating point} conversion functions are now locale aware. The also now support hexadecimal floating point notation. Add the wcsto{floating point} conversion functions. Fix a bug in mktime() related to dst. Note that unlike glibc's mktime, uClibc's version always normalizes the struct tm before attempting to determine the correct dst setting if tm_isdst == -1 on entry. Add a stub version of the libintl functions. (untested) Fixed a known memory leak in setlocale() related to the collation data. Add lots of new config options (which Erik agreed to sort out :-), including finally exposing some of the stripped down stdio configs. Be careful with those though, as they haven't been tested in a long time. (temporary) GOTCHAs... The ctype functions are currently incorrect for 8-bit locales. They will be fixed shortly. The ctype functions are now table-based, resulting in larger staticly linked binaries. I'll be adding an option to use the old approach in the stub locale configuration.
Diffstat (limited to 'libc/sysdeps/linux/common/bits/uClibc_stdio.h')
-rw-r--r--libc/sysdeps/linux/common/bits/uClibc_stdio.h123
1 files changed, 97 insertions, 26 deletions
diff --git a/libc/sysdeps/linux/common/bits/uClibc_stdio.h b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
index 59156eeea..6c0cff7ed 100644
--- a/libc/sysdeps/linux/common/bits/uClibc_stdio.h
+++ b/libc/sysdeps/linux/common/bits/uClibc_stdio.h
@@ -44,6 +44,79 @@
#define __STDIO_WIDE
#endif
+#define __STDIO_BUFFERS
+/* ANSI/ISO mandate at least 256. */
+#if defined(__UCLIBC_HAS_STDIO_BUFSIZ_NONE__)
+/* Fake this because some apps use stdio.h BUFSIZ. */
+#define _STDIO_BUFSIZ 256
+#undef __STDIO_BUFFERS
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_256__)
+#define _STDIO_BUFSIZ 256
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_512__)
+#define _STDIO_BUFSIZ 512
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_1024__)
+#define _STDIO_BUFSIZ 1024
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_2048__)
+#define _STDIO_BUFSIZ 2048
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_4096__)
+#define _STDIO_BUFSIZ 4096
+#elif defined(__UCLIBC_HAS_STDIO_BUFSIZ_8192__)
+#define _STDIO_BUFSIZ 8192
+#else
+#error config seems to be out of sync regarding bufsiz options
+#endif
+
+#ifdef __UCLIBC_HAS_STDIO_GETC_MACRO__
+#define __STDIO_GETC_MACRO
+#endif
+
+#ifdef __UCLIBC_HAS_STDIO_PUTC_MACRO__
+#define __STDIO_PUTC_MACRO
+#endif
+
+#ifdef __UCLIBC_HAS_STDIO_AUTO_RW_TRANSITION__
+#define __STDIO_AUTO_RW_TRANSITION
+#endif
+
+#ifdef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__
+#define __STDIO_FOPEN_LARGEFILE_MODE
+#endif
+
+#ifdef __UCLIBC_HAS_FOPEN_LARGEFILE_MODE__
+#define __STDIO_FOPEN_EXCLUSIVE_MODE
+#endif
+
+#ifdef __UCLIBC_HAS_PRINTF_M_SPEC__
+#define __STDIO_PRINTF_M_SUPPORT
+#endif
+
+#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_STREAMS__
+#define __STDIO_GLIBC_CUSTOM_STREAMS
+#endif
+
+#ifdef __UCLIBC_HAS_STDIO_BUFSIZ_NONE__
+#define _STDIO_BUILTIN_BUF_SIZE 0
+#else /* __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ */
+#if defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_NONE__)
+#define _STDIO_BUILTIN_BUF_SIZE 0
+#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_4__)
+#define _STDIO_BUILTIN_BUF_SIZE 4
+#elif defined(__UCLIBC_HAS_STDIO_BUILTIN_BUFFER_8__)
+#define _STDIO_BUILTIN_BUF_SIZE 8
+#else
+#error config seems to be out of sync regarding builtin buffer size
+#endif
+#endif /* __UCLIBC_HAS_STDIO_BUFSIZ_NONE__ */
+
+#ifdef __UCLIBC_HAS_GLIBC_CUSTOM_PRINTF__
+#define __STDIO_GLIBC_CUSTOM_PRINTF
+#endif
+
+
+/* Currently unimplemented/untested */
+/* #define __STDIO_FLEXIBLE_SETVBUF */
+
+
/* Make sure defines related to large files are consistent. */
#ifdef _LIBC
@@ -81,32 +154,23 @@
#include <wchar.h>
#endif
-#define __STDIO_BUFFERS
-#define __STDIO_GETC_MACRO
-#define __STDIO_PUTC_MACRO
/* For uClibc, these are currently handled above. */
-/* #define __STDIO_LARGE_FILES */
-/* #define __STDIO_THREADSAFE */
-
+/* #define __STDIO_BUFFERS */
+/* #define __STDIO_GETC_MACRO */
+/* #define __STDIO_PUTC_MACRO */
+/* #define __STDIO_LARGE_FILES */
+/* #define __STDIO_THREADSAFE */
+/* ANSI/ISO mandate at least 256. */
+/* #define _STDIO_BUFSIZ 256 */
+/* #define __STDIO_AUTO_RW_TRANSITION */
+/* #define __STDIO_FOPEN_EXCLUSIVE_MODE */
+/* #define __STDIO_PRINTF_M_SPEC */
+/* #define __STDIO_GLIBC_CUSTOM_STREAMS */
/* L mode extension for fopen. */
-#define __STDIO_FOPEN_LARGEFILE_MODE
-
+/* #define __STDIO_FOPEN_LARGEFILE_MODE */
/* size of builtin buf -- only tested with 0 */
-#define _STDIO_BUILTIN_BUF_SIZE 0
-
-/* TODO - enable features based on __STDIO_GLIBC_FEATURES */
-
-/* #define __STDIO_GLIBC_FEATURES */
-#define __STDIO_AUTO_RW_TRANSITION
-#define __STDIO_FOPEN_EXCLUSIVE_MODE
-#define __STDIO_PRINTF_M_SPEC
-#define __STDIO_GLIBC_CUSTOM_STREAMS
-
-
-/* ANSI/ISO mandate at least 256. */
-#define _STDIO_BUFSIZ 256
-
+/* #define _STDIO_BUILTIN_BUF_SIZE 0 */
/* Currently unimplemented/untested */
/* #define __STDIO_FLEXIBLE_SETVBUF */
@@ -173,7 +237,10 @@
typedef struct {
__off_t __pos;
#ifdef __STDIO_MBSTATE
- __mbstate_t __mbstate;
+ __mbstate_t __mbstate;
+#endif
+#ifdef __STDIO_WIDE
+ int mblen_pending;
#endif
} __stdio_fpos_t;
@@ -181,7 +248,10 @@ typedef struct {
typedef struct {
__off64_t __pos;
#ifdef __STDIO_MBSTATE
- __mbstate_t __mbstate;
+ __mbstate_t __mbstate;
+#endif
+#ifdef __STDIO_WIDE
+ int mblen_pending;
#endif
} __stdio_fpos64_t;
#endif
@@ -234,6 +304,7 @@ typedef _IO_cookie_io_functions_t cookie_io_functions_t;
* 0 1 one user (unused ungot is 1) or one scanf (unused ungot is 0)
* 1 0 must be scanf[0] and user[1]
* 1 1 illegal -- could be used to signal safe for setbuf
+ * but if used, need to fix _stdio_adjpos at least!
*/
#ifdef __UCLIBC__
@@ -244,8 +315,8 @@ struct __stdio_file_struct {
unsigned short modeflags;
/* There could be a hole here, but modeflags is used most.*/
#ifdef __STDIO_WIDE
- /* TOOD - ungot_width could be combined with ungot. But what about hole? */
- unsigned char ungot_width[2];
+ /* TODO - ungot_width could be combined with ungot. But what about hole? */
+ unsigned char ungot_width[2]; /* 0 is current (building) char, 1 is scanf */
wchar_t ungot[2];
#else /* __STDIO_WIDE */
unsigned char ungot[2];