From ca043950974033787245ab205c256072deb11d64 Mon Sep 17 00:00:00 2001 From: Chris Hanson Date: Mon, 31 Jan 2000 03:32:45 +0000 Subject: [PATCH] Add special heap allocator for FreeBSD, much like the one used for Linux, but with small differences. --- v7/src/microcode/config.h | 10 ++++++++-- v7/src/microcode/ux.c | 31 +++++++++++++++++++++++++++++-- 2 files changed, 37 insertions(+), 4 deletions(-) diff --git a/v7/src/microcode/config.h b/v7/src/microcode/config.h index 82c35ba1f..e9517e469 100644 --- a/v7/src/microcode/config.h +++ b/v7/src/microcode/config.h @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: config.h,v 9.100 1999/01/02 06:11:34 cph Exp $ +$Id: config.h,v 9.101 2000/01/31 03:32:45 cph Exp $ -Copyright (c) 1987-1999 Massachusetts Institute of Technology +Copyright (c) 1987-2000 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -433,6 +433,12 @@ extern void * linux_heap_malloc (unsigned long); #define HEAP_FREE(address) #endif +#ifdef __FreeBSD__ +extern void * freebsd_heap_malloc (unsigned long); +#define HEAP_MALLOC freebsd_heap_malloc +#define HEAP_FREE(address) +#endif + /* !WINNT_RAW_ADDRESSES is useful only for Windows 3.1, which we no longer support -- so define it always. */ #ifdef WINNT diff --git a/v7/src/microcode/ux.c b/v7/src/microcode/ux.c index 1bc105853..faff93a99 100644 --- a/v7/src/microcode/ux.c +++ b/v7/src/microcode/ux.c @@ -1,8 +1,8 @@ /* -*-C-*- -$Id: ux.c,v 1.17 1999/01/02 06:11:34 cph Exp $ +$Id: ux.c,v 1.18 2000/01/31 03:32:37 cph Exp $ -Copyright (c) 1990-1999 Massachusetts Institute of Technology +Copyright (c) 1990-2000 Massachusetts Institute of Technology This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by @@ -647,3 +647,30 @@ linux_heap_malloc (unsigned long requested_length) } #endif /* __linux */ + +#ifdef __FreeBSD__ + +#include + +void * +freebsd_heap_malloc (unsigned long requested_length) +{ + unsigned long ps = (getpagesize ()); + char * p = ((char *) ps); + void * addr; + while (p < 0x04000000) + { + addr + = (mmap (p, + (((requested_length + (ps - 1)) / ps) * ps), + (PROT_EXEC | PROT_READ | PROT_WRITE), + (MAP_PRIVATE | MAP_ANON | MAP_FIXED), + (-1), 0)); + if (addr != MAP_FAILED) + return (addr); + p += ps; + } + return (0); +} + +#endif /* __FreeBSD__ */ -- 2.25.1