249 |
|
} |
250 |
|
#endif |
251 |
|
|
252 |
< |
#ifdef __i386__ |
252 |
> |
/* FIXME: SheepShaver occasionnally hangs with those locks */ |
253 |
> |
#if 0 && (defined(__i386__) || defined(__x86_64__)) |
254 |
|
#define HAVE_TEST_AND_SET 1 |
255 |
|
static inline int testandset(volatile int *p) |
256 |
|
{ |
257 |
< |
int ret; |
257 |
< |
long int readval; |
257 |
> |
long int ret; |
258 |
|
/* Note: the "xchg" instruction does not need a "lock" prefix */ |
259 |
< |
__asm__ __volatile__("xchgl %0, %1" |
260 |
< |
: "=r" (ret), "=m" (*p), "=a" (readval) |
259 |
> |
__asm__ __volatile__("xchgl %k0, %1" |
260 |
> |
: "=r" (ret), "=m" (*p) |
261 |
|
: "0" (1), "m" (*p) |
262 |
|
: "memory"); |
263 |
|
return ret; |
329 |
|
|
330 |
|
#endif /* __GNUC__ */ |
331 |
|
|
332 |
– |
#if HAVE_TEST_AND_SET |
333 |
– |
#define HAVE_SPINLOCKS 1 |
332 |
|
typedef volatile int spinlock_t; |
333 |
|
|
334 |
|
static const spinlock_t SPIN_LOCK_UNLOCKED = 0; |
335 |
|
|
336 |
+ |
#if HAVE_TEST_AND_SET |
337 |
+ |
#define HAVE_SPINLOCKS 1 |
338 |
|
static inline void spin_lock(spinlock_t *lock) |
339 |
|
{ |
340 |
|
while (testandset(lock)); |
349 |
|
{ |
350 |
|
return !testandset(lock); |
351 |
|
} |
352 |
+ |
#else |
353 |
+ |
static inline void spin_lock(spinlock_t *lock) |
354 |
+ |
{ |
355 |
+ |
} |
356 |
+ |
|
357 |
+ |
static inline void spin_unlock(spinlock_t *lock) |
358 |
+ |
{ |
359 |
+ |
} |
360 |
+ |
|
361 |
+ |
static inline int spin_trylock(spinlock_t *lock) |
362 |
+ |
{ |
363 |
+ |
return 1; |
364 |
+ |
} |
365 |
|
#endif |
366 |
|
|
367 |
|
// Time data type for Time Manager emulation |