autoconf
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Test for native (fast) 64-bit integer type?


From: lennox
Subject: Test for native (fast) 64-bit integer type?
Date: Mon, 31 Mar 2014 17:46:23 -0400

Hi --

Does anyone have any idea as to how one could write an Autoconf test to
check whether long long (or int64_t, or whatever) is implemented natively,
and so is likely to be fast, as opposed to being emulated by the compiler as
a pair of 32-bit values?

(SIZEOF_LONG == 8 || SIZEOF_VOID_P == 8) would seem to reflect it with high
probability, but a) wouldn't detect x32, MIPS n32, and the like (i.e., ILP32
ABIs on 64-bit CPUs), and b) is out of the "spirit" of Autoconf tests, since
it's not actually detecting the thing we're looking for.

I could check whether compiling [long long foo(long long x, long long y) {
return x/y;}] uses any external functions, or call AC_CHECK_FUNC([__lldiv]),
but this also seems fragile (and in the latter case GCC-specific, unless I
want to catalog every compiler runtime's long long division routine).

Does anyone have any thoughts about the best way to detect this feature
directly?

(The motivation is tight-loop math operations that on 32-bit architectures
can be implemented more efficiently than using most compilers' generic
emulated 64-bit math routines, but on 64-bit architectures should just use
native 64-bit operations.)

-- 
Jonathan Lennox
address@hidden



reply via email to

[Prev in Thread] Current Thread [Next in Thread]