2004-06-04 05:29:43 +08:00
|
|
|
/* winbase.h
|
|
|
|
|
|
|
|
Copyright 2002, 2003, 2004 Red Hat, Inc.
|
|
|
|
|
|
|
|
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 08:06:35 +08:00
|
|
|
#include_next "winbase.h"
|
|
|
|
|
|
|
|
#ifndef _WINBASE2_H
|
|
|
|
#define _WINBASE2_H
|
|
|
|
|
2002-12-14 13:06:59 +08:00
|
|
|
extern __inline__ long
|
|
|
|
ilockincr (long *m)
|
2001-11-28 08:06:35 +08:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $1,%0\n\
|
2004-06-04 05:29:43 +08:00
|
|
|
lock xadd %0,%1\n\
|
2001-11-28 08:06:35 +08:00
|
|
|
inc %0\n\
|
2004-06-05 07:55:44 +08:00
|
|
|
": "=r" (__res), "=m" (*m): "m" (*m): "cc");
|
2001-11-28 08:06:35 +08:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 13:06:59 +08:00
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockdecr (long *m)
|
2001-11-28 08:06:35 +08:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $0xffffffff,%0\n\
|
2004-06-04 05:29:43 +08:00
|
|
|
lock xadd %0,%1\n\
|
2001-11-28 08:06:35 +08:00
|
|
|
dec %0\n\
|
2004-06-05 07:55:44 +08:00
|
|
|
": "=r" (__res), "=m" (*m): "m" (*m): "cc");
|
2001-11-28 08:06:35 +08:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 13:06:59 +08:00
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockexch (long *t, long v)
|
2001-11-28 08:06:35 +08:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
1: lock cmpxchgl %3,(%1)\n\
|
|
|
|
jne 1b\n\
|
2004-05-26 04:00:19 +08:00
|
|
|
": "=a" (__res), "=q" (t): "1" (t), "q" (v), "0" (*t): "cc");
|
2002-12-14 13:06:59 +08:00
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockcmpexch (long *t, long v, long c)
|
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
lock cmpxchgl %3,(%1)\n\
|
2004-05-26 04:00:19 +08:00
|
|
|
": "=a" (__res), "=q" (t) : "1" (t), "q" (v), "0" (c): "cc");
|
2001-11-28 08:06:35 +08:00
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef InterlockedIncrement
|
|
|
|
#define InterlockedIncrement ilockincr
|
|
|
|
#undef InterlockedDecrement
|
|
|
|
#define InterlockedDecrement ilockdecr
|
|
|
|
#undef InterlockedExchange
|
|
|
|
#define InterlockedExchange ilockexch
|
2002-12-14 13:06:59 +08:00
|
|
|
#undef InterlockedCompareExchange
|
|
|
|
#define InterlockedCompareExchange ilockcmpexch
|
2001-11-28 08:06:35 +08:00
|
|
|
#endif /*_WINBASE2_H*/
|