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

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

Issue 1449873003: Reland "Cleanup some numeric code."" (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Fix windows build 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 "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 33 matching lines...) Expand 10 before | Expand all | Expand 10 after
44 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly); 44 return FX_CreateFileStream(filename, FX_FILEMODE_ReadOnly);
45 } 45 }
46 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer, 46 IFX_MemoryStream* FX_CreateMemoryStream(uint8_t* pBuffer,
47 size_t dwSize, 47 size_t dwSize,
48 FX_BOOL bTakeOver) { 48 FX_BOOL bTakeOver) {
49 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver); 49 return new CFX_MemoryStream(pBuffer, dwSize, bTakeOver);
50 } 50 }
51 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) { 51 IFX_MemoryStream* FX_CreateMemoryStream(FX_BOOL bConsecutive) {
52 return new CFX_MemoryStream(bConsecutive); 52 return new CFX_MemoryStream(bConsecutive);
53 } 53 }
54 #ifdef __cplusplus 54
55 extern "C" {
56 #endif
57 FX_FLOAT FXSYS_tan(FX_FLOAT a) { 55 FX_FLOAT FXSYS_tan(FX_FLOAT a) {
58 return (FX_FLOAT)tan(a); 56 return (FX_FLOAT)tan(a);
59 } 57 }
60 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) { 58 FX_FLOAT FXSYS_logb(FX_FLOAT b, FX_FLOAT x) {
61 return FXSYS_log(x) / FXSYS_log(b); 59 return FXSYS_log(x) / FXSYS_log(b);
62 } 60 }
63 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr, 61 FX_FLOAT FXSYS_strtof(const FX_CHAR* pcsStr,
64 int32_t iLength, 62 int32_t iLength,
65 int32_t* pUsedLen) { 63 int32_t* pUsedLen) {
66 FXSYS_assert(pcsStr != NULL); 64 FXSYS_assert(pcsStr != NULL);
(...skipping 116 matching lines...) Expand 10 before | Expand all | Expand 10 after
183 while (pStr < pStrEnd) { 181 while (pStr < pStrEnd) {
184 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++); 182 dwHashCode = 1313 * dwHashCode + FXSYS_tolower(*pStr++);
185 } 183 }
186 } else { 184 } else {
187 while (pStr < pStrEnd) { 185 while (pStr < pStrEnd) {
188 dwHashCode = 1313 * dwHashCode + *pStr++; 186 dwHashCode = 1313 * dwHashCode + *pStr++;
189 } 187 }
190 } 188 }
191 return dwHashCode; 189 return dwHashCode;
192 } 190 }
193 #ifdef __cplusplus 191
194 }
195 #endif
196 #ifdef __cplusplus
197 extern "C" {
198 #endif
199 void* FX_Random_MT_Start(FX_DWORD dwSeed) { 192 void* FX_Random_MT_Start(FX_DWORD dwSeed) {
200 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1); 193 FX_LPMTRANDOMCONTEXT pContext = FX_Alloc(FX_MTRANDOMCONTEXT, 1);
201 pContext->mt[0] = dwSeed; 194 pContext->mt[0] = dwSeed;
202 FX_DWORD& i = pContext->mti; 195 FX_DWORD& i = pContext->mti;
203 FX_DWORD* pBuf = pContext->mt; 196 FX_DWORD* pBuf = pContext->mt;
204 for (i = 1; i < MT_N; i++) { 197 for (i = 1; i < MT_N; i++) {
205 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i); 198 pBuf[i] = (1812433253UL * (pBuf[i - 1] ^ (pBuf[i - 1] >> 30)) + i);
206 } 199 }
207 pContext->bHaveSeed = TRUE; 200 pContext->bHaveSeed = TRUE;
208 return pContext; 201 return pContext;
(...skipping 82 matching lines...) Expand 10 before | Expand all | Expand 10 after
291 return TRUE; 284 return TRUE;
292 } 285 }
293 #endif 286 #endif
294 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) { 287 void FX_Random_GenerateCrypto(FX_DWORD* pBuffer, int32_t iCount) {
295 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ 288 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
296 FX_GenerateCryptoRandom(pBuffer, iCount); 289 FX_GenerateCryptoRandom(pBuffer, iCount);
297 #else 290 #else
298 FX_Random_GenerateBase(pBuffer, iCount); 291 FX_Random_GenerateBase(pBuffer, iCount);
299 #endif 292 #endif
300 } 293 }
301 #ifdef __cplusplus
302 }
303 #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