From 7a04c368ffe1993810d92011351e3c36855b9103 Mon Sep 17 00:00:00 2001 From: Samy Al Bahra Date: Sat, 15 Sep 2012 14:39:14 -0400 Subject: [PATCH] build: Add VMA bits detection for Mac OS X and Linux on x86*. --- configure | 43 ++++++++++++++++++++++++++++++++++++++++--- include/ck_md.h.in | 4 ++++ 2 files changed, 44 insertions(+), 3 deletions(-) diff --git a/configure b/configure index 3c80559..942dce0 100755 --- a/configure +++ b/configure @@ -92,7 +92,9 @@ generate() -e "s#@MANDIR@#$MANDIR#g" \ -e "s#@GZIP@#$GZIP#g" \ -e "s#@GZIP_SUFFIX@#$GZIP_SUFFIX#g" \ - -e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \ + -e "s#@POINTER_PACK_ENABLE@#$POINTER_PACK_ENABLE#g" \ + -e "s#@VMA_BITS@#$VMA_BITS_R#g" \ + -e "s#@VMA_BITS_VALUE@#$VMA_BITS_VALUE_R#g" \ $1 > $2 } @@ -109,8 +111,9 @@ generate_stdout() echo " LD = $LD" echo " LDFLAGS = $LDFLAGS" echo " GZIP = $GZIP" - echo " POINTER_PACK = $POINTER_PACK_ENABLE" echo " CORES = $CORES" + echo " POINTER_PACK = $POINTER_PACK_ENABLE" + echo " VMA_BITS = $VMA_BITS" echo echo "Headers will be installed in $HEADERS" echo "Libraries will be installed in $LIBRARY" @@ -136,6 +139,7 @@ for option in $*; do echo "The following options will modify code generation." echo " --cores=N Specify number of cores available on target machine" echo " --enable-pointer-packing Assumes 48-bit address encoding" + echo " --vma-bits=N Specify valid number of VMA bits" echo echo "The following environment variables may be used:" echo " CC C compiler command" @@ -146,6 +150,9 @@ for option in $*; do echo "Report bugs to ${MAINTAINER}." exit $EXIT_SUCCESS ;; + --vma-bits=*) + VMA_BITS=$value + ;; --enable-pointer-packing) POINTER_PACK_ENABLE="CK_MD_POINTER_PACK_ENABLE" ;; @@ -336,6 +343,37 @@ esac assert "$PLATFORM" "$PLATFORM" "unsupported" +printf "Detecting VMA bits..............." +if test "$VMA_BITS" = ""; then + if test "$PLATFORM" = "x86" || test $PLATFORM = "x86_64"; then + case $SYSTEM in + darwin) + VMA=`sysctl -n machdep.cpu.address_bits.virtual` + ;; + linux) + VMA=`awk '/address sizes/ {print $7;exit}' /proc/cpuinfo` + ;; + *) + VMA="unknown" + ;; + esac + fi + + VMA_BITS=$VMA +else + VMA=$VMA_BITS +fi + +if test "$VMA" = "unknown"; then + echo "unknown" + VMA_BITS_R="CK_MD_VMA_BITS_UNKNOWN" + VMA_BITS_VALUE_R="" +else + echo "success [$VMA]" + VMA_BITS_R="CK_MD_VMA_BITS" + VMA_BITS_VALUE_R="${VMA_BITS}ULL" +fi + # Platform will be used as a macro. PROFILE="${PROFILE:-$PLATFORM}" PLATFORM="__${PLATFORM}__" @@ -380,7 +418,6 @@ if test -z "$CC" -o ! -x "$CC"; then fi assert "$CC" "not found" -# Make sure GCC 4.X, the only supported compiler, is being used. cat << EOF > .1.c #include int main(void) { diff --git a/include/ck_md.h.in b/include/ck_md.h.in index a4bb9a5..6f3ab8d 100644 --- a/include/ck_md.h.in +++ b/include/ck_md.h.in @@ -39,4 +39,8 @@ #define @POINTER_PACK_ENABLE@ #endif +#ifndef @VMA_BITS@ +#define @VMA_BITS@ @VMA_BITS_VALUE@ +#endif + #endif /* _CK_MD_H */