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