summaryrefslogtreecommitdiff
path: root/malloc.c
diff options
context:
space:
mode:
authorGurusamy Sarathy <gsar@cpan.org>1999-06-07 05:18:34 +0000
committerGurusamy Sarathy <gsar@cpan.org>1999-06-07 05:18:34 +0000
commit864dbfa3ca8032ef66f7aa86961933b19b962357 (patch)
tree4186157b2fc82346ec83e789b065a908a56c1641 /malloc.c
parentfdf134946da249a71c49962435817212b8fa195a (diff)
downloadperl-864dbfa3ca8032ef66f7aa86961933b19b962357.tar.gz
initial stub implementation of implicit thread/this
pointer argument; builds/tests on Solaris, win32 hasn't been fixed up yet; proto.h, global.sym and static function decls are now generated from a common database in proto.pl; some inconsistently named perl_foo() things are now Perl_foo(), compatibility #defines provided; perl_foo() (lowercase 'p') reserved for functions that take an explicit context argument; next step: generate #define foo(a,b) Perl_foo(aTHX_ a,b) p4raw-id: //depot/perl@3522
Diffstat (limited to 'malloc.c')
-rw-r--r--malloc.c45
1 files changed, 19 insertions, 26 deletions
diff --git a/malloc.c b/malloc.c
index 5a51413b7d..32c669bbe0 100644
--- a/malloc.c
+++ b/malloc.c
@@ -227,6 +227,7 @@
#ifdef PERL_CORE
# include "EXTERN.h"
+#define PERL_IN_MALLOC_C
# include "perl.h"
#else
# ifdef PERL_FOR_X2P
@@ -411,13 +412,6 @@ union overhead {
#define ov_rmagic ovu.ovu_rmagic
};
-#ifdef DEBUGGING
-static void botch (char *diag, char *s);
-#endif
-static void morecore (int bucket);
-static int findbucket (union overhead *freep, int srchlen);
-static void add_to_chain(void *p, MEM_SIZE size, MEM_SIZE chip);
-
#define MAGIC 0xff /* magic # on accounting info */
#define RMAGIC 0x55555555 /* magic # on range info */
#define RMAGIC_C 0x55 /* magic # on range info */
@@ -715,10 +709,9 @@ static char bucket_of[] =
static char *emergency_buffer;
static MEM_SIZE emergency_buffer_size;
-static Malloc_t emergency_sbrk(MEM_SIZE size);
-static Malloc_t
-emergency_sbrk(MEM_SIZE size)
+STATIC Malloc_t
+emergency_sbrk(pTHX_ MEM_SIZE size)
{
MEM_SIZE rsize = (((size - 1)>>LOG_OF_MIN_ARENA) + 1)<<LOG_OF_MIN_ARENA;
@@ -816,8 +809,8 @@ static u_int goodsbrk;
#ifdef DEBUGGING
#undef ASSERT
#define ASSERT(p,diag) if (!(p)) botch(diag,STRINGIFY(p)); else
-static void
-botch(char *diag, char *s)
+STATIC void
+botch(pTHX_ char *diag, char *s)
{
PerlIO_printf(PerlIO_stderr(), "assertion botched (%s?): %s\n", diag, s);
PerlProc_abort();
@@ -954,8 +947,8 @@ static int n_chunks;
static char max_bucket;
/* Cutoff a piece of one of the chunks in the chain. Prefer smaller chunk. */
-static void *
-get_from_chain(MEM_SIZE size)
+STATIC void *
+get_from_chain(pTHX_ MEM_SIZE size)
{
struct chunk_chain_s *elt = chunk_chain, **oldp = &chunk_chain;
struct chunk_chain_s **oldgoodp = NULL;
@@ -992,8 +985,8 @@ get_from_chain(MEM_SIZE size)
}
}
-static void
-add_to_chain(void *p, MEM_SIZE size, MEM_SIZE chip)
+STATIC void
+add_to_chain(pTHX_ void *p, MEM_SIZE size, MEM_SIZE chip)
{
struct chunk_chain_s *next = chunk_chain;
char *cp = (char*)p;
@@ -1005,8 +998,8 @@ add_to_chain(void *p, MEM_SIZE size, MEM_SIZE chip)
n_chunks++;
}
-static void *
-get_from_bigger_buckets(int bucket, MEM_SIZE size)
+STATIC void *
+get_from_bigger_buckets(pTHX_ int bucket, MEM_SIZE size)
{
int price = 1;
static int bucketprice[NBUCKETS];
@@ -1035,8 +1028,8 @@ get_from_bigger_buckets(int bucket, MEM_SIZE size)
return NULL;
}
-static union overhead *
-getpages(int needed, int *nblksp, int bucket)
+STATIC union overhead *
+getpages(pTHX_ int needed, int *nblksp, int bucket)
{
/* Need to do (possibly expensive) system call. Try to
optimize it for rare calling. */
@@ -1188,8 +1181,8 @@ getpages(int needed, int *nblksp, int bucket)
return ovp;
}
-static int
-getpages_adjacent(int require)
+STATIC int
+getpages_adjacent(pTHX_ int require)
{
if (require <= sbrked_remains) {
sbrked_remains -= require;
@@ -1232,8 +1225,8 @@ getpages_adjacent(int require)
/*
* Allocate more memory to the indicated bucket.
*/
-static void
-morecore(register int bucket)
+STATIC void
+morecore(pTHX_ register int bucket)
{
register union overhead *ovp;
register int rnu; /* 2^rnu bytes will be requested */
@@ -1613,7 +1606,7 @@ Perl_calloc(register size_t elements, register size_t size)
}
MEM_SIZE
-malloced_size(void *p)
+Perl_malloced_size(pTHX_ void *p)
{
union overhead *ovp = (union overhead *)
((caddr_t)p - sizeof (union overhead) * CHUNK_SHIFT);
@@ -1643,7 +1636,7 @@ malloced_size(void *p)
* frees for each size category.
*/
void
-dump_mstats(char *s)
+Perl_dump_mstats(pTHX_ char *s)
{
#ifdef DEBUGGING_MSTATS
register int i, j;