]>
sourceware.org Git - newlib-cygwin.git/blob - winsup/cygwin/sync.h
1 /* sync.h: Header file for cygwin synchronization primitives.
3 Copyright 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
5 Written by Christopher Faylor <cgf@cygnus.com>
7 This file is part of Cygwin.
9 This software is a copyrighted work licensed under the terms of the
10 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
15 /* FIXME: Note that currently this class cannot be allocated via `new' since
16 there are issues with malloc and fork. */
19 static DWORD exiting_thread
;
20 LONG sync
; /* Used to serialize access to this class. */
21 LONG waiters
; /* Number of threads waiting for lock. */
22 HANDLE bruteforce
; /* event handle used to control waiting for lock. */
24 LONG visits
; /* Count of number of times a thread has called acquire. */
25 DWORD tid
; /* Thread Id of lock owner. */
29 /* The real constructor. */
30 muto
*init(const char *name
) __attribute__ ((regparm (3)));
32 #if 0 /* FIXME: See comment in sync.cc */
35 int acquire (DWORD ms
= INFINITE
) __attribute__ ((regparm (2))); /* Acquire the lock. */
36 int release () __attribute__ ((regparm (1))); /* Release the lock. */
38 /* Return true if caller thread owns the lock. */
39 int ismine () {return tid
== GetCurrentThreadId ();}
40 DWORD
owner () {return tid
;}
41 int unstable () {return !tid
&& (sync
|| waiters
>= 0);}
42 void reset () __attribute__ ((regparm (1)));
44 static void set_exiting_thread () {exiting_thread
= GetCurrentThreadId ();}
47 extern muto muto_start
;
49 /* Use a statically allocated buffer as the storage for a muto */
50 #define new_muto(__name) \
52 static muto __name##_storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy1"))); \
53 __name = __name##_storage.init (#__name); \
56 /* Use a statically allocated buffer as the storage for a muto */
57 #define new_muto1(__name, __storage) \
59 static muto __storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy1"))); \
60 __name = __storage.init (#__name); \
This page took 0.03618 seconds and 5 git commands to generate.