strtouq on 64bit

Peter Korsgaard jacmet at sunsite.dk
Tue Mar 10 16:46:42 UTC 2009


Hi,

The bsd extension strtouq (which maps to strtoull() on 32bit and
strtoul on 64bit) is currently only available on 32bit:

i586-linux-nm -D ./libuClibc-0.9.30.so|grep strtou
00046525 T strtoul
00046769 T strtoul_l
000466ec T strtoull
000468e5 T strtoull_l
000466ec T strtoumax
000466ec T strtouq

vs:

x86_64-linux-nm -D libuClibc-0.9.30.so|grep strtou
000000000004850c T strtoul
00000000000486b4 T strtoul_l
000000000004850c T strtoull
00000000000486b4 T strtoull_l
000000000004850c T strtoumax

The following patch fixes it:
-----------------------------

[PATCH]: Add strtouq alias (to strtoul) for 64bit

The strtouq alias was only available on 32bit, breaking compilation of stuff
using strtouq on 64bit machines. At the same time use the correct return
type (u_quad_t).

Signed-of-by: Peter Korsgaard <jacmet at sunsite.dk>
---
 include/stdlib.h     |    4 +++-
 libc/stdlib/stdlib.c |    1 +
 2 files changed, 4 insertions(+), 1 deletion(-)

Index: uClibc-0.9.30.1/libc/stdlib/stdlib.c
===================================================================
--- uClibc-0.9.30.1.orig/libc/stdlib/stdlib.c
+++ uClibc-0.9.30.1/libc/stdlib/stdlib.c
@@ -401,6 +401,7 @@
 libc_hidden_proto(__XL_NPP(strtoull))
 strong_alias(__XL_NPP(strtoul),__XL_NPP(strtoull))
 libc_hidden_def(__XL_NPP(strtoull))
+strong_alias(strtoul,strtouq)
 #endif
 
 
Index: uClibc-0.9.30.1/include/stdlib.h
===================================================================
--- uClibc-0.9.30.1.orig/include/stdlib.h
+++ uClibc-0.9.30.1/include/stdlib.h
@@ -203,6 +203,8 @@
 __END_NAMESPACE_STD
 
 #ifdef __USE_BSD
+#include <sys/types.h> /* for u_quad_t */
+
 /* Convert a string to a quadword integer.  */
 __extension__
 extern long long int strtoq (__const char *__restrict __nptr,
@@ -210,7 +212,7 @@
      __THROW __nonnull ((1)) __wur;
 /* Convert a string to an unsigned quadword integer.  */
 __extension__
-extern unsigned long long int strtouq (__const char *__restrict __nptr,
+extern u_quad_t strtouq (__const char *__restrict __nptr,
 				       char **__restrict __endptr, int __base)
      __THROW __nonnull ((1)) __wur;
 #endif /* GCC and use BSD.  */

-- 
Bye, Peter Korsgaard


More information about the uClibc mailing list