From de2d6867ad569686e62ef5a1d00bb5a8a710a5ae Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADtor=20Santos=20Costa?= Date: Wed, 23 Jun 2010 11:47:14 +0100 Subject: [PATCH] isupport for improved SWI emulation. --- H/YapHeap.h | 4 ++++ H/dglobals.h | 4 ++++ H/hglobals.h | 4 ++++ H/iglobals.h | 4 ++++ H/iopreds.h | 4 ++++ H/rglobals.h | 4 ++++ 6 files changed, 24 insertions(+) diff --git a/H/YapHeap.h b/H/YapHeap.h index 098f6c825..0aa5dc800 100755 --- a/H/YapHeap.h +++ b/H/YapHeap.h @@ -22,6 +22,10 @@ #include #endif +typedef int (*SWI_PutFunction)(int, void *); +typedef int (*SWI_GetFunction)(void *); +typedef int (*SWI_CloseFunction)(void *); + #include "../include/dswiatoms.h" #ifndef INT_KEYS_DEFAULT_SIZE diff --git a/H/dglobals.h b/H/dglobals.h index ea87f54dd..0eea087e5 100644 --- a/H/dglobals.h +++ b/H/dglobals.h @@ -91,6 +91,10 @@ #define TotGcRecovered WL->tot_gc_recovered #define LastGcTime WL->last_gc_time #define LastSSTime WL->last_ss_time +#define FSWIStream WL->f_swi_stream +#define SWIGetc WL->swi_getc +#define SWIPutc WL->swi_putc +#define SWIClose WL->swi_close #if defined(YAPOR) || defined(THREADS) #define SignalLock WL->signal_lock diff --git a/H/hglobals.h b/H/hglobals.h index 622f16d7b..b41656049 100644 --- a/H/hglobals.h +++ b/H/hglobals.h @@ -93,6 +93,10 @@ typedef struct worker_local { YAP_ULONG_LONG tot_gc_recovered; Int last_gc_time; Int last_ss_time; + Functor f_swi_stream; + SWI_GetFunction swi_getc; + SWI_PutFunction swi_putc; + SWI_CloseFunction swi_close; #if defined(YAPOR) || defined(THREADS) lockvar signal_lock; diff --git a/H/iglobals.h b/H/iglobals.h index 4b3132ddc..5c4a81dae 100644 --- a/H/iglobals.h +++ b/H/iglobals.h @@ -91,6 +91,10 @@ static void InitWorker(int wid) { FOREIGN_WL(wid)->tot_gc_recovered = 0L; FOREIGN_WL(wid)->last_gc_time = 0L; FOREIGN_WL(wid)->last_ss_time = 0L; + FOREIGN_WL(wid)->f_swi_stream = NULL; + FOREIGN_WL(wid)->swi_getc = NULL; + FOREIGN_WL(wid)->swi_putc = NULL; + FOREIGN_WL(wid)->swi_close = NULL; #if defined(YAPOR) || defined(THREADS) INIT_LOCK(FOREIGN_WL(wid)->signal_lock); diff --git a/H/iopreds.h b/H/iopreds.h index 3c3a04598..dd043ae60 100644 --- a/H/iopreds.h +++ b/H/iopreds.h @@ -48,6 +48,9 @@ typedef int (*GetsFunc)(int, UInt, char *); typedef struct stream_desc { union { + struct { + struct io_stream *swi_ptr; + } swi_stream; struct { Atom name; Term user_name; @@ -129,6 +132,7 @@ StreamDesc; #define HAS_BOM_f 0x200000 #define RepError_Prolog_f 0x400000 #define RepError_Xml_f 0x800000 +#define SWI_Stream_f 0x1000000 #define EXPAND_FILENAME 0x000080 diff --git a/H/rglobals.h b/H/rglobals.h index 75a8858ed..77084af95 100644 --- a/H/rglobals.h +++ b/H/rglobals.h @@ -92,6 +92,10 @@ static void RestoreWorker(int wid) { + + + + #if defined(YAPOR) || defined(THREADS) REINIT_LOCK(FOREIGN_WL(wid)->signal_lock);