1 /* l64a - convert long to radix-64 ascii string
3 * Conversion is performed on at most 32-bits of input value starting
4 * from least significant bits to the most significant bits.
6 * The routine splits the input value into groups of 6 bits for up to
7 * 32 bits of input. This means that the last group may be 2 bits
10 * Each group of 6 bits forms a value from 0-63 which is converted into
11 * a character as follows:
18 * When the remaining bits are zero or all 32 bits have been translated,
19 * a nul terminator is appended to the resulting string. An input value of
20 * 0 results in an empty string.
27 #ifdef _REENT_THREAD_LOCAL
28 _Thread_local
char _tls_l64a_buf
[8];
31 static const char R64_ARRAY
[] = "./0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz";
36 return _l64a_r (_REENT
, value
);
40 _l64a_r (struct _reent
*rptr
,
46 unsigned long tmp
= (unsigned long)value
& 0xffffffff;
48 _REENT_CHECK_MISC(rptr
);
49 result
= _REENT_L64A_BUF(rptr
);
52 for (i
= 0; i
< 6; ++i
)
60 index
= tmp
& (64 - 1);
61 *ptr
++ = R64_ARRAY
[index
];