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

cygwin.com/git/newlib-cygwin.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2001-11-28 03:06:35 +0300
committerChristopher Faylor <me@cgf.cx>2001-11-28 03:06:35 +0300
commit4d029f3940b1f91b5ee06ccd724c90245c9d52cc (patch)
tree4fd6a178d45eaa67f07ed6e1905b6e192987a743 /winsup/cygwin/winbase.h
parenta6d66c13997c667dc5de8de8865371b9fc1d20ef (diff)
* cygwin.din (ualarm): New export.
* dcrt0.cc (_dll_crt0): Add experimental tls storage declaration. (dll_crt0): Ditto. * debug.cc (thread_stub): Ditto. * thread.cc: Minor cleanup. (__pthread_create): Add experimental tls storage declaration. * miscfuncs.cc: Define tls index. * winsup.h: Declare experimental tls storage. * window.cc (alarm): Use old timer return from setitimer. (ualarm): New function.
Diffstat (limited to 'winsup/cygwin/winbase.h')
-rw-r--r--winsup/cygwin/winbase.h84
1 files changed, 84 insertions, 0 deletions
diff --git a/winsup/cygwin/winbase.h b/winsup/cygwin/winbase.h
new file mode 100644
index 000000000..801badc44
--- /dev/null
+++ b/winsup/cygwin/winbase.h
@@ -0,0 +1,84 @@
+#include_next "winbase.h"
+
+#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 __inline__ DWORD
+my_tlsalloc ()
+{
+ return (DWORD) ilockincr (&tls_ix);
+}
+
+extern __inline__ BOOL
+my_tlssetvalue (DWORD ix, void *val)
+{
+ char **stackbase;
+ __asm__ volatile ("movl %%fs:4,%0": "=g" (stackbase));
+ stackbase[-ix] = (char *) val;
+ return 1;
+}
+
+extern __inline__ void *
+my_tlsgetvalue (DWORD ix)
+{
+ char **stackbase;
+ __asm__ volatile ("movl %%fs:4,%0": "=g" (stackbase));
+ 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*/