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

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

Issue 1431683008: Revert "Revert "Revert "Cleanup some numeric code.""" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
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
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | core/src/fxcrt/fx_extension_unittest.cpp » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
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 "../../include/fxcrt/fx_basic.h" 7 #include "../../include/fxcrt/fx_basic.h"
8 #include "../../include/fxcrt/fx_ext.h" 8 #include "../../include/fxcrt/fx_ext.h"
9 #include "extension.h" 9 #include "extension.h"
10
11 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 10 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
12 #include <wincrypt.h> 11 #include <wincrypt.h>
13 #else 12 #else
14 #include <ctime> 13 #include <ctime>
15 #endif 14 #endif
16 15
17 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) { 16 IFX_FileStream* FX_CreateFileStream(const FX_CHAR* filename, FX_DWORD dwModes) {
18 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create(); 17 IFXCRT_FileAccess* pFA = FXCRT_FileAccess_Create();
19 if (!pFA) { 18 if (!pFA) {
20 return NULL; 19 return NULL;
(...skipping 23 matching lines...) Expand all
44 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); 43 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
45 } 44 }
46 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, 45 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
47 size_t dwSize, 46 size_t dwSize,
48 FX_BOOL bTakeOver) { 47 FX_BOOL bTakeOver) {
49 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); 48 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
50 } 49 }
51 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { 50 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) {
52 return new CFX_MemoryStream(bConsecutive); 51 return new CFX_MemoryStream(bConsecutive);
53 } 52 }
54 53 #ifdef __cplusplus
54 extern "C" {
55 #endif
55 FX_FLOAT FXSYS_tan(FX_FLOAT a) { 56 FX_FLOAT FXSYS_tan(FX_FLOAT a) {
56 return (FX_FLOAT)tan(a); 57 return (FX_FLOAT)tan(a);
57 } 58 }
58 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { 59 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
59 return FXSYS_log(x) / FXSYS_log(b); 60 return FXSYS_log(x) / FXSYS_log(b);
60 } 61 }
61 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, 62 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
62 int32_t iLength, 63 int32_t iLength,
63 int32_t* pUsedLen) { 64 int32_t* pUsedLen) {
64 FXSYS_assert(pcsStr != NULL); 65 FXSYS_assert(pcsStr != NULL);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
181 while (pStr < pStrEnd) { 182 while (pStr < pStrEnd) {
182 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++); 183 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++);
183 } 184 }
184 } else { 185 } else {
185 while (pStr < pStrEnd) { 186 while (pStr < pStrEnd) {
186 dwHashCode = 1313 * dwHashCode + *pStr++; 187 dwHashCode = 1313 * dwHashCode + *pStr++;
187 } 188 }
188 } 189 }
189 return dwHashCode; 190 return dwHashCode;
190 } 191 }
191 192 #ifdef __cplusplus
193 }
194 #endif
195 #ifdef __cplusplus
196 extern "C" {
197 #endif
192 void* FX_Random_MT_Start(FX_DWORD dwSeed) { 198 void* FX_Random_MT_Start(FX_DWORD dwSeed) {
193 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); 199 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1);
194 pContext->mt[0] = dwSeed; 200 pContext->mt[0] = dwSeed;
195 FX_DWORD& i = pContext->mti; 201 FX_DWORD& i = pContext->mti;
196 FX_DWORD* pBuf = pContext->mt; 202 FX_DWORD* pBuf = pContext->mt;
197 for (i = 1; i < MT_N; i++) { 203 for (i = 1; i < MT_N; i++) {
198 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); 204 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i);
199 } 205 }
200 pContext->bHaveSeed = TRUE; 206 pContext->bHaveSeed = TRUE;
201 return pContext; 207 return pContext;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
284 return TRUE; 290 return TRUE;
285 } 291 }
286 #endif 292 #endif
287 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { 293 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) {
288 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 294 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
289 FX_GenerateCryptoRandom(pBuffer, iCount); 295 FX_GenerateCryptoRandom(pBuffer, iCount);
290 #else 296 #else
291 FX_Random_GenerateBase(pBuffer, iCount); 297 FX_Random_GenerateBase(pBuffer, iCount);
292 #endif 298 #endif
293 } 299 }
294 300 #ifdef __cplusplus
301 }
302 #endif
OLDNEW
« no previous file with comments | « core/src/fxcrt/fx_basic_wstring.cpp ('k') | core/src/fxcrt/fx_extension_unittest.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698