diff options
author | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-10 15:55:14 +0000 |
---|---|---|
committer | rmanfredi <rmanfredi@2592e710-e01b-42a5-8df0-11608a6cc53d> | 2012-02-10 15:55:14 +0000 |
commit | d91676e0527cad5d20112690192e5197a75a065b (patch) | |
tree | d9074a70e09fe111332487ccb6ec2f0cb638aeda | |
parent | eebe137986ea89031cd490f6ec39c5617e9fd341 (diff) |
Fixed charsize.U for cross-compiling, plus random cleanup.
git-svn-id: svn://svn.code.sf.net/p/dist/code/trunk/dist@135 2592e710-e01b-42a5-8df0-11608a6cc53d
-rw-r--r-- | mcon/U/charsize.U | 46 | ||||
-rw-r--r-- | mcon/U/intsize.U | 10 | ||||
-rw-r--r-- | mcon/U/ptrsize.U | 1 |
3 files changed, 32 insertions, 25 deletions
diff --git a/mcon/U/charsize.U b/mcon/U/charsize.U index ba6b9b3..50afdd3 100644 --- a/mcon/U/charsize.U +++ b/mcon/U/charsize.U @@ -15,7 +15,7 @@ ?RCS: Revision 3.0 1993/08/18 12:05:34 ram ?RCS: Baseline for dist 3.0 netwide release. ?RCS: -?MAKE:charsize: cat rm Myread +cc +ccflags +?MAKE:charsize: Assert Myread cat rm +cc +ccflags echo n c ?MAKE: -pick add $@ %< ?S:charsize: ?S: This variable contains the value of the CHARSIZE symbol, which @@ -25,34 +25,40 @@ ?C: This symbol contains the size of a char, so that the C preprocessor ?C: can make decisions based on it. ?C:. -?H:#define CHARSIZE $charsize /**/ +?H:#define CHARSIZE $charsize ?H:. -?F:!try +?T:size s : check for length of character echo " " -case "$charsize" in -'') - echo "Checking to see how big your characters are..." >&4 - $cat >try.c <<'EOCP' -#include <stdio.h> +$echo $n "Checking to see how big your characters are...$c" >&4 +for size in 1 2 4 8 error; do + $cat >try.c <<EOCP +#include "static_assert.h" +char foo; int main() { - printf("%d\n", sizeof(char)); + STATIC_ASSERT($size == sizeof(foo)); + return 0; } EOCP - if $cc $ccflags -o try try.c >/dev/null 2>&1 ; then - dflt=`./try` - else - dflt='1' - echo "(I can't seem to compile the test program. Guessing...)" - fi + if $cc -c $ccflags try.c >/dev/null 2>&1; then break; fi +done +case "$size" in +error) + echo " cannot compute it." >&4 + dflt=1 + rp="What is the size of a character (in bytes)?" + . ./myread + charsize="$ans" ;; *) - dflt="$charsize" + case "$size" in + 1) s='';; + *) s='s';; + esac + echo " $size byte$s." >&4 + charsize=$size ;; esac -rp="What is the size of a character (in bytes)?" -. ./myread -charsize="$ans" -$rm -f try.c try +$rm -f try.* diff --git a/mcon/U/intsize.U b/mcon/U/intsize.U index 362ee4d..5dcf6d3 100644 --- a/mcon/U/intsize.U +++ b/mcon/U/intsize.U @@ -39,19 +39,19 @@ ?H:#define SHORTSIZE $shortsize ?H:. ?T:types t size var -?LINT: set intsize longsize shortsize +?LINT: set shortsize intsize longsize : check for lengths of integral types echo " " types='' +@if SHORTSIZE || shortsize +types="$types short" +@end @if INTSIZE || intsize types="$types int" @end @if LONGSIZE || longsize types="$types long" @end -@if SHORTSIZE || shortsize -types="$types short" -@end for t in $types; do $echo $n "Checking to see how big your ${t}s are...$c" >&4 for size in 2 4 8 16 error; do @@ -71,9 +71,9 @@ EOCP error) echo " cannot compute it." >&4 case $t in + short) dflt=2;; int) dflt=4;; long) dflt=4;; - short) dflt=2;; esac rp="What is the size of the \"$t\" type (in bytes)?" . ./myread diff --git a/mcon/U/ptrsize.U b/mcon/U/ptrsize.U index 4e073d9..88bcd15 100644 --- a/mcon/U/ptrsize.U +++ b/mcon/U/ptrsize.U @@ -39,6 +39,7 @@ done case "$size" in error) echo " cannot compute it." >&4 + dflt=4 rp="What is the size of a pointer type (in bytes)?" . ./myread ptrsize="$ans" |