diff options
author | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-10 15:53:21 +0000 |
---|---|---|
committer | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-10 15:53:21 +0000 |
commit | 269e631cd8201c661e2ccdd7366148968a74dbdd (patch) | |
tree | 42bbb1e9b3318392dfa255e6d8f4ccb3d33165e8 /mcon/U/ilp.U | |
parent | 8160f5523cbbb37197732ea645d02f884e180f3c (diff) |
Added integer-long-pointer architecture checks.
git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@133 2592e710-e01b-42a5-8df0-11608a6cc53d
Diffstat (limited to 'mcon/U/ilp.U')
-rw-r--r-- | mcon/U/ilp.U | 117 |
1 files changed, 117 insertions, 0 deletions
diff --git a/mcon/U/ilp.U b/mcon/U/ilp.U new file mode 100644 index 0000000..c47bc3e --- /dev/null +++ b/mcon/U/ilp.U @@ -0,0 +1,117 @@ +?RCS: +?RCS: Copyright (c) 2012 Raphael Manfredi +?RCS: +?RCS: You may redistribute only under the terms of the Artistic Licence, +?RCS: as specified in the README file that comes with the distribution. +?RCS: You may reuse parts of this distribution only within the terms of +?RCS: that same Artistic Licence; a copy of which may be found at the root +?RCS: of the source tree for dist 4.0. +?RCS: +?MAKE:ilp d_ilp32 d_ilp64 d_lp64 d_can64: Assert Myread Setvar \ + cat rm +cc +ccflags echo n c intsize longsize ptrsize +?MAKE: -pick add $@ %< +?S:ilp: +?S: This variable contains the largest amount of bits that the CPU supports, +?S: from the compiler's point of view. Typically 32 or 64. +?S:. +?S:d_ilp32: +?S: This variable conditionally defines the CPU_IS_ILP32. +?S:. +?S:d_ilp64: +?S: This variable conditionally defines the CPU_IS_ILP64. +?S:. +?S:d_lp64: +?S: This variable conditionally defines the CPU_IS_LP64. +?S:. +?S:d_can64: +?S: This variable conditionally defines CAN_HANDLE_64BITS. +?S:. +?C:CPU_ILP_MAXBITS: +?C: This symbol contains the largest amount of bits that the CPU natively +?C: supports from the compiler's point of view. Typically 32 or 64. +?C:. +?C:CPU_IS_ILP32: +?C: When defined, this indicates that the integer, long and pointer variables +?C: hold 32-bit values. +?C:. +?C:CPU_IS_ILP64: +?C: When defined, this indicates that the integer, long and pointer variables +?C: hold 64-bit values. +?C:. +?C:CPU_IS_LP64: +?C: When defined, this indicates that the long and pointer variables hold +?C: 64-bit values but integers are smaller (probably only 32-bit wide). +?C:. +?C:CAN_HANDLE_64BITS: +?C: When defined, this indicates that the compiler can handle 64-bit values +?C: despite the CPU having only 32-bit registers. These are available using +?C: the "long long" C type. It is only defined for ILP32 machines, since +?C: 64-bit support is naturally available on ILP64 and LP64 machines. +?C:. +?H:#define CPU_ILP_MAXBITS $ilp +?H:#$d_ilp32 CPU_IS_ILP32 /**/ +?H:#$d_ilp64 CPU_IS_ILP64 /**/ +?H:#$d_lp64 CPU_IS_LP64 /**/ +?H:#$d_can64 CAN_HANDLE_64BITS /**/ +?H:. +?LINT: set d_ilp32 d_ilp64 d_lp64 d_can64 +: check for architecture type +echo " " +$echo $n "Computing CPU architecture type...$c" >&4 +ilp=`expr $longsize \* 8` +case "$ptrsize" in +8) + val=$undef; set d_ilp32; eval $setvar + case "$intsize" in + 8) + echo " ILP64." >&4 + val=$define; set d_ilp64; eval $setvar + val=$undef; set d_lp64; eval $setvar + ;; + *) + echo " LP64." >&4 + val=$define; set d_lp64; eval $setvar + val=$undef; set d_ilp64; eval $setvar + ;; + esac + ;; +*) + echo " ILP${ilp}." >&4 + case "$ilp" in + 32) val=$define;; + *) val=$undef;; + esac + set d_ilp32; eval $setvar + val=$undef; set d_ilp64; eval $setvar + val=$undef; set d_lp64; eval $setvar + ;; +esac + +@if CAN_HANDLE_64BITS || d_can64 +: see whether compiler supports 64-bit emulation +case "$ilp" in +64) ;; +*) + $cat >try.c <<EOCP +#include "static_assert.h" +long long foo; +int main() +{ + STATIC_ASSERT(8 == sizeof(foo)); + return 0; +} +EOCP + if $cc -c $ccflags try.c >/dev/null 2>&1; then + echo " " + echo "Your compiler also supports 64-bit emulation." >&4 + val=$define + else + val=$undef + fi + set d_can64 + eval $setvar + $rm -f try.* + ;; +esac + +@end |