Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (21 years ago)
Author:
bird
Message:

GCC v3.3.3 sources.

Location:
branches/GNU/src/gcc
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/GNU/src/gcc

    • Property svn:ignore
      •  

        old new  
        2626configure.vr
        2727configure.vrs
         28dir.info
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/win32-threads.cc

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    11// win32-threads.cc - interface between libjava and Win32 threads.
    22
    3 /* Copyright (C) 1998, 1999  Free Software Foundation, Inc.
     3/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
     4   Foundation, Inc.
    45
    56   This file is part of libgcj.
     
    7172ensure_condvar_initialized(_Jv_ConditionVariable_t *cv)
    7273{
    73   if (cv->ev[0] == 0) {
    74     cv->ev[0] = CreateEvent (NULL, 0, 0, NULL);
    75     if (cv->ev[0] == 0) JvFail("CreateEvent() failed");
    76     cv->ev[1] = CreateEvent (NULL, 1, 0, NULL);
    77     if (cv->ev[1] == 0) JvFail("CreateEvent() failed");
    78   }
     74  if (cv->ev[0] == 0)
     75    {
     76      cv->ev[0] = CreateEvent (NULL, 0, 0, NULL);
     77      if (cv->ev[0] == 0) JvFail("CreateEvent() failed");
     78
     79      cv->ev[1] = CreateEvent (NULL, 1, 0, NULL);
     80      if (cv->ev[1] == 0) JvFail("CreateEvent() failed");
     81    }
    7982}
    8083
     
    8689_Jv_CondWait(_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu, jlong millis, jint nanos)
    8790{
    88 
    89   EnterCriticalSection(&cv->count_mutex);
    90   ensure_condvar_initialized(cv);
     91  if (mu->owner != GetCurrentThreadId ( ))
     92    return _JV_NOT_OWNER;
     93
     94  EnterCriticalSection (&cv->count_mutex);
     95  ensure_condvar_initialized (cv);
    9196  cv->blocked_count++;
    92   LeaveCriticalSection(&cv->count_mutex);
     97  LeaveCriticalSection (&cv->count_mutex);
    9398
    9499  DWORD time;
     
    103108  EnterCriticalSection(&cv->count_mutex);
    104109  cv->blocked_count--;
    105   // If we were unblocked by the second event (the broadcast one) and nobody is
    106   // left, then reset the signal.
    107   int last_waiter = rval == WAIT_OBJECT_0 + 1 && cv->blocked_count == 0;
     110  // If we were unblocked by the second event (the broadcast one)
     111  // and nobody is left, then reset the event.
     112  int last_waiter = (rval == (WAIT_OBJECT_0 + 1)) && (cv->blocked_count == 0);
    108113  LeaveCriticalSection(&cv->count_mutex);
    109114
    110   if (last_waiter) ResetEvent(&cv->ev[1]);
     115  if (last_waiter)
     116    ResetEvent (cv->ev[1]);
    111117
    112118  _Jv_MutexLock (mu);
    113119
    114   if (rval == WAIT_FAILED) return GetLastError();
    115   else if (rval == WAIT_TIMEOUT) return ETIMEDOUT;
    116   else return 0;
     120  return 0;
    117121}
    118122
     
    122126  // we do lazy creation of Events since CreateEvent() is insanely expensive
    123127  cv->ev[0] = 0;
    124   InitializeCriticalSection(&cv->count_mutex);
     128  InitializeCriticalSection (&cv->count_mutex);
    125129  cv->blocked_count = 0;
    126130}
     
    129133_Jv_CondDestroy (_Jv_ConditionVariable_t *cv)
    130134{
    131   if (cv->ev[0] != 0) CloseHandle(cv->ev[0]);
    132   cv = NULL;
     135  if (cv->ev[0] != 0)
     136    {
     137      CloseHandle (cv->ev[0]);
     138      CloseHandle (cv->ev[1]);
     139
     140      cv->ev[0] = 0;
     141    }
     142
     143  DeleteCriticalSection (&cv->count_mutex);
    133144}
    134145
    135146int
    136 _Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
    137 {
    138   EnterCriticalSection(&cv->count_mutex);
    139   ensure_condvar_initialized(cv);
     147_Jv_CondNotify (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu)
     148{
     149  if (mu->owner != GetCurrentThreadId ( ))
     150    return _JV_NOT_OWNER;
     151
     152  EnterCriticalSection (&cv->count_mutex);
     153  ensure_condvar_initialized (cv);
    140154  int somebody_is_blocked = cv->blocked_count > 0;
    141   LeaveCriticalSection(&cv->count_mutex);
    142 
    143   if (somebody_is_blocked) return SetEvent (cv->ev[0]) ? 0 : GetLastError();
    144   else return 0;
     155  LeaveCriticalSection (&cv->count_mutex);
     156
     157  if (somebody_is_blocked)
     158    SetEvent (cv->ev[0]);
     159
     160  return 0;
    145161}
    146162
    147163int
    148 _Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *)
    149 {
    150   EnterCriticalSection(&cv->count_mutex);
    151   ensure_condvar_initialized(cv);
     164_Jv_CondNotifyAll (_Jv_ConditionVariable_t *cv, _Jv_Mutex_t *mu)
     165{
     166  if (mu->owner != GetCurrentThreadId ( ))
     167    return _JV_NOT_OWNER;
     168
     169  EnterCriticalSection (&cv->count_mutex);
     170  ensure_condvar_initialized (cv);
    152171  int somebody_is_blocked = cv->blocked_count > 0;
    153   LeaveCriticalSection(&cv->count_mutex);
    154 
    155   if (somebody_is_blocked) return SetEvent (cv->ev[1]) ? 0 : GetLastError();
    156   else return 0;
     172  LeaveCriticalSection (&cv->count_mutex);
     173
     174  if (somebody_is_blocked)
     175    SetEvent (cv->ev[1]);
     176
     177  return 0;
    157178}
    158179
     
    166187  _Jv_ThreadKey = TlsAlloc();
    167188  _Jv_ThreadDataKey = TlsAlloc();
    168   daemon_mutex = CreateMutex(NULL, 0, NULL);
    169   daemon_cond = CreateEvent(NULL, 0, 0, NULL);
     189  daemon_mutex = CreateMutex (NULL, 0, NULL);
     190  daemon_cond = CreateEvent (NULL, 1, 0, NULL);
    170191  non_daemon_count = 0;
    171192}
     
    256277      non_daemon_count--;
    257278      if (! non_daemon_count)
    258           PulseEvent (daemon_cond);
     279        SetEvent (daemon_cond);
    259280      ReleaseMutex (daemon_mutex);
    260281    }
     
    298319_Jv_ThreadWait (void)
    299320{
    300   WaitForSingleObject(daemon_mutex, INFINITE);
    301   if(non_daemon_count)
    302       SignalObjectAndWait(daemon_mutex, daemon_cond, INFINITE, 0);
    303   ReleaseMutex(daemon_mutex);
     321  WaitForSingleObject (daemon_mutex, INFINITE);
     322  if (non_daemon_count)
     323    {
     324      ReleaseMutex (daemon_mutex);
     325      WaitForSingleObject (daemon_cond, INFINITE);
     326    }
    304327}
    305328
Note: See TracChangeset for help on using the changeset viewer.