update to newer pl-file.c and pl-write.c.

This commit is contained in:
Vitor Santos Costa
2013-01-15 16:51:55 +00:00
parent 5ae2ccc416
commit e85e76cd57
17 changed files with 1820 additions and 1221 deletions

View File

@@ -225,6 +225,35 @@ users foreign language code.
*******************************/
#define WM_SIGNALLED (WM_USER+4201) /* how to select a good number!? */
#endif
// THIS HAS TO BE ABSTRACTED
#define GLOBAL_LD (LOCAL_PL_local_data_p)
#if !defined(O_PLMT) && !defined(YAPOR)
#define LOCAL_LD (GLOBAL_LD)
#define LD (GLOBAL_LD)
#define ARG1_LD void
#define ARG_LD
#define GET_LD
#define PRED_LD
#define PASS_LD
#define PASS_LD1
#else
#define LOCAL_LD (__PL_ld)
#define LD LOCAL_LD
#define GET_LD CACHE_REGS struct PL_local_data *__PL_ld = GLOBAL_LD;
#define ARG1_LD struct PL_local_data *__PL_ld
#define ARG_LD , ARG1_LD
#define PASS_LD1 LD
#define PASS_LD , LD
#define PRED_LD GET_LD
#endif
/********************************
@@ -481,6 +510,27 @@ typedef struct exception_frame /* PL_throw exception environments */
jmp_buf exception_jmp_env; /* longjmp environment */
} exception_frame;
/*******************************
* STREAM I/O *
*******************************/
#define REDIR_MAGIC 0x23a9bef3
typedef struct redir_context
{ int magic; /* REDIR_MAGIC */
IOSTREAM *stream; /* temporary output */
int is_stream; /* redirect to stream */
int redirected; /* output is redirected */
term_t term; /* redirect target */
int out_format; /* output type */
int out_arity; /* 2 for difference-list versions */
size_t size; /* size of I/O buffer */
char *data; /* data written */
char buffer[1024]; /* fast temporary buffer */
} redir_context;
#include "pl-file.h"
/* vsc: global variables */
#include "pl-global.h"
@@ -558,25 +608,6 @@ typedef struct wakeup_state
} wakeup_state;
/*******************************
* STREAM I/O *
*******************************/
#define REDIR_MAGIC 0x23a9bef3
typedef struct redir_context
{ int magic; /* REDIR_MAGIC */
IOSTREAM *stream; /* temporary output */
int is_stream; /* redirect to stream */
int redirected; /* output is redirected */
term_t term; /* redirect target */
int out_format; /* output type */
int out_arity; /* 2 for difference-list versions */
size_t size; /* size of I/O buffer */
char *data; /* data written */
char buffer[1024]; /* fast temporary buffer */
} redir_context;
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
Defining built-in predicates using the new interface
@@ -740,7 +771,19 @@ PL_EXPORT(int) PL_release_stream(IOSTREAM *s);
COMMON(atom_t) fileNameStream(IOSTREAM *s);
COMMON(int) streamStatus(IOSTREAM *s);
COMMON(int) getOutputStream(term_t t, IOSTREAM **s);
#define getOutputStream(t, k, s) getOutputStream__LD(t, k, s PASS_LD)
#define getTextOutputStream(t, s) getTextOutputStream__LD(t, s PASS_LD)
#define getBinaryOutputStream(t, s) getBinaryOutputStream__LD(t, s PASS_LD)
#define getInputStream(t, k, s) getInputStream__LD(t, k, s PASS_LD)
#define getTextInputStream(t, s) getTextInputStream__LD(t, s PASS_LD)
#define getBinaryInputStream(t, s) getBinaryInputStream__LD(t, s PASS_LD)
COMMON(int) getTextOutputStream__LD(term_t t, IOSTREAM **s ARG_LD);
COMMON(int) getBinaryOutputStream__LD(term_t t, IOSTREAM **s ARG_LD);
COMMON(int) getTextInputStream__LD(term_t t, IOSTREAM **s ARG_LD);
COMMON(int) getBinaryInputStream__LD(term_t t, IOSTREAM **s ARG_LD);
COMMON(void) pushOutputContext(void);
COMMON(void) popOutputContext(void);
COMMON(int) getSingleChar(IOSTREAM *s, int signals);
@@ -869,7 +912,6 @@ setBoolean(int *flag, term_t old, term_t new)
succeed;
}
COMMON(int) getInputStream__LD(term_t t, IOSTREAM **s ARG_LD);
COMMON(int) PL_get_atom__LD(term_t t1, atom_t *a ARG_LD);
COMMON(int) PL_get_atom_ex__LD(term_t t, atom_t *a ARG_LD);
@@ -901,7 +943,14 @@ static inline void *allocHeap__LD(size_t n ARG_LD)
return YAP_AllocSpaceFromYap(n);
}
static inline void freeHeap__LD(void *mem, size_t n ARG_LD)
static inline void *allocHeapOrHalt(size_t n)
{
void *ptr = YAP_AllocSpaceFromYap(n);
if (!ptr) Yap_exit(1);
return ptr;
}
static inline void freeHeap(void *mem, size_t n)
{
YAP_FreeSpaceFromYap(mem);
}