Changeset 207282 in webkit
- Timestamp:
- Oct 13, 2016 4:30:25 AM (7 years ago)
- Location:
- trunk/Source/WebCore
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebCore/ChangeLog
r207281 r207282 1 2016-10-12 Per Arne Vollan <pvollan@apple.com> 2 3 [Win] Encode function pointers. 4 https://bugs.webkit.org/show_bug.cgi?id=163331 5 6 Reviewed by Brent Fulgham. 7 8 We should encode stored function pointers. 9 10 * platform/win/SoftLinking.h: 11 1 12 2016-10-13 Youenn Fablet <youenn@apple.com> 2 13 -
trunk/Source/WebCore/platform/win/SoftLinking.h
r184799 r207282 45 45 46 46 #define SOFT_LINK(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \ 47 static resultType callingConvention init##functionName parameterDeclarations; \ 48 static resultType (callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \ 49 \ 50 static resultType callingConvention init##functionName parameterDeclarations \ 51 { \ 52 softLink##functionName = reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \ 53 ASSERT(softLink##functionName); \ 54 return softLink##functionName parameterNames; \ 55 } \ 47 static resultType(callingConvention*softLink##functionName) parameterDeclarations = nullptr; \ 56 48 \ 57 49 inline resultType functionName parameterDeclarations \ 58 50 { \ 59 return softLink##functionName parameterNames; \ 51 if (!softLink##functionName) \ 52 softLink##functionName = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \ 53 return reinterpret_cast<resultType (callingConvention*) parameterDeclarations>(::DecodePointer(softLink##functionName)) parameterNames; \ 60 54 } 61 55 … … 67 61 static bool initialized; \ 68 62 \ 69 if (initialized) \ 70 return ptr; \ 71 initialized = true; \ 72 \ 73 ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \ 74 return ptr; \ 63 if (!initialized) { \ 64 ptr = reinterpret_cast<functionName##PtrType>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \ 65 initialized = true; \ 66 } \ 67 return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \ 75 68 } \ 76 69 … … 82 75 static bool initialized; \ 83 76 \ 84 if (initialized) \ 85 return ptr; \ 86 initialized = true; \ 87 \ 88 static HINSTANCE libraryInstance = ::GetModuleHandle(L#library); \ 89 \ 90 ptr = reinterpret_cast<functionName##PtrType>(SOFT_LINK_GETPROCADDRESS(libraryInstance, #functionName)); \ 91 return ptr; \ 77 if (!initialized) { \ 78 static HINSTANCE libraryInstance = ::GetModuleHandle(L#library); \ 79 ptr = reinterpret_cast<functionName##PtrType>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(libraryInstance, #functionName))); \ 80 initialized = true; \ 81 } \ 82 \ 83 return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \ 92 84 } \ 93 85 … … 100 92 */ 101 93 #define SOFT_LINK_DLL_IMPORT(library, functionName, resultType, callingConvention, parameterDeclarations, parameterNames) \ 102 static resultType callingConvention init##functionName parameterDeclarations; \ 103 static resultType(callingConvention*softLink##functionName) parameterDeclarations = init##functionName; \ 104 \ 105 static resultType callingConvention init##functionName parameterDeclarations \ 106 { \ 107 softLink##functionName = reinterpret_cast<resultType (callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \ 108 ASSERT(softLink##functionName); \ 109 return softLink##functionName parameterNames; \ 110 } \ 94 static resultType(callingConvention*softLink##functionName) parameterDeclarations = nullptr; \ 111 95 \ 112 96 inline resultType softLink_##functionName parameterDeclarations \ 113 97 { \ 114 return softLink##functionName parameterNames; \ 98 if (!softLink##functionName) \ 99 softLink##functionName = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \ 100 return reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::DecodePointer(softLink##functionName)) parameterNames; \ 115 101 } 116 102 … … 122 108 static bool initialized; \ 123 109 \ 124 if (initialized) \ 125 return ptr; \ 126 initialized = true; \ 127 \ 128 ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \ 129 return ptr; \ 110 if (!initialized) { \ 111 ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \ 112 initialized = true; \ 113 } \ 114 return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \ 130 115 } \ 131 116 … … 137 122 static bool initialized; \ 138 123 \ 139 if (initialized) \ 140 return ptr; \ 141 initialized = true; \ 142 \ 143 ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName)); \ 144 return ptr; \ 124 if (!initialized) { \ 125 ptr = reinterpret_cast<resultType(callingConvention*)parameterDeclarations>(::EncodePointer(SOFT_LINK_GETPROCADDRESS(library##Library(), #functionName))); \ 126 initialized = true; \ 127 } \ 128 return reinterpret_cast<functionName##PtrType>(::DecodePointer(ptr)); \ 145 129 } \ 146 130
Note: See TracChangeset
for help on using the changeset viewer.