diff options
author | Manoj Srivastava <srivasta@golden-gryphon.com> | 2014-04-27 18:05:39 -0700 |
---|---|---|
committer | Manoj Srivastava <srivasta@golden-gryphon.com> | 2014-04-27 18:05:39 -0700 |
commit | 7d4c02d5c9108aa413fbb0ffa1dc8a39bc5f54a1 (patch) | |
tree | 2abb9ad01d397bc1e208f57f528c1ec529761392 /mcon/U/intsize.U | |
parent | 5c913c35c09a82eead2c07534baa709a5dead3e7 (diff) | |
parent | 8f5e5726134ce5b4bd436b16f367796d851df553 (diff) |
Merge branch 'upstream'
Signed-off-by: Manoj Srivastava <srivasta@golden-gryphon.com>
Conflicts:
jmake/jmake.man
Diffstat (limited to 'mcon/U/intsize.U')
-rw-r--r-- | mcon/U/intsize.U | 129 |
1 files changed, 47 insertions, 82 deletions
diff --git a/mcon/U/intsize.U b/mcon/U/intsize.U index 8f84a78..264f6b6 100644 --- a/mcon/U/intsize.U +++ b/mcon/U/intsize.U @@ -1,27 +1,14 @@ -?RCS: $Id: intsize.U 1 2006-08-24 12:32:52Z rmanfredi $ +?RCS: $Id: intsize.U 167 2013-05-08 17:58:00Z rmanfredi $ ?RCS: -?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi +?RCS: Copyright (c) 1991-1997, 2004-2006, 2012 Raphael Manfredi ?RCS: -?RCS: You may redistribute only under the terms of the Artistic Licence, +?RCS: You may redistribute only under the terms of the Artistic License, ?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: that same Artistic License; a copy of which may be found at the root ?RCS: of the source tree for dist 4.0. ?RCS: -?RCS: $Log: intsize.U,v $ -?RCS: Revision 3.0.1.2 1997/02/28 15:55:26 ram -?RCS: patch61: avoid prompting the user if the test runs ok -?RCS: patch61: moved code from longsize.U into there -?RCS: patch61: new tests for shortsize as well -?RCS: -?RCS: Revision 3.0.1.1 1994/10/29 16:21:06 ram -?RCS: patch36: added ?F: line for metalint file checking -?RCS: -?RCS: Revision 3.0 1993/08/18 12:08:52 ram -?RCS: Baseline for dist 3.0 netwide release. -?RCS: -?MAKE:intsize longsize shortsize: \ - Myread cat rm +cc +optimize +ccflags +ldflags +libs +?MAKE:intsize longsize shortsize: Assert Myread cat rm +cc +ccflags echo n c ?MAKE: -pick add $@ %< ?S:intsize: ?S: This variable contains the value of the INTSIZE symbol, which @@ -47,78 +34,56 @@ ?C: This symbol contains the value of sizeof(short) so that the C ?C: preprocessor can make decisions based on it. ?C:. -?H:#define INTSIZE $intsize /**/ -?H:#define LONGSIZE $longsize /**/ -?H:#define SHORTSIZE $shortsize /**/ +?H:#define INTSIZE $intsize +?H:#define LONGSIZE $longsize +?H:#define SHORTSIZE $shortsize ?H:. -?F:!intsize.out !intsize +?T:types t size var +?LINT: set shortsize intsize longsize : check for lengths of integral types echo " " -case "$intsize" in -'') - echo "Checking to see how big your integers are..." >&4 - $cat >intsize.c <<'EOCP' -#include <stdio.h> -int main() -{ -@if INTSIZE || intsize - printf("intsize=%d;\n", sizeof(int)); -@end -@if LONGSIZE || longsize - printf("longsize=%d;\n", sizeof(long)); -@end +types='' @if SHORTSIZE || shortsize - printf("shortsize=%d;\n", sizeof(short)); +types="$types short" @end - fflush(stdout); - exit(0); -} -EOCP -# If $libs contains -lsfio, and sfio is mis-configured, then it -# sometimes (apparently) runs and exits with a 0 status, but with no -# output!. Thus we check with test -s whether we actually got any -# output. I think it has to do with sfio's use of _exit vs. exit, -# but I don't know for sure. --Andy Dougherty 1/27/97. - if $cc $optimize $ccflags $ldflags -o intsize intsize.c $libs >/dev/null 2>&1 && - ./intsize > intsize.out 2>/dev/null && test -s intsize.out ; then - eval `$cat intsize.out` @if INTSIZE || intsize - echo "Your integers are $intsize bytes long." +types="$types int" @end @if LONGSIZE || longsize - echo "Your long integers are $longsize bytes long." -@end -@if SHORTSIZE || shortsize - echo "Your short integers are $shortsize bytes long." +types="$types long" @end - else - $cat >&4 <<EOM -! -Help! I can't compile and run the intsize test program: please enlighten me! -(This is probably a misconfiguration in your system or libraries, and -you really ought to fix it. Still, I'll try anyway.) -! -EOM -@if INTSIZE || intsize - dflt=4 - rp="What is the size of an integer (in bytes)?" - . ./myread - intsize="$ans" -@end -@if LONGSIZE || longsize - dflt=$intsize - rp="What is the size of a long integer (in bytes)?" - . ./myread - longsize="$ans" -@end -@if SHORTSIZE || shortsize - dflt=2 - rp="What is the size of a short integer (in bytes)?" +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 + $cat >try.c <<EOCP +#include "static_assert.h" +$t foo; +int main() +{ + STATIC_ASSERT($size == sizeof(foo)); + return 0; +} +EOCP + if $cc -c $ccflags try.c >/dev/null 2>&1; then break; fi + done + var=${t}size + case "$size" in + error) + echo " cannot compute it." >&4 + case $t in + short) dflt=2;; + int) dflt=4;; + long) dflt=4;; + esac + rp="What is the size of the \"$t\" type (in bytes)?" . ./myread - shortsize="$ans" -@end - fi - ;; -esac -$rm -f intsize intsize.[co] intsize.out + eval $var="$ans" + ;; + *) + echo " $size bytes." >&4 + eval $var=$size + ;; + esac +done +$rm -f try.* |