Welcome to mirror list, hosted at ThFree Co, Russian Federation.

winbase.h « cygwin « winsup - cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
blob: 15d16a4292b1876569452effb12b0f11bdb63e39 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#include_next "winbase.h"

#ifdef EXPCGF
#define DECLARE_TLS_STORAGE char **tls[4096] __attribute__ ((unused))
#else
#define DECLARE_TLS_STORAGE do {} while (0)
#define _WINBASE2_H
#endif

#ifndef _WINBASE2_H
#define _WINBASE2_H

extern __inline__ long ilockincr (long *m)
{
  register int __res;
  __asm__ __volatile__ ("\n\
	movl	$1,%0\n\
	lock	xadd %0,(%1)\n\
	inc	%0\n\
	": "=a" (__res), "=r" (m): "1" (m));
  return __res;
}
extern __inline__ long ilockdecr (long *m)
{
  register int __res;
  __asm__ __volatile__ ("\n\
	movl	$0xffffffff,%0\n\
	lock	xadd %0,(%1)\n\
	dec	%0\n\
	": "=a" (__res), "=r" (m): "1" (m));
  return __res;
}
extern __inline__ long ilockexch (long *t, long v)
{
  register int __res;
  __asm__ __volatile__ ("\n\
	movl	(%2),%0\n\
1:	lock	cmpxchgl %3,(%1)\n\
	jne 1b\n\
 	": "=a" (__res), "=c" (t): "1" (t), "d" (v));
  return __res;
}

#undef InterlockedIncrement
#define InterlockedIncrement ilockincr
#undef InterlockedDecrement
#define InterlockedDecrement ilockdecr
#undef InterlockedExchange
#define InterlockedExchange ilockexch

extern long tls_ix;
extern char * volatile *__stackbase __asm__ ("%fs:4");

extern __inline__ DWORD
my_tlsalloc ()
{
  DWORD n = ilockdecr (&tls_ix);
  __stackbase[tls_ix] = NULL;
  return n;
}

extern __inline__ BOOL
my_tlssetvalue (DWORD ix, void *val)
{
  __stackbase[ix] = (char *) val;
  return 1;
}

extern __inline__ void *
my_tlsgetvalue (DWORD ix)
{
  return __stackbase[ix];
}

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
#endif /*_WINBASE2_H*/