diff --git a/C/errors.c b/C/errors.c index ffb58bbc6..14fe9eb93 100644 --- a/C/errors.c +++ b/C/errors.c @@ -1337,6 +1337,20 @@ Yap_Error(yap_error_number type, Term where, char *format,...) serious = TRUE; } break; + case RESOURCE_ERROR_MAX_STREAMS: + { + int i; + Term ti[1]; + + i = strlen(tmpbuf); + ti[0] = MkAtomTerm(AtomStreams); + nt[0] = Yap_MkApplTerm(FunctorResourceError, 1, ti); + tp = tmpbuf+i; + psize -= i; + fun = FunctorError; + serious = TRUE; + } + break; case RESOURCE_ERROR_STACK: { int i; diff --git a/C/iopreds.c b/C/iopreds.c index 097734475..9cedfc656 100644 --- a/C/iopreds.c +++ b/C/iopreds.c @@ -2291,7 +2291,7 @@ p_open (void) return (PlIOError (SYSTEM_ERROR,file_name,"file name is too long in open/3")); sno = GetFreeStreamD(); if (sno < 0) - return (PlIOError (SYSTEM_ERROR,TermNil, "new stream not available for open/3")); + return (PlIOError (RESOURCE_ERROR_MAX_STREAMS,TermNil, "all streams in use")); st = &Stream[sno]; /* can never happen */ tenc = Deref(ARG5); diff --git a/H/Yap.h b/H/Yap.h index 38a163cbd..49042ec5e 100644 --- a/H/Yap.h +++ b/H/Yap.h @@ -479,6 +479,7 @@ typedef enum REPRESENTATION_ERROR_CHARACTER_CODE, REPRESENTATION_ERROR_MAX_ARITY, RESOURCE_ERROR_HUGE_INT, + RESOURCE_ERROR_MAX_STREAMS, RESOURCE_ERROR_MAX_THREADS, RESOURCE_ERROR_MEMORY, RESOURCE_ERROR_STACK, diff --git a/H/iatoms.h b/H/iatoms.h index 5516cb901..306ba247b 100644 --- a/H/iatoms.h +++ b/H/iatoms.h @@ -243,6 +243,7 @@ AtomStaticClause = Yap_FullLookupAtom("$static_clause"); AtomStaticProcedure = Yap_LookupAtom("static_procedure"); AtomStream = Yap_FullLookupAtom("$stream"); + AtomStreams = Yap_FullLookupAtom("streams"); AtomStreamOrAlias = Yap_LookupAtom("stream_or_alias"); AtomStreamPos = Yap_FullLookupAtom("$stream_position"); AtomStreamPosition = Yap_LookupAtom("stream_position"); diff --git a/H/ratoms.h b/H/ratoms.h index f69eb4819..cb08cf55f 100644 --- a/H/ratoms.h +++ b/H/ratoms.h @@ -245,6 +245,7 @@ AtomStaticClause = AtomAdjust(AtomStaticClause); AtomStaticProcedure = AtomAdjust(AtomStaticProcedure); AtomStream = AtomAdjust(AtomStream); + AtomStreams = AtomAdjust(AtomStreams); AtomStreamOrAlias = AtomAdjust(AtomStreamOrAlias); AtomStreamPos = AtomAdjust(AtomStreamPos); AtomStreamPosition = AtomAdjust(AtomStreamPosition); diff --git a/H/tatoms.h b/H/tatoms.h index f1e902e85..9a17f9b5c 100644 --- a/H/tatoms.h +++ b/H/tatoms.h @@ -492,6 +492,8 @@ #define AtomStaticProcedure Yap_heap_regs->AtomStaticProcedure_ Atom AtomStream_; #define AtomStream Yap_heap_regs->AtomStream_ + Atom AtomStreams_; +#define AtomStreams Yap_heap_regs->AtomStreams_ Atom AtomStreamOrAlias_; #define AtomStreamOrAlias Yap_heap_regs->AtomStreamOrAlias_ Atom AtomStreamPos_; diff --git a/misc/ATOMS b/misc/ATOMS index 95daa53f7..31beff40b 100644 --- a/misc/ATOMS +++ b/misc/ATOMS @@ -254,6 +254,7 @@ A StackFree N "stackfree" A StaticClause F "$static_clause" A StaticProcedure N "static_procedure" A Stream F "$stream" +A Streams F "streams" A StreamOrAlias N "stream_or_alias" A StreamPos F "$stream_position" A StreamPosition N "stream_position" diff --git a/pl/messages.yap b/pl/messages.yap index cf3fc0890..456ea1d60 100644 --- a/pl/messages.yap +++ b/pl/messages.yap @@ -244,14 +244,16 @@ system_message(error(representation_error(character_code), Where)) --> [ 'REPRESENTATION ERROR- ~w: expected character code' - [Where] ]. system_message(error(representation_error(max_arity), Where)) --> [ 'REPRESENTATION ERROR- ~w: number too big' - [Where] ]. +system_message(error(resource_error(code_space), Where)) --> + [ 'RESOURCE ERROR- not enough code space' - [Where] ]. system_message(error(resource_error(huge_int), Where)) --> [ 'RESOURCE ERROR- too large an integer in absolute value' - [Where] ]. system_message(error(resource_error(memory), Where)) --> [ 'RESOURCE ERROR- not enough virtual memory' - [Where] ]. system_message(error(resource_error(stack), Where)) --> [ 'RESOURCE ERROR- not enough stack' - [Where] ]. -system_message(error(resource_error(code_space), Where)) --> - [ 'RESOURCE ERROR- not enough code space' - [Where] ]. +system_message(error(resource_error(streams), Where)) --> + [ 'RESOURCE ERROR- could not find a free stream' - [Where] ]. system_message(error(resource_error(threads), Where)) --> [ 'RESOURCE ERROR- too many open threads' - [Where] ]. system_message(error(resource_error(trail), Where)) -->