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
|
|
|
|
ilockincr (long *m)
|
2001-11-28 01:06:35 +01:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $1,%0\n\
|
|
|
|
lock xadd %0,(%1)\n\
|
|
|
|
inc %0\n\
|
2002-12-14 06:06:59 +01:00
|
|
|
": "=a" (__res), "=q" (m): "1" (m));
|
2001-11-28 01:06:35 +01:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 06:06:59 +01:00
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockdecr (long *m)
|
2001-11-28 01:06:35 +01:00
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
movl $0xffffffff,%0\n\
|
|
|
|
lock xadd %0,(%1)\n\
|
|
|
|
dec %0\n\
|
2002-12-14 06:06:59 +01:00
|
|
|
": "=a" (__res), "=q" (m): "1" (m));
|
2001-11-28 01:06:35 +01:00
|
|
|
return __res;
|
|
|
|
}
|
2002-12-14 06:06:59 +01:00
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockexch (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\
|
2002-12-14 06:06:59 +01:00
|
|
|
": "=a" (__res), "=q" (t): "1" (t), "q" (v), "0" (*t));
|
|
|
|
return __res;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ long
|
|
|
|
ilockcmpexch (long *t, long v, long c)
|
|
|
|
{
|
|
|
|
register int __res;
|
|
|
|
__asm__ __volatile__ ("\n\
|
|
|
|
lock cmpxchgl %3,(%1)\n\
|
|
|
|
": "=a" (__res), "=q" (t) : "1" (t), "q" (v), "0" (c));
|
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
|
|
|
|
2002-12-14 06:06:59 +01:00
|
|
|
#ifndef EXPCGf
|
|
|
|
#define DECLARE_TLS_STORAGE do {} while (0)
|
|
|
|
#else
|
|
|
|
#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused))
|
2001-11-28 01:06:35 +01:00
|
|
|
extern long tls_ix;
|
2001-11-30 07:19:58 +01:00
|
|
|
extern char * volatile *__stackbase __asm__ ("%fs:4");
|
2001-11-28 01:06:35 +01:00
|
|
|
|
|
|
|
extern __inline__ DWORD
|
|
|
|
my_tlsalloc ()
|
|
|
|
{
|
2001-11-30 07:19:58 +01:00
|
|
|
DWORD n = ilockdecr (&tls_ix);
|
|
|
|
__stackbase[tls_ix] = NULL;
|
|
|
|
return n;
|
2001-11-28 01:06:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ BOOL
|
|
|
|
my_tlssetvalue (DWORD ix, void *val)
|
|
|
|
{
|
2001-11-30 07:19:58 +01:00
|
|
|
__stackbase[ix] = (char *) val;
|
2001-11-28 01:06:35 +01:00
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ void *
|
|
|
|
my_tlsgetvalue (DWORD ix)
|
|
|
|
{
|
2001-11-30 07:19:58 +01:00
|
|
|
return __stackbase[ix];
|
2001-11-28 01:06:35 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
extern __inline__ BOOL
|
|
|
|
my_tlsfree (DWORD ix)
|
|
|
|
{
|
|
|
|
/* nothing for now */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
#undef TlsAlloc
|
|
|
|
#define TlsAlloc my_tlsalloc
|
|
|
|
#undef TlsGetValue
|
|
|
|
#define TlsGetValue my_tlsgetvalue
|
|
|
|
#undef TlsSetValue
|
|
|
|
#define TlsSetValue my_tlssetvalue
|
|
|
|
#undef TlsFree
|
|
|
|
#define TlsFree my_tlsfree
|
2002-12-14 06:06:59 +01:00
|
|
|
#endif /*EXPCGF*/
|
2001-11-28 01:06:35 +01:00
|
|
|
#endif /*_WINBASE2_H*/
|