OLD | NEW |
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 #ifndef CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 7 #ifndef CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
8 #define CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 8 #define CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
9 | 9 |
10 #include <assert.h> | 10 #include <assert.h> |
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
61 | 61 |
62 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 62 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
63 #include <Carbon/Carbon.h> | 63 #include <Carbon/Carbon.h> |
64 #include <libkern/OSAtomic.h> | 64 #include <libkern/OSAtomic.h> |
65 #endif | 65 #endif |
66 | 66 |
67 #ifdef __cplusplus | 67 #ifdef __cplusplus |
68 extern "C" { | 68 extern "C" { |
69 #endif | 69 #endif |
70 typedef void* FX_POSITION; // Keep until fxcrt containers gone | 70 typedef void* FX_POSITION; // Keep until fxcrt containers gone |
71 typedef uint32_t FX_DWORD; // Keep - "an efficient type" | |
72 typedef float FX_FLOAT; // Keep, allow upgrade to doubles. | 71 typedef float FX_FLOAT; // Keep, allow upgrade to doubles. |
73 typedef double FX_DOUBLE; // Keep, allow downgrade to floats. | 72 typedef double FX_DOUBLE; // Keep, allow downgrade to floats. |
74 typedef int FX_BOOL; // Keep, sadly not always 0 or 1. | 73 typedef int FX_BOOL; // Keep, sadly not always 0 or 1. |
75 typedef char FX_CHAR; // Keep, questionable signedness. | 74 typedef char FX_CHAR; // Keep, questionable signedness. |
76 typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. | 75 typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. |
77 | 76 |
78 // PDFium string sizes are limited to 2^31-1, and the value is signed to | 77 // PDFium string sizes are limited to 2^31-1, and the value is signed to |
79 // allow -1 as a placeholder for "unknown". | 78 // allow -1 as a placeholder for "unknown". |
80 // TODO(palmer): it should be a |size_t|, or at least unsigned. | 79 // TODO(palmer): it should be a |size_t|, or at least unsigned. |
81 typedef int FX_STRSIZE; | 80 typedef int FX_STRSIZE; |
(...skipping 120 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
202 #define FXSYS_WideCharToMultiByte WideCharToMultiByte | 201 #define FXSYS_WideCharToMultiByte WideCharToMultiByte |
203 #define FXSYS_MultiByteToWideChar MultiByteToWideChar | 202 #define FXSYS_MultiByteToWideChar MultiByteToWideChar |
204 #define FXSYS_wcslwr _wcslwr | 203 #define FXSYS_wcslwr _wcslwr |
205 #define FXSYS_wcsupr _wcsupr | 204 #define FXSYS_wcsupr _wcsupr |
206 #endif | 205 #endif |
207 #define FXSYS_GetFullPathName GetFullPathName | 206 #define FXSYS_GetFullPathName GetFullPathName |
208 #define FXSYS_GetModuleFileName GetModuleFileName | 207 #define FXSYS_GetModuleFileName GetModuleFileName |
209 #else | 208 #else |
210 int FXSYS_GetACP(void); | 209 int FXSYS_GetACP(void); |
211 char* FXSYS_itoa(int value, char* str, int radix); | 210 char* FXSYS_itoa(int value, char* str, int radix); |
212 int FXSYS_WideCharToMultiByte(FX_DWORD codepage, | 211 int FXSYS_WideCharToMultiByte(uint32_t codepage, |
213 FX_DWORD dwFlags, | 212 uint32_t dwFlags, |
214 const wchar_t* wstr, | 213 const wchar_t* wstr, |
215 int wlen, | 214 int wlen, |
216 char* buf, | 215 char* buf, |
217 int buflen, | 216 int buflen, |
218 const char* default_str, | 217 const char* default_str, |
219 int* pUseDefault); | 218 int* pUseDefault); |
220 int FXSYS_MultiByteToWideChar(FX_DWORD codepage, | 219 int FXSYS_MultiByteToWideChar(uint32_t codepage, |
221 FX_DWORD dwFlags, | 220 uint32_t dwFlags, |
222 const char* bstr, | 221 const char* bstr, |
223 int blen, | 222 int blen, |
224 wchar_t* buf, | 223 wchar_t* buf, |
225 int buflen); | 224 int buflen); |
226 FX_DWORD FXSYS_GetFullPathName(const char* filename, | 225 uint32_t FXSYS_GetFullPathName(const char* filename, |
227 FX_DWORD buflen, | 226 uint32_t buflen, |
228 char* buf, | 227 char* buf, |
229 char** filepart); | 228 char** filepart); |
230 FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize); | 229 uint32_t FXSYS_GetModuleFileName(void* hModule, char* buf, uint32_t bufsize); |
231 char* FXSYS_strlwr(char* str); | 230 char* FXSYS_strlwr(char* str); |
232 char* FXSYS_strupr(char* str); | 231 char* FXSYS_strupr(char* str); |
233 int FXSYS_stricmp(const char*, const char*); | 232 int FXSYS_stricmp(const char*, const char*); |
234 int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2); | 233 int FXSYS_wcsicmp(const wchar_t* str1, const wchar_t* str2); |
235 wchar_t* FXSYS_wcslwr(wchar_t* str); | 234 wchar_t* FXSYS_wcslwr(wchar_t* str); |
236 wchar_t* FXSYS_wcsupr(wchar_t* str); | 235 wchar_t* FXSYS_wcsupr(wchar_t* str); |
237 #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ | 236 #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ |
238 | 237 |
239 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 238 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
240 #define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b) | 239 #define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b) |
241 #else | 240 #else |
242 #define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b) | 241 #define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b) |
243 #endif | 242 #endif |
244 #define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a) | 243 #define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a) |
245 #define FXSYS_fabs(a) (FX_FLOAT) fabs(a) | 244 #define FXSYS_fabs(a) (FX_FLOAT) fabs(a) |
246 #define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b) | 245 #define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b) |
247 #define FXSYS_ceil(a) (FX_FLOAT) ceil(a) | 246 #define FXSYS_ceil(a) (FX_FLOAT) ceil(a) |
248 #define FXSYS_floor(a) (FX_FLOAT) floor(a) | 247 #define FXSYS_floor(a) (FX_FLOAT) floor(a) |
249 #define FXSYS_cos(a) (FX_FLOAT) cos(a) | 248 #define FXSYS_cos(a) (FX_FLOAT) cos(a) |
250 #define FXSYS_acos(a) (FX_FLOAT) acos(a) | 249 #define FXSYS_acos(a) (FX_FLOAT) acos(a) |
251 #define FXSYS_sin(a) (FX_FLOAT) sin(a) | 250 #define FXSYS_sin(a) (FX_FLOAT) sin(a) |
252 #define FXSYS_log(a) (FX_FLOAT) log(a) | 251 #define FXSYS_log(a) (FX_FLOAT) log(a) |
253 #define FXSYS_log10(a) (FX_FLOAT) log10(a) | 252 #define FXSYS_log10(a) (FX_FLOAT) log10(a) |
254 #define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b) | 253 #define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b) |
255 #define FXSYS_abs abs | 254 #define FXSYS_abs abs |
256 #define FXDWORD_GET_LSBFIRST(p) \ | 255 #define FXDWORD_GET_LSBFIRST(p) \ |
257 ((static_cast<FX_DWORD>(p[3]) << 24) | (static_cast<FX_DWORD>(p[2]) << 16) | \ | 256 ((static_cast<uint32_t>(p[3]) << 24) | (static_cast<uint32_t>(p[2]) << 16) | \ |
258 (static_cast<FX_DWORD>(p[1]) << 8) | (static_cast<FX_DWORD>(p[0]))) | 257 (static_cast<uint32_t>(p[1]) << 8) | (static_cast<uint32_t>(p[0]))) |
259 #define FXDWORD_GET_MSBFIRST(p) \ | 258 #define FXDWORD_GET_MSBFIRST(p) \ |
260 ((static_cast<FX_DWORD>(p[0]) << 24) | (static_cast<FX_DWORD>(p[1]) << 16) | \ | 259 ((static_cast<uint32_t>(p[0]) << 24) | (static_cast<uint32_t>(p[1]) << 16) | \ |
261 (static_cast<FX_DWORD>(p[2]) << 8) | (static_cast<FX_DWORD>(p[3]))) | 260 (static_cast<uint32_t>(p[2]) << 8) | (static_cast<uint32_t>(p[3]))) |
262 #define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8)) | 261 #define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8)) |
263 #define FXSYS_LOBYTE(word) ((uint8_t)(word)) | 262 #define FXSYS_LOBYTE(word) ((uint8_t)(word)) |
264 #define FXSYS_HIWORD(dword) ((uint16_t)((dword) >> 16)) | 263 #define FXSYS_HIWORD(dword) ((uint16_t)((dword) >> 16)) |
265 #define FXSYS_LOWORD(dword) ((uint16_t)(dword)) | 264 #define FXSYS_LOWORD(dword) ((uint16_t)(dword)) |
266 int32_t FXSYS_atoi(const FX_CHAR* str); | 265 int32_t FXSYS_atoi(const FX_CHAR* str); |
267 uint32_t FXSYS_atoui(const FX_CHAR* str); | 266 uint32_t FXSYS_atoui(const FX_CHAR* str); |
268 int32_t FXSYS_wtoi(const FX_WCHAR* str); | 267 int32_t FXSYS_wtoi(const FX_WCHAR* str); |
269 int64_t FXSYS_atoi64(const FX_CHAR* str); | 268 int64_t FXSYS_atoi64(const FX_CHAR* str); |
270 int64_t FXSYS_wtoi64(const FX_WCHAR* str); | 269 int64_t FXSYS_wtoi64(const FX_WCHAR* str); |
271 const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); | 270 const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); |
(...skipping 35 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
307 | 306 |
308 // Prevent a function from ever being inlined, typically because we'd | 307 // Prevent a function from ever being inlined, typically because we'd |
309 // like it to appear in stack traces. | 308 // like it to appear in stack traces. |
310 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 309 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
311 #define NEVER_INLINE __declspec(noinline) | 310 #define NEVER_INLINE __declspec(noinline) |
312 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 311 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
313 #define NEVER_INLINE __attribute__((__noinline__)) | 312 #define NEVER_INLINE __attribute__((__noinline__)) |
314 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 313 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
315 | 314 |
316 #endif // CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ | 315 #endif // CORE_FXCRT_INCLUDE_FX_SYSTEM_H_ |
OLD | NEW |