VirtualBox

Changeset 102242 in vbox for trunk


Ignore:
Timestamp:
Nov 22, 2023 10:33:40 AM (15 months ago)
Author:
vboxsync
Message:

libs/xpcom: Move the remaining lock specific definitions to the only place using it, bugref:10545

Location:
trunk/src/libs/xpcom18a4/nsprpub/pr
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/libs/xpcom18a4/nsprpub/pr/include/private/primpl.h

    r102241 r102242  
    3939#define primpl_h___
    4040
    41 /*
    42  * HP-UX 10.10's pthread.h (DCE threads) includes dce/cma.h, which
    43  * has:
    44  *     #define sigaction _sigaction_sys
    45  * This macro causes chaos if signal.h gets included before pthread.h.
    46  * To be safe, we include pthread.h first.
    47  */
    48 
    49 #include <pthread.h>
    50 
    5141#include "nspr.h"
    52 
    5342#include "md/prosdep.h"
    5443
    55 PR_BEGIN_EXTERN_C
    56 
    57 typedef struct _MDLock _MDLock;
    58 typedef struct _MDCVar _MDCVar;
    59 
    60 typedef struct PRLock    PRLock;
    61 typedef struct PRCondVar PRCondVar;
    62 
    63 /*
    64 ** The following definitions are unique to implementing NSPR using pthreads.
    65 ** Since pthreads defines most of the thread and thread synchronization
    66 ** stuff, this is a pretty small set.
    67 */
    68 
    69 #define PT_CV_NOTIFIED_LENGTH 6
    70 typedef struct _PT_Notified _PT_Notified;
    71 struct _PT_Notified
    72 {
    73     PRIntn length;              /* # of used entries in this structure */
    74     struct
    75     {
    76         PRCondVar *cv;          /* the condition variable notified */
    77         PRIntn times;           /* and the number of times notified */
    78     } cv[PT_CV_NOTIFIED_LENGTH];
    79     _PT_Notified *link;         /* link to another of these | NULL */
    80 };
    81 
    82 /************************************************************************/
    83 /*************************************************************************
    84 ** The remainder of the definitions are shared by pthreads and the classic
    85 ** NSPR code. These too may be conditionalized.
    86 *************************************************************************/
    87 /************************************************************************/
    88 
    89 struct PRLock {
    90     pthread_mutex_t mutex;          /* the underlying lock */
    91     _PT_Notified notified;          /* array of conditions notified */
    92     PRBool locked;                  /* whether the mutex is locked */
    93     pthread_t owner;                /* if locked, current lock owner */
    94 };
    95 
    96 struct PRCondVar {
    97     PRLock *lock;               /* associated lock that protects the condition */
    98     pthread_cond_t cv;          /* underlying pthreads condition */
    99     volatile int32_t notify_pending;     /* CV has destroy pending notification */
    100 };
    101 
    102 /************************************************************************/
    103 
    104 struct PRMonitor {
    105     const char* name;           /* monitor name for debugging */
    106     PRLock lock;                /* the lock structure */
    107     pthread_t owner;            /* the owner of the lock or invalid */
    108     PRCondVar *cvar;            /* condition variable queue */
    109     PRUint32 entryCount;        /* # of times re-entered */
    110 };
    111 
    112 /************************************************************************/
    113 
    114 PR_END_EXTERN_C
    115 
    11644#endif /* primpl_h___ */
  • trunk/src/libs/xpcom18a4/nsprpub/pr/src/pthreads/ptsynch.c

    r102241 r102242  
    105105#endif
    106106
     107typedef struct PRLock    PRLock;
     108typedef struct PRCondVar PRCondVar;
     109
     110#define PT_CV_NOTIFIED_LENGTH 6
     111typedef struct _PT_Notified _PT_Notified;
     112struct _PT_Notified
     113{
     114    PRIntn length;              /* # of used entries in this structure */
     115    struct
     116    {
     117        PRCondVar *cv;          /* the condition variable notified */
     118        PRIntn times;           /* and the number of times notified */
     119    } cv[PT_CV_NOTIFIED_LENGTH];
     120    _PT_Notified *link;         /* link to another of these | NULL */
     121};
     122
     123struct PRLock {
     124    pthread_mutex_t mutex;          /* the underlying lock */
     125    _PT_Notified notified;          /* array of conditions notified */
     126    PRBool locked;                  /* whether the mutex is locked */
     127    pthread_t owner;                /* if locked, current lock owner */
     128};
     129
     130struct PRCondVar {
     131    PRLock *lock;               /* associated lock that protects the condition */
     132    pthread_cond_t cv;          /* underlying pthreads condition */
     133    volatile int32_t notify_pending;     /* CV has destroy pending notification */
     134};
     135
     136struct PRMonitor {
     137    const char* name;           /* monitor name for debugging */
     138    PRLock lock;                /* the lock structure */
     139    pthread_t owner;            /* the owner of the lock or invalid */
     140    PRCondVar *cvar;            /* condition variable queue */
     141    PRUint32 entryCount;        /* # of times re-entered */
     142};
     143
     144
    107145static pthread_mutexattr_t _pt_mattr;
    108146static pthread_condattr_t _pt_cvar_attr;
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette