This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Moving mp_limb_t initialization to compile time
- From: Richard Henderson <rth at twiddle dot net>
- To: Siddhesh Poyarekar <siddhesh at redhat dot com>
- Cc: libc-alpha at sourceware dot org
- Date: Wed, 15 May 2013 08:45:40 -0700
- Subject: Moving mp_limb_t initialization to compile time
- References: <1368459372-2415-1-git-send-email-pcc at google dot com> <1368459372-2415-6-git-send-email-pcc at google dot com> <519114FF dot 9030501 at twiddle dot net> <CAMn1gO5AM73ZhN7rO6UnFPG9R4fmW34uhsqmAZb-E175JUBAbg at mail dot gmail dot com> <51933CEE dot 3060901 at redhat dot com> <mvmfvxoy948 dot fsf at hawking dot suse dot de> <5193A20C dot 1010306 at twiddle dot net>
On 05/15/2013 07:56 AM, Richard Henderson wrote:
> Much more useful would be figuring out a way to store the log2/exp1/exp_m1
> values as mp_limb_t's rather than strings. Then we have no runtime
> initialization at all.
Perhaps something like
#if defined(_LONG_LONG_LIMB) || __LONG_MAX__ > 0xfffffffful
# define LIMB64(L, H) 0x ## H ## L
#else
# define LIMB64(L, H) 0x ## L, 0x ## H
#endif
#define CONSTSZ(INT, F1, F2, F3, F4) LIMB64(F4, F3), LIMB64(F2, F1), INT
Then we have e.g.
static const mp1 exp1 = {
CONSTSZ(2, b7e15162, 8aed2a6a, bf715880, 9cf4f3c7)
};
Which I think is fairly readable.
The strings we have at the moment are over-long, given that we know that
FRAC is set to 128 bits. If we want to retain the extra digits for posterity,
CONSTSZ could have extra arguments which get ignored.
r~