saved states and anaconda
This commit is contained in:
@@ -88,6 +88,7 @@ struct foreign_context {
|
||||
struct PL_local_data *engine; /* invoking engine */
|
||||
};
|
||||
|
||||
|
||||
X_API bool python_in_python;
|
||||
|
||||
X_API int YAP_Reset(yap_reset_t mode);
|
||||
@@ -2426,7 +2427,6 @@ static void do_bootfile(const char *bootfilename USES_REGS) {
|
||||
/* ignore repeated calls to YAP_Init */
|
||||
if (YAP_initialized)
|
||||
return YAP_FOUND_BOOT_ERROR;
|
||||
|
||||
Yap_embedded = yap_init->Embedded;
|
||||
Yap_page_size = Yap_InitPageSize(); /* init memory page size, required by
|
||||
later functions */
|
||||
|
@@ -79,9 +79,8 @@ char *Yap_FindExecutable(void) {
|
||||
}
|
||||
return "yap";
|
||||
#elif defined(__linux__)
|
||||
enum { BUFFERSIZE = 1024 };
|
||||
char *buf = malloc(BUFFERSIZE);
|
||||
ssize_t len = readlink("/proc/self/exe", buf, sizeof(buf) - 1);
|
||||
char *buf = malloc(YAP_FILENAME_MAX);
|
||||
ssize_t len = readlink("/proc/self/exe", buf, YAP_FILENAME_MAX - 1);
|
||||
|
||||
if (len != -1) {
|
||||
buf[len] = '\0';
|
||||
@@ -194,7 +193,6 @@ static Int LoadForeign(StringList ofiles, StringList libs, char *proc_name,
|
||||
|
||||
/* load libraries first so that their symbols are available to
|
||||
other routines */
|
||||
/* dlopen wants to follow the LD_CONFIG_PATH */
|
||||
const char *file = AtomName(ofiles->name);
|
||||
if (!Yap_findFile(file, NULL, NULL, LOCAL_FileNameBuf, true, YAP_OBJ, true,
|
||||
true)) {
|
||||
|
17
C/qlyr.c
17
C/qlyr.c
@@ -79,11 +79,18 @@ static char *Yap_AlwaysAllocCodeSpace(UInt size) {
|
||||
return out;
|
||||
}
|
||||
|
||||
static void QLYR_ERROR(qlfr_err_t my_err) {
|
||||
|
||||
#define QLYR_ERROR(err) \
|
||||
QLYR_ERROR__(__FILE__, __FUNCTION__, __LINE__, err)
|
||||
|
||||
|
||||
|
||||
static void QLYR_ERROR__(const char *file, const char *function, int lineno,
|
||||
qlfr_err_t my_err) {
|
||||
// __android_log_print(ANDROID_LOG_INFO, "YAP ", "error %s in saved state
|
||||
// %s",GLOBAL_RestoreFile, qlyr_error[my_err]);
|
||||
Yap_Error(SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s",
|
||||
GLOBAL_RestoreFile, qlyr_error[my_err]);
|
||||
Yap_Error__(file, function, lineno, SYSTEM_ERROR_SAVED_STATE, TermNil, "error %s in saved state %s",
|
||||
GLOBAL_RestoreFile, qlyr_error[my_err]);
|
||||
Yap_exit(1);
|
||||
}
|
||||
|
||||
@@ -638,7 +645,7 @@ static bool checkChars(FILE *stream, char s[]) {
|
||||
}
|
||||
|
||||
static Atom do_header(FILE *stream) {
|
||||
char s[2560], *p = s, ch;
|
||||
char s[2048], *p = s, ch;
|
||||
Atom at;
|
||||
|
||||
if (!checkChars(stream, "#!/bin/sh\nexec_dir=${YAPBINDIR:-"))
|
||||
@@ -1044,6 +1051,8 @@ static void ReInitProlog(void) {
|
||||
|
||||
static Int qload_program(USES_REGS1) {
|
||||
FILE *stream;
|
||||
|
||||
|
||||
Term t1 = Deref(ARG1);
|
||||
|
||||
if (IsVarTerm(t1)) {
|
||||
|
7
C/qlyw.c
7
C/qlyw.c
@@ -727,14 +727,15 @@ static size_t save_ops(FILE *stream, Term mod) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int save_header(FILE *stream, char type[]) {
|
||||
char msg[256 * 16];
|
||||
static size_t save_header(FILE *stream, char type[]) {
|
||||
char msg[2048];
|
||||
|
||||
memset(msg, 0, 2048);
|
||||
sprintf(msg,
|
||||
"#!/bin/sh\nexec_dir=${YAPBINDIR:-%s}\nexec $exec_dir/yap $0 "
|
||||
"\"$@\"\n%s %s\n",
|
||||
YAP_BINDIR, type, YAP_FULL_VERSION);
|
||||
return save_bytes(stream, msg, strlen(msg) + 1);
|
||||
return save_bytes(stream, msg, 2048);
|
||||
}
|
||||
|
||||
static size_t save_module(FILE *stream, Term mod) {
|
||||
|
40
C/yap-args.c
40
C/yap-args.c
@@ -45,6 +45,18 @@
|
||||
#include <direct.h>
|
||||
#endif
|
||||
|
||||
|
||||
#ifndef YAP_ROOTDIR
|
||||
#include <libgen.h>
|
||||
|
||||
char
|
||||
*YAP_BINDIR,
|
||||
*YAP_ROOTDIR,
|
||||
*YAP_SHAREDIR,
|
||||
*YAP_LIBDIR,
|
||||
*YAP_YAPLIB;
|
||||
#endif
|
||||
|
||||
static void print_usage(void) {
|
||||
fprintf(stderr, "\n[ Valid switches for command line arguments: ]\n");
|
||||
fprintf(stderr, " -? Shows this screen\n");
|
||||
@@ -147,6 +159,7 @@ YAP_file_type_t Yap_InitDefaults(YAP_init_args *iap, char saved_state[],
|
||||
#endif
|
||||
iap->Argc = argc;
|
||||
iap->Argv = argv;
|
||||
iap->YapLibDir = YAP_YAPLIB;
|
||||
return iap->boot_file_type;
|
||||
}
|
||||
|
||||
@@ -155,6 +168,33 @@ X_API YAP_file_type_t YAP_parse_yap_arguments(int argc, char *argv[],
|
||||
char *p;
|
||||
size_t *ssize;
|
||||
|
||||
#ifndef YAP_ROOTDIR
|
||||
{
|
||||
char *b0=Yap_FindExecutable(), *b1, *b2;
|
||||
char b[YAP_FILENAME_MAX + 1];
|
||||
|
||||
strncpy(b, b0, YAP_FILENAME_MAX);
|
||||
b1 = dirname(b);
|
||||
YAP_BINDIR = malloc(strlen(b1)+1);
|
||||
strcpy(YAP_BINDIR, b1);
|
||||
b2 = dirname(b1);
|
||||
YAP_ROOTDIR = malloc(strlen(b2)+1);
|
||||
strcpy(YAP_ROOTDIR, b2);
|
||||
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
|
||||
strncat( b, "/share", YAP_FILENAME_MAX);
|
||||
YAP_SHAREDIR= malloc(strlen(b)+1);
|
||||
strcpy(YAP_SHAREDIR, b);
|
||||
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
|
||||
strncat( b, "/lib", YAP_FILENAME_MAX);
|
||||
YAP_LIBDIR= malloc(strlen(b)+1);
|
||||
strcpy(YAP_LIBDIR, b);
|
||||
strncpy(b, YAP_ROOTDIR, YAP_FILENAME_MAX);
|
||||
strncat( b, "/lib/Yap", YAP_FILENAME_MAX);
|
||||
YAP_YAPLIB= malloc(strlen(b)+1);
|
||||
strcpy(YAP_YAPLIB, b);
|
||||
};
|
||||
#endif
|
||||
|
||||
Yap_InitDefaults(iap, NULL, argc, argv);
|
||||
while (--argc > 0) {
|
||||
p = *++argv;
|
||||
|
Reference in New Issue
Block a user