- Use inline function instead of macro.

svn path=/trunk/; revision=16803
This commit is contained in:
Alex Ionescu 2005-07-27 16:34:14 +00:00
parent 5af8e51ad1
commit 52973bb61c
2 changed files with 22 additions and 19 deletions

View file

@ -20,14 +20,7 @@
* Wirzenius wrote this portably, Torvalds fucked it up :-) * Wirzenius wrote this portably, Torvalds fucked it up :-)
*/ */
#define __NO_CTYPE_INLINES
#include <ctype.h>
#include <limits.h>
#include <ntdll.h> #include <ntdll.h>
#define NDEBUG
#include <debug.h>
#define ZEROPAD 1 /* pad with zero */ #define ZEROPAD 1 /* pad with zero */
#define SIGN 2 /* unsigned/signed long */ #define SIGN 2 /* unsigned/signed long */
@ -38,11 +31,16 @@
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \ static
int __res; \ __inline
__res = ((unsigned long long) n) % (unsigned) base; \ int
n = ((unsigned long long) n) / (unsigned) base; \ do_div(long long *n, int base)
__res; }) {
int a;
a = ((unsigned long long) *n) % (unsigned) base;
*n = ((unsigned long long) *n) / (unsigned) base;
return a;
}
static int skip_atoi(const char **s) static int skip_atoi(const char **s)
@ -94,7 +92,7 @@ number(char * buf, char * end, long long num, int base, int size, int precision,
if (num == 0) if (num == 0)
tmp[i++]='0'; tmp[i++]='0';
else while (num != 0) else while (num != 0)
tmp[i++] = digits[do_div(num,base)]; tmp[i++] = digits[do_div(&num,base)];
if (i > precision) if (i > precision)
precision = i; precision = i;
size -= precision; size -= precision;

View file

@ -37,11 +37,16 @@
#define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */ #define LARGE 64 /* use 'ABCDEF' instead of 'abcdef' */
#define do_div(n,base) ({ \ static
int __res; \ __inline
__res = ((unsigned long long) n) % (unsigned) base; \ int
n = ((unsigned long long) n) / (unsigned) base; \ do_div(long long *n, int base)
__res; }) {
int a;
a = ((unsigned long long) *n) % (unsigned) base;
*n = ((unsigned long long) *n) / (unsigned) base;
return a;
}
static int skip_atoi(const wchar_t **s) static int skip_atoi(const wchar_t **s)
@ -93,7 +98,7 @@ number(wchar_t * buf, wchar_t * end, long long num, int base, int size, int prec
if (num == 0) if (num == 0)
tmp[i++] = L'0'; tmp[i++] = L'0';
else while (num != 0) else while (num != 0)
tmp[i++] = digits[do_div(num,base)]; tmp[i++] = digits[do_div(&num,base)];
if (i > precision) if (i > precision)
precision = i; precision = i;
size -= precision; size -= precision;