This commit is contained in:
Vitor Santos Costa 2016-08-01 17:48:25 -05:00
parent 957aa9f977
commit 8973689b43

View File

@ -19,10 +19,10 @@ static char SccsId[] = "%W% %G%";
#endif #endif
#include "Yap.h"
#include "Yatom.h"
#include "YapHeap.h"
#include "alloc.h" #include "alloc.h"
#include "Yap.h"
#include "YapHeap.h"
#include "Yatom.h"
#include "yapio.h" #include "yapio.h"
#if HAVE_STRING_H #if HAVE_STRING_H
#include <string.h> #include <string.h>
@ -45,8 +45,8 @@ static char SccsId[] = "%W% %G%";
#if HAVE_SYS_STAT_H #if HAVE_SYS_STAT_H
#include <sys/stat.h> #include <sys/stat.h>
#endif #endif
#include <stdlib.h>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h>
#if __simplescalar__ #if __simplescalar__
#ifdef USE_SYSTEM_MMAP #ifdef USE_SYSTEM_MMAP
@ -69,37 +69,35 @@ static char SccsId[] = "%W% %G%";
#undef malloc #undef malloc
#undef realloc #undef realloc
int write_malloc=0; int write_malloc = 0;
void * my_malloc(size_t sz) void *my_malloc(size_t sz) {
{
void *p; void *p;
p = malloc(sz); p = malloc(sz);
// Yap_DebugPuts(stderr,"gof\n"); // Yap_DebugPuts(stderr,"gof\n");
if (sz > 500 & write_malloc++ > 0) if (sz > 500 && write_malloc++ > 0)
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc, p); __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "+ %d %p", write_malloc,
p);
return p; return p;
} }
void * my_realloc(void *ptr, size_t sz) void *my_realloc(void *ptr, size_t sz) {
{
void *p; void *p;
p = realloc(ptr, sz); p = realloc(ptr, sz);
// Yap_DebugPuts(stderr,"gof\n"); // Yap_DebugPuts(stderr,"gof\n");
if (sz > 500 & write_malloc++ > 0) if (sz > 500 && write_malloc++ > 0)
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "* %d %p", write_malloc, p); __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "* %d %p", write_malloc,
p);
return p; return p;
} }
void my_free(void *p) {
// printf("f %p\n",p);
void my_free(void *p) if (write_malloc && write_malloc++ > 0)
{ __android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc,
//printf("f %p\n",p); p);
if (write_malloc && write_malloc++ > 0)
__android_log_print(ANDROID_LOG_ERROR, "YAPDroid ", "- %d %p", write_malloc, p);
free(p); free(p);
// Yap_DebugPuts(stderr,"gof\n"); // Yap_DebugPuts(stderr,"gof\n");
@ -344,8 +342,7 @@ ADDR Yap_ExpandPreAllocCodeSpace(UInt sz0, void *cip, int safe) {
tmalloc -= LOCAL_ScratchPad.sz; tmalloc -= LOCAL_ScratchPad.sz;
tmalloc += sz; tmalloc += sz;
#endif #endif
if (!(ptr = if (!(ptr = my_realloc(LOCAL_ScratchPad.ptr, sz))) {
my_realloc(LOCAL_ScratchPad.ptr, sz))) {
LOCAL_PrologMode &= ~MallocMode; LOCAL_PrologMode &= ~MallocMode;
#if USE_DL_MALLOC #if USE_DL_MALLOC
UNLOCK(DLMallocLock); UNLOCK(DLMallocLock);
@ -1086,8 +1083,7 @@ static MALLOC_T mmap_extension(Int s, MALLOC_T base, int fixed_allocation) {
MAP_PRIVATE MAP_PRIVATE
#if !defined(__linux) #if !defined(__linux)
/* use MAP_FIXED, otherwise God knows where you will be placed */ /* use MAP_FIXED, otherwise God knows where you will be placed */
| | fixed_allocation
fixed_allocation
#endif #endif
, ,
fd, 0); fd, 0);