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
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
1: lock cmpxchgl %3,(%1)\n\
|
|
|
|
jne 1b\n\
|
2004-05-25 22:00:19 +02:00
|
|
|
": "=a" (__res), "=q" (t): "1" (t), "q" (v), "0" (*t): "cc");
|
2002-12-14 06:06:59 +01:00
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
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
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
lock cmpxchgl %3,(%1)\n\
|
2004-05-25 22:00:19 +02:00
|
|
|
": "=a" (__res), "=q" (t) : "1" (t), "q" (v), "0" (c): "cc");
|
2001-11-28 01:06:35 +01:00
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
#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*/
|