summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-07-27 07:45:08 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-07-27 07:45:08 +0000
commit773ae483b9833dec8b7ccd7abbf3ce6ed04d3d69 (patch)
treedb687340898dc77c9548f823983a4c527bd00c91
parent6055f9d42166344699550b8045e96c47c97d767c (diff)
downloadperl-773ae483b9833dec8b7ccd7abbf3ce6ed04d3d69.tar.gz
provide MakeMaker attribute PERL_MALLOC_OK that allows extensions
to call Perl_malloc() as malloc() (from Ilya Zakharevich) p4raw-id: //depot/perl@3790
-rw-r--r--ext/SDBM_File/Makefile.PL1
-rw-r--r--lib/ExtUtils/MM_Unix.pm9
-rw-r--r--lib/ExtUtils/MakeMaker.pm29
-rw-r--r--os2/OS2/REXX/Makefile.PL1
-rw-r--r--perl.h2
5 files changed, 41 insertions, 1 deletions
diff --git a/ext/SDBM_File/Makefile.PL b/ext/SDBM_File/Makefile.PL
index 749478551f..afce3f1a54 100644
--- a/ext/SDBM_File/Makefile.PL
+++ b/ext/SDBM_File/Makefile.PL
@@ -16,6 +16,7 @@ WriteMakefile(
XSPROTOARG => '-noprototypes', # XXX remove later?
VERSION_FROM => 'SDBM_File.pm',
DEFINE => $define,
+ PERL_MALLOC_OK => 1,
);
sub MY::postamble {
diff --git a/lib/ExtUtils/MM_Unix.pm b/lib/ExtUtils/MM_Unix.pm
index 248ad8b8d1..8d5646bad7 100644
--- a/lib/ExtUtils/MM_Unix.pm
+++ b/lib/ExtUtils/MM_Unix.pm
@@ -388,12 +388,18 @@ sub cflags {
$self->{CCFLAGS} .= ' -DPERL_POLLUTE ';
}
+ my $pollute = '';
+ if ($Config{usemymalloc} and $self->{PERL_MALLOC_OK}) {
+ $pollute = '$(PERL_MALLOC_DEF)';
+ }
+
return $self->{CFLAGS} = qq{
CCFLAGS = $self->{CCFLAGS}
OPTIMIZE = $self->{OPTIMIZE}
PERLTYPE = $self->{PERLTYPE}
LARGE = $self->{LARGE}
SPLIT = $self->{SPLIT}
+MPOLLUTE = $pollute
};
}
@@ -450,7 +456,7 @@ sub const_cccmd {
return '' unless $self->needs_linking();
return $self->{CONST_CCCMD} =
q{CCCMD = $(CC) -c $(INC) $(CCFLAGS) $(OPTIMIZE) \\
- $(PERLTYPE) $(LARGE) $(SPLIT) $(DEFINE_VERSION) \\
+ $(PERLTYPE) $(LARGE) $(SPLIT) $(MPOLLUTE) $(DEFINE_VERSION) \\
$(XS_DEFINE_VERSION)};
}
@@ -535,6 +541,7 @@ VERSION_MACRO = VERSION
DEFINE_VERSION = -D\$(VERSION_MACRO)=\\\"\$(VERSION)\\\"
XS_VERSION_MACRO = XS_VERSION
XS_DEFINE_VERSION = -D\$(XS_VERSION_MACRO)=\\\"\$(XS_VERSION)\\\"
+PERL_MALLOC_DEF = -DPERL_EXTMALLOC_DEF -Dmalloc=Perl_malloc -Dfree=Perl_mfree -Drealloc=Perl_realloc -Dcalloc=Perl_calloc
};
push @m, qq{
diff --git a/lib/ExtUtils/MakeMaker.pm b/lib/ExtUtils/MakeMaker.pm
index ad1944c46f..6318d0eed1 100644
--- a/lib/ExtUtils/MakeMaker.pm
+++ b/lib/ExtUtils/MakeMaker.pm
@@ -250,6 +250,7 @@ sub full_setup {
INST_HTMLLIBDIR INST_HTMLSCRIPTDIR
INST_MAN1DIR INST_MAN3DIR INST_SCRIPT LDFROM LIB LIBPERL_A LIBS
LINKTYPE MAKEAPERL MAKEFILE MAN1PODS MAN3PODS MAP_TARGET MYEXTLIB
+ PERL_MALLOC_OK
NAME NEEDS_LINKING NOECHO NORECURS NO_VC OBJECT OPTIMIZE PERL PERLMAINCC
PERL_ARCHLIB PERL_LIB PERL_SRC PERM_RW PERM_RWX
PL_FILES PM PMLIBDIRS POLLUTE PPM_INSTALL_EXEC PPM_INSTALL_SCRIPT PREFIX
@@ -1484,6 +1485,34 @@ Directory, where executable files should be installed during
testing. make install will copy the files in INST_SCRIPT to
INSTALLSCRIPT.
+=item PERL_MALLOC_OK
+
+defaults to 0. Should be set to TRUE if the extension can work with
+the memory allocation routines substituted by the Perl malloc() subsystem.
+This should be applicable to most extensions with exceptions of those
+
+=over
+
+=item *
+
+with bugs in memory allocations which are caught by Perl's malloc();
+
+=item *
+
+which interact with the memory allocator in other ways than via
+malloc(), realloc(), free(), calloc(), sbrk() and brk();
+
+=item *
+
+which rely on special alignment which is not provided by Perl's malloc().
+
+=back
+
+B<NOTE.> Negligence to set this flag in I<any one> of loaded extension
+nullifies many advantages of Perl's malloc(), such as better usage of
+system resources, error detection, memory usage reporting, catchable failure
+of memory allocations, etc.
+
=item LDFROM
defaults to "$(OBJECT)" and is used in the ld command to specify
diff --git a/os2/OS2/REXX/Makefile.PL b/os2/OS2/REXX/Makefile.PL
index 0b43a36612..5eda5a35d1 100644
--- a/os2/OS2/REXX/Makefile.PL
+++ b/os2/OS2/REXX/Makefile.PL
@@ -5,4 +5,5 @@ WriteMakefile(
VERSION => '0.21',
MAN3PODS => ' ', # Pods will be built by installman.
XSPROTOARG => '-noprototypes',
+ PERL_MALLOC_OK => 1,
);
diff --git a/perl.h b/perl.h
index b8f9ae6934..7b23166305 100644
--- a/perl.h
+++ b/perl.h
@@ -502,10 +502,12 @@ register struct op *Perl_op asm(stringify(OP_IN_REGISTER));
#ifdef MYMALLOC
# ifdef PERL_POLLUTE_MALLOC
+# ifndef PERL_EXTMALLOC_DEF
# define Perl_malloc malloc
# define Perl_calloc calloc
# define Perl_realloc realloc
# define Perl_mfree free
+# endif
# else
# define EMBEDMYMALLOC /* for compatibility */
# endif