locking and other small fixes
This commit is contained in:
parent
34fe3e6ded
commit
9326b2ea62
@ -1,16 +0,0 @@
|
|||||||
# CMAKE generated file: DO NOT EDIT!
|
|
||||||
# Generated by "Unix Makefiles" Generator, CMake Version 3.3
|
|
||||||
|
|
||||||
# Relative path conversion top directories.
|
|
||||||
set(CMAKE_RELATIVE_PATH_TOP_SOURCE "/Users/vsc/git/yap-6.3")
|
|
||||||
set(CMAKE_RELATIVE_PATH_TOP_BINARY "/Users/vsc/git/yap-6.3")
|
|
||||||
|
|
||||||
# Force unix paths in dependencies.
|
|
||||||
set(CMAKE_FORCE_UNIX_PATHS 1)
|
|
||||||
|
|
||||||
|
|
||||||
# The C and CXX include file regular expressions for this directory.
|
|
||||||
set(CMAKE_C_INCLUDE_REGEX_SCAN "^.*$")
|
|
||||||
set(CMAKE_C_INCLUDE_REGEX_COMPLAIN "^$")
|
|
||||||
set(CMAKE_CXX_INCLUDE_REGEX_SCAN ${CMAKE_C_INCLUDE_REGEX_SCAN})
|
|
||||||
set(CMAKE_CXX_INCLUDE_REGEX_COMPLAIN ${CMAKE_C_INCLUDE_REGEX_COMPLAIN})
|
|
File diff suppressed because it is too large
Load Diff
@ -1,59 +0,0 @@
|
|||||||
# The set of languages for which implicit dependencies are needed:
|
|
||||||
set(CMAKE_DEPENDS_LANGUAGES
|
|
||||||
"C"
|
|
||||||
)
|
|
||||||
# The set of files for implicit dependencies of each language:
|
|
||||||
set(CMAKE_DEPENDS_CHECK_C
|
|
||||||
"/Users/vsc/git/yap-6.3/os/alias.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/alias.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/charsio.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/charsio.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/chartypes.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/chartypes.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/console.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/console.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/files.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/files.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/fmemopen.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/fmemopen.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/format.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/format.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/iopreds.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/iopreds.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/mem.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/mem.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/open_memstream.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/open_memstream.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/pipes.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/pipes.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/readline.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/readline.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/readterm.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/readterm.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/readutil.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/readutil.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/sockets.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/sockets.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/streams.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/streams.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/sysbits.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/sysbits.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/writeterm.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/writeterm.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/ypsocks.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/ypsocks.c.o"
|
|
||||||
"/Users/vsc/git/yap-6.3/os/ypstdio.c" "/Users/vsc/git/yap-6.3/os/CMakeFiles/libYAPOs.dir/ypstdio.c.o"
|
|
||||||
)
|
|
||||||
set(CMAKE_C_COMPILER_ID "Clang")
|
|
||||||
|
|
||||||
# Preprocessor definitions for this target.
|
|
||||||
set(CMAKE_TARGET_DEFINITIONS_C
|
|
||||||
"COROUTINING=1"
|
|
||||||
"DEBUG=1"
|
|
||||||
"DEPTH_LIMIT=1"
|
|
||||||
"HAVE_CONFIG_H"
|
|
||||||
"LOW_LEVEL_TRACER=1"
|
|
||||||
"RATIONAL_TREES=1"
|
|
||||||
"TABLING=1"
|
|
||||||
"USE_THREADEAD_CODE=1"
|
|
||||||
"_YAP_NOT_INSTALLED_=1"
|
|
||||||
)
|
|
||||||
|
|
||||||
# The include file search paths:
|
|
||||||
set(CMAKE_C_TARGET_INCLUDE_PATH
|
|
||||||
"."
|
|
||||||
"H"
|
|
||||||
"include"
|
|
||||||
"os"
|
|
||||||
"JIT/HPP"
|
|
||||||
"/usr/local/include"
|
|
||||||
"OPTYap"
|
|
||||||
"os/../H"
|
|
||||||
"os/../include"
|
|
||||||
"os/."
|
|
||||||
)
|
|
||||||
|
|
||||||
# Targets to which this target links.
|
|
||||||
set(CMAKE_TARGET_LINKED_INFO_FILES
|
|
||||||
)
|
|
File diff suppressed because it is too large
Load Diff
@ -1 +0,0 @@
|
|||||||
9
|
|
@ -184,7 +184,6 @@ Yap_FetchStreamAlias (int sno, Term t2 USES_REGS)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static void
|
static void
|
||||||
ExtendAliasArray(void)
|
ExtendAliasArray(void)
|
||||||
{
|
{
|
||||||
|
@ -19,10 +19,9 @@
|
|||||||
|
|
||||||
#define ENCODING_H 1
|
#define ENCODING_H 1
|
||||||
|
|
||||||
#if defined(_PL_STREAM_H)
|
|
||||||
typedef IOENC encoding_t;
|
#include "Yap.h"
|
||||||
#define ENC_ISO_LATIN1 ENC_ISO_LATIN_1
|
|
||||||
#else
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
ENC_OCTET = 0, /// binary files
|
ENC_OCTET = 0, /// binary files
|
||||||
ENC_ISO_LATIN1 = 1, /// US+West Europe
|
ENC_ISO_LATIN1 = 1, /// US+West Europe
|
||||||
@ -77,7 +76,6 @@ encoding_t enc_id(char *s)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -338,7 +338,7 @@ time_file(USES_REGS1)
|
|||||||
static Int
|
static Int
|
||||||
file_size(USES_REGS1)
|
file_size(USES_REGS1)
|
||||||
{
|
{
|
||||||
|
int rc;
|
||||||
Int sno = Yap_CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "file_size/2");
|
Int sno = Yap_CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "file_size/2");
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return (FALSE);
|
return (FALSE);
|
||||||
@ -346,9 +346,12 @@ file_size(USES_REGS1)
|
|||||||
!(GLOBAL_Stream[sno]. status & (InMemory_Stream_f|Socket_Stream_f|Pipe_Stream_f))) {
|
!(GLOBAL_Stream[sno]. status & (InMemory_Stream_f|Socket_Stream_f|Pipe_Stream_f))) {
|
||||||
// there
|
// there
|
||||||
struct stat file_stat;
|
struct stat file_stat;
|
||||||
if (fstat(fileno(GLOBAL_Stream[sno].file), &file_stat) < 0) {
|
if ((rc = fstat(fileno(GLOBAL_Stream[sno].file), &file_stat) )< 0) {
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
PlIOError( PERMISSION_ERROR_INPUT_STREAM, ARG1, "%s in file_size/2", strerror(errno));
|
if (rc == ENOENT)
|
||||||
|
PlIOError( EXISTENCE_ERROR_SOURCE_SINK, ARG1, "%s in file_size", strerror(errno));
|
||||||
|
else
|
||||||
|
PlIOError( PERMISSION_ERROR_INPUT_STREAM, ARG1, "%s in file_size", strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
// and back again
|
// and back again
|
||||||
|
21
os/iopreds.c
21
os/iopreds.c
@ -277,7 +277,6 @@ InitFileIO(StreamDesc *s)
|
|||||||
static void
|
static void
|
||||||
InitStdStream (int sno, SMALLUNSGN flags, FILE * file)
|
InitStdStream (int sno, SMALLUNSGN flags, FILE * file)
|
||||||
{
|
{
|
||||||
CACHE_REGS
|
|
||||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||||
s->file = file;
|
s->file = file;
|
||||||
s->status = flags;
|
s->status = flags;
|
||||||
@ -358,16 +357,23 @@ Yap_InitStdStreams (void)
|
|||||||
InitStdStreams();
|
InitStdStreams();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
Int
|
Int
|
||||||
PlIOError (yap_error_number type, Term culprit, const char *who, ...)
|
PlIOError__ (const char *function, int lineno, const char *file, yap_error_number type, Term culprit, ...)
|
||||||
{
|
{
|
||||||
|
|
||||||
if (trueLocalPrologFlag(FILEERRORS_FLAG) == MkIntTerm(1) ||
|
if (trueLocalPrologFlag(FILEERRORS_FLAG) == MkIntTerm(1) ||
|
||||||
type == RESOURCE_ERROR_MAX_STREAMS /* do not catch resource errors */) {
|
type == RESOURCE_ERROR_MAX_STREAMS /* do not catch resource errors */) {
|
||||||
va_list args;
|
va_list args;
|
||||||
|
const char *format;
|
||||||
|
char who[1024];
|
||||||
|
|
||||||
va_start(args, who);
|
va_start(args, culprit);
|
||||||
Yap_Error(type, culprit, who);
|
format = va_arg(args, char *);
|
||||||
|
vsnprintf(who, 1023, format, args);
|
||||||
va_end( args );
|
va_end( args );
|
||||||
|
Yap_Error__(function, lineno,file, type, culprit, who);
|
||||||
/* and fail */
|
/* and fail */
|
||||||
return FALSE;
|
return FALSE;
|
||||||
} else {
|
} else {
|
||||||
@ -487,6 +493,7 @@ Yap_DebugErrorPuts(const char *s)
|
|||||||
|
|
||||||
void Yap_DebugWriteIndicator( PredEntry *ap )
|
void Yap_DebugWriteIndicator( PredEntry *ap )
|
||||||
{
|
{
|
||||||
|
CACHE_REGS
|
||||||
Term tmod = ap->ModuleOfPred;
|
Term tmod = ap->ModuleOfPred;
|
||||||
if (!tmod) tmod = TermProlog;
|
if (!tmod) tmod = TermProlog;
|
||||||
#if THREADS
|
#if THREADS
|
||||||
@ -1546,7 +1553,7 @@ binary_file(char *file_name)
|
|||||||
/* done */
|
/* done */
|
||||||
sno = GetFreeStreamD();
|
sno = GetFreeStreamD();
|
||||||
if (sno < 0)
|
if (sno < 0)
|
||||||
return (PlIOError (RESOURCE_ERROR_MAX_STREAMS,TermNil, "open/3"));
|
return PlIOError (RESOURCE_ERROR_MAX_STREAMS,TermNil, "open/3");
|
||||||
st = &GLOBAL_Stream[sno];
|
st = &GLOBAL_Stream[sno];
|
||||||
st->user_name = file_name;
|
st->user_name = file_name;
|
||||||
st->name = Yap_LookupAtom(Yap_AbsoluteFile(fname, NULL));
|
st->name = Yap_LookupAtom(Yap_AbsoluteFile(fname, NULL));
|
||||||
@ -1634,9 +1641,9 @@ binary_file(char *file_name)
|
|||||||
{
|
{
|
||||||
UNLOCK(st->streamlock);
|
UNLOCK(st->streamlock);
|
||||||
if (errno == ENOENT)
|
if (errno == ENOENT)
|
||||||
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK,ARG6,"open/3"));
|
return (PlIOError(EXISTENCE_ERROR_SOURCE_SINK,ARG6,"%s: %s", fname, strerror(errno)));
|
||||||
else
|
else
|
||||||
return (PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK,file_name,"open/3"));
|
return (PlIOError(PERMISSION_ERROR_OPEN_SOURCE_SINK,file_name,"%s: %s", fname, strerror(errno)));
|
||||||
}
|
}
|
||||||
#if MAC
|
#if MAC
|
||||||
if (open_mode == AtomWrite)
|
if (open_mode == AtomWrite)
|
||||||
|
13
os/iopreds.h
13
os/iopreds.h
@ -252,7 +252,10 @@ GetCurInpPos (StreamDesc * inp_stream)
|
|||||||
return (inp_stream->linecount);
|
return (inp_stream->linecount);
|
||||||
}
|
}
|
||||||
|
|
||||||
Int PlIOError( yap_error_number, Term, const char *, ...);
|
#define PlIOError(type, culprit,...) PlIOError__(__FUNCTION__, __LINE__,__FILE__, type, culprit, __VA_ARGS__)
|
||||||
|
|
||||||
|
Int PlIOError__( const char *, int, const char *, yap_error_number, Term, ...);
|
||||||
|
|
||||||
int GetFreeStreamD(void);
|
int GetFreeStreamD(void);
|
||||||
Term Yap_MkStream (int n);
|
Term Yap_MkStream (int n);
|
||||||
|
|
||||||
@ -260,8 +263,6 @@ bool Yap_PrintWarning( Term twarning );
|
|||||||
|
|
||||||
char *Yap_MemExportStreamPtr( int sno );
|
char *Yap_MemExportStreamPtr( int sno );
|
||||||
|
|
||||||
Int
|
|
||||||
PlIOError (yap_error_number type, Term culprit, const char *who, ...);
|
|
||||||
|
|
||||||
void Yap_plwrite(Term, struct stream_desc *, int, int, int);
|
void Yap_plwrite(Term, struct stream_desc *, int, int, int);
|
||||||
void Yap_WriteAtom(struct stream_desc *s, Atom atom);
|
void Yap_WriteAtom(struct stream_desc *s, Atom atom);
|
||||||
@ -371,6 +372,12 @@ StreamName(int i)
|
|||||||
return(GLOBAL_Stream[i].user_name);
|
return(GLOBAL_Stream[i].user_name);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
inline static Atom
|
||||||
|
StreamFullName(int i)
|
||||||
|
{
|
||||||
|
return(GLOBAL_Stream[i].name);
|
||||||
|
}
|
||||||
|
|
||||||
inline static void
|
inline static void
|
||||||
console_count_output_char(int ch, StreamDesc *s)
|
console_count_output_char(int ch, StreamDesc *s)
|
||||||
{
|
{
|
||||||
|
@ -759,8 +759,6 @@ static parser_state_t parse(REnv *re, FEnv *fe, int inp_stream) {
|
|||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
Term Yap_read_term(int inp_stream, Term opts, int nargs) {
|
Term Yap_read_term(int inp_stream, Term opts, int nargs) {
|
||||||
CACHE_REGS
|
|
||||||
|
|
||||||
FEnv fe;
|
FEnv fe;
|
||||||
REnv re;
|
REnv re;
|
||||||
#if EMACS
|
#if EMACS
|
||||||
|
@ -126,18 +126,20 @@ FILE *Yap_GetOutputStream(Term t, const char *msg) {
|
|||||||
|
|
||||||
int GetFreeStreamD(void) {
|
int GetFreeStreamD(void) {
|
||||||
CACHE_REGS
|
CACHE_REGS
|
||||||
|
LOCK(GLOBAL_StreamDescLock);
|
||||||
int sno;
|
int sno;
|
||||||
for (sno = 0; sno < MaxStreams; ++sno) {
|
for (sno = 0; sno < MaxStreams; ++sno) {
|
||||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
|
||||||
if (GLOBAL_Stream[sno].status & Free_Stream_f) {
|
if (GLOBAL_Stream[sno].status & Free_Stream_f) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
|
||||||
}
|
}
|
||||||
if (sno == MaxStreams) {
|
if (sno == MaxStreams) {
|
||||||
|
UNLOCK(GLOBAL_StreamDescLock);
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||||
|
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||||
|
UNLOCK(GLOBAL_StreamDescLock);
|
||||||
return sno;
|
return sno;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user