This commit is contained in:
Vitor Santos Costa 2018-06-30 14:33:32 +01:00
parent 6c1d3d1a95
commit 5f96c07131
90 changed files with 632 additions and 623 deletions

View File

@ -221,7 +221,7 @@ Atom Yap_LookupAtomWithLength(const char *atom,
ptr = Yap_AllocCodeSpace(len0 + 1);
if (!ptr)
return NIL;
memcpy(ptr, atom, len0);
memmove(ptr, atom, len0);
ptr[len0] = '\0';
at = LookupAtom(ptr);
Yap_FreeCodeSpace(ptr);
@ -1010,7 +1010,7 @@ Atom Yap_LookupAtomWithLength(const char *atom,
if (IsApplTerm(t0)) {
Yap_FreeCodeSpace((char *)RepAppl(t0));
}
memcpy((void *)pt, (void *)ap, sz);
memmove((void *)pt, (void *)ap, sz);
p->ValueOfVE = AbsAppl(pt);
#endif
} else if (IsStringTerm(v)) {
@ -1025,7 +1025,7 @@ Atom Yap_LookupAtomWithLength(const char *atom,
if (IsApplTerm(t0)) {
Yap_FreeCodeSpace((char *)RepAppl(t0));
}
memcpy((void *)pt, (void *)ap, sz);
memmove((void *)pt, (void *)ap, sz);
p->ValueOfVE = AbsAppl(pt);
} else {
if (IsApplTerm(t0)) {

View File

@ -216,7 +216,7 @@ Atom Yap_LookupAtomWithLength(const char *atom,
ptr = Yap_AllocCodeSpace(len0 + 1);
if (!ptr)
return NIL;
memcpy(ptr, atom, len0);
memmove(ptr, atom, len0);
ptr[len0] = '\0';
at = LookupAtom(ptr);
Yap_FreeCodeSpace(ptr);
@ -1004,7 +1004,7 @@ void Yap_PutValue(Atom a, Term v) {
if (IsApplTerm(t0)) {
Yap_FreeCodeSpace((char *)RepAppl(t0));
}
memcpy((void *)pt, (void *)ap, sz);
memmove((void *)pt, (void *)ap, sz);
p->ValueOfVE = AbsAppl(pt);
#endif
} else if (IsStringTerm(v)) {
@ -1019,7 +1019,7 @@ void Yap_PutValue(Atom a, Term v) {
if (IsApplTerm(t0)) {
Yap_FreeCodeSpace((char *)RepAppl(t0));
}
memcpy((void *)pt, (void *)ap, sz);
memmove((void *)pt, (void *)ap, sz);
p->ValueOfVE = AbsAppl(pt);
} else {
if (IsApplTerm(t0)) {

View File

@ -1329,7 +1329,7 @@ XX realloc(MALLOC_T ptr, size_t size) {
MALLOC_T new = malloc(size);
if (ptr)
memcpy(new, ptr, size);
memmove(new, ptr, size);
free(ptr);
return (new);
}

View File

@ -2070,7 +2070,7 @@ static Int atom_split(USES_REGS1) {
}
size_t b_mid = skip_utf8(s0, u_mid) - s0;
s1 = s10 = Malloc(b_mid + 1);
memcpy(s1, s, b_mid);
memmove(s1, s, b_mid);
s1[b_mid] = '\0';
to1 = MkAtomTerm(Yap_ULookupAtom(s10));
to2 = MkAtomTerm(Yap_ULookupAtom(s0 + b_mid));

View File

@ -48,7 +48,7 @@ char *Yap_blob_to_string(AtomEntry *ref, const char *s0, size_t sz) {
size_t sz0 = strlcpy(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz);
#else
size_t sz0;
char *f = (char *)memcpy(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz);
char *f = (char *)memmove(s, (char *)RepAtom(AtomSWIStream)->StrOfAE, sz);
f[0] = '\0';
sz0 = f - s;
#endif
@ -156,7 +156,7 @@ AtomEntry *Yap_lookupBlob(void *blob, size_t len, void *type0, int *new) {
ae->PropsOfAE = AbsBlobProp(b);
ae->NextOfAE = AbsAtom(Blobs);
ae->rep.blob->length = len;
memcpy(ae->rep.blob->data, blob, len);
memmove(ae->rep.blob->data, blob, len);
Blobs = ae;
if (NOfBlobs > NOfBlobsMax) {
Yap_signal(YAP_CDOVF_SIGNAL);

View File

@ -1898,7 +1898,7 @@ X_API YAP_opaque_tag_t YAP_NewOpaqueType(struct YAP_opaque_handler_struct *f) {
return -1;
}
i = GLOBAL_OpaqueHandlersCount++;
memcpy(GLOBAL_OpaqueHandlers + i, f, sizeof(YAP_opaque_handler_t));
memmove(GLOBAL_OpaqueHandlers + i, f, sizeof(YAP_opaque_handler_t));
return i;
}
@ -2176,7 +2176,8 @@ X_API void YAP_EndConsult(int sno, int *osnop, const char *full) {
if (osnop >= 0)
Yap_AddAlias(AtomLoopStream, *osnop);
Yap_end_consult();
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " closing %s(%d), %d", full, *osnop, sno);
__android_log_print(ANDROID_LOG_INFO, "YAPDroid ", " closing %s:%s(%d), %d",
CurrentModule == 0? "prolog": RepAtom(AtomOfTerm(CurrentModule))->StrOfAE, full, *osnop, sno);
// LOCAL_CurSlot);
pop_text_stack(lvl);
RECOVER_MACHINE_REGS();
@ -3104,7 +3105,7 @@ X_API Int YAP_AtomToInt(YAP_Atom At) {
"No more room for translations");
return -1;
}
memcpy(nt, ot, sizeof(atom_t) * MaxAtomTranslations);
memmove(nt, ot, sizeof(atom_t) * MaxAtomTranslations);
TR_Atoms = nt;
free(ot);
MaxAtomTranslations *= 2;
@ -3132,7 +3133,7 @@ X_API Int YAP_FunctorToInt(YAP_Functor f) {
"No more room for translations");
return -1;
}
memcpy(nt, ot, sizeof(functor_t) * MaxFunctorTranslations);
memmove(nt, ot, sizeof(functor_t) * MaxFunctorTranslations);
TR_Functors = nt;
free(ot);
MaxFunctorTranslations *= 2;

View File

@ -301,7 +301,7 @@ void Yap_BuildMegaClause(PredEntry *ap) {
mcl->ClLine = cl->usc.ClLine;
ptr = mcl->ClCode;
while (TRUE) {
memcpy((void *)ptr, (void *)cl->ClCode, sz);
memmove((void *)ptr, (void *)cl->ClCode, sz);
if (has_blobs) {
LOCAL_ClDiff = (char *)(ptr) - (char *)cl->ClCode;
restore_opcodes(ptr, NULL PASS_REGS);
@ -380,7 +380,7 @@ static void split_megaclause(PredEntry *ap) {
new->ClSize = mcl->ClItemSize;
new->usc.ClLine = Yap_source_line_no();
new->ClNext = NULL;
memcpy((void *)new->ClCode, (void *)ptr, mcl->ClItemSize);
memmove((void *)new->ClCode, (void *)ptr, mcl->ClItemSize);
if (prev) {
prev->ClNext = new;
} else {
@ -1386,7 +1386,7 @@ static void expand_consult(void) {
}
new_cs = new_cl + InitialConsultCapacity;
/* start copying */
memcpy((void *)new_cs, (void *)LOCAL_ConsultLow,
memmove((void *)new_cs, (void *)LOCAL_ConsultLow,
OldConsultCapacity * sizeof(consult_obj));
/* copying done, release old space */
Yap_FreeCodeSpace((char *)LOCAL_ConsultLow);

View File

@ -719,7 +719,7 @@ restart:
dest = Yap_emit_extra_size(blob_op, sz / CellSize, sz, &cglobs->cint);
/* copy the bignum */
memcpy(dest, src, sz);
memmove(dest, src, sz);
/* note that we don't need to copy size info, unless we wanted
to garbage collect clauses ;-) */
cglobs->cint.icpc = cglobs->cint.cpc;
@ -758,7 +758,7 @@ restart:
dest = Yap_emit_extra_size(blob_op, sz / CellSize, sz, &cglobs->cint);
/* copy the bignum */
memcpy(dest, src, sz);
memmove(dest, src, sz);
/* note that we don't need to copy size info, unless we wanted
to garbage collect clauses ;-) */
cglobs->cint.icpc = cglobs->cint.cpc;

View File

@ -642,7 +642,7 @@ static CELL *copy_double(CELL *st, CELL *pt) {
static CELL *copy_string(CELL *st, CELL *pt) {
UInt sz = pt[1] + 3;
/* first thing, store a link to the list before we move on */
memcpy(st, pt, sizeof(CELL) * sz);
memmove(st, pt, sizeof(CELL) * sz);
/* now reserve space */
return st + sz;
}
@ -656,7 +656,7 @@ static CELL *copy_big_int(CELL *st, CELL *pt) {
st[0] = (CELL)FunctorBigInt;
st[1] = pt[1];
/* then the actual number */
memcpy((void *)(st + 2), (void *)(pt + 2), sz);
memmove((void *)(st + 2), (void *)(pt + 2), sz);
st = st + 2 + sz / CellSize;
/* then the tail for gc */
st[0] = EndSpecials;
@ -968,7 +968,7 @@ loop:
if (HR + sz >= ASP) {
goto error2;
}
memcpy((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *));
memmove((void *)HR, (void *)(to_visit_base), sz * sizeof(CELL *));
to_visit_base = (CELL **)HR;
to_visit = to_visit_base + sz;
}
@ -1684,7 +1684,7 @@ static DBRef CreateDBStruct(Term Tm, DBProp p, int InFlag, int *pstat,
nar = ppt->Contents + Unsigned(NOfCells);
}
woar = (link_entry *)nar;
memcpy((void *)woar, (const void *)dbg->LinkAr,
memmove((void *)woar, (const void *)dbg->LinkAr,
(size_t)(NOfLinks * sizeof(link_entry)));
woar += NOfLinks;
#ifdef ALIGN_LONGS

View File

@ -1978,7 +1978,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
assert(ncopies >= 3);
if (ncopies > 9)
memcpy(d, s, copysize);
memmove(d, s, copysize);
else {
*(d+0) = *(s+0);
@ -2077,7 +2077,7 @@ Void_t* rEALLOc(oldmem, bytes) Void_t* oldmem; size_t bytes;
/* Must alloc, copy, free. */
newmem = mALLOc(nb - MALLOC_ALIGN_MASK);
if (newmem != 0) {
memcpy(newmem, oldmem, oldsize - 2*SIZE_SZ);
memmove(newmem, oldmem, oldsize - 2*SIZE_SZ);
fREe(oldmem);
}
}

View File

@ -49,7 +49,7 @@
const char *s = IsAtomTerm(t) ? RepAtom(AtomOfTerm(t))->StrOfAE \
: IsStringTerm(t) ? StringOfTerm(t) : NULL; \
if (s) { \
char *tmp = malloc(strlen(s) + 1); \
char *tmp = calloc(1,strlen(s) + 1); \
strcpy(tmp, s); \
i->k = tmp; \
} \
@ -148,10 +148,10 @@ static void printErr(yap_error_descriptor_t *i) {
return;
}
print_key_i("errorNo", i->errorNo);
print_key_i("errorClass", i->errorClass);
print_key_s("errorAsText", i->errorAsText);
print_key_i("errorClass", (i->errorClass = Yap_errorClass(i->errorNo)));
print_key_s("errorAsText", (i->errorAsText=Yap_errorName(i->errorNo) ) );
print_key_s("errorGoal", i->errorGoal);
print_key_s("classAsText", i->classAsText);
print_key_s("classAsText", (i->classAsText=Yap_errorClassName(i->errorClass)));
print_key_i("errorLine", i->errorLine);
print_key_s("errorFunction", i->errorFunction);
print_key_s("errorFile", i->errorFile);
@ -589,7 +589,7 @@ yap_error_descriptor_t *Yap_popErrorContext(bool mdnew, bool pass) {
LOCAL_ActiveError = e->top_error;
if (e->errorNo) {
if (!LOCAL_ActiveError->errorNo && pass) {
memcpy(LOCAL_ActiveError, e, sizeof(*LOCAL_ActiveError));
memmove(LOCAL_ActiveError, e, sizeof(*LOCAL_ActiveError));
} else {
return e;
}
@ -941,6 +941,7 @@ typedef struct c_error_info {
;
#include <YapErrors.h>
#include <iopreds.h>
yap_error_class_number Yap_errorClass(yap_error_number e) {
return c_error_list[e].class;
@ -956,8 +957,8 @@ yap_error_descriptor_t *Yap_GetException(yap_error_descriptor_t *i) {
CACHE_REGS
if (i->errorNo != YAP_NO_ERROR) {
yap_error_descriptor_t *t = LOCAL_ActiveError,
*nt = malloc(sizeof(yap_error_descriptor_t));
memcpy(nt, t, sizeof(yap_error_descriptor_t));
*nt = calloc(1,sizeof(yap_error_descriptor_t));
memmove(nt, t, sizeof(yap_error_descriptor_t));
return nt;
}
return 0;
@ -1002,8 +1003,13 @@ static Int read_exception(USES_REGS1) {
}
static Int print_exception(USES_REGS1) {
yap_error_descriptor_t *t = AddressOfTerm(Deref(ARG1));
printErr(t);
Term t1 = Deref(ARG1);
if (IsAddressTerm(t1)) {
yap_error_descriptor_t *t = AddressOfTerm(t1);
printErr(t);
} else {
return Yap_WriteTerm(LOCAL_c_error_stream,t1,TermNil PASS_REGS);
}
// Yap_DebugPlWriteln(rc);
return true;
}

View File

@ -253,7 +253,7 @@ IntervalUDIRefitIndex(struct index_t **ip, UInt b[] USES_REGS)
qsort(s0+1, (size_t)*s0, sizeof(BITS32), compar);
it->links[offset0] = s0-sorted0;
if (it->udi_free_args) {
memcpy(sorted, s0+1, sizeof(BITS32)*(*s0));
memmove(sorted, s0+1, sizeof(BITS32)*(*s0));
qsort(sorted, (size_t)*s0, sizeof(BITS32), compar2);
sorted += *s0;
}

View File

@ -56,7 +56,7 @@
CPredicate f = PREG->y_u.Osbpp.p->cs.f_code;
PREG = NEXTOP(PREG, Osbpp);
saveregs();
d0 = (f)(PASS_REGS1);
d0 = f(PASS_REGS1);
setregs();
#ifdef SHADOW_S
SREG = Yap_REGS.S_;

View File

@ -475,7 +475,7 @@ loop:
goto overflow;
}
*ptf++ = AbsAppl(HR);
memcpy(HR, ap2, sizeof(CELL) * (3 + ap2[1]));
memmove(HR, ap2, sizeof(CELL) * (3 + ap2[1]));
HR += ap2[1] + 3;
break;
default: {
@ -756,7 +756,7 @@ restart:
res = -1;
goto error_handler;
}
memcpy(HR, ap, sizeof(CELL) * (3 + ap[1]));
memmove(HR, ap, sizeof(CELL) * (3 + ap[1]));
HR += ap[1] + 3;
break;
default: {

View File

@ -205,13 +205,13 @@ CopyLocalAndTrail( USES_REGS1 )
static void
IncrementalCopyStacksFromWorker( USES_REGS1 )
{
memcpy((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
memmove((void *) PtoGloAdjust((CELL *)LOCAL_start_global_copy),
(void *) (LOCAL_start_global_copy),
(size_t) (LOCAL_end_global_copy - LOCAL_start_global_copy));
memcpy((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy),
memmove((void *) PtoLocAdjust((CELL *)LOCAL_start_local_copy),
(void *) LOCAL_start_local_copy,
(size_t) (LOCAL_end_local_copy - LOCAL_start_local_copy));
memcpy((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy),
memmove((void *) PtoTRAdjust((tr_fr_ptr)LOCAL_start_trail_copy),
(void *) (LOCAL_start_trail_copy),
(size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy));
}

View File

@ -825,7 +825,7 @@ static inline int smaller_or_eq(Term t1, Term t2) {
}
static inline void clcpy(ClauseDef *d, ClauseDef *s) {
memcpy((void *)d, (void *)s, sizeof(ClauseDef));
memmove((void *)d, (void *)s, sizeof(ClauseDef));
}
static void insort(ClauseDef base[], CELL *p, CELL *q, int my_p) {
@ -2670,7 +2670,7 @@ static ClauseDef *copy_clauses(ClauseDef *max0, ClauseDef *min0, CELL *top,
save_machine_regs();
siglongjmp(cint->CompilerBotch, 4);
}
memcpy((void *)top, (void *)min0, sz);
memmove((void *)top, (void *)min0, sz);
return (ClauseDef *)top;
}

View File

@ -301,7 +301,7 @@ bool Yap_dup_op(OpEntry *op, ModEntry *she) {
OpEntry *info = (OpEntry *)Yap_AllocAtomSpace(sizeof(OpEntry));
if (!info)
return false;
memcpy(info, op, sizeof(OpEntry));
memmove(info, op, sizeof(OpEntry));
info->NextForME = she->OpForME;
she->OpForME = info;
info->OpModule = MkAtomTerm(she->AtomOfME);
@ -1162,7 +1162,7 @@ void Yap_init_yapor_workers(void) {
worker_id = proc;
Yap_remap_yapor_memory();
LOCAL = REMOTE(worker_id);
memcpy(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local));
memmove(REMOTE(worker_id), REMOTE(0), sizeof(struct worker_local));
InitWorker(worker_id);
break;
} else

View File

@ -199,7 +199,7 @@ const void *MallocExportAsRO(const void *pt USES_REGS) {
return NULL;
size_t sz = o->sz;
release_block(o);
memcpy((void *)o, pt, sz);
memmove((void *)o, pt, sz);
return realloc((void *)o, sz);
}
@ -690,7 +690,7 @@ static Atom write_atom(void *s0, seq_tv_t *out USES_REGS) {
} else {
size_t n = get_utf8(s, -1, &ch);
unsigned char *buf = Malloc(n + 1);
memcpy(buf, s0, n + 1);
memmove(buf, s0, n + 1);
return Yap_ULookupAtom(buf);
}
}
@ -921,7 +921,7 @@ bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) {
const unsigned char *ptr = skip_utf8(buf, out->max);
size_t diff = (ptr - buf);
char *nbuf = Malloc(diff + 1);
memcpy(nbuf, buf, diff);
memmove(nbuf, buf, diff);
nbuf[diff] = '\0';
leng = diff;
}

View File

@ -85,7 +85,7 @@ void *protected_pop_text_stack(int i, void *protected, bool tmp,
out = LOCAL_FileNameBuf;
else
out = p;
memcpy(out, protected, sz);
memmove(out, protected, sz);
} else {
free(p);
}
@ -661,7 +661,7 @@ static Atom write_atom(void *s0, seq_tv_t *out, size_t leng USES_REGS) {
return Yap_LookupAtom(s0);
} else {
unsigned char *buf = Malloc(leng + 1);
memcpy(buf, s0, leng);
memmove(buf, s0, leng);
buf[leng] = \0;
return Yap_ULookupAtom(buf);
}
@ -872,7 +872,7 @@ bool Yap_CVT_Text(seq_tv_t *inp, seq_tv_t *out USES_REGS) {
size_t max_s = skip_utf8( buf, out-> max )-buf;
if (max_s < leng_s) {
char *nbuf = Malloc(max_s + 1);
memcpy(nbuf, buf, max_s);
memmove(nbuf, buf, max_s);
nbuf[max_s] = '\0';
leng_s = out->max;
}

View File

@ -182,7 +182,7 @@ copy_complex_term(CELL *pt0, CELL *pt0_end, int share, int newattvs, CELL *ptf,
if (HR+sz > ASP - 2048) {
goto overflow;
}
memcpy((void *)HR, (void *)ap2, sz*sizeof(CELL));
memmove((void *)HR, (void *)ap2, sz*sizeof(CELL));
HR += sz;
} else {
*ptf++ = d0; /* you can just copy other extensions. */
@ -845,7 +845,7 @@ export_term_to_buffer(Term inpt, char *buf, char *bptr, CELL *t0 , CELL *tf, siz
if (buf + len < (char *)((CELL *)td + (tf-t0))) {
return FALSE;
}
memcpy((void *)td, (void *)t0, (tf-t0)* sizeof(CELL));
memmove((void *)td, (void *)t0, (tf-t0)* sizeof(CELL));
bf[0] = (td-buf);
bf[1] = (tf-t0);
bf[2] = inpt;
@ -945,7 +945,7 @@ export_complex_term(Term tf, CELL *pt0, CELL *pt0_end, char * buf, size_t len0,
if (HR+sz > ASP - 2048) {
goto overflow;
}
memcpy((void *)HR, (void *)ap2, sz*sizeof(CELL));
memmove((void *)HR, (void *)ap2, sz*sizeof(CELL));
HR += sz;
continue;
}
@ -1263,7 +1263,7 @@ Yap_ImportTerm(char * buf) {
return 0L;
}
}
memcpy(HR, buf+bc[0], sizeof(CELL)*sz);
memmove(HR, buf+bc[0], sizeof(CELL)*sz);
if (IsApplTerm(tinp)) {
tret = AbsAppl(HR);
import_compound(HR, (char *)HR, buf, HR);
@ -3476,7 +3476,7 @@ hash_complex_term(register CELL *pt0,
*st++ = LongIntOfTerm(d0);
break;
case (CELL)FunctorString:
memcpy(st, RepAppl(d0), (3+RepAppl(d0)[1])*sizeof(CELL));
memmove(st, RepAppl(d0), (3+RepAppl(d0)[1])*sizeof(CELL));
st += 3+RepAppl(d0)[1];
break;
#ifdef USE_GMP
@ -3491,7 +3491,7 @@ hash_complex_term(register CELL *pt0,
goto global_overflow;
}
/* then the actual number */
memcpy((void *)(st+1), (void *)(pt+1), sz);
memmove((void *)(st+1), (void *)(pt+1), sz);
st = st+sz/CellSize;
}
break;

View File

@ -567,7 +567,7 @@ List(APPEND YLIBS $<TARGET_OBJECTS:utf8proc>)
List(APPEND YLIBS $<TARGET_OBJECTS:myddas>)
List(APPEND YLIBS $<TARGET_OBJECTS:libswi>)
if (WIN32 OR ANDROID)
List(APPEND YLIBS $<TARGET_OBJECTS:Yapsqlite3>)
List(APPEND YLIBS $<TARGET_OBJECTS:YAPsqlite3>)
List(APPEND YLIBS $<TARGET_OBJECTS:YAP++>)
if (WIN32 AND WITH_PYTHON)
List(APPEND YLIBS $<TARGET_OBJECTS:Py4YAP>)

View File

@ -914,7 +914,7 @@ PredEntry *YAPPredicate::getPred(Term &t, CELL *&out) {
} else {
ap = RepPredProp(PredPropByFunc(f, m));
if (out)
memcpy( out, RepAppl(t) + 1, ap->ArityOfPE*sizeof(CELL) );
memmove( out, RepAppl(t) + 1, ap->ArityOfPE*sizeof(CELL) );
else
out = RepAppl(t) + 1;
}

View File

@ -309,7 +309,6 @@ extern void Yap_DebugPlWriteln(Term t);
extern void Yap_DebugErrorPutc(int n);
extern void Yap_DebugErrorPuts(const char *s);
extern void Yap_DebugWriteIndicator(struct pred_entry *ap);
extern void Yap_PlWriteToStream(Term, int, int);
extern void Yap_CloseReadline(void);
/* depth_lim.c */
extern bool Yap_InitReadline(Term t);

View File

@ -181,14 +181,14 @@ INLINE_ONLY void init_absmi_regs(REGSTORE *absmi_regs);
INLINE_ONLY void init_absmi_regs(REGSTORE *absmi_regs) {
CACHE_REGS
memcpy(absmi_regs, Yap_regp, sizeof(REGSTORE));
memmove(absmi_regs, Yap_regp, sizeof(REGSTORE));
}
INLINE_ONLY void restore_absmi_regs(REGSTORE *old_regs);
INLINE_ONLY void restore_absmi_regs(REGSTORE *old_regs) {
CACHE_REGS
memcpy(old_regs, Yap_regp, sizeof(REGSTORE));
memmove(old_regs, Yap_regp, sizeof(REGSTORE));
#ifdef THREADS
pthread_setspecific(Yap_yaamregs_key, (void *)old_regs);
LOCAL_ThreadHandle.current_yaam_regs = old_regs;

View File

@ -95,7 +95,7 @@ typedef enum{
t_createLowerExpectIntrinsicPass, //Removes llvm.expect intrinsics and creates "block_weights" metadata
t_createLowerInvokePass, //Converts invoke and unwind instructions to use sjlj exception handling mechanisms
t_createLowerSwitchPass, //Converts SwitchInst instructions into a sequence of chained binary branch instructions
t_createMemCpyOptPass, //Performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset's
t_createMemCpyOptPass, //Performs optimizations related to eliminating memmove calls and/or combining multiple stores into memset's
t_createMergeFunctionsPass, //Discovers identical functions and collapses them
t_createObjCARCAPElimPass, //ObjC ARC autorelease pool elimination
t_createObjCARCContractPass, //Late ObjC ARC cleanups

View File

@ -95,7 +95,7 @@ typedef struct {
#define utarray_push_back(a,p) do { \
utarray_reserve(a,1); \
if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,(a)->i++), p); } \
else { memcpy(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \
else { memmove(_utarray_eltptr(a,(a)->i++), p, (a)->icd.sz); }; \
} while(0)
#define utarray_pop_back(a) do { \
@ -123,7 +123,7 @@ typedef struct {
((a)->i - (j))*((a)->icd.sz)); \
} \
if ((a)->icd.copy) { (a)->icd.copy( _utarray_eltptr(a,j), p); } \
else { memcpy(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \
else { memmove(_utarray_eltptr(a,j), p, (a)->icd.sz); }; \
(a)->i++; \
} while(0)
@ -142,7 +142,7 @@ typedef struct {
(a)->icd.copy(_utarray_eltptr(a,j+_ut_i), _utarray_eltptr(w,_ut_i)); \
} \
} else { \
memcpy(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \
memmove(_utarray_eltptr(a,j), _utarray_eltptr(w,0), \
utarray_len(w)*((a)->icd.sz)); \
} \
(a)->i += utarray_len(w); \

View File

@ -95,7 +95,7 @@ typedef enum{
t_createLowerExpectIntrinsicPass, //Removes llvm.expect intrinsics and creates "block_weights" metadata
t_createLowerInvokePass, //Converts invoke and unwind instructions to use sjlj exception handling mechanisms
t_createLowerSwitchPass, //Converts SwitchInst instructions into a sequence of chained binary branch instructions
t_createMemCpyOptPass, //Performs optimizations related to eliminating memcpy calls and/or combining multiple stores into memset's
t_createMemCpyOptPass, //Performs optimizations related to eliminating memmove calls and/or combining multiple stores into memset's
t_createMergeFunctionsPass, //Discovers identical functions and collapses them
t_createObjCARCAPElimPass, //ObjC ARC autorelease pool elimination
t_createObjCARCContractPass, //Late ObjC ARC cleanups

View File

@ -66,29 +66,29 @@ static void share_private_nodes(int worker_q);
#endif
#define P_COPY_GLOBAL_TO(Q) \
memcpy((void *) (worker_offset(Q) + REMOTE_start_global_copy(Q)), \
memmove((void *) (worker_offset(Q) + REMOTE_start_global_copy(Q)), \
(void *) REMOTE_start_global_copy(Q), \
(size_t) (REMOTE_end_global_copy(Q) - REMOTE_start_global_copy(Q)))
#define Q_COPY_GLOBAL_FROM(P) \
memcpy((void *) LOCAL_start_global_copy, \
memmove((void *) LOCAL_start_global_copy, \
(void *) (worker_offset(P) + LOCAL_start_global_copy), \
(size_t) (LOCAL_end_global_copy - LOCAL_start_global_copy))
#define P_COPY_LOCAL_TO(Q) \
memcpy((void *) (worker_offset(Q) + REMOTE_start_local_copy(Q)), \
memmove((void *) (worker_offset(Q) + REMOTE_start_local_copy(Q)), \
(void *) REMOTE_start_local_copy(Q), \
(size_t) (REMOTE_end_local_copy(Q) - REMOTE_start_local_copy(Q)))
#define Q_COPY_LOCAL_FROM(P) \
memcpy((void *) LOCAL_start_local_copy, \
memmove((void *) LOCAL_start_local_copy, \
(void *) (worker_offset(P) + LOCAL_start_local_copy), \
(size_t) (LOCAL_end_local_copy - LOCAL_start_local_copy))
#define P_COPY_TRAIL_TO(Q) \
memcpy((void *) (worker_offset(Q) + REMOTE_start_trail_copy(Q)), \
memmove((void *) (worker_offset(Q) + REMOTE_start_trail_copy(Q)), \
(void *) REMOTE_start_trail_copy(Q), \
(size_t) (REMOTE_end_trail_copy(Q) - REMOTE_start_trail_copy(Q)))
#define Q_COPY_TRAIL_FROM(P) \
memcpy((void *) LOCAL_start_trail_copy, \
memmove((void *) LOCAL_start_trail_copy, \
(void *) (worker_offset(P) + LOCAL_start_trail_copy), \
(size_t) (LOCAL_end_trail_copy - LOCAL_start_trail_copy))

View File

@ -409,13 +409,13 @@ void resume_suspension_frame(susp_fr_ptr resume_fr, or_fr_ptr top_or_fr) {
sg_fr_ptr sg_frame;
/* copy suspended stacks */
memcpy(SuspFr_global_reg(resume_fr),
memmove(SuspFr_global_reg(resume_fr),
SuspFr_global_start(resume_fr),
SuspFr_global_size(resume_fr));
memcpy(SuspFr_local_reg(resume_fr),
memmove(SuspFr_local_reg(resume_fr),
SuspFr_local_start(resume_fr),
SuspFr_local_size(resume_fr));
memcpy(SuspFr_trail_reg(resume_fr),
memmove(SuspFr_trail_reg(resume_fr),
SuspFr_trail_start(resume_fr),
SuspFr_trail_size(resume_fr));

View File

@ -574,9 +574,9 @@ typedef enum {
SuspFr_global_size(SUSP_FR) = H_SIZE; \
SuspFr_local_size(SUSP_FR) = B_SIZE; \
SuspFr_trail_size(SUSP_FR) = TR_SIZE; \
memcpy(SuspFr_global_start(SUSP_FR), SuspFr_global_reg(SUSP_FR), H_SIZE); \
memcpy(SuspFr_local_start(SUSP_FR), SuspFr_local_reg(SUSP_FR), B_SIZE); \
memcpy(SuspFr_trail_start(SUSP_FR), SuspFr_trail_reg(SUSP_FR), TR_SIZE)
memmove(SuspFr_global_start(SUSP_FR), SuspFr_global_reg(SUSP_FR), H_SIZE); \
memmove(SuspFr_local_start(SUSP_FR), SuspFr_local_reg(SUSP_FR), B_SIZE); \
memmove(SuspFr_trail_start(SUSP_FR), SuspFr_trail_reg(SUSP_FR), TR_SIZE)
#define new_subgoal_trie_node(NODE, ENTRY, CHILD, PARENT, NEXT) \
ALLOC_SUBGOAL_TRIE_NODE(NODE); \

View File

@ -665,12 +665,12 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str,
bucket = Hash_buckets(hash);
last_bucket = bucket + Hash_num_buckets(hash);
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
do {
if (*bucket) {
traverse_subgoal_trie(*bucket, str, str_index, arity, mode,
TRAVERSE_POSITION_FIRST PASS_REGS);
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -687,7 +687,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str,
/* save current state if first sibling node */
if (position == TRAVERSE_POSITION_FIRST) {
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
current_str_index = str_index;
current_mode = mode;
}
@ -737,7 +737,7 @@ static void traverse_subgoal_trie(sg_node_ptr current_node, char *str,
mode = current_mode;
current_node = TrNode_next(current_node);
while (current_node) {
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -768,12 +768,12 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str,
bucket = Hash_buckets(hash);
last_bucket = bucket + Hash_num_buckets(hash);
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
do {
if (*bucket) {
traverse_answer_trie(*bucket, str, str_index, arity, var_index, mode,
TRAVERSE_POSITION_FIRST PASS_REGS);
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -790,7 +790,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str,
/* save current state if first sibling node */
if (position == TRAVERSE_POSITION_FIRST) {
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
current_str_index = str_index;
current_var_index = var_index;
current_mode = mode;
@ -832,7 +832,7 @@ static void traverse_answer_trie(ans_node_ptr current_node, char *str,
mode = current_mode;
current_node = TrNode_next(current_node);
while (current_node) {
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -863,12 +863,12 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str,
bucket = Hash_buckets(hash);
last_bucket = bucket + Hash_num_buckets(hash);
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
do {
if (*bucket) {
traverse_global_trie(*bucket, str, str_index, arity, mode,
TRAVERSE_POSITION_FIRST PASS_REGS);
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -885,7 +885,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str,
/* save current state if first sibling node */
if (position == TRAVERSE_POSITION_FIRST) {
current_arity = (int *)malloc(sizeof(int) * (arity[0] + 1));
memcpy(current_arity, arity, sizeof(int) * (arity[0] + 1));
memmove(current_arity, arity, sizeof(int) * (arity[0] + 1));
current_str_index = str_index;
current_mode = mode;
}
@ -913,7 +913,7 @@ static void traverse_global_trie(gt_node_ptr current_node, char *str,
mode = current_mode;
current_node = TrNode_next(current_node);
while (current_node) {
memcpy(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
memmove(arity, current_arity, sizeof(int) * (current_arity[0] + 1));
#ifdef TRIE_COMPACT_PAIRS
if (arity[arity[0]] == -2 && str[str_index - 1] != '[')
str[str_index - 1] = ',';
@ -1200,7 +1200,7 @@ sg_fr_ptr subgoal_search(yamop *preg, CELL **Yaddr) {
#ifdef MODE_DIRECTED_TABLING
if (subs_pos) {
ALLOC_BLOCK(mode_directed, subs_pos * sizeof(int), int);
memcpy((void *)mode_directed, (void *)aux_mode_directed,
memmove((void *)mode_directed, (void *)aux_mode_directed,
subs_pos * sizeof(int));
} else
mode_directed = NULL;

View File

@ -77,7 +77,7 @@
#define copy_aux_stack() \
{ arity_t size = 3 + heap_arity + subs_arity + vars_arity; \
TOP_STACK -= size; \
memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
memmove(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
aux_stack = TOP_STACK; \
}/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' **
** do not include 'set_cut' because trie instructions are cut safe */

View File

@ -77,7 +77,7 @@
#define copy_aux_stack() \
{ int size = 3 + heap_arity + subs_arity + vars_arity; \
TOP_STACK -= size; \
memcpy(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
memmove(TOP_STACK, aux_stack, size * sizeof(CELL *)); \
aux_stack = TOP_STACK; \
}/* macros 'store_trie_node', 'restore_trie_node' and 'pop_trie_node' **
** do not include 'set_cut' because trie instructions are cut safe */

View File

@ -496,7 +496,7 @@
/* Define to 1 if you have the `mbsnrtowcs' function. */
#undef HAVE_MBSNRTOWCS
/* Define to 1 if you have the `memcpy' function. */
/* Define to 1 if you have the `memmove' function. */
#undef HAVE_MEMCPY
/* Define to 1 if you have the `memmove' function. */

View File

@ -1767,7 +1767,7 @@ AC_CHECK_FUNCS(localeconv localtime lstat mallinfo)
AC_CHECK_FUNCS(mbscoll)
AC_CHECK_FUNCS(mbscasecoll)
AC_CHECK_FUNCS(mbsnrtowcs)
AC_CHECK_FUNCS(memcpy memmove mkstemp mktemp)
AC_CHECK_FUNCS(memmove memmove mkstemp mktemp)
AC_CHECK_FUNCS(nanosleep mktime opendir)
AC_CHECK_FUNCS(putenv rand random drand48)
AC_CHECK_FUNCS(readlink realpath regexec)

View File

@ -291,7 +291,7 @@ check_symbol_exists(mallinfo " malloc.h" HAVE_MALLINFO)
check_function_exists(mbscoll HAVE_MBSCOLL)
check_function_exists(mbscasecoll HAVE_MBSCASECOLL)
check_function_exists(mbsnrtowcs HAVE_MBSNRTOWCS)
check_function_exists(memcpy HAVE_MEMCPY)
check_function_exists(memmove HAVE_MEMCPY)
check_function_exists(memmove HAVE_MEMMOVE)
check_function_exists(mkstemp HAVE_MKSTEMP)
check_function_exists(mktemp HAVE_MKTEMP)

View File

@ -897,7 +897,7 @@ function. */
#cmakedefine HAVE_MBSNRTOWCS ${HAVE_MBSNRTOWCS}
#endif
/* Define to 1 if you have the `memcpy' function. */
/* Define to 1 if you have the `memmove' function. */
#ifndef HAVE_MEMCPY
#cmakedefine HAVE_MEMCPY ${HAVE_MEMCPY}
#endif

View File

@ -356,7 +356,7 @@ Srlc_write(void *handle, char *buffer, size_t size)
{ char buf[sizeof(TCHAR)]; /* Pad to TCHAR */
size_t i = sizeof(TCHAR) - (size-n);
memcpy(buf, buffer+n, i);
memmove(buf, buffer+n, i);
for(; i<sizeof(TCHAR); i++)
buf[i] = '?';
rlc_write(c, (TCHAR*)buffer, 1);

View File

@ -26,7 +26,7 @@
*/
:- module(charsio, [
:- module(system(charsio), [
format_to_chars/3,
format_to_chars/4,
write_to_chars/3,

View File

@ -593,7 +593,7 @@ Bfree
}
}
#define Bcopy(x,y) memcpy((char *)&x->sign, (char *)&y->sign, \
#define Bcopy(x,y) memmove((char *)&x->sign, (char *)&y->sign, \
y->wds*sizeof(Long) + 2*sizeof(int))
static Bigint *

View File

@ -42,7 +42,7 @@ growBuffer(Buffer b, size_t minfree)
{ if ( !(new = malloc(sz)) )
return FALSE;
memcpy(new, b->static_buffer, osz);
memmove(new, b->static_buffer, osz);
} else
{ if ( !(new = realloc(b->base, sz)) )
return FALSE;

View File

@ -2381,7 +2381,7 @@ re_buffer(IOSTREAM *s, const char *from, size_t len)
{ s->bufp = s->limitp = s->buffer;
}
memcpy(s->bufp, from, len);
memmove(s->bufp, from, len);
s->bufp += len;
}
@ -5846,7 +5846,7 @@ struct PL_local_data *Yap_InitThreadIO(int wid)
return p;
}
#if THREADS
memcpy(p, Yap_local[0]->PL_local_data_p_, sizeof(struct PL_local_data));
memmove(p, Yap_local[0]->PL_local_data_p_, sizeof(struct PL_local_data));
#endif
return p;
}

View File

@ -1426,7 +1426,7 @@ localizeDecimalPoint(PL_locale *locale, Buffer b)
if ( strncmp(e, ddp, ddplen) == 0 )
{ if ( dplen == ddplen )
{ memcpy(e, dp, dplen);
{ memmove(e, dp, dplen);
} else
{ char *ob = baseBuffer(b, char);
if ( dplen > ddplen && !growBuffer(b, dplen-ddplen) )
@ -1434,7 +1434,7 @@ localizeDecimalPoint(PL_locale *locale, Buffer b)
e += baseBuffer(b, char) - ob;
memmove(&e[dplen-ddplen], e, strlen(e)+1);
memcpy(e, dp, dplen);
memmove(e, dp, dplen);
}
}
}
@ -1477,7 +1477,7 @@ groupDigits(PL_locale *locale, Buffer b)
{ *o-- = *e--;
if ( --gsize == 0 && e>=s )
{ o -= thslen-1;
memcpy(o, ths, thslen);
memmove(o, ths, thslen);
o--;
if ( grouping[1] == 0 )
gsize = grouping[0];

View File

@ -429,7 +429,7 @@ win_exec(size_t len, const wchar_t *cmd, UINT show)
/* ensure 0-terminated */
wcmd = PL_malloc((len+1)*sizeof(wchar_t));
memcpy(wcmd, cmd, len*sizeof(wchar_t));
memmove(wcmd, cmd, len*sizeof(wchar_t));
wcmd[len] = 0;
rval = CreateProcessW(NULL, /* app */

View File

@ -953,7 +953,7 @@ getenv3(const char *name, char *buf, size_t len)
if ( s )
{ if ( (l=strlen(s)) < len )
memcpy(buf, s, l+1);
memmove(buf, s, l+1);
else if ( len > 0 )
buf[0] = EOS; /* empty string if not fit */

View File

@ -253,7 +253,7 @@ static void growToBuffer(int c, ReadData _PL_rd) {
if (rb.base == rb.fast) /* intptr_t clause: jump to use malloc() */
{
rb.base = PL_malloc(FASTBUFFERSIZE * 2);
memcpy(rb.base, rb.fast, FASTBUFFERSIZE);
memmove(rb.base, rb.fast, FASTBUFFERSIZE);