This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Add the files from dist/meta to perl's repo
[metaconfig.git] / dist / U / ssizetype.U
CommitLineData
d8875586
MBT
1?RCS: $Id: ssizetype.U 1 2006-08-24 12:32:52Z rmanfredi $
2?RCS:
3?RCS: Copyright (c) 1991-1997, 2004-2006, Raphael Manfredi
4?RCS:
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.
10?RCS:
11?RCS: Original Author: Andy Dougherty <doughera@lafcol.lafayette.edu>
12?RCS:
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
16?RCS:
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)
20?RCS:
21?RCS: Revision 3.0.1.1 1994/08/29 16:33:06 ram
22?RCS: patch32: created by ADO
23?RCS:
24?MAKE:ssizetype: Myread Typedef sizetype cat rm \
25 +cc +optimize +ccflags +ldflags +libs _o
26?MAKE: -pick add $@ %<
27?S:ssizetype:
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).
32?S:.
33?C:SSize_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).
40?C:.
41?H:#define SSize_t $ssizetype /* signed count of bytes */
42?H:.
43?F:!ssize.out !ssize
44: see what type is used for signed size_t
45set ssize_t ssizetype int stdio.h sys/types.h
46eval $typedef
47dflt="$ssizetype"
48?X: Now check out whether sizeof(SSize_t) == sizeof(Size_t)
49$cat > ssize.c <<EOM
50#include <stdio.h>
51#include <sys/types.h>
52#define Size_t $sizetype
53#define SSize_t $dflt
54int main()
55{
56 if (sizeof(Size_t) == sizeof(SSize_t))
57 printf("$dflt\n");
58 else if (sizeof(Size_t) == sizeof(int))
59 printf("int\n");
60 else
61 printf("long\n");
62 fflush(stdout);
63 exit(0);
64}
65EOM
66echo " "
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.
72if $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
76else
77 $cat >&4 <<EOM
78Help! 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
80you really ought to fix it. Still, I'll try anyway.)
81
82I need a type that is the same size as $sizetype, but is guaranteed to
83be signed. Common values are ssize_t, int and long.
84
85EOM
86 rp="What signed type is the same size as $sizetype?"
87 . ./myread
88 ssizetype="$ans"
89fi
90$rm -f ssize ssize$_o ssize.*
91