diff options
Diffstat (limited to 'mcon/U/ptrsize.U')
-rw-r--r-- | mcon/U/ptrsize.U | 53 |
1 files changed, 53 insertions, 0 deletions
diff --git a/mcon/U/ptrsize.U b/mcon/U/ptrsize.U new file mode 100644 index 0000000..24a733b --- /dev/null +++ b/mcon/U/ptrsize.U @@ -0,0 +1,53 @@ +?RCS: $Id: ptrsize.U 167 2013-05-08 17:58:00Z rmanfredi $ +?RCS: +?RCS: Copyright (c) 1991-1997, 2004-2006, 2012 Raphael Manfredi +?RCS: +?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 License; a copy of which may be found at the root +?RCS: of the source tree for dist 4.0. +?RCS: +?MAKE:ptrsize: Assert Myread cat rm +cc +ccflags echo n c +?MAKE: -pick add $@ %< +?S:ptrsize: +?S: This variable contains the value of the PTRSIZE symbol, which +?S: indicates to the C program how many bytes there are in a pointer. +?S:. +?C:PTRSIZE: +?C: This symbol contains the size of a pointer, so that the C preprocessor +?C: can make decisions based on it. +?C:. +?H:#define PTRSIZE $ptrsize +?H:. +?T:size +: check for length of pointer +echo " " +$echo $n "Checking to see how big your pointers are...$c" >&4 +for size in 2 4 8 16 error; do + $cat >try.c <<EOCP +#include "static_assert.h" +char *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 +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" + ;; +*) + echo " $size bytes." >&4 + ptrsize=$size + ;; +esac +$rm -f try.* + |