2004-06-03 23:29:43 +02:00
|
|
|
/* winbase.h
|
|
|
|
|
2008-07-12 20:09:17 +02:00
|
|
|
Copyright 2002, 2003, 2004, 2008 Red Hat, Inc.
|
2004-06-03 23:29:43 +02:00
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2001-11-28 01:06:35 +01:00
|
|
|
#include_next "winbase.h"
|
|
|
|
|
|
|
|
#ifndef _WINBASE2_H
|
|
|
|
#define _WINBASE2_H
|
|
|
|
|
2002-12-14 06:06:59 +01:00
|
|
|
extern __inline__ long
|
2008-07-12 20:09:17 +02:00
|
|
|
ilockincr (volatile long *m)
|
2001-11-28 01:06:35 +01:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $1,%0\n\
|
2004-06-03 23:29:43 +02:00
|
|
|
lock xadd %0,%1\n\
|
2001-11-28 01:06:35 +01:00
|
|
|
inc %0\n\
|
2005-06-07 21:31:42 +02:00
|
|
|
": "=&r" (__res), "=m" (*m): "m" (*m): "cc");
|
2001-11-28 01:06:35 +01:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 06:06:59 +01:00
|
|
|
|
|
|
|
extern __inline__ long
|
2008-07-12 20:09:17 +02:00
|
|
|
ilockdecr (volatile long *m)
|
2001-11-28 01:06:35 +01:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $0xffffffff,%0\n\
|
2004-06-03 23:29:43 +02:00
|
|
|
lock xadd %0,%1\n\
|
2001-11-28 01:06:35 +01:00
|
|
|
dec %0\n\
|
2005-06-07 21:31:42 +02:00
|
|
|
": "=&r" (__res), "=m" (*m): "m" (*m): "cc");
|
2001-11-28 01:06:35 +01:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 06:06:59 +01:00
|
|
|
|
|
|
|
extern __inline__ long
|
2008-07-12 20:09:17 +02:00
|
|
|
ilockexch (volatile long *t, long v)
|
2001-11-28 01:06:35 +01:00
|
|
|
{
|
2009-06-05 15:53:01 +02:00
|
|
|
return
|
|
|
|
({
|
2009-07-07 23:41:43 +02:00
|
|
|
register long ret __asm ("%eax");
|
2009-06-05 15:53:01 +02:00
|
|
|
__asm __volatile ("\n"
|
|
|
|
"1: lock cmpxchgl %2, %1\n"
|
|
|
|
" jne 1b\n"
|
|
|
|
: "=a" (ret), "=m" (*t)
|
|
|
|
: "r" (v), "m" (*t), "0" (*t)
|
|
|
|
: "memory");
|
|
|
|
ret;
|
|
|
|
});
|
2002-12-14 06:06:59 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ long
|
2008-07-12 20:09:17 +02:00
|
|
|
ilockcmpexch (volatile long *t, long v, long c)
|
2002-12-14 06:06:59 +01:00
|
|
|
{
|
2009-06-05 15:53:01 +02:00
|
|
|
return
|
|
|
|
({
|
2009-07-07 23:41:43 +02:00
|
|
|
register long ret __asm ("%eax");
|
2009-06-05 15:53:01 +02:00
|
|
|
__asm __volatile ("lock cmpxchgl %2, %1"
|
|
|
|
: "=a" (ret), "=m" (*t)
|
|
|
|
: "r" (v), "m" (*t), "0" (c)
|
|
|
|
: "memory");
|
|
|
|
ret;
|
|
|
|
});
|
2001-11-28 01:06:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
#undef InterlockedIncrement
|
|
|
|
#define InterlockedIncrement ilockincr
|
|
|
|
#undef InterlockedDecrement
|
|
|
|
#define InterlockedDecrement ilockdecr
|
|
|
|
#undef InterlockedExchange
|
|
|
|
#define InterlockedExchange ilockexch
|
2002-12-14 06:06:59 +01:00
|
|
|
#undef InterlockedCompareExchange
|
|
|
|
#define InterlockedCompareExchange ilockcmpexch
|
2001-11-28 01:06:35 +01:00
|
|
|
#endif /*_WINBASE2_H*/
|