4
0
mirror of git://sourceware.org/git/newlib-cygwin.git synced 2025-01-30 19:10:36 +08:00

minor cleanups

This commit is contained in:
Christopher Faylor 2001-09-12 04:47:47 +00:00
parent 8e4d969260
commit ff6e295ebf
2 changed files with 30 additions and 26 deletions

View File

@ -1,6 +1,7 @@
Wed Sep 12 13:03:00 2001 Robert Collins <rbtcollins@hotmail.com> Wed Sep 12 13:03:00 2001 Robert Collins <rbtcollins@hotmail.com>
* autoload.cc (LoadDLLfuncEx): Auto load TryEnterCriticalSection - its an NT only call. * autoload.cc (LoadDLLfuncEx): Auto load TryEnterCriticalSection - it's
an NT only call.
* thread.cc (pthread_cond::TimedWait): Use critical sections for NT. * thread.cc (pthread_cond::TimedWait): Use critical sections for NT.
(pthread_cond::fixup_after_fork): Don't detect bad apps. (pthread_cond::fixup_after_fork): Don't detect bad apps.
(pthread_mutex::pthread_mutex): Use critical sections for NT. (pthread_mutex::pthread_mutex): Use critical sections for NT.
@ -8,9 +9,11 @@ Wed Sep 12 13:03:00 2001 Robert Collins <rbtcollins@hotmail.com>
(pthread_mutex::Lock): Ditto. (pthread_mutex::Lock): Ditto.
(pthread_mutex::TryLock): Ditto. (pthread_mutex::TryLock): Ditto.
(pthread_mutex::UnLock): Ditto. (pthread_mutex::UnLock): Ditto.
(pthread_mutex::fixup_after_fork): Ditto. Also do not detect bad apps. (pthread_mutex::fixup_after_fork): Ditto. Also do not detect bad apps.
(__pthread_mutex_trylock): Move WIN32 specific test into the class method. (__pthread_mutex_trylock): Move WIN32 specific test into the class
(__pthread_mutex_destroy): Prevent dereferencing passed pointer without valid address. method.
(__pthread_mutex_destroy): Prevent dereferencing passed pointer without
valid address.
* thread.h (pthread_mutex): Use critical sections for NT. * thread.h (pthread_mutex): Use critical sections for NT.
Tue Sep 11 21:55:37 2001 Christopher Faylor <cgf@cygnus.com> Tue Sep 11 21:55:37 2001 Christopher Faylor <cgf@cygnus.com>
@ -77,11 +80,11 @@ Sun Sep 9 20:09:11 2001 Christopher Faylor <cgf@cygnus.com>
Mon Sep 10 08:28:00 2001 Robert Collins <rbtcollins@hotmail.com> Mon Sep 10 08:28:00 2001 Robert Collins <rbtcollins@hotmail.com>
* thread.h (MT_Interface): Remove pshared mutex array. * thread.h (MT_Interface): Remove pshared mutex array. Add a
Add a threadsafe list for mutex tracking (for fixup after fork). threadsafe list for mutex tracking (for fixup after fork).
* thread.cc (MTInterface::Init): Remove pshared mutex array. * thread.cc (MTInterface::Init): Remove pshared mutex array.
(pthread_mutex::pthread_mutex): Remove pshared mutex functionality. (pthread_mutex::pthread_mutex): Remove pshared mutex functionality.
Fail with EINVAL on attempts to use pshared functionality. Fail with EINVAL on attempts to use pshared functionality.
(__pthread_mutex_getpshared): Remove. (__pthread_mutex_getpshared): Remove.
(__pthread_cond_timedwait): Remove pshared mutex functionality. (__pthread_cond_timedwait): Remove pshared mutex functionality.
(__pthread_cond_wait): Ditto. (__pthread_cond_wait): Ditto.
@ -93,8 +96,8 @@ Mon Sep 10 08:28:00 2001 Robert Collins <rbtcollins@hotmail.com>
(__pthread_mutex_destroy): Ditto. (__pthread_mutex_destroy): Ditto.
(__pthread_mutex_setprioceiling): Ditto. (__pthread_mutex_setprioceiling): Ditto.
(__pthread_mutexattr_setpshared): Ditto. (__pthread_mutexattr_setpshared): Ditto.
Sun Sep 9 23:09:00 2001 Corinna Vinschen <corinna@vinschen.de> Sun Sep 9 23:09:00 2001 Corinna Vinschen <corinna@vinschen.de>
* pwdgrp.h (pwdgrp_check::set_last_modified): Call GetFileTime() * pwdgrp.h (pwdgrp_check::set_last_modified): Call GetFileTime()
instead of GetFileInformationByHandle(). instead of GetFileInformationByHandle().

View File

@ -3,6 +3,7 @@
Copyright 1998, 1999, 2000, 2001 Red Hat, Inc. Copyright 1998, 1999, 2000, 2001 Red Hat, Inc.
Originally written by Marco Fuykschot <marco@ddi.nl> Originally written by Marco Fuykschot <marco@ddi.nl>
Substantialy enhanced by Robert Collins <<rbtcollins@hotmail.com>
This file is part of Cygwin. This file is part of Cygwin.
@ -10,19 +11,19 @@ This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */ details. */
/*Implementation overview and caveats: /* Implementation overview and caveats:
Win32 puts some contraints on what can and cannot be implemented. Where possible Win32 puts some contraints on what can and cannot be implemented. Where
we work around those contrainsts. Where we cannot work around the constraints we possible we work around those contrainsts. Where we cannot work around
either pretend to be conformant, or return an error code. the constraints we either pretend to be conformant, or return an error
code.
Some caveats: PROCESS_SHARED objects while they pretend to be process shared, Some caveats: PROCESS_SHARED objects while they pretend to be process
may not actually work. Some test cases are needed to determine win32's behaviour. shared, may not actually work. Some test cases are needed to determine
My suspicion is that the win32 handle needs to be opened with different flags for win32's behaviour. My suspicion is that the win32 handle needs to be
proper operation. opened with different flags for proper operation.
R.Collins, April 2001. R.Collins, April 2001. */
*/
#ifdef HAVE_CONFIG_H #ifdef HAVE_CONFIG_H
# include "config.h" # include "config.h"
@ -449,7 +450,7 @@ pthread_cond::~pthread_cond ()
{ {
pthread_cond *tempcond = MT_INTERFACE->conds; pthread_cond *tempcond = MT_INTERFACE->conds;
while (tempcond->next && tempcond->next != this) while (tempcond->next && tempcond->next != this)
tempcond = tempcond->next; tempcond = tempcond->next;
/* but there may be a race between the loop above and this statement */ /* but there may be a race between the loop above and this statement */
InterlockedExchangePointer (&tempcond->next, this->next); InterlockedExchangePointer (&tempcond->next, this->next);
} }
@ -514,7 +515,7 @@ pthread_cond::TimedWait (DWORD dwMilliseconds)
* critical sections, which are faster, but introduce a race _here_. Until then * critical sections, which are faster, but introduce a race _here_. Until then
* The NT variant of the code is redundant. * The NT variant of the code is redundant.
*/ */
rv = SignalObjectAndWait (mutex->win32_obj_id, win32_obj_id, dwMilliseconds, rv = SignalObjectAndWait (mutex->win32_obj_id, win32_obj_id, dwMilliseconds,
false); false);
#endif #endif
@ -626,7 +627,7 @@ pthread_mutex::pthread_mutex (pthread_mutexattr *attr):verifyable_object (PTHREA
{ {
this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL); this->win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
if (!win32_obj_id) if (!win32_obj_id)
magic = 0; magic = 0;
} }
condwaits = 0; condwaits = 0;
pshared = PTHREAD_PROCESS_PRIVATE; pshared = PTHREAD_PROCESS_PRIVATE;
@ -641,7 +642,7 @@ pthread_mutex::~pthread_mutex ()
else else
{ {
if (win32_obj_id) if (win32_obj_id)
CloseHandle (win32_obj_id); CloseHandle (win32_obj_id);
win32_obj_id = NULL; win32_obj_id = NULL;
} }
/* I'm not 100% sure the next bit is threadsafe. I think it is... */ /* I'm not 100% sure the next bit is threadsafe. I think it is... */
@ -704,7 +705,7 @@ pthread_mutex::fixup_after_fork ()
{ {
win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL); win32_obj_id =::CreateMutex (&sec_none_nih, false, NULL);
if (!win32_obj_id) if (!win32_obj_id)
api_fatal("pthread_mutex::fixup_after_fork() failed to create new win32 mutex\n"); api_fatal("pthread_mutex::fixup_after_fork() failed to create new win32 mutex\n");
} }
#if DETECT_BAD_APPS #if DETECT_BAD_APPS
if (condwaits) if (condwaits)
@ -746,7 +747,7 @@ semaphore::~semaphore ()
{ {
semaphore *tempsem = MT_INTERFACE->semaphores; semaphore *tempsem = MT_INTERFACE->semaphores;
while (tempsem->next && tempsem->next != this) while (tempsem->next && tempsem->next != this)
tempsem = tempsem->next; tempsem = tempsem->next;
/* but there may be a race between the loop above and this statement */ /* but there may be a race between the loop above and this statement */
InterlockedExchangePointer (&tempsem->next, this->next); InterlockedExchangePointer (&tempsem->next, this->next);
} }