VirtualBox

Changeset 106020 in vbox for trunk/include


Ignore:
Timestamp:
Sep 12, 2024 9:23:00 AM (3 months ago)
Author:
vboxsync
Message:

IPRT: Added RTCritSectInitNamed and RTCritSectRwInitNamed to simplify naming critical sections w/o sabotaging automatic lock order validation.

Location:
trunk/include/iprt
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/iprt/critsect.h

    r98103 r106020  
    134134
    135135/**
     136 * Initialize a critical section with a simple name,
     137 */
     138RTDECL(int) RTCritSectInitNamed(PRTCRITSECT pCritSect, const char *pszName);
     139
     140/**
    136141 * Initialize a critical section.
    137142 *
     
    376381/* Strict lock order: Automatically classify locks by init location. */
    377382#if defined(RT_LOCK_STRICT_ORDER) && defined(IN_RING3) && !defined(RTCRITSECT_WITHOUT_REMAPPING) && !defined(RT_WITH_MANGLING)
     383# undef  RTCritSectInit
    378384# define RTCritSectInit(pCritSect) \
    379385    RTCritSectInitEx((pCritSect), 0 /*fFlags*/, \
    380386                     RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
    381387                     RTLOCKVAL_SUB_CLASS_NONE, NULL)
     388
     389# undef  RTCritSectInitNamed
     390# define RTCritSectInitNamed(a_pCritSect, a_pszName) \
     391    RTCritSectInitEx((a_pCritSect), 0 /*fFlags*/, \
     392                     RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
     393                     RTLOCKVAL_SUB_CLASS_NONE, "%s", a_pszName)
    382394#endif
    383395
     
    485497
    486498/**
    487  * Initialize a critical section.
     499 * Initialize a read/write critical section.
    488500 */
    489501RTDECL(int) RTCritSectRwInit(PRTCRITSECTRW pThis);
    490502
    491503/**
    492  * Initialize a critical section.
     504 * Initialize a read/write critical section with a simple name.
     505 */
     506RTDECL(int) RTCritSectRwInitNamed(PRTCRITSECTRW pThis, const char *pszName);
     507
     508/**
     509 * Initialize a read/write critical section.
    493510 *
    494511 * @returns IPRT status code.
     
    758775    RTCritSectRwInitEx((a_pThis), 0 /*fFlags*/, \
    759776                       RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
    760                         RTLOCKVAL_SUB_CLASS_NONE, NULL)
     777                       RTLOCKVAL_SUB_CLASS_NONE, NULL)
     778
     779# define RTCritSectRwInitNamed(a_pThis, a_pszName) \
     780    RTCritSectRwInitEx((a_pThis), 0 /*fFlags*/, \
     781                       RTLockValidatorClassForSrcPos(RT_SRC_POS, NULL), \
     782                       RTLOCKVAL_SUB_CLASS_NONE, "%s", a_pszName)
    761783#endif
    762784
  • trunk/include/iprt/mangling.h

    r105746 r106020  
    667667# define RTCritSectInit                                 RT_MANGLER(RTCritSectInit)
    668668# define RTCritSectInitEx                               RT_MANGLER(RTCritSectInitEx)
     669# define RTCritSectInitNamed                            RT_MANGLER(RTCritSectInitNamed)
    669670# define RTCritSectLeave                                RT_MANGLER(RTCritSectLeave)
    670671# define RTCritSectLeaveMultiple                        RT_MANGLER(RTCritSectLeaveMultiple)
     
    682683# define RTCritSectRwInit                               RT_MANGLER(RTCritSectRwInit)
    683684# define RTCritSectRwInitEx                             RT_MANGLER(RTCritSectRwInitEx)
     685# define RTCritSectRwInitNamed                          RT_MANGLER(RTCritSectRwInitNamed)
    684686# define RTCritSectRwIsReadOwner                        RT_MANGLER(RTCritSectRwIsReadOwner)
    685687# define RTCritSectRwIsWriteOwner                       RT_MANGLER(RTCritSectRwIsWriteOwner)
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