perl5.000 patch.0o: [address] a few more Configure and build nits.
[p5sagit/p5-mst-13.2.git] / U / mallocsrc.U
index 3fc4ee7..6762f90 100644 (file)
@@ -1,13 +1,4 @@
-?X:  These units are based on the ones supplied with dist-3.0
-?X:  patchlevel 22.  They have been changed or enhanced to work with
-?X:  perl5alpha.  I would appreciate hearing about any changes,
-?X:  corrections, or enhancements.
-?X:    Andy Dougherty                  doughera@lafcol.lafayette.edu
-?X:    Dept. of Physics                
-?X:    Lafayette College       
-?X:    Easton, PA  18042-1782
-?X:     Sat Apr  2 15:45:17 EST 1994
-?RCS: $Id: mallocsrc.U,v 3.0 1993/08/18 12:09:12 ram Exp $
+?RCS: $Id: mallocsrc.U,v 3.0.1.1 1994/05/06 15:10:46 ram Exp $
 ?RCS:
 ?RCS: Copyright (c) 1991-1993, Raphael Manfredi
 ?RCS: 
 ?RCS: of the source tree for dist 3.0.
 ?RCS:
 ?RCS: $Log: mallocsrc.U,v $
+?RCS: Revision 3.0.1.1  1994/05/06  15:10:46  ram
+?RCS: patch23: added support for MYMALLOC, mainly  for perl5 (ADO)
+?RCS:
 ?RCS: Revision 3.0  1993/08/18  12:09:12  ram
 ?RCS: Baseline for dist 3.0 netwide release.
 ?RCS:
-?MAKE:mallocsrc mallocobj usemymalloc malloctype: Myread Oldconfig package \
-       Guess test rm cat +cc +ccflags Findhdr
+?MAKE:mallocsrc mallocobj usemymalloc malloctype d_mymalloc \
+       freetype: Myread \
+       Oldconfig package Guess Setvar rm cat +cc +ccflags Findhdr \
+       i_malloc i_stdlib sed libs
 ?MAKE: -pick add $@ %<
 ?S:usemymalloc:
 ?S:    This variable contains y if the malloc that comes with this package
 ?S:    is desired over the system's version of malloc.  People often include
 ?S:    special versions of malloc for effiency, but such versions are often
 ?S:    less portable.  See also mallocsrc and mallocobj.
+?S:    If this is 'y', then -lmalloc is removed from $libs.
 ?S:.
 ?S:mallocsrc:
 ?S:    This variable contains the name of the malloc.c that comes with
 ?S:    Otherwise the value is null.  This variable is intended for generating
 ?S:    Makefiles.
 ?S:.
+?S:d_mymalloc:
+?S:    This variable conditionally defines MYMALLOC in case other parts
+?S:    of the source want to take special action if MYMALLOC is used.
+?S:    This may include different sorts of profiling or error detection.
+?S:.
 ?S:mallocobj:
 ?S:    This variable contains the name of the malloc.o that this package
 ?S:    generates, if that malloc.o is preferred over the system malloc.
 ?S:    Otherwise the value is null.  This variable is intended for generating
 ?S:    Makefiles.  See mallocsrc.
 ?S:.
+?S:freetype:
+?S:    This variable contains the return type of free().  It is usually
+?S: void, but occasionally int.
+?S:.
 ?S:malloctype:
 ?S:    This variable contains the kind of ptr returned by malloc and realloc.
 ?S:.
+?C:Free_t:
+?C:    This variable contains the return type of free().  It is usually
+?C: void, but occasionally int.
+?C:.
 ?C:Malloc_t (MALLOCPTRTYPE):
 ?C:    This symbol is the type of pointer returned by malloc and realloc.
 ?C:.
 ?H:#define Malloc_t $malloctype                        /**/
+?H:#define Free_t $freetype                    /**/
 ?H:.
+?C:MYMALLOC:
+?C:    This symbol, if defined, indicates that we're using our own malloc.
+?C:.
+?H:#$d_mymalloc MYMALLOC                       /**/
+?H:.
+?LINT:change libs
 ?X: Cannot test for mallocsrc; it is the unit's name and there is a bug in
 ?X: the interpreter which defines all the names, even though they are not used.
 @if mallocobj
 : determine which malloc to compile in
-:  Old versions had dflt='y' only for bsd or v7.
 echo " "
 case "$usemymalloc" in
-'')
-       if bsd || v7; then
-               dflt='y'
-       else
-               dflt='y'
-       fi
-       ;;
-*)  dflt="$usemymalloc"
-       ;;
+''|y*|true)    dflt='y' ;;
+n*|false)      dflt='n' ;;
+*)     dflt="$usemymalloc" ;;
 esac
 rp="Do you wish to attempt to use the malloc that comes with $package?"
 . ./myread
 usemymalloc="$ans"
 case "$ans" in
-y*) mallocsrc='malloc.c'; mallocobj='malloc.o';;
-*) mallocsrc=''; mallocobj='';;
+y*|true)
+       usemymalloc='y'
+       mallocsrc='malloc.c'
+       mallocobj='malloc.o'
+       d_mymalloc="$define"
+?X:    Maybe libs.U should be dependent on mallocsrc.U, but then
+?X:    most packages that use dist probably don't supply their own
+?X:    malloc, so this is probably an o.k. comprpomise
+       case "$libs" in
+       *-lmalloc*)
+               : Remove malloc from list of libraries to use
+               echo "Removing unneeded -lmalloc from library list" >&4
+               set `echo X $libs | $sed -e 's/-lmalloc / /' -e 's/-lmalloc$//'`
+               shift
+               libs="$*"
+               echo "libs = $libs" >&4
+               ;;
+       esac
+       ;;
+*)
+       usemymalloc='n'
+       mallocsrc=''
+       mallocobj=''
+       d_mymalloc="$undef"
+       ;;
 esac
 
 @end
-@if MALLOCPTRTYPE || Malloc_t
-: compute the type returned by malloc
+@if MALLOCPTRTYPE || Malloc_t || Free_t
+: compute the return types of malloc and free
 echo " "
-case "$malloctype" in
-'')
-       if $test `./findhdr malloc.h`; then
-               echo "#include <malloc.h>" > malloc.c
-       fi
+$cat >malloc.c <<END
+#$i_malloc I_MALLOC
+#$i_stdlib I_STDLIB
+#include <stdio.h>
+#include <sys/types.h>
+#ifdef I_MALLOC
 #include <malloc.h>
-       $cat >>malloc.c <<'END'
+#endif
+#ifdef I_STDLIB
+#include <stdlib.h>
+#endif
+#ifdef TRY_MALLOC
 void *malloc();
+#endif
+#ifdef TRY_FREE
+void free();
+#endif
 END
-       if $cc $ccflags -c malloc.c >/dev/null 2>&1; then
+@if MALLOCPTRTYPE || Malloc_t
+case "$malloctype" in
+'')
+       if $cc $ccflags -c -DTRY_MALLOC malloc.c >/dev/null 2>&1; then
                malloctype='void *'
        else
                malloctype='char *'
        fi
-       $rm -f malloc.[co]
        ;;
 esac
 echo "Your system wants malloc to return '$malloctype', it would seem." >&4
+@end
 
+@if Free_t
+case "$freetype" in
+'')
+       if $cc $ccflags -c -DTRY_FREE malloc.c >/dev/null 2>&1; then
+               freetype='void'
+       else
+               freetype='int'
+       fi
+       ;;
+esac
+echo "Your system uses $freetype free(), it would seem." >&4
+@end
+$rm -f malloc.[co]
 @end