malloc and android

This commit is contained in:
Vitor Santos Costa 2016-07-31 10:25:46 -05:00
parent d5ce45f09f
commit a8f101cbcf
16 changed files with 22 additions and 78 deletions

View File

@ -38,12 +38,6 @@ UInt SizeOfOverflow =0
UInt AGcThreshold =10000 UInt AGcThreshold =10000
Agc_hook AGCHook =NULL Agc_hook AGCHook =NULL
#if __ANDROID__
// no need to perform initialization, it is done before we start the Prolog engine.
struct AAssetManager* assetManager =NULL
char* AssetsWD =NULL
#endif
/* multi-thread support */ /* multi-thread support */
#if THREADS #if THREADS
/* number of threads and processes in system */ /* number of threads and processes in system */
@ -173,5 +167,6 @@ struct AliasDescS* FileAliases =Yap_InitStandardAliases()
int NOfFileAliases void int NOfFileAliases void
int SzOfFileAliases void int SzOfFileAliases void
struct vfs* VFS =Yap_InitAssetManager()
END_GLOBAL_DATA END_GLOBAL_DATA

View File

@ -28,11 +28,11 @@
START_HEAP START_HEAP
/* memory management */ /* memory management */
UInt Yap_HoleSize void void UInt Yap_HoleSize
struct malloc_state *Yap_av void void
#if USE_DL_MALLOC #if USE_DL_MALLOC
struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void void struct malloc_state *Yap_av
UInt Yap_NOfMemoryHoles void void struct memory_hole Yap_MemoryHoles[MAX_DLMALLOC_HOLES]
UInt Yap_NOfMemoryHoles
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
lockvar DLMallocLock MkLock lockvar DLMallocLock MkLock
#endif #endif

View File

@ -11,6 +11,7 @@ bool sockets_io =false
bool within_print_message =false bool within_print_message =false
// //
// Used by the prompts to check if they are after a newline, and then a // Used by the prompts to check if they are after a newline, and then a
// prompt should be output, or if we are in the middle of a line. // prompt should be output, or if we are in the middle of a line.
// //
@ -215,8 +216,8 @@ wchar_t* CommentsBuff void
size_t CommentsBuffPos void size_t CommentsBuffPos void
size_t CommentsBuffLim void size_t CommentsBuffLim void
sigjmp_buf RestartEnv void sigjmp_buf RestartEnv void
char FileNameBuf[YAP_FILENAME_MAX] void char FileNameBuf[YAP_FILENAME_MAX+1] void
char FileNameBuf2[YAP_FILENAME_MAX] void char FileNameBuf2[YAP_FILENAME_MAX+1] void
// Prolog State // Prolog State
UInt BreakLevel =0 UInt BreakLevel =0
@ -294,14 +295,6 @@ UInt ImportDBRefHashTableSize =0
UInt ImportDBRefHashTableNum =0 UInt ImportDBRefHashTableNum =0
yamop *ImportFAILCODE =NULL yamop *ImportFAILCODE =NULL
#if __ANDROID__
// current virtual directory.
struct AAssetManager* assetManager =GLOBAL_assetManager
char* InAssetDir =NULL
#endif
// exo indexing // exo indexing
UInt ibnds[256] void UInt ibnds[256] void
@ -316,6 +309,7 @@ struct pred_entry* SearchPreds void
// Slots // Slots
yhandle_t CurSlot =0 yhandle_t CurSlot =0
yhandle_t FrozenHandles =0
yhandle_t NSlots =0 yhandle_t NSlots =0
CELL* SlotBase =InitHandles(wid) CELL* SlotBase =InitHandles(wid)

View File

@ -36,11 +36,6 @@
#define GLOBAL_AGcThreshold Yap_global->AGcThreshold_ #define GLOBAL_AGcThreshold Yap_global->AGcThreshold_
#define GLOBAL_AGCHook Yap_global->AGCHook_ #define GLOBAL_AGCHook Yap_global->AGCHook_
#if __ANDROID__
#define GLOBAL_assetManager Yap_global->assetManager_
#define GLOBAL_AssetsWD Yap_global->AssetsWD_
#endif
#if THREADS #if THREADS
@ -145,4 +140,5 @@
#define GLOBAL_FileAliases Yap_global->FileAliases_ #define GLOBAL_FileAliases Yap_global->FileAliases_
#define GLOBAL_NOfFileAliases Yap_global->NOfFileAliases_ #define GLOBAL_NOfFileAliases Yap_global->NOfFileAliases_
#define GLOBAL_SzOfFileAliases Yap_global->SzOfFileAliases_ #define GLOBAL_SzOfFileAliases Yap_global->SzOfFileAliases_
#define GLOBAL_VFS Yap_global->VFS_

View File

@ -30,11 +30,7 @@
#define Yap_HoleSize Yap_heap_regs->Yap_HoleSize_
#define Yap_av Yap_heap_regs->Yap_av_
#if USE_DL_MALLOC #if USE_DL_MALLOC
#define void Yap_heap_regs->void_
#define Yap_NOfMemoryHoles Yap_heap_regs->Yap_NOfMemoryHoles_
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
#define DLMallocLock Yap_heap_regs->DLMallocLock_ #define DLMallocLock Yap_heap_regs->DLMallocLock_
#endif #endif
@ -52,7 +48,7 @@
#define HeapLim Yap_heap_regs->HeapLim_ #define HeapLim Yap_heap_regs->HeapLim_
#define FreeBlocks Yap_heap_regs->FreeBlocks_ #define FreeBlocks Yap_heap_regs->FreeBlocks_
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
#define FreeBlocksLock Yap_heap_regs->FreeBlocksLock_ #define fFreeBlocksLock Yap_heap_regs->FreeBlocksLock_
#define HeapUsedLock Yap_heap_regs->HeapUsedLock_ #define HeapUsedLock Yap_heap_regs->HeapUsedLock_
#define HeapTopLock Yap_heap_regs->HeapTopLock_ #define HeapTopLock Yap_heap_regs->HeapTopLock_
#define HeapTopOwner Yap_heap_regs->HeapTopOwner_ #define HeapTopOwner Yap_heap_regs->HeapTopOwner_

View File

@ -453,13 +453,6 @@
#define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_ #define REMOTE_ImportDBRefHashTableNum(wid) REMOTE(wid)->ImportDBRefHashTableNum_
#define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_ #define LOCAL_ImportFAILCODE LOCAL->ImportFAILCODE_
#define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_ #define REMOTE_ImportFAILCODE(wid) REMOTE(wid)->ImportFAILCODE_
#if __ANDROID__
#define LOCAL_assetManager LOCAL->assetManager_
#define REMOTE_assetManager(wid) REMOTE(wid)->assetManager_
#define LOCAL_InAssetDir LOCAL->InAssetDir_
#define REMOTE_InAssetDir(wid) REMOTE(wid)->InAssetDir_
#endif
#define LOCAL_ibnds LOCAL->ibnds_ #define LOCAL_ibnds LOCAL->ibnds_
#define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_ #define REMOTE_ibnds(wid) REMOTE(wid)->ibnds_
@ -479,6 +472,8 @@
#define LOCAL_CurSlot LOCAL->CurSlot_ #define LOCAL_CurSlot LOCAL->CurSlot_
#define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_ #define REMOTE_CurSlot(wid) REMOTE(wid)->CurSlot_
#define LOCAL_FrozenHandles LOCAL->FrozenHandles_
#define REMOTE_FrozenHandles(wid) REMOTE(wid)->FrozenHandles_
#define LOCAL_NSlots LOCAL->NSlots_ #define LOCAL_NSlots LOCAL->NSlots_
#define REMOTE_NSlots(wid) REMOTE(wid)->NSlots_ #define REMOTE_NSlots(wid) REMOTE(wid)->NSlots_
#define LOCAL_SlotBase LOCAL->SlotBase_ #define LOCAL_SlotBase LOCAL->SlotBase_

View File

@ -36,11 +36,6 @@ EXTERNAL UInt GLOBAL_SizeOfOverflow;
// amount of space recovered in all garbage collections // amount of space recovered in all garbage collections
EXTERNAL UInt GLOBAL_AGcThreshold; EXTERNAL UInt GLOBAL_AGcThreshold;
EXTERNAL Agc_hook GLOBAL_AGCHook; EXTERNAL Agc_hook GLOBAL_AGCHook;
#if __ANDROID__
// no need to perform initialization, it is done before we start the Prolog engine.
EXTERNAL struct AAssetManager* GLOBAL_assetManager;
EXTERNAL char* GLOBAL_AssetsWD;
#endif
/* multi-thread support */ /* multi-thread support */
#if THREADS #if THREADS
/* number of threads and processes in system */ /* number of threads and processes in system */
@ -145,4 +140,5 @@ EXTERNAL int GLOBAL_MaxPriority;
EXTERNAL struct AliasDescS* GLOBAL_FileAliases; EXTERNAL struct AliasDescS* GLOBAL_FileAliases;
EXTERNAL int GLOBAL_NOfFileAliases; EXTERNAL int GLOBAL_NOfFileAliases;
EXTERNAL int GLOBAL_SzOfFileAliases; EXTERNAL int GLOBAL_SzOfFileAliases;
EXTERNAL struct vfs* GLOBAL_VFS;

View File

@ -31,9 +31,9 @@
/* memory management */ /* memory management */
EXTERNAL UInt Yap_HoleSize; EXTERNAL UInt Yap_HoleSize;
EXTERNAL struct malloc_state *Yap_av;
#if USE_DL_MALLOC #if USE_DL_MALLOC
EXTERNAL struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void; EXTERNAL struct malloc_state *Yap_av;
EXTERNAL struct memory_hole Yap_MemoryHoles[MAX_DLMALLOC_HOLES];
EXTERNAL UInt Yap_NOfMemoryHoles; EXTERNAL UInt Yap_NOfMemoryHoles;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
EXTERNAL lockvar DLMallocLock; EXTERNAL lockvar DLMallocLock;

View File

@ -36,11 +36,6 @@ typedef struct global_data {
// amount of space recovered in all garbage collections // amount of space recovered in all garbage collections
UInt AGcThreshold_; UInt AGcThreshold_;
Agc_hook AGCHook_; Agc_hook AGCHook_;
#if __ANDROID__
// no need to perform initialization, it is done before we start the Prolog engine.
struct AAssetManager* assetManager_;
char* AssetsWD_;
#endif
/* multi-thread support */ /* multi-thread support */
#if THREADS #if THREADS
/* number of threads and processes in system */ /* number of threads and processes in system */
@ -145,4 +140,5 @@ const char* RestoreFile_;
struct AliasDescS* FileAliases_; struct AliasDescS* FileAliases_;
int NOfFileAliases_; int NOfFileAliases_;
int SzOfFileAliases_; int SzOfFileAliases_;
struct vfs* VFS_;
} w_shared; } w_shared;

View File

@ -255,11 +255,6 @@ const char* Error_Function_;
UInt ImportDBRefHashTableSize_; UInt ImportDBRefHashTableSize_;
UInt ImportDBRefHashTableNum_; UInt ImportDBRefHashTableNum_;
yamop *ImportFAILCODE_; yamop *ImportFAILCODE_;
#if __ANDROID__
// current virtual directory.
struct AAssetManager* assetManager_;
char* InAssetDir_;
#endif
// exo indexing // exo indexing
UInt ibnds_[256]; UInt ibnds_[256];
struct index_t* exo_it_; struct index_t* exo_it_;
@ -271,6 +266,7 @@ const char* Error_Function_;
struct pred_entry* SearchPreds_; struct pred_entry* SearchPreds_;
// Slots // Slots
yhandle_t CurSlot_; yhandle_t CurSlot_;
yhandle_t FrozenHandles_;
yhandle_t NSlots_; yhandle_t NSlots_;
CELL* SlotBase_; CELL* SlotBase_;
// Mutexes // Mutexes

View File

@ -31,9 +31,9 @@
/* memory management */ /* memory management */
UInt Yap_HoleSize_; UInt Yap_HoleSize_;
struct malloc_state *Yap_av_;
#if USE_DL_MALLOC #if USE_DL_MALLOC
struct Yap_MemoryHoles[MAX_DLMALLOC_HOLES] void_; struct malloc_state *Yap_av_;
struct memory_hole Yap_MemoryHoles[MAX_DLMALLOC_HOLES]_;
UInt Yap_NOfMemoryHoles_; UInt Yap_NOfMemoryHoles_;
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
lockvar DLMallocLock_; lockvar DLMallocLock_;

View File

@ -36,11 +36,6 @@ static void InitGlobal(void) {
GLOBAL_AGcThreshold = 10000; GLOBAL_AGcThreshold = 10000;
GLOBAL_AGCHook = NULL; GLOBAL_AGCHook = NULL;
#if __ANDROID__
GLOBAL_assetManager = NULL;
GLOBAL_AssetsWD = NULL;
#endif
#if THREADS #if THREADS
@ -145,4 +140,5 @@ static void InitGlobal(void) {
GLOBAL_FileAliases = Yap_InitStandardAliases(); GLOBAL_FileAliases = Yap_InitStandardAliases();
GLOBAL_VFS = Yap_InitAssetManager();
} }

View File

@ -27,14 +27,10 @@
#if USE_DL_MALLOC #if USE_DL_MALLOC
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
INIT_LOCK(DLMallocLock); INIT_LOCK(DLMallocLock);
#endif #endif

View File

@ -255,11 +255,6 @@ static void InitWorker(int wid) {
REMOTE_ImportDBRefHashTableSize(wid) = 0; REMOTE_ImportDBRefHashTableSize(wid) = 0;
REMOTE_ImportDBRefHashTableNum(wid) = 0; REMOTE_ImportDBRefHashTableNum(wid) = 0;
REMOTE_ImportFAILCODE(wid) = NULL; REMOTE_ImportFAILCODE(wid) = NULL;
#if __ANDROID__
REMOTE_assetManager(wid) = GLOBAL_assetManager;
REMOTE_InAssetDir(wid) = NULL;
#endif
REMOTE_exo_it(wid) = NULL; REMOTE_exo_it(wid) = NULL;
@ -271,6 +266,7 @@ static void InitWorker(int wid) {
REMOTE_CurSlot(wid) = 0; REMOTE_CurSlot(wid) = 0;
REMOTE_FrozenHandles(wid) = 0;
REMOTE_NSlots(wid) = 0; REMOTE_NSlots(wid) = 0;
REMOTE_SlotBase(wid) = InitHandles(wid); REMOTE_SlotBase(wid) = InitHandles(wid);

View File

@ -27,14 +27,10 @@
#if USE_DL_MALLOC #if USE_DL_MALLOC
#if defined(YAPOR) || defined(THREADS) #if defined(YAPOR) || defined(THREADS)
REINIT_LOCK(DLMallocLock); REINIT_LOCK(DLMallocLock);
#endif #endif

View File

@ -255,13 +255,9 @@ static void RestoreWorker(int wid USES_REGS) {
#if __ANDROID__
#endif