2 * Handling of the int64 and uint64 types. Done in 32-bit integers,
3 * for (pre-C99) portability. Hopefully once C99 becomes widespread
4 * we can kiss this lot goodbye...
13 uint64
uint64_div10(uint64 x
, int *remainder
) {
20 * Now we have to add in the remainder left over from x.hi.
23 y
.lo
+= r2
* 2 * (0x80000000 / 10);
24 rem
+= r2
* 2 * (0x80000000 % 10);
33 void uint64_decimal(uint64 x
, char *buffer
) {
38 while (x
.hi
|| x
.lo
) {
39 x
= uint64_div10(x
, &d
);
41 buf
[--start
] = d
+ '0';
44 memcpy(buffer
, buf
+start
, sizeof(buf
)-start
);
45 buffer
[sizeof(buf
)-start
] = '\0';
48 uint64
uint64_make(unsigned long hi
, unsigned long lo
) {
55 uint64
uint64_add(uint64 x
, uint64 y
) {
57 x
.hi
+= y
.hi
+ (x
.lo
< y
.lo ?
1 : 0);
61 uint64
uint64_add32(uint64 x
, unsigned long y
) {
65 return uint64_add(x
, yy
);