Skip to content

Commit

Permalink
Delete get_spinlock / release_spinlock
Browse files Browse the repository at this point in the history
  • Loading branch information
snuglas authored and Douglas Katzman committed May 8, 2018
1 parent cab31f2 commit bfc02d7
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 247 deletions.
13 changes: 0 additions & 13 deletions src/runtime/alpha-arch.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#ifndef _ALPHA_ARCH_H
#define _ALPHA_ARCH_H


static inline void
get_spinlock(lispobj *word,long value)
{
*word=value; /* FIXME for threads */
}

static inline void
release_spinlock(lispobj *word)
{
*word=0;
}

#define ALIEN_STACK_GROWS_DOWNWARD

#endif /* _ALPHA_ARCH_H */
20 changes: 0 additions & 20 deletions src/runtime/arm-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,26 +3,6 @@

#define ALIEN_STACK_GROWS_DOWNWARD

static inline long
get_spinlock(lispobj *word,long value)
{
#ifdef LISP_FEATURE_SB_THREAD
#error "get_spinlock not defined for threads"
#else
*word=value;
return 0;
#endif
}

static inline void
release_spinlock(lispobj *word)
{
#ifdef LISP_FEATURE_SB_THREAD
#error "release_spinlock not defined for threads"
#endif
*word=0;
}

#ifdef LISP_FEATURE_SB_THREAD
static inline lispobj
swap_lispobjs(volatile lispobj *dest, lispobj value)
Expand Down
13 changes: 0 additions & 13 deletions src/runtime/hppa-arch.h
Original file line number Diff line number Diff line change
@@ -1,19 +1,6 @@
#ifndef _HPPA_ARCH_H
#define _HPPA_ARCH_H


static inline void
get_spinlock(lispobj *word,long value)
{
*word=value; /* FIXME for threads */
}

static inline void
release_spinlock(lispobj *word)
{
*word=0;
}

#define ARCH_HAS_NPC_REGISTER
#define ALIEN_STACK_GROWS_UPWARD

Expand Down
55 changes: 0 additions & 55 deletions src/runtime/mips-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,61 +3,6 @@

#define ALIEN_STACK_GROWS_DOWNWARD

static inline void
get_spinlock(volatile lispobj *word, long value)
{
#ifdef LISP_FEATURE_SB_THREAD
unsigned long __old = (volatile lispobj)*word;
unsigned long __prev;
int __cmp;

__asm__ __volatile__ (
" .set push\n"
" .set mips2\n"
" .set noreorder\n"
"1: ll %[__prev],%[__mem]\n"
" bne %[__prev],%[__old],2f\n"
" li %[__cmp],0\n"
" move %[__cmp],%[__new]\n"
" sc %[__cmp],%[__mem]\n"
" beqz %[__cmp],1b\n"
" nop\n"
" sync\n"
"2:\n"
" .set pop"
: [__prev] "=&r" (__prev),
[__cmp] "=&r" (__cmp)
: [__mem] "R" (*word),
[__old] "r" (__old),
[__new] "r" (value)
: "memory");

if (!cmp)
lose("recursive get_spinlock: 0x%x,%d\n", word, value);
#else /* LISP_FEATURE_SB_THREAD */
*word=value;
#endif
}

static inline void
release_spinlock(volatile lispobj *word)
{
#ifdef LISP_FEATURE_SB_THREAD
__asm__ __volatile__ (
" .set push\n"
" .set mips2\n"
" .set noreorder\n"
" sw $0,%[__mem]\n"
" sync\n"
" .set pop"
:
: [__mem] "R" (*word)
: "memory");
#else /* LISP_FEATURE_SB_THREAD */
*word=0;
#endif
}

unsigned int arch_get_fp_control(void);
void arch_set_fp_control(unsigned int fp);

Expand Down
31 changes: 0 additions & 31 deletions src/runtime/ppc-arch.h
Original file line number Diff line number Diff line change
@@ -1,37 +1,6 @@
#ifndef _PPC_ARCH_H
#define _PPC_ARCH_H

static inline long
get_spinlock(lispobj *word,long value)
{
#ifdef LISP_FEATURE_SB_THREAD
long temp;

asm volatile("1: lwarx %0,0,%1;"
" cmpwi %0,0;"
" bne- 1b;"
" stwcx. %2,0,%1;"
" bne- 1b;"
" isync"
: "=&r" (temp)
: "r" (word), "r" (value)
: "cr0", "memory");
return temp;
#else
*word=value;
return 0;
#endif
}

static inline void
release_spinlock(lispobj *word)
{
#ifdef LISP_FEATURE_SB_THREAD
asm volatile ("sync" : : : "memory");
#endif
*word=0;
}

#ifdef LISP_FEATURE_SB_THREAD
static inline lispobj
swap_lispobjs(volatile lispobj *dest, lispobj value)
Expand Down
12 changes: 0 additions & 12 deletions src/runtime/sparc-arch.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,6 @@
#ifndef _SPARC_ARCH_H
#define _SPARC_ARCH_H

static inline void
get_spinlock(lispobj *word,long value)
{
*word=value; /* FIXME for threads */
}

static inline void
release_spinlock(lispobj *word)
{
*word=0;
}

#define ARCH_HAS_NPC_REGISTER
#define ALIEN_STACK_GROWS_DOWNWARD

Expand Down
47 changes: 0 additions & 47 deletions src/runtime/x86-64-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,56 +5,9 @@
#ifndef _X86_64_ARCH_H
#define _X86_64_ARCH_H

#ifndef SBCL_GENESIS_CONFIG
#error genesis/config.h (or sbcl.h) must be included before this file
#endif

#include "interr.h" /* for declaration of lose() */

#define ARCH_HAS_STACK_POINTER
#define ALIEN_STACK_GROWS_DOWNWARD

#define COMPILER_BARRIER \
do { __asm__ __volatile__ ( "" : : : "memory"); } while (0)

static inline void
get_spinlock(volatile lispobj *word, unsigned long value)
{
#ifdef LISP_FEATURE_SB_THREAD
u64 rax=0;
if(*word==value)
lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
do {
#if defined(LISP_FEATURE_DARWIN)
asm volatile
("xor %0,%0\n\
lock/cmpxchg %1,%2"
: "=a" (rax)
: "r" (value), "m" (*word)
: "memory", "cc");
#else
asm volatile
("xor %0,%0\n\
lock cmpxchg %1,%2"
: "=a" (rax)
: "r" (value), "m" (*word)
: "memory", "cc");
#endif
} while(rax!=0);
#else
*word=value;
#endif
}

static inline void
release_spinlock(volatile lispobj *word)
{
/* See comment in RELEASE-SPINLOCK in target-thread.lisp. */
COMPILER_BARRIER;
*word=0;
COMPILER_BARRIER;
}

static inline lispobj
swap_lispobjs(volatile lispobj *dest, lispobj value)
{
Expand Down
56 changes: 0 additions & 56 deletions src/runtime/x86-arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,65 +9,9 @@
#error genesis/config.h (or sbcl.h) must be included before this file
#endif

#include "interr.h" /* for declaration of lose() */

#define ARCH_HAS_STACK_POINTER
#define ALIEN_STACK_GROWS_DOWNWARD

#define COMPILER_BARRIER \
do { __asm__ __volatile__ ( "" : : : "memory"); } while (0)

#ifdef LISP_FEATURE_WIN32
extern int os_number_of_processors;
#define yield_on_uniprocessor() \
do { if (os_number_of_processors<=1) SwitchToThread(); } while(0)
#else
/* Stubs are better than ifdef EVERYWHERE. */
#define yield_on_uniprocessor() \
do {} while(0)
#endif


static inline void
get_spinlock(volatile lispobj *word, unsigned long value)
{
#ifdef LISP_FEATURE_SB_THREAD
u32 eax=0;
if(*word==value)
lose("recursive get_spinlock: 0x%x,%ld\n",word,value);
do {
#if defined(LISP_FEATURE_DARWIN)
asm volatile ("xor %0,%0;\n\
lock/cmpxchg %1,%2"
: "=a" (eax)
: "r" (value), "m" (*word)
: "memory", "cc");
#else
if (eax!=0) {
asm volatile("rep; nop");
}
asm volatile ("xor %0,%0\n\
lock cmpxchg %1,%2"
: "=a" (eax)
: "r" (value), "m" (*word)
: "memory", "cc");
#endif
yield_on_uniprocessor();
} while(eax!=0);
#else
*word=value;
#endif
}

static inline void
release_spinlock(volatile lispobj *word)
{
/* See comment in RELEASE-SPINLOCK in target-thread.lisp. */
COMPILER_BARRIER;
*word=0;
COMPILER_BARRIER;
}

static inline lispobj
swap_lispobjs(volatile lispobj *dest, lispobj value)
{
Expand Down

0 comments on commit bfc02d7

Please sign in to comment.