From e16866e072f94410321d70daedbcb855ea878cac Mon Sep 17 00:00:00 2001 From: Timothy Pearson Date: Sun, 6 Nov 2011 15:56:40 -0600 Subject: Actually move the kde files that were renamed in the last commit --- tdecore/malloc/x86.h | 41 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 tdecore/malloc/x86.h (limited to 'tdecore/malloc/x86.h') diff --git a/tdecore/malloc/x86.h b/tdecore/malloc/x86.h new file mode 100644 index 000000000..b21517374 --- /dev/null +++ b/tdecore/malloc/x86.h @@ -0,0 +1,41 @@ +#include +#include + +typedef struct { + volatile unsigned int lock; + int pad0_; +} mutex_t; + +#define MUTEX_INITIALIZER { 0, 0 } + +static __inline__ int lock(mutex_t *m) { + int cnt = 0, r; + struct timespec tm; + + for(;;) { + __asm__ __volatile__ + ("xchgl %0, %1" + : "=r"(r), "=m"(m->lock) + : "0"(1), "m"(m->lock) + : "memory"); + if(!r) + return 0; +#ifdef _POSIX_PRIORITY_SCHEDULING + if(cnt < 50) { + sched_yield(); + cnt++; + } else +#endif + { + tm.tv_sec = 0; + tm.tv_nsec = 2000001; + nanosleep(&tm, NULL); + cnt = 0; + } + } +} + +static __inline__ int unlock(mutex_t *m) { + __asm __volatile ("movl $0,%0" : "=m" (m->lock)); + return 0; +} -- cgit v1.2.1