about summary refs log tree commit diff
path: root/sysdeps/generic
diff options
context:
space:
mode:
authorH.J. Lu <hjl.tools@gmail.com>2012-03-21 14:38:47 -0700
committerH.J. Lu <hjl.tools@gmail.com>2012-03-21 14:38:47 -0700
commit8e95c99a7a0b0ca8cf9bfbeddf1e43fb3efc1bee (patch)
tree2e038a43f7b15ea609cb9e37a98fc4f9eb8a83e0 /sysdeps/generic
parent6f4db457f8300d9d58fe5f931cdf9f54c0fde2a2 (diff)
downloadglibc-8e95c99a7a0b0ca8cf9bfbeddf1e43fb3efc1bee.tar.gz
glibc-8e95c99a7a0b0ca8cf9bfbeddf1e43fb3efc1bee.tar.xz
glibc-8e95c99a7a0b0ca8cf9bfbeddf1e43fb3efc1bee.zip
Add _ITOA_NEEDED and _ITOA_WORD_TYPE
Add _ITOA_NEEDED and _ITOA_WORD_TYPE to override _itoa and _itowa.
Diffstat (limited to 'sysdeps/generic')
-rw-r--r--sysdeps/generic/_itoa.h24
1 files changed, 20 insertions, 4 deletions
diff --git a/sysdeps/generic/_itoa.h b/sysdeps/generic/_itoa.h
index 8870ee0286..0a670431e4 100644
--- a/sysdeps/generic/_itoa.h
+++ b/sysdeps/generic/_itoa.h
@@ -21,6 +21,21 @@
 
 #include <limits.h>
 
+/* When long long is different from long, by default, _itoa_word is
+   provided to convert long to ASCII and _itoa is provided to convert
+   long long.  A sysdeps _itoa.h can define _ITOA_NEEDED to 0 and define
+   _ITOA_WORD_TYPE to unsigned long long int to override it so that
+   _itoa_word is changed to convert long long to ASCII and _itoa is
+   mapped to _itoa_word.  */
+
+#ifndef _ITOA_NEEDED
+# define _ITOA_NEEDED		(LONG_MAX != LLONG_MAX)
+#endif
+#ifndef _ITOA_WORD_TYPE
+# define _ITOA_WORD_TYPE	unsigned long int
+#endif
+
+
 /* Convert VALUE into ASCII in base BASE (2..36).
    Write backwards starting the character just before BUFLIM.
    Return the address of the first (left-to-right) character in the number.
@@ -35,11 +50,11 @@ extern const char _itoa_lower_digits[];
 extern const char _itoa_lower_digits_internal[] attribute_hidden;
 
 #ifndef NOT_IN_libc
-extern char *_itoa_word (unsigned long value, char *buflim,
+extern char *_itoa_word (_ITOA_WORD_TYPE value, char *buflim,
 			 unsigned int base, int upper_case);
 #else
 static inline char * __attribute__ ((unused, always_inline))
-_itoa_word (unsigned long value, char *buflim,
+_itoa_word (_ITOA_WORD_TYPE value, char *buflim,
 	    unsigned int base, int upper_case)
 {
   const char *digits = (upper_case
@@ -76,12 +91,13 @@ _itoa_word (unsigned long value, char *buflim,
 
 /* Similar to the _itoa functions, but output starts at buf and pointer
    after the last written character is returned.  */
-extern char *_fitoa_word (unsigned long value, char *buf, unsigned int base,
+extern char *_fitoa_word (_ITOA_WORD_TYPE value, char *buf,
+			  unsigned int base,
 			  int upper_case) attribute_hidden;
 extern char *_fitoa (unsigned long long value, char *buf, unsigned int base,
 		     int upper_case) attribute_hidden;
 
-#if LONG_MAX == LLONG_MAX
+#if !_ITOA_NEEDED
 /* No need for special long long versions.  */
 # define _itoa(value, buf, base, upper_case) \
   _itoa_word (value, buf, base, upper_case)