From 142429e5ae9ac82c3e37af759f12d058f8259e23 Mon Sep 17 00:00:00 2001 From: Aaron Carroll Date: Thu, 14 Mar 2013 16:57:39 +1100 Subject: [PATCH] configure: compile-time word size detection Signed-off-by: Aaron Carroll Signed-off-by: Jens Axboe --- configure | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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" -- 2.25.1