This is the mail archive of the libc-alpha@sourceware.org mailing list for the glibc project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]
Other format: [Raw text]

Moving mp_limb_t initialization to compile time


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~


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]