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_INCLUDE_FXCRT_FX_SYSTEM_H_ | 7 #ifndef CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ |
8 #define CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ | 8 #define CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ |
9 | 9 |
10 #include <assert.h> | 10 #include <assert.h> |
11 #include <math.h> | 11 #include <math.h> |
12 #include <stdarg.h> | 12 #include <stdarg.h> |
13 #include <stddef.h> | 13 #include <stddef.h> |
14 #include <stdint.h> | 14 #include <stdint.h> |
15 #include <stdio.h> | 15 #include <stdio.h> |
16 #include <stdlib.h> | 16 #include <stdlib.h> |
17 #include <string.h> | 17 #include <string.h> |
18 #include <wchar.h> | 18 #include <wchar.h> |
19 | 19 |
20 // _FX_OS_ values: | 20 // _FX_OS_ values: |
21 #define _FX_WIN32_DESKTOP_ 1 | 21 #define _FX_WIN32_DESKTOP_ 1 |
22 #define _FX_WIN64_DESKTOP_ 2 | 22 #define _FX_WIN64_DESKTOP_ 2 |
23 #define _FX_LINUX_DESKTOP_ 4 | 23 #define _FX_LINUX_DESKTOP_ 4 |
24 #define _FX_MACOSX_ 7 | 24 #define _FX_MACOSX_ 7 |
25 #define _FX_ANDROID_ 12 | 25 #define _FX_ANDROID_ 12 |
26 | 26 |
27 // _FXM_PLATFORM_ values; | 27 // _FXM_PLATFORM_ values; |
28 #define _FXM_PLATFORM_WINDOWS_ 1 // _FX_WIN32_DESKTOP_ or _FX_WIN64_DESKTOP_. | 28 #define _FXM_PLATFORM_WINDOWS_ 1 // _FX_WIN32_DESKTOP_ or _FX_WIN64_DESKTOP_. |
29 #define _FXM_PLATFORM_LINUX_ 2 // _FX_LINUX_DESKTOP_ always. | 29 #define _FXM_PLATFORM_LINUX_ 2 // _FX_LINUX_DESKTOP_ always. |
30 #define _FXM_PLATFORM_APPLE_ 3 // _FX_MACOSX_ always. | 30 #define _FXM_PLATFORM_APPLE_ 3 // _FX_MACOSX_ always. |
31 #define _FXM_PLATFORM_ANDROID_ 4 // _FX_ANDROID_ always. | 31 #define _FXM_PLATFORM_ANDROID_ 4 // _FX_ANDROID_ always. |
32 | 32 |
33 #ifndef _FX_OS_ | 33 #ifndef _FX_OS_ |
34 #if defined(__ANDROID__) | 34 #if defined(__ANDROID__) |
35 #define _FX_OS_ _FX_ANDROID_ | 35 #define _FX_OS_ _FX_ANDROID_ |
36 #define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_ | 36 #define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_ |
37 #elif defined(_WIN32) | 37 #elif defined(_WIN32) |
38 #define _FX_OS_ _FX_WIN32_DESKTOP_ | 38 #define _FX_OS_ _FX_WIN32_DESKTOP_ |
39 #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_ | 39 #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_ |
40 #elif defined(_WIN64) | 40 #elif defined(_WIN64) |
41 #define _FX_OS_ _FX_WIN64_DESKTOP_ | 41 #define _FX_OS_ _FX_WIN64_DESKTOP_ |
(...skipping 18 matching lines...) Expand all Loading... |
60 #endif | 60 #endif |
61 | 61 |
62 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ | 62 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_ |
63 #include <libkern/OSAtomic.h> | 63 #include <libkern/OSAtomic.h> |
64 #include <Carbon/Carbon.h> | 64 #include <Carbon/Carbon.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 unsigned short FX_WORD; // Keep - "an efficient small type" | 71 typedef unsigned short FX_WORD; // Keep - "an efficient small type" |
72 typedef unsigned int FX_DWORD; // Keep - "an efficient type" | 72 typedef unsigned int FX_DWORD; // Keep - "an efficient type" |
73 typedef float FX_FLOAT; // Keep, allow upgrade to doubles. | 73 typedef float FX_FLOAT; // Keep, allow upgrade to doubles. |
74 typedef int FX_BOOL; // Keep, sadly not always 0 or 1. | 74 typedef int FX_BOOL; // Keep, sadly not always 0 or 1. |
75 typedef char FX_CHAR; // Keep, questionable signedness. | 75 typedef char FX_CHAR; // Keep, questionable signedness. |
76 typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. | 76 typedef wchar_t FX_WCHAR; // Keep, maybe bad platform wchars. |
77 | 77 |
78 // PDFium string sizes are limited to 2^31-1, and the value is signed to | 78 // PDFium string sizes are limited to 2^31-1, and the value is signed to |
79 // allow -1 as a placeholder for "unknown". | 79 // allow -1 as a placeholder for "unknown". |
80 // TODO(palmer): it should be a |size_t|, or at least unsigned. | 80 // TODO(palmer): it should be a |size_t|, or at least unsigned. |
81 typedef int FX_STRSIZE; | 81 typedef int FX_STRSIZE; |
82 | 82 |
83 #if defined(DEBUG) && !defined(_DEBUG) | 83 #if defined(DEBUG) && !defined(_DEBUG) |
84 #define _DEBUG | 84 #define _DEBUG |
85 #endif | 85 #endif |
86 | 86 |
87 #ifndef TRUE | 87 #ifndef TRUE |
88 #define TRUE» 1 | 88 #define TRUE 1 |
89 #endif | 89 #endif |
90 | 90 |
91 #ifndef FALSE | 91 #ifndef FALSE |
92 #define FALSE» 0 | 92 #define FALSE 0 |
93 #endif | 93 #endif |
94 | 94 |
95 #ifndef NULL | 95 #ifndef NULL |
96 #define NULL» 0 | 96 #define NULL 0 |
97 #endif | 97 #endif |
98 | 98 |
99 #define FXSYS_assert assert | 99 #define FXSYS_assert assert |
100 #ifndef ASSERT | 100 #ifndef ASSERT |
101 #ifdef _DEBUG | 101 #ifdef _DEBUG |
102 #define ASSERT FXSYS_assert | 102 #define ASSERT FXSYS_assert |
103 #else | 103 #else |
104 #define ASSERT(a) | 104 #define ASSERT(a) |
105 #endif | 105 #endif |
106 #endif | 106 #endif |
107 | 107 |
108 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) | 108 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b)) |
109 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) | 109 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b)) |
110 #define FX_PI» 3.1415926535897932384626433832795f | 110 #define FX_PI 3.1415926535897932384626433832795f |
111 | 111 |
112 // NOTE: prevent use of the return value from snprintf() since some platforms | 112 // NOTE: prevent use of the return value from snprintf() since some platforms |
113 // have different return values (e.g. windows _vsnprintf()), and provide | 113 // have different return values (e.g. windows _vsnprintf()), and provide |
114 // versions that always NUL-terminate. | 114 // versions that always NUL-terminate. |
115 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 | 115 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ && _MSC_VER < 1900 |
116 void FXSYS_snprintf(char *str, size_t size, _Printf_format_string_ const char* f
mt, ...); | 116 void FXSYS_snprintf(char* str, |
117 void FXSYS_vsnprintf(char *str, size_t size, const char* fmt, va_list ap); | 117 size_t size, |
| 118 _Printf_format_string_ const char* fmt, |
| 119 ...); |
| 120 void FXSYS_vsnprintf(char* str, size_t size, const char* fmt, va_list ap); |
118 #else | 121 #else |
119 #define FXSYS_snprintf» (void) snprintf | 122 #define FXSYS_snprintf (void) snprintf |
120 #define FXSYS_vsnprintf»(void) vsnprintf | 123 #define FXSYS_vsnprintf (void) vsnprintf |
121 #endif | 124 #endif |
122 | 125 |
123 #define FXSYS_sprintf» DO_NOT_USE_SPRINTF_DIE_DIE_DIE | 126 #define FXSYS_sprintf DO_NOT_USE_SPRINTF_DIE_DIE_DIE |
124 #define FXSYS_vsprintf» DO_NOT_USE_VSPRINTF_DIE_DIE_DIE | 127 #define FXSYS_vsprintf DO_NOT_USE_VSPRINTF_DIE_DIE_DIE |
125 #define FXSYS_strchr» strchr | 128 #define FXSYS_strchr strchr |
126 #define FXSYS_strncmp» strncmp | 129 #define FXSYS_strncmp strncmp |
127 #define FXSYS_strcmp» strcmp | 130 #define FXSYS_strcmp strcmp |
128 #define FXSYS_strcpy» strcpy | 131 #define FXSYS_strcpy strcpy |
129 #define FXSYS_strncpy» strncpy | 132 #define FXSYS_strncpy strncpy |
130 #define FXSYS_strstr» strstr | 133 #define FXSYS_strstr strstr |
131 #define FXSYS_FILE» » FILE | 134 #define FXSYS_FILE FILE |
132 #define FXSYS_fopen» » fopen | 135 #define FXSYS_fopen fopen |
133 #define FXSYS_fclose» fclose | 136 #define FXSYS_fclose fclose |
134 #define FXSYS_SEEK_END» SEEK_END | 137 #define FXSYS_SEEK_END SEEK_END |
135 #define FXSYS_SEEK_SET» SEEK_SET | 138 #define FXSYS_SEEK_SET SEEK_SET |
136 #define FXSYS_fseek» » fseek | 139 #define FXSYS_fseek fseek |
137 #define FXSYS_ftell» » ftell | 140 #define FXSYS_ftell ftell |
138 #define FXSYS_fread» » fread | 141 #define FXSYS_fread fread |
139 #define FXSYS_fwrite» fwrite | 142 #define FXSYS_fwrite fwrite |
140 #define FXSYS_fprintf» fprintf | 143 #define FXSYS_fprintf fprintf |
141 #define FXSYS_fflush» fflush | 144 #define FXSYS_fflush fflush |
142 | 145 |
143 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 146 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
144 #ifdef _NATIVE_WCHAR_T_DEFINED | 147 #ifdef _NATIVE_WCHAR_T_DEFINED |
145 #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m)) | 148 #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m)) |
146 #else | 149 #else |
147 #define FXSYS_wfopen _wfopen | 150 #define FXSYS_wfopen _wfopen |
148 #endif | 151 #endif |
149 #else | 152 #else |
150 FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode); | 153 FXSYS_FILE* FXSYS_wfopen(const FX_WCHAR* filename, const FX_WCHAR* mode); |
151 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 154 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
152 | 155 |
153 #ifdef __cplusplus | 156 #ifdef __cplusplus |
154 } // extern "C" | 157 } // extern "C" |
155 #include "../../../third_party/base/numerics/safe_conversions.h" | 158 #include "../../../third_party/base/numerics/safe_conversions.h" |
156 #define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr)) | 159 #define FXSYS_strlen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(strlen(ptr)) |
157 #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) | 160 #define FXSYS_wcslen(ptr) pdfium::base::checked_cast<FX_STRSIZE>(wcslen(ptr)) |
158 extern "C" { | 161 extern "C" { |
159 #else | 162 #else |
160 #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) | 163 #define FXSYS_strlen(ptr) ((FX_STRSIZE)strlen(ptr)) |
161 #define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr)) | 164 #define FXSYS_wcslen(ptr) ((FX_STRSIZE)wcslen(ptr)) |
162 #endif | 165 #endif |
163 | 166 |
164 #define FXSYS_wcscmp» wcscmp | 167 #define FXSYS_wcscmp wcscmp |
165 #define FXSYS_wcschr» wcschr | 168 #define FXSYS_wcschr wcschr |
166 #define FXSYS_wcsstr» wcsstr | 169 #define FXSYS_wcsstr wcsstr |
167 #define FXSYS_wcsncmp» wcsncmp | 170 #define FXSYS_wcsncmp wcsncmp |
168 #define FXSYS_vswprintf»vswprintf | 171 #define FXSYS_vswprintf vswprintf |
169 #define FXSYS_mbstowcs» mbstowcs | 172 #define FXSYS_mbstowcs mbstowcs |
170 #define FXSYS_wcstombs» wcstombs | 173 #define FXSYS_wcstombs wcstombs |
171 #define FXSYS_memcmp» memcmp | 174 #define FXSYS_memcmp memcmp |
172 #define FXSYS_memcpy» memcpy | 175 #define FXSYS_memcpy memcpy |
173 #define FXSYS_memmove» memmove | 176 #define FXSYS_memmove memmove |
174 #define FXSYS_memset» memset | 177 #define FXSYS_memset memset |
175 #define FXSYS_memchr» memchr | 178 #define FXSYS_memchr memchr |
176 #define FXSYS_qsort» » qsort | 179 #define FXSYS_qsort qsort |
177 #define FXSYS_bsearch» bsearch | 180 #define FXSYS_bsearch bsearch |
178 | 181 |
179 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 182 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
180 #define FXSYS_GetACP GetACP | 183 #define FXSYS_GetACP GetACP |
181 #define FXSYS_itoa _itoa | 184 #define FXSYS_itoa _itoa |
182 #define FXSYS_strlwr _strlwr | 185 #define FXSYS_strlwr _strlwr |
183 #define FXSYS_strupr _strupr | 186 #define FXSYS_strupr _strupr |
184 #define FXSYS_stricmp _stricmp | 187 #define FXSYS_stricmp _stricmp |
185 #ifdef _NATIVE_WCHAR_T_DEFINED | 188 #ifdef _NATIVE_WCHAR_T_DEFINED |
186 #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2)) | 189 #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2)) |
187 #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMult
iByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8) | 190 #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) \ |
188 #define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1
, p2, p3, p4, (wchar_t*)(p5), p6) | 191 WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8) |
| 192 #define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) \ |
| 193 MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6) |
189 #define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str)) | 194 #define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str)) |
190 #define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str)) | 195 #define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str)) |
191 #else | 196 #else |
192 #define FXSYS_wcsicmp _wcsicmp | 197 #define FXSYS_wcsicmp _wcsicmp |
193 #define FXSYS_WideCharToMultiByte WideCharToMultiByte | 198 #define FXSYS_WideCharToMultiByte WideCharToMultiByte |
194 #define FXSYS_MultiByteToWideChar MultiByteToWideChar | 199 #define FXSYS_MultiByteToWideChar MultiByteToWideChar |
195 #define FXSYS_wcslwr _wcslwr | 200 #define FXSYS_wcslwr _wcslwr |
196 #define FXSYS_wcsupr _wcsupr | 201 #define FXSYS_wcsupr _wcsupr |
197 #endif | 202 #endif |
198 #define FXSYS_GetFullPathName GetFullPathName | 203 #define FXSYS_GetFullPathName GetFullPathName |
199 #define FXSYS_GetModuleFileName GetModuleFileName | 204 #define FXSYS_GetModuleFileName GetModuleFileName |
200 #else | 205 #else |
201 int» » » FXSYS_GetACP(void); | 206 int FXSYS_GetACP(void); |
202 char*» » FXSYS_itoa(int value, char* string, int radix); | 207 char* FXSYS_itoa(int value, char* string, int radix); |
203 int» » » FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dw
Flags, const wchar_t* wstr, int wlen, | 208 int FXSYS_WideCharToMultiByte(FX_DWORD codepage, |
204 char* buf, int buflen, const char* default
_str, int* pUseDefault); | 209 FX_DWORD dwFlags, |
205 int» » » FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dw
Flags, const char* bstr, int blen, | 210 const wchar_t* wstr, |
206 wchar_t* buf, int buflen); | 211 int wlen, |
207 FX_DWORD» FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, cha
r* buf, char** filepart); | 212 char* buf, |
208 FX_DWORD» FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsi
ze); | 213 int buflen, |
209 char*» » FXSYS_strlwr(char* str); | 214 const char* default_str, |
210 char*» » FXSYS_strupr(char* str); | 215 int* pUseDefault); |
211 int» » » FXSYS_stricmp(const char*, const char*); | 216 int FXSYS_MultiByteToWideChar(FX_DWORD codepage, |
212 int» » » FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *str
ing2); | 217 FX_DWORD dwFlags, |
213 wchar_t*» FXSYS_wcslwr(wchar_t* str); | 218 const char* bstr, |
214 wchar_t*» FXSYS_wcsupr(wchar_t* str); | 219 int blen, |
| 220 wchar_t* buf, |
| 221 int buflen); |
| 222 FX_DWORD FXSYS_GetFullPathName(const char* filename, |
| 223 FX_DWORD buflen, |
| 224 char* buf, |
| 225 char** filepart); |
| 226 FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize); |
| 227 char* FXSYS_strlwr(char* str); |
| 228 char* FXSYS_strupr(char* str); |
| 229 int FXSYS_stricmp(const char*, const char*); |
| 230 int FXSYS_wcsicmp(const wchar_t* string1, const wchar_t* string2); |
| 231 wchar_t* FXSYS_wcslwr(wchar_t* str); |
| 232 wchar_t* FXSYS_wcsupr(wchar_t* str); |
215 #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ | 233 #endif // _FXM_PLATFORM == _FXM_PLATFORM_WINDOWS_ |
216 | 234 |
217 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 235 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
218 #define FXSYS_pow(a, b)»» (FX_FLOAT)powf(a, b) | 236 #define FXSYS_pow(a, b) (FX_FLOAT) powf(a, b) |
219 #else | 237 #else |
220 #define FXSYS_pow(a, b)»» (FX_FLOAT)pow(a, b) | 238 #define FXSYS_pow(a, b) (FX_FLOAT) pow(a, b) |
221 #endif | 239 #endif |
222 #define FXSYS_sqrt(a)» » (FX_FLOAT)sqrt(a) | 240 #define FXSYS_sqrt(a) (FX_FLOAT) sqrt(a) |
223 #define FXSYS_fabs(a)» » (FX_FLOAT)fabs(a) | 241 #define FXSYS_fabs(a) (FX_FLOAT) fabs(a) |
224 #define FXSYS_atan2(a, b)» (FX_FLOAT)atan2(a, b) | 242 #define FXSYS_atan2(a, b) (FX_FLOAT) atan2(a, b) |
225 #define FXSYS_ceil(a)» » (FX_FLOAT)ceil(a) | 243 #define FXSYS_ceil(a) (FX_FLOAT) ceil(a) |
226 #define FXSYS_floor(a)» » (FX_FLOAT)floor(a) | 244 #define FXSYS_floor(a) (FX_FLOAT) floor(a) |
227 #define FXSYS_cos(a)» » (FX_FLOAT)cos(a) | 245 #define FXSYS_cos(a) (FX_FLOAT) cos(a) |
228 #define FXSYS_acos(a)» » (FX_FLOAT)acos(a) | 246 #define FXSYS_acos(a) (FX_FLOAT) acos(a) |
229 #define FXSYS_sin(a)» » (FX_FLOAT)sin(a) | 247 #define FXSYS_sin(a) (FX_FLOAT) sin(a) |
230 #define FXSYS_log(a)» » (FX_FLOAT)log(a) | 248 #define FXSYS_log(a) (FX_FLOAT) log(a) |
231 #define FXSYS_log10(a)» » (FX_FLOAT)log10(a) | 249 #define FXSYS_log10(a) (FX_FLOAT) log10(a) |
232 #define FXSYS_fmod(a, b)» (FX_FLOAT)fmod(a, b) | 250 #define FXSYS_fmod(a, b) (FX_FLOAT) fmod(a, b) |
233 #define FXSYS_abs» » » abs | 251 #define FXSYS_abs abs |
234 #define FXDWORD_FROM_LSBFIRST(i)» (i) | 252 #define FXDWORD_FROM_LSBFIRST(i) (i) |
235 #define FXDWORD_FROM_MSBFIRST(i)» (((uint8_t)(i) << 24) | ((uint8_t)((i) >
> 8) << 16) | ((uint8_t)((i) >> 16) << 8) | (uint8_t)((i) >> 24)) | 253 #define FXDWORD_FROM_MSBFIRST(i) \ |
236 #define FXDWORD_GET_LSBFIRST(p)»» ((((uint8_t*)(p))[3] << 24) | (((uint8_t
*)(p))[2] << 16) | (((uint8_t*)(p))[1] << 8) | (((uint8_t*)(p))[0])) | 254 (((uint8_t)(i) << 24) | ((uint8_t)((i) >> 8) << 16) | \ |
237 #define FXDWORD_GET_MSBFIRST(p) ((((uint8_t*)(p))[0] << 24) | (((uint8_t*)(p))[1
] << 16) | (((uint8_t*)(p))[2] << 8) | (((uint8_t*)(p))[3])) | 255 ((uint8_t)((i) >> 16) << 8) | (uint8_t)((i) >> 24)) |
238 #define FXSYS_HIBYTE(word)» ((uint8_t)((word) >> 8)) | 256 #define FXDWORD_GET_LSBFIRST(p) \ |
239 #define FXSYS_LOBYTE(word)» ((uint8_t)(word)) | 257 ((((uint8_t*)(p))[3] << 24) | (((uint8_t*)(p))[2] << 16) | \ |
240 #define FXSYS_HIWORD(dword)» ((FX_WORD)((dword) >> 16)) | 258 (((uint8_t*)(p))[1] << 8) | (((uint8_t*)(p))[0])) |
241 #define FXSYS_LOWORD(dword)» ((FX_WORD)(dword)) | 259 #define FXDWORD_GET_MSBFIRST(p) \ |
242 int32_t»FXSYS_atoi(const FX_CHAR* str); | 260 ((((uint8_t*)(p))[0] << 24) | (((uint8_t*)(p))[1] << 16) | \ |
243 int32_t»FXSYS_wtoi(const FX_WCHAR* str); | 261 (((uint8_t*)(p))[2] << 8) | (((uint8_t*)(p))[3])) |
244 int64_t»FXSYS_atoi64(const FX_CHAR* str); | 262 #define FXSYS_HIBYTE(word) ((uint8_t)((word) >> 8)) |
245 int64_t»FXSYS_wtoi64(const FX_WCHAR* str); | 263 #define FXSYS_LOBYTE(word) ((uint8_t)(word)) |
246 const FX_CHAR*» FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); | 264 #define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16)) |
247 const FX_WCHAR*»FXSYS_i64tow(int64_t value, FX_WCHAR* str, int radix); | 265 #define FXSYS_LOWORD(dword) ((FX_WORD)(dword)) |
248 int» » » FXSYS_round(FX_FLOAT f); | 266 int32_t FXSYS_atoi(const FX_CHAR* str); |
249 #define»» FXSYS_Mul(a, b) ((a) * (b)) | 267 int32_t FXSYS_wtoi(const FX_WCHAR* str); |
250 #define»» FXSYS_Div(a, b) ((a) / (b)) | 268 int64_t FXSYS_atoi64(const FX_CHAR* str); |
251 #define»» FXSYS_MulDiv(a, b, c) ((a) * (b) / (c)) | 269 int64_t FXSYS_wtoi64(const FX_WCHAR* str); |
252 #define»» FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b)) | 270 const FX_CHAR* FXSYS_i64toa(int64_t value, FX_CHAR* str, int radix); |
| 271 const FX_WCHAR* FXSYS_i64tow(int64_t value, FX_WCHAR* str, int radix); |
| 272 int FXSYS_round(FX_FLOAT f); |
| 273 #define FXSYS_Mul(a, b) ((a) * (b)) |
| 274 #define FXSYS_Div(a, b) ((a) / (b)) |
| 275 #define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c)) |
| 276 #define FXSYS_sqrt2(a, b) (FX_FLOAT) FXSYS_sqrt((a) * (a) + (b) * (b)) |
253 #ifdef __cplusplus | 277 #ifdef __cplusplus |
254 }; | 278 }; |
255 #endif | 279 #endif |
256 | 280 |
257 // To print a size_t value in a portable way: | 281 // To print a size_t value in a portable way: |
258 // size_t size; | 282 // size_t size; |
259 // printf("xyz: %" PRIuS, size); | 283 // printf("xyz: %" PRIuS, size); |
260 // The "u" in the macro corresponds to %u, and S is for "size". | 284 // The "u" in the macro corresponds to %u, and S is for "size". |
261 | 285 |
262 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 286 #if _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
(...skipping 16 matching lines...) Expand all Loading... |
279 #else // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 303 #else // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
280 | 304 |
281 #if !defined(PRIuS) | 305 #if !defined(PRIuS) |
282 #define PRIuS "Iu" | 306 #define PRIuS "Iu" |
283 #endif | 307 #endif |
284 | 308 |
285 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ | 309 #endif // _FXM_PLATFORM_ != _FXM_PLATFORM_WINDOWS_ |
286 | 310 |
287 // Prevent a function from ever being inlined, typically because we'd | 311 // Prevent a function from ever being inlined, typically because we'd |
288 // like it to appear in stack traces. | 312 // like it to appear in stack traces. |
289 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 313 #if _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
290 #define NEVER_INLINE __declspec(noinline) | 314 #define NEVER_INLINE __declspec(noinline) |
291 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 315 #else // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
292 #define NEVER_INLINE __attribute__((__noinline__)) | 316 #define NEVER_INLINE __attribute__((__noinline__)) |
293 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ | 317 #endif // _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_ |
294 | 318 |
295 #endif // CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ | 319 #endif // CORE_INCLUDE_FXCRT_FX_SYSTEM_H_ |
OLD | NEW |