ExportMemory
This commit is contained in:
parent
7219992154
commit
1289899918
17
C/text.c
17
C/text.c
@ -185,6 +185,23 @@ void *Realloc(void *pt, size_t sz USES_REGS) {
|
|||||||
return o + 1;
|
return o + 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Export a local memory object as a RO object to the outside world, that is, recovering as much storage as one can.
|
||||||
|
* @param pt pointer to object
|
||||||
|
* @return new object
|
||||||
|
*/
|
||||||
|
const void *MallocExportAsRO(const void *pt USES_REGS) {
|
||||||
|
struct mblock *old = pt, *o;
|
||||||
|
if (o == NULL)
|
||||||
|
return NULL;
|
||||||
|
old--;
|
||||||
|
release_block(old);
|
||||||
|
size_t sz = strlen(pt)+1;
|
||||||
|
memcpy((void*)pt,old,sz);
|
||||||
|
return realloc((void *)pt, sz);
|
||||||
|
}
|
||||||
|
|
||||||
void Free(void *pt USES_REGS) {
|
void Free(void *pt USES_REGS) {
|
||||||
struct mblock *o = pt;
|
struct mblock *o = pt;
|
||||||
o--;
|
o--;
|
||||||
|
60
C/yap-args.c
60
C/yap-args.c
@ -176,8 +176,8 @@ static void consult(const char *b_file USES_REGS) {
|
|||||||
osno = 0;
|
osno = 0;
|
||||||
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, full, &oactive);
|
c_stream = YAP_InitConsult(YAP_BOOT_MODE, b_file, full, &oactive);
|
||||||
if (c_stream < 0) {
|
if (c_stream < 0) {
|
||||||
pop_text_stack(lvl);
|
|
||||||
fprintf(stderr, "[ FATAL ERROR: could not open stream %s ]\n", b_file);
|
fprintf(stderr, "[ FATAL ERROR: could not open stream %s ]\n", b_file);
|
||||||
|
pop_text_stack(lvl);
|
||||||
exit(1);
|
exit(1);
|
||||||
}
|
}
|
||||||
if (!Yap_AddAlias(AtomLoopStream, c_stream)) {
|
if (!Yap_AddAlias(AtomLoopStream, c_stream)) {
|
||||||
@ -456,7 +456,6 @@ char *location(YAP_init_args *iap, const char *inp) {
|
|||||||
static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
||||||
const char *filename) {
|
const char *filename) {
|
||||||
int lvl = push_text_stack();
|
int lvl = push_text_stack();
|
||||||
char *out = Malloc(YAP_FILENAME_MAX + 1);
|
|
||||||
const char *inp;
|
const char *inp;
|
||||||
if (filename) {
|
if (filename) {
|
||||||
if (Yap_IsAbsolutePath(filename, true)) {
|
if (Yap_IsAbsolutePath(filename, true)) {
|
||||||
@ -466,11 +465,12 @@ static const char *find_directory(YAP_init_args *iap, const char *paths[],
|
|||||||
int i = 0;
|
int i = 0;
|
||||||
while ((inp = paths[i++]) != NULL) {
|
while ((inp = paths[i++]) != NULL) {
|
||||||
char *o = location(iap, inp);
|
char *o = location(iap, inp);
|
||||||
|
const char *rc;
|
||||||
if (filename && o) {
|
if (filename && o) {
|
||||||
strcat(o, "/");
|
strcat(o, "/");
|
||||||
strcat(o, filename);
|
strcat(o, filename);
|
||||||
if ((o = Yap_AbsoluteFile(o, false))) {
|
if ((rc = Yap_AbsoluteFile(o, false))) {
|
||||||
return pop_output_text_stack(lvl, o);
|
return pop_output_text_stack(lvl, rc);
|
||||||
}
|
}
|
||||||
} else if (o && Yap_isDirectory(o)) {
|
} else if (o && Yap_isDirectory(o)) {
|
||||||
return pop_output_text_stack(lvl, o);
|
return pop_output_text_stack(lvl, o);
|
||||||
@ -484,27 +484,51 @@ static void Yap_set_locations(YAP_init_args *iap) {
|
|||||||
config_t t, *template;
|
config_t t, *template;
|
||||||
|
|
||||||
template = cfg(&t);
|
template = cfg(&t);
|
||||||
Yap_ROOTDIR = find_directory(iap, template->root, NULL);
|
#if __ANDROID__
|
||||||
Yap_LIBDIR = find_directory(iap, template->lib, NULL);
|
Yap_ROOTDIR = "/assets";
|
||||||
// Yap_BINDIR = find_directory(iap, template->bin, NULL);
|
Yap_LIBDIR = "/assets/lib";
|
||||||
Yap_SHAREDIR = find_directory(iap, template->share, NULL);
|
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL);
|
||||||
Yap_DLLDIR = find_directory(iap, template->dll, NULL);
|
Yap_SHAREDIR = "/assets/Yap";
|
||||||
Yap_PLDIR = find_directory(iap, template->pl, NULL);
|
Yap_DLLDIR = "/assets/lib";
|
||||||
Yap_BOOTPLDIR = find_directory(iap, template->bootpldir, NULL);
|
Yap_PLDIR = "/assets/Yap";
|
||||||
|
Yap_BOOTPLDIR = "/assets/Yap/pl";
|
||||||
|
if (iap->PrologBootFile == NULL)
|
||||||
|
iap->PrologBootFile = "boot.yap";
|
||||||
|
Yap_BOOTFILE = "/assets/Yap/pl/boot.yap";
|
||||||
|
Yap_COMMONSDIR =NULL;
|
||||||
|
if (iap->SavedState == NULL) {
|
||||||
|
if (iap->OutputSavedState)
|
||||||
|
iap->SavedState = iap->OutputSavedState;
|
||||||
|
else
|
||||||
|
iap->SavedState = "startup.yss";
|
||||||
|
}
|
||||||
|
Yap_STARTUP = NULL;
|
||||||
|
iap->OutputSavedState = "startup.yss";
|
||||||
|
Yap_OUTPUT_STARTUP = NULL;
|
||||||
|
#else
|
||||||
|
Yap_ROOTDIR = MallocExportAsRO(find_directory(iap, template->root, NULL) );
|
||||||
|
Yap_LIBDIR = MallocExportAsRO( find_directory(iap, template->lib, NULL) );
|
||||||
|
// Yap_BINDIR = MallocExportAsROfind_directory(iap, template->bin, NULL);
|
||||||
|
Yap_SHAREDIR = MallocExportAsRO( find_directory(iap, template->share, NULL) );
|
||||||
|
Yap_DLLDIR = MallocExportAsRO( find_directory(iap, template->dll, NULL) );
|
||||||
|
Yap_PLDIR = MallocExportAsRO( find_directory(iap, template->pl, NULL) );
|
||||||
|
Yap_BOOTPLDIR = MallocExportAsRO( find_directory(iap, template->bootpldir, NULL) );
|
||||||
if (iap->PrologBootFile == NULL)
|
if (iap->PrologBootFile == NULL)
|
||||||
iap->PrologBootFile = "boot.yap";
|
iap->PrologBootFile = "boot.yap";
|
||||||
Yap_BOOTFILE = find_directory(iap, template->bootpldir, iap->PrologBootFile);
|
Yap_BOOTFILE = MallocExportAsRO( find_directory(iap, template->bootpldir, iap->PrologBootFile) ) ;
|
||||||
Yap_COMMONSDIR = find_directory(iap, template->commons, NULL);
|
Yap_COMMONSDIR = MallocExportAsRO( find_directory(iap, template->commons, NULL) );
|
||||||
if (iap->SavedState == NULL) {
|
if (iap->SavedState == NULL) {
|
||||||
if (iap->OutputSavedState)
|
if (iap->OutputSavedState)
|
||||||
iap->SavedState = iap->OutputSavedState;
|
iap->SavedState = iap->OutputSavedState;
|
||||||
else
|
else
|
||||||
iap->SavedState = "startup.yss";
|
iap->SavedState = "startup.yss";
|
||||||
}
|
}
|
||||||
Yap_STARTUP = find_directory(iap, template->ss, iap->SavedState);
|
Yap_STARTUP = MallocExportAsRO( find_directory(iap, template->ss, iap->SavedState));
|
||||||
if (iap->OutputSavedState == NULL)
|
if (iap->OutputSavedState == NULL)
|
||||||
iap->OutputSavedState = "startup.yss";
|
iap->OutputSavedState = "startup.yss";
|
||||||
Yap_OUTPUT_STARTUP = find_directory(iap, template->ss, iap->OutputSavedState);
|
Yap_OUTPUT_STARTUP = MallocExportAsRO( find_directory(iap, template->ss, iap->OutputSavedState) );
|
||||||
|
|
||||||
|
#endif
|
||||||
if (Yap_ROOTDIR)
|
if (Yap_ROOTDIR)
|
||||||
setAtomicGlobalPrologFlag(HOME_FLAG,
|
setAtomicGlobalPrologFlag(HOME_FLAG,
|
||||||
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
MkAtomTerm(Yap_LookupAtom(Yap_ROOTDIR)));
|
||||||
@ -1108,7 +1132,7 @@ static void init_hw(YAP_init_args *yap_init, struct ssz_t *spt) {
|
|||||||
#if __ANDROID__
|
#if __ANDROID__
|
||||||
|
|
||||||
// if (yap_init->assetManager)
|
// if (yap_init->assetManager)
|
||||||
Yap_InitAssetManager();
|
//Yap_InitAssetManager();
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
@ -1149,11 +1173,11 @@ X_API YAP_file_type_t YAP_Init(YAP_init_args *yap_init) {
|
|||||||
struct ssz_t minfo;
|
struct ssz_t minfo;
|
||||||
|
|
||||||
if (YAP_initialized)
|
if (YAP_initialized)
|
||||||
return YAP_FOUND_BOOT_ERROR;
|
/* ignore repeated calls to YAP_Init */
|
||||||
|
return YAP_FOUND_BOOT_ERROR;
|
||||||
if (!LOCAL_TextBuffer)
|
if (!LOCAL_TextBuffer)
|
||||||
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
LOCAL_TextBuffer = Yap_InitTextAllocator();
|
||||||
|
|
||||||
/* ignore repeated calls to YAP_Init */
|
|
||||||
Yap_embedded = yap_init->Embedded;
|
Yap_embedded = yap_init->Embedded;
|
||||||
|
|
||||||
minfo.Trail = 0, minfo.Stack = 0, minfo.Trail = 0;
|
minfo.Trail = 0, minfo.Stack = 0, minfo.Trail = 0;
|
||||||
|
@ -515,19 +515,13 @@ endif (WITH_CALL_TRACER)
|
|||||||
|
|
||||||
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)
|
set_property(DIRECTORY APPEND PROPERTY COMPILE_DEFINITIONS UTF8PROC=1)
|
||||||
|
|
||||||
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src)
|
include_directories(utf8proc packages/myddas packages/myddas/sqlite3/src )
|
||||||
|
|
||||||
|
|
||||||
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
set_property(SOURCE ${LIBYAP_SOURCES} APPEND PROPERTY COMPILE_DEFINITIONS YAP_KERNEL=1)
|
||||||
|
|
||||||
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
add_definitions(-DUSE_MYDDAS=1 -DMYDDAS_SQLITE3=1)
|
||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
include_directories(
|
|
||||||
packages/myddas/sqlite3/src/Android/jni/sqlite
|
|
||||||
packages/myddas/sqlite3/src/Android/jni/sqlite/nativehelper
|
|
||||||
)
|
|
||||||
|
|
||||||
else()
|
else()
|
||||||
|
|
||||||
if (MYSQL_FOUND)
|
if (MYSQL_FOUND)
|
||||||
@ -572,7 +566,10 @@ if (WIN32 OR ANDROID)
|
|||||||
if (WIN32 AND WITH_PYTHON)
|
if (WIN32 AND WITH_PYTHON)
|
||||||
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
|
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)
|
||||||
endif ()
|
endif ()
|
||||||
|
if (ANDROID)
|
||||||
|
List(APPEND YLIBS $<TARGET_OBJECTS:YAPJava>)
|
||||||
endif ()
|
endif ()
|
||||||
|
endif ()
|
||||||
|
|
||||||
include(Sources)
|
include(Sources)
|
||||||
|
|
||||||
@ -697,8 +694,18 @@ endif ()
|
|||||||
|
|
||||||
|
|
||||||
IF ( ANDROID)
|
IF ( ANDROID)
|
||||||
add_subDIRECTORY(packages/swig )
|
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||||
target_link_libraries(libYap android log)
|
set(CMAKE_SWIG_OUTPUT ${YAP_APP_DIR}/src/generated/jni )
|
||||||
|
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
||||||
|
|
||||||
|
add_subDIRECTORY(packages/swig )
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#target_link_libraries(libYap ${CMAKE_SOURCE_DIR}/../../../sqlite-android/jni/${ANDROID_ABI}/libsqliteX.so android log )
|
||||||
|
|
||||||
|
target_link_libraries(libYap android log )
|
||||||
ENDIF ()
|
ENDIF ()
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,12 +99,15 @@ X_API extern void YAP_UserBackCutCPredicate(const char *name,
|
|||||||
|
|
||||||
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
|
X_API extern YAP_Term YAP_ReadBuffer(const char *s, YAP_Term *tp);
|
||||||
|
|
||||||
|
|
||||||
#if YAP_PYTHON
|
#if YAP_PYTHON
|
||||||
|
|
||||||
#include <Python.h>
|
#include <Python.h>
|
||||||
|
|
||||||
extern bool python_in_python;
|
extern bool python_in_python;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
class YAPEngine;
|
class YAPEngine;
|
||||||
|
10
CXX/yapq.hh
10
CXX/yapq.hh
@ -187,6 +187,8 @@ public:
|
|||||||
|
|
||||||
/// @brief Setup all arguments to a new engine
|
/// @brief Setup all arguments to a new engine
|
||||||
struct X_API YAPEngineArgs : YAP_init_args {
|
struct X_API YAPEngineArgs : YAP_init_args {
|
||||||
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
YAPEngineArgs() {
|
YAPEngineArgs() {
|
||||||
const std::string *s = new std::string("startup.yss");
|
const std::string *s = new std::string("startup.yss");
|
||||||
@ -195,6 +197,8 @@ public:
|
|||||||
#if YAP_PYTHON
|
#if YAP_PYTHON
|
||||||
Embedded = true;
|
Embedded = true;
|
||||||
python_in_python = Py_IsInitialized();
|
python_in_python = Py_IsInitialized();
|
||||||
|
#endif
|
||||||
|
#if __ANDROID__
|
||||||
#endif
|
#endif
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -269,11 +273,6 @@ public:
|
|||||||
|
|
||||||
inline bool getFastBoot() { return FastBoot; };
|
inline bool getFastBoot() { return FastBoot; };
|
||||||
|
|
||||||
#if __ANDROID__
|
|
||||||
//> export ResoourceManager
|
|
||||||
inline void setAssetManager(AAssetManager *mgr) { assetManager = mgr; };
|
|
||||||
#endif
|
|
||||||
|
|
||||||
inline void setArgc(int fl) { Argc = fl; };
|
inline void setArgc(int fl) { Argc = fl; };
|
||||||
|
|
||||||
inline int getArgc() { return Argc; };
|
inline int getArgc() { return Argc; };
|
||||||
@ -281,6 +280,7 @@ public:
|
|||||||
inline void setArgv(char **fl) { Argv = fl; };
|
inline void setArgv(char **fl) { Argv = fl; };
|
||||||
|
|
||||||
inline char **getArgv() { return Argv; };
|
inline char **getArgv() { return Argv; };
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -39,7 +39,7 @@ extern void Free(void *buf USES_REGS);
|
|||||||
|
|
||||||
extern void *MallocAtLevel(size_t sz, int atL USES_REGS);
|
extern void *MallocAtLevel(size_t sz, int atL USES_REGS);
|
||||||
#define BaseMalloc(sz) MallocAtLevel(sz, 1)
|
#define BaseMalloc(sz) MallocAtLevel(sz, 1)
|
||||||
extern void *export_block(void *blk);
|
extern const void *MallocExportAsRO(const void *blk);
|
||||||
|
|
||||||
#ifndef Yap_Min
|
#ifndef Yap_Min
|
||||||
#define Yap_Min(x, y) (x < y ? x : y)
|
#define Yap_Min(x, y) (x < y ? x : y)
|
||||||
|
@ -11,18 +11,18 @@
|
|||||||
|
|
||||||
if (ANDROID)
|
if (ANDROID)
|
||||||
|
|
||||||
set( GMP_LOC ${CMAKE_SOURCE_DIR}/../gmp/${ANDROID_ABI} )
|
set( GMP_ROOT ${CMAKE_SOURCE_DIR}/../../../gmp/${ANDROID_ABI} )
|
||||||
if (EXISTS ${GMP_LOC} )
|
if (EXISTS ${GMP_ROOT} )
|
||||||
message("Looking good for ${GMP_LOC}")
|
message("Looking good for ${GMP_ROOT}")
|
||||||
set(GMP_INCLUDE_DIRS ${GMP_LOC} CACHE PATH "include search path")
|
set(GMP_INCLUDE_DIRS ${GMP_ROOT} CACHE PATH "include search path")
|
||||||
set(GMP_LIBRARIES ${GMP_LOC}/libgmp.so CACHE FILEPATH "include search path")
|
set(GMP_LIBRARIES ${GMP_ROOT}/libgmp.so CACHE FILEPATH "include search path")
|
||||||
set(GMP_LIBRARIES_DIR ${GMP_LOC} CACHE PATH "include search path")
|
set(GMP_LIBRARIES_DIR ${GMP_ROOT} CACHE PATH "include search path")
|
||||||
else()
|
else()
|
||||||
message("Bad call: ${GMP_LOC} does not exist")
|
message("Bad call: ${GMP_ROOT} does not exist")
|
||||||
endif()
|
endif()
|
||||||
find_path(GMP_INCLUDE_DIRS
|
find_path(GMP_INCLUDE_DIRS
|
||||||
NAMES gmp.h
|
NAMES gmp.h
|
||||||
HINTS ${GMP_LOC}
|
HINTS ${GMP_ROOT}
|
||||||
NO_SYSTEM_ENVIRONMENT_PATH)
|
NO_SYSTEM_ENVIRONMENT_PATH)
|
||||||
find_library(GMP_LIBRARIES NAMES gmp
|
find_library(GMP_LIBRARIES NAMES gmp
|
||||||
PATHS
|
PATHS
|
||||||
|
@ -106,8 +106,6 @@ typedef struct vfs {
|
|||||||
YAP_Term (*parsers)(int sno); // a set of parsers that can read the
|
YAP_Term (*parsers)(int sno); // a set of parsers that can read the
|
||||||
// stream and generate a YAP_Term
|
// stream and generate a YAP_Term
|
||||||
int (*writers)(int ch, int sno);
|
int (*writers)(int ch, int sno);
|
||||||
/// convert a YAP_Term into this space
|
|
||||||
const char *virtual_cwd;
|
|
||||||
/** VFS dep
|
/** VFS dep
|
||||||
endent area */
|
endent area */
|
||||||
cell_size_t priv[4];
|
cell_size_t priv[4];
|
||||||
|
32
os/assets.c
32
os/assets.c
@ -40,6 +40,10 @@ static char SccsId[] = "%W% %G%";
|
|||||||
#include <android/asset_manager.h>
|
#include <android/asset_manager.h>
|
||||||
#include <android/native_activity.h>
|
#include <android/native_activity.h>
|
||||||
|
|
||||||
|
|
||||||
|
extern void
|
||||||
|
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager);
|
||||||
|
|
||||||
jobject *Yap_aref;
|
jobject *Yap_aref;
|
||||||
JNIEnv *Yap_env;
|
JNIEnv *Yap_env;
|
||||||
|
|
||||||
@ -48,11 +52,10 @@ AAssetManager *Yap_assetManager(void)
|
|||||||
return AAssetManager_fromJava(Yap_env, Yap_aref);
|
return AAssetManager_fromJava(Yap_env, Yap_aref);
|
||||||
}
|
}
|
||||||
|
|
||||||
jboolean
|
void
|
||||||
Java_pt_up_yap_app_YAPDroid_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
Java_pt_up_yap_YAPIO_setAssetManager(JNIEnv *env, jclass clazz, jobject assetManager) {
|
||||||
Yap_aref = (*env)->NewGlobalRef(env,assetManager);
|
Yap_aref = (*env)->NewGlobalRef(env,assetManager);
|
||||||
Yap_env = env;
|
Yap_env = env;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -61,7 +64,6 @@ open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) {
|
|||||||
int mode;
|
int mode;
|
||||||
const void *buf;
|
const void *buf;
|
||||||
|
|
||||||
|
|
||||||
AAsset *am = NULL;
|
AAsset *am = NULL;
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode);
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "open %s <%s>", fname, io_mode);
|
||||||
if (strchr(io_mode, 'B'))
|
if (strchr(io_mode, 'B'))
|
||||||
@ -83,9 +85,9 @@ open_asset(VFS_t *me, int sno, const char *fname, const char *io_mode) {
|
|||||||
//
|
//
|
||||||
// }
|
// }
|
||||||
// }
|
// }
|
||||||
|
if (!am) {
|
||||||
if (!am)
|
|
||||||
return NULL;
|
return NULL;
|
||||||
|
}
|
||||||
// try not to use it as an asset
|
// try not to use it as an asset
|
||||||
off64_t sz = AAsset_getLength64(am), sz0 = 0;
|
off64_t sz = AAsset_getLength64(am), sz0 = 0;
|
||||||
int fd;
|
int fd;
|
||||||
@ -157,10 +159,10 @@ static bool stat_a(VFS_t *me, const char *fname, vfs_stat *out) {
|
|||||||
out->st_dev = bf.st_dev;
|
out->st_dev = bf.st_dev;
|
||||||
out->st_uid = bf.st_uid;
|
out->st_uid = bf.st_uid;
|
||||||
out->st_gid = bf.st_gid;
|
out->st_gid = bf.st_gid;
|
||||||
memcpy(&out->st_atimespec, (const void *) &out->st_atimespec, sizeof(struct timespec));
|
memcpy(&out->st_atimespec, (const void *) &bf.st_atim, sizeof(struct timespec));
|
||||||
memcpy(&out->st_mtimespec, (const void *) &out->st_mtimespec, sizeof(struct timespec));
|
memcpy(&out->st_mtimespec, (const void *) &bf.st_mtim, sizeof(struct timespec));
|
||||||
memcpy(&out->st_ctimespec, (const void *) &out->st_ctimespec, sizeof(struct timespec));
|
memcpy(&out->st_ctimespec, (const void *) &bf.st_ctim, sizeof(struct timespec));
|
||||||
memcpy(&out->st_birthtimespec, (const void *) &out->st_birthtimespec,
|
memcpy(&out->st_birthtimespec, (const void *) &bf.st_ctim,
|
||||||
sizeof(struct timespec));
|
sizeof(struct timespec));
|
||||||
}
|
}
|
||||||
AAsset *a = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
AAsset *a = AAssetManager_open(Yap_assetManager(), fname, AASSET_MODE_UNKNOWN);
|
||||||
@ -201,14 +203,17 @@ bool exists_a(VFS_t *me, const char *dirName) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
char virtual_cwd[YAP_FILENAME_MAX + 1];
|
char *virtual_cwd;
|
||||||
|
|
||||||
static bool set_cwd(VFS_t *me, const char *dirName) {
|
static bool set_cwd(VFS_t *me, const char *dirName) {
|
||||||
|
|
||||||
chdir("/assets");
|
chdir("/assets");
|
||||||
|
if (virtual_cwd) {
|
||||||
|
free(virtual_cwd);
|
||||||
|
}
|
||||||
|
virtual_cwd = malloc(strlen(dirName)+1);
|
||||||
strcpy(virtual_cwd, dirName);
|
strcpy(virtual_cwd, dirName);
|
||||||
__android_log_print(ANDROID_LOG_INFO, "YAPDroid",
|
__android_log_print(ANDROID_LOG_INFO, "YAPDroid", "chdir %s", virtual_cwd);
|
||||||
"chdir %s", virtual_cwd);
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -243,6 +248,7 @@ Yap_InitAssetManager(void) {
|
|||||||
me->enc = ENC_ISO_UTF8; /// how the file is encoded.
|
me->enc = ENC_ISO_UTF8; /// how the file is encoded.
|
||||||
me->parsers = NULL; /// a set of parsers that can read the stream and generate a term
|
me->parsers = NULL; /// a set of parsers that can read the stream and generate a term
|
||||||
me->writers = NULL;
|
me->writers = NULL;
|
||||||
|
virtual_cwd = NULL;
|
||||||
LOCK(BGL);
|
LOCK(BGL);
|
||||||
me->next = GLOBAL_VFS;
|
me->next = GLOBAL_VFS;
|
||||||
GLOBAL_VFS = me;
|
GLOBAL_VFS = me;
|
||||||
|
@ -94,7 +94,7 @@ bool Yap_isDirectory(const char *FileName) {
|
|||||||
|
|
||||||
bool Yap_Exists(const char *f) {
|
bool Yap_Exists(const char *f) {
|
||||||
VFS_t *vfs;
|
VFS_t *vfs;
|
||||||
f = Yap_VFAlloc(f);
|
// f = Yap_VFAlloc(f);
|
||||||
if ((vfs = vfs_owner(f))) {
|
if ((vfs = vfs_owner(f))) {
|
||||||
return vfs->exists(vfs, f);
|
return vfs->exists(vfs, f);
|
||||||
}
|
}
|
||||||
@ -340,7 +340,7 @@ static char *PrologPath(const char *Y, char *X) { return (char *)Y; }
|
|||||||
#define HAVE_REALPATH 1
|
#define HAVE_REALPATH 1
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
char virtual_cwd[YAP_FILENAME_MAX + 1];
|
extern char *virtual_cwd;
|
||||||
|
|
||||||
bool Yap_ChDir(const char *path) {
|
bool Yap_ChDir(const char *path) {
|
||||||
bool rc = false;
|
bool rc = false;
|
||||||
@ -1121,7 +1121,7 @@ static int volume_header(char *file) {
|
|||||||
int Yap_volume_header(char *file) { return volume_header(file); }
|
int Yap_volume_header(char *file) { return volume_header(file); }
|
||||||
|
|
||||||
const char *Yap_getcwd(char *cwd, size_t cwdlen) {
|
const char *Yap_getcwd(char *cwd, size_t cwdlen) {
|
||||||
if (virtual_cwd[0]) {
|
if (virtual_cwd && virtual_cwd[0]) {
|
||||||
if (!cwd) {
|
if (!cwd) {
|
||||||
cwd = malloc(cwdlen + 1);
|
cwd = malloc(cwdlen + 1);
|
||||||
}
|
}
|
||||||
@ -1135,6 +1135,9 @@ const char *Yap_getcwd(char *cwd, size_t cwdlen) {
|
|||||||
}
|
}
|
||||||
return (char *)cwd;
|
return (char *)cwd;
|
||||||
#endif
|
#endif
|
||||||
|
if (!cwd) {
|
||||||
|
cwd = malloc(cwdlen + 1);
|
||||||
|
}
|
||||||
return getcwd((char *)cwd, cwdlen);
|
return getcwd((char *)cwd, cwdlen);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
19
os/yapio.h
19
os/yapio.h
@ -152,30 +152,29 @@ INLINE_ONLY inline EXTERN Term MkCharTerm(Int c) {
|
|||||||
return MkAtomTerm(Yap_ULookupAtom(cs));
|
return MkAtomTerm(Yap_ULookupAtom(cs));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
extern char *virtual_cwd;
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN char *Yap_VF(const char *path){
|
INLINE_ONLY inline EXTERN char *Yap_VF(const char *path){
|
||||||
char out[YAP_FILENAME_MAX+1], *p = (char *)path;
|
char *out;
|
||||||
extern char virtual_cwd[];
|
|
||||||
|
|
||||||
if ( virtual_cwd[0] == 0 || Yap_IsAbsolutePath(path, false)) {
|
out = (char *)malloc(YAP_FILENAME_MAX+1);
|
||||||
return p;
|
if ( virtual_cwd == NULL || virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
||||||
|
return (char *) path;
|
||||||
}
|
}
|
||||||
strcpy(out, virtual_cwd);
|
strcpy(out, virtual_cwd);
|
||||||
strcat(out, "/" );
|
strcat(out, "/" );
|
||||||
strcat(out, p);
|
strcat(out, path);
|
||||||
strcpy(p, out);
|
return out;
|
||||||
return p;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
INLINE_ONLY inline EXTERN char *Yap_VFAlloc(const char *path){
|
INLINE_ONLY inline EXTERN char *Yap_VFAlloc(const char *path){
|
||||||
char *out;
|
char *out;
|
||||||
extern char virtual_cwd[];
|
|
||||||
|
|
||||||
out = (char *)malloc(YAP_FILENAME_MAX+1);
|
out = (char *)malloc(YAP_FILENAME_MAX+1);
|
||||||
if ( virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
if ( virtual_cwd == NULL || virtual_cwd[0] == 0 || !Yap_IsAbsolutePath(path, false)) {
|
||||||
return (char *)path;
|
return (char *) path;
|
||||||
}
|
}
|
||||||
strcpy(out, virtual_cwd);
|
strcpy(out, virtual_cwd);
|
||||||
strcat(out, "/" );
|
strcat(out, "/" );
|
||||||
|
@ -664,15 +664,15 @@ static void Yap_InitBackMYDDAS_SQLITE3Preds(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
X_API void init_sqlite3(void) {
|
X_API void init_sqlite3(void) {
|
||||||
Yap_InitMYDDAS_SQLITE3Preds();
|
// Yap_InitMYDDAS_SQLITE3Preds();
|
||||||
Yap_InitBackMYDDAS_SQLITE3Preds();
|
// Yap_InitBackMYDDAS_SQLITE3Preds();
|
||||||
}
|
}
|
||||||
|
|
||||||
#if _ANDROID_
|
#if _ANDROID_
|
||||||
JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
//JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env);
|
||||||
|
|
||||||
JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
|
// JNIEXPORT void JNICALL lib_yap_up_pt_init_sqlite(JNIEnv *env) {
|
||||||
init_sqlite3();
|
// init_sqlite3();
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -3,8 +3,7 @@
|
|||||||
|
|
||||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
||||||
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
||||||
set(CMAKE_SWIG_OUTDIR ${YAP_APP_DIR}/src/generated/java/pt/up/yap/lib )
|
FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/jni)
|
||||||
set( SWIG_MODULE_NAME pt.up.yap.lib )
|
|
||||||
set ( pllib ${YAP_APP_DIR}/src/generated/assets/Yap )
|
set ( pllib ${YAP_APP_DIR}/src/generated/assets/Yap )
|
||||||
|
|
||||||
set ( SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i )
|
set ( SWIG_SOURCES ${CMAKE_SOURCE_DIR}/packages/swig/yap.i )
|
||||||
@ -18,36 +17,41 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
|||||||
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
set (GMP_LIBRARIES ${GMP_ROOT}/libgmp.so)
|
||||||
|
|
||||||
|
|
||||||
add_custom_target (pllib ALL
|
add_custom_target (pllib
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_library} ${pllib}
|
||||||
)
|
DEPENDS ${pl_library}
|
||||||
|
)
|
||||||
|
|
||||||
add_custom_target (pllibpl ALL
|
add_custom_target (pllibpl
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${pllib}/pl
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_boot_library} ${pllib}/pl
|
||||||
|
DEPENDS pllib ${pl_boot_library}
|
||||||
)
|
)
|
||||||
add_custom_target (pllibos ALL
|
add_custom_target (pllibos ALL
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
||||||
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${pllib}/os
|
COMMAND ${CMAKE_COMMAND} -E copy ${pl_os_library} ${pllib}/os
|
||||||
|
DEPENDS pllibpl ${pl_os_library}
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command (OUTPUT swig_streamer.cpp
|
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
||||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o swig_streamer.cpp streamer.i
|
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_CURRENT_SOURCE_DIR} -o ${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp -oh ${CMAKE_SWIG_OUTPUT}/swig_streamer.hh streamer.i
|
||||||
DEPENDS streamer.i
|
DEPENDS streamer.i
|
||||||
)
|
)
|
||||||
|
|
||||||
add_custom_command (OUTPUT yap_swig.cpp
|
add_custom_command (OUTPUT ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/pl
|
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o ${CMAKE_SWIG_OUTPUT}/yap_swig.cpp -oh ${CMAKE_SWIG_OUTPUT}/yap_swig.hh ${SWIG_SOURCES}
|
||||||
COMMAND ${CMAKE_COMMAND} -E make_directory ${pllib}/os
|
DEPENDS pllibos ${SWIG_SOURCES} YAP++)
|
||||||
COMMAND ${SWIG_EXECUTABLE} -c++ -java -package ${SWIG_MODULE_NAME} -outdir ${CMAKE_SWIG_OUTDIR} -outcurrentdir -addextern -I${CMAKE_SOURCE_DIR}/CXX -I${CMAKE_SOURCE_DIR}/include -I${CMAKE_SOURCE_DIR}/H -I${CMAKE_SOURCE_DIR}/os -I${CMAKE_SOURCE_DIR}/OPTYap -I${CMAKE_BINARY_DIR} -I${GMP_INCLUDE_DIRS} -DX_API="" -o yap_swig.cpp ${SWIG_SOURCES}
|
|
||||||
DEPENDS pllibos ${SWIG_SOURCES} YAP++ ${pl_boot_library}
|
|
||||||
)
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
add_library(YAPJava OBJECT
|
||||||
|
${CMAKE_SWIG_OUTPUT}/swig_streamer.cpp
|
||||||
|
${CMAKE_SWIG_OUTPUT}/yap_swig.cpp
|
||||||
|
streamer.cpp
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
# GMP_FOUND - true if GMP/MPIR was found
|
# GMP_FOUND - true if GMP/MPIR was found
|
||||||
# GMP_INCLUDE_DIRS - include search path
|
# GMP_INCLUDE_DIRS - include search path
|
||||||
# GMP_LIBRARIES - libraries to link with
|
# GMP_LIBRARIES - libraries to link with
|
||||||
@ -57,17 +61,10 @@ FILE( MAKE_DIRECTORY ${YAP_APP_DIR}/src/generated/assets)
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
add_lib(YAPJava
|
|
||||||
yap_swig.cpp swig_streamer.cpp streamer.cpp streamer.h
|
|
||||||
)
|
|
||||||
target_link_libraries(YAPJava ${GMP_LIBRARIES} )
|
|
||||||
|
|
||||||
|
|
||||||
target_link_libraries( YAPJava libYap android log)
|
|
||||||
|
|
||||||
if (FALSE)
|
if (FALSE)
|
||||||
|
|
||||||
set (SWIG_ADD_MODULE YAPJava SHARED CPLUPLUS ${SWIG_SOURCES} )
|
set (SWIG_ADD_MODULE YAPJava SHARED CPLUSPLUS ${SWIG_SOURCES} )
|
||||||
# Define swig module with given name and specified language
|
# Define swig module with given name and specified language
|
||||||
|
|
||||||
|
|
||||||
|
@ -25,12 +25,12 @@ extern "C" {
|
|||||||
#include <yapio.h>
|
#include <yapio.h>
|
||||||
#include <iopreds.h>
|
#include <iopreds.h>
|
||||||
|
|
||||||
extern void Java_pt_up_yap_lib_streamerJNI_swig_1module_1init__(void);
|
extern void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void);
|
||||||
|
|
||||||
static VFS_t andstream;
|
static VFS_t andstream;
|
||||||
|
|
||||||
void Java_pt_up_yap_lib_streamerJNI_swig_1module_1init__(void) {
|
void Java_pt_up_yap_streamerJNI_swig_1module_1init__(void) {
|
||||||
streamerInstance = 0;
|
// streamerInstance = 0;
|
||||||
} ;
|
} ;
|
||||||
|
|
||||||
static std::string buff0;
|
static std::string buff0;
|
||||||
|
@ -31,6 +31,13 @@ class YAPEngine;
|
|||||||
|
|
||||||
extern "C"{
|
extern "C"{
|
||||||
#include "Yap.h"
|
#include "Yap.h"
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#if __ANDROID__
|
||||||
|
|
||||||
|
#endif
|
||||||
|
|
||||||
#ifdef SWIGPYTHON
|
#ifdef SWIGPYTHON
|
||||||
#include <py4yap.h>
|
#include <py4yap.h>
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user