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 #if defined(_FXM_PLATFORM_LINUX_JS_) || defined(_CHROME_PNACL_)
160  #define _FX_OS_ _FX_LINUX_DESKTOP_
161  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
162 #endif
163 
164 /* OS */
165 
166 #ifndef _FX_OS_
167  #if defined(__SYMBIAN32__) || defined(__symbian__)
168  #define _FX_OS_ _FX_SYMBIAN_
169  #elif defined(_WIN32_WCE)
170  #define _FX_OS_ _FX_WIN32_MOBILE_
171  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
172  #if defined (_WIN32_WCE) && (_WIN32_WCE == 0x600)
173  #define UNSUPPORT_CPP0X
174  #endif
175  #elif defined(__linux__) || defined(__native_client__)
176  #if (defined(__arm__) || defined(__aarch64__)) && (!defined(OS_CHROMEOS))
177  #define _FX_OS_ _FX_LINUX_EMBEDDED_
178  #else
179  #define _FX_OS_ _FX_LINUX_DESKTOP_
180  #endif
181  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
182  #elif defined(__NetBSD__)
183  #define _FX_OS_ _FX_NETBSD_
184  #elif defined(_WIN64)
185  #define _FX_OS_ _FX_WIN64_
186  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
187  #elif defined(_WIN32)
188  #define _FX_OS_ _FX_WIN32_DESKTOP_
189  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
190  #elif defined(__sparc__)
191  #define _FX_OS_ _FX_SOLARIS_
192  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
193  #elif defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__TMS470__)
194  #define _FX_OS_ _FX_EMBEDDED_
195  #elif defined(__APPLE__)
196  #include "TargetConditionals.h"
197  #if (defined(TARGET_OS_IPHONE) && TARGET_OS_IPHONE == 1) || (defined(TARGET_IPHONE_SIMULATOR) && TARGET_IPHONE_SIMULATOR == 1)
198  #define _FX_OS_ _FX_IOS_
199  #else
200  #define _FX_OS_ _FX_MACOSX_
201  #endif
202  #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
203  #elif defined(__ARM_EABI__)
204  #define _FX_OS_ _FX_EMBEDDED_
205  #endif
206 #else
207  #if _FX_OS_ == _FX_ANDROID_
208  #ifndef _FXM_PLATFORM_
209  #define _FXM_PLATFORM_ _FXM_PLATFORM_ANDROID_
210  #endif
211  #elif (_FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_ || _FX_OS_ == _FX_WIN32_DESKTOP_)
212  #ifndef _FXM_PLATFORM_
213  #define _FXM_PLATFORM_ _FXM_PLATFORM_WINDOWS_
214  #endif
215  #elif (_FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_MACOSX_)
216  #ifndef _FXM_PLATFORM_
217  #define _FXM_PLATFORM_ _FXM_PLATFORM_APPLE_
218  #endif
219  #elif _FX_OS_ == _FX_SOLARIS_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_LINUX_DESKTOP_
220  #ifndef _FXM_PLATFORM_
221  #define _FXM_PLATFORM_ _FXM_PLATFORM_LINUX_
222  #endif
223  #endif
224 #endif //_FX_OS_
225 
226 #if !defined(_FX_OS_) || _FX_OS_ == 0
227  #error Sorry, can not figure out what OS you are targeting to. Please specify _FX_OS_ macro.
228 #endif
229 
230 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
231 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
232 
233  #define _CRT_SECURE_NO_WARNINGS
234  #if defined(_MSC_VER) && _MSC_VER < 1300
235  #define _WIN32_WINNT 0x400
236  #endif
237  #if defined(_MSC_VER) && _MSC_VER < 1600
238  #define UNSUPPORT_CPP0X
239  #endif
240  #ifndef NOMINMAX
241  #define NOMINMAX
242  #endif
243  #include <windows.h>
244 
245  #ifdef WINAPI_FAMILY
246  #if (0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP) //Macros in Windows Kit/8
247  #define _FX_WIN8_
248  #else //Macros in Windows Kit/8.1
249  #define _FX_WIN81_
250  #endif //(0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP)
251 
252  #ifdef _FX_WIN8_
253  #if /*defined(WINAPI_FAMILY) && */((WINAPI_FAMILY&WINAPI_PARTITION_APP) == WINAPI_PARTITION_APP)
254 
255  #define _FX_WINAPI_PARTITION_APP_
256  #endif
257  #if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY&WINAPI_PARTITION_DESKTOP) == WINAPI_PARTITION_DESKTOP)
258 
259  #define _FX_WINAPI_PARTITION_DESKTOP_
260  #endif
261  #endif //_FX_WIN8_
262 
263  #ifdef _FX_WIN81_
264 
265  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
266 
267  #define _FX_WINAPI_PARTITION_APP_
268  #endif
269 
270  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
271 
272  #define _FX_WINAPI_PARTITION_PHONE_APP_
273  #endif
274 
275  #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
276 
277  #define _FX_WINAPI_PARTITION_DESKTOP_
278  #endif
279  #endif //_FX_WIN81_
280  #else // !defined(WINAPI_FAMILY)
281  #ifndef _WIN32_WCE
282  #define _FX_WINAPI_PARTITION_DESKTOP_
283  #endif
284  #endif //WINAPI_FAMILY
285 #endif //(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
286 //<<<+++OPENSOURCE_MUST_END
287 
294 
296 #define _FX_VC6_ 1
297 
298 #define _FX_VC7_ 2
299 
300 #define _FX_VC8_ 3
301 
302 #define _FX_GCC_ 4
303 
304 #define _FX_ADS_ 5
305 
306 #define _FX_RVCT_ 6
307 
308 #define _FX_IARCC_ 7
309 
310 #define _FX_NOKIA_X86_ 8
311 
312 #define _FX_METROWERKS_ 9
313 
314 #define _FX_PACC_ 10
315 
316 #define _FX_TMS470_ 11
317 
318 #define _FX_MIPS_SDE_ 12
319 
320 /* Compiler */
321 #ifndef _FX_COMPILER_
322  #ifdef _MSC_VER
323  #if _MSC_VER >= 1400
324  #define _FX_COMPILER_ _FX_VC8_
325  #elif _MSC_VER >= 1300
326  #define _FX_COMPILER_ _FX_VC7_
327  #else
328 
347  #define _FX_COMPILER_ _FX_VC6_
348  #endif
349  #elif defined(__GNUC__)
350  #define _FX_COMPILER_ _FX_GCC_
351  #elif defined(__ARMCC_VERSION)
352  #if __ARMCC_VERSION < 200000
353  #define _FX_COMPILER_ _FX_ADS_
354  #else
355  #define _FX_COMPILER_ _FX_RVCT_
356  #endif
357  #elif defined(__ICCARM__)
358  #define _FX_COMPILER_ _FX_IARCC_
359  #elif defined(_PACC_VER)
360  #define _FX_COMPILER_ _FX_PACC_
361  #elif defined(__TMS470__)
362  #define _FX_COMPILER_ _FX_TMS470_
363  #endif
364 #endif /* !_FX_COMPILER_ */
365 #if !defined(_FX_COMPILER_) || _FX_COMPILER_ == 0
366  #error Sorry, can not figure out what compiler you are using. Please specify _FX_COMPILER_ macro.
367 #endif
368 //<<<+++OPENSOURCE_MUST_END
369 
376 
378 #define _FX_X86_ 1
379 
380 #define _FX_ARM_ 2
381 
382 #define _FX_POWERPC_ 3
383 
384 #define _FX_SPARC_ 4
385 
386 #define _FX_IA64_ 5
387 
388 #define _FX_MIPS_ 6
389 
390 #define _FX_X64_ 7
391 
392 #define _FX_ARM64_ 8
393 
394 #define _FX_MIPS64_ 9
395 
396 #if defined(_FXM_PLATFORM_LINUX_JS_)
397 #define _FX_CPU_ _FX_X86_
398 #endif
399 
400 #if defined(_CHROME_PNACL_)
401  #define _FX_CPU_ _FX_X86_
402 #endif
403 /* CPU */
404 #ifndef _FX_CPU_
405  #if defined(__arm__) || defined(ARM) || defined(_ARM_) || defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__arm) || defined(arm9)
406  #define _FX_CPU_ _FX_ARM_
407  #elif defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_ARM64_)
408  #define _FX_CPU_ _FX_ARM64_
409  #elif defined(_M_IX86) || defined(__i386__)
410 
425  #define _FX_CPU_ _FX_X86_
426  #elif defined(_M_X64) || defined(__x86_64__)
427  #define _FX_CPU_ _FX_X64_
428  #elif defined(_M_IA64)
429  #define _FX_CPU_ _FX_IA64_
430  #elif defined(__POWERPC__)
431  #define _FX_CPU_ _FX_POWERPC_
432  #elif defined(__sparc__)
433  #define _FX_CPU_ _FX_SPARC_
434  #elif defined(__mips64)
435  #define _FX_CPU_ _FX_MIPS64_
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) || \
466  defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || \
467  __WORDSIZE == 64 || defined(__LP64__) || defined(__mips64)
468 #define _FX_WORDSIZE_ _FX_W64_
469 #else
470 #define _FX_WORDSIZE_ _FX_W32_
471 #endif
472 #endif
473 //<<<+++OPENSOURCE_MUST_END
474 
481 
483 #define _FX_BIG_ENDIAN_ 1
484 
485 #define _FX_LITTLE_ENDIAN_ 2
486 
487 /* Byte Order */
488 #ifndef _FX_ENDIAN_
489  #if _FX_CPU_ == _FX_POWERPC_ || _FX_CPU_ == _FX_SPARC_
490  #define _FX_ENDIAN_ _FX_BIG_ENDIAN_
491  #else
492 
501  #define _FX_ENDIAN_ _FX_LITTLE_ENDIAN_
502  #endif
503 #endif
504 
507 /* Include basic headers */
508 #include <stddef.h>
509 #include <stdarg.h>
510 #include <setjmp.h>
511 #include <float.h>
512 
513  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
514  #ifndef _FX_NO_ANSIC_
515  #include <stdlib.h>
516  #include <stdio.h>
517  #include <string.h>
518  #include <assert.h>
519  #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_)
520  #include <wchar.h>
521  #endif
522  #endif
523  //<<<+++OPENSOURCE_MUST_END
524 
525 //<<<+++OPENSOURCE_MUST_BEGIN
526 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
527  #include <libkern/OSAtomic.h>
528  #if _FX_OS_ == _FX_MACOSX_
529  #include <Carbon/Carbon.h>
530  #elif _FX_OS_ == _FX_IOS_
531  #include <CoreText/CoreText.h>
532  #include <CoreGraphics/CoreGraphics.h>
533  #endif
534 #endif
535 //<<<+++OPENSOURCE_MUST_END
536 
537 #ifdef _UNICODE
538  #define GetObject GetObjectW
539  #define GetModuleFileName GetModuleFileNameW
540  #define GetFullPathName GetFullPathNameW
541 #else
542 
546  #define GetObject GetObjectA
547 
552  #define GetModuleFileName GetModuleFileNameA
553 
558  #define GetFullPathName GetFullPathNameA
559 #endif
560 
561 #if ( _FX_OS_ == _FX_IOS_ && (_FX_CPU_ == _FX_ARM_ || _FX_CPU_ == _FX_ARM64_)) || (_FX_OS_ == _FX_ANDROID_) || (_FX_OS_ == _FX_WIN32_MOBILE_)
562  #ifndef _FXCORE_LIMITED_MEMORY_
563  #define _FXCORE_LIMITED_MEMORY_
564  #endif
565  #ifndef _FXCORE_LIMITED_CPU_
566  #define _FXCORE_LIMITED_CPU_
567  #endif
568 #endif
569 
570 #if _FX_COMPILER_ == _FX_ADS_ || _FX_COMPILER_ == _FX_RVCT_ || _FX_COMPILER_ == _FX_TMS470_ || _FX_OS_ == _FX_ANDROID_
571  //#define _FX_NO_EXCEPTION_ //Removed by Malcolm J. Xue, Sep. 9th, 2010, should be defined outside
572  #define _FX_NO_NAMESPACE_
573 #endif
574 
579 
581 #define _FX_DEFAULT_TARGET_ 0
582 
583 #define _FX_BREW_ 1
584 
586 //<<<+++OPENSOURCE_MUST_END
587 
588 #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_)
589 #ifndef _FX_NO_SIMD_
590 #if !defined(_FXM_PLATFORM_LINUX_JS_) && !defined(_CHROME_PNACL_) && (_FX_CPU_ != _FX_ARM_) && \
591  (_FX_CPU_ != _FX_ARM64_) && (_FX_CPU_ != _FX_MIPS_) && (_FX_CPU_ != _FX_MIPS64_)
592 #define _FXM_SIMD_
593 #endif
594 #endif
595 #endif
596 #if _FX_OS_ != _FX_MACOSX_
597  //#define _FXM_OPENMP_
598 #endif
599 
600 #ifndef _FX_NO_OPENSSL_
601  #define _FX_NO_OPENSSL_
602 #endif
603 
604 #if (((_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && defined(_FX_WINAPI_PARTITION_DESKTOP_)) || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_)
605 #ifndef _FX_NO_JPEG_TURBO_
606  #if !defined(_CHROME_PNACL_)
607  #define _FX_JPEG_TURBO_
608  #endif
609 #endif
610 #ifndef _FX_NO_OPENSSL_
611  #define _FXM_OPENSSL_
612 #endif
613  #define _FX_LARGEFILE_SUPPORT_
614 #ifndef _FX_NO_SIMD_
615  #define WITH_SIMD
616 #endif
617  #define _FPDF_STREAM_RENDER_
618 #ifndef _FX_ENABLE_OVERPRINT_
619  #define _FX_ENABLE_OVERPRINT_
620 #endif
621 #endif
622 
623 #if _FX_OS_ == _FX_LINUX_EMBEDDED_
624 #ifndef _FX_ENABLE_OVERPRINT_
625  #define _FX_ENABLE_OVERPRINT_
626 #endif
627 #endif
628 
629 #ifdef _FX_WINAPI_PARTITION_APP_
630 #define _FPDF_STREAM_RENDER_
631 #endif
632 //<<<+++OPENSOURCE_MUST_END
633 
634 //<<<+++OPENSOURCE_MUST_BEGIN
635 #ifdef __cplusplus
636 extern "C" {
637 #endif
638 //<<<+++OPENSOURCE_MUST_END
639 
645 typedef void* FX_LPVOID;
647 typedef void const* FX_LPCVOID;
649  typedef void* FX_POSITION;
650 
652 typedef signed char FX_INT8;
654 typedef unsigned char FX_UINT8;
656 typedef unsigned char FX_BYTE;
658 typedef unsigned char* FX_LPBYTE;
660 typedef unsigned char const* FX_LPCBYTE;
662 typedef short FX_INT16;
664 typedef unsigned short FX_UINT16;
666 typedef short FX_SHORT;
668 typedef unsigned short FX_WORD;
670 typedef unsigned short* FX_LPWORD;
672 typedef unsigned short const* FX_LPCWORD;
674 typedef int FX_INT32;
676 typedef float FX_FLOAT;
677 #ifdef __cplusplus
678 
679 typedef bool FX_BOOL;
680 #else
681 
682 typedef int FX_BOOL;
683 #endif
684 
685 typedef int FX_ERR;
687 #define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0)
688 
689 #define FX_FAILED(Status) ((FX_ERR)(Status) < 0)
690 
692 typedef char FX_CHAR;
694 typedef char* FX_LPSTR;
696 typedef char const* FX_LPCSTR;
697 
698  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
708  #if !defined(_MSC_VER) && (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_ || _FX_CPU_ == _FX_MIPS64_)
709 
710  typedef unsigned int FX_DWORD;
712  typedef unsigned int* FX_LPDWORD;
713  #else
714 
715  typedef unsigned long FX_DWORD;
717  typedef unsigned long* FX_LPDWORD;
718  #endif
719 
721  typedef wchar_t FX_WCHAR;
723  typedef wchar_t* FX_LPWSTR;
725  typedef wchar_t const* FX_LPCWSTR;
726 
727  #ifdef _MSC_VER
728 
729  typedef __int64 FX_INT64;
731  typedef unsigned __int64 FX_UINT64;
732  #else
733  typedef long long int FX_INT64;
734  typedef unsigned long long FX_UINT64;
735  #endif
736 
737  #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
738 
739  typedef INT_PTR FX_INTPTR;
741  typedef UINT_PTR FX_UINTPTR;
742  #else
743  #if (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_ || _FX_CPU_ == _FX_MIPS64_)
744  typedef FX_INT64 FX_INTPTR;
745  typedef FX_UINT64 FX_UINTPTR;
746  #else
747  typedef int FX_INTPTR;
748  typedef unsigned int FX_UINTPTR;
749  #endif
750  #endif
751  //<<<+++OPENSOURCE_MUST_END
752 
753 //<<<+++OPENSOURCE_MUST_BEGIN
758 
760 #define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name;
761 
762 #if defined(DEBUG) && !defined(_DEBUG)
763  #define _DEBUG
764 #endif
765 
766 #ifndef __cplusplus
767 #ifndef TRUE
768 
769  #define TRUE 1
770 #endif
771 
772 #ifndef FALSE
773 
774  #define FALSE 0
775 #endif
776 #endif
777 
778 #ifndef NULL
779 
780  #define NULL 0
781 #endif
782 //<<<+++OPENSOURCE_MUST_END
783 
784 /* Assertion */
785 
786  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
787  #if !defined(_FX_NO_ANSIC_)
788 
792  #define FXSYS_assert assert
793  #else
794  void FXSYS_assert(int condition);
795  #endif
796  //<<<+++OPENSOURCE_MUST_END
797 
798 //<<<+++OPENSOURCE_MUST_BEGIN
799 #ifndef ASSERT
800  #ifdef _DEBUG
801  #define ASSERT FXSYS_assert
802  #else
803 
807  #define ASSERT(a)
808  #endif
809 #endif
810 
812 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
813 
814 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
815 
817 #define FX_PI 3.1415926535897932384626433832795f
818 
820 #if _FX_WORDSIZE_ == _FX_W64_ && _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
821  #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffffffffffL
822 #else
823  #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffL
824 #endif
825 
826 //<<<+++OPENSOURCE_MUST_END
827 
834 
835  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
836  #if !defined(_FX_NO_ANSIC_)
837 
841  #define FXSYS_sprintf sprintf
842 
846  #ifdef _WIN32
847  #define FXSYS_snprintf _snprintf
848  #define FXSYS_vsnprintf _vsnprintf
849  #else
850  #define FXSYS_snprintf snprintf
851  #define FXSYS_vsnprintf vsnprintf
852  #endif
853 
857  #define FXSYS_vsprintf vsprintf
858 
862  #define FXSYS_strchr strchr
863 
867  #define FXSYS_strlen strlen
868 
872  #define FXSYS_strncmp strncmp
873 
877  #define FXSYS_strcmp strcmp
878 
882  #define FXSYS_strcpy strcpy
883 
887  #define FXSYS_strncpy strncpy
888 
892  #define FXSYS_strstr strstr
893  #else
894  int FXSYS_sprintf(char* buffer, const char* format, ...);
895  int FXSYS_vsprintf(char *buffer, const char *format, va_list args);
896  char* FXSYS_strchr(const char* str, int ch);
897  long FXSYS_strlen(const char* str);
898  int FXSYS_strncmp(const char* str1, const char* str2, size_t len);
899  int FXSYS_strcmp(const char* str1, const char* str2);
900  char* FXSYS_strcpy(char* dest, const char* src);
901  char* FXSYS_strncpy(char* dest, const char* src, size_t len);
902  char* FXSYS_strstr(const char *string, const char *strFind);
903  #endif
904  //<<<+++OPENSOURCE_MUST_END
905 
912  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
913  #if !defined(_FX_NO_ANSIC_) && !defined(__EMSCRIPTEN__)
914 
918  #define FXSYS_FILE FILE
919 
923  #define FXSYS_fopen fopen
924 
928  #define FXSYS_fclose fclose
929 
933  #define FXSYS_SEEK_END SEEK_END
934 
938  #define FXSYS_SEEK_SET SEEK_SET
939 
943  #define FXSYS_fseek fseek
944 
948  #define FXSYS_ftell ftell
949 
953  #define FXSYS_fread fread
954 
958  #define FXSYS_fwrite fwrite
959 
963  #define FXSYS_fprintf fprintf
964 
968  #define FXSYS_fflush fflush
969  #else
970  #define FXSYS_FILE void
971  FXSYS_FILE* FXSYS_fopen(const char* filename, const char* mode);
972  int FXSYS_fclose(FXSYS_FILE*);
973  #define FXSYS_SEEK_END 2
974  #define FXSYS_SEEK_SET 0
975  int FXSYS_fseek(FXSYS_FILE*, long, int);
976  long FXSYS_ftell(FXSYS_FILE*);
977  size_t FXSYS_fread(void*, size_t, size_t, FXSYS_FILE*);
978  long FXSYS_fwrite(const void*, long, long, FXSYS_FILE*);
979  int FXSYS_fprintf(FXSYS_FILE*, const char*, ...);
980  int FXSYS_fflush(FXSYS_FILE*);
981  #endif
982 
983  // For now, we provide wide-string file name support for Windows only
984  #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
985 
989  #ifdef _NATIVE_WCHAR_T_DEFINED
990  #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m))
991  #else
992  #define FXSYS_wfopen _wfopen
993  #endif
994  #else
995  FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode);
996  #endif
997 
1004 
1005  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1006  /* Basic wide string operations, not available in ADS/RVCT/PACC/Android/MIPS_SDE */
1007  #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_
1008  #ifdef _NATIVE_WCHAR_T_DEFINED
1009  #define FXSYS_wcslen(str) wcslen((wchar_t*)(str))
1010  #define FXSYS_wcscmp(str1, str2) wcscmp((wchar_t*)(str1), (wchar_t*)(str2))
1011  #else
1012 
1016  #define FXSYS_wcslen wcslen
1017 
1021  #define FXSYS_wcscmp wcscmp
1022  #endif
1023  #else
1024  size_t FXSYS_wcslen(const wchar_t*);
1025  int FXSYS_wcscmp(const wchar_t*, const wchar_t*);
1026  #endif
1027 
1028  /* Some other wide string functions, not available in ADS/RVCT/GCCE/PACC/Android/MIPS_SDE */
1029  #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_
1030  #ifdef _NATIVE_WCHAR_T_DEFINED
1031  #define FXSYS_wcschr(str, ch) (FX_LPCWSTR)wcschr((wchar_t*)(str), ch)
1032  #define FXSYS_wcsstr(str1, str2) (FX_LPCWSTR)wcsstr((wchar_t*)(str1), (wchar_t*)(str2))
1033  #define FXSYS_wcsncmp(str1, str2, n) wcsncmp((wchar_t*)(str1), (wchar_t*)(str2), n)
1034  #else
1035 
1039  #define FXSYS_wcschr wcschr
1040 
1044  #define FXSYS_wcsstr wcsstr
1045 
1049  #define FXSYS_wcsncmp wcsncmp
1050  #endif
1051 
1055  #define FXSYS_vswprintf vswprintf
1056  #else
1057  wchar_t* FXSYS_wcschr(const wchar_t*, wchar_t);
1058  wchar_t* FXSYS_wcsstr(const wchar_t*, const wchar_t*);
1059  int FXSYS_wcsncmp(const wchar_t*, const wchar_t*, size_t);
1060  #if _FX_OS_ != _FX_ANDROID_
1061  int FXSYS_vswprintf(wchar_t*, const wchar_t*, va_list);
1062  #else
1063  #define FXSYS_vswprintf vswprintf
1064  #endif
1065  #endif
1066 
1067  #if !defined(_FX_NO_ANSIC_) && _FX_COMPILER_ != _FX_TMS470_
1068 
1072  #define FXSYS_mbstowcs mbstowcs
1073 
1077  #define FXSYS_wcstombs wcstombs
1078  #else
1079  size_t FXSYS_mbstowcs(wchar_t *dest, const char *src, size_t n);
1080  size_t FXSYS_wcstombs(char *dest, const wchar_t *src, size_t n);
1081  #endif
1082  //<<<+++OPENSOURCE_MUST_END
1083 
1086  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1091 
1092  #if !defined(_FX_NO_ANSIC_)
1093 
1097  #define FXSYS_memcmp memcmp
1098 
1102  #define FXSYS_memcpy memcpy
1103 
1109  #define FXSYS_memmove memmove
1110 
1114  #define FXSYS_memset memset
1115 
1119  #define FXSYS_memchr memchr
1120  #else
1121  int FXSYS_memcmp(const void*, const void*, size_t);
1122  void* FXSYS_memcpy(void*, const void*, size_t);
1123  void* FXSYS_memmove(void*, const void*, size_t);
1124  void* FXSYS_memset(void*, int, size_t);
1125  void* FXSYS_memchr(const void*, int, size_t);
1126  #endif
1127 
1130  /* Others */
1131  #if !defined(_FX_NO_ANSIC_)
1132 
1136  #define FXSYS_qsort qsort
1137  #else
1138  void FXSYS_qsort(void*, unsigned, unsigned, int (*)(const void*, const void*));
1139  #endif
1140 
1141  #if _FX_OS_ != _FX_WIN32_MOBILE_ && !defined(_FX_NO_ANSIC_) && _FX_OS_ != _FX_SYMBIAN_
1142 
1146  #define FXSYS_bsearch bsearch
1147  #else
1148  /* WinCE doesn't support bsearch. The bsearch function comes with Symbian also has crash problem. */
1149  void * FXSYS_bsearch(const void *key, const void *base, size_t num, size_t width, int (*compare)(const void *, const void *));
1150  #endif
1151 
1152  #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1153  /* On Windows platform, we can replace more system calls */
1154 
1159  #define FXSYS_itoa _itoa
1160 
1164  #define FXSYS_strlwr _strlwr
1165 
1169  #define FXSYS_strupr _strupr
1170 
1174  #define FXSYS_stricmp _stricmp
1175 
1176  #ifdef _NATIVE_WCHAR_T_DEFINED
1177  #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
1178  #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
1179  #define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
1180  #define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
1181  #define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
1182  #else
1183 
1187  #define FXSYS_wcsicmp _wcsicmp
1188 
1192  #define FXSYS_WideCharToMultiByte WideCharToMultiByte
1193 
1197  #define FXSYS_MultiByteToWideChar MultiByteToWideChar
1198 
1202  #define FXSYS_wcslwr _wcslwr
1203 
1207  #define FXSYS_wcsupr _wcsupr
1208  #endif
1209 
1210  #ifndef _FX_WINAPI_PARTITION_DESKTOP_
1211  int FXSYS_IntersectRect(struct FX_RECT*, const struct FX_RECT*, const struct FX_RECT*);
1212  int FXSYS_GetACP(void);
1213  FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1214  FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1215  #else
1216 
1220  #define FXSYS_GetFullPathName GetFullPathName
1221 
1225  #define FXSYS_GetModuleFileName GetModuleFileName
1226 
1230  #define FXSYS_GetACP GetACP
1231  #endif
1232  #else
1233  char* FXSYS_itoa(int value, char* string, int radix);
1234  int FXSYS_GetACP(void);
1235  int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
1236  char* buf, int buflen, const char* default_str, int* pUseDefault);
1237  int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
1238  wchar_t* buf, int buflen);
1239  FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1240  FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1241 
1242  char* FXSYS_strlwr(char* str);
1243  char* FXSYS_strupr(char* str);
1244  int FXSYS_stricmp(const char*, const char*);
1245  int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
1246 
1247  wchar_t* FXSYS_wcslwr(wchar_t* str);
1248  wchar_t* FXSYS_wcsupr(wchar_t* str);
1249  #endif
1250  //<<<+++OPENSOURCE_MUST_END
1251 
1252  //*****************************************************************************
1253  //* Memory utilities
1254  //*****************************************************************************
1259 
1272  void* FXSYS_memcpy32(void* dst, const void* src, size_t size);
1273 
1290  FX_INT32 FXSYS_memcmp32(const void* buf1, const void* buf2, size_t size);
1291 
1303  void* FXSYS_memset32(void* dst, FX_INT32 v, size_t size);
1304 
1316  void* FXSYS_memset8(void* dst, FX_BYTE v, size_t size);
1317 
1327  void* FXSYS_memmove32(void* dst, const void* src, size_t size);
1329 //<<<+++OPENSOURCE_MUST_END
1330 
1331 //<<<+++OPENSOURCE_MUST_BEGIN
1332 #ifdef __cplusplus
1333 }
1334 #endif
1335 //<<<+++OPENSOURCE_MUST_END
1336 
1337  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1342 
1343  #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_METROWERKS_
1344  #ifdef __cplusplus
1345  extern "C" {
1346  #endif
1347 
1348  /* Metrowerks for Palm OS (9.3) doesn't support standard math.h */
1349  extern double __ieee754_pow(double, double);
1350  extern double __ieee754_sqrt(double);
1351  extern double __fabs(double);
1352  extern double __ieee754_atan2(double, double);
1353  extern double __ceil(double);
1354  extern double __floor(double);
1355  extern double __cos(double);
1356  extern double __ieee754_acos(double);
1357  extern double __sin(double);
1358  extern double __ieee754_log(double);
1359  extern double __ieee754_log10(double);
1360 
1361  #define FXSYS_pow(x, y) __ieee754_pow(x, y)
1362  #define FXSYS_sqrt(x) __ieee754_sqrt(x)
1363  #define FXSYS_fabs(x) __fabs(x)
1364  #define FXSYS_atan2(x, y) __ieee754_atan2(x, y)
1365  #define FXSYS_ceil(x) __ceil(x)
1366  #define FXSYS_floor(x) __floor(x)
1367  #define FXSYS_cos(x) __cos(x)
1368  #define FXSYS_acos(x) __ieee754_acos(x)
1369  #define FXSYS_sin(x) __sin(x)
1370  #define FXSYS_log(x) __ieee754_log(x)
1371  #define FXSYS_log10(x) __ieee754_log10(x)
1372 
1373  #ifdef __cplusplus
1374  }
1375  #endif
1376  #else
1377  #include <math.h>
1378  #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || _FX_OS_ == _FX_LINUX_DESKTOP_
1379 
1383  #define FXSYS_pow powf
1384 
1388  #define FXSYS_sqrt sqrtf
1389 
1393  #define FXSYS_fabs fabsf
1394 
1398  #define FXSYS_atan2 atan2f
1399 
1403  #define FXSYS_ceil ceilf
1404 
1408  #define FXSYS_floor floorf
1409 
1413  #define FXSYS_cos cosf
1414 
1418  #define FXSYS_acos acosf
1419 
1423  #define FXSYS_sin sinf
1424 
1428  #define FXSYS_log logf
1429 
1433  #define FXSYS_log10 log10f
1434 
1438  #define FXSYS_fmod fmodf
1439  #else
1440  #define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
1441  #define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
1442  #define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
1443  #define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
1444  #define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
1445  #define FXSYS_floor(a) (FX_FLOAT)floor(a)
1446  #define FXSYS_cos(a) (FX_FLOAT)cos(a)
1447  #define FXSYS_acos(a) (FX_FLOAT)acos(a)
1448  #define FXSYS_sin(a) (FX_FLOAT)sin(a)
1449  #define FXSYS_log(a) (FX_FLOAT)log(a)
1450  #define FXSYS_log10(a) (FX_FLOAT)log10(a)
1451  #define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
1452  #endif
1453  #endif
1454 
1455  #if !defined(_FX_NO_ANSIC_)
1456 
1460  #define FXSYS_abs abs
1461  #else
1462  #define FXSYS_abs(a) ((a)<0?-(a):(a))
1463  #endif
1464 
1466  //<<<+++OPENSOURCE_MUST_END
1467 
1468 //<<<+++OPENSOURCE_MUST_BEGIN
1469 #ifdef __cplusplus
1470 extern "C" {
1471 #endif
1472 //<<<+++OPENSOURCE_MUST_END
1473 
1474  //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1475  #ifdef _FX_NO_GLOBAL_
1476  /* If platform doesn't support global variable, then we have to get from static functions */
1478  void FXSYS_SetStaticPointer1(void*);
1480  void* FXSYS_GetStaticPointer1(void);
1482  void FXSYS_SetStaticPointer2(void*);
1484  void* FXSYS_GetStaticPointer2(void);
1485  #endif
1486 
1487  /* CPU byte order */
1488  #if _FX_ENDIAN_ == _FX_BIG_ENDIAN_
1489  #define _FX_MSB_FIRST_
1490  #define FXDWORD_FROM_LSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1491  #define FXDWORD_FROM_MSBFIRST(i) (i)
1492  #else
1493  #define _FX_LSB_FIRST_
1494  #define FXDWORD_FROM_LSBFIRST(i) (i)
1495  #define FXDWORD_FROM_MSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1496  #endif
1497 
1498  #if _FX_CPU_ == _FX_X86_ || _FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_ARM64_ || _FX_CPU_ == _FX_MIPS64_
1499  #define FXDWORD_GET_LSBFIRST(p) (*(FX_DWORD*)(p))
1500  #else
1501  #define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0]))
1502  #endif
1503 
1504 #define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3]))
1505 
1506 #define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8))
1507 #define FXSYS_LOBYTE(word) ((FX_BYTE)(word))
1508 #define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
1509 #define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
1510 
1512 #define FXSYS_strtol strtol
1513 
1555 FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix);
1565 FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix);
1573 int FXSYS_round(FX_FLOAT f);
1575 #define FXSYS_Mul(a, b) ((a) * (b))
1576 
1577 #define FXSYS_Div(a, b) ((a) / (b))
1578 
1579 #define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
1580 
1581 #define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
1582 
1583 //*****************************************************************************
1584 //* Multiple thread controls
1585 //*****************************************************************************
1587 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1588  typedef CRITICAL_SECTION FX_MUTEX;
1589  FX_DEFINEHANDLE(FX_RWLOCK)
1590 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_
1591  #include <pthread.h>
1592  typedef pthread_mutex_t FX_MUTEX;
1593  #if _FX_OS_ == _FX_ANDROID_
1594  FX_DEFINEHANDLE(FX_RWLOCK)
1595  #else
1596  typedef pthread_rwlock_t FX_RWLOCK;
1597  #endif
1598 #else
1600  FX_DEFINEHANDLE(FX_RWLOCK)
1601 #endif
1602 // The following five functions are defined in fx_process.h, please refer there.
1604 void FX_Mutex_Destroy(FX_MUTEX* pMutex);
1606 void FX_Mutex_Lock(FX_MUTEX* pMutex);
1607 void FX_Mutex_Unlock(FX_MUTEX* pMutex);
1608 
1609 #define FX_CRITICAL_SECTION FX_MUTEX
1610 #define FX_InitializeCriticalSection(a) FX_Mutex_Initialize(a)
1611 #define FX_DeleteCriticalSection(a) FX_Mutex_Destroy(a)
1612 #define FX_TryEnterCriticalSection(a) FX_Mutex_TryLock(a)
1613 #define FX_EnterCriticalSection(a) FX_Mutex_Lock(a)
1614 #define FX_LeaveCriticalSection(a) FX_Mutex_Unlock(a)
1615 
1617 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1618  typedef void* FX_SPINLOCK;
1619 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_==_FX_LINUX_EMBEDDED_
1620  #ifdef _FX_SPINLOCK_USEGCCCAS_
1621  typedef size_t FX_SPINLOCK;
1622  #else
1623 #ifndef _CHROME_PNACL_
1624  typedef pthread_spinlock_t FX_SPINLOCK;
1625 #else
1626  typedef size_t FX_SPINLOCK;
1627 #endif
1628  #endif
1629 #elif _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
1630  typedef OSSpinLock FX_SPINLOCK;
1631 #else // android/embeded linux/other os
1633 #endif
1634 //<<<+++OPENSOURCE_MUST_END
1635 
1636 //<<<+++OPENSOURCE_MUST_BEGIN
1637 #ifdef __cplusplus
1638 };
1639 #endif
1640 //<<<+++OPENSOURCE_MUST_END
1641 
1642 #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_PACC_
1643  #include <errtrycatch.h>
1644  #define setjmp ErrSetJump
1645  #define longjmp ErrLongJump
1646  #define jmp_buf ErrJumpBuf
1647 #else
1648  #include <setjmp.h>
1649 #endif
1650 
1651 #if _FX_OS_ == _FX_MACOSX_
1652  #include <Carbon/Carbon.h>
1653 #elif _FX_OS_ == _FX_IOS_
1654  #include <CoreText/CoreText.h>
1655  #include <CoreGraphics/CoreGraphics.h>
1656 #endif
1657 //<<<+++OPENSOURCE_MUST_END
1658 //<<<+++OPENSOURCE_MUST_BEGIN
1659 #endif /* _FPDF_SYSTEM_H_ */
1660 //<<<+++OPENSOURCE_MUST_END
1661 
1664 //<<<+++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:645
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:721
#define FXSYS_wcslwr
Convert a wide-character string to lowercase.
Definition: fx_system.h:1202
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:715
#define FXSYS_mbstowcs
Converts a sequence of multi-byte characters to a corresponding sequence of wide characters.
Definition: fx_system.h:1072
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:958
#define FXSYS_fprintf
Print formatted data to a file.
Definition: fx_system.h:963
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:1049
#define FXSYS_FILE
File structure.
Definition: fx_system.h:918
void const * FX_LPCVOID
Pointer to any constant type.
Definition: fx_system.h:647
int FXSYS_round(FX_FLOAT f)
Get nearest integer.
#define FXSYS_strcpy
Copy an ANSIC string.
Definition: fx_system.h:882
#define FXSYS_fflush
Flush file.
Definition: fx_system.h:968
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:755
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:725
#define FXSYS_GetFullPathName
Get the full path and file name of a specified file.
Definition: fx_system.h:1220
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:867
#define FXSYS_wcsupr
Convert a wide-character string to uppercase.
Definition: fx_system.h:1207
#define FXSYS_strncpy
Copy an ANSIC string with length limitation.
Definition: fx_system.h:887
#define FXSYS_wcschr
Find a wide-character in a wide-character string.
Definition: fx_system.h:1039
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:694
#define FXSYS_wfopen
Open a file using wide-string parameters. Only supported on Windows platforms now.
Definition: fx_system.h:992
#define FXSYS_memmove
Moves one buffer to another. If some regions of the source area and the destination overlap,...
Definition: fx_system.h:1109
CRITICAL_SECTION FX_MUTEX
Definition for mutex/critical section and read-write lock.
Definition: fx_system.h:1588
#define FXSYS_memcpy
Copy from one buffer to another.
Definition: fx_system.h:1102
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:649
#define FXSYS_vswprintf
Write formatted output wide character string using a pointer to a list of arguments.
Definition: fx_system.h:1055
#define FXSYS_itoa
Convert an integer to a ANSIC string.
Definition: fx_system.h:1159
__int64 FX_INT64
Signed 64-bit integer.
Definition: fx_system.h:729
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:862
#define FXSYS_strlwr
Convert a ANSIC string to lowercase.
Definition: fx_system.h:1164
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:674
#define FXSYS_GetModuleFileName
Get the fully-qualified path for specified module.
Definition: fx_system.h:1225
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:1097
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:682
unsigned short * FX_LPWORD
Pointer to a WORD.
Definition: fx_system.h:670
#define FXSYS_fseek
Moves the file pointer to a specified location.
Definition: fx_system.h:943
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:696
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1016
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:652
#define FXSYS_wcscmp
Compare wide-character strings.
Definition: fx_system.h:1021
#define FXSYS_GetACP
Retrieve the current ANSI code-page identifier for the system.
Definition: fx_system.h:1230
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:953
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:741
#define FXSYS_qsort
Performs a quick sort. A generic algorithm.
Definition: fx_system.h:1136
#define FXSYS_wcsicmp
Compare two wide character strings. case-insensitive.
Definition: fx_system.h:1187
void * FX_SPINLOCK
Definition for spinlock.
Definition: fx_system.h:1618
unsigned long * FX_LPDWORD
Pointer to a DWORD.
Definition: fx_system.h:717
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:666
#define FXSYS_fopen
Open a file.
Definition: fx_system.h:923
#define FXSYS_bsearch
Performs a binary search of a sorted array. A generic algorithm.
Definition: fx_system.h:1146
#define FXSYS_MultiByteToWideChar
Maps a character string to a wide-character string.
Definition: fx_system.h:1197
void FX_Mutex_Destroy(FX_MUTEX *pMutex)
Destroy a mutex.
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:658
#define FXSYS_strstr
Find a substring.
Definition: fx_system.h:892
#define FXSYS_wcsstr
Find a sub-wide-character-string.
Definition: fx_system.h:1044
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:692
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:676
#define FXSYS_assert
Assertion.
Definition: fx_system.h:792
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:664
#define FXSYS_memchr
Search for a byte in a memory block.
Definition: fx_system.h:1119
#define FXSYS_strcmp
Compare ANSIC strings.
Definition: fx_system.h:877
#define FXSYS_WideCharToMultiByte
Maps a wide-character string to a character string.
Definition: fx_system.h:1192
Definition: fx_coordinates.h:596
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:654
unsigned short const * FX_LPCWORD
Pointer to a WORD.
Definition: fx_system.h:672
#define FXSYS_fclose
Close a file.
Definition: fx_system.h:928
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:948
#define FXSYS_stricmp
Compare two ANSIC strings. case-insensitive.
Definition: fx_system.h:1174
#define FXSYS_strncmp
Compare characters of two ANSIC strings.
Definition: fx_system.h:872
void FX_Mutex_Lock(FX_MUTEX *pMutex)
Lock a mutex.
unsigned short FX_WORD
16-bit unsigned integer.
Definition: fx_system.h:668
unsigned __int64 FX_UINT64
Unsigned 64-bit integer.
Definition: fx_system.h:731
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:662
#define FXSYS_memset
Use given character to initialize the buffer.
Definition: fx_system.h:1114
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:660
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:723
#define FXSYS_sprintf
Write formatted data to a ANSIC string.
Definition: fx_system.h:841
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:760
#define FXSYS_wcstombs
Converts a sequence of wide characters to a corresponding sequence of multi-byte characters.
Definition: fx_system.h:1077
#define FXSYS_vsprintf
Write formatted output using a pointer to a list of arguments.
Definition: fx_system.h:857
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:1169
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:757
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:739
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:656
int FX_ERR
Error indicator.
Definition: fx_system.h:685