From: Aaron Carroll Date: Thu, 14 Mar 2013 05:57:39 +0000 (+1100) Subject: configure: compile-time word size detection X-Git-Tag: fio-2.0.15~28 X-Git-Url: https://git.kernel.dk/?a=commitdiff_plain;h=142429e5ae9ac82c3e37af759f12d058f8259e23;p=fio.git configure: compile-time word size detection Signed-off-by: Aaron Carroll Signed-off-by: Jens Axboe --- diff --git a/configure b/configure index 1fa9b635..84c6af28 100755 --- a/configure +++ b/configure @@ -348,16 +348,20 @@ echo # check for wordsize wordsize="0" cat > $TMPC < +#include +#define BUILD_BUG_ON(condition) ((void)sizeof(char[1 - 2*!!(condition)])) int main(void) { - unsigned int wsize = sizeof(long) * 8; - printf("%d\n", wsize); + BUILD_BUG_ON(sizeof(long)*CHAR_BIT != WORDSIZE); return 0; } EOF -if compile_prog "" "" "wordsize"; then - wordsize=`$TMPE` +if compile_prog "-DWORDSIZE=32" "" "wordsize"; then + wordsize="32" +elif compile_prog "-DWORDSIZE=64" "" "wordsize"; then + wordsize="64" +else + fatal "Unknown wordsize" fi echo "Wordsize $wordsize"