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:
@@ -109,97 +109,4 @@ void error_message(const char *mesg, ...) {
|
||||
}
|
||||
#endif /* YAPOR_ERRORS || TABLING_ERRORS */
|
||||
|
||||
|
||||
#ifdef YAPOR
|
||||
#ifdef sparc
|
||||
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:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" be,a ___rw_read_enter"
|
||||
" ldstub [%g1 + 3], %g2"
|
||||
" b ___rw_read_enter_spin_on_wlock"
|
||||
" ldub [%g1 + 3], %g2"
|
||||
"___rw_read_exit_spin_on_wlock:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" be,a ___rw_read_exit"
|
||||
" ldstub [%g1 + 3], %g2"
|
||||
" b ___rw_read_exit_spin_on_wlock"
|
||||
" ldub [%g1 + 3], %g2"
|
||||
"___rw_write_enter_spin_on_wlock:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" be,a ___rw_write_enter"
|
||||
" ldstub [%g1 + 3], %g2"
|
||||
" b ___rw_write_enter_spin_on_wlock"
|
||||
" ld [%g1], %g2"
|
||||
""
|
||||
" .globl ___rw_read_enter"
|
||||
"___rw_read_enter:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" bne,a ___rw_read_enter_spin_on_wlock"
|
||||
" ldub [%g1 + 3], %g2"
|
||||
" ld [%g1], %g2"
|
||||
" add %g2, 1, %g2"
|
||||
" st %g2, [%g1]"
|
||||
" retl"
|
||||
" mov %g4, %o7"
|
||||
|
||||
" .globl ___rw_read_exit"
|
||||
"___rw_read_exit:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" bne,a ___rw_read_exit_spin_on_wlock"
|
||||
" ldub [%g1 + 3], %g2"
|
||||
" ld [%g1], %g2"
|
||||
" sub %g2, 0x1ff, %g2"
|
||||
" st %g2, [%g1]"
|
||||
" retl"
|
||||
" mov %g4, %o7"
|
||||
|
||||
" .globl ___rw_write_enter"
|
||||
"___rw_write_enter:"
|
||||
" orcc %g2, 0x0, %g0"
|
||||
" bne ___rw_write_enter_spin_on_wlock"
|
||||
" ld [%g1], %g2"
|
||||
" andncc %g2, 0xff, %g0"
|
||||
" bne,a ___rw_write_enter_spin_on_wlock"
|
||||
" stb %g0, [%g1 + 3]"
|
||||
" retl"
|
||||
" mov %g4, %o7"
|
||||
);
|
||||
}
|
||||
#endif /* sparc */
|
||||
|
||||
|
||||
#ifdef i386
|
||||
asm(
|
||||
|
||||
".align 4"
|
||||
".globl __write_lock_failed"
|
||||
"__write_lock_failed:"
|
||||
" lock; addl $" RW_LOCK_BIAS_STR ",(%eax)"
|
||||
"1: cmpl $" RW_LOCK_BIAS_STR ",(%eax)"
|
||||
" jne 1b"
|
||||
""
|
||||
" lock; subl $" RW_LOCK_BIAS_STR ",(%eax)"
|
||||
" jnz __write_lock_failed"
|
||||
" ret"
|
||||
""
|
||||
""
|
||||
".align 4"
|
||||
".globl __read_lock_failed"
|
||||
"__read_lock_failed:"
|
||||
" lock ; incl (%eax)"
|
||||
"1: cmpl $1,(%eax)"
|
||||
" js 1b"
|
||||
""
|
||||
" lock ; decl (%eax)"
|
||||
" js __read_lock_failed"
|
||||
" ret"
|
||||
|
||||
);
|
||||
#endif /* i386 */
|
||||
#endif /* YAPOR */
|
||||
#endif /* YAPOR || TABLING */
|
||||
|
@@ -3,7 +3,6 @@
|
||||
** ----------------- */
|
||||
|
||||
typedef double realtime;
|
||||
typedef volatile int lockvar;
|
||||
typedef unsigned long bitmap;
|
||||
#define MAX_WORKERS (sizeof(bitmap) * 8 - 1)
|
||||
|
||||
|
@@ -3,12 +3,10 @@
|
||||
** ----------------------- */
|
||||
|
||||
extern struct worker{
|
||||
int worker_id;
|
||||
void *worker_area[MAX_WORKERS];
|
||||
long worker_offset[MAX_WORKERS];
|
||||
} WORKER;
|
||||
|
||||
#define worker_id (WORKER.worker_id)
|
||||
#define worker_area(W) (WORKER.worker_area[W])
|
||||
#define worker_offset(W) (WORKER.worker_offset[W])
|
||||
|
||||
|
@@ -47,15 +47,15 @@ static __inline__ void _read_lock(rwlock_t *rw)
|
||||
{
|
||||
register rwlock_t *lp asm("g1");
|
||||
lp = rw;
|
||||
__asm__ __volatile__("
|
||||
mov %%o7, %%g4
|
||||
call ___rw_read_enter
|
||||
ldstub [%%g1 + 3], %%g2
|
||||
" : /* no outputs */
|
||||
: "r" (lp)
|
||||
asm __volatile__("mov %%o7, %%g4\n\t" \
|
||||
"call ___rw_read_enter\n\t" \
|
||||
"ldstub [%%g1 + 3], %%g2\n" \
|
||||
: /* no outputs */ \
|
||||
: "r" (lp) \
|
||||
: "g2", "g4", "g7", "memory", "cc");
|
||||
}
|
||||
|
||||
|
||||
#define READ_LOCK(lock) \
|
||||
do { _read_lock(&(lock)); \
|
||||
} while(0)
|
||||
@@ -64,12 +64,12 @@ static __inline__ void _read_unlock(rwlock_t *rw)
|
||||
{
|
||||
register rwlock_t *lp asm("g1");
|
||||
lp = rw;
|
||||
__asm__ __volatile__("
|
||||
mov %%o7, %%g4
|
||||
call ___rw_read_exit
|
||||
ldstub [%%g1 + 3], %%g2
|
||||
" : /* no outputs */
|
||||
: "r" (lp)
|
||||
asm __volatile__( \
|
||||
"mov %%o7, %%g4\n\t" \
|
||||
"call ___rw_read_exit\n\t" \
|
||||
"ldstub [%%g1 + 3], %%g2\n" \
|
||||
: /* no outputs */ \
|
||||
: "r" (lp) \
|
||||
: "g2", "g4", "g7", "memory", "cc");
|
||||
}
|
||||
|
||||
@@ -81,12 +81,12 @@ static __inline__ void write_lock(rwlock_t *rw)
|
||||
{
|
||||
register rwlock_t *lp asm("g1");
|
||||
lp = rw;
|
||||
__asm__ __volatile__("
|
||||
mov %%o7, %%g4
|
||||
call ___rw_write_enter
|
||||
ldstub [%%g1 + 3], %%g2
|
||||
" : /* no outputs */
|
||||
: "r" (lp)
|
||||
asm __volatile__( \
|
||||
"mov %%o7, %%g4\n\t"\
|
||||
"call ___rw_write_enter\n\t" \
|
||||
"ldstub [%%g1 + 3], %%g2\n\t" \
|
||||
: /* no outputs */ \
|
||||
: "r" (lp) \
|
||||
: "g2", "g4", "g7", "memory", "cc");
|
||||
}
|
||||
|
||||
|
@@ -16,9 +16,7 @@
|
||||
#define INIT_LOCK(LOCK_VAR) ((LOCK_VAR) = 0)
|
||||
#define LOCK(LOCK_VAR) do { \
|
||||
if (TRY_LOCK(&(LOCK_VAR))) break; \
|
||||
SIMICS_SERVICE(START_COUNTER, 11); \
|
||||
while (IS_LOCKED(LOCK_VAR)) continue; \
|
||||
SIMICS_SERVICE(STOP_COUNTER, 11); \
|
||||
} while (1)
|
||||
#define IS_LOCKED(LOCK_VAR) ((LOCK_VAR) != 0)
|
||||
#define IS_UNLOCKED(LOCK_VAR) ((LOCK_VAR) == 0)
|
||||
|
Reference in New Issue
Block a user