allow strong generic buffers in stack.
This commit is contained in:
parent
2c8e6cf2d1
commit
7a33b8ebbf
22
C/bignum.c
22
C/bignum.c
@ -59,6 +59,28 @@ Yap_MkBigIntTerm(MP_INT *big)
|
|||||||
return AbsAppl(ret);
|
return AbsAppl(ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Term
|
||||||
|
Yap_AllocDynamicData(size_t bytes)
|
||||||
|
{
|
||||||
|
CACHE_REGS
|
||||||
|
Int nlimbs;
|
||||||
|
MP_INT *dst = (MP_INT *)(H+2);
|
||||||
|
CELL *ret = H;
|
||||||
|
|
||||||
|
nlimbs = ALIGN_YAPTYPE(bytes,CELL)/CellSize;
|
||||||
|
if (nlimbs > (ASP-ret)-1024) {
|
||||||
|
return TermNil;
|
||||||
|
}
|
||||||
|
H[0] = (CELL)FunctorBigInt;
|
||||||
|
H[1] = EXTERNAL_BLOB;
|
||||||
|
dst->_mp_size = 0;
|
||||||
|
dst->_mp_alloc = nlimbs;
|
||||||
|
H = (CELL *)(dst+1)+nlimbs;
|
||||||
|
H[0] = EndSpecials;
|
||||||
|
H++;
|
||||||
|
return AbsAppl(ret);
|
||||||
|
}
|
||||||
|
|
||||||
MP_INT *
|
MP_INT *
|
||||||
Yap_BigIntOfTerm(Term t)
|
Yap_BigIntOfTerm(Term t)
|
||||||
{
|
{
|
||||||
|
@ -1325,7 +1325,7 @@ mark_variable(CELL_PTR current USES_REGS)
|
|||||||
sz++;
|
sz++;
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (next[sz] != EndSpecials) {
|
if (next[sz] != EndSpecials) {
|
||||||
fprintf(stderr,"[ Error: could not find EndSpecials at blob %p type %lx ]\n", next, next[1]);
|
fprintf(stderr,"[ Error: could not find EndSpecials at blob %p type " UInt_FORMAT " ]\n", next, next[1]);
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
MARK(next+sz);
|
MARK(next+sz);
|
||||||
@ -1904,11 +1904,11 @@ mark_choicepoints(register choiceptr gc_B, tr_fr_ptr saved_TR, int very_verbose
|
|||||||
PredEntry *pe = Yap_PredForChoicePt(gc_B);
|
PredEntry *pe = Yap_PredForChoicePt(gc_B);
|
||||||
#if defined(ANALYST) || defined(DEBUG)
|
#if defined(ANALYST) || defined(DEBUG)
|
||||||
if (pe == NULL) {
|
if (pe == NULL) {
|
||||||
fprintf(GLOBAL_stderr,"%% marked %ld (%s)\n", LOCAL_total_marked, Yap_op_names[opnum]);
|
fprintf(GLOBAL_stderr,"%% marked " UInt_FORMAT " (%s)\n", LOCAL_total_marked, Yap_op_names[opnum]);
|
||||||
} else if (pe->ArityOfPE) {
|
} else if (pe->ArityOfPE) {
|
||||||
fprintf(GLOBAL_stderr,"%% %s/%d marked %ld (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, LOCAL_total_marked, Yap_op_names[opnum]);
|
fprintf(GLOBAL_stderr,"%% %s/%d marked " UInt_FORMAT " (%s)\n", RepAtom(NameOfFunctor(pe->FunctorOfPred))->StrOfAE, pe->ArityOfPE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||||
} else {
|
} else {
|
||||||
fprintf(GLOBAL_stderr,"%% %s marked %ld (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, Yap_op_names[opnum]);
|
fprintf(GLOBAL_stderr,"%% %s marked " UInt_FORMAT " (%s)\n", RepAtom((Atom)(pe->FunctorOfPred))->StrOfAE, LOCAL_total_marked, Yap_op_names[opnum]);
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
if (pe == NULL) {
|
if (pe == NULL) {
|
||||||
|
21
H/TermExt.h
21
H/TermExt.h
@ -86,7 +86,7 @@ typedef enum
|
|||||||
CLAUSE_LIST = 0x40,
|
CLAUSE_LIST = 0x40,
|
||||||
BLOB_STRING = 0x80, /* SWI style strings */
|
BLOB_STRING = 0x80, /* SWI style strings */
|
||||||
BLOB_WIDE_STRING = 0x81, /* SWI style strings */
|
BLOB_WIDE_STRING = 0x81, /* SWI style strings */
|
||||||
EXTERNAL_BLOB = 0x100 /* for SWI emulation */
|
EXTERNAL_BLOB = 0x100 /* generic data */
|
||||||
}
|
}
|
||||||
big_blob_type;
|
big_blob_type;
|
||||||
|
|
||||||
@ -438,6 +438,25 @@ IsLargeNumTerm (Term t)
|
|||||||
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
&& (FunctorOfTerm (t) >= FunctorLongInt)));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline EXTERN int IsExternalBlobTerm (Term);
|
||||||
|
|
||||||
|
inline EXTERN int
|
||||||
|
IsExternalBlobTerm (Term t)
|
||||||
|
{
|
||||||
|
return (int) (IsApplTerm (t) &&
|
||||||
|
FunctorOfTerm (t) == FunctorBigInt &&
|
||||||
|
RepAppl(t)[1] == EXTERNAL_BLOB);
|
||||||
|
}
|
||||||
|
|
||||||
|
inline EXTERN void *ExternalBlobFromTerm (Term);
|
||||||
|
|
||||||
|
inline EXTERN void *
|
||||||
|
ExternalBlobFromTerm (Term t)
|
||||||
|
{
|
||||||
|
MP_INT *base = (MP_INT *)(RepAppl(t)+2);
|
||||||
|
return (void *) (base+1);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -120,6 +120,7 @@ int STD_PROTO(Yap_IsStringTerm, (Term));
|
|||||||
int STD_PROTO(Yap_IsWideStringTerm, (Term));
|
int STD_PROTO(Yap_IsWideStringTerm, (Term));
|
||||||
Term STD_PROTO(Yap_RatTermToApplTerm, (Term));
|
Term STD_PROTO(Yap_RatTermToApplTerm, (Term));
|
||||||
void STD_PROTO(Yap_InitBigNums, (void));
|
void STD_PROTO(Yap_InitBigNums, (void));
|
||||||
|
Term STD_PROTO(Yap_AllocDynamicData, (size_t));
|
||||||
|
|
||||||
/* c_interface.c */
|
/* c_interface.c */
|
||||||
Int STD_PROTO(YAP_Execute,(struct pred_entry *, CPredicate));
|
Int STD_PROTO(YAP_Execute,(struct pred_entry *, CPredicate));
|
||||||
|
Reference in New Issue
Block a user