4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-15 11:00:04 +08:00
Christopher Faylor 2bd22312df * times.cc (hires::prime): Restore thread priority on failure condition.
* uinfo.cc (uinfo_init): Use more robust method for determining if process was
invoked from a non-cygwin process.
* sync.h (muto::init): Eliminate "inheritance" parameter.
(new_muto): Reflect removal of parameter.
* sync.cc (muto::init): Ditto.
* cygheap.cc (cygheap_init): Ditto.
* debug.cc (threadname_init): Ditto.
* exceptions.cc (events_init): Ditto.
* malloc.cc (malloc_init): Ditto.
* path.cc (cwdstuff::init): Ditto.
* sigproc.cc (sigproc_init): Ditto.
* grp.cc (group_lock): Use different method for locking with static member.
(read_etc_group): REALLY ensure that read lock mutex is released.
* passwd.cc (passwd_lock): Use different method for locking with static member.
(read_etc_passwd): REALLY ensure that read lock mutex is released.
* shared.cc (sec_user): Correct reversed inheritance test.
2002-02-17 04:59:55 +00:00

50 lines
1.5 KiB
C++

/* sync.h: Header file for cygwin synchronization primitives.
Copyright 1999, 2000, 2001 Red Hat, Inc.
Written by Christopher Faylor <cgf@cygnus.com>
This file is part of Cygwin.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
/* FIXME: Note that currently this class cannot be allocated via `new' since
there are issues with malloc and fork. */
class muto
{
LONG sync; /* Used to serialize access to this class. */
LONG visits; /* Count of number of times a thread has called acquire. */
LONG waiters; /* Number of threads waiting for lock. */
HANDLE bruteforce; /* event handle used to control waiting for lock. */
DWORD tid; /* Thread Id of lock owner. */
public:
class muto *next;
const char *name;
/* The real constructor. */
muto *init(const char *name) __attribute__ ((regparm (3)));
#if 0 /* FIXME: See comment in sync.cc */
~muto ()
#endif
int acquire (DWORD ms = INFINITE) __attribute__ ((regparm (1))); /* Acquire the lock. */
int release (); /* Release the lock. */
/* Return true if caller thread owns the lock. */
int ismine () {return tid == GetCurrentThreadId ();}
DWORD owner () {return tid;}
int unstable () {return !tid && (sync || waiters >= 0);}
void reset ();
};
extern muto muto_start;
/* Use a statically allocated buffer as the storage for a muto */
#define new_muto(__name) \
({ \
static muto __mbuf __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))); \
__mbuf.init (__name); \
})