Commit | Line | Data |
---|---|---|
d8875586 MBT |
1 | ?RCS: $Id: mallocsrc.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: $Log: mallocsrc.U,v $ | |
12 | ?RCS: Revision 3.0.1.2 1997/02/28 16:10:26 ram | |
13 | ?RCS: patch61: added support for Free_t, the type of free() | |
14 | ?RCS: patch61: replaced .o with $_o all over the place | |
15 | ?RCS: | |
16 | ?RCS: Revision 3.0.1.1 1994/05/06 15:10:46 ram | |
17 | ?RCS: patch23: added support for MYMALLOC, mainly for perl5 (ADO) | |
18 | ?RCS: | |
19 | ?RCS: Revision 3.0 1993/08/18 12:09:12 ram | |
20 | ?RCS: Baseline for dist 3.0 netwide release. | |
21 | ?RCS: | |
22 | ?MAKE:mallocsrc mallocobj usemymalloc malloctype d_mymalloc \ | |
23 | freetype: Myread \ | |
24 | Oldconfig package Guess Setvar rm cat +cc +ccflags Findhdr \ | |
25 | i_malloc i_stdlib sed libs _o ptrsize | |
26 | ?MAKE: -pick add $@ %< | |
27 | ?X: Put near top so that other tests don't erroneously include | |
28 | ?X: -lmalloc. --AD 22 June 1998 | |
29 | ?Y:TOP | |
30 | ?S:usemymalloc: | |
31 | ?S: This variable contains y if the malloc that comes with this package | |
32 | ?S: is desired over the system's version of malloc. People often include | |
33 | ?S: special versions of malloc for effiency, but such versions are often | |
34 | ?S: less portable. See also mallocsrc and mallocobj. | |
35 | ?S: If this is 'y', then -lmalloc is removed from $libs. | |
36 | ?S:. | |
37 | ?S:mallocsrc: | |
38 | ?S: This variable contains the name of the malloc.c that comes with | |
39 | ?S: the package, if that malloc.c is preferred over the system malloc. | |
40 | ?S: Otherwise the value is null. This variable is intended for generating | |
41 | ?S: Makefiles. | |
42 | ?S:. | |
43 | ?S:d_mymalloc: | |
44 | ?S: This variable conditionally defines MYMALLOC in case other parts | |
45 | ?S: of the source want to take special action if MYMALLOC is used. | |
46 | ?S: This may include different sorts of profiling or error detection. | |
47 | ?S:. | |
48 | ?S:mallocobj: | |
49 | ?S: This variable contains the name of the malloc.o that this package | |
50 | ?S: generates, if that malloc.o is preferred over the system malloc. | |
51 | ?S: Otherwise the value is null. This variable is intended for generating | |
52 | ?S: Makefiles. See mallocsrc. | |
53 | ?S:. | |
54 | ?S:freetype: | |
55 | ?S: This variable contains the return type of free(). It is usually | |
56 | ?S: void, but occasionally int. | |
57 | ?S:. | |
58 | ?S:malloctype: | |
59 | ?S: This variable contains the kind of ptr returned by malloc and realloc. | |
60 | ?S:. | |
61 | ?C:Free_t: | |
62 | ?C: This variable contains the return type of free(). It is usually | |
63 | ?C: void, but occasionally int. | |
64 | ?C:. | |
65 | ?C:Malloc_t (MALLOCPTRTYPE): | |
66 | ?C: This symbol is the type of pointer returned by malloc and realloc. | |
67 | ?C:. | |
68 | ?H:#define Malloc_t $malloctype /**/ | |
69 | ?H:#define Free_t $freetype /**/ | |
70 | ?H:. | |
71 | ?C:MYMALLOC: | |
72 | ?C: This symbol, if defined, indicates that we're using our own malloc. | |
73 | ?C:. | |
74 | ?H:#$d_mymalloc MYMALLOC /**/ | |
75 | ?H:. | |
76 | ?LINT:change libs | |
77 | ?X: Cannot test for mallocsrc; it is the unit's name and there is a bug in | |
78 | ?X: the interpreter which defines all the names, even though they are not used. | |
79 | @if mallocobj | |
80 | : determine which malloc to compile in | |
81 | echo " " | |
82 | case "$usemymalloc" in | |
83 | [yY]*|true|$define) dflt='y' ;; | |
84 | [nN]*|false|$undef) dflt='n' ;; | |
85 | *) | |
86 | case "$ptrsize" in | |
87 | 4) dflt='y' ;; | |
88 | *) dflt='n' ;; | |
89 | esac | |
90 | ;; | |
91 | esac | |
92 | rp="Do you wish to attempt to use the malloc that comes with $package?" | |
93 | . ./myread | |
94 | usemymalloc="$ans" | |
95 | case "$ans" in | |
96 | y*|true) | |
97 | usemymalloc='y' | |
98 | mallocsrc='malloc.c' | |
99 | mallocobj="malloc$_o" | |
100 | d_mymalloc="$define" | |
101 | ?X: Maybe libs.U should be dependent on mallocsrc.U, but then | |
102 | ?X: most packages that use dist probably don't supply their own | |
103 | ?X: malloc, so this is probably an o.k. comprpomise | |
104 | case "$libs" in | |
105 | *-lmalloc*) | |
106 | : Remove malloc from list of libraries to use | |
107 | echo "Removing unneeded -lmalloc from library list" >&4 | |
108 | set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'` | |
109 | shift | |
110 | libs="$*" | |
111 | echo "libs = $libs" >&4 | |
112 | ;; | |
113 | esac | |
114 | ;; | |
115 | *) | |
116 | usemymalloc='n' | |
117 | mallocsrc='' | |
118 | mallocobj='' | |
119 | d_mymalloc="$undef" | |
120 | ;; | |
121 | esac | |
122 | ||
123 | @end | |
124 | @if MALLOCPTRTYPE || Malloc_t || Free_t | |
125 | : compute the return types of malloc and free | |
126 | echo " " | |
127 | $cat >malloc.c <<END | |
128 | #$i_malloc I_MALLOC | |
129 | #$i_stdlib I_STDLIB | |
130 | #include <stdio.h> | |
131 | #include <sys/types.h> | |
132 | #ifdef I_MALLOC | |
133 | #include <malloc.h> | |
134 | #endif | |
135 | #ifdef I_STDLIB | |
136 | #include <stdlib.h> | |
137 | #endif | |
138 | #ifdef TRY_MALLOC | |
139 | void *malloc(); | |
140 | #endif | |
141 | #ifdef TRY_FREE | |
142 | void free(); | |
143 | #endif | |
144 | END | |
145 | @if MALLOCPTRTYPE || Malloc_t | |
146 | case "$malloctype" in | |
147 | '') | |
148 | if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then | |
149 | malloctype='void *' | |
150 | else | |
151 | malloctype='char *' | |
152 | fi | |
153 | ;; | |
154 | esac | |
155 | echo "Your system wants malloc to return '$malloctype', it would seem." >&4 | |
156 | @end | |
157 | ||
158 | @if Free_t | |
159 | case "$freetype" in | |
160 | '') | |
161 | if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then | |
162 | freetype='void' | |
163 | else | |
164 | freetype='int' | |
165 | fi | |
166 | ;; | |
167 | esac | |
168 | echo "Your system uses $freetype free(), it would seem." >&4 | |
169 | @end | |
170 | $rm -f malloc.[co] | |
171 | @end |