c_inp_stream and friends are thread private!

This commit is contained in:
Vítor Santos Costa 2010-07-27 17:28:58 +01:00
parent 4c9d74c2e7
commit 18d77309a6
9 changed files with 25 additions and 8 deletions

View File

@ -165,8 +165,6 @@ int Yap_CritLocks = 0;
/********* streams ********************************************/
int Yap_c_input_stream, Yap_c_output_stream, Yap_c_error_stream;
YP_FILE *Yap_stdin;
YP_FILE *Yap_stdout;
YP_FILE *Yap_stderr;

View File

@ -81,6 +81,9 @@ store_specs(int new_worker_id, UInt ssize, UInt tsize, UInt sysize, Term *tpgoal
FOREIGN_ThreadHandle(new_worker_id).ssize = ssize;
FOREIGN_ThreadHandle(new_worker_id).tsize = tsize;
FOREIGN_ThreadHandle(new_worker_id).sysize = sysize;
FOREIGN_WL(new_worker_id)->c_input_stream = Yap_c_input_stream;
FOREIGN_WL(new_worker_id)->c_output_stream = Yap_c_output_stream;
FOREIGN_WL(new_worker_id)->c_error_stream = Yap_c_error_stream;
pm = (ssize + tsize)*1024;
if (!(FOREIGN_ThreadHandle(new_worker_id).stack_address = malloc(pm))) {
return FALSE;

View File

@ -21,6 +21,10 @@
#define Yap_c_input_stream WL->c_input_stream
#define Yap_c_output_stream WL->c_output_stream
#define Yap_c_error_stream WL->c_error_stream
#define OldASP WL->rinfo.old_ASP
#define OldLCL0 WL->rinfo.old_LCL0

View File

@ -22,6 +22,10 @@
typedef struct worker_local {
int c_input_stream;
int c_output_stream;
int c_error_stream;
restoreinfo rinfo;

View File

@ -22,6 +22,10 @@
static void InitWorker(int wid) {
FOREIGN_WL(wid)->c_input_stream = 0;
FOREIGN_WL(wid)->c_output_stream = 1;
FOREIGN_WL(wid)->c_error_stream = 2;
FOREIGN_WL(wid)->rinfo.old_ASP = NULL;
FOREIGN_WL(wid)->rinfo.old_LCL0 = NULL;
FOREIGN_WL(wid)->rinfo.old_TR = NULL;

View File

@ -54,6 +54,10 @@ static void RestoreWorker(int wid) {

View File

@ -322,11 +322,6 @@ Term STD_PROTO(Yap_WStringToList,(wchar_t *));
Term STD_PROTO(Yap_WStringToListOfAtoms,(wchar_t *));
Atom STD_PROTO(Yap_LookupWideAtom,(wchar_t *));
extern int
Yap_c_input_stream,
Yap_c_output_stream,
Yap_c_error_stream;
#define YAP_INPUT_STREAM 0x01
#define YAP_OUTPUT_STREAM 0x02
#define YAP_APPEND_STREAM 0x04

View File

@ -20,6 +20,11 @@
// Stuff that must be considered local to a thread or worker
START_WORKER_LOCAL
// Streams
int c_input_stream Yap_c_input_stream =0
int c_output_stream Yap_c_output_stream =1
int c_error_stream Yap_c_error_stream =2
/* shifts and restore: per local data-structure */
restoreinfo rinfo
. rinfo.old_ASP OldASP =NULL

@ -1 +1 @@
Subproject commit 7c9456b5c9c60ab227674f7653dc226e13973484
Subproject commit 6e7c68cdcc5d781d218b57d04f2a16b3e0bcbfca