From 8bfc5756fb68e0b13d7e7c0073ad5b9a4790d1b6 Mon Sep 17 00:00:00 2001 From: rmanfredi Date: Thu, 24 Aug 2006 12:32:52 +0000 Subject: Moving project to sourceforge. git-svn-id: https://dist.svn.sourceforge.net/svnroot/dist/trunk/dist@1 190e5f8e-a817-0410-acf6-e9863daed9af --- mcon/U/ssizetype.U | 91 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) create mode 100644 mcon/U/ssizetype.U (limited to 'mcon/U/ssizetype.U') diff --git a/mcon/U/ssizetype.U b/mcon/U/ssizetype.U new file mode 100644 index 0000000..70dcc69 --- /dev/null +++ b/mcon/U/ssizetype.U @@ -0,0 +1,91 @@ +?RCS: $Id$ +?RCS: +?RCS: Copyright (c) 1991-1997, 2004-2006, 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: +?RCS: Original Author: Andy Dougherty +?RCS: +?RCS: $Log: ssizetype.U,v $ +?RCS: Revision 3.0.1.3 1997/02/28 16:24:21 ram +?RCS: patch61: integrated perl5 concerns for mis-configured sfio +?RCS: +?RCS: Revision 3.0.1.2 1994/10/29 16:30:28 ram +?RCS: patch36: added ?F: line for metalint file checking +?RCS: patch36: added 'ldflags' to the test compile line (ADO) +?RCS: +?RCS: Revision 3.0.1.1 1994/08/29 16:33:06 ram +?RCS: patch32: created by ADO +?RCS: +?MAKE:ssizetype: Myread Typedef sizetype cat rm \ + +cc +optimize +ccflags +ldflags +libs _o +?MAKE: -pick add $@ %< +?S:ssizetype: +?S: This variable defines ssizetype to be something like ssize_t, +?S: long or int. It is used by functions that return a count +?S: of bytes or an error condition. It must be a signed type. +?S: We will pick a type such that sizeof(SSize_t) == sizeof(Size_t). +?S:. +?C:SSize_t: +?C: This symbol holds the type used by functions that return +?C: a count of bytes or an error condition. It must be a signed type. +?C: It is usually ssize_t, but may be long or int, etc. +?C: It may be necessary to include or +?C: to get any typedef'ed information. +?C: We will pick a type such that sizeof(SSize_t) == sizeof(Size_t). +?C:. +?H:#define SSize_t $ssizetype /* signed count of bytes */ +?H:. +?F:!ssize.out !ssize +: see what type is used for signed size_t +set ssize_t ssizetype int stdio.h sys/types.h +eval $typedef +dflt="$ssizetype" +?X: Now check out whether sizeof(SSize_t) == sizeof(Size_t) +$cat > ssize.c < +#include +#define Size_t $sizetype +#define SSize_t $dflt +int main() +{ + if (sizeof(Size_t) == sizeof(SSize_t)) + printf("$dflt\n"); + else if (sizeof(Size_t) == sizeof(int)) + printf("int\n"); + else + printf("long\n"); + fflush(stdout); + exit(0); +} +EOM +echo " " +?X: If $libs contains -lsfio, and sfio is mis-configured, then it +?X: sometimes (apparently) runs and exits with a 0 status, but with no +?X: output!. Thus we check with test -s whether we actually got any +?X: output. I think it has to do with sfio's use of _exit vs. exit, +?X: but I don't know for sure. --Andy Dougherty 1/27/97. +if $cc $optimize $ccflags $ldflags -o ssize ssize.c $libs > /dev/null 2>&1 && + ./ssize > ssize.out 2>/dev/null && test -s ssize.out ; then + ssizetype=`$cat ssize.out` + echo "I'll be using $ssizetype for functions returning a byte count." >&4 +else + $cat >&4 <