Index: core/include/fxcrt/fx_system.h |
diff --git a/core/include/fxcrt/fx_system.h b/core/include/fxcrt/fx_system.h |
index 6d659e2c10804ee75a5f528f71f63c897450b8e4..7a181439f9a95da257a129101d508442aa6db032 100644 |
--- a/core/include/fxcrt/fx_system.h |
+++ b/core/include/fxcrt/fx_system.h |
@@ -1,19 +1,19 @@ |
// Copyright 2014 PDFium Authors. All rights reserved. |
// Use of this source code is governed by a BSD-style license that can be |
// found in the LICENSE file. |
- |
+ |
// Original code copyright 2014 Foxit Software Inc. http://www.foxitsoftware.com |
#ifndef _FX_SYSTEM_H_ |
#define _FX_SYSTEM_H_ |
-#define _FX_WIN32_DESKTOP_ 1 |
-#define _FX_LINUX_DESKTOP_ 4 |
-#define _FX_MACOSX_ 7 |
-#define _FX_ANDROID_ 12 |
-#define _FXM_PLATFORM_WINDOWS_ 1 |
-#define _FXM_PLATFORM_LINUX_ 2 |
-#define _FXM_PLATFORM_APPLE_ 3 |
-#define _FXM_PLATFORM_ANDROID_ 4 |
+#define _FX_WIN32_DESKTOP_ 1 |
+#define _FX_LINUX_DESKTOP_ 4 |
+#define _FX_MACOSX_ 7 |
+#define _FX_ANDROID_ 12 |
+#define _FXM_PLATFORM_WINDOWS_ 1 |
+#define _FXM_PLATFORM_LINUX_ 2 |
+#define _FXM_PLATFORM_APPLE_ 3 |
+#define _FXM_PLATFORM_ANDROID_ 4 |
#ifndef _FX_OS_ |
#if defined(__ANDROID__) |
#define _FX_OS_ _FX_ANDROID_ |
@@ -36,13 +36,16 @@ |
#define _CRT_SECURE_NO_WARNINGS |
#include <windows.h> |
#endif |
-#define _FX_W32_ 1 |
-#define _FX_W64_ 2 |
+#define _FX_W32_ 1 |
+#define _FX_W64_ 2 |
#ifndef _FX_WORDSIZE_ |
-#if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || __WORDSIZE == 64 || defined(__LP64__) |
-#define _FX_WORDSIZE_ _FX_W64_ |
+#if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || \ |
+ defined(_M_AMD64) || defined(_M_X64) || defined(_M_IA64) || \ |
+ defined(__powerpc64__) || defined(__x86_64__) || __WORDSIZE == 64 || \ |
+ defined(__LP64__) |
+#define _FX_WORDSIZE_ _FX_W64_ |
#else |
-#define _FX_WORDSIZE_ _FX_W32_ |
+#define _FX_WORDSIZE_ _FX_W32_ |
#endif |
#endif |
#include <stddef.h> |
@@ -65,65 +68,66 @@ |
#ifdef __cplusplus |
extern "C" { |
#endif |
-typedef void* FX_LPVOID; |
-typedef void const* FX_LPCVOID; |
-typedef void* FX_POSITION; |
-typedef signed char FX_INT8; |
-typedef unsigned char FX_UINT8; |
-typedef unsigned char FX_BYTE; |
-typedef unsigned char* FX_LPBYTE; |
-typedef unsigned char const* FX_LPCBYTE; |
-typedef short FX_INT16; |
-typedef unsigned short FX_UINT16; |
-typedef short FX_SHORT; |
-typedef unsigned short FX_WORD; |
-typedef unsigned short* FX_LPWORD; |
-typedef unsigned short const* FX_LPCWORD; |
-typedef int FX_INT32; |
-typedef float FX_FLOAT; |
-typedef int FX_BOOL; |
-typedef int FX_ERR; |
-#define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0) |
-#define FX_FAILED(Status) ((FX_ERR)(Status) < 0) |
-typedef char FX_CHAR; |
-typedef char* FX_LPSTR; |
-typedef char const* FX_LPCSTR; |
-typedef unsigned int FX_DWORD; |
-typedef unsigned int* FX_LPDWORD; |
+typedef void* FX_LPVOID; |
+typedef void const* FX_LPCVOID; |
+typedef void* FX_POSITION; |
+typedef signed char FX_INT8; |
+typedef unsigned char FX_UINT8; |
+typedef unsigned char FX_BYTE; |
+typedef unsigned char* FX_LPBYTE; |
+typedef unsigned char const* FX_LPCBYTE; |
+typedef short FX_INT16; |
+typedef unsigned short FX_UINT16; |
+typedef short FX_SHORT; |
+typedef unsigned short FX_WORD; |
+typedef unsigned short* FX_LPWORD; |
+typedef unsigned short const* FX_LPCWORD; |
+typedef int FX_INT32; |
+typedef float FX_FLOAT; |
+typedef int FX_BOOL; |
+typedef int FX_ERR; |
+#define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0) |
+#define FX_FAILED(Status) ((FX_ERR)(Status) < 0) |
+typedef char FX_CHAR; |
+typedef char* FX_LPSTR; |
+typedef char const* FX_LPCSTR; |
+typedef unsigned int FX_DWORD; |
+typedef unsigned int* FX_LPDWORD; |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
-typedef __int64 FX_INT64; |
-typedef unsigned __int64 FX_UINT64; |
+typedef __int64 FX_INT64; |
+typedef unsigned __int64 FX_UINT64; |
#else |
-typedef long long int FX_INT64; |
-typedef unsigned long long FX_UINT64; |
+typedef long long int FX_INT64; |
+typedef unsigned long long FX_UINT64; |
#endif |
#if _FX_WORDSIZE_ == _FX_W64_ |
-typedef FX_INT64 FX_INTPTR; |
-typedef FX_UINT64 FX_UINTPTR; |
+typedef FX_INT64 FX_INTPTR; |
+typedef FX_UINT64 FX_UINTPTR; |
#else |
-typedef int FX_INTPTR; |
-typedef unsigned int FX_UINTPTR; |
+typedef int FX_INTPTR; |
+typedef unsigned int FX_UINTPTR; |
#endif |
-typedef wchar_t FX_WCHAR; |
-typedef wchar_t* FX_LPWSTR; |
-typedef wchar_t const* FX_LPCWSTR; |
-typedef FX_DWORD FX_UINT32; |
-typedef FX_UINT64 FX_QWORD; |
-#define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name; |
+typedef wchar_t FX_WCHAR; |
+typedef wchar_t* FX_LPWSTR; |
+typedef wchar_t const* FX_LPCWSTR; |
+typedef FX_DWORD FX_UINT32; |
+typedef FX_UINT64 FX_QWORD; |
+#define FX_DEFINEHANDLE(name) \ |
+ typedef struct _##name { FX_LPVOID pData; }* name; |
#if defined(DEBUG) && !defined(_DEBUG) |
#define _DEBUG |
#endif |
#ifndef TRUE |
-#define TRUE 1 |
+#define TRUE 1 |
#endif |
#ifndef FALSE |
-#define FALSE 0 |
+#define FALSE 0 |
#endif |
#ifndef NULL |
-#define NULL 0 |
+#define NULL 0 |
#endif |
#define FXSYS_assert assert |
#ifndef ASSERT |
@@ -136,32 +140,32 @@ typedef FX_UINT64 FX_QWORD; |
#endif |
#define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
#define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
-#define FX_PI 3.1415926535897932384626433832795f |
+#define FX_PI 3.1415926535897932384626433832795f |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
-#define FXSYS_snprintf _snprintf |
+#define FXSYS_snprintf _snprintf |
#else |
-#define FXSYS_snprintf snprintf |
+#define FXSYS_snprintf snprintf |
#endif |
-#define FXSYS_sprintf sprintf |
-#define FXSYS_vsprintf vsprintf |
-#define FXSYS_strchr strchr |
-#define FXSYS_strlen strlen |
-#define FXSYS_strncmp strncmp |
-#define FXSYS_strcmp strcmp |
-#define FXSYS_strcpy strcpy |
-#define FXSYS_strncpy strncpy |
-#define FXSYS_strstr strstr |
-#define FXSYS_FILE FILE |
-#define FXSYS_fopen fopen |
-#define FXSYS_fclose fclose |
-#define FXSYS_SEEK_END SEEK_END |
-#define FXSYS_SEEK_SET SEEK_SET |
-#define FXSYS_fseek fseek |
-#define FXSYS_ftell ftell |
-#define FXSYS_fread fread |
-#define FXSYS_fwrite fwrite |
-#define FXSYS_fprintf fprintf |
-#define FXSYS_fflush fflush |
+#define FXSYS_sprintf sprintf |
+#define FXSYS_vsprintf vsprintf |
+#define FXSYS_strchr strchr |
+#define FXSYS_strlen strlen |
+#define FXSYS_strncmp strncmp |
+#define FXSYS_strcmp strcmp |
+#define FXSYS_strcpy strcpy |
+#define FXSYS_strncpy strncpy |
+#define FXSYS_strstr strstr |
+#define FXSYS_FILE FILE |
+#define FXSYS_fopen fopen |
+#define FXSYS_fclose fclose |
+#define FXSYS_SEEK_END SEEK_END |
+#define FXSYS_SEEK_SET SEEK_SET |
+#define FXSYS_fseek fseek |
+#define FXSYS_ftell ftell |
+#define FXSYS_fread fread |
+#define FXSYS_fwrite fwrite |
+#define FXSYS_fprintf fprintf |
+#define FXSYS_fflush fflush |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
#ifdef _NATIVE_WCHAR_T_DEFINED |
#define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m)) |
@@ -172,21 +176,21 @@ typedef FX_UINT64 FX_QWORD; |
FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode); |
#endif |
-#define FXSYS_wcslen wcslen |
-#define FXSYS_wcscmp wcscmp |
-#define FXSYS_wcschr wcschr |
-#define FXSYS_wcsstr wcsstr |
-#define FXSYS_wcsncmp wcsncmp |
-#define FXSYS_vswprintf vswprintf |
-#define FXSYS_mbstowcs mbstowcs |
-#define FXSYS_wcstombs wcstombs |
-#define FXSYS_memcmp memcmp |
-#define FXSYS_memcpy memcpy |
-#define FXSYS_memmove memmove |
-#define FXSYS_memset memset |
-#define FXSYS_memchr memchr |
-#define FXSYS_qsort qsort |
-#define FXSYS_bsearch bsearch |
+#define FXSYS_wcslen wcslen |
+#define FXSYS_wcscmp wcscmp |
+#define FXSYS_wcschr wcschr |
+#define FXSYS_wcsstr wcsstr |
+#define FXSYS_wcsncmp wcsncmp |
+#define FXSYS_vswprintf vswprintf |
+#define FXSYS_mbstowcs mbstowcs |
+#define FXSYS_wcstombs wcstombs |
+#define FXSYS_memcmp memcmp |
+#define FXSYS_memcpy memcpy |
+#define FXSYS_memmove memmove |
+#define FXSYS_memset memset |
+#define FXSYS_memchr memchr |
+#define FXSYS_qsort qsort |
+#define FXSYS_bsearch bsearch |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
#define FXSYS_GetACP GetACP |
#define FXSYS_itoa _itoa |
@@ -195,8 +199,10 @@ FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode); |
#define FXSYS_stricmp _stricmp |
#ifdef _NATIVE_WCHAR_T_DEFINED |
#define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2)) |
-#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8) |
-#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6) |
+#define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) \ |
+ WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8) |
+#define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) \ |
+ MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6) |
#define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str)) |
#define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str)) |
#else |
@@ -209,81 +215,100 @@ FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode); |
#define FXSYS_GetFullPathName GetFullPathName |
#define FXSYS_GetModuleFileName GetModuleFileName |
#else |
-int FXSYS_GetACP(void); |
-char* FXSYS_itoa(int value, char* string, int radix); |
-int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen, |
- char* buf, int buflen, const char* default_str, int* pUseDefault); |
-int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen, |
- wchar_t* buf, int buflen); |
-FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart); |
-FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize); |
-char* FXSYS_strlwr(char* str); |
-char* FXSYS_strupr(char* str); |
-int FXSYS_stricmp(const char*, const char*); |
-int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2); |
-wchar_t* FXSYS_wcslwr(wchar_t* str); |
-wchar_t* FXSYS_wcsupr(wchar_t* str); |
+int FXSYS_GetACP(void); |
+char* FXSYS_itoa(int value, char* string, int radix); |
+int FXSYS_WideCharToMultiByte(FX_DWORD codepage, |
+ FX_DWORD dwFlags, |
+ const wchar_t* wstr, |
+ int wlen, |
+ char* buf, |
+ int buflen, |
+ const char* default_str, |
+ int* pUseDefault); |
+int FXSYS_MultiByteToWideChar(FX_DWORD codepage, |
+ FX_DWORD dwFlags, |
+ const char* bstr, |
+ int blen, |
+ wchar_t* buf, |
+ int buflen); |
+FX_DWORD FXSYS_GetFullPathName(const char* filename, |
+ FX_DWORD buflen, |
+ char* buf, |
+ char** filepart); |
+FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize); |
+char* FXSYS_strlwr(char* str); |
+char* FXSYS_strupr(char* str); |
+int FXSYS_stricmp(const char*, const char*); |
+int FXSYS_wcsicmp(const wchar_t* string1, const wchar_t* string2); |
+wchar_t* FXSYS_wcslwr(wchar_t* str); |
+wchar_t* FXSYS_wcsupr(wchar_t* str); |
#endif |
-#define FXSYS_memcpy32 FXSYS_memcpy |
-#define FXSYS_memcmp32 FXSYS_memcmp |
-#define FXSYS_memset32 FXSYS_memset |
-#define FXSYS_memset8 FXSYS_memset |
-#define FXSYS_memmove32 FXSYS_memmove |
+#define FXSYS_memcpy32 FXSYS_memcpy |
+#define FXSYS_memcmp32 FXSYS_memcmp |
+#define FXSYS_memset32 FXSYS_memset |
+#define FXSYS_memset8 FXSYS_memset |
+#define FXSYS_memmove32 FXSYS_memmove |
#ifdef __cplusplus |
} |
#endif |
#include <math.h> |
#if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
-#define FXSYS_pow(a, b) (FX_FLOAT)powf(a, b) |
+#define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b) |
#else |
-#define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b) |
+#define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b) |
#endif |
-#define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a) |
-#define FXSYS_fabs(a) (FX_FLOAT)fabs(a) |
-#define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b) |
-#define FXSYS_ceil(a) (FX_FLOAT)ceil(a) |
-#define FXSYS_floor(a) (FX_FLOAT)floor(a) |
-#define FXSYS_cos(a) (FX_FLOAT)cos(a) |
-#define FXSYS_acos(a) (FX_FLOAT)acos(a) |
-#define FXSYS_sin(a) (FX_FLOAT)sin(a) |
-#define FXSYS_log(a) (FX_FLOAT)log(a) |
-#define FXSYS_log10(a) (FX_FLOAT)log10(a) |
-#define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b) |
-#define FXSYS_abs abs |
+#define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a) |
+#define FXSYS_fabs(a) (FX_FLOAT) fabs(a) |
+#define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b) |
+#define FXSYS_ceil(a) (FX_FLOAT) ceil(a) |
+#define FXSYS_floor(a) (FX_FLOAT) floor(a) |
+#define FXSYS_cos(a) (FX_FLOAT) cos(a) |
+#define FXSYS_acos(a) (FX_FLOAT) acos(a) |
+#define FXSYS_sin(a) (FX_FLOAT) sin(a) |
+#define FXSYS_log(a) (FX_FLOAT) log(a) |
+#define FXSYS_log10(a) (FX_FLOAT) log10(a) |
+#define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b) |
+#define FXSYS_abs abs |
#ifdef __cplusplus |
extern "C" { |
#endif |
#define _FX_LSB_FIRST_ |
-#define FXDWORD_FROM_LSBFIRST(i) (i) |
-#define FXDWORD_FROM_MSBFIRST(i) (((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24)) |
-#define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0])) |
-#define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3])) |
-#define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8)) |
-#define FXSYS_LOBYTE(word) ((FX_BYTE)(word)) |
-#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16)) |
-#define FXSYS_LOWORD(dword) ((FX_WORD)(dword)) |
-FX_INT32 FXSYS_atoi(FX_LPCSTR str); |
-FX_INT32 FXSYS_wtoi(FX_LPCWSTR str); |
-FX_INT64 FXSYS_atoi64(FX_LPCSTR str); |
-FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str); |
-FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix); |
-FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix); |
-int FXSYS_round(FX_FLOAT f); |
-#define FXSYS_Mul(a, b) ((a) * (b)) |
-#define FXSYS_Div(a, b) ((a) / (b)) |
-#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c)) |
-#define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b)) |
+#define FXDWORD_FROM_LSBFIRST(i) (i) |
+#define FXDWORD_FROM_MSBFIRST(i) \ |
+ (((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | \ |
+ ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24)) |
+#define FXDWORD_GET_LSBFIRST(p) \ |
+ ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | \ |
+ (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0])) |
+#define FXDWORD_GET_MSBFIRST(p) \ |
+ ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | \ |
+ (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3])) |
+#define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8)) |
+#define FXSYS_LOBYTE(word) ((FX_BYTE)(word)) |
+#define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16)) |
+#define FXSYS_LOWORD(dword) ((FX_WORD)(dword)) |
+FX_INT32 FXSYS_atoi(FX_LPCSTR str); |
+FX_INT32 FXSYS_wtoi(FX_LPCWSTR str); |
+FX_INT64 FXSYS_atoi64(FX_LPCSTR str); |
+FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str); |
+FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix); |
+FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix); |
+int FXSYS_round(FX_FLOAT f); |
+#define FXSYS_Mul(a, b) ((a) * (b)) |
+#define FXSYS_Div(a, b) ((a) / (b)) |
+#define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c)) |
+#define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b)) |
#ifdef __cplusplus |
}; |
#include "../../../third_party/numerics/safe_math.h" |
typedef base::CheckedNumeric<FX_DWORD> FX_SAFE_DWORD; |
typedef base::CheckedNumeric<FX_INT32> FX_SAFE_INT32; |
-typedef base::CheckedNumeric<size_t> FX_SAFE_SIZE_T; |
+typedef base::CheckedNumeric<size_t> FX_SAFE_SIZE_T; |
#if defined(__clang__) || _MSC_VER >= 1700 |
#define FX_FINAL final |
#elif defined(__GNUC__) && __cplusplus >= 201103 && \ |
- (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
+ (__GNUC__ * 10000 + __GNUC_MINOR__ * 100) >= 40700 |
#define FX_FINAL final |
#else |
#define FX_FINAL |