Foxit PDF SDK
fx_system.h
Go to the documentation of this file.
1 
14 //<<<+++OPENSOURCE
15 //<<<+++OPENSOURCE_LICENSE
16 //<<<+++OPENSOURCE_BEGIN LIC==FOXIT||LIC==GOOGLE
17 
23 /*
24  * @brief System dependant service routines.
25  * All system-specific function and non-standard C/C++ routines go here
26  *
27  * FPDFAPI PREDEFINED MACROES
28  *
29  * FPDFAPI makes use of a number of predefined macroes to support all kind of platforms
30  * with a single set of codes. In most of times, application developers can ignore those
31  * macroes because they are properly defined according to system or compiler environment
32  * settings. However, sometimes, especially for cross platform development, FPDFAPI might
33  * take incorrect settings of the host platform, rather then the target platform. In such
34  * case, the application developers should manually set necessary macroes in their project
35  * settings.
36  *
37  *
38  * Currently the following macroes are defined:
39  * - #_FX_OS_ The target operating system
40  * - #_FX_COMPILER_ The compiler
41  * - #_FX_CPU_ The CPU
42  * - #_FX_ENDIAN_ Little endian or big endian
43  *
44  * #_FX_OS_ can be one of the followings:
45  * - #_FX_WIN32_DESKTOP_ Windows desktop OS (from Windows 95)
46  * - #_FX_WIN32_MOBILE_ Windows Mobile OS (from Windows CE 4.0)
47  * - #_FX_WIN64_ Windows 64 bit
48  * - #_FX_LINUX_DESKTOP_ Linux Desktop OS
49  * - #_FX_LINUX_EMBEDDED_ Embedded Linux OS
50  * - #_FX_SYMBIAN_ Symbian OS (from 7.0)
51  * - #_FX_MACOSX_ MAC OS X
52  * - #_FX_EMBEDDED_ Embedded OS
53  * - #_FX_SOLARIS_ Solaris 8 or later
54  * - #_FX_PALMOS_ PalmOS (5.0 or later)
55  * - #_FX_NETBSD_ NetBSD
56  * - #_FX_ANDROID_ Android
57  * - #_FX_VXWORKS_ VxWorks
58  *
59  * #_FX_COMPILER_ can be one of the following:
60  * - #_FX_VC6_ Microsoft Visual C++ 6.0
61  * - #_FX_VC7_ Microsoft Visual Studio.Net 2003
62  * - #_FX_VC8_ Microsoft Visual Studio.Net 2005
63  * - #_FX_GCC_ GNU C++ Compiler
64  * - #_FX_ADS_ ADS 1.2 Compiler
65  * - #_FX_RVCT_ RVCT 2.1 Compiler
66  * - #_FX_IARCC_ IAR C/C++ Compiler
67  * - #_FX_NOKIA_X86_ Nokia X86 Compiler
68  * - #_FX_METROWERKS_ Metrowerks C/C++ Compiler (with MSL)
69  * - #_FX_PACC_ Protein C/C++ Compiler (used by PalmOS)
70  * - #_FX_MIPS_SDE_ MIPS SDE
71  *
72  * #_FX_CPU_ can be one of the following:
73  * - #_FX_X86_ 32-bit x86 CPU
74  * - #_FX_X64_ 64-bit x86 CPU
75  * - #_FX_POWERPC_ Power PC
76  * - #_FX_ARM_ ARM
77  * - #_FX_SPARC_ Sparc
78  * - #_FX_MIPS_ MIPS
79  * - #_FX_ARM64_ 64-bit ARM
80  *
81  * #_FX_ENDIAN_ can be one of the following:
82  * - #_FX_BIG_ENDIAN_
83  * - #_FX_LITTLE_ENDIAN_
84  *
85  * #_FX_WORDSIZE_ can be one of the following:
86  * - #_FX_W32_ 32-bit instruct
87  * - #_FX_W64_ 64-bit instruct
88  */
89 
90 //<<<+++OPENSOURCE_MUST_BEGIN
91 #ifndef _FX_SYSTEM_H_
92 #define _FX_SYSTEM_H_
93 //<<<+++OPENSOURCE_MUST_END
94 
95 #ifdef _WIN32_WCE
96  #ifndef _SIZE_T_DEFINED
97  #define _SIZE_T_DEFINED
98  #endif //_SIZE_T_DEFINED
99 #endif
100 
105 
107 #define _FX_WIN32_DESKTOP_ 1
108  //<<<+++OPENSOURCE_BEGIN LIC==FOXIT
110  #define _FX_WIN32_MOBILE_ 2
111 
112  #define _FX_WIN64_ 3
113  //<<<+++OPENSOURCE_END
114 
116 #define _FX_LINUX_DESKTOP_ 4
117 
119  #define _FX_LINUX_EMBEDDED_ 5
120 
121  #define _FX_SYMBIAN_ 6
122 
124 #define _FX_MACOSX_ 7
125 
127  #define _FX_EMBEDDED_ 8
128 
129  #define _FX_SOLARIS_ 9
130 
131  #define _FX_PALMOS_ 10
132 
133  #define _FX_NETBSD_ 11
134  //<<<+++OPENSOURCE_END
135 
137 #define _FX_ANDROID_ 12
138 
140  #define _FX_VXWORKS_ 13
141 
142  #define _FX_MTK_ 14
143 
144  #define _FX_IOS_ 15
145 
147 #define _FXM_PLATFORM_WINDOWS_ 1
148 
149 #define _FXM_PLATFORM_LINUX_ 2
150 
151 #define _FXM_PLATFORM_APPLE_ 3
152 
153 #define _FXM_PLATFORM_ANDROID_ 4
154 
155 #ifdef __pnacl__
156 #define _CHROME_PNACL_
157 #endif
158 
159 #ifdef __EMSCRIPTEN__
160  #define _FXM_PLATFORM_LINUX_JS_
161 #endif
162 
163 #if defined(_FXM_PLATFORM_LINUX_JS_) || defined(_CHROME_PNACL_)
164  #define _FX_OS_ _FX_LINUX_DESKTOP_
165  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
166 #endif
167 
168 /* OS */
169 
170 #ifndef _FX_OS_
171  #if defined(__SYMBIAN32__) || defined(__symbian__)
172  #define _FX_OS_ _FX_SYMBIAN_
173  #elif defined(_WIN32_WCE)
174  #define _FX_OS_ _FX_WIN32_MOBILE_
175  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
176  #if defined (_WIN32_WCE) && (_WIN32_WCE == 0x600)
177  #define UNSUPPORT_CPP0X
178  #endif
179  #elif defined(__linux__) || defined(__native_client__)
180  #if defined(__arm__) && (!defined(OS_CHROMEOS))
181  #define _FX_OS_ _FX_LINUX_EMBEDDED_
182  #else
183  #define _FX_OS_ _FX_LINUX_DESKTOP_
184  #endif
185  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
186  #elif defined(__NetBSD__)
187  #define _FX_OS_ _FX_NETBSD_
188  #elif defined(_WIN64)
189  #define _FX_OS_ _FX_WIN64_
190  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
191  #elif defined(_WIN32)
192  #define _FX_OS_ _FX_WIN32_DESKTOP_
193  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
194  #elif defined(__sparc__)
195  #define _FX_OS_ _FX_SOLARIS_
196  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
197  #elif defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__TMS470__)
198  #define _FX_OS_ _FX_EMBEDDED_
199  #elif defined(__APPLE__)
200  #include "TargetConditionals.h"
201  #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR == 1)
202  #define _FX_OS_ _FX_IOS_
203  #else
204  #define _FX_OS_ _FX_MACOSX_
205  #endif
206  #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
207  #elif defined(__ARM_EABI__)
208  #define _FX_OS_ _FX_EMBEDDED_
209  #endif
210 #else
211  #if _FX_OS_ == _FX_ANDROID_
212  #ifndef _FXM_PLATFORM_
213  #define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_
214  #endif
215  #elif (_FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_ || _FX_OS_ == _FX_WIN32_DESKTOP_)
216  #ifndef _FXM_PLATFORM_
217  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
218  #endif
219  #elif (_FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_MACOSX_)
220  #ifndef _FXM_PLATFORM_
221  #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
222  #endif
223  #elif _FX_OS_ == _FX_SOLARIS_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_LINUX_DESKTOP_
224  #ifndef _FXM_PLATFORM_
225  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
226  #endif
227  #endif
228 #endif //_FX_OS_
229 
230 #if !defined(_FX_OS_) || _FX_OS_ == 0
231  #error Sorry, can not figure out what OS you are targeting to. Please specify _FX_OS_ macro.
232 #endif
233 
234 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
235 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
236 
237  #define _CRT_SECURE_NO_WARNINGS
238  #if defined(_MSC_VER) && _MSC_VER < 1300
239  #define _WIN32_WINNT 0x400
240  #endif
241  #if defined(_MSC_VER) && _MSC_VER < 1600
242  #define UNSUPPORT_CPP0X
243  #endif
244  #ifndef NOMINMAX
245  #define NOMINMAX
246  #endif
247  #include <windows.h>
248 
249  #ifdef WINAPI_FAMILY
250  #if (0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP) //Macros in Windows Kit/8
251  #define _FX_WIN8_
252  #else //Macros in Windows Kit/8.1
253  #define _FX_WIN81_
254  #endif //(0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP)
255 
256  #ifdef _FX_WIN8_
257  #if /*defined(WINAPI_FAMILY) && */((WINAPI_FAMILY&WINAPI_PARTITION_APP) == WINAPI_PARTITION_APP)
258 
259  #define _FX_WINAPI_PARTITION_APP_
260  #endif
261  #if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY&WINAPI_PARTITION_DESKTOP) == WINAPI_PARTITION_DESKTOP)
262 
263  #define _FX_WINAPI_PARTITION_DESKTOP_
264  #endif
265  #endif //_FX_WIN8_
266 
267  #ifdef _FX_WIN81_
268 
269  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
270 
271  #define _FX_WINAPI_PARTITION_APP_
272  #endif
273 
274  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
275 
276  #define _FX_WINAPI_PARTITION_PHONE_APP_
277  #endif
278 
279  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
280 
281  #define _FX_WINAPI_PARTITION_DESKTOP_
282  #endif
283  #endif //_FX_WIN81_
284  #else // !defined(WINAPI_FAMILY)
285  #ifndef _WIN32_WCE
286  #define _FX_WINAPI_PARTITION_DESKTOP_
287  #endif
288  #endif //WINAPI_FAMILY
289 #endif //(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
290 //<<<+++OPENSOURCE_MUST_END
291 
298 
300 #define _FX_VC6_ 1
301 
302 #define _FX_VC7_ 2
303 
304 #define _FX_VC8_ 3
305 
306 #define _FX_GCC_ 4
307 
308 #define _FX_ADS_ 5
309 
310 #define _FX_RVCT_ 6
311 
312 #define _FX_IARCC_ 7
313 
314 #define _FX_NOKIA_X86_ 8
315 
316 #define _FX_METROWERKS_ 9
317 
318 #define _FX_PACC_ 10
319 
320 #define _FX_TMS470_ 11
321 
322 #define _FX_MIPS_SDE_ 12
323 
324 /* Compiler */
325 #ifndef _FX_COMPILER_
326  #ifdef _MSC_VER
327  #if _MSC_VER >= 1400
328  #define _FX_COMPILER_ _FX_VC8_
329  #elif _MSC_VER >= 1300
330  #define _FX_COMPILER_ _FX_VC7_
331  #else
332 
351  #define _FX_COMPILER_ _FX_VC6_
352  #endif
353  #elif defined(__GNUC__)
354  #define _FX_COMPILER_ _FX_GCC_
355  #elif defined(__ARMCC_VERSION)
356  #if __ARMCC_VERSION < 200000
357  #define _FX_COMPILER_ _FX_ADS_
358  #else
359  #define _FX_COMPILER_ _FX_RVCT_
360  #endif
361  #elif defined(__ICCARM__)
362  #define _FX_COMPILER_ _FX_IARCC_
363  #elif defined(_PACC_VER)
364  #define _FX_COMPILER_ _FX_PACC_
365  #elif defined(__TMS470__)
366  #define _FX_COMPILER_ _FX_TMS470_
367  #endif
368 #endif /* !_FX_COMPILER_ */
369 #if !defined(_FX_COMPILER_) || _FX_COMPILER_ == 0
370  #error Sorry, can not figure out what compiler you are using. Please specify _FX_COMPILER_ macro.
371 #endif
372 //<<<+++OPENSOURCE_MUST_END
373 
380 
382 #define _FX_X86_ 1
383 
384 #define _FX_ARM_ 2
385 
386 #define _FX_POWERPC_ 3
387 
388 #define _FX_SPARC_ 4
389 
390 #define _FX_IA64_ 5
391 
392 #define _FX_MIPS_ 6
393 
394 #define _FX_X64_ 7
395 
396 #define _FX_ARM64_ 8
397 
398 #if defined(_FXM_PLATFORM_LINUX_JS_)
399 #define _FX_CPU_ _FX_X64_
400 #endif
401 
402 #if defined(_CHROME_PNACL_)
403  #define _FX_CPU_ _FX_X86_
404 #endif
405 /* CPU */
406 #ifndef _FX_CPU_
407  #if defined(__arm__) || defined(ARM) || defined(_ARM_) || defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__arm) || defined(arm9)
408  #define _FX_CPU_ _FX_ARM_
409  #elif defined(__arm64) || defined(__arm64__) || defined(__aarch64__)
410  #define _FX_CPU_ _FX_ARM64_
411  #elif defined(_M_IX86) || defined(__i386__)
412 
427  #define _FX_CPU_ _FX_X86_
428  #elif defined(_M_X64) || defined(__x86_64__)
429  #define _FX_CPU_ _FX_X64_
430  #elif defined(_M_IA64)
431  #define _FX_CPU_ _FX_IA64_
432  #elif defined(__POWERPC__)
433  #define _FX_CPU_ _FX_POWERPC_
434  #elif defined(__sparc__)
435  #define _FX_CPU_ _FX_SPARC_
436  #elif defined(MIPS) || defined(_MIPS_) || defined(__mips)
437  #define _FX_CPU_ _FX_MIPS_
438  #endif
439 #endif
440 #if !defined(_FX_CPU_) || _FX_CPU_ == 0
441  #error Sorry, can not figure out what CPU you are targeting to. Please specify _FX_CPU_ macro.
442 #endif
443 //<<<+++OPENSOURCE_MUST_END
444 
446 #ifdef _MSC_VER
447  #if _MSC_VER >= 1600
448  #define _FX_EMBEDFONT_PRINT_
449  #endif
450 #endif
451 
456 
457 //<<<+++OPENSOURCE_MUST_BEGIN
459 #define _FX_W32_ 1
460 
461 #define _FX_W64_ 2
462 
463 /* Word size or instruct length */
464 #ifndef _FX_WORDSIZE_
465 #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__)
466  #define _FX_WORDSIZE_ _FX_W64_
467  #else
468  #define _FX_WORDSIZE_ _FX_W32_
469  #endif
470 #endif
471 //<<<+++OPENSOURCE_MUST_END
472 
479 
481 #define _FX_BIG_ENDIAN_ 1
482 
483 #define _FX_LITTLE_ENDIAN_ 2
484 
485 /* Byte Order */
486 #ifndef _FX_ENDIAN_
487  #if _FX_CPU_ == _FX_POWERPC_ || _FX_CPU_ == _FX_SPARC_
488  #define _FX_ENDIAN_ _FX_BIG_ENDIAN_
489  #else
490 
499  #define _FX_ENDIAN_ _FX_LITTLE_ENDIAN_
500  #endif
501 #endif
502 
505 /* Include basic headers */
506 #include <stddef.h>
507 #include <stdarg.h>
508 #include <setjmp.h>
509 #include <float.h>
510 
511  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
512  #ifndef _FX_NO_ANSIC_
513  #include <stdlib.h>
514  #include <stdio.h>
515  #include <string.h>
516  #include <assert.h>
517  #if _FX_OS_ != _FX_VXWORKS_ && ((_FX_COMPILER_ == _FX_GCC_ && _FX_OS_ != _FX_SYMBIAN_) || _FX_COMPILER_ == _FX_NOKIA_X86_ || _FX_COMPILER_ == _FX_METROWERKS_ || _FX_COMPILER_ == _FX_IARCC_)
518  #include <wchar.h>
519  #endif
520  #endif
521  //<<<+++OPENSOURCE_MUST_END
522 
523 //<<<+++OPENSOURCE_MUST_BEGIN
524 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
525  #include <libkern/OSAtomic.h>
526  #if _FX_OS_ == _FX_MACOSX_
527  #include <Carbon/Carbon.h>
528  #elif _FX_OS_ == _FX_IOS_
529  #include <CoreText/CoreText.h>
530  #include <CoreGraphics/CoreGraphics.h>
531  #endif
532 #endif
533 //<<<+++OPENSOURCE_MUST_END
534 
535 #ifdef _UNICODE
536  #define GetObject GetObjectW
537  #define GetModuleFileName GetModuleFileNameW
538  #define GetFullPathName GetFullPathNameW
539 #else
540 
544  #define GetObject GetObjectA
545 
550  #define GetModuleFileName GetModuleFileNameA
551 
556  #define GetFullPathName GetFullPathNameA
557 #endif
558 
559 #if ( _FX_OS_ == _FX_IOS_ && (_FX_CPU_ == _FX_ARM_ || _FX_CPU_ == _FX_ARM64_)) || (_FX_OS_ == _FX_ANDROID_) || (_FX_OS_ == _FX_WIN32_MOBILE_)
560  #ifndef _FXCORE_LIMITED_MEMORY_
561  #define _FXCORE_LIMITED_MEMORY_
562  #endif
563  #ifndef _FXCORE_LIMITED_CPU_
564  #define _FXCORE_LIMITED_CPU_
565  #endif
566 #endif
567 
568 #if _FX_COMPILER_ == _FX_ADS_ || _FX_COMPILER_ == _FX_RVCT_ || _FX_COMPILER_ == _FX_TMS470_ || _FX_OS_ == _FX_ANDROID_
569  //#define _FX_NO_EXCEPTION_ //Removed by Malcolm J. Xue, Sep. 9th, 2010, should be defined outside
570  #define _FX_NO_NAMESPACE_
571 #endif
572 
577 
579 #define _FX_DEFAULT_TARGET_ 0
580 
581 #define _FX_BREW_ 1
582 
584 //<<<+++OPENSOURCE_MUST_END
585 
586 #if (((_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && (defined(_FX_WINAPI_PARTITION_DESKTOP_) || defined(_FX_WINAPI_PARTITION_APP_))) || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_)
587 #ifndef _FX_NO_SIMD_
588  #if !defined(_FXM_PLATFORM_LINUX_JS_) && !defined(_CHROME_PNACL_) && (_FX_CPU_ != _FX_ARM_) && (_FX_CPU_ != _FX_ARM64_)
589  #define _FXM_SIMD_
590  #endif
591 #endif
592 #endif
593 #if _FX_OS_ != _FX_MACOSX_
594  //#define _FXM_OPENMP_
595 #endif
596 
597 #ifndef _FX_NO_OPENSSL_
598  #define _FX_NO_OPENSSL_
599 #endif
600 
601 #if (((_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && defined(_FX_WINAPI_PARTITION_DESKTOP_)) || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_)
602 #ifndef _FX_NO_JPEG_TURBO_
603  #if !defined(_FXM_PLATFORM_LINUX_JS_) && !defined(_CHROME_PNACL_)
604  #define _FX_JPEG_TURBO_
605  #endif
606 #endif
607 #ifndef _FX_NO_OPENSSL_
608  #define _FXM_OPENSSL_
609 #endif
610  #define _FX_LARGEFILE_SUPPORT_
611 #ifndef _FX_NO_SIMD_
612  #define WITH_SIMD
613 #endif
614  #define _FPDF_STREAM_RENDER_
615 #ifndef _FX_ENABLE_OVERPRINT_
616  #define _FX_ENABLE_OVERPRINT_
617 #endif
618 #endif
619 
620 #ifdef _FX_WINAPI_PARTITION_APP_
621 #define _FPDF_STREAM_RENDER_
622 #endif
623 //<<<+++OPENSOURCE_MUST_END
624 
625 //<<<+++OPENSOURCE_MUST_BEGIN
626 #ifdef __cplusplus
627 extern "C" {
628 #endif
629 //<<<+++OPENSOURCE_MUST_END
630 
636 typedef void* FX_LPVOID;
638 typedef void const* FX_LPCVOID;
640 typedef void* FX_POSITION;
641 
643 typedef signed char FX_INT8;
645 typedef unsigned char FX_UINT8;
647 typedef unsigned char FX_BYTE;
649 typedef unsigned char* FX_LPBYTE;
651 typedef unsigned char const* FX_LPCBYTE;
653 typedef short FX_INT16;
655 typedef unsigned short FX_UINT16;
657 typedef short FX_SHORT;
659 typedef unsigned short FX_WORD;
661 typedef unsigned short* FX_LPWORD;
663 typedef unsigned short const* FX_LPCWORD;
665 typedef int FX_INT32;
667 typedef float FX_FLOAT;
668 #ifdef __cplusplus
669 
670 typedef bool FX_BOOL;
671 #else
672 
673 typedef int FX_BOOL;
674 #endif
675 
676 typedef int FX_ERR;
678 #define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0)
679 
680 #define FX_FAILED(Status) ((FX_ERR)(Status) < 0)
681 
683 typedef char FX_CHAR;
685 typedef char* FX_LPSTR;
687 typedef char const* FX_LPCSTR;
688 
689  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
699  #if !defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_)
700 
701  typedef unsigned int FX_DWORD;
703  typedef unsigned int* FX_LPDWORD;
704  #else
705 
706  typedef unsigned long FX_DWORD;
708  typedef unsigned long* FX_LPDWORD;
709  #endif
710 
712  typedef wchar_t FX_WCHAR;
714  typedef wchar_t* FX_LPWSTR;
716  typedef wchar_t const* FX_LPCWSTR;
717 
718  #ifdef _MSC_VER
719 
720  typedef __int64 FX_INT64;
722  typedef unsigned __int64 FX_UINT64;
723  #else
724  typedef long long int FX_INT64;
725  typedef unsigned long long FX_UINT64;
726  #endif
727 
728  #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
729 
730  typedef INT_PTR FX_INTPTR;
732  typedef UINT_PTR FX_UINTPTR;
733  #else
734  #if (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_)
735  typedef FX_INT64 FX_INTPTR;
736  typedef FX_UINT64 FX_UINTPTR;
737  #else
738  typedef int FX_INTPTR;
739  typedef unsigned int FX_UINTPTR;
740  #endif
741  #endif
742  //<<<+++OPENSOURCE_MUST_END
743 
744 //<<<+++OPENSOURCE_MUST_BEGIN
748 typedef FX_UINT64 FX_QWORD;
749 
751 #define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name;
752 
753 #if defined(DEBUG) && !defined(_DEBUG)
754  #define _DEBUG
755 #endif
756 
757 #ifndef __cplusplus
758 #ifndef TRUE
759 
760  #define TRUE 1
761 #endif
762 
763 #ifndef FALSE
764 
765  #define FALSE 0
766 #endif
767 #endif
768 
769 #ifndef NULL
770 
771  #define NULL 0
772 #endif
773 //<<<+++OPENSOURCE_MUST_END
774 
775 /* Assertion */
776 
777  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
778  #if !defined(_FX_NO_ANSIC_)
779 
783  #define FXSYS_assert assert
784  #else
785  void FXSYS_assert(int condition);
786  #endif
787  //<<<+++OPENSOURCE_MUST_END
788 
789 //<<<+++OPENSOURCE_MUST_BEGIN
790 #ifndef ASSERT
791  #ifdef _DEBUG
792  #define ASSERT FXSYS_assert
793  #else
794 
798  #define ASSERT(a)
799  #endif
800 #endif
801 
803 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
804 
805 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
806 
808 #define FX_PI 3.1415926535897932384626433832795f
809 
811 #if _FX_WORDSIZE_ == _FX_W64_ && _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
812  #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffffffffffL
813 #else
814  #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffL
815 #endif
816 
817 //<<<+++OPENSOURCE_MUST_END
818 
825 
826  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
827  #if !defined(_FX_NO_ANSIC_)
828 
832  #define FXSYS_sprintf sprintf
833 
834  #ifdef _WIN32
835 
839  #define FXSYS_snprintf _snprintf
840 
844  #define FXSYS_vsnprintf _vsnprintf
845  #else
846 
850  #define FXSYS_snprintf snprintf
851 
855  #define FXSYS_vsnprintf vsnprintf
856  #endif
857 
861  #define FXSYS_vsprintf vsprintf
862 
866  #define FXSYS_strchr strchr
867 
871  #define FXSYS_strlen strlen
872 
876  #define FXSYS_strncmp strncmp
877 
881  #define FXSYS_strcmp strcmp
882 
886  #define FXSYS_strcpy strcpy
887 
891  #define FXSYS_strncpy strncpy
892 
896  #define FXSYS_strstr strstr
897  #else
898  int FXSYS_sprintf(char* buffer, const char* format, ...);
899  int FXSYS_vsprintf(char *buffer, const char *format, va_list args);
900  char* FXSYS_strchr(const char* str, int ch);
901  long FXSYS_strlen(const char* str);
902  int FXSYS_strncmp(const char* str1, const char* str2, size_t len);
903  int FXSYS_strcmp(const char* str1, const char* str2);
904  char* FXSYS_strcpy(char* dest, const char* src);
905  char* FXSYS_strncpy(char* dest, const char* src, size_t len);
906  char* FXSYS_strstr(const char *string, const char *strFind);
907  #endif
908  //<<<+++OPENSOURCE_MUST_END
909 
916  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
917  #if !defined(_FX_NO_ANSIC_)
918 
922  #define FXSYS_FILE FILE
923 
927  #define FXSYS_fopen fopen
928 
932  #define FXSYS_fclose fclose
933 
937  #define FXSYS_SEEK_END SEEK_END
938 
942  #define FXSYS_SEEK_SET SEEK_SET
943 
947  #define FXSYS_fseek fseek
948 
952  #define FXSYS_ftell ftell
953 
957  #define FXSYS_fread fread
958 
962  #define FXSYS_fwrite fwrite
963 
967  #define FXSYS_fprintf fprintf
968 
972  #define FXSYS_fflush fflush
973  #else
974  #define FXSYS_FILE void
975  FXSYS_FILE* FXSYS_fopen(const char* filename, const char* mode);
976  int FXSYS_fclose(FXSYS_FILE*);
977  #define FXSYS_SEEK_END 2
978  #define FXSYS_SEEK_SET 0
979  int FXSYS_fseek(FXSYS_FILE*, long, int);
980  long FXSYS_ftell(FXSYS_FILE*);
981  size_t FXSYS_fread(void*, size_t, size_t, FXSYS_FILE*);
982  long FXSYS_fwrite(const void*, long, long, FXSYS_FILE*);
983  int FXSYS_fprintf(FXSYS_FILE*, const char*, ...);
984  int FXSYS_fflush(FXSYS_FILE*);
985  #endif
986 
987  // For now, we provide wide-string file name support for Windows only
988  #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
989 
993  #ifdef _NATIVE_WCHAR_T_DEFINED
994  #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m))
995  #else
996  #define FXSYS_wfopen _wfopen
997  #endif
998  #else
999  FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode);
1000  #endif
1001 
1008 
1009  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1010  /* Basic wide string operations, not available in ADS/RVCT/PACC/Android/MIPS_SDE */
1011  #if _FX_OS_ != _FX_VXWORKS_ && _FX_OS_ != _FX_ANDROID_ && !defined(_FX_NO_ANSIC_) && _FX_COMPILER_ != _FX_ADS_ && _FX_COMPILER_ != _FX_RVCT_ && _FX_COMPILER_ != _FX_PACC_ && _FX_COMPILER_ != _FX_TMS470_ && _FX_COMPILER_ != _FX_MIPS_SDE_
1012  #ifdef _NATIVE_WCHAR_T_DEFINED
1013  #define FXSYS_wcslen(str) wcslen((wchar_t*)(str))
1014  #define FXSYS_wcscmp(str1, str2) wcscmp((wchar_t*)(str1), (wchar_t*)(str2))
1015  #else
1016 
1020  #define FXSYS_wcslen wcslen
1021 
1025  #define FXSYS_wcscmp wcscmp
1026  #endif
1027  #else
1028  size_t FXSYS_wcslen(const wchar_t*);
1029  int FXSYS_wcscmp(const wchar_t*, const wchar_t*);
1030  #endif
1031 
1032  /* Some other wide string functions, not available in ADS/RVCT/GCCE/PACC/Android/MIPS_SDE */
1033  #if _FX_OS_ != _FX_VXWORKS_ && _FX_OS_ != _FX_ANDROID_ && !defined(_FX_NO_ANSIC_) && _FX_COMPILER_ != _FX_ADS_ && _FX_COMPILER_ != _FX_RVCT_ && !(_FX_COMPILER_ == _FX_GCC_ && _FX_OS_ == _FX_SYMBIAN_) && _FX_COMPILER_ != _FX_PACC_ && _FX_COMPILER_ != _FX_TMS470_ && _FX_COMPILER_ != _FX_MIPS_SDE_
1034  #ifdef _NATIVE_WCHAR_T_DEFINED
1035  #define FXSYS_wcschr(str, ch) (FX_LPCWSTR)wcschr((wchar_t*)(str), ch)
1036  #define FXSYS_wcsstr(str1, str2) (FX_LPCWSTR)wcsstr((wchar_t*)(str1), (wchar_t*)(str2))
1037  #define FXSYS_wcsncmp(str1, str2, n) wcsncmp((wchar_t*)(str1), (wchar_t*)(str2), n)
1038  #else
1039 
1043  #define FXSYS_wcschr wcschr
1044 
1048  #define FXSYS_wcsstr wcsstr
1049 
1053  #define FXSYS_wcsncmp wcsncmp
1054  #endif
1055 
1059  #define FXSYS_vswprintf vswprintf
1060  #else
1061  wchar_t* FXSYS_wcschr(const wchar_t*, wchar_t);
1062  wchar_t* FXSYS_wcsstr(const wchar_t*, const wchar_t*);
1063  int FXSYS_wcsncmp(const wchar_t*, const wchar_t*, size_t);
1064  #if _FX_OS_ != _FX_ANDROID_
1065  int FXSYS_vswprintf(wchar_t*, const wchar_t*, va_list);
1066  #else
1067  #define FXSYS_vswprintf vswprintf
1068  #endif
1069  #endif
1070 
1071  #if !defined(_FX_NO_ANSIC_) && _FX_COMPILER_ != _FX_TMS470_
1072 
1076  #define FXSYS_mbstowcs mbstowcs
1077 
1081  #define FXSYS_wcstombs wcstombs
1082  #else
1083  size_t FXSYS_mbstowcs(wchar_t *dest, const char *src, size_t n);
1084  size_t FXSYS_wcstombs(char *dest, const wchar_t *src, size_t n);
1085  #endif
1086  //<<<+++OPENSOURCE_MUST_END
1087 
1090  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1095 
1096  #if !defined(_FX_NO_ANSIC_)
1097 
1101  #define FXSYS_memcmp memcmp
1102 
1106  #define FXSYS_memcpy memcpy
1107 
1113  #define FXSYS_memmove memmove
1114 
1118  #define FXSYS_memset memset
1119 
1123  #define FXSYS_memchr memchr
1124  #else
1125  int FXSYS_memcmp(const void*, const void*, size_t);
1126  void* FXSYS_memcpy(void*, const void*, size_t);
1127  void* FXSYS_memmove(void*, const void*, size_t);
1128  void* FXSYS_memset(void*, int, size_t);
1129  void* FXSYS_memchr(const void*, int, size_t);
1130  #endif
1131 
1134  /* Others */
1135  #if !defined(_FX_NO_ANSIC_)
1136 
1140  #define FXSYS_qsort qsort
1141  #else
1142  void FXSYS_qsort(void*, unsigned, unsigned, int (*)(const void*, const void*));
1143  #endif
1144 
1145  #if _FX_OS_ != _FX_WIN32_MOBILE_ && !defined(_FX_NO_ANSIC_) && _FX_OS_ != _FX_SYMBIAN_
1146 
1150  #define FXSYS_bsearch bsearch
1151  #else
1152  /* WinCE doesn't support bsearch. The bsearch function comes with Symbian also has crash problem. */
1153  void * FXSYS_bsearch(const void *key, const void *base, size_t num, size_t width, int (*compare)(const void *, const void *));
1154  #endif
1155 
1156  #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1157  /* On Windows platform, we can replace more system calls */
1158 
1163  #define FXSYS_itoa _itoa
1164 
1168  #define FXSYS_strlwr _strlwr
1169 
1173  #define FXSYS_strupr _strupr
1174 
1178  #define FXSYS_stricmp _stricmp
1179 
1180  #ifdef _NATIVE_WCHAR_T_DEFINED
1181  #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
1182  #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
1183  #define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
1184  #define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
1185  #define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
1186  #else
1187 
1191  #define FXSYS_wcsicmp _wcsicmp
1192 
1196  #define FXSYS_WideCharToMultiByte WideCharToMultiByte
1197 
1201  #define FXSYS_MultiByteToWideChar MultiByteToWideChar
1202 
1206  #define FXSYS_wcslwr _wcslwr
1207 
1211  #define FXSYS_wcsupr _wcsupr
1212  #endif
1213 
1214  #ifndef _FX_WINAPI_PARTITION_DESKTOP_
1215  int FXSYS_IntersectRect(struct FX_RECT*, const struct FX_RECT*, const struct FX_RECT*);
1216  int FXSYS_GetACP(void);
1217  FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1218  FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1219  #else
1220 
1224  #define FXSYS_GetFullPathName GetFullPathName
1225 
1229  #define FXSYS_GetModuleFileName GetModuleFileName
1230 
1234  #define FXSYS_GetACP GetACP
1235  #endif
1236  #else
1237  char* FXSYS_itoa(int value, char* string, int radix);
1238  int FXSYS_GetACP(void);
1239  int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
1240  char* buf, int buflen, const char* default_str, int* pUseDefault);
1241  int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
1242  wchar_t* buf, int buflen);
1243  FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1244  FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1245 
1246  char* FXSYS_strlwr(char* str);
1247  char* FXSYS_strupr(char* str);
1248  int FXSYS_stricmp(const char*, const char*);
1249  int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
1250 
1251  wchar_t* FXSYS_wcslwr(wchar_t* str);
1252  wchar_t* FXSYS_wcsupr(wchar_t* str);
1253  #endif
1254  //<<<+++OPENSOURCE_MUST_END
1255 
1256  //*****************************************************************************
1257  //* Memory utilities
1258  //*****************************************************************************
1263 
1276  void* FXSYS_memcpy32(void* dst, const void* src, size_t size);
1277 
1294  FX_INT32 FXSYS_memcmp32(const void* buf1, const void* buf2, size_t size);
1295 
1307  void* FXSYS_memset32(void* dst, FX_INT32 v, size_t size);
1308 
1320  void* FXSYS_memset8(void* dst, FX_BYTE v, size_t size);
1321 
1331  void* FXSYS_memmove32(void* dst, const void* src, size_t size);
1333 //<<<+++OPENSOURCE_MUST_END
1334 
1335 //<<<+++OPENSOURCE_MUST_BEGIN
1336 #ifdef __cplusplus
1337 }
1338 #endif
1339 //<<<+++OPENSOURCE_MUST_END
1340 
1341  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1346 
1347  #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_METROWERKS_
1348  #ifdef __cplusplus
1349  extern "C" {
1350  #endif
1351 
1352  /* Metrowerks for Palm OS (9.3) doesn't support standard math.h */
1353  extern double __ieee754_pow(double, double);
1354  extern double __ieee754_sqrt(double);
1355  extern double __fabs(double);
1356  extern double __ieee754_atan2(double, double);
1357  extern double __ceil(double);
1358  extern double __floor(double);
1359  extern double __cos(double);
1360  extern double __ieee754_acos(double);
1361  extern double __sin(double);
1362  extern double __ieee754_log(double);
1363  extern double __ieee754_log10(double);
1364 
1365  #define FXSYS_pow(x, y) __ieee754_pow(x, y)
1366  #define FXSYS_sqrt(x) __ieee754_sqrt(x)
1367  #define FXSYS_fabs(x) __fabs(x)
1368  #define FXSYS_atan2(x, y) __ieee754_atan2(x, y)
1369  #define FXSYS_ceil(x) __ceil(x)
1370  #define FXSYS_floor(x) __floor(x)
1371  #define FXSYS_cos(x) __cos(x)
1372  #define FXSYS_acos(x) __ieee754_acos(x)
1373  #define FXSYS_sin(x) __sin(x)
1374  #define FXSYS_log(x) __ieee754_log(x)
1375  #define FXSYS_log10(x) __ieee754_log10(x)
1376 
1377  #ifdef __cplusplus
1378  }
1379  #endif
1380  #else
1381  #include <math.h>
1382  #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || _FX_OS_ == _FX_LINUX_DESKTOP_
1383 
1387  #define FXSYS_pow powf
1388 
1392  #define FXSYS_sqrt sqrtf
1393 
1397  #define FXSYS_fabs fabsf
1398 
1402  #define FXSYS_atan2 atan2f
1403 
1407  #define FXSYS_ceil ceilf
1408 
1412  #define FXSYS_floor floorf
1413 
1417  #define FXSYS_cos cosf
1418 
1422  #define FXSYS_acos acosf
1423 
1427  #define FXSYS_sin sinf
1428 
1432  #define FXSYS_log logf
1433 
1437  #define FXSYS_log10 log10f
1438 
1442  #define FXSYS_fmod fmodf
1443  #else
1444  #define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
1445  #define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
1446  #define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
1447  #define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
1448  #define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
1449  #define FXSYS_floor(a) (FX_FLOAT)floor(a)
1450  #define FXSYS_cos(a) (FX_FLOAT)cos(a)
1451  #define FXSYS_acos(a) (FX_FLOAT)acos(a)
1452  #define FXSYS_sin(a) (FX_FLOAT)sin(a)
1453  #define FXSYS_log(a) (FX_FLOAT)log(a)
1454  #define FXSYS_log10(a) (FX_FLOAT)log10(a)
1455  #define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
1456  #endif
1457  #endif
1458 
1459  #if !defined(_FX_NO_ANSIC_)
1460 
1464  #define FXSYS_abs abs
1465  #else
1466  #define FXSYS_abs(a) ((a)<0?-(a):(a))
1467  #endif
1468 
1470  //<<<+++OPENSOURCE_MUST_END
1471 
1472 //<<<+++OPENSOURCE_MUST_BEGIN
1473 #ifdef __cplusplus
1474 extern "C" {
1475 #endif
1476 //<<<+++OPENSOURCE_MUST_END
1477 
1478  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1479  #ifdef _FX_NO_GLOBAL_
1480  /* If platform doesn't support global variable, then we have to get from static functions */
1482  void FXSYS_SetStaticPointer1(void*);
1484  void* FXSYS_GetStaticPointer1(void);
1486  void FXSYS_SetStaticPointer2(void*);
1488  void* FXSYS_GetStaticPointer2(void);
1489  #endif
1490 
1491  /* CPU byte order */
1492  #if _FX_ENDIAN_ == _FX_BIG_ENDIAN_
1493  #define _FX_MSB_FIRST_
1494  #define FXDWORD_FROM_LSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1495  #define FXDWORD_FROM_MSBFIRST(i) (i)
1496  #else
1497  #define _FX_LSB_FIRST_
1498  #define FXDWORD_FROM_LSBFIRST(i) (i)
1499  #define FXDWORD_FROM_MSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1500  #endif
1501 
1502  #if _FX_CPU_ == _FX_X86_ || _FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_ARM64_
1503  #define FXDWORD_GET_LSBFIRST(p) (*(FX_DWORD*)(p))
1504  #else
1505  #define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0]))
1506  #endif
1507 
1508 #define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3]))
1509 
1510 #define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8))
1511 #define FXSYS_LOBYTE(word) ((FX_BYTE)(word))
1512 #define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
1513 #define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
1514 
1516 #define FXSYS_strtol strtol
1517 
1541 FX_INT64 FXSYS_atoi64(FX_LPCSTR str);
1549 FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str);
1559 FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix);
1569 FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix);
1577 int FXSYS_round(FX_FLOAT f);
1579 #define FXSYS_Mul(a, b) ((a) * (b))
1580 
1581 #define FXSYS_Div(a, b) ((a) / (b))
1582 
1583 #define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
1584 
1585 #define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
1586 
1587 //*****************************************************************************
1588 //* Multiple thread controls
1589 //*****************************************************************************
1591 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1592  typedef CRITICAL_SECTION FX_MUTEX;
1593  FX_DEFINEHANDLE(FX_RWLOCK)
1594 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_
1595  #include <pthread.h>
1596  typedef pthread_mutex_t FX_MUTEX;
1597  #if _FX_OS_ == _FX_ANDROID_
1598  FX_DEFINEHANDLE(FX_RWLOCK)
1599  #else
1600  typedef pthread_rwlock_t FX_RWLOCK;
1601  #endif
1602 #else
1604  FX_DEFINEHANDLE(FX_RWLOCK)
1605 #endif
1606 // The following five functions are defined in fx_process.h, please refer there.
1608 void FX_Mutex_Destroy(FX_MUTEX* pMutex);
1610 void FX_Mutex_Lock(FX_MUTEX* pMutex);
1611 void FX_Mutex_Unlock(FX_MUTEX* pMutex);
1612 
1613 #define FX_CRITICAL_SECTION FX_MUTEX
1614 #define FX_InitializeCriticalSection(a) FX_Mutex_Initialize(a)
1615 #define FX_DeleteCriticalSection(a) FX_Mutex_Destroy(a)
1616 #define FX_TryEnterCriticalSection(a) FX_Mutex_TryLock(a)
1617 #define FX_EnterCriticalSection(a) FX_Mutex_Lock(a)
1618 #define FX_LeaveCriticalSection(a) FX_Mutex_Unlock(a)
1619 
1621 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1622  typedef void* FX_SPINLOCK;
1623 #elif _FX_OS_ == _FX_LINUX_DESKTOP_
1624  #ifdef _FX_SPINLOCK_USEGCCCAS_
1625  typedef size_t FX_SPINLOCK;
1626  #else
1627 #ifndef _CHROME_PNACL_
1628  typedef pthread_spinlock_t FX_SPINLOCK;
1629 #else
1630  typedef size_t FX_SPINLOCK;
1631 #endif
1632  #endif
1633 #elif _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
1634  typedef OSSpinLock FX_SPINLOCK;
1635 #else // android/embeded linux/other os
1637 #endif
1638 //<<<+++OPENSOURCE_MUST_END
1639 
1640 //<<<+++OPENSOURCE_MUST_BEGIN
1641 #ifdef __cplusplus
1642 };
1643 #endif
1644 //<<<+++OPENSOURCE_MUST_END
1645 
1646 #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_PACC_
1647  #include <errtrycatch.h>
1648  #define setjmp ErrSetJump
1649  #define longjmp ErrLongJump
1650  #define jmp_buf ErrJumpBuf
1651 #else
1652  #include <setjmp.h>
1653 #endif
1654 
1655 #if _FX_OS_ == _FX_MACOSX_
1656  #include <Carbon/Carbon.h>
1657 #elif _FX_OS_ == _FX_IOS_
1658  #include <CoreText/CoreText.h>
1659  #include <CoreGraphics/CoreGraphics.h>
1660 #endif
1661 //<<<+++OPENSOURCE_MUST_END
1662 //<<<+++OPENSOURCE_MUST_BEGIN
1663 #endif /* _FPDF_SYSTEM_H_ */
1664 //<<<+++OPENSOURCE_MUST_END
1665 
1668 //<<<+++OPENSOURCE_END
void * FXSYS_memset8(void *dst, FX_BYTE v, size_t size)
Set buffer data to specified value.
FX_BOOL FX_Mutex_TryLock(FX_MUTEX *pMutex)
Try to lock a mutex.
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:636
FX_BOOL FX_Mutex_Initialize(FX_MUTEX *pMutex)
Initialize a mutex.
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:712
#define FXSYS_wcslwr
Convert a wide-character string to lowercase.
Definition: fx_system.h:1206
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:706
#define FXSYS_mbstowcs
Converts a sequence of multi-byte characters to a corresponding sequence of wide characters.
Definition: fx_system.h:1076
FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix)
Convert an integer to an wide string.
#define FXSYS_fwrite
Writes data to a file.
Definition: fx_system.h:962
#define FXSYS_fprintf
Print formatted data to a file.
Definition: fx_system.h:967
FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix)
Convert an integer to an ANSI string.
#define FXSYS_wcsncmp
Compare characters of two wide-character strings.
Definition: fx_system.h:1053
#define FXSYS_FILE
File structure.
Definition: fx_system.h:922
void const * FX_LPCVOID
Pointer to any constant type.
Definition: fx_system.h:638
int FXSYS_round(FX_FLOAT f)
Get nearest integer.
#define FXSYS_strcpy
Copy an ANSIC string.
Definition: fx_system.h:886
#define FXSYS_fflush
Flush file.
Definition: fx_system.h:972
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:746
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:716
#define FXSYS_GetFullPathName
Get the full path and file name of a specified file.
Definition: fx_system.h:1224
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:871
#define FXSYS_wcsupr
Convert a wide-character string to uppercase.
Definition: fx_system.h:1211
#define FXSYS_strncpy
Copy an ANSIC string with length limitation.
Definition: fx_system.h:891
#define FXSYS_wcschr
Find a wide-character in a wide-character string.
Definition: fx_system.h:1043
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:685
#define FXSYS_wfopen
Open a file using wide-string parameters. Only supported on Windows platforms now.
Definition: fx_system.h:996
#define FXSYS_memmove
Moves one buffer to another. If some regions of the source area and the destination overlap,...
Definition: fx_system.h:1113
CRITICAL_SECTION FX_MUTEX
Definition for mutex/critical section and read-write lock.
Definition: fx_system.h:1592
#define FXSYS_memcpy
Copy from one buffer to another.
Definition: fx_system.h:1106
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:640
#define FXSYS_vswprintf
Write formatted output wide character string using a pointer to a list of arguments.
Definition: fx_system.h:1059
#define FXSYS_itoa
Convert an integer to a ANSIC string.
Definition: fx_system.h:1163
FX_INT64 FXSYS_atoi64(FX_LPCSTR str)
Convert an ANSI string to an integer.
#define FXSYS_strchr
Find a character in a ANSIC string.
Definition: fx_system.h:866
#define FXSYS_strlwr
Convert a ANSIC string to lowercase.
Definition: fx_system.h:1168
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:665
#define FXSYS_GetModuleFileName
Get the fully-qualified path for specified module.
Definition: fx_system.h:1229
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
#define FXSYS_memcmp
Compares two buffers.
Definition: fx_system.h:1101
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:673
unsigned short * FX_LPWORD
Pointer to a WORD.
Definition: fx_system.h:661
#define FXSYS_fseek
Moves the file pointer to a specified location.
Definition: fx_system.h:947
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:687
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1020
FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str)
Convert a wide string to an integer.
signed char FX_INT8
Signed 8bits integer.
Definition: fx_system.h:643
#define FXSYS_wcscmp
Compare wide-character strings.
Definition: fx_system.h:1025
#define FXSYS_GetACP
Retrieve the current ANSI code-page identifier for the system.
Definition: fx_system.h:1234
FX_INT32 FXSYS_wtoi(FX_LPCWSTR str)
Convert a wide string to an integer.
#define FXSYS_fread
Reads data from a file.
Definition: fx_system.h:957
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:732
#define FXSYS_qsort
Performs a quick sort. A generic algorithm.
Definition: fx_system.h:1140
#define FXSYS_wcsicmp
Compare two wide character strings. case-insensitive.
Definition: fx_system.h:1191
void * FX_SPINLOCK
Definition for spinlock.
Definition: fx_system.h:1622
unsigned long * FX_LPDWORD
Pointer to a DWORD.
Definition: fx_system.h:708
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:657
#define FXSYS_fopen
Open a file.
Definition: fx_system.h:927
#define FXSYS_bsearch
Performs a binary search of a sorted array. A generic algorithm.
Definition: fx_system.h:1150
#define FXSYS_MultiByteToWideChar
Maps a character string to a wide-character string.
Definition: fx_system.h:1201
void FX_Mutex_Destroy(FX_MUTEX *pMutex)
Destroy a mutex.
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:649
#define FXSYS_strstr
Find a substring.
Definition: fx_system.h:896
#define FXSYS_wcsstr
Find a sub-wide-character-string.
Definition: fx_system.h:1048
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:683
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:667
#define FXSYS_assert
Assertion.
Definition: fx_system.h:783
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:655
#define FXSYS_memchr
Search for a byte in a memory block.
Definition: fx_system.h:1123
#define FXSYS_strcmp
Compare ANSIC strings.
Definition: fx_system.h:881
#define FXSYS_WideCharToMultiByte
Maps a wide-character string to a character string.
Definition: fx_system.h:1196
Definition: fx_coordinates.h:590
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:645
unsigned short const * FX_LPCWORD
Pointer to a WORD.
Definition: fx_system.h:663
#define FXSYS_fclose
Close a file.
Definition: fx_system.h:932
void FX_Mutex_Unlock(FX_MUTEX *pMutex)
Unlock a mutex.
#define FXSYS_ftell
Gets the current position of a file pointer.
Definition: fx_system.h:952
#define FXSYS_stricmp
Compare two ANSIC strings. case-insensitive.
Definition: fx_system.h:1178
#define FXSYS_strncmp
Compare characters of two ANSIC strings.
Definition: fx_system.h:876
void FX_Mutex_Lock(FX_MUTEX *pMutex)
Lock a mutex.
unsigned short FX_WORD
16-bit unsigned integer.
Definition: fx_system.h:659
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:653
#define FXSYS_memset
Use given character to initialize the buffer.
Definition: fx_system.h:1118
FX_INT32 FXSYS_atoi(FX_LPCSTR str)
Convert an ANSI string to an integer.
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:651
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:714
#define FXSYS_sprintf
Write formatted data to a ANSIC string.
Definition: fx_system.h:832
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:751
#define FXSYS_wcstombs
Converts a sequence of wide characters to a corresponding sequence of multi-byte characters.
Definition: fx_system.h:1081
#define FXSYS_vsprintf
Write formatted output using a pointer to a list of arguments.
Definition: fx_system.h:861
void * FXSYS_memmove32(void *dst, const void *src, size_t size)
Move source buffer data into destination.
#define FXSYS_strupr
Convert a ANSIC string to uppercase.
Definition: fx_system.h:1173
void * FXSYS_memcpy32(void *dst, const void *src, size_t size)
Copy buffer data from source to destination.
FX_UINT64 FX_QWORD
unsigned quad-word integer.
Definition: fx_system.h:748
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:730
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:647
int FX_ERR
Error indicator.
Definition: fx_system.h:676