perl 5.0 alpha 8
[p5sagit/p5-mst-13.2.git] / U / mallocsrc.U
1 ?X:  These units are based on the ones supplied with dist-3.0
2 ?X:  patchlevel 22.  They have been changed or enhanced to work with
3 ?X:  perl5alpha.  I would appreciate hearing about any changes,
4 ?X:  corrections, or enhancements.
5 ?X:     Andy Dougherty                  doughera@lafcol.lafayette.edu
6 ?X:     Dept. of Physics                
7 ?X:     Lafayette College       
8 ?X:     Easton, PA  18042-1782
9 ?X:     Sat Apr  2 15:45:17 EST 1994
10 ?RCS: $Id: mallocsrc.U,v 3.0 1993/08/18 12:09:12 ram Exp $
11 ?RCS:
12 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
13 ?RCS: 
14 ?RCS: You may redistribute only under the terms of the Artistic Licence,
15 ?RCS: as specified in the README file that comes with the distribution.
16 ?RCS: You may reuse parts of this distribution only within the terms of
17 ?RCS: that same Artistic Licence; a copy of which may be found at the root
18 ?RCS: of the source tree for dist 3.0.
19 ?RCS:
20 ?RCS: $Log: mallocsrc.U,v $
21 ?RCS: Revision 3.0  1993/08/18  12:09:12  ram
22 ?RCS: Baseline for dist 3.0 netwide release.
23 ?RCS:
24 ?MAKE:mallocsrc mallocobj usemymalloc malloctype: Myread Oldconfig package \
25         Guess test rm cat +cc +ccflags Findhdr
26 ?MAKE:  -pick add $@ %<
27 ?S:usemymalloc:
28 ?S:     This variable contains y if the malloc that comes with this package
29 ?S:     is desired over the system's version of malloc.  People often include
30 ?S:     special versions of malloc for effiency, but such versions are often
31 ?S:     less portable.  See also mallocsrc and mallocobj.
32 ?S:.
33 ?S:mallocsrc:
34 ?S:     This variable contains the name of the malloc.c that comes with
35 ?S:     the package, if that malloc.c is preferred over the system malloc.
36 ?S:     Otherwise the value is null.  This variable is intended for generating
37 ?S:     Makefiles.
38 ?S:.
39 ?S:mallocobj:
40 ?S:     This variable contains the name of the malloc.o that this package
41 ?S:     generates, if that malloc.o is preferred over the system malloc.
42 ?S:     Otherwise the value is null.  This variable is intended for generating
43 ?S:     Makefiles.  See mallocsrc.
44 ?S:.
45 ?S:malloctype:
46 ?S:     This variable contains the kind of ptr returned by malloc and realloc.
47 ?S:.
48 ?C:Malloc_t (MALLOCPTRTYPE):
49 ?C:     This symbol is the type of pointer returned by malloc and realloc.
50 ?C:.
51 ?H:#define Malloc_t $malloctype                 /**/
52 ?H:.
53 ?X: Cannot test for mallocsrc; it is the unit's name and there is a bug in
54 ?X: the interpreter which defines all the names, even though they are not used.
55 @if mallocobj
56 : determine which malloc to compile in
57 :  Old versions had dflt='y' only for bsd or v7.
58 echo " "
59 case "$usemymalloc" in
60 '')
61         if bsd || v7; then
62                 dflt='y'
63         else
64                 dflt='y'
65         fi
66         ;;
67 *)  dflt="$usemymalloc"
68         ;;
69 esac
70 rp="Do you wish to attempt to use the malloc that comes with $package?"
71 . ./myread
72 usemymalloc="$ans"
73 case "$ans" in
74 y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
75 *) mallocsrc=''; mallocobj='';;
76 esac
77
78 @end
79 @if MALLOCPTRTYPE || Malloc_t
80 : compute the type returned by malloc
81 echo " "
82 case "$malloctype" in
83 '')
84         if $test `./findhdr malloc.h`; then
85                 echo "#include <malloc.h>" > malloc.c
86         fi
87 #include <malloc.h>
88         $cat >>malloc.c <<'END'
89 void *malloc();
90 END
91         if $cc $ccflags -c malloc.c >/dev/null 2>&1; then
92                 malloctype='void *'
93         else
94                 malloctype='char *'
95         fi
96         $rm -f malloc.[co]
97         ;;
98 esac
99 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
100
101 @end