1 ?RCS: $Id: ssizetype.U 1 2006-08-24 12:32:52Z rmanfredi $
3 ?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
5 ?RCS: You may redistribute only under the terms of the Artistic Licence,
6 ?RCS: as specified in the README file that comes with the distribution.
7 ?RCS: You may reuse parts of this distribution only within the terms of
8 ?RCS: that same Artistic Licence; a copy of which may be found at the root
9 ?RCS: of the source tree for dist 4.0.
11 ?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
13 ?RCS: $Log: ssizetype.U,v $
14 ?RCS: Revision 3.0.1.3 1997/02/28 16:24:21 ram
15 ?RCS: patch61: integrated perl5 concerns for mis-configured sfio
17 ?RCS: Revision 3.0.1.2 1994/10/29 16:30:28 ram
18 ?RCS: patch36: added ?F: line for metalint file checking
19 ?RCS: patch36: added 'ldflags' to the test compile line (ADO)
21 ?RCS: Revision 3.0.1.1 1994/08/29 16:33:06 ram
22 ?RCS: patch32: created by ADO
24 ?MAKE:ssizetype: Myread Typedef sizetype cat rm \
25 +cc +optimize +ccflags +ldflags +libs _o
26 ?MAKE: -pick add $@ %<
28 ?S: This variable defines ssizetype to be something like ssize_t,
29 ?S: long or int. It is used by functions that return a count
30 ?S: of bytes or an error condition. It must be a signed type.
31 ?S: We will pick a type such that sizeof(SSize_t) == sizeof(Size_t).
34 ?C: This symbol holds the type used by functions that return
35 ?C: a count of bytes or an error condition. It must be a signed type.
36 ?C: It is usually ssize_t, but may be long or int, etc.
37 ?C: It may be necessary to include <sys/types.h> or <unistd.h>
38 ?C: to get any typedef'ed information.
39 ?C: We will pick a type such that sizeof(SSize_t) == sizeof(Size_t).
41 ?H:#define SSize_t $ssizetype /* signed count of bytes */
44 : see what type is used for signed size_t
45 set ssize_t ssizetype int stdio.h sys/types.h
48 ?X: Now check out whether sizeof(SSize_t) == sizeof(Size_t)
51 #include <sys/types.h>
52 #define Size_t $sizetype
56 if (sizeof(Size_t) == sizeof(SSize_t))
58 else if (sizeof(Size_t) == sizeof(int))
67 ?X: If $libs contains -lsfio, and sfio is mis-configured, then it
68 ?X: sometimes (apparently) runs and exits with a 0 status, but with no
69 ?X: output!. Thus we check with test -s whether we actually got any
70 ?X: output. I think it has to do with sfio's use of _exit vs. exit,
71 ?X: but I don't know for sure. --Andy Dougherty 1/27/97.
72 if $cc $optimize $ccflags $ldflags -o ssize ssize.c $libs > /dev/null 2>&1 &&
73 ./ssize > ssize.out 2>/dev/null && test -s ssize.out ; then
74 ssizetype=`$cat ssize.out`
75 echo "I'll be using $ssizetype for functions returning a byte count." >&4
78 Help! I can't compile and run the ssize_t test program: please enlighten me!
79 (This is probably a misconfiguration in your system or libraries, and
80 you really ought to fix it. Still, I'll try anyway.)
82 I need a type that is the same size as $sizetype, but is guaranteed to
83 be signed. Common values are ssize_t, int and long.
86 rp="What signed type is the same size as $sizetype?"
90 $rm -f ssize ssize$_o ssize.*