thread compilation

This commit is contained in:
Vítor Santos Costa 2016-02-22 13:01:09 +00:00
parent 712d79c7bb
commit 6f1b5fbef9
10 changed files with 52 additions and 29 deletions

View File

@ -44,8 +44,10 @@ Yap_ArgKey(Atom key, const param_t *def, int n)
return -1;
}
#define failed(e, t, a) failed__(e, t, a PASS_REGS)
static xarg *
failed( yap_error_number e, Term t, xarg *a)
failed__( yap_error_number e, Term t, xarg *a USES_REGS)
{
free( a );
LOCAL_Error_TYPE = e;
@ -70,7 +72,7 @@ Yap_ArgListToVector (Term listl, const param_t *def, int n)
if (IsAtomTerm(listl) ) {
xarg *na = matchKey( AtomOfTerm(listl), a, n, def);
if (!na) {
return failed( TYPE_ERROR_LIST, listl, a);
return failed( TYPE_ERROR_LIST, listl, a );
}
} else if (IsApplTerm(listl)) {
Functor f = FunctorOfTerm( listl );

View File

@ -2686,6 +2686,7 @@ static PredEntry *new_lu_int_key(Int key) {
}
static PredEntry *new_lu_entry(Term t) {
CACHE_REGS
Prop p0;
PredEntry *pe;

View File

@ -26,7 +26,7 @@ static Int current_module(USES_REGS1);
static Int current_module1(USES_REGS1);
static ModEntry *LookupModule(Term a);
static ModEntry *LookupSystemModule(Term a);
static ModEntry *GetModuleEntry(Atom at);
static ModEntry *GetModuleEntry(Atom at USES_REGS);
static ModEntry *FetchModuleEntry(Atom at);
/**
@ -67,7 +67,7 @@ initMod( AtomEntry *toname, AtomEntry *ae) {
*
* @return module descriptorxs
*/
static ModEntry *GetModuleEntry(Atom at)
static ModEntry *GetModuleEntry(Atom at USES_REGS)
{
Prop p0;
AtomEntry *ae = RepAtom(at);
@ -126,8 +126,9 @@ bool Yap_getUnknown ( Term mod) {
bool Yap_CharacterEscapes(Term mt) {
CACHE_REGS
if (mt == PROLOG_MODULE) mt = TermProlog;
return GetModuleEntry(AtomOfTerm(mt))->flags & M_CHARESCAPE;
return GetModuleEntry(AtomOfTerm(mt) PASS_REGS)->flags & M_CHARESCAPE;
}
@ -163,7 +164,7 @@ static ModEntry *LookupSystemModule(Term a) {
a = TermProlog;
}
at = AtomOfTerm(a);
me = GetModuleEntry(at);
me = GetModuleEntry(at PASS_REGS);
if (!me)
return NULL;
me->flags |= M_SYSTEM;
@ -173,15 +174,16 @@ static ModEntry *LookupSystemModule(Term a) {
static ModEntry *LookupModule(Term a) {
CACHE_REGS
Atom at;
ModEntry *me;
/* prolog module */
if (a == 0) {
return GetModuleEntry(AtomProlog);
return GetModuleEntry(AtomProlog PASS_REGS);
}
at = AtomOfTerm(a);
me = GetModuleEntry(at);
me = GetModuleEntry(at PASS_REGS);
return me;
}

View File

@ -563,7 +563,8 @@ typedef struct scanner_extra_alloc {
void *filler;
} ScannerExtraBlock;
static TokEntry *CodeSpaceError(TokEntry *t, TokEntry *p, TokEntry *l) {
#define CodeSpaceError(t, p, l) CodeSpaceError__(t, p, l PASS_REGS)
static TokEntry *CodeSpaceError__(TokEntry *t, TokEntry *p, TokEntry *l USES_REGS) {
LOCAL_Error_TYPE = RESOURCE_ERROR_HEAP;
LOCAL_ErrorMessage = "Code Space Overflow";
if (t) {
@ -574,7 +575,8 @@ static TokEntry *CodeSpaceError(TokEntry *t, TokEntry *p, TokEntry *l) {
return l;
}
static TokEntry *TrailSpaceError(TokEntry *t, TokEntry *l) {
#define TrailSpaceError(t, l) TrailSpaceError__(t, l PASS_REGS)
static TokEntry *TrailSpaceError__(TokEntry *t, TokEntry *l USES_REGS) {
LOCAL_ErrorMessage = "Trail Overflow";
LOCAL_Error_TYPE = RESOURCE_ERROR_TRAIL;
if (t) {
@ -584,7 +586,8 @@ static TokEntry *TrailSpaceError(TokEntry *t, TokEntry *l) {
return l;
}
static TokEntry *AuxSpaceError(TokEntry *p, TokEntry *l, const char *msg) {
#define AuxSpaceError(p, l, msg) AuxSpaceError__(p, l, msg PASS_REGS)
static TokEntry *AuxSpaceError__(TokEntry *p, TokEntry *l, const char *msg USES_REGS) {
/* huge atom or variable, we are in trouble */
LOCAL_ErrorMessage = (char *)msg;
LOCAL_Error_TYPE = RESOURCE_ERROR_AUXILIARY_STACK;

View File

@ -353,7 +353,7 @@ void Yap_InitQLYR(void);
void Yap_InitRange(void);
/* save.c */
int Yap_SavedInfo(char *, char *, CELL *, CELL *, CELL *);
int Yap_SavedInfo(const char *, char *, CELL *, CELL *, CELL *);
int Yap_SavedStateRestore(char *, char *);
FILE *Yap_OpenRestore(const char *, char *);
void Yap_InitSavePreds(void);

View File

@ -259,6 +259,7 @@ Yap_GetCharForSIGINT(void)
void Yap_InitConsole(void) {
CACHE_REGS
LOCAL_newline = true;
Yap_InitCPred ("prompt", 1, prompt1, SafePredFlag|SyncPredFlag);
Yap_InitCPred ("prompt1", 1, prompt1, SafePredFlag|SyncPredFlag);

View File

@ -114,6 +114,7 @@ FILE *Yap_stdout;
FILE *Yap_stderr;
static Term gethdir(Term t) {
CACHE_REGS
Atom aref = AtomOfTerm(t);
char *s = RepAtom(aref)->StrOfAE;
size_t nsz;
@ -189,6 +190,7 @@ static bool is_file_errors(Term t) {
}
void Yap_DefaultStreamOps(StreamDesc *st) {
CACHE_REGS
st->stream_wputc = put_wchar;
st->stream_wgetc = get_wchar;
if (st->status & (Promptable_Stream_f)) {
@ -266,6 +268,7 @@ static void unix_upd_stream_info(StreamDesc *s) {
static void InitFileIO(StreamDesc *s) {
CACHE_REGS
if (s->status & Socket_Stream_f) {
/* Console is a socket and socket will prompt */
Yap_ConsoleSocketOps(s);

View File

@ -267,6 +267,7 @@ static bool getLine(int inp, int out) {
}
static int ReadlinePutc(int sno, int ch) {
CACHE_REGS
StreamDesc *s = &GLOBAL_Stream[sno];
#if MAC || _MSC_VER || defined(__MINGW32__)
if (ch == 10) {

View File

@ -216,7 +216,7 @@ static const param_t read_defs[] = {READ_DEFS()};
* +
*/
Term Yap_syntax_error(TokEntry *errtok, int sno) {
CACHE_REGS
CACHE_REGS
Term info;
Term startline, errline, endline;
Term tf[4];
@ -395,7 +395,7 @@ typedef struct renv {
static xarg *setClauseReadEnv(Term opts, FEnv *fe, struct renv *re,
int inp_stream);
static xarg *setReadEnv(Term opts, FEnv *fe, struct renv *re, int inp_stream) {
CACHE_REGS
CACHE_REGS
LOCAL_VarTable = NULL;
LOCAL_AnonVarTable = NULL;
fe->cmod = CurrentModule;
@ -488,7 +488,7 @@ typedef enum {
} parser_state_t;
Int Yap_FirstLineInParse(void) {
CACHE_REGS
CACHE_REGS
return LOCAL_StartLineCount;
}
@ -496,7 +496,7 @@ Int Yap_FirstLineInParse(void) {
#define POPFET(X) fe->X = *--HR
static void reset_regs(TokEntry *tokstart, FEnv *fe) {
CACHE_REGS
CACHE_REGS
restore_machine_regs();
@ -524,6 +524,7 @@ static void reset_regs(TokEntry *tokstart, FEnv *fe) {
}
static Term get_variables(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
if (fe->vp) {
while (true) {
@ -543,6 +544,7 @@ static Term get_variables(FEnv *fe, TokEntry *tokstart) {
}
static Term get_varnames(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
if (fe->np) {
while (true) {
@ -562,6 +564,7 @@ static Term get_varnames(FEnv *fe, TokEntry *tokstart) {
}
static Term get_singletons(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
if (fe->sp) {
while (TRUE) {
@ -579,6 +582,7 @@ static Term get_singletons(FEnv *fe, TokEntry *tokstart) {
}
static void warn_singletons(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
Term v;
fe->sp = TermNil;
v = get_singletons(fe, tokstart);
@ -600,7 +604,8 @@ static void warn_singletons(FEnv *fe, TokEntry *tokstart) {
}
static Term get_stream_position(FEnv *fe, TokEntry *tokstart) {
Term v;
CACHE_REGS
Term v;
if (fe->tp) {
while (true) {
fe->old_H = HR;
@ -617,7 +622,7 @@ static Term get_stream_position(FEnv *fe, TokEntry *tokstart) {
}
static bool complete_processing(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
CACHE_REGS
Term v1, v2, v3, vc, tp;
CurrentModule = fe->cmod;
@ -655,7 +660,7 @@ static bool complete_processing(FEnv *fe, TokEntry *tokstart) {
}
static bool complete_clause_processing(FEnv *fe, TokEntry *tokstart) {
CACHE_REGS
CACHE_REGS
Term v_vp, v_vnames, v_comments, v_pos;
CurrentModule = fe->cmod;
@ -704,7 +709,7 @@ static parser_state_t scanEOF(FEnv *fe, int inp_stream);
static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream);
static parser_state_t scanEOF(FEnv *fe, int inp_stream) {
CACHE_REGS
CACHE_REGS
// bool store_comments = false;
TokEntry *tokstart = LOCAL_tokptr;
// check for an user abort
@ -745,7 +750,7 @@ static parser_state_t scanEOF(FEnv *fe, int inp_stream) {
static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
int nargs) {
CACHE_REGS
CACHE_REGS
LOCAL_ErrorMessage = NULL;
fe->old_TR = TR;
LOCAL_Error_TYPE = YAP_NO_ERROR;
@ -782,7 +787,7 @@ static parser_state_t initParser(Term opts, FEnv *fe, REnv *re, int inp_stream,
}
static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream) {
CACHE_REGS
CACHE_REGS
/* preserve value of H after scanning: otherwise we may lose strings
and floats */
LOCAL_tokptr = LOCAL_toktide =
@ -806,7 +811,7 @@ static parser_state_t scan(REnv *re, FEnv *fe, int inp_stream) {
}
static parser_state_t scanError(REnv *re, FEnv *fe, int inp_stream) {
CACHE_REGS
CACHE_REGS
fe->t = 0;
// running out of memory
if (LOCAL_Error_TYPE == RESOURCE_ERROR_TRAIL) {
@ -846,7 +851,7 @@ static parser_state_t scanError(REnv *re, FEnv *fe, int inp_stream) {
}
static parser_state_t parseError(REnv *re, FEnv *fe, int inp_stream) {
CACHE_REGS
CACHE_REGS
fe->t = 0;
if (LOCAL_Error_TYPE == RESOURCE_ERROR_TRAIL ||
LOCAL_Error_TYPE == RESOURCE_ERROR_AUXILIARY_STACK ||
@ -877,7 +882,7 @@ static parser_state_t parseError(REnv *re, FEnv *fe, int inp_stream) {
}
static parser_state_t parse(REnv *re, FEnv *fe, int inp_stream) {
CACHE_REGS
CACHE_REGS
TokEntry *tokstart = LOCAL_tokptr;
encoding_t e = LOCAL_encoding;
LOCAL_encoding = fe->enc;
@ -937,7 +942,7 @@ Term Yap_read_term(int inp_stream, Term opts, int nargs) {
state = parseError(&re, &fe, inp_stream);
break;
case YAP_PARSING_FINISHED: {
CACHE_REGS
CACHE_REGS
bool done;
if (fe.reading_clause)
done = complete_clause_processing(&fe, LOCAL_tokptr);
@ -1011,7 +1016,7 @@ static const param_t read_clause_defs[] = {READ_CLAUSE_DEFS()};
static xarg *setClauseReadEnv(Term opts, FEnv *fe, struct renv *re,
int inp_stream) {
CACHE_REGS
CACHE_REGS
xarg *args = Yap_ArgListToVector(opts, read_clause_defs, READ_END);
if (args == NULL) {
@ -1255,7 +1260,7 @@ static Int style_checker(USES_REGS1) {
Term Yap_StringToTerm(const char *s, size_t len, encoding_t *encp, int prio,
Term *bindings) {
CACHE_REGS
CACHE_REGS
Term bvar = MkVarTerm(), ctl;
yhandle_t sl;

View File

@ -60,6 +60,7 @@ void exit(int);
static void
freeBuffer( const void *ptr )
{
CACHE_REGS
if (ptr == NULL ||
ptr == LOCAL_FileNameBuf || ptr == LOCAL_FileNameBuf2)
return;
@ -297,6 +298,7 @@ Yap_IsAbsolutePath(const char *p0)
static const char *
PlExpandVars (const char *source, const char *root, char *result)
{
CACHE_REGS
const char *src = source;
if (!result)
result = malloc(YAP_FILENAME_MAX+1);
@ -600,6 +602,7 @@ static const char *myrealpath( const char *path)
static const char *
expandVars(const char *spec)
{
CACHE_REGS
#if _WIN32 || defined(__MINGW32__)
char u[YAP_FILENAME_MAX+1];
@ -658,7 +661,7 @@ Yap_AbsoluteFile(const char *spec, bool ok)
const char *
Yap_AbsoluteFileInBuffer(const char *spec, char *out, size_t sz, bool ok)
{
CACHE_REGS
const char*p;
const char*rc;
if (ok) {
@ -689,6 +692,8 @@ static Term
/* Expand the string for the program to run. */
do_glob(const char *spec, bool glob_vs_wordexp)
{
CACHE_REGS
char u[YAP_FILENAME_MAX+1];
if (spec == NULL) {
return TermNil;
}