From f0d5c576f73efed254eaa77ad270afa6efe6026c Mon Sep 17 00:00:00 2001 From: Mike Frysinger Date: Wed, 8 Mar 2006 03:58:13 +0000 Subject: macro out the /10 operation so arches can have their own versions ... and create some default macros for do_rem/do_div_10 so we dont duplicate the samething in many arch header files --- ldso/include/dl-string.h | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) (limited to 'ldso/include') diff --git a/ldso/include/dl-string.h b/ldso/include/dl-string.h index ec098d2ca..a50cfd6b3 100644 --- a/ldso/include/dl-string.h +++ b/ldso/include/dl-string.h @@ -11,6 +11,14 @@ #include /* for do_rem */ #include +/* provide some sane defaults */ +#ifndef do_rem +# define do_rem(result, n, base) ((result) = (n) % (base)) +#endif +#ifndef do_div_10 +# define do_div_10(result, remain) ((result) /= 10) +#endif + static size_t _dl_strlen(const char * str); static char *_dl_strcat(char *dst, const char *src); static char * _dl_strcpy(char * dst,const char *src); @@ -234,7 +242,7 @@ static __always_inline char * _dl_simple_ltoa(char * local, unsigned long i) char temp; do_rem(temp, i, 10); *--p = '0' + temp; - i /= 10; + do_div_10(i, temp); } while (i > 0); return p; } @@ -324,7 +332,7 @@ static __always_inline char * _dl_simple_ltoahex(char * local, unsigned long i) do { \ do_rem(v, (X), 10); \ *--tmp2 = '0' + v; \ - (X) /= 10; \ + do_div_10((X), v); \ } while ((X) > 0); \ _dl_write(2, tmp2, tmp1 - tmp2 + sizeof(tmp) - 1); \ } -- cgit v1.2.3