Merge branch 'master' of ../yap-6.2
This commit is contained in:
commit
40be6b56f2
45
C/save.c
45
C/save.c
@ -97,7 +97,7 @@ STATIC_PROTO(int save_heap, (void));
|
|||||||
STATIC_PROTO(int save_stacks, (int));
|
STATIC_PROTO(int save_stacks, (int));
|
||||||
STATIC_PROTO(int save_crc, (void));
|
STATIC_PROTO(int save_crc, (void));
|
||||||
STATIC_PROTO(Int do_save, (int));
|
STATIC_PROTO(Int do_save, (int));
|
||||||
STATIC_PROTO(Int p_save, (void));
|
STATIC_PROTO(Int p_save2, (void));
|
||||||
STATIC_PROTO(Int p_save_program, (void));
|
STATIC_PROTO(Int p_save_program, (void));
|
||||||
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL *));
|
STATIC_PROTO(int check_header, (CELL *, CELL *, CELL *, CELL *));
|
||||||
STATIC_PROTO(int get_heap_info, (void));
|
STATIC_PROTO(int get_heap_info, (void));
|
||||||
@ -606,49 +606,36 @@ do_save(int mode) {
|
|||||||
|
|
||||||
/* Saves a complete prolog environment */
|
/* Saves a complete prolog environment */
|
||||||
static Int
|
static Int
|
||||||
p_save(void)
|
p_save2(void)
|
||||||
{
|
{
|
||||||
Int res;
|
Int res;
|
||||||
|
|
||||||
|
Term t;
|
||||||
#if defined(YAPOR) && !defined(THREADS)
|
#if defined(YAPOR) && !defined(THREADS)
|
||||||
if (number_workers != 1) {
|
if (number_workers != 1) {
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||||
|
"cannot perform save: more than a worker/thread running");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#elif defined(THREADS)
|
#elif defined(THREADS)
|
||||||
if (NOfThreads != 1) {
|
if (NOfThreads != 1) {
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,"cannot perform save: more than a worker/thread running");
|
Yap_Error(SYSTEM_ERROR,TermNil,
|
||||||
|
"cannot perform save: more than a worker/thread running");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
which_save = 1;
|
/* avoid double saves */
|
||||||
|
if (IsNonVarTerm(t = Deref(ARG2)))
|
||||||
|
return TRUE;
|
||||||
|
if (!Yap_unify(ARG2,MkIntTerm(1)))
|
||||||
|
return FALSE;
|
||||||
|
which_save = 2;
|
||||||
Yap_StartSlots();
|
Yap_StartSlots();
|
||||||
res = do_save(DO_EVERYTHING);
|
res = do_save(DO_EVERYTHING);
|
||||||
Yap_CloseSlots();
|
Yap_CloseSlots();
|
||||||
return res;
|
return res;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Saves a complete prolog environment */
|
|
||||||
static Int
|
|
||||||
p_save2(void)
|
|
||||||
{
|
|
||||||
#if defined(YAPOR) && !defined(THREADS)
|
|
||||||
if (number_workers != 1) {
|
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
|
||||||
"cannot perform save: more than a worker/thread running");
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
#elif defined(THREADS)
|
|
||||||
if (NOfThreads != 1) {
|
|
||||||
Yap_Error(SYSTEM_ERROR,TermNil,
|
|
||||||
"cannot perform save: more than a worker/thread running");
|
|
||||||
return(FALSE);
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
which_save = 2;
|
|
||||||
return(do_save(DO_EVERYTHING) && Yap_unify(ARG2,MkIntTerm(1)));
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Just save the program, not the stacks */
|
/* Just save the program, not the stacks */
|
||||||
static Int
|
static Int
|
||||||
p_save_program(void)
|
p_save_program(void)
|
||||||
@ -1778,6 +1765,7 @@ static Int
|
|||||||
p_restore(void)
|
p_restore(void)
|
||||||
{
|
{
|
||||||
int mode;
|
int mode;
|
||||||
|
char s[YAP_FILENAME_MAX+1];
|
||||||
|
|
||||||
Term t1 = Deref(ARG1);
|
Term t1 = Deref(ARG1);
|
||||||
#if defined(YAPOR) && !defined(THREADS)
|
#if defined(YAPOR) && !defined(THREADS)
|
||||||
@ -1791,11 +1779,11 @@ p_restore(void)
|
|||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
if (!Yap_GetName(Yap_FileNameBuf, YAP_FILENAME_MAX, t1)) {
|
if (!Yap_GetName(s, YAP_FILENAME_MAX, t1)) {
|
||||||
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
Yap_Error(TYPE_ERROR_LIST,t1,"restore/1");
|
||||||
return(FALSE);
|
return(FALSE);
|
||||||
}
|
}
|
||||||
if ((mode = Restore(Yap_FileNameBuf, NULL)) == DO_ONLY_CODE) {
|
if ((mode = Restore(s, NULL)) == DO_ONLY_CODE) {
|
||||||
#if PUSH_REGS
|
#if PUSH_REGS
|
||||||
restore_absmi_regs(&Yap_standard_regs);
|
restore_absmi_regs(&Yap_standard_regs);
|
||||||
#endif
|
#endif
|
||||||
@ -1808,7 +1796,6 @@ p_restore(void)
|
|||||||
void
|
void
|
||||||
Yap_InitSavePreds(void)
|
Yap_InitSavePreds(void)
|
||||||
{
|
{
|
||||||
Yap_InitCPred("$save", 1, p_save, SyncPredFlag|HiddenPredFlag);
|
|
||||||
Yap_InitCPred("$save", 2, p_save2, SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$save", 2, p_save2, SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$save_program", 1, p_save_program, SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$save_program", 1, p_save_program, SyncPredFlag|HiddenPredFlag);
|
||||||
Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag|HiddenPredFlag);
|
Yap_InitCPred("$restore", 1, p_restore, SyncPredFlag|HiddenPredFlag);
|
||||||
|
@ -217,3 +217,5 @@
|
|||||||
#define Yap_PL_Argc Yap_global->pl_argc
|
#define Yap_PL_Argc Yap_global->pl_argc
|
||||||
#define Yap_PL_Argv Yap_global->pl_argv
|
#define Yap_PL_Argv Yap_global->pl_argv
|
||||||
|
|
||||||
|
#define Yap_HaltHooks Yap_global->yap_halt_hook
|
||||||
|
|
||||||
|
@ -263,8 +263,6 @@
|
|||||||
|
|
||||||
#define Stream Yap_heap_regs->yap_streams
|
#define Stream Yap_heap_regs->yap_streams
|
||||||
|
|
||||||
#define Yap_HaltHooks Yap_heap_regs->yap_halt_hook
|
|
||||||
|
|
||||||
#define NOfFileAliases Yap_heap_regs->n_of_file_aliases
|
#define NOfFileAliases Yap_heap_regs->n_of_file_aliases
|
||||||
#define SzOfFileAliases Yap_heap_regs->sz_of_file_aliases
|
#define SzOfFileAliases Yap_heap_regs->sz_of_file_aliases
|
||||||
#define FileAliases Yap_heap_regs->file_aliases
|
#define FileAliases Yap_heap_regs->file_aliases
|
||||||
|
@ -218,4 +218,6 @@ typedef struct worker_shared {
|
|||||||
int initialised_from_pl;
|
int initialised_from_pl;
|
||||||
int pl_argc;
|
int pl_argc;
|
||||||
char **pl_argv;
|
char **pl_argv;
|
||||||
|
|
||||||
|
struct halt_hook *yap_halt_hook;
|
||||||
} w_shared;
|
} w_shared;
|
||||||
|
@ -263,8 +263,6 @@
|
|||||||
|
|
||||||
struct stream_desc *yap_streams;
|
struct stream_desc *yap_streams;
|
||||||
|
|
||||||
struct halt_hook *yap_halt_hook;
|
|
||||||
|
|
||||||
UInt n_of_file_aliases;
|
UInt n_of_file_aliases;
|
||||||
UInt sz_of_file_aliases;
|
UInt sz_of_file_aliases;
|
||||||
struct AliasDescS *file_aliases;
|
struct AliasDescS *file_aliases;
|
||||||
|
@ -216,4 +216,6 @@ static void InitGlobal(void) {
|
|||||||
Yap_global->initialised_from_pl = FALSE;
|
Yap_global->initialised_from_pl = FALSE;
|
||||||
Yap_global->pl_argc = 0;
|
Yap_global->pl_argc = 0;
|
||||||
Yap_global->pl_argv = NULL;
|
Yap_global->pl_argv = NULL;
|
||||||
|
|
||||||
|
Yap_global->yap_halt_hook = NULL;
|
||||||
}
|
}
|
||||||
|
@ -263,8 +263,6 @@
|
|||||||
|
|
||||||
Yap_heap_regs->yap_streams = NULL;
|
Yap_heap_regs->yap_streams = NULL;
|
||||||
|
|
||||||
Yap_heap_regs->yap_halt_hook = NULL;
|
|
||||||
|
|
||||||
Yap_heap_regs->n_of_file_aliases = 0;
|
Yap_heap_regs->n_of_file_aliases = 0;
|
||||||
Yap_heap_regs->sz_of_file_aliases = 0;
|
Yap_heap_regs->sz_of_file_aliases = 0;
|
||||||
Yap_heap_regs->file_aliases = NULL;
|
Yap_heap_regs->file_aliases = NULL;
|
||||||
|
@ -216,4 +216,6 @@ static void RestoreGlobal(void) {
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
12
H/rheap.h
12
H/rheap.h
@ -903,18 +903,6 @@ RestoreDBErasedIList(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void
|
|
||||||
RestoreHaltHooks(void)
|
|
||||||
{
|
|
||||||
struct halt_hook *hooke = Yap_HaltHooks = HaltHookAdjust(Yap_HaltHooks);
|
|
||||||
|
|
||||||
while (hooke) {
|
|
||||||
hooke->next = HaltHookAdjust(hooke->next);
|
|
||||||
hooke = hooke->next;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
RestoreStreams(void)
|
RestoreStreams(void)
|
||||||
{
|
{
|
||||||
|
@ -263,8 +263,6 @@
|
|||||||
|
|
||||||
RestoreStreams();
|
RestoreStreams();
|
||||||
|
|
||||||
RestoreHaltHooks();
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
RestoreAliases();
|
RestoreAliases();
|
||||||
|
@ -245,5 +245,8 @@ int initialised_from_pl Yap_InitialisedFromPL =FALSE
|
|||||||
int pl_argc Yap_PL_Argc =0
|
int pl_argc Yap_PL_Argc =0
|
||||||
char **pl_argv Yap_PL_Argv =NULL
|
char **pl_argv Yap_PL_Argv =NULL
|
||||||
|
|
||||||
|
// halt hooks
|
||||||
|
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL
|
||||||
|
|
||||||
END_WORKER_SHARED
|
END_WORKER_SHARED
|
||||||
|
|
||||||
|
@ -295,9 +295,6 @@ struct operator_entry *op_list OpList =NULL OpListAdjust
|
|||||||
/* stream array */
|
/* stream array */
|
||||||
struct stream_desc *yap_streams Stream =NULL RestoreStreams()
|
struct stream_desc *yap_streams Stream =NULL RestoreStreams()
|
||||||
|
|
||||||
/* halt hooks */
|
|
||||||
struct halt_hook *yap_halt_hook Yap_HaltHooks =NULL RestoreHaltHooks()
|
|
||||||
|
|
||||||
/* stream aliases */
|
/* stream aliases */
|
||||||
UInt n_of_file_aliases NOfFileAliases =0 void
|
UInt n_of_file_aliases NOfFileAliases =0 void
|
||||||
UInt sz_of_file_aliases SzOfFileAliases =0 void
|
UInt sz_of_file_aliases SzOfFileAliases =0 void
|
||||||
|
@ -307,19 +307,16 @@ getenv(Na,Val) :-
|
|||||||
|
|
||||||
%%% Saving and restoring a computation
|
%%% Saving and restoring a computation
|
||||||
|
|
||||||
save(A) :- var(A), !,
|
save(A) :- save(A,_).
|
||||||
'$do_error'(instantiation_error,save(A)).
|
|
||||||
save(A) :- atom(A), !, name(A,S), '$save'(S).
|
|
||||||
save(S) :- '$save'(S).
|
|
||||||
|
|
||||||
save(A,_) :- var(A), !,
|
save(A,_) :- var(A), !,
|
||||||
'$do_error'(instantiation_error,save(A)).
|
'$do_error'(instantiation_error,save(A)).
|
||||||
save(A,OUT) :- atom(A), !, name(A,S), '$save'(S,OUT).
|
save(A,OUT) :- atom(A), !, atom_codes(A,S), '$save'(S,OUT).
|
||||||
save(S,OUT) :- '$save'(S,OUT).
|
save(S,OUT) :- '$save'(S,OUT).
|
||||||
|
|
||||||
save_program(A) :- var(A), !,
|
save_program(A) :- var(A), !,
|
||||||
'$do_error'(instantiation_error,save_program(A)).
|
'$do_error'(instantiation_error,save_program(A)).
|
||||||
save_program(A) :- atom(A), !, name(A,S), '$save_program'(S).
|
save_program(A) :- atom(A), !, atom_codes(A,S), '$save_program'(S).
|
||||||
save_program(S) :- '$save_program'(S).
|
save_program(S) :- '$save_program'(S).
|
||||||
|
|
||||||
save_program(A, G) :- var(A), !,
|
save_program(A, G) :- var(A), !,
|
||||||
|
Reference in New Issue
Block a user