Merge ../yap-6.2
This commit is contained in:
commit
bdc497cba0
@ -133,7 +133,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
||||
|
||||
ofiles->handle = handle;
|
||||
|
||||
if (!*init_proc)
|
||||
if (proc_name && !*init_proc)
|
||||
*init_proc = (YapInitProc) dlsym(handle,proc_name);
|
||||
|
||||
ofiles = ofiles->next;
|
||||
|
@ -261,7 +261,8 @@ Yap_ReOpenLoadForeign(void)
|
||||
while (f_code != NULL) {
|
||||
CurrentModule = f_code->module;
|
||||
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||
(*InitProc)();
|
||||
if (InitProc)
|
||||
(*InitProc)();
|
||||
}
|
||||
f_code = f_code->next;
|
||||
}
|
||||
|
@ -513,8 +513,8 @@ extern X_API int PL_recorded_external(char *, term_t);
|
||||
extern X_API int PL_erase_external(char *);
|
||||
extern X_API int PL_action(int,...);
|
||||
extern X_API void PL_on_halt(void (*)(int, void *), void *);
|
||||
extern X_API void *PL_malloc(int);
|
||||
extern X_API void *PL_realloc(void*,int);
|
||||
extern X_API void *PL_malloc(size_t);
|
||||
extern X_API void *PL_realloc(void*,size_t);
|
||||
extern X_API void PL_free(void *);
|
||||
extern X_API int PL_eval_expression_to_int64_ex(term_t t, int64_t *val);
|
||||
extern X_API void PL_cleanup_fork(void);
|
||||
|
@ -272,8 +272,8 @@ ensure_space(char **sp, size_t room, unsigned flags) {
|
||||
min += 512;
|
||||
|
||||
if (flags & BUF_MALLOC) {
|
||||
free(*sp);
|
||||
*sp = malloc(room);
|
||||
PL_free(*sp);
|
||||
*sp = PL_malloc(room);
|
||||
return *sp;
|
||||
} else if (flags & BUF_RING) {
|
||||
for (i=1; i<= SWI_BUF_RINGS; i++)
|
||||
@ -512,7 +512,7 @@ static int do_yap_putc(int sno, wchar_t ch) {
|
||||
UInt bufsize = putc_cur_lim-putc_cur_buf;
|
||||
UInt bufpos = putc_curp-putc_cur_buf;
|
||||
|
||||
if (!(putc_cur_buf = realloc(putc_cur_buf, bufsize+SWI_BUF_SIZE))) {
|
||||
if (!(putc_cur_buf = PL_realloc(putc_cur_buf, bufsize+SWI_BUF_SIZE))) {
|
||||
/* we can+t go forever */
|
||||
return FALSE;
|
||||
}
|
||||
@ -564,7 +564,7 @@ X_API int PL_get_chars(term_t l, char **sp, unsigned flags)
|
||||
if ((flags & BUF_RING)) {
|
||||
tmp = alloc_ring_buf();
|
||||
} else if ((flags & BUF_MALLOC)) {
|
||||
tmp = malloc(SWI_BUF_SIZE);
|
||||
tmp = PL_malloc(SWI_BUF_SIZE);
|
||||
} else {
|
||||
tmp = SWI_buffers[0];
|
||||
}
|
||||
@ -641,7 +641,7 @@ X_API int PL_get_chars(term_t l, char **sp, unsigned flags)
|
||||
}
|
||||
if (flags & BUF_MALLOC) {
|
||||
size_t sz = strlen(tmp);
|
||||
char *nbf = malloc(sz+1);
|
||||
char *nbf = PL_malloc(sz+1);
|
||||
if (!nbf)
|
||||
return 0;
|
||||
strncpy(nbf,tmp,sz+1);
|
||||
@ -685,7 +685,7 @@ X_API int PL_get_wchars(term_t l, size_t *len, wchar_t **wsp, unsigned flags)
|
||||
}
|
||||
room = (sz+1)*sizeof(wchar_t);
|
||||
if (flags & BUF_MALLOC) {
|
||||
*wsp = buf = (wchar_t *)malloc(room);
|
||||
*wsp = buf = (wchar_t *)PL_malloc(room);
|
||||
} else if (flags & BUF_RING) {
|
||||
*wsp = (wchar_t *)alloc_ring_buf();
|
||||
buf = (wchar_t *)ensure_space((char **)wsp, room, flags);
|
||||
@ -3011,21 +3011,33 @@ PL_set_engine(PL_engine_t engine, PL_engine_t *old)
|
||||
|
||||
|
||||
X_API void *
|
||||
PL_malloc(int sz)
|
||||
PL_malloc(size_t sz)
|
||||
{
|
||||
return (void *)Yap_AllocCodeSpace((long unsigned int)sz);
|
||||
if ( sz == 0 )
|
||||
return NULL;
|
||||
return (void *)malloc((long unsigned int)sz);
|
||||
}
|
||||
|
||||
X_API void *
|
||||
PL_realloc(void *ptr, int sz)
|
||||
PL_realloc(void *ptr, size_t sz)
|
||||
{
|
||||
return Yap_ReallocCodeSpace((char *)ptr,(long unsigned int)sz);
|
||||
if (ptr) {
|
||||
if (sz) {
|
||||
return realloc((char *)ptr,(long unsigned int)sz);
|
||||
} else {
|
||||
free(ptr);
|
||||
return NULL;
|
||||
}
|
||||
} else {
|
||||
return PL_malloc(sz);
|
||||
}
|
||||
}
|
||||
|
||||
X_API void
|
||||
PL_free(void *obj)
|
||||
{
|
||||
return Yap_FreeCodeSpace((char *)obj);
|
||||
if (obj)
|
||||
free(obj);
|
||||
}
|
||||
|
||||
X_API int
|
||||
|
@ -45,6 +45,8 @@
|
||||
:- use_module(library(option)).
|
||||
:- use_module(library(error)).
|
||||
|
||||
:- use_module(library(maplist)).
|
||||
|
||||
:- use_foreign_library(foreign(process)).
|
||||
|
||||
/** <module> Create processes and redirect I/O
|
||||
|
10
pl/utils.yap
10
pl/utils.yap
@ -220,9 +220,17 @@ cd :-
|
||||
|
||||
ls :-
|
||||
getcwd(X),
|
||||
system:directory_files(X, L),
|
||||
'$load_system_ls'(X,L),
|
||||
'$do_print_files'(L).
|
||||
|
||||
'$load_system_ls'(X,L) :-
|
||||
'$undefined'(directory_files(X, L), operating_system_support),
|
||||
load_files(library(system),[silent(true)]),
|
||||
fail.
|
||||
'$load_system_ls'(X,L) :-
|
||||
operating_system_support:directory_files(X, L).
|
||||
|
||||
|
||||
'$do_print_files'([]) :-
|
||||
nl.
|
||||
'$do_print_files'([F| Fs]) :-
|
||||
|
18
pl/yio.yap
18
pl/yio.yap
@ -1209,3 +1209,21 @@ with_output_to(Output, Command) :-
|
||||
atom_codes(Char, [Code]),
|
||||
'$codes_to_chars'(String0, String, Chars).
|
||||
|
||||
prolog_to_os_filename(Prolog, OS) :-
|
||||
'$undefined'(swi_prolog_to_os_filename(Prolog, OS), system),
|
||||
'$current_module'(Old, system),
|
||||
load_foreign_files([libplstream], [], initIO),
|
||||
'$current_module'(system, Old),
|
||||
fail.
|
||||
prolog_to_os_filename(Prolog, OS) :-
|
||||
system:swi_prolog_to_os_filename(Prolog, OS).
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user