summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenis Vlasenko <vda.linux@googlemail.com>2008-06-03 03:51:30 +0000
committerDenis Vlasenko <vda.linux@googlemail.com>2008-06-03 03:51:30 +0000
commitd8dfa34f0e0aa7d5e49f01bbccfea3e0c0f972eb (patch)
tree49260a96e3671499b9a514ee0c20b1be5a038f17
parentc9a2b6c249a5d78e9cd21e6a92e64ab7886a014f (diff)
Remove __PRINTF_INFO_NO_BITFIELD hack, UCLIBC_INTERNAL can be used instead,
and it's slightly shorter. Also removes stray macros from public <printf.h> header and uses spaces for comment indentation. No code changes (verified with objdump).
-rw-r--r--include/printf.h145
-rw-r--r--libc/stdio/_vfprintf.c2
-rw-r--r--libc/stdio/old_vfprintf.c2
3 files changed, 65 insertions, 84 deletions
diff --git a/include/printf.h b/include/printf.h
index a68c6daad..72dffaab4 100644
--- a/include/printf.h
+++ b/include/printf.h
@@ -38,9 +38,10 @@ __BEGIN_DECLS
* with gcc, which is currently the only "supported" compiler.
* The library code uses bitmasks for space-efficiency (you can't
* set/test multiple bitfields in one operation). Unfortunatly, we
- * need to support bitfields since that's what glibc uses. So, we take
+ * need to support bitfields since that's what glibc made visible to users.
+ * So, we take
* advantage of how gcc lays out bitfields to create an appropriate
- * mapping. By defining __PRINTF_INFO_NO_BITFIELD we access the
+ * mapping. Inside uclibc (UCLIBC_INTERNAL is defined) we access the
* bitfields using bitmasks in a single flag variable.
*
* WARNING -- This may very well fail if built with -fpack-struct!!!
@@ -49,96 +50,81 @@ __BEGIN_DECLS
* TODO -- Add an option to build in a shim translation function if
* the bitfield<->bitmask mapping fails.
*/
-/* #define __PRINTF_INFO_NO_BITFIELD */
#include <endian.h>
-struct printf_info
-{
- int prec; /* Precision. */
- int width; /* Width. */
+struct printf_info {
+ int prec; /* Precision. */
+ int width; /* Width. */
#ifdef __UCLIBC_HAS_WCHAR__
- wchar_t spec; /* Format letter. */
+ wchar_t spec; /* Format letter. */
#else
int spec;
#endif
-#ifndef __PRINTF_INFO_NO_BITFIELD
+
+#ifndef UCLIBC_INTERNAL
+
#if __BYTE_ORDER == __LITTLE_ENDIAN
- unsigned int space:1; /* Space flag. */
- unsigned int showsign:1; /* + flag. */
- unsigned int extra:1; /* For special use. */
- unsigned int left:1; /* - flag. */
- unsigned int alt:1; /* # flag. */
- unsigned int group:1; /* ' flag. */
- unsigned int i18n:1; /* I flag. */
- unsigned int wide:1; /* Nonzero for wide character streams. */
- unsigned int is_char:1; /* hh flag. */
- unsigned int is_short:1; /* h flag. */
- unsigned int is_long:1; /* l flag. */
+ unsigned int space:1; /* Space flag. */
+ unsigned int showsign:1; /* + flag. */
+ unsigned int extra:1; /* For special use. */
+ unsigned int left:1; /* - flag. */
+ unsigned int alt:1; /* # flag. */
+ unsigned int group:1; /* ' flag. */
+ unsigned int i18n:1; /* I flag. */
+ unsigned int wide:1; /* Nonzero for wide character streams. */
+ unsigned int is_char:1; /* hh flag. */
+ unsigned int is_short:1; /* h flag. */
+ unsigned int is_long:1; /* l flag. */
unsigned int is_long_double:1;/* L flag. */
- unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */
-
+ unsigned int __padding:20; /* non-gnu: match _flags width of 32 bits */
#elif __BYTE_ORDER == __BIG_ENDIAN
-
- unsigned int __padding:20;/* non-gnu -- total of 32 bits on 32bit arch */
+ unsigned int __padding:20; /* non-gnu: match _flags width of 32 bits */
unsigned int is_long_double:1;/* L flag. */
- unsigned int is_long:1; /* l flag. */
- unsigned int is_short:1; /* h flag. */
- unsigned int is_char:1; /* hh flag. */
- unsigned int wide:1; /* Nonzero for wide character streams. */
- unsigned int i18n:1; /* I flag. */
- unsigned int group:1; /* ' flag. */
- unsigned int alt:1; /* # flag. */
- unsigned int left:1; /* - flag. */
- unsigned int extra:1; /* For special use. */
- unsigned int showsign:1; /* + flag. */
- unsigned int space:1; /* Space flag. */
-
+ unsigned int is_long:1; /* l flag. */
+ unsigned int is_short:1; /* h flag. */
+ unsigned int is_char:1; /* hh flag. */
+ unsigned int wide:1; /* Nonzero for wide character streams. */
+ unsigned int i18n:1; /* I flag. */
+ unsigned int group:1; /* ' flag. */
+ unsigned int alt:1; /* # flag. */
+ unsigned int left:1; /* - flag. */
+ unsigned int extra:1; /* For special use. */
+ unsigned int showsign:1; /* + flag. */
+ unsigned int space:1; /* Space flag. */
#else
#error unsupported byte order!
#endif
-#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD
-#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD = 1
-#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) (INFO_PTR)->BITFIELD = 0
-#define PRINT_INFO_SET_extra(INFO_PTR,VAL) (INFO_PTR)->extra = (VAL)
-
-#else /* __PRINTF_INFO_NO_BITFIELD */
-
- unsigned int _flags; /* non-gnu */
-#define __PRINT_INFO_FLAG_space (1<<0)
-#define __PRINT_INFO_FLAG_showsign (1<<1)
-#define __PRINT_INFO_FLAG_extra (1<<2)
-#define __PRINT_INFO_FLAG_left (1<<3)
-#define __PRINT_INFO_FLAG_alt (1<<4)
-#define __PRINT_INFO_FLAG_group (1<<5)
-#define __PRINT_INFO_FLAG_i18n (1<<6)
-#define __PRINT_INFO_FLAG_wide (1<<7)
-
-#define __PRINT_INFO_FLAG_is_char (1<<8)
-#define __PRINT_INFO_FLAG_is_short (1<<9)
-#define __PRINT_INFO_FLAG_is_long (1<<10)
-#define __PRINT_INFO_FLAG_is_long_double (1<<11)
-
-#if defined(__STDC__) && __STDC__
+#else /* UCLIBC_INTERNAL */
+
+ uint32_t _flags; /* non-gnu */
+#define __PRINT_INFO_FLAG_space (1<<0)
+#define __PRINT_INFO_FLAG_showsign (1<<1)
+#define __PRINT_INFO_FLAG_extra (1<<2)
+#define __PRINT_INFO_FLAG_left (1<<3)
+#define __PRINT_INFO_FLAG_alt (1<<4)
+#define __PRINT_INFO_FLAG_group (1<<5)
+#define __PRINT_INFO_FLAG_i18n (1<<6)
+#define __PRINT_INFO_FLAG_wide (1<<7)
+
+#define __PRINT_INFO_FLAG_is_char (1<<8)
+#define __PRINT_INFO_FLAG_is_short (1<<9)
+#define __PRINT_INFO_FLAG_is_long (1<<10)
+#define __PRINT_INFO_FLAG_is_long_double (1<<11)
+
#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) \
((INFO_PTR)->_flags & __PRINT_INFO_FLAG_##BITFIELD)
#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) \
((INFO_PTR)->_flags |= __PRINT_INFO_FLAG_##BITFIELD)
#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) \
((INFO_PTR)->_flags &= ~__PRINT_INFO_FLAG_##BITFIELD)
-#else
-#define PRINT_INFO_FLAG_VAL(INFO_PTR,BITFIELD) \
- ((INFO_PTR)->_flags & __PRINT_INFO_FLAG_/**/BITFIELD)
-#define PRINT_INFO_SET_FLAG(INFO_PTR,BITFIELD) \
- ((INFO_PTR)->_flags |= __PRINT_INFO_FLAG_/**/BITFIELD)
-#define PRINT_INFO_CLR_FLAG(INFO_PTR,BITFIELD) \
- ((INFO_PTR)->_flags &= ~__PRINT_INFO_FLAG_/**/BITFIELD)
-#endif
#define PRINT_INFO_SET_extra(INFO_PTR,VAL) \
((INFO_PTR)->_flags |= (((INFO_PTR)->_flags & ~1) | ((VAL) & 1)))
-#endif /* __PRINTF_INFO_NO_BITFIELD */
+
+#endif /* UCLIBC_INTERNAL */
+
#ifdef __UCLIBC_HAS_WCHAR__
- wchar_t pad; /* Padding character. */
+ wchar_t pad; /* Padding character. */
#else
int pad;
#endif
@@ -203,17 +189,16 @@ extern size_t parse_printf_format (__const char *__restrict __fmt, size_t __n,
* aren't qualified as pointers, I _think_ glibc just ignores them
* and carries on. I think it should be treated as an error. */
-enum
-{ /* C type: */
- PA_INT, /* int */
- PA_CHAR, /* int, cast to char */
- PA_WCHAR, /* wide char */
- PA_STRING, /* const char *, a '\0'-terminated string */
- PA_WSTRING, /* const wchar_t *, wide character string */
- PA_POINTER, /* void * */
- PA_FLOAT, /* float */
- PA_DOUBLE, /* double */
- __PA_NOARG, /* non-glibc -- signals non-arg width or prec */
+enum { /* C type: */
+ PA_INT, /* int */
+ PA_CHAR, /* int, cast to char */
+ PA_WCHAR, /* wide char */
+ PA_STRING, /* const char *, a '\0'-terminated string */
+ PA_WSTRING, /* const wchar_t *, wide character string */
+ PA_POINTER, /* void * */
+ PA_FLOAT, /* float */
+ PA_DOUBLE, /* double */
+ __PA_NOARG, /* non-glibc -- signals non-arg width or prec */
PA_LAST
};
diff --git a/libc/stdio/_vfprintf.c b/libc/stdio/_vfprintf.c
index 9c44a26a6..947b5b077 100644
--- a/libc/stdio/_vfprintf.c
+++ b/libc/stdio/_vfprintf.c
@@ -101,8 +101,6 @@
#include <stdint.h>
#include <errno.h>
#include <locale.h>
-
-#define __PRINTF_INFO_NO_BITFIELD
#include <printf.h>
#ifdef __UCLIBC_HAS_THREADS__
diff --git a/libc/stdio/old_vfprintf.c b/libc/stdio/old_vfprintf.c
index 8b8d50077..85a0967c1 100644
--- a/libc/stdio/old_vfprintf.c
+++ b/libc/stdio/old_vfprintf.c
@@ -137,8 +137,6 @@
#include <errno.h>
#include <ctype.h>
#include <bits/uClibc_uintmaxtostr.h>
-
-#define __PRINTF_INFO_NO_BITFIELD
#include <printf.h>
#ifdef __UCLIBC_HAS_THREADS__