]> sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/winbase.h
d72bb0893ce80ca6e890efb31c24aa7c8cb1f191
[newlib-cygwin.git] / winsup / cygwin / winbase.h
1 #include_next "winbase.h"
2
3 #ifndef _WINBASE2_H
4 #define _WINBASE2_H
5
6 extern __inline__ long ilockincr (long *m)
7 {
8 register int __res;
9 __asm__ __volatile__ ("\n\
10 movl $1,%0\n\
11 lock xadd %0,(%1)\n\
12 inc %0\n\
13 ": "=a" (__res), "=r" (m): "1" (m));
14 return __res;
15 }
16 extern __inline__ long ilockdecr (long *m)
17 {
18 register int __res;
19 __asm__ __volatile__ ("\n\
20 movl $0xffffffff,%0\n\
21 lock xadd %0,(%1)\n\
22 dec %0\n\
23 ": "=a" (__res), "=r" (m): "1" (m));
24 return __res;
25 }
26 extern __inline__ long ilockexch (long *t, long v)
27 {
28 register int __res;
29 __asm__ __volatile__ ("\n\
30 movl (%2),%0\n\
31 1: lock cmpxchgl %3,(%1)\n\
32 jne 1b\n\
33 ": "=a" (__res), "=c" (t): "1" (t), "d" (v));
34 return __res;
35 }
36
37 #undef InterlockedIncrement
38 #define InterlockedIncrement ilockincr
39 #undef InterlockedDecrement
40 #define InterlockedDecrement ilockdecr
41 #undef InterlockedExchange
42 #define InterlockedExchange ilockexch
43
44 extern long tls_ix;
45 extern char * volatile *__stackbase __asm__ ("%fs:4");
46
47 extern __inline__ DWORD
48 my_tlsalloc ()
49 {
50 DWORD n = ilockdecr (&tls_ix);
51 __stackbase[tls_ix] = NULL;
52 return n;
53 }
54
55 extern __inline__ BOOL
56 my_tlssetvalue (DWORD ix, void *val)
57 {
58 __stackbase[ix] = (char *) val;
59 return 1;
60 }
61
62 extern __inline__ void *
63 my_tlsgetvalue (DWORD ix)
64 {
65 return __stackbase[ix];
66 }
67
68 extern __inline__ BOOL
69 my_tlsfree (DWORD ix)
70 {
71 /* nothing for now */
72 return 1;
73 }
74
75 #undef TlsAlloc
76 #define TlsAlloc my_tlsalloc
77 #undef TlsGetValue
78 #define TlsGetValue my_tlsgetvalue
79 #undef TlsSetValue
80 #define TlsSetValue my_tlssetvalue
81 #undef TlsFree
82 #define TlsFree my_tlsfree
83 #endif /*_WINBASE2_H*/
This page took 0.038019 seconds and 4 git commands to generate.