Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(82)

Side by Side Diff: core/src/fxcrt/fx_extension.cpp

Issue 1452673002: Merge to XFA: Reland "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@xfa
Patch Set: Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2014 PDFium Authors. All rights reserved. 1 // Copyright 2014 PDFium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com 5 // Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com
6 6
7 #include "core/include/fxcrt/fx_basic.h" 7 #include "core/include/fxcrt/fx_basic.h"
8 #include "core/include/fxcrt/fx_ext.h" 8 #include "core/include/fxcrt/fx_ext.h"
9 #include "extension.h" 9 #include "extension.h"
10 10
(...skipping 45 matching lines...) Expand 10 before | Expand all | Expand 10 after
56 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); 56 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
57 } 57 }
58 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, 58 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
59 size_t dwSize, 59 size_t dwSize,
60 FX_BOOL bTakeOver) { 60 FX_BOOL bTakeOver) {
61 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); 61 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
62 } 62 }
63 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { 63 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) {
64 return new CFX_MemoryStream(bConsecutive); 64 return new CFX_MemoryStream(bConsecutive);
65 } 65 }
66 #ifdef __cplusplus 66
67 extern "C" {
68 #endif
69 FX_FLOAT FXSYS_tan(FX_FLOAT a) { 67 FX_FLOAT FXSYS_tan(FX_FLOAT a) {
70 return (FX_FLOAT)tan(a); 68 return (FX_FLOAT)tan(a);
71 } 69 }
72 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { 70 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
73 return FXSYS_log(x) / FXSYS_log(b); 71 return FXSYS_log(x) / FXSYS_log(b);
74 } 72 }
75 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, 73 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
76 int32_t iLength, 74 int32_t iLength,
77 int32_t* pUsedLen) { 75 int32_t* pUsedLen) {
78 FXSYS_assert(pcsStr != NULL); 76 FXSYS_assert(pcsStr != NULL);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
195 while (pStr < pStrEnd) { 193 while (pStr < pStrEnd) {
196 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++); 194 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++);
197 } 195 }
198 } else { 196 } else {
199 while (pStr < pStrEnd) { 197 while (pStr < pStrEnd) {
200 dwHashCode = 1313 * dwHashCode + *pStr++; 198 dwHashCode = 1313 * dwHashCode + *pStr++;
201 } 199 }
202 } 200 }
203 return dwHashCode; 201 return dwHashCode;
204 } 202 }
205 #ifdef __cplusplus 203
206 }
207 #endif
208 #ifdef __cplusplus
209 extern "C" {
210 #endif
211 void* FX_Random_MT_Start(FX_DWORD dwSeed) { 204 void* FX_Random_MT_Start(FX_DWORD dwSeed) {
212 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); 205 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1);
213 pContext->mt[0] = dwSeed; 206 pContext->mt[0] = dwSeed;
214 FX_DWORD& i = pContext->mti; 207 FX_DWORD& i = pContext->mti;
215 FX_DWORD* pBuf = pContext->mt; 208 FX_DWORD* pBuf = pContext->mt;
216 for (i = 1; i < MT_N; i++) { 209 for (i = 1; i < MT_N; i++) {
217 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); 210 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i);
218 } 211 }
219 pContext->bHaveSeed = TRUE; 212 pContext->bHaveSeed = TRUE;
220 return pContext; 213 return pContext;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
303 return TRUE; 296 return TRUE;
304 } 297 }
305 #endif 298 #endif
306 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { 299 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) {
307 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 300 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
308 FX_GenerateCryptoRandom(pBuffer, iCount); 301 FX_GenerateCryptoRandom(pBuffer, iCount);
309 #else 302 #else
310 FX_Random_GenerateBase(pBuffer, iCount); 303 FX_Random_GenerateBase(pBuffer, iCount);
311 #endif 304 #endif
312 } 305 }
313 #ifdef __cplusplus 306
dsinclair 2015/11/16 17:44:48 Merge conflict.
314 }
315 #endif
316 #ifdef __cplusplus
317 extern "C" {
318 #endif
319 void FX_GUID_CreateV4(FX_LPGUID pGUID) { 307 void FX_GUID_CreateV4(FX_LPGUID pGUID) {
320 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \ 308 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || \
321 _FX_OS_ == _FX_WIN64_) 309 _FX_OS_ == _FX_WIN64_)
322 #ifdef _FX_WINAPI_PARTITION_DESKTOP_ 310 #ifdef _FX_WINAPI_PARTITION_DESKTOP_
323 if (!FX_GenerateCryptoRandom((FX_DWORD*)pGUID, 4)) { 311 if (!FX_GenerateCryptoRandom((FX_DWORD*)pGUID, 4)) {
324 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); 312 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4);
325 } 313 }
326 #else 314 #else
327 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4); 315 FX_Random_GenerateMT((FX_DWORD*)pGUID, 4);
328 #endif 316 #endif
(...skipping 12 matching lines...) Expand all
341 for (int32_t i = 0; i < 16; i++) { 329 for (int32_t i = 0; i < 16; i++) {
342 b = ((const uint8_t*)pGUID)[i]; 330 b = ((const uint8_t*)pGUID)[i];
343 *pBuf++ = gs_FX_pHexChars[b >> 4]; 331 *pBuf++ = gs_FX_pHexChars[b >> 4];
344 *pBuf++ = gs_FX_pHexChars[b & 0x0F]; 332 *pBuf++ = gs_FX_pHexChars[b & 0x0F];
345 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) { 333 if (bSeparator && (i == 3 || i == 5 || i == 7 || i == 9)) {
346 *pBuf++ = L'-'; 334 *pBuf++ = L'-';
347 } 335 }
348 } 336 }
349 bsStr.ReleaseBuffer(bSeparator ? 36 : 32); 337 bsStr.ReleaseBuffer(bSeparator ? 36 : 32);
350 } 338 }
351 #ifdef __cplusplus
dsinclair 2015/11/16 17:44:49 Merge conflict.
352 }
353 #endif
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698