Changeset 34029 in vbox for trunk/include/iprt
- Timestamp:
- Nov 12, 2010 2:21:59 PM (14 years ago)
- svn:sync-xref-src-repo-rev:
- 67708
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/include/iprt/vfslowlevel.h
r34002 r34029 40 40 */ 41 41 42 43 /** @name VFS Lock Abstraction 44 * @todo This should be moved somewhere else as it is of general use. 45 * @{ */ 46 47 /** 48 * VFS lock types. 49 */ 50 typedef enum RTVFSLOCKTYPE 51 { 52 /** Invalid lock type. */ 53 RTVFSLOCKTYPE_INVALID = 0, 54 /** Read write semaphore. */ 55 RTVFSLOCKTYPE_RW, 56 /** Fast mutex semaphore (critical section in ring-3). */ 57 RTVFSLOCKTYPE_FASTMUTEX, 58 /** Full fledged mutex semaphore. */ 59 RTVFSLOCKTYPE_MUTEX, 60 /** The end of valid lock types. */ 61 RTVFSLOCKTYPE_END, 62 /** The customary 32-bit type hack. */ 63 RTVFSLOCKTYPE_32BIT_HACK = 0x7fffffff 64 } RTVFSLOCKTYPE; 65 66 /** VFS lock handle. */ 67 typedef struct RTVFSLOCKINTERNAL *RTVFSLOCK; 68 /** Pointer to a VFS lock handle. */ 69 typedef RTVFSLOCK *PRTVFSLOCK; 70 /** Nil VFS lock handle. */ 71 #define NIL_RTVFSLOCK ((RTVFSLOCK)~(uintptr_t)0) 72 73 /** Special handle value for creating a new read/write semaphore based lock. */ 74 #define RTVFSLOCK_CREATE_RW ((RTVFSLOCK)~(uintptr_t)1) 75 /** Special handle value for creating a new fast mutex semaphore based lock. */ 76 #define RTVFSLOCK_CREATE_FASTMUTEX ((RTVFSLOCK)~(uintptr_t)2) 77 /** Special handle value for creating a new mutex semaphore based lock. */ 78 #define RTVFSLOCK_CREATE_MUTEX ((RTVFSLOCK)~(uintptr_t)3) 79 80 /** 81 * Retains a reference to the VFS lock handle. 82 * 83 * @returns New reference count on success, UINT32_MAX on failure. 84 * @param hLock The VFS lock handle. 85 */ 86 RTDECL(uint32_t) RTVfsLockRetain(RTVFSLOCK hLock); 87 88 /** 89 * Releases a reference to the VFS lock handle. 90 * 91 * @returns New reference count on success (0 if closed), UINT32_MAX on failure. 92 * @param hLock The VFS lock handle. 93 */ 94 RTDECL(uint32_t) RTVfsLockRelease(RTVFSLOCK hLock); 95 96 /** 97 * Gets the lock type. 98 * 99 * @returns The lock type on success, RTVFSLOCKTYPE_INVALID if the handle is 100 * not valid. 101 * @param hLock The lock handle. 102 */ 103 RTDECL(RTVFSLOCKTYPE) RTVfsLockGetType(RTVFSLOCK hLock); 104 105 106 107 RTDECL(void) RTVfsLockAcquireReadSlow(RTVFSLOCK hLock); 108 RTDECL(void) RTVfsLockReleaseReadSlow(RTVFSLOCK hLock); 109 RTDECL(void) RTVfsLockAcquireWriteSlow(RTVFSLOCK hLock); 110 RTDECL(void) RTVfsLockReleaseWriteSlow(RTVFSLOCK hLock); 111 /** @} */ 112 113 /** 114 * Acquire a read lock. 115 * 116 * @param hLock The lock handle, can be NIL. 117 */ 118 DECLINLINE(void) RTVfsLockAcquireRead(RTVFSLOCK hLock) 119 { 120 if (hLock != NIL_RTVFSLOCK) 121 RTVfsLockAcquireReadSlow(hLock); 122 } 123 124 125 /** 126 * Release a read lock. 127 * 128 * @param hLock The lock handle, can be NIL. 129 */ 130 DECLINLINE(void) RTVfsLockReleaseRead(RTVFSLOCK hLock) 131 { 132 if (hLock != NIL_RTVFSLOCK) 133 RTVfsLockReleaseReadSlow(hLock); 134 } 135 136 137 /** 138 * Acquire a write lock. 139 * 140 * @param hLock The lock handle, can be NIL. 141 */ 142 DECLINLINE(void) RTVfsLockAcquireWrite(RTVFSLOCK hLock) 143 { 144 if (hLock != NIL_RTVFSLOCK) 145 RTVfsLockAcquireWriteSlow(hLock); 146 } 147 148 149 /** 150 * Release a write lock. 151 * 152 * @param hLock The lock handle, can be NIL. 153 */ 154 DECLINLINE(void) RTVfsLockReleaseWrite(RTVFSLOCK hLock) 155 { 156 if (hLock != NIL_RTVFSLOCK) 157 RTVfsLockReleaseWriteSlow(hLock); 158 } 159 160 /** @} */ 161 42 162 /** 43 163 * The VFS operations. … … 141 261 /** The RTVFSOBJOPS structure version. */ 142 262 #define RTVFSOBJOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x1f,1,0) 263 264 265 /** 266 * Creates a new VFS base object handle. 267 * 268 * @returns IPRT status code 269 * @param pObjOps The base object operations. 270 * @param cbInstance The size of the instance data. 271 * @param hVfs The VFS handle to associate this base object 272 * with. NIL_VFS is ok. 273 * @param hLock Handle to a custom lock to be used with the new 274 * object. The reference is consumed. NIL and 275 * special lock handles are fine. 276 * @param phVfsFss Where to return the new handle. 277 * @param ppvInstance Where to return the pointer to the instance data 278 * (size is @a cbInstance). 279 */ 280 RTDECL(int) RTVfsNewBaseObj(PCRTVFSOBJOPS pObjOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock, 281 PRTVFSOBJ phVfsObj, void **ppvInstance); 143 282 144 283 … … 255 394 * @param cbInstance The size of the instance data. 256 395 * @param hVfs The VFS handle to associate this filesystem 257 * steram with. NIL_VFS is ok. 258 * @param hSemRW The read-write semaphore to use to protect the 259 * handle if this differs from the one the VFS 260 * uses. NIL_RTSEMRW is ok if no locking is 261 * desired. 396 * stream with. NIL_VFS is ok. 397 * @param hLock Handle to a custom lock to be used with the new 398 * object. The reference is consumed. NIL and 399 * special lock handles are fine. 262 400 * @param phVfsFss Where to return the new handle. 263 401 * @param ppvInstance Where to return the pointer to the instance data 264 402 * (size is @a cbInstance). 265 403 */ 266 RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RT SEMRW hSemRW,404 RTDECL(int) RTVfsNewFsStream(PCRTVFSFSSTREAMOPS pFsStreamOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock, 267 405 PRTVFSFSSTREAM phVfsFss, void **ppvInstance); 268 406 … … 450 588 /** The RTVFSSYMLINKOPS structure version. */ 451 589 #define RTVFSSYMLINKOPS_VERSION RT_MAKE_U32_FROM_U8(0xff,0x5f,1,0) 590 591 592 /** 593 * Creates a new VFS symlink handle. 594 * 595 * @returns IPRT status code 596 * @param pSymlinkOps The symlink operations. 597 * @param cbInstance The size of the instance data. 598 * @param hVfs The VFS handle to associate this symlink object 599 * with. NIL_VFS is ok. 600 * @param hLock Handle to a custom lock to be used with the new 601 * object. The reference is consumed. NIL and 602 * special lock handles are fine. 603 * @param phVfsSym Where to return the new handle. 604 * @param ppvInstance Where to return the pointer to the instance data 605 * (size is @a cbInstance). 606 */ 607 RTDECL(int) RTVfsNewSymlink(PCRTVFSSYMLINKOPS pSymlinkOps, size_t cbInstance, RTVFS hVfs, RTVFSLOCK hLock, 608 PRTVFSSYMLINK phVfsSym, void **ppvInstance); 452 609 453 610 … … 576 733 * @param hVfs The VFS handle to associate this I/O stream 577 734 * with. NIL_VFS is ok. 578 * @param hSemRW The read-write semaphore to use to protect the 579 * handle if this differs from the one the VFS 580 * uses. NIL_RTSEMRW is ok if no locking is 581 * desired. 735 * @param hLock Handle to a custom lock to be used with the new 736 * object. The reference is consumed. NIL and 737 * special lock handles are fine. 582 738 * @param phVfsIos Where to return the new handle. 583 739 * @param ppvInstance Where to return the pointer to the instance data 584 740 * (size is @a cbInstance). 585 741 */ 586 RTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RT SEMRW hSemRW,742 RTDECL(int) RTVfsNewIoStream(PCRTVFSIOSTREAMOPS pIoStreamOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock, 587 743 PRTVFSIOSTREAM phVfsIos, void **ppvInstance); 588 744 … … 647 803 * @param hVfs The VFS handle to associate this file with. 648 804 * NIL_VFS is ok. 805 * @param hLock Handle to a custom lock to be used with the new 806 * object. The reference is consumed. NIL and 807 * special lock handles are fine. 649 808 * @param phVfsFile Where to return the new handle. 650 809 * @param ppvInstance Where to return the pointer to the instance data 651 810 * (size is @a cbInstance). 652 811 */ 653 RTDECL(int) RTVfsNewFile(PCRTVFSFILEOPS pFileOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, 812 RTDECL(int) RTVfsNewFile(PCRTVFSFILEOPS pFileOps, size_t cbInstance, uint32_t fOpen, RTVFS hVfs, RTVFSLOCK hLock, 654 813 PRTVFSFILE phVfsFile, void **ppvInstance); 655 814
Note:
See TracChangeset
for help on using the changeset viewer.