summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorDominic Dunlop <domo@computer.org>1998-07-02 22:57:26 +0000
committerGurusamy Sarathy <gsar@cpan.org>1998-07-04 05:22:41 +0000
commit38ac2dc8b9ef312238d19f03f1ce779224b04154 (patch)
treeeb13eec6af09065421e3de6d255b5f9e860f2d9f /malloc.c
parent411d5715b3cb26f927bf38fdb0914c2fef9fb906 (diff)
downloadperl-38ac2dc8b9ef312238d19f03f1ce779224b04154.tar.gz
Make Power MachTen use vfork and perl's malloc
Message-Id: <v03110701b1c1603eae52@[195.95.102.68]> p4raw-id: //depot/perl@1298
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c38
1 files changed, 31 insertions, 7 deletions
diff --git a/malloc.c b/malloc.c
index ea00e5a5e5..a12f768a98 100644
--- a/malloc.c
+++ b/malloc.c
@@ -51,10 +51,17 @@
# Use table lookup to decide in which bucket a given allocation will go.
SMALL_BUCKET_VIA_TABLE !NO_FANCY_MALLOC
- # Use system-malloc() to emulate sbrk(). Normally only used with broken
- # sbrk()s.
+ # Use a perl-defined sbrk() instead of the (presumably broken or
+ # missing) system-supplied sbrk().
+ USE_PERL_SBRK undef
+
+ # Use system malloc() (or calloc() etc.) to emulate sbrk(). Normally
+ # only used with broken sbrk()s.
PERL_SBRK_VIA_MALLOC undef
+ # Which allocator to use if PERL_SBRK_VIA_MALLOC
+ SYSTEM_ALLOC(a) malloc(a)
+
# Disable memory overwrite checking with DEBUGGING. Memory and speed
# optimization, error reporting pessimization.
NO_RCHECK undef
@@ -94,9 +101,6 @@
# This many continuous sbrk()s compensate for one discontinuous one.
SBRK_FAILURE_PRICE 50
- # Which allocator to use if PERL_SBRK_VIA_MALLOC
- SYSTEM_ALLOC(a) malloc(a)
-
This implementation assumes that calling PerlIO_printf() does not
result in any memory allocation calls (used during a panic).
@@ -1546,9 +1550,27 @@ dump_mstats(char *s)
# define PERL_SBRK_VIA_MALLOC
# endif
+# ifdef __MACHTEN_PPC__
+# define PERL_SBRK_VIA_MALLOC
+/*
+ * MachTen's malloc() returns a buffer aligned on a two-byte boundary.
+ * While this is adequate, it may slow down access to longer data
+ * types by forcing multiple memory accesses. It also causes
+ * complaints when RCHECK is in force. So we allocate six bytes
+ * more than we need to, and return an address rounded up to an
+ * eight-byte boundary.
+ *
+ * 980701 Dominic Dunlop <domo@computer.org>
+ */
+# define SYSTEM_ALLOC(a) ((void *)(((unsigned)malloc((a)+6)+6)&~7))
+# endif
+
# ifdef PERL_SBRK_VIA_MALLOC
# if defined(HIDEMYMALLOC) || defined(EMBEDMYMALLOC)
-# undef malloc
+# undef malloc /* Expose names that */
+# undef calloc /* HIDEMYMALLOC hides */
+# undef realloc
+# undef free
# else
# include "Error: -DPERL_SBRK_VIA_MALLOC needs -D(HIDE|EMBED)MYMALLOC"
# endif
@@ -1558,7 +1580,9 @@ dump_mstats(char *s)
/* frequent core dumps within nxzonefreenolock. This sbrk routine put an */
/* end to the cores */
-# define SYSTEM_ALLOC(a) malloc(a)
+# ifndef SYSTEM_ALLOC
+# define SYSTEM_ALLOC(a) malloc(a)
+# endif
# endif /* PERL_SBRK_VIA_MALLOC */