Merge ../yap-6.2
This commit is contained in:
commit
bdc497cba0
@ -133,7 +133,7 @@ LoadForeign(StringList ofiles, StringList libs,
|
|||||||
|
|
||||||
ofiles->handle = handle;
|
ofiles->handle = handle;
|
||||||
|
|
||||||
if (!*init_proc)
|
if (proc_name && !*init_proc)
|
||||||
*init_proc = (YapInitProc) dlsym(handle,proc_name);
|
*init_proc = (YapInitProc) dlsym(handle,proc_name);
|
||||||
|
|
||||||
ofiles = ofiles->next;
|
ofiles = ofiles->next;
|
||||||
|
@ -261,6 +261,7 @@ Yap_ReOpenLoadForeign(void)
|
|||||||
while (f_code != NULL) {
|
while (f_code != NULL) {
|
||||||
CurrentModule = f_code->module;
|
CurrentModule = f_code->module;
|
||||||
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
if(Yap_ReLoadForeign(f_code->objs,f_code->libs,f_code->f,&InitProc)==LOAD_SUCCEEDED) {
|
||||||
|
if (InitProc)
|
||||||
(*InitProc)();
|
(*InitProc)();
|
||||||
}
|
}
|
||||||
f_code = f_code->next;
|
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_erase_external(char *);
|
||||||
extern X_API int PL_action(int,...);
|
extern X_API int PL_action(int,...);
|
||||||
extern X_API void PL_on_halt(void (*)(int, void *), void *);
|
extern X_API void PL_on_halt(void (*)(int, void *), void *);
|
||||||
extern X_API void *PL_malloc(int);
|
extern X_API void *PL_malloc(size_t);
|
||||||
extern X_API void *PL_realloc(void*,int);
|
extern X_API void *PL_realloc(void*,size_t);
|
||||||
extern X_API void PL_free(void *);
|
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 int PL_eval_expression_to_int64_ex(term_t t, int64_t *val);
|
||||||
extern X_API void PL_cleanup_fork(void);
|
extern X_API void PL_cleanup_fork(void);
|
||||||
|
@ -272,8 +272,8 @@ ensure_space(char **sp, size_t room, unsigned flags) {
|
|||||||
min += 512;
|
min += 512;
|
||||||
|
|
||||||
if (flags & BUF_MALLOC) {
|
if (flags & BUF_MALLOC) {
|
||||||
free(*sp);
|
PL_free(*sp);
|
||||||
*sp = malloc(room);
|
*sp = PL_malloc(room);
|
||||||
return *sp;
|
return *sp;
|
||||||
} else if (flags & BUF_RING) {
|
} else if (flags & BUF_RING) {
|
||||||
for (i=1; i<= SWI_BUF_RINGS; i++)
|
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 bufsize = putc_cur_lim-putc_cur_buf;
|
||||||
UInt bufpos = putc_curp-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 */
|
/* we can+t go forever */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -564,7 +564,7 @@ X_API int PL_get_chars(term_t l, char **sp, unsigned flags)
|
|||||||
if ((flags & BUF_RING)) {
|
if ((flags & BUF_RING)) {
|
||||||
tmp = alloc_ring_buf();
|
tmp = alloc_ring_buf();
|
||||||
} else if ((flags & BUF_MALLOC)) {
|
} else if ((flags & BUF_MALLOC)) {
|
||||||
tmp = malloc(SWI_BUF_SIZE);
|
tmp = PL_malloc(SWI_BUF_SIZE);
|
||||||
} else {
|
} else {
|
||||||
tmp = SWI_buffers[0];
|
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) {
|
if (flags & BUF_MALLOC) {
|
||||||
size_t sz = strlen(tmp);
|
size_t sz = strlen(tmp);
|
||||||
char *nbf = malloc(sz+1);
|
char *nbf = PL_malloc(sz+1);
|
||||||
if (!nbf)
|
if (!nbf)
|
||||||
return 0;
|
return 0;
|
||||||
strncpy(nbf,tmp,sz+1);
|
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);
|
room = (sz+1)*sizeof(wchar_t);
|
||||||
if (flags & BUF_MALLOC) {
|
if (flags & BUF_MALLOC) {
|
||||||
*wsp = buf = (wchar_t *)malloc(room);
|
*wsp = buf = (wchar_t *)PL_malloc(room);
|
||||||
} else if (flags & BUF_RING) {
|
} else if (flags & BUF_RING) {
|
||||||
*wsp = (wchar_t *)alloc_ring_buf();
|
*wsp = (wchar_t *)alloc_ring_buf();
|
||||||
buf = (wchar_t *)ensure_space((char **)wsp, room, flags);
|
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 *
|
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 *
|
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
|
X_API void
|
||||||
PL_free(void *obj)
|
PL_free(void *obj)
|
||||||
{
|
{
|
||||||
return Yap_FreeCodeSpace((char *)obj);
|
if (obj)
|
||||||
|
free(obj);
|
||||||
}
|
}
|
||||||
|
|
||||||
X_API int
|
X_API int
|
||||||
|
@ -45,6 +45,8 @@
|
|||||||
:- use_module(library(option)).
|
:- use_module(library(option)).
|
||||||
:- use_module(library(error)).
|
:- use_module(library(error)).
|
||||||
|
|
||||||
|
:- use_module(library(maplist)).
|
||||||
|
|
||||||
:- use_foreign_library(foreign(process)).
|
:- use_foreign_library(foreign(process)).
|
||||||
|
|
||||||
/** <module> Create processes and redirect I/O
|
/** <module> Create processes and redirect I/O
|
||||||
|
10
pl/utils.yap
10
pl/utils.yap
@ -220,9 +220,17 @@ cd :-
|
|||||||
|
|
||||||
ls :-
|
ls :-
|
||||||
getcwd(X),
|
getcwd(X),
|
||||||
system:directory_files(X, L),
|
'$load_system_ls'(X,L),
|
||||||
'$do_print_files'(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'([]) :-
|
'$do_print_files'([]) :-
|
||||||
nl.
|
nl.
|
||||||
'$do_print_files'([F| Fs]) :-
|
'$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]),
|
atom_codes(Char, [Code]),
|
||||||
'$codes_to_chars'(String0, String, Chars).
|
'$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