make --enable-threads work on CVS release.
git-svn-id: https://yap.svn.sf.net/svnroot/yap/trunk@645 b08c6af1-5177-4d33-ba66-4b1c6b8b522a
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
* Last rev: *
|
||||
* mods: *
|
||||
* comments: allocating space *
|
||||
* version:$Id: alloc.c,v 1.24 2002-10-17 01:37:46 vsc Exp $ *
|
||||
* version:$Id: alloc.c,v 1.25 2002-10-21 22:14:28 vsc Exp $ *
|
||||
*************************************************************************/
|
||||
#ifdef SCCS
|
||||
static char SccsId[] = "%W% %G%";
|
||||
@@ -165,7 +165,6 @@ FreeBlock(BlockHeader *b)
|
||||
}
|
||||
b->b_size &= ~InUseFlag;
|
||||
LOCK(FreeBlocksLock);
|
||||
LOCK(GLOBAL_LOCKS_alloc_block);
|
||||
/* check if we can collapse with other blocsks */
|
||||
/* check previous */
|
||||
sp = &(b->b_size) - 1;
|
||||
@@ -199,7 +198,6 @@ FreeBlock(BlockHeader *b)
|
||||
if (!HEAPTOP_OWNER(worker_id)) {
|
||||
UNLOCK(HeapTopLock);
|
||||
}
|
||||
UNLOCK(GLOBAL_LOCKS_alloc_block);
|
||||
UNLOCK(FreeBlocksLock);
|
||||
}
|
||||
|
||||
@@ -244,7 +242,6 @@ AllocHeap(unsigned int size)
|
||||
if (size < 6)
|
||||
size = 6;
|
||||
LOCK(FreeBlocksLock);
|
||||
LOCK(GLOBAL_LOCKS_alloc_block);
|
||||
if ((b = GetBlock(size))) {
|
||||
if (b->b_size >= size + 6 + 1) {
|
||||
n = (BlockHeader *) (((YAP_SEG_SIZE *) b) + size + 1);
|
||||
@@ -255,7 +252,6 @@ AllocHeap(unsigned int size)
|
||||
sp = &(b->b_size) + b->b_size;
|
||||
*sp = b->b_size | InUseFlag;
|
||||
b->b_size |= InUseFlag;
|
||||
UNLOCK(GLOBAL_LOCKS_alloc_block);
|
||||
UNLOCK(FreeBlocksLock);
|
||||
return (Addr(b) + sizeof(YAP_SEG_SIZE));
|
||||
}
|
||||
@@ -311,7 +307,6 @@ AllocHeap(unsigned int size)
|
||||
if (HeapUsed > HeapMax)
|
||||
HeapMax = HeapUsed;
|
||||
HeapPlus = HeapTop + MinHGap / CellSize;
|
||||
UNLOCK(GLOBAL_LOCKS_alloc_block);
|
||||
UNLOCK(HeapUsedLock);
|
||||
b->b_size = size | InUseFlag;
|
||||
sp = &(b->b_size) + size;
|
||||
|
||||
18
C/cdmgr.c
18
C/cdmgr.c
@@ -1762,7 +1762,7 @@ p_compile_mode(void)
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
#if !defined(YAPOR) && !defined(THREADS)
|
||||
#if !defined(YAPOR)
|
||||
static yamop *next_clause(PredEntry *pe, CODEADDR codeptr)
|
||||
{
|
||||
CODEADDR clcode, cl;
|
||||
@@ -2008,12 +2008,6 @@ all_calls(void)
|
||||
return(MkApplTerm(f,3,ts));
|
||||
}
|
||||
|
||||
static Int
|
||||
p_current_stack(void)
|
||||
{
|
||||
return(unify(ARG1,all_calls()));
|
||||
}
|
||||
|
||||
static void
|
||||
mark_pred(int mark, PredEntry *pe)
|
||||
{
|
||||
@@ -2089,6 +2083,16 @@ do_toggle_static_predicates_in_use(int mask)
|
||||
|
||||
#endif
|
||||
|
||||
static Int
|
||||
p_current_stack(void)
|
||||
{
|
||||
#ifdef YAPOR
|
||||
return(FALSE);
|
||||
#else
|
||||
return(unify(ARG1,all_calls()));
|
||||
#endif
|
||||
}
|
||||
|
||||
/* This predicate is to be used by reconsult to mark all predicates
|
||||
currently in use as being executed.
|
||||
|
||||
|
||||
30
C/dbase.c
30
C/dbase.c
@@ -1229,12 +1229,10 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
INIT_LOCK(pp->lock);
|
||||
INIT_DBREF_COUNT(pp);
|
||||
return(pp);
|
||||
|
||||
} else if (IsAtomOrIntTerm(Tm)) {
|
||||
Register DBRef pp;
|
||||
SMALLUNSGN flag;
|
||||
|
||||
|
||||
tt = Tm;
|
||||
flag = DBAtomic;
|
||||
if (IsAtomOrIntTerm(tt))
|
||||
@@ -1274,8 +1272,10 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
ntp = MkDBTerm(VarOfTerm(Tm), VarOfTerm(Tm), ntp0, ntp0+1, ntp0-1,
|
||||
&attachments,
|
||||
&vars_found);
|
||||
if (ntp == NULL)
|
||||
return(NULL);
|
||||
if (ntp == NULL) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
} else
|
||||
#endif
|
||||
if (IsPairTerm(Tm)) {
|
||||
@@ -1287,6 +1287,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
#endif
|
||||
&vars_found);
|
||||
if (ntp == NULL) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
@@ -1340,6 +1341,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
pp->Code = NULL;
|
||||
INIT_LOCK(pp->lock);
|
||||
INIT_DBREF_COUNT(pp);
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(pp);
|
||||
}
|
||||
#ifdef USE_GMP
|
||||
@@ -1375,13 +1377,17 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
&attachments,
|
||||
#endif
|
||||
&vars_found);
|
||||
if (ntp == NULL)
|
||||
if (ntp == NULL) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
}
|
||||
}
|
||||
CodeAbs = (CELL *)((CELL)ntp-(CELL)ntp0);
|
||||
if (DBErrorFlag)
|
||||
if (DBErrorFlag) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return (NULL); /* Error Situation */
|
||||
}
|
||||
NOfCells = ntp - ntp0; /* End Of Code Info */
|
||||
#ifdef IDB_LINK_TABLE
|
||||
*lr++ = 0;
|
||||
@@ -1398,13 +1404,16 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
CodeAbs += CellPtr(lr) - CellPtr(LinkAr);
|
||||
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
/* restore lr to NULL in case there is a TR overflow */
|
||||
lr = NULL;
|
||||
#endif
|
||||
if ((InFlag & MkIfNot) && (found_one = check_if_wvars(p->First, NOfCells, ntp0)))
|
||||
if ((InFlag & MkIfNot) && (found_one = check_if_wvars(p->First, NOfCells, ntp0))) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return (found_one);
|
||||
}
|
||||
} else {
|
||||
#ifdef IDB_LINK_TABLE
|
||||
/* make sure lr ends in 0 for check_if_nvars */
|
||||
@@ -1412,13 +1421,16 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
lr = NULL;
|
||||
#endif
|
||||
flag = DBNoVars;
|
||||
if ((InFlag & MkIfNot) && (found_one = check_if_nvars(p->First, NOfCells, ntp0)))
|
||||
if ((InFlag & MkIfNot) && (found_one = check_if_nvars(p->First, NOfCells, ntp0))) {
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return (found_one);
|
||||
}
|
||||
}
|
||||
if (tofref != TmpRefBase) {
|
||||
CodeAbs += TmpRefBase - tofref + 1;
|
||||
if ((CELL *)((char *)ntp0+(CELL)CodeAbs) > AuxSp) {
|
||||
DBErrorFlag = OVF_ERROR_IN_DB;
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
flag |= DBWithRefs;
|
||||
@@ -1430,6 +1442,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
DBErrorNumber = SYSTEM_ERROR;
|
||||
DBErrorTerm = TermNil;
|
||||
DBErrorMsg = "trying to store term larger than 256KB";
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
#endif
|
||||
@@ -1440,6 +1453,7 @@ CreateDBStruct(Term Tm, DBProp p, int InFlag)
|
||||
DBErrorNumber = SYSTEM_ERROR;
|
||||
DBErrorTerm = TermNil;
|
||||
DBErrorMsg = "heap crashed against stacks";
|
||||
ReleasePreAllocCodeSpace((ADDR)pp0);
|
||||
return(NULL);
|
||||
}
|
||||
pp->id = FunctorDBRef;
|
||||
|
||||
4
C/init.c
4
C/init.c
@@ -834,6 +834,7 @@ InitCodes(void)
|
||||
INIT_LOCK(heap_regs->heap_used_lock);
|
||||
INIT_LOCK(heap_regs->heap_top_lock);
|
||||
INIT_LOCK(heap_regs->dead_clauses_lock);
|
||||
heap_regs->heap_top_owner = -1;
|
||||
#endif /* YAPOR */
|
||||
heap_regs->clausecode.arity = 0;
|
||||
heap_regs->clausecode.clause = NIL;
|
||||
@@ -1194,6 +1195,9 @@ InitStacks(int Heap,
|
||||
register array, but for now they exist */
|
||||
#endif /* PUSH_REGS */
|
||||
|
||||
#ifdef THREADS
|
||||
regp->worker_id_ = 0;
|
||||
#endif
|
||||
/* Init signal handling and time */
|
||||
/* also init memory page size, required by later functions */
|
||||
InitSysbits ();
|
||||
|
||||
89
C/sysbits.c
89
C/sysbits.c
@@ -2231,3 +2231,92 @@ int WINAPI win_yap(HANDLE hinst, DWORD reason, LPVOID reserved)
|
||||
}
|
||||
#endif
|
||||
|
||||
#if defined(YAPOR) || defined(THREADS)
|
||||
#ifdef sparc
|
||||
void STD_PROTO(rw_lock_voodoo,(void));
|
||||
|
||||
void
|
||||
rw_lock_voodoo(void) {
|
||||
/* code taken from the Linux kernel, it handles shifting between locks */
|
||||
/* Read/writer locks, as usual this is overly clever to make it as fast as possible. */
|
||||
/* caches... */
|
||||
__asm__ __volatile__(
|
||||
"___rw_read_enter_spin_on_wlock:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" be,a ___rw_read_enter\n"
|
||||
" ldstub [%g1 + 3], %g2\n"
|
||||
" b ___rw_read_enter_spin_on_wlock\n"
|
||||
" ldub [%g1 + 3], %g2\n"
|
||||
"___rw_read_exit_spin_on_wlock:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" be,a ___rw_read_exit\n"
|
||||
" ldstub [%g1 + 3], %g2\n"
|
||||
" b ___rw_read_exit_spin_on_wlock\n"
|
||||
" ldub [%g1 + 3], %g2\n"
|
||||
"___rw_write_enter_spin_on_wlock:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" be,a ___rw_write_enter\n"
|
||||
" ldstub [%g1 + 3], %g2\n"
|
||||
" b ___rw_write_enter_spin_on_wlock\n"
|
||||
" ld [%g1], %g2\n"
|
||||
"\n"
|
||||
" .globl ___rw_read_enter\n"
|
||||
"___rw_read_enter:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" bne,a ___rw_read_enter_spin_on_wlock\n"
|
||||
" ldub [%g1 + 3], %g2\n"
|
||||
" ld [%g1], %g2\n"
|
||||
" add %g2, 1, %g2\n"
|
||||
" st %g2, [%g1]\n"
|
||||
" retl\n"
|
||||
" mov %g4, %o7\n"
|
||||
" .globl ___rw_read_exit\n"
|
||||
"___rw_read_exit:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" bne,a ___rw_read_exit_spin_on_wlock\n"
|
||||
" ldub [%g1 + 3], %g2\n"
|
||||
" ld [%g1], %g2\n"
|
||||
" sub %g2, 0x1ff, %g2\n"
|
||||
" st %g2, [%g1]\n"
|
||||
" retl\n"
|
||||
" mov %g4, %o7\n"
|
||||
" .globl ___rw_write_enter\n"
|
||||
"___rw_write_enter:\n"
|
||||
" orcc %g2, 0x0, %g0\n"
|
||||
" bne ___rw_write_enter_spin_on_wlock\n"
|
||||
" ld [%g1], %g2\n"
|
||||
" andncc %g2, 0xff, %g0\n"
|
||||
" bne,a ___rw_write_enter_spin_on_wlock\n"
|
||||
" stb %g0, [%g1 + 3]\n"
|
||||
" retl\n"
|
||||
" mov %g4, %o7\n"
|
||||
);
|
||||
}
|
||||
#endif /* sparc */
|
||||
|
||||
|
||||
#ifdef i386
|
||||
asm(
|
||||
|
||||
".align 4\n"
|
||||
".globl __write_lock_failed\n"
|
||||
"__write_lock_failed:\n"
|
||||
" lock; addl $" RW_LOCK_BIAS_STR ",(%eax)\n"
|
||||
"1: cmpl $" RW_LOCK_BIAS_STR ",(%eax)\n"
|
||||
" jne 1b\n"
|
||||
" lock; subl $" RW_LOCK_BIAS_STR ",(%eax)\n"
|
||||
" jnz __write_lock_failed\n"
|
||||
" ret\n"
|
||||
".align 4\n"
|
||||
".globl __read_lock_failed\n"
|
||||
"__read_lock_failed:\n"
|
||||
" lock ; incl (%eax)\n"
|
||||
"1: cmpl $1,(%eax)\n"
|
||||
" js 1b\n"
|
||||
" lock ; decl (%eax)\n"
|
||||
" js __read_lock_failed\n"
|
||||
" ret\n"
|
||||
|
||||
);
|
||||
#endif /* i386 */
|
||||
#endif /* YAPOR || THREADS */
|
||||
|
||||
Reference in New Issue
Block a user