memory allocation patches for Apple's OS/X.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@23 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
parent
18ff961273
commit
f48f399540
36
C/alloc.c
36
C/alloc.c
@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.1.1.1 2001-04-09 19:53:30 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.2 2001-05-03 17:13:18 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@ -443,15 +443,21 @@ InitWorkSpace(Int s)
|
||||
int fd;
|
||||
#endif
|
||||
|
||||
#if defined(_AIX)
|
||||
#if defined(_AIX) || defined(__APPLE__)
|
||||
a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_VARIABLE, -1, 0);
|
||||
#elif __hpux
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS | MAP_FIXED, -1, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not map ANON at %p, got %p", (void *)MMAP_ADDR,a );
|
||||
}
|
||||
#else
|
||||
fd = open("/dev/zero", O_RDWR);
|
||||
if (fd < 0) {
|
||||
@ -496,6 +502,9 @@ InitWorkSpace(Int s)
|
||||
#if USE_FIXED
|
||||
a = mmap(((void *)MMAP_ADDR), (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED, fd, 0);
|
||||
if (a != (MALLOC_T)MMAP_ADDR) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not map at %p, got %p", (void *)MMAP_ADDR, a);
|
||||
}
|
||||
#else
|
||||
a = mmap(0, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE, fd, 0);
|
||||
@ -536,9 +545,15 @@ ExtendWorkSpace(Int s)
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANONYMOUS, -1, 0);
|
||||
|
||||
if (a != WorkSpaceTop) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not grow memory at %p, got %p", WorkSpaceTop, a );
|
||||
}
|
||||
#elif defined(__APPLE__)
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_ANON, -1, 0);
|
||||
MAP_PRIVATE | MAP_ANON | MAP_FIXED, -1, 0);
|
||||
if (a != WorkSpaceTop) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not grow memory at %p, got %p", WorkSpaceTop, a );
|
||||
}
|
||||
#else
|
||||
int fd;
|
||||
fd = open("/dev/zero", O_RDWR);
|
||||
@ -581,9 +596,6 @@ ExtendWorkSpace(Int s)
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED, fd, 0);
|
||||
|
||||
if (close(fd) == -1) {
|
||||
#if HAVE_STRERROR
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not close file (%s) ]\n", strerror(errno));
|
||||
@ -593,7 +605,6 @@ ExtendWorkSpace(Int s)
|
||||
return FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
if (a == (MALLOC_T) - 1) {
|
||||
#if HAVE_STRERROR
|
||||
Error(SYSTEM_ERROR, TermNil, "could not allocate %d bytes (%s)", (int)s, strerror(errno));
|
||||
@ -602,6 +613,13 @@ ExtendWorkSpace(Int s)
|
||||
#endif
|
||||
return FALSE;
|
||||
}
|
||||
a = mmap(WorkSpaceTop, (size_t) s, PROT_READ | PROT_WRITE | PROT_EXEC,
|
||||
MAP_PRIVATE | MAP_FIXED, fd, 0);
|
||||
|
||||
if (a != WorkSpaceTop) {
|
||||
Error(SYSTEM_ERROR, TermNil, "mmap could not grow memory at %p, got %p", WorkSpaceTop, a );
|
||||
}
|
||||
|
||||
WorkSpaceTop = (char *) a + s;
|
||||
#endif /* YAPOR */
|
||||
return TRUE;
|
||||
|
@ -655,7 +655,7 @@ init_dbtable(tr_fr_ptr trail_ptr) {
|
||||
#ifdef DEBUG
|
||||
|
||||
/*#define INSTRUMENT_GC 1*/
|
||||
#define CHECK_CHOICEPOINTS 1
|
||||
/*#define CHECK_CHOICEPOINTS 1*/
|
||||
|
||||
#ifdef INSTRUMENT_GC
|
||||
typedef enum {
|
||||
@ -2546,7 +2546,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
|
||||
YP_fprintf(YP_stderr,"[GC] Oops on iptop-H (%d) vs %d\n", iptop-(CELL_PTR *)H, total_marked);
|
||||
#endif
|
||||
if (iptop < (CELL_PTR *)ASP-1024 && 10*total_marked < H-H0) {
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG_IN
|
||||
int effectiveness = (((H-H0)-total_marked)*100)/(H-H0);
|
||||
fprintf(stderr,"using pointers (%d)\n", effectiveness);
|
||||
#endif
|
||||
@ -2555,7 +2555,7 @@ compaction_phase(tr_fr_ptr old_TR, CELL *current_env, yamop *curp, CELL *max)
|
||||
} else
|
||||
#endif /* HYBRID_SCHEME */
|
||||
{
|
||||
#ifdef DEBUG
|
||||
#ifdef DEBUG_IN
|
||||
int effectiveness = (((H-H0)-total_marked)*100)/(H-H0);
|
||||
fprintf(stderr,"not using pointers (%d)\n", effectiveness);
|
||||
#endif
|
||||
|
@ -1669,6 +1669,7 @@ SetAlias (Atom arg, int sno)
|
||||
#endif /* HAVE_SETBUF */
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return;
|
||||
}
|
||||
@ -1705,6 +1706,7 @@ PurgeAlias (int sno)
|
||||
YP_stderr = 2;
|
||||
break;
|
||||
default:
|
||||
break; /* just put something here */
|
||||
}
|
||||
new_aliasp++;
|
||||
} else {
|
||||
|
@ -93,10 +93,6 @@ void STD_PROTO(YAP_InitHeap, (void *));
|
||||
|
||||
#if USE_MMAP
|
||||
|
||||
#ifdef _APPLE__
|
||||
|
||||
#endif
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/mman.h>
|
||||
|
||||
|
@ -6,6 +6,8 @@
|
||||
|
||||
<H2 ALIGN=CENTER>Yap-4.3.19:</H2>
|
||||
<UL>
|
||||
<LI> FIXED: Patches for memory allocation in Apple's OS/X..
|
||||
<LI> FIXED: checked whether mmap work right in alloc.c.
|
||||
<LI> FIXED: ASP from Y should have space for env size.
|
||||
<LI> NEW: new garbage collection algorithm.
|
||||
<LI> FIXED: don't allow importing from the module itself.
|
||||
|
@ -10,7 +10,7 @@
|
||||
* File: Yap.h.m4 *
|
||||
* mods: *
|
||||
* comments: main header file for YAP *
|
||||
* version: $Id: Yap.h.m4,v 1.3 2001-04-17 21:07:41 vsc Exp $ *
|
||||
* version: $Id: Yap.h.m4,v 1.4 2001-05-03 17:13:18 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
|
||||
#include "config.h"
|
||||
@ -223,8 +223,10 @@ extern char Option[20];
|
||||
#define MMAP_ADDR 0x40000000
|
||||
#elif mips
|
||||
#define MMAP_ADDR 0x02000000
|
||||
#elif __APPLE__
|
||||
#define MMAP_ADDR 0x01000000
|
||||
#else
|
||||
#define MMAP_ADDR 0x10010000
|
||||
#define MMAP_ADDR 0x10000000
|
||||
#endif
|
||||
#elif __svr4__
|
||||
#define MMAP_ADDR 0x02000000
|
||||
|
Reference in New Issue
Block a user