Ignore:
Timestamp:
Apr 27, 2004, 8:39:34 PM (22 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
         28
        2829Makefile
        29 dir.info
        3030lost+found
        3131update.out
  • branches/GNU/src/gcc/libjava/include/win32-threads.h

    • Property cvs2svn:cvs-rev changed from 1.1 to 1.1.1.2
    r1390 r1391  
    22// win32-threads.h - Defines for using Win32 threads.
    33
    4 /* Copyright (C) 1998, 1999, 2000  Free Software Foundation
     4/* Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software
     5   Foundation
    56
    67   This file is part of libgcj.
     
    1920//
    2021
    21 typedef struct _Jv_ConditionVariable_t {
     22typedef struct
     23{
     24  // ev[0] (signal) is a Win32 auto-reset event for _Jv_CondNotify
     25  // ev[1] (broadcast) is a Win32 manual-reset event for _Jv_CondNotifyAll
    2226  HANDLE ev[2];
     27
     28
     29
     30
     31
    2332  CRITICAL_SECTION count_mutex;
    24   int blocked_count;
    25 };
    2633
    27 typedef CRITICAL_SECTION _Jv_Mutex_t;
     34} _Jv_ConditionVariable_t;
     35
     36typedef struct
     37{
     38  // The thread-id of the owner thread if any, 0 otherwise
     39  DWORD owner;
     40
     41  // Track nested mutex acquisitions by the same thread
     42  int refcount;
     43
     44  // The actual Windows construct used to implement this mutex
     45  CRITICAL_SECTION cs;
     46
     47} _Jv_Mutex_t;
    2848
    2949typedef struct
     
    3353  java::lang::Thread *thread_obj;
    3454} _Jv_Thread_t;
     55
     56
     57
     58
     59
     60
     61
     62
    3563
    3664typedef void _Jv_ThreadStartFunc (java::lang::Thread *);
     
    5381inline void _Jv_MutexInit (_Jv_Mutex_t *mu)
    5482{
    55   InitializeCriticalSection(mu);
     83  mu->owner = 0UL;
     84  mu->refcount = 0;
     85  InitializeCriticalSection (&(mu->cs));
    5686}
    5787
     
    5989inline void _Jv_MutexDestroy (_Jv_Mutex_t *mu)
    6090{
    61   DeleteCriticalSection(mu);
     91  mu->owner = 0UL;
     92  mu->refcount = 0;
     93  DeleteCriticalSection (&(mu->cs));
    6294  mu = NULL;
    6395}
     
    6597inline int _Jv_MutexUnlock (_Jv_Mutex_t *mu)
    6698{
    67   LeaveCriticalSection(mu);
    68   return 0;
     99  if (mu->owner == GetCurrentThreadId ( ))
     100    {
     101      mu->refcount--;
     102      if (mu->refcount == 0)
     103        mu->owner = 0UL;
     104      LeaveCriticalSection (&(mu->cs));
     105      return 0;
     106    }
     107  else
     108    return 1;
    69109}
    70110
    71111inline int _Jv_MutexLock (_Jv_Mutex_t *mu)
    72112{
    73   EnterCriticalSection(mu);
     113  EnterCriticalSection (&(mu->cs));
     114  mu->owner = GetCurrentThreadId ( );
     115  mu->refcount++;
    74116  return 0;
    75117}
     
    97139inline void _Jv_ThreadYield (void)
    98140{
    99   // FIXME: win98 freezes hard (OS hang) when we use this --
    100   //        for now, we simply don't yield
    101   // Sleep (0);
     141  Sleep (0);
    102142}
    103143
Note: See TracChangeset for help on using the changeset viewer.