VirtualBox

Changeset 25704 in vbox for trunk/include


Ignore:
Timestamp:
Jan 10, 2010 8:12:30 PM (15 years ago)
Author:
vboxsync
svn:sync-xref-src-repo-rev:
56439
Message:

iprt,pdmcritsect: More flexible lock naming, added RTCritSectSetSubClass and made some RTCritSectInitEx.

Location:
trunk/include/iprt
Files:
3 edited

Legend:

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

    r25685 r25704  
    125125 *                              order inside the same class.  If you don't know,
    126126 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
    127  * @param   pszName             The lock name (optional).
     127 * @param   pszNameFmt          Name format string for the lock validator,
     128 *                              optional (NULL). Max length is 32 bytes.
     129 * @param   ...                 Format string arguments.
    128130 */
    129131RTDECL(int) RTCritSectInitEx(PRTCRITSECT pCritSect, uint32_t fFlags,
    130                              RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName);
     132                             RTLOCKVALCLASS hClass, uint32_t uSubClass, const char *pszName, ...);
     133
     134/**
     135 * Changes the lock validator sub-class of the critical section.
     136 *
     137 * It is recommended to try make sure that nobody is using this critical section
     138 * while changing the value.
     139 *
     140 * @returns The old sub-class.  RTLOCKVAL_SUB_CLASS_INVALID is returns if the
     141 *          lock validator isn't compiled in or either of the parameters are
     142 *          invalid.
     143 * @param   pCritSect           The critical section.
     144 * @param   uSubClass           The new sub-class value.
     145 */
     146RTDECL(uint32_t) RTCritSectSetSubClass(PRTCRITSECT pCritSect, uint32_t uSubClass);
    131147
    132148/**
  • trunk/include/iprt/lockvalidator.h

    r25703 r25704  
    153153    /** Pointer to the lock. */
    154154    RTHCPTR                             hLock;
    155     /** The lock name. */
    156     R3R0PTRTYPE(const char *)           pszName;
    157155    /** Pointer to the next sibling record.
    158156     * This is used to find the read side of a read-write lock.  */
    159157    R3R0PTRTYPE(PRTLOCKVALRECUNION)     pSibling;
     158    /** The lock name.
     159     * @remarks The bytes beyond 32 are for better size alignment and can be
     160     *          taken and used for other purposes if it becomes necessary. */
     161    char                                szName[32 + (HC_ARCH_BITS == 32 ? 12 : 8)];
    160162} RTLOCKVALRECEXCL;
    161 AssertCompileSize(RTLOCKVALRECEXCL, HC_ARCH_BITS == 32 ? 8 + 16 + 32 : 8 + 32 + 56);
     163AssertCompileSize(RTLOCKVALRECEXCL, HC_ARCH_BITS == 32 ? 0x60 : 0x80);
    162164/* The pointer type is defined in iprt/types.h. */
    163165
     
    208210    /** Pointer to the lock. */
    209211    RTHCPTR                             hLock;
    210     /** The lock name. */
    211     R3R0PTRTYPE(const char *)           pszName;
    212212    /** Pointer to the next sibling record.
    213213     * This is used to find the write side of a read-write lock.  */
     
    234234    /** Pointer to a table containing pointers to records of all the owners. */
    235235    R3R0PTRTYPE(PRTLOCKVALRECSHRDOWN volatile *) papOwners;
    236 #if HC_ARCH_BITS == 32
    237     /** Alignment padding. */
    238     uint32_t                            u32Alignment;
    239 #endif
     236
     237    /** The lock name.
     238     * @remarks The bytes beyond 32 are for better size alignment and can be
     239     *          taken and used for other purposes if it becomes necessary. */
     240    char                                szName[32 + (HC_ARCH_BITS == 32 ? 8 : 8)];
    240241} RTLOCKVALRECSHRD;
    241 AssertCompileSize(RTLOCKVALRECSHRD, HC_ARCH_BITS == 32 ? 24 + 20 + 4 : 40 + 24);
     242AssertCompileSize(RTLOCKVALRECSHRD, HC_ARCH_BITS == 32 ? 0x50 : 0x60);
    242243
    243244
     
    264265 *                              order inside the same class.  If you don't know,
    265266 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
    266  * @param   pszName             The lock name (optional).
    267267 * @param   hLock               The lock handle.
    268268 * @param   fEnabled            Pass @c false to explicitly disable lock
    269269 *                              validation, otherwise @c true.
     270 * @param   pszNameFmt          Name format string for the lock validator,
     271 *                              optional (NULL). Max length is 32 bytes.
     272 * @param   ...                 Format string arguments.
    270273 */
    271274RTDECL(void) RTLockValidatorRecExclInit(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    272                                         const char *pszName, void *hLock, bool fEnabled);
     275                                        void *hLock, bool fEnabled, const char *pszNameFmt, ...);
     276/**
     277 * Initialize a lock validator record.
     278 *
     279 * Use RTLockValidatorRecExclDelete to deinitialize it.
     280 *
     281 * @param   pRec                The record.
     282 * @param   hClass              The class (no reference consumed). If NIL, the
     283 *                              no lock order validation will be performed on
     284 *                              this lock.
     285 * @param   uSubClass           The sub-class.  This is used to define lock
     286 *                              order inside the same class.  If you don't know,
     287 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
     288 * @param   hLock               The lock handle.
     289 * @param   fEnabled            Pass @c false to explicitly disable lock
     290 *                              validation, otherwise @c true.
     291 * @param   pszNameFmt          Name format string for the lock validator,
     292 *                              optional (NULL). Max length is 32 bytes.
     293 * @param   va                  Format string arguments.
     294 */
     295RTDECL(void) RTLockValidatorRecExclInitV(PRTLOCKVALRECEXCL pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     296                                         void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
    273297/**
    274298 * Uninitialize a lock validator record previously initialized by
     
    293317 *                              order inside the same class.  If you don't know,
    294318 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
    295  * @param   pszName             The lock name (optional).
    296319 * @param   hLock               The lock handle.
    297320 * @param   fEnabled            Pass @c false to explicitly disable lock
    298321 *                              validation, otherwise @c true.
     322 * @param   pszNameFmt          Name format string for the lock validator,
     323 *                              optional (NULL). Max length is 32 bytes.
     324 * @param   ...                 Format string arguments.
    299325 */
    300326RTDECL(int)  RTLockValidatorRecExclCreate(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    301                                           const char *pszName, void *hLock, bool fEnabled);
     327                                          void *hLock, bool fEnabled, const char *pszNameFmt, ...);
     328
     329/**
     330 * Create and initialize a lock validator record.
     331 *
     332 * Use RTLockValidatorRecExclDestroy to deinitialize and destroy the returned
     333 * record.
     334 *
     335 * @return VINF_SUCCESS or VERR_NO_MEMORY.
     336 * @param   ppRec               Where to return the record pointer.
     337 * @param   hClass              The class (no reference consumed). If NIL, the
     338 *                              no lock order validation will be performed on
     339 *                              this lock.
     340 * @param   uSubClass           The sub-class.  This is used to define lock
     341 *                              order inside the same class.  If you don't know,
     342 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
     343 * @param   hLock               The lock handle.
     344 * @param   fEnabled            Pass @c false to explicitly disable lock
     345 *                              validation, otherwise @c true.
     346 * @param   pszNameFmt          Name format string for the lock validator,
     347 *                              optional (NULL). Max length is 32 bytes.
     348 * @param   va                  Format string arguments.
     349 */
     350RTDECL(int)  RTLockValidatorRecExclCreateV(PRTLOCKVALRECEXCL *ppRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     351                                           void *hLock, bool fEnabled, const char *pszNameFmt, va_list va);
    302352
    303353/**
     
    308358 */
    309359RTDECL(void) RTLockValidatorRecExclDestroy(PRTLOCKVALRECEXCL *ppRec);
     360
     361/**
     362 * Sets the sub-class of the record.
     363 *
     364 * It is recommended to try make sure that nobody is using this class while
     365 * changing the value.
     366 *
     367 * @returns The old sub-class.  RTLOCKVAL_SUB_CLASS_INVALID is returns if the
     368 *          lock validator isn't compiled in or either of the parameters are
     369 *          invalid.
     370 * @param   pRec                The validator record.
     371 * @param   uSubClass           The new sub-class value.
     372 */
     373RTDECL(uint32_t) RTLockValidatorRecExclSetSubClass(PRTLOCKVALRECEXCL pRec, uint32_t uSubClass);
    310374
    311375/**
     
    497561 *                              order inside the same class.  If you don't know,
    498562 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
    499  * @param   pszName             The lock name (optional).
    500563 * @param   hLock               The lock handle.
    501564 * @param   fSignaller          Set if event semaphore signaller logic should be
     
    504567 * @param   fEnabled            Pass @c false to explicitly disable lock
    505568 *                              validation, otherwise @c true.
     569 * @param   pszNameFmt          Name format string for the lock validator,
     570 *                              optional (NULL). Max length is 32 bytes.
     571 * @param   ...                 Format string arguments.
    506572 */
    507573RTDECL(void) RTLockValidatorRecSharedInit(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
    508                                           const char *pszName, void *hLock, bool fSignaller, bool fEnabled);
     574                                          void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, ...);
     575/**
     576 * Initialize a lock validator record for a shared lock.
     577 *
     578 * Use RTLockValidatorRecSharedDelete to deinitialize it.
     579 *
     580 * @param   pRec                The shared lock record.
     581 * @param   hClass              The class (no reference consumed). If NIL, the
     582 *                              no lock order validation will be performed on
     583 *                              this lock.
     584 * @param   uSubClass           The sub-class.  This is used to define lock
     585 *                              order inside the same class.  If you don't know,
     586 *                              then pass RTLOCKVAL_SUB_CLASS_NONE.
     587 * @param   hLock               The lock handle.
     588 * @param   fSignaller          Set if event semaphore signaller logic should be
     589 *                              applied to this record, clear if read-write
     590 *                              semaphore logic should be used.
     591 * @param   fEnabled            Pass @c false to explicitly disable lock
     592 *                              validation, otherwise @c true.
     593 * @param   pszNameFmt          Name format string for the lock validator,
     594 *                              optional (NULL). Max length is 32 bytes.
     595 * @param   va                  Format string arguments.
     596 */
     597RTDECL(void) RTLockValidatorRecSharedInitV(PRTLOCKVALRECSHRD pRec, RTLOCKVALCLASS hClass, uint32_t uSubClass,
     598                                           void *hLock, bool fSignaller, bool fEnabled, const char *pszNameFmt, va_list va);
    509599/**
    510600 * Uninitialize a lock validator record previously initialized by
     
    790880 * @param   iLine               The source position of the call, line.
    791881 * @param   pszFunction         The source position of the call, function.
    792  */
    793 RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL);
     882 * @param   pszNameFmt          Class name format string, optional (NULL).  Max
     883 *                              length is 32 bytes.
     884 * @param   ...                 Format string arguments.
     885 */
     886RTDECL(int) RTLockValidatorClassCreate(PRTLOCKVALCLASS phClass, bool fAutodidact, RT_SRC_POS_DECL, const char *pszNameFmt, ...);
    794887
    795888/**
  • trunk/include/iprt/types.h

    r25692 r25704  
    15001500 * taking in ascending order.
    15011501 * @{ */
     1502/** Invalid value.  */
     1503#define RTLOCKVAL_SUB_CLASS_INVALID     UINT32_C(0)
    15021504/** Not allowed to be taken with any other locks in the same class.
    15031505  * This is the recommended value.  */
    1504 #define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(0)
     1506#define RTLOCKVAL_SUB_CLASS_NONE        UINT32_C(1)
    15051507/** Any order is allowed within the class. */
    1506 #define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(1)
     1508#define RTLOCKVAL_SUB_CLASS_ANY         UINT32_C(2)
    15071509/** The first user value. */
    15081510#define RTLOCKVAL_SUB_CLASS_USER        UINT32_C(16)
Note: See TracChangeset for help on using the changeset viewer.

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