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
path: root/winsup
diff options
context:
space:
mode:
authorChristopher Faylor <me@cgf.cx>2005-04-05 08:31:00 +0400
committerChristopher Faylor <me@cgf.cx>2005-04-05 08:31:00 +0400
commit322c131f9f8ec512b0b319aa383d70f8c8e60fbd (patch)
treedfb27bede722fde757fd4b86b2e51f3d6603b84f /winsup
parent82ae6271bae18731076156c2a52065cfb89d2f53 (diff)
* sync.h (muto::operator int): New operator.
(locker): Remove unused class. (new_muto): Delete. (new_muto1): Ditto. (new_muto_name): Ditto. * cygheap.cc (cygheap_setup_for_child): Reflect use of static storage for muto rather than pointer. (_csbrk): Ditto. (_cmalloc): Ditto. (_cmalloc): Ditto. (_cfree): Ditto. * cygheap.h (cwdstuff::cwd_lock): Ditto. (cwdstuff::get_drive): Ditto. * cygmalloc.h (__malloc_lock): Ditto. (__malloc_unlock): Ditto. * cygtls.cc (sentry::lock): Ditto. (sentry::sentry): Ditto. (~sentry): Ditto. (_cygtls::init): Ditto. * dcrt0.cc: Ditto. (cygwin_atexit): Ditto. (cygwin_exit): Ditto. * debug.cc (lock_debug::locker): Ditto. (lock_debug::lock_debug): Ditto. (lock_debug::unlock): Ditto. (debug_init): Ditto. * dtable.cc (dtable::init_lock): Ditto. * dtable.h (dtable::lock_cs): Ditto. (dtable::lock): Ditto. (dtable::unlock): Ditto. * exceptions.cc (mask_sync): Ditto. (sighold): Ditto. (set_process_mask_delta): Ditto. (set_signal_mask): Ditto. (events_init): Ditto. * grp.cc (pwdgrp::pwdgrp): Ditto. * malloc_wrapper.cc (mallock): Ditto. (malloc_init): Ditto. * path.cc (cwdstuff::cwd_lock): Ditto. (cwdstuff::get_hash): Ditto. (cwdstuff::get_hash): Ditto. (cwdstuff::init): Ditto. (cwdstuff::set): Ditto. (cwdstuff::get): Ditto. * pwdgrp.h (pwdgrp::pglock): Ditto. (pwdgrp::refresh): Ditto. * sigproc.cc (sync_proc_subproc): Ditto. (get_proc_lock): Ditto. (proc_subproc): Ditto. (_cygtls::remove_wq): Ditto. (proc_terminate): Ditto. (sigproc_init): Ditto. * timer.cc (lock_timer_tracker::protect): Ditto. (lock_timer_tracker::lock_timer_tracker): Ditto. (lock_timer_tracker::~lock_timer_tracker): Ditto. * wininfo.cc (wininfo::_lock;): Ditto. (wininfo::winthread): Ditto. (operator HWND): Ditto. (wininfo::lock): Ditto. (wininfo::release): Ditto. * wininfo.h (wininfo::_lock;): Ditto.
Diffstat (limited to 'winsup')
-rw-r--r--winsup/cygwin/ChangeLog80
-rw-r--r--winsup/cygwin/cygheap.cc22
-rw-r--r--winsup/cygwin/cygheap.h4
-rw-r--r--winsup/cygwin/cygmalloc.h6
-rw-r--r--winsup/cygwin/cygtls.cc12
-rw-r--r--winsup/cygwin/dcrt0.cc13
-rw-r--r--winsup/cygwin/debug.cc15
-rw-r--r--winsup/cygwin/dtable.cc2
-rw-r--r--winsup/cygwin/dtable.h6
-rw-r--r--winsup/cygwin/exceptions.cc16
-rw-r--r--winsup/cygwin/grp.cc4
-rw-r--r--winsup/cygwin/malloc_wrapper.cc4
-rw-r--r--winsup/cygwin/path.cc16
-rw-r--r--winsup/cygwin/pwdgrp.h6
-rw-r--r--winsup/cygwin/sigproc.cc16
-rw-r--r--winsup/cygwin/sync.h35
-rw-r--r--winsup/cygwin/timer.cc8
-rw-r--r--winsup/cygwin/window.cc10
-rw-r--r--winsup/cygwin/wininfo.h2
19 files changed, 159 insertions, 118 deletions
diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog
index 99a23892c..c5b3c610c 100644
--- a/winsup/cygwin/ChangeLog
+++ b/winsup/cygwin/ChangeLog
@@ -1,3 +1,67 @@
+2005-04-05 Christopher Faylor <cgf@timesys.com>
+
+ * sync.h (muto::operator int): New operator.
+ (locker): Remove unused class.
+ (new_muto): Delete.
+ (new_muto1): Ditto.
+ (new_muto_name): Ditto.
+ * cygheap.cc (cygheap_setup_for_child): Reflect use of static storage
+ for muto rather than pointer.
+ (_csbrk): Ditto.
+ (_cmalloc): Ditto.
+ (_cmalloc): Ditto.
+ (_cfree): Ditto.
+ * cygheap.h (cwdstuff::cwd_lock): Ditto.
+ (cwdstuff::get_drive): Ditto.
+ * cygmalloc.h (__malloc_lock): Ditto.
+ (__malloc_unlock): Ditto.
+ * cygtls.cc (sentry::lock): Ditto.
+ (sentry::sentry): Ditto.
+ (~sentry): Ditto.
+ (_cygtls::init): Ditto.
+ * dcrt0.cc: Ditto.
+ (cygwin_atexit): Ditto.
+ (cygwin_exit): Ditto.
+ * debug.cc (lock_debug::locker): Ditto.
+ (lock_debug::lock_debug): Ditto.
+ (lock_debug::unlock): Ditto.
+ (debug_init): Ditto.
+ * dtable.cc (dtable::init_lock): Ditto.
+ * dtable.h (dtable::lock_cs): Ditto.
+ (dtable::lock): Ditto.
+ (dtable::unlock): Ditto.
+ * exceptions.cc (mask_sync): Ditto.
+ (sighold): Ditto.
+ (set_process_mask_delta): Ditto.
+ (set_signal_mask): Ditto.
+ (events_init): Ditto.
+ * grp.cc (pwdgrp::pwdgrp): Ditto.
+ * malloc_wrapper.cc (mallock): Ditto.
+ (malloc_init): Ditto.
+ * path.cc (cwdstuff::cwd_lock): Ditto.
+ (cwdstuff::get_hash): Ditto.
+ (cwdstuff::get_hash): Ditto.
+ (cwdstuff::init): Ditto.
+ (cwdstuff::set): Ditto.
+ (cwdstuff::get): Ditto.
+ * pwdgrp.h (pwdgrp::pglock): Ditto.
+ (pwdgrp::refresh): Ditto.
+ * sigproc.cc (sync_proc_subproc): Ditto.
+ (get_proc_lock): Ditto.
+ (proc_subproc): Ditto.
+ (_cygtls::remove_wq): Ditto.
+ (proc_terminate): Ditto.
+ (sigproc_init): Ditto.
+ * timer.cc (lock_timer_tracker::protect): Ditto.
+ (lock_timer_tracker::lock_timer_tracker): Ditto.
+ (lock_timer_tracker::~lock_timer_tracker): Ditto.
+ * wininfo.cc (wininfo::_lock;): Ditto.
+ (wininfo::winthread): Ditto.
+ (operator HWND): Ditto.
+ (wininfo::lock): Ditto.
+ (wininfo::release): Ditto.
+ * wininfo.h (wininfo::_lock;): Ditto.
+
2005-04-04 Christopher Faylor <cgf@timesys.com>
* path.cc (path_conv::check): Only check for PC_NO_ACCESS_CHECK in end
@@ -10,13 +74,13 @@
* fhandler.h (enum change_state): Add.
(fhandler_base::status): Add a bit to has_changed flag.
(fhandler_base::has_changed): Implement with type change_state.
- * fhandler.cc (fhandler_base::raw_write): Accomodate type change
+ * fhandler.cc (fhandler_base::raw_write): Accommodate type change
of has_changed.
* fhandler_disk_file.cc )fhandler_disk_file::touch_ctime): Also
touch modification time if has_changed == data_changed.
(fhandler_disk_file::fchmod): Also open on 9x, otherwise we can't
- touch ctime. Accomodate type change of has_changed.
- (fhandler_disk_file::fchown): Accomodate type change of has_changed.
+ touch ctime. Accommodate type change of has_changed.
+ (fhandler_disk_file::fchown): Accommodate type change of has_changed.
(fhandler_disk_file::facl): Ditto.
(fhandler_disk_file::ftruncate): Ditto.
(fhandler_disk_file::link): Ditto.
@@ -24,7 +88,7 @@
2005-04-03 Corinna Vinschen <corinna@vinschen.de>
- * cygheap.cc (cygheap_init): Accomodate set_process_privilege change.
+ * cygheap.cc (cygheap_init): Accommodate set_process_privilege change.
* cygheap.h (cygheap_user::curr_primary_token): New member.
(cygheap_user::primary_token): New method.
(cygheap_user::deimpersonate): Always revert to processes'
@@ -881,7 +945,7 @@
(class fhandler_disk_file): Ditto.
(class fhandler_dev_mem): Ditto.
* fhandler_mem.cc (fhandler_dev_mem::fixup_mmap_after_fork):
- Accomodate new parameters.
+ Accommodate new parameters.
* mmap.cc: Include ntdll.h.
(class mmap_record): Add flags member.
(mmap_record::mmap_record): Add flags parameter.
@@ -893,14 +957,14 @@
(mmap64): Don't align offset and length to granularity in case of
MAP_ANONYMOUS on NT. Check for already existing mapping only on 9x.
Call mmap_record::mmap_record with additional flags argument.
- (fhandler_base::fixup_mmap_after_fork): Accomodate new parameters.
+ (fhandler_base::fixup_mmap_after_fork): Accommodate new parameters.
(fhandler_disk_file::mmap): Use NtMapViewOfSection with
AT_ROUND_TO_PAGE flag for anonymous mappings on NT. If addr is NULL,
try to map adjacent to previous mapping.
(fhandler_disk_file::fixup_mmap_after_fork): Add flags argument.
Change offset parameter to _off64_t. Use NtMapViewOfSection to
re-create anonymous mappings on NT.
- (fixup_mmaps_after_fork): Accomodate new parameters when calling
+ (fixup_mmaps_after_fork): Accommodate new parameters when calling
fhandler's fixup_mmaps_after_fork function.
* ntdll.h (AT_ROUND_TO_PAGE): New define.
@@ -1019,7 +1083,7 @@
* fhandler_disk_file.cc (fhandler_base::fstat_by_handle): Pass
dwVolumeSerialNumber from GetFileInformationByHandle to fstat_helper.
(fhandler_base::fstat_by_name): Pass pc.volser () to fstat_helper.
- Accomodate dropping default values for last three arguments of
+ Accommodate dropping default values for last three arguments of
fstat_helper.
(fhandler_base::fstat_helper): Add dwVolumeSerialNumber argument.
Use for st_dev member unless 0 in which case pc.volser () is used.
diff --git a/winsup/cygwin/cygheap.cc b/winsup/cygwin/cygheap.cc
index a44901886..369501131 100644
--- a/winsup/cygwin/cygheap.cc
+++ b/winsup/cygwin/cygheap.cc
@@ -26,7 +26,7 @@
init_cygheap NO_COPY *cygheap;
void NO_COPY *cygheap_max;
-static NO_COPY muto *cygheap_protect;
+static NO_COPY muto cygheap_protect;
static NO_COPY DWORD reserve_sz;
struct cygheap_entry
@@ -100,7 +100,7 @@ void *__stdcall
cygheap_setup_for_child (child_info *ci, bool dup_later)
{
void *newcygheap;
- cygheap_protect->acquire ();
+ cygheap_protect.acquire ();
unsigned n = (char *) cygheap_max - (char *) cygheap;
unsigned size = reserve_sz;
if (size < n)
@@ -115,7 +115,7 @@ cygheap_setup_for_child (child_info *ci, bool dup_later)
ProtectHandle1INH (ci->cygheap_h, passed_cygheap_h);
if (!dup_later)
dup_now (newcygheap, ci, n);
- cygheap_protect->release ();
+ cygheap_protect.release ();
ci->cygheap = cygheap;
ci->cygheap_max = cygheap_max;
ci->cygheap_reserve_sz = size;
@@ -131,9 +131,9 @@ cygheap_setup_for_child_cleanup (void *newcygheap, child_info *ci,
/* NOTE: There is an assumption here that cygheap_max has not changed
between the time that cygheap_setup_for_child was called and now.
Make sure that this is a correct assumption. */
- cygheap_protect->acquire ();
+ cygheap_protect.acquire ();
dup_now (newcygheap, ci, (char *) cygheap_max - (char *) cygheap);
- cygheap_protect->release ();
+ cygheap_protect.release ();
}
UnmapViewOfFile (newcygheap);
ForceCloseHandle1 (ci->cygheap_h, passed_cygheap_h);
@@ -254,7 +254,7 @@ _csbrk (int sbs)
extern "C" void __stdcall
cygheap_init ()
{
- new_muto (cygheap_protect);
+ cygheap_protect.init ("cygheap_protect");
if (!cygheap)
{
init_cheap ();
@@ -288,7 +288,7 @@ _cmalloc (unsigned size)
for (b = 3, sz = 8; sz && sz < size; b++, sz <<= 1)
continue;
- cygheap_protect->acquire ();
+ cygheap_protect.acquire ();
if (cygheap->buckets[b])
{
rvc = (_cmalloc_entry *) cygheap->buckets[b];
@@ -300,7 +300,7 @@ _cmalloc (unsigned size)
rvc = (_cmalloc_entry *) _csbrk (sz + sizeof (_cmalloc_entry));
if (!rvc)
{
- cygheap_protect->release ();
+ cygheap_protect.release ();
return NULL;
}
@@ -308,19 +308,19 @@ _cmalloc (unsigned size)
rvc->prev = cygheap->chain;
cygheap->chain = rvc;
}
- cygheap_protect->release ();
+ cygheap_protect.release ();
return rvc->data;
}
static void __stdcall
_cfree (void *ptr)
{
- cygheap_protect->acquire ();
+ cygheap_protect.acquire ();
_cmalloc_entry *rvc = to_cmalloc (ptr);
DWORD b = rvc->b;
rvc->ptr = cygheap->buckets[b];
cygheap->buckets[b] = (char *) rvc;
- cygheap_protect->release ();
+ cygheap_protect.release ();
}
static void *__stdcall
diff --git a/winsup/cygwin/cygheap.h b/winsup/cygwin/cygheap.h
index 3679ddb56..df0d54d16 100644
--- a/winsup/cygwin/cygheap.h
+++ b/winsup/cygwin/cygheap.h
@@ -226,14 +226,14 @@ struct cwdstuff
char *win32;
DWORD hash;
DWORD drive_length;
- muto *cwd_lock;
+ static muto cwd_lock;
char *get (char *, int = 1, int = 0, unsigned = CYG_MAX_PATH);
DWORD get_hash ();
DWORD get_drive (char * dst)
{
get_initial ();
memcpy (dst, win32, drive_length);
- cwd_lock->release ();
+ cwd_lock.release ();
return drive_length;
}
void init ();
diff --git a/winsup/cygwin/cygmalloc.h b/winsup/cygwin/cygmalloc.h
index adb37cf69..10508296d 100644
--- a/winsup/cygwin/cygmalloc.h
+++ b/winsup/cygwin/cygmalloc.h
@@ -25,9 +25,9 @@ void dlmalloc_stats ();
#ifndef __INSIDE_CYGWIN__
# define USE_DL_PREFIX 1
#else
-# define __malloc_lock() mallock->acquire ()
-# define __malloc_unlock() mallock->release ()
-extern muto *mallock;
+# define __malloc_lock() mallock.acquire ()
+# define __malloc_unlock() mallock.release ()
+extern muto mallock;
#endif
#ifdef __cplusplus
}
diff --git a/winsup/cygwin/cygtls.cc b/winsup/cygwin/cygtls.cc
index 4055f0228..b4ca01b44 100644
--- a/winsup/cygwin/cygtls.cc
+++ b/winsup/cygwin/cygtls.cc
@@ -25,18 +25,18 @@ details. */
class sentry
{
- static muto *lock;
+ static muto lock;
int destroy;
public:
void init ();
- bool acquired () {return lock->acquired ();}
+ bool acquired () {return lock.acquired ();}
sentry () {destroy = 0;}
- sentry (DWORD wait) {destroy = lock->acquire (wait);}
- ~sentry () {if (destroy) lock->release ();}
+ sentry (DWORD wait) {destroy = lock.acquire (wait);}
+ ~sentry () {if (destroy) lock.release ();}
friend void _cygtls::init ();
};
-muto NO_COPY *sentry::lock;
+muto NO_COPY sentry::lock;
static size_t NO_COPY nthreads;
@@ -53,7 +53,7 @@ _cygtls::init ()
cygheap->threadlist = (_cygtls **) ccalloc (HEAP_TLS, cygheap->sthreads,
sizeof (cygheap->threadlist[0]));
}
- new_muto1 (sentry::lock, sentry_lock);
+ sentry::lock.init ("sentry_lock");
}
void
diff --git a/winsup/cygwin/dcrt0.cc b/winsup/cygwin/dcrt0.cc
index 52b82c1aa..c5db62c07 100644
--- a/winsup/cygwin/dcrt0.cc
+++ b/winsup/cygwin/dcrt0.cc
@@ -47,6 +47,8 @@ HANDLE NO_COPY hMainProc = (HANDLE) -1;
HANDLE NO_COPY hMainThread;
HANDLE NO_COPY hProcToken;
HANDLE NO_COPY hProcImpToken;
+muto NO_COPY dtable::lock_cs; /* This should be in dtable.cc but it causes inexplicable
+ errors there. */
bool display_title;
bool strip_title_path;
@@ -1078,17 +1080,16 @@ do_exit (int status)
myself.exit (n);
}
-static muto *atexit_lock;
+static NO_COPY muto atexit_lock;
extern "C" int
cygwin_atexit (void (*function)(void))
{
int res;
- if (!atexit_lock)
- new_muto (atexit_lock);
- atexit_lock->acquire ();
+ atexit_lock.init ("atexit_lock");
+ atexit_lock.acquire ();
res = atexit (function);
- atexit_lock->release ();
+ atexit_lock.release ();
return res;
}
@@ -1096,7 +1097,7 @@ extern "C" void
cygwin_exit (int n)
{
if (atexit_lock)
- atexit_lock->acquire ();
+ atexit_lock.acquire ();
exit (n);
}
diff --git a/winsup/cygwin/debug.cc b/winsup/cygwin/debug.cc
index b885a9fc4..ad493cd9d 100644
--- a/winsup/cygwin/debug.cc
+++ b/winsup/cygwin/debug.cc
@@ -31,19 +31,19 @@ details. */
class lock_debug
{
- static muto *locker;
+ static muto locker;
bool acquired;
public:
lock_debug () : acquired (0)
{
- if (locker && !exit_state)
- acquired = !!locker->acquire (INFINITE);
+ if (locker.name && !exit_state)
+ acquired = !!locker.acquire (INFINITE);
}
void unlock ()
{
- if (locker && acquired)
+ if (locker.name && acquired)
{
- locker->release ();
+ locker.release ();
acquired = false;
}
}
@@ -51,15 +51,14 @@ class lock_debug
friend void debug_init ();
};
-muto NO_COPY *lock_debug::locker = NULL;
+muto NO_COPY lock_debug::locker;
static bool __stdcall mark_closed (const char *, int, HANDLE, const char *, bool);
void
debug_init ()
{
- muto *debug_lock_muto;
- lock_debug::locker = new_muto (debug_lock_muto);
+ lock_debug::locker.init ("debug_lock");
}
/* Find a registered handle in the linked list of handles. */
diff --git a/winsup/cygwin/dtable.cc b/winsup/cygwin/dtable.cc
index 1495ccdbc..2f011e6fb 100644
--- a/winsup/cygwin/dtable.cc
+++ b/winsup/cygwin/dtable.cc
@@ -63,7 +63,7 @@ set_std_handle (int fd)
void
dtable::init_lock ()
{
- new_muto (lock_cs);
+ lock_cs.init ("lock_cs");
}
int
diff --git a/winsup/cygwin/dtable.h b/winsup/cygwin/dtable.h
index dcb1bde19..343eb8cc8 100644
--- a/winsup/cygwin/dtable.h
+++ b/winsup/cygwin/dtable.h
@@ -20,7 +20,7 @@ class fhandler_fifo;
#define BFH_OPTS (PC_NULLEMPTY | PC_FULL | PC_POSIX)
class dtable
{
- muto *lock_cs;
+ static muto lock_cs;
fhandler_base **fds;
#ifdef NEWVFORK
fhandler_base **fds_on_hold;
@@ -31,8 +31,8 @@ class dtable
static const int initial_archetype_size = 8;
int first_fd_for_open;
int cnt_need_fixup_before;
- void lock () {lock_cs->acquire ();}
- void unlock () {lock_cs->release ();}
+ void lock () {lock_cs.acquire ();}
+ void unlock () {lock_cs.release ();}
void init_lock ();
public:
size_t size;
diff --git a/winsup/cygwin/exceptions.cc b/winsup/cygwin/exceptions.cc
index db8b5044a..96702b1de 100644
--- a/winsup/cygwin/exceptions.cc
+++ b/winsup/cygwin/exceptions.cc
@@ -49,7 +49,7 @@ static size_t windows_system_directory_length;
/* This is set to indicate that we have already exited. */
static NO_COPY int exit_already = 0;
-static NO_COPY muto *mask_sync = NULL;
+static NO_COPY muto mask_sync;
NO_COPY static struct
{
@@ -901,11 +901,11 @@ sighold (int sig)
syscall_printf ("signal %d out of range", sig);
return -1;
}
- mask_sync->acquire (INFINITE);
+ mask_sync.acquire (INFINITE);
sigset_t mask = myself->getsigmask ();
sigaddset (&mask, sig);
set_signal_mask (mask);
- mask_sync->release ();
+ mask_sync.release ();
return 0;
}
@@ -915,7 +915,7 @@ sighold (int sig)
extern "C" sigset_t
set_process_mask_delta ()
{
- mask_sync->acquire (INFINITE);
+ mask_sync.acquire (INFINITE);
sigset_t newmask, oldmask;
if (_my_tls.deltamask & SIG_NONMASKABLE)
@@ -926,7 +926,7 @@ set_process_mask_delta ()
sigproc_printf ("oldmask %p, newmask %p, deltamask %p", oldmask, newmask,
_my_tls.deltamask);
myself->setsigmask (newmask);
- mask_sync->release ();
+ mask_sync.release ();
return oldmask;
}
@@ -935,7 +935,7 @@ set_process_mask_delta ()
extern "C" void __stdcall
set_signal_mask (sigset_t newmask, sigset_t oldmask)
{
- mask_sync->acquire (INFINITE);
+ mask_sync.acquire (INFINITE);
newmask &= ~SIG_NONMASKABLE;
sigset_t mask_bits = oldmask & ~newmask;
sigproc_printf ("oldmask %p, newmask %p, mask_bits %p", oldmask, newmask,
@@ -945,7 +945,7 @@ set_signal_mask (sigset_t newmask, sigset_t oldmask)
sig_dispatch_pending (true);
else
sigproc_printf ("not calling sig_dispatch_pending");
- mask_sync->release ();
+ mask_sync.release ();
return;
}
@@ -1142,7 +1142,7 @@ events_init (void)
api_fatal ("can't create title mutex '%s', %E", name);
ProtectHandle (tty_mutex);
- new_muto (mask_sync);
+ mask_sync.init ("mask_sync");
windows_system_directory[0] = '\0';
(void) GetSystemDirectory (windows_system_directory, sizeof (windows_system_directory) - 2);
char *end = strchr (windows_system_directory, '\0');
diff --git a/winsup/cygwin/grp.cc b/winsup/cygwin/grp.cc
index df5a14ee9..5f45a31b3 100644
--- a/winsup/cygwin/grp.cc
+++ b/winsup/cygwin/grp.cc
@@ -111,7 +111,7 @@ pwdgrp::pwdgrp (passwd *&pbuf) :
{
read = &pwdgrp::read_passwd;
parse = &pwdgrp::parse_passwd;
- new_muto (pglock);
+ pglock.init ("pwd_lock");
}
pwdgrp::pwdgrp (__group32 *&gbuf) :
@@ -119,7 +119,7 @@ pwdgrp::pwdgrp (__group32 *&gbuf) :
{
read = &pwdgrp::read_group;
parse = &pwdgrp::parse_group;
- new_muto (pglock);
+ pglock.init ("grp_lock");
}
struct __group32 *
diff --git a/winsup/cygwin/malloc_wrapper.cc b/winsup/cygwin/malloc_wrapper.cc
index 2995ca6e2..8cd6e3ecd 100644
--- a/winsup/cygwin/malloc_wrapper.cc
+++ b/winsup/cygwin/malloc_wrapper.cc
@@ -248,12 +248,12 @@ strdup (const char *s)
newlib will call __malloc_lock and __malloc_unlock at appropriate
times. */
-NO_COPY muto *mallock = NULL;
+muto NO_COPY mallock;
void
malloc_init ()
{
- new_muto (mallock);
+ mallock.init ("mallock");
#ifndef MALLOC_DEBUG
/* Check if malloc is provided by application. If so, redirect all
diff --git a/winsup/cygwin/path.cc b/winsup/cygwin/path.cc
index b4bbe5681..b1d8a4416 100644
--- a/winsup/cygwin/path.cc
+++ b/winsup/cygwin/path.cc
@@ -104,6 +104,8 @@ struct symlink_info
void set_error (int);
};
+muto NO_COPY cwdstuff::cwd_lock;
+
int pcheck_case = PCHECK_RELAXED; /* Determines the case check behaviour. */
static const GUID GUID_shortcut
@@ -3728,9 +3730,9 @@ DWORD
cwdstuff::get_hash ()
{
DWORD hashnow;
- cwd_lock->acquire ();
+ cwd_lock.acquire ();
hashnow = hash;
- cwd_lock->release ();
+ cwd_lock.release ();
return hashnow;
}
@@ -3738,7 +3740,7 @@ cwdstuff::get_hash ()
void
cwdstuff::init ()
{
- new_muto (cwd_lock);
+ cwd_lock.init ("cwd_lock");
}
/* Get initial cwd. Should only be called once in a
@@ -3746,7 +3748,7 @@ cwdstuff::init ()
bool
cwdstuff::get_initial ()
{
- cwd_lock->acquire ();
+ cwd_lock.acquire ();
if (win32)
return 1;
@@ -3766,7 +3768,7 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit)
if (win32_cwd)
{
- cwd_lock->acquire ();
+ cwd_lock.acquire ();
if (doit && !SetCurrentDirectory (win32_cwd))
{
__seterrno ();
@@ -3823,7 +3825,7 @@ cwdstuff::set (const char *win32_cwd, const char *posix_cwd, bool doit)
res = 0;
out:
if (win32_cwd)
- cwd_lock->release ();
+ cwd_lock.release ();
return res;
}
@@ -3867,7 +3869,7 @@ cwdstuff::get (char *buf, int need_posix, int with_chroot, unsigned ulen)
strcpy (buf, "/");
}
- cwd_lock->release ();
+ cwd_lock.release ();
out:
syscall_printf ("(%s) = cwdstuff::get (%p, %d, %d, %d), errno %d",
diff --git a/winsup/cygwin/pwdgrp.h b/winsup/cygwin/pwdgrp.h
index c579fc4f4..53899e87d 100644
--- a/winsup/cygwin/pwdgrp.h
+++ b/winsup/cygwin/pwdgrp.h
@@ -39,7 +39,7 @@ class pwdgrp
char *buf, *lptr;
int max_lines;
bool initialized;
- muto *pglock;
+ muto pglock;
bool parse_passwd ();
bool parse_group ();
@@ -72,10 +72,10 @@ public:
{
if (!check && initialized)
return;
- if (pglock->acquire () == 1 &&
+ if (pglock.acquire () == 1 &&
(!initialized || (check && etc::file_changed (etc_ix))))
(this->*read) ();
- pglock->release ();
+ pglock.release ();
}
pwdgrp (passwd *&pbuf);
diff --git a/winsup/cygwin/sigproc.cc b/winsup/cygwin/sigproc.cc
index e17c744dd..564a805b0 100644
--- a/winsup/cygwin/sigproc.cc
+++ b/winsup/cygwin/sigproc.cc
@@ -70,7 +70,7 @@ Static char cprocs[(NPROCS + 1) * sizeof (pinfo)];// All my children info
// constructor operation at DLL startup
Static waitq waitq_head = {0, 0, 0, 0, 0, 0, 0};// Start of queue for wait'ing threads
-muto NO_COPY *sync_proc_subproc = NULL; // Control access to subproc stuff
+muto NO_COPY sync_proc_subproc; // Control access to subproc stuff
DWORD NO_COPY sigtid = 0; // ID of the signal thread
@@ -150,7 +150,7 @@ get_proc_lock (DWORD what, DWORD val)
sigproc_printf ("sync_proc_subproc is NULL (1)");
return false;
}
- if (sync_proc_subproc->acquire (WPSP))
+ if (sync_proc_subproc.acquire (WPSP))
{
lastwhat = what;
return true;
@@ -351,7 +351,7 @@ proc_subproc (DWORD what, DWORD val)
}
out:
- sync_proc_subproc->release (); // Release the lock
+ sync_proc_subproc.release (); // Release the lock
out1:
sigproc_printf ("returning %d", rc);
return rc;
@@ -363,7 +363,7 @@ out1:
void
_cygtls::remove_wq (DWORD wait)
{
- if (sync_proc_subproc && sync_proc_subproc->acquire (wait))
+ if (sync_proc_subproc && sync_proc_subproc.acquire (wait))
{
for (waitq *w = &waitq_head; w->next != NULL; w = w->next)
if (w->next == &wq)
@@ -372,7 +372,7 @@ _cygtls::remove_wq (DWORD wait)
w->next = wq.next;
break;
}
- sync_proc_subproc->release ();
+ sync_proc_subproc.release ();
}
}
@@ -389,7 +389,7 @@ proc_terminate (void)
/* Signal processing is assumed to be blocked in this routine. */
if (nprocs)
{
- sync_proc_subproc->acquire (WPSP);
+ sync_proc_subproc.acquire (WPSP);
(void) proc_subproc (PROC_CLEARWAIT, 1);
@@ -406,7 +406,7 @@ proc_terminate (void)
procs[i].release ();
}
nprocs = 0;
- sync_proc_subproc->release ();
+ sync_proc_subproc.release ();
}
sigproc_printf ("leaving");
}
@@ -488,7 +488,7 @@ sigproc_init ()
/* sync_proc_subproc is used by proc_subproc. It serialises
* access to the children and proc arrays.
*/
- new_muto (sync_proc_subproc);
+ sync_proc_subproc.init ("sync_proc_subproc");
create_signal_arrived ();
diff --git a/winsup/cygwin/sync.h b/winsup/cygwin/sync.h
index c729454c3..441892a08 100644
--- a/winsup/cygwin/sync.h
+++ b/winsup/cygwin/sync.h
@@ -16,6 +16,9 @@ details. */
there are issues with malloc and fork. */
class muto
{
+public:
+ const char *name;
+private:
static DWORD exiting_thread;
LONG sync; /* Used to serialize access to this class. */
LONG waiters; /* Number of threads waiting for lock. */
@@ -24,10 +27,9 @@ public:
LONG visits; /* Count of number of times a thread has called acquire. */
void *tls; /* Tls of lock owner. */
// class muto *next;
- const char *name;
/* The real constructor. */
- muto *init(const char *name) __attribute__ ((regparm (3)));
+ muto *init (const char *) __attribute__ ((regparm (2)));
#if 0 /* FIXME: See comment in sync.cc */
~muto ()
@@ -38,35 +40,8 @@ public:
bool acquired () __attribute__ ((regparm (1)));
void upforgrabs () {tls = this;} // just set to an invalid address
void grab () __attribute__ ((regparm (1)));
+ operator int () const {return !!name;}
static void set_exiting_thread () {exiting_thread = GetCurrentThreadId ();}
};
-class locker
-{
- muto *room;
-public:
- locker (muto *m) {room = m; room->acquire ();}
- ~locker () {room->release ();}
-};
-
-/* 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_nocopy1"))); \
- __name = __name##_storage.init (#__name); \
-})
-
-/* Use a statically allocated buffer as the storage for a muto */
-#define new_muto1(__name, __storage) \
-({ \
- static muto __storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy1"))); \
- __name = __storage.init (#__name); \
-})
-
-/* Use a statically allocated buffer as the storage for a muto */
-#define new_muto_name(__var, __name) \
-({ \
- static muto __var##_storage __attribute__((nocommon)) __attribute__((section(".data_cygwin_nocopy1"))); \
- __var = __var##_storage.init (__name); \
-})
#endif /*_SYNC_H*/
diff --git a/winsup/cygwin/timer.cc b/winsup/cygwin/timer.cc
index 8815cdc63..a20e04b6e 100644
--- a/winsup/cygwin/timer.cc
+++ b/winsup/cygwin/timer.cc
@@ -43,22 +43,22 @@ timer_tracker NO_COPY ttstart (CLOCK_REALTIME, NULL);
class lock_timer_tracker
{
- static muto *protect;
+ static muto protect;
public:
lock_timer_tracker ();
~lock_timer_tracker ();
};
-muto NO_COPY *lock_timer_tracker::protect;
+muto NO_COPY lock_timer_tracker::protect;
lock_timer_tracker::lock_timer_tracker ()
{
- new_muto (protect)->acquire ();
+ protect.init ("timer_protect")->acquire ();
}
lock_timer_tracker::~lock_timer_tracker ()
{
- protect->release ();
+ protect.release ();
}
bool
diff --git a/winsup/cygwin/window.cc b/winsup/cygwin/window.cc
index 335ce3339..1d9b4af84 100644
--- a/winsup/cygwin/window.cc
+++ b/winsup/cygwin/window.cc
@@ -30,7 +30,7 @@ details. */
wininfo NO_COPY winmsg;
-muto NO_COPY *wininfo::_lock;
+muto NO_COPY wininfo::_lock;
int __stdcall
wininfo::process (HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
@@ -70,7 +70,7 @@ wininfo::winthread ()
WNDCLASS wc;
static NO_COPY char classname[] = "CygwinWndClass";
- _lock->grab ();
+ _lock.grab ();
/* Register the window class for the main window. */
wc.style = 0;
@@ -117,7 +117,7 @@ HWND ()
lock ();
if (!hwnd)
{
- _lock->upforgrabs ();
+ _lock.upforgrabs ();
cygthread *h = new cygthread (::winthread, this, "win");
h->SetThreadPriority (THREAD_PRIORITY_HIGHEST);
h->zap_h ();
@@ -130,11 +130,11 @@ HWND ()
void
wininfo::lock ()
{
- new_muto (_lock)->acquire ();
+ _lock.init ("wininfo_lock")->acquire ();
}
void
wininfo::release ()
{
- _lock->release ();
+ _lock.release ();
}
diff --git a/winsup/cygwin/wininfo.h b/winsup/cygwin/wininfo.h
index bde386561..0247ae917 100644
--- a/winsup/cygwin/wininfo.h
+++ b/winsup/cygwin/wininfo.h
@@ -12,7 +12,7 @@ class muto;
class wininfo
{
HWND hwnd;
- static muto *_lock;
+ static muto _lock;
public:
operator HWND ();
int __stdcall wininfo::process (HWND, UINT, WPARAM, LPARAM)