083abe5428
muto. Use this argument to construct static storage. * cygheap.cc (cygheap_init): Reflect above change. * exceptions.cc (events_init): Ditto. * malloc.cc (malloc_init): Ditto. * path.cc (cwdstuff::init): Ditto. * cygheap.h (cwdstuff): Change name of lock element to make it less generic. * path.cc (cwdstuff::get_hash): Ditto. (cwdstuff::get_initial): Ditto. (cwdstuff::set): Ditto. (cwdstuff::get): Ditto. * sigproc.cc (proc_subproc): Ditto. * debug.cc (lock_debug): Change to method. Use method rather than macro throughout. * tty.h (tty_min::kill_pgrp): Declare new method. * fhandler_termios.cc (tty_min::kill_pgrp): New method. (fhandler_termios::line_edit): Use new method for killing process. * dcrt0.cc (do_exit): Ditto. * dtable.cc (dtable::get_debugger_info): New method for inheriting dtable info from a debugger. * tty.cc (tty_init): Attempt to grab file handle info from parent debugger, if appropriate. # dtable.cc (dtable::stdio_init): Make this a method. (dtable::init_std_file_from_handle): Don't set fd unless it's not open. (dtable::build_fhandler_from_name): Move name setting to dtable::build_fhandler. (dtable::build_fhandler): Add win32 name parameter. * dcrt0.cc (dll_crt0_1): Change to use dtable stdio_init. * dtable.h (dtable): Reflect build_fhandler parameter change. * mmap.cc (mmap_record::alloc_fh): Don't set name parameter in build_fhandler. * net.cc (fdsock): Remove set_name call since it is now handled by build_fhandler. * sigproc.cc (proc_subproc): Release muto as early as possible.
50 lines
1.6 KiB
C++
50 lines
1.6 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 __name##_storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy"))); \
|
|
__name = __name##_storage.init (#__name); \
|
|
})
|