locking and other small fixes

This commit is contained in:
Vítor Santos Costa
2015-09-29 23:44:11 +01:00
parent 34fe3e6ded
commit 9326b2ea62
12 changed files with 39 additions and 2879 deletions

View File

@@ -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;
}