Changeset 25908 in vbox for trunk/src/VBox/Runtime/generic
- Timestamp:
- Jan 18, 2010 10:07:28 PM (15 years ago)
- svn:sync-xref-src-repo-rev:
- 56726
- Location:
- trunk/src/VBox/Runtime/generic
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Runtime/generic/RTFileReadAll-generic.cpp
r21337 r25908 39 39 RTDECL(int) RTFileReadAll(const char *pszFilename, void **ppvFile, size_t *pcbFile) 40 40 { 41 return RTFileReadAllEx(pszFilename, 0, RTFOFF_MAX, 0, ppvFile, pcbFile);41 return RTFileReadAllEx(pszFilename, 0, RTFOFF_MAX, RTFILE_RDALL_O_DENY_WRITE, ppvFile, pcbFile); 42 42 } 43 43 RT_EXPORT_SYMBOL(RTFileReadAll); -
trunk/src/VBox/Runtime/generic/semrw-generic.cpp
r25831 r25908 869 869 RTDECL(bool) RTSemRWIsWriteOwner(RTSEMRW hRWSem) 870 870 { 871 /* 872 * Validate handle. 873 */ 871 874 struct RTSEMRWINTERNAL *pThis = hRWSem; 872 873 /*874 * Validate handle.875 */876 875 AssertPtrReturn(pThis, false); 877 876 AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false); … … 886 885 } 887 886 RT_EXPORT_SYMBOL(RTSemRWIsWriteOwner); 887 888 889 RTDECL(bool) RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear) 890 { 891 /* 892 * Validate handle. 893 */ 894 struct RTSEMRWINTERNAL *pThis = hRWSem; 895 AssertPtrReturn(pThis, false); 896 AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false); 897 898 /* 899 * Check write ownership. The writer is also a valid reader. 900 */ 901 RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf(); 902 RTNATIVETHREAD hWriter; 903 ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter); 904 if (hWriter == hNativeSelf) 905 return true; 906 if (hWriter != NIL_RTNATIVETHREAD) 907 return false; 908 909 #ifdef RTSEMRW_STRICT 910 /* 911 * Ask the lock validator. 912 */ 913 return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD); 914 #else 915 /* 916 * If there are no reads we cannot be one of them... But if there are we 917 * cannot know and can only return what the caller want to hear. 918 */ 919 if (pThis->cReads == 0) 920 return false; 921 return fWannaHear; 922 #endif 923 } 924 RT_EXPORT_SYMBOL(RTSemRWIsReadOwner); 888 925 889 926 -
trunk/src/VBox/Runtime/generic/semrw-lockless-generic.cpp
r25831 r25908 876 876 877 877 878 RTDECL(bool) RTSemRWIsReadOwner(RTSEMRW hRWSem, bool fWannaHear) 879 { 880 /* 881 * Validate handle. 882 */ 883 struct RTSEMRWINTERNAL *pThis = hRWSem; 884 AssertPtrReturn(pThis, false); 885 AssertReturn(pThis->u32Magic == RTSEMRW_MAGIC, false); 886 887 /* 888 * Inspect the state. 889 */ 890 uint64_t u64State = ASMAtomicReadU64(&pThis->u64State); 891 if ((u64State & RTSEMRW_DIR_MASK) == (RTSEMRW_DIR_WRITE << RTSEMRW_DIR_SHIFT)) 892 { 893 /* 894 * It's in write mode, so we can only be a reader if we're also the 895 * current writer. 896 */ 897 RTNATIVETHREAD hNativeSelf = RTThreadNativeSelf(); 898 RTNATIVETHREAD hWriter; 899 ASMAtomicUoReadHandle(&pThis->hWriter, &hWriter); 900 return hWriter == hNativeSelf; 901 } 902 903 /* 904 * Read mode. If there are no current readers, then we cannot be a reader. 905 */ 906 if (!(u64State & RTSEMRW_CNT_RD_MASK)) 907 return false; 908 909 #ifdef RTSEMRW_STRICT 910 /* 911 * Ask the lock validator. 912 */ 913 return RTLockValidatorRecSharedIsOwner(&pThis->ValidatorRead, NIL_RTTHREAD); 914 #else 915 /* 916 * Ok, we don't know, just tell the caller what he want to hear. 917 */ 918 return fWannaHear; 919 #endif 920 } 921 RT_EXPORT_SYMBOL(RTSemRWIsReadOwner); 922 923 878 924 RTDECL(uint32_t) RTSemRWGetWriteRecursion(RTSEMRW hRWSem) 879 925 {
Note:
See TracChangeset
for help on using the changeset viewer.