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
|
||||
ExtendAliasArray(void)
|
||||
{
|
||||
|
@ -19,10 +19,9 @@
|
||||
|
||||
#define ENCODING_H 1
|
||||
|
||||
#if defined(_PL_STREAM_H)
|
||||
typedef IOENC encoding_t;
|
||||
#define ENC_ISO_LATIN1 ENC_ISO_LATIN_1
|
||||
#else
|
||||
|
||||
#include "Yap.h"
|
||||
|
||||
typedef enum {
|
||||
ENC_OCTET = 0, /// binary files
|
||||
ENC_ISO_LATIN1 = 1, /// US+West Europe
|
||||
@ -77,7 +76,6 @@ encoding_t enc_id(char *s)
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -338,7 +338,7 @@ time_file(USES_REGS1)
|
||||
static Int
|
||||
file_size(USES_REGS1)
|
||||
{
|
||||
|
||||
int rc;
|
||||
Int sno = Yap_CheckStream (ARG1, (Input_Stream_f | Output_Stream_f | Socket_Stream_f), "file_size/2");
|
||||
if (sno < 0)
|
||||
return (FALSE);
|
||||
@ -346,9 +346,12 @@ file_size(USES_REGS1)
|
||||
!(GLOBAL_Stream[sno]. status & (InMemory_Stream_f|Socket_Stream_f|Pipe_Stream_f))) {
|
||||
// there
|
||||
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);
|
||||
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;
|
||||
}
|
||||
// and back again
|
||||
|
25
os/iopreds.c
25
os/iopreds.c
@ -277,7 +277,6 @@ InitFileIO(StreamDesc *s)
|
||||
static void
|
||||
InitStdStream (int sno, SMALLUNSGN flags, FILE * file)
|
||||
{
|
||||
CACHE_REGS
|
||||
StreamDesc *s = &GLOBAL_Stream[sno];
|
||||
s->file = file;
|
||||
s->status = flags;
|
||||
@ -358,16 +357,23 @@ Yap_InitStdStreams (void)
|
||||
InitStdStreams();
|
||||
}
|
||||
|
||||
|
||||
|
||||
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) ||
|
||||
type == RESOURCE_ERROR_MAX_STREAMS /* do not catch resource errors */) {
|
||||
va_list args;
|
||||
|
||||
va_start(args, who);
|
||||
Yap_Error(type, culprit, who);
|
||||
va_end( args );
|
||||
const char *format;
|
||||
char who[1024];
|
||||
|
||||
va_start(args, culprit);
|
||||
format = va_arg(args, char *);
|
||||
vsnprintf(who, 1023, format, args);
|
||||
va_end( args );
|
||||
Yap_Error__(function, lineno,file, type, culprit, who);
|
||||
/* and fail */
|
||||
return FALSE;
|
||||
} else {
|
||||
@ -487,6 +493,7 @@ Yap_DebugErrorPuts(const char *s)
|
||||
|
||||
void Yap_DebugWriteIndicator( PredEntry *ap )
|
||||
{
|
||||
CACHE_REGS
|
||||
Term tmod = ap->ModuleOfPred;
|
||||
if (!tmod) tmod = TermProlog;
|
||||
#if THREADS
|
||||
@ -1546,7 +1553,7 @@ binary_file(char *file_name)
|
||||
/* done */
|
||||
sno = GetFreeStreamD();
|
||||
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->user_name = file_name;
|
||||
st->name = Yap_LookupAtom(Yap_AbsoluteFile(fname, NULL));
|
||||
@ -1634,9 +1641,9 @@ binary_file(char *file_name)
|
||||
{
|
||||
UNLOCK(st->streamlock);
|
||||
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
|
||||
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 (open_mode == AtomWrite)
|
||||
|
13
os/iopreds.h
13
os/iopreds.h
@ -252,7 +252,10 @@ GetCurInpPos (StreamDesc * inp_stream)
|
||||
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);
|
||||
Term Yap_MkStream (int n);
|
||||
|
||||
@ -260,8 +263,6 @@ bool Yap_PrintWarning( Term twarning );
|
||||
|
||||
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_WriteAtom(struct stream_desc *s, Atom atom);
|
||||
@ -371,6 +372,12 @@ StreamName(int i)
|
||||
return(GLOBAL_Stream[i].user_name);
|
||||
}
|
||||
|
||||
inline static Atom
|
||||
StreamFullName(int i)
|
||||
{
|
||||
return(GLOBAL_Stream[i].name);
|
||||
}
|
||||
|
||||
inline static void
|
||||
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) {
|
||||
CACHE_REGS
|
||||
|
||||
FEnv fe;
|
||||
REnv re;
|
||||
#if EMACS
|
||||
|
@ -126,18 +126,20 @@ FILE *Yap_GetOutputStream(Term t, const char *msg) {
|
||||
|
||||
int GetFreeStreamD(void) {
|
||||
CACHE_REGS
|
||||
LOCK(GLOBAL_StreamDescLock);
|
||||
int sno;
|
||||
for (sno = 0; sno < MaxStreams; ++sno) {
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
if (GLOBAL_Stream[sno].status & Free_Stream_f) {
|
||||
break;
|
||||
}
|
||||
UNLOCK(GLOBAL_Stream[sno].streamlock);
|
||||
}
|
||||
if (sno == MaxStreams) {
|
||||
UNLOCK(GLOBAL_StreamDescLock);
|
||||
return -1;
|
||||
}
|
||||
GLOBAL_Stream[sno].encoding = LOCAL_encoding;
|
||||
LOCK(GLOBAL_Stream[sno].streamlock);
|
||||
UNLOCK(GLOBAL_StreamDescLock);
|
||||
return sno;
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user