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(__ARM_EABI__)) && (!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 #ifndef _CRT_SECURE_NO_WARNINGS
234 #define _CRT_SECURE_NO_WARNINGS
235 #endif //_CRT_SECURE_NO_WARNINGS
236 #if defined(_MSC_VER) && _MSC_VER < 1300
237 #define _WIN32_WINNT 0x400
238 #endif
239 #if defined(_MSC_VER) && _MSC_VER < 1600
240 #define UNSUPPORT_CPP0X
241 #endif
242 #ifndef NOMINMAX
243 #define NOMINMAX
244 #endif
245 #include <windows.h>
246
247 #ifdef WINAPI_FAMILY
248 #if (0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP) //Macros in Windows Kit/8
249 #define _FX_WIN8_
250 #else //Macros in Windows Kit/8.1
251 #define _FX_WIN81_
252 #endif //(0x00000001 == WINAPI_PARTITION_DESKTOP) && (0x00000002 == WINAPI_PARTITION_APP)
253
254 #ifdef _FX_WIN8_
255 #if /*defined(WINAPI_FAMILY) && */((WINAPI_FAMILY&WINAPI_PARTITION_APP) == WINAPI_PARTITION_APP)
256
257 #define _FX_WINAPI_PARTITION_APP_
258 #endif
259 #if defined(WINAPI_FAMILY) && ((WINAPI_FAMILY&WINAPI_PARTITION_DESKTOP) == WINAPI_PARTITION_DESKTOP)
260
261 #define _FX_WINAPI_PARTITION_DESKTOP_
262 #endif
263 #endif //_FX_WIN8_
264
265 #ifdef _FX_WIN81_
266
267 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
268
269 #define _FX_WINAPI_PARTITION_APP_
270 #endif
271
272 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP) && !WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PC_APP)
273
274 #define _FX_WINAPI_PARTITION_PHONE_APP_
275 #endif
276
277 #if WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
278
279 #define _FX_WINAPI_PARTITION_DESKTOP_
280 #endif
281 #endif //_FX_WIN81_
282 #else // !defined(WINAPI_FAMILY)
283 #ifndef _WIN32_WCE
284 #define _FX_WINAPI_PARTITION_DESKTOP_
285 #endif
286 #endif //WINAPI_FAMILY
287 #endif //(_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
288 //<<<+++OPENSOURCE_MUST_END
289
296
298 #define _FX_VC6_ 1
299
300 #define _FX_VC7_ 2
301
302 #define _FX_VC8_ 3
303
304 #define _FX_GCC_ 4
305
306 #define _FX_ADS_ 5
307
308 #define _FX_RVCT_ 6
309
310 #define _FX_IARCC_ 7
311
312 #define _FX_NOKIA_X86_ 8
313
314 #define _FX_METROWERKS_ 9
315
316 #define _FX_PACC_ 10
317
318 #define _FX_TMS470_ 11
319
320 #define _FX_MIPS_SDE_ 12
321
322 /* Compiler */
323 #ifndef _FX_COMPILER_
324 #ifdef _MSC_VER
325 #if _MSC_VER >= 1400
326 #define _FX_COMPILER_ _FX_VC8_
327 #elif _MSC_VER >= 1300
328 #define _FX_COMPILER_ _FX_VC7_
329 #else
330
349 #define _FX_COMPILER_ _FX_VC6_
350 #endif
351 #elif defined(__GNUC__)
352 #define _FX_COMPILER_ _FX_GCC_
353 #elif defined(__ARMCC_VERSION)
354 #if __ARMCC_VERSION < 200000
355 #define _FX_COMPILER_ _FX_ADS_
356 #else
357 #define _FX_COMPILER_ _FX_RVCT_
358 #endif
359 #elif defined(__ICCARM__)
360 #define _FX_COMPILER_ _FX_IARCC_
361 #elif defined(_PACC_VER)
362 #define _FX_COMPILER_ _FX_PACC_
363 #elif defined(__TMS470__)
364 #define _FX_COMPILER_ _FX_TMS470_
365 #endif
366 #endif /* !_FX_COMPILER_ */
367 #if !defined(_FX_COMPILER_) || _FX_COMPILER_ == 0
368 #error Sorry, can not figure out what compiler you are using. Please specify _FX_COMPILER_ macro.
369 #endif
370 //<<<+++OPENSOURCE_MUST_END
371
378
380 #define _FX_X86_ 1
381
382 #define _FX_ARM_ 2
383
384 #define _FX_POWERPC_ 3
385
386 #define _FX_SPARC_ 4
387
388 #define _FX_IA64_ 5
389
390 #define _FX_MIPS_ 6
391
392 #define _FX_X64_ 7
393
394 #define _FX_ARM64_ 8
395
396 #define _FX_MIPS64_ 9
397
398 #define _FX_LOONGARCH64_ 10
399
400 #if defined(_FXM_PLATFORM_LINUX_JS_)
401 #define _FX_CPU_ _FX_X86_
402 #endif
403
404 #if defined(_CHROME_PNACL_)
405 #define _FX_CPU_ _FX_X86_
406 #endif
407 /* CPU */
408 #ifndef _FX_CPU_
409 #if defined(__arm__) || defined(ARM) || defined(_ARM_) || defined(__ARMCC_VERSION) || defined(__ICCARM__) || defined(__arm) || defined(arm9) || defined(_M_ARM)
410 #define _FX_CPU_ _FX_ARM_
411 #elif defined(__arm64) || defined(__arm64__) || defined(__aarch64__) || defined(_ARM64_) || defined(_M_ARM64)
412 #define _FX_CPU_ _FX_ARM64_
413 #elif defined(_M_IX86) || defined(__i386__)
414
429 #define _FX_CPU_ _FX_X86_
430 #elif defined(_M_X64) || defined(__x86_64__)
431 #define _FX_CPU_ _FX_X64_
432 #elif defined(_M_IA64)
433 #define _FX_CPU_ _FX_IA64_
434 #elif defined(__POWERPC__)
435 #define _FX_CPU_ _FX_POWERPC_
436 #elif defined(__sparc__)
437 #define _FX_CPU_ _FX_SPARC_
438 #elif defined(__mips64)
439 #define _FX_CPU_ _FX_MIPS64_
440 #elif defined(__loongarch64)
441 #define _FX_CPU_ _FX_LOONGARCH64_
442 #elif defined(MIPS) || defined(_MIPS_) || defined(__mips)
443 #define _FX_CPU_ _FX_MIPS_
444 #endif
445 #endif
446 #if !defined(_FX_CPU_) || _FX_CPU_ == 0
447 #error Sorry, can not figure out what CPU you are targeting to. Please specify _FX_CPU_ macro.
448 #endif
449 //<<<+++OPENSOURCE_MUST_END
450
452 #ifdef _MSC_VER
453 #if _MSC_VER >= 1600
454 #define _FX_EMBEDFONT_PRINT_
455 #endif
456 #endif
457
458 #if defined linux || defined __linux__
459 #define _FX_EMBEDFONT_PRINT_
460 #endif
461
466
467 //<<<+++OPENSOURCE_MUST_BEGIN
469 #define _FX_W32_ 1
470
471 #define _FX_W64_ 2
472
473 /* Word size or instruct length */
474 #ifndef _FX_WORDSIZE_
475 #if defined(_WIN64) || defined(__arm64) || defined(__arm64__) || defined(_M_AMD64) || \
476 defined(_M_X64) || defined(_M_IA64) || defined(__powerpc64__) || defined(__x86_64__) || \
477 __WORDSIZE == 64 || defined(__LP64__) || defined(__mips64) || defined(__loongarch64)
478 #define _FX_WORDSIZE_ _FX_W64_
479 #else
480 #define _FX_WORDSIZE_ _FX_W32_
481 #endif
482 #endif
483 //<<<+++OPENSOURCE_MUST_END
484
491
493 #define _FX_BIG_ENDIAN_ 1
494
495 #define _FX_LITTLE_ENDIAN_ 2
496
497 /* Byte Order */
498 #ifndef _FX_ENDIAN_
499 #if _FX_CPU_ == _FX_POWERPC_ || _FX_CPU_ == _FX_SPARC_
500 #define _FX_ENDIAN_ _FX_BIG_ENDIAN_
501 #else
502
511 #define _FX_ENDIAN_ _FX_LITTLE_ENDIAN_
512 #endif
513 #endif
514
517 /* Include basic headers */
518 #include <stddef.h>
519 #include <stdarg.h>
520 #include <setjmp.h>
521 #include <float.h>
522
523 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
524 #ifndef _FX_NO_ANSIC_
525 #include <stdlib.h>
526 #include <stdio.h>
527 #include <string.h>
528 #include <assert.h>
529 #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_)
530 #include <wchar.h>
531 #endif
532 #endif
533 //<<<+++OPENSOURCE_MUST_END
534
535 //<<<+++OPENSOURCE_MUST_BEGIN
536 #if _FXM_PLATFORM_ == _FXM_PLATFORM_APPLE_
537 #include <libkern/OSAtomic.h>
538 #if _FX_OS_ == _FX_MACOSX_
539 #include <Carbon/Carbon.h>
540 #elif _FX_OS_ == _FX_IOS_
541 #include <CoreText/CoreText.h>
542 #include <CoreGraphics/CoreGraphics.h>
543 #endif
544 #endif
545 //<<<+++OPENSOURCE_MUST_END
546
547 #ifdef _UNICODE
548 #define GetModuleFileName GetModuleFileNameW
549 #define GetFullPathName GetFullPathNameW
550 #else
551
556 #define GetModuleFileName GetModuleFileNameA
557
562 #define GetFullPathName GetFullPathNameA
563 #endif
564
565 #if ( _FX_OS_ == _FX_IOS_ && (_FX_CPU_ == _FX_ARM_ || _FX_CPU_ == _FX_ARM64_)) || (_FX_OS_ == _FX_ANDROID_) || (_FX_OS_ == _FX_WIN32_MOBILE_)
566 #ifndef _FXCORE_LIMITED_MEMORY_
567 #define _FXCORE_LIMITED_MEMORY_
568 #endif
569 #ifndef _FXCORE_LIMITED_CPU_
570 #define _FXCORE_LIMITED_CPU_
571 #endif
572 #endif
573
574 #if _FX_COMPILER_ == _FX_ADS_ || _FX_COMPILER_ == _FX_RVCT_ || _FX_COMPILER_ == _FX_TMS470_ || _FX_OS_ == _FX_ANDROID_
575 //#define _FX_NO_EXCEPTION_ //Removed by Malcolm J. Xue, Sep. 9th, 2010, should be defined outside
576 #define _FX_NO_NAMESPACE_
577 #endif
578
583
585 #define _FX_DEFAULT_TARGET_ 0
586
587 #define _FX_BREW_ 1
588
590 //<<<+++OPENSOURCE_MUST_END
591
592 #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_)
593 #ifndef _FX_NO_SIMD_
594 #if !defined(_FXM_PLATFORM_LINUX_JS_) && !defined(_CHROME_PNACL_) && (_FX_CPU_ != _FX_ARM_) && \
595 (_FX_CPU_ != _FX_ARM64_) && (_FX_CPU_ != _FX_MIPS_) && (_FX_CPU_ != _FX_MIPS64_) && \
596 (_FX_CPU_ != _FX_LOONGARCH64_)
597 #define _FXM_SIMD_
598 #endif
599 #endif
600 #endif
601 #if _FX_OS_ != _FX_MACOSX_
602 //#define _FXM_OPENMP_
603 #endif
604
605 #ifndef _FX_NO_OPENSSL_
606 #define _FX_NO_OPENSSL_
607 #endif
608
609 #if (((_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && defined(_FX_WINAPI_PARTITION_DESKTOP_)) || _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_MACOSX_)
610 #ifndef _FX_NO_JPEG_TURBO_
611 #if !defined(_CHROME_PNACL_)
612 #define _FX_JPEG_TURBO_
613 #endif
614 #endif
615 #ifndef _FX_NO_OPENSSL_
616 #define _FXM_OPENSSL_
617 #endif
618 #define _FX_LARGEFILE_SUPPORT_
619 #ifndef _FX_NO_SIMD_
620 #define WITH_SIMD
621 #endif
622 #ifndef _FXM_FEATURE_LIGHT_
623 #define _FPDF_STREAM_RENDER_
624 #endif
625 #ifndef _FX_ENABLE_OVERPRINT_
626 #ifndef _FXM_FEATURE_LIGHT_
627 #define _FX_ENABLE_OVERPRINT_
628 #endif
629 #endif
630 #endif
631
632 #if _FX_OS_ == _FX_LINUX_EMBEDDED_
633 #ifndef _FX_ENABLE_OVERPRINT_
634 #define _FX_ENABLE_OVERPRINT_
635 #endif
636 #endif
637
638 #ifdef _FX_WINAPI_PARTITION_APP_
639 #define _FPDF_STREAM_RENDER_
640 #endif
641 //<<<+++OPENSOURCE_MUST_END
642
643 //<<<+++OPENSOURCE_MUST_BEGIN
644 #ifdef __cplusplus
645 extern "C" {
646 #endif
647 //<<<+++OPENSOURCE_MUST_END
648
654 typedef void* FX_LPVOID;
656 typedef void const* FX_LPCVOID;
658 typedef void* FX_POSITION;
659
661 typedef signed char FX_INT8;
663 typedef unsigned char FX_UINT8;
665 typedef unsigned char FX_BYTE;
667 typedef unsigned char* FX_LPBYTE;
669 typedef unsigned char const* FX_LPCBYTE;
671 typedef short FX_INT16;
673 typedef unsigned short FX_UINT16;
675 typedef short FX_SHORT;
677 typedef unsigned short FX_WORD;
679 typedef unsigned short* FX_LPWORD;
681 typedef unsigned short const* FX_LPCWORD;
683 typedef int FX_INT32;
685 typedef float FX_FLOAT;
686 #ifdef __cplusplus
687
688 typedef bool FX_BOOL;
689 #else
690
691 typedef int FX_BOOL;
692 #endif
693
694 typedef int FX_ERR;
696 #define FX_SUCCEEDED(Status) ((FX_ERR)(Status) >= 0)
697
698 #define FX_FAILED(Status) ((FX_ERR)(Status) < 0)
699
701 typedef char FX_CHAR;
703 typedef char* FX_LPSTR;
705 typedef char const* FX_LPCSTR;
706
707 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
717 #if !defined(_MSC_VER) && \
718 (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_ || \
719 _FX_CPU_ == _FX_MIPS64_ || _FX_CPU_ == _FX_LOONGARCH64_)
720
721 typedef unsigned int FX_DWORD;
723 typedef unsigned int* FX_LPDWORD;
724 #else
725
726 typedef unsigned long FX_DWORD;
728 typedef unsigned long* FX_LPDWORD;
729 #endif
730
732 typedef wchar_t FX_WCHAR;
734 typedef wchar_t* FX_LPWSTR;
736 typedef wchar_t const* FX_LPCWSTR;
737
738 #ifdef _MSC_VER
739
740 typedef __int64 FX_INT64;
742 typedef unsigned __int64 FX_UINT64;
743 #else
744 typedef long long int FX_INT64;
745 typedef unsigned long long FX_UINT64;
746 #endif
747
748 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
749
750 typedef INT_PTR FX_INTPTR;
752 typedef UINT_PTR FX_UINTPTR;
753 #else
754 #if (_FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_IA64_ || _FX_CPU_ == _FX_ARM64_ || \
755 _FX_CPU_ == _FX_MIPS64_ || _FX_CPU_ == _FX_LOONGARCH64_)
756 typedef FX_INT64 FX_INTPTR;
757 typedef FX_UINT64 FX_UINTPTR;
758 #else
759 typedef int FX_INTPTR;
760 typedef unsigned int FX_UINTPTR;
761 #endif
762 #endif
763 //<<<+++OPENSOURCE_MUST_END
764
765 //<<<+++OPENSOURCE_MUST_BEGIN
767 typedef FX_DWORD FX_UINT32;
769 typedef FX_UINT64 FX_QWORD;
770
772 #define FX_DEFINEHANDLE(name) typedef struct _##name {FX_LPVOID pData;} * name;
773
774 #if defined(DEBUG) && !defined(_DEBUG)
775 #define _DEBUG
776 #endif
777
778 #ifndef __cplusplus
779 #ifndef TRUE
780
781 #define TRUE 1
782 #endif
783
784 #ifndef FALSE
785
786 #define FALSE 0
787 #endif
788 #endif
789
790 #ifndef NULL
791
792 #define NULL 0
793 #endif
794 //<<<+++OPENSOURCE_MUST_END
795
796 /* Assertion */
797
798 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
799 #if !defined(_FX_NO_ANSIC_)
800
804 #define FXSYS_assert assert
805 #else
806 void FXSYS_assert(int condition);
807 #endif
808 //<<<+++OPENSOURCE_MUST_END
809
810 //<<<+++OPENSOURCE_MUST_BEGIN
811 #ifndef ASSERT
812 #ifdef _DEBUG
813 #define ASSERT FXSYS_assert
814 #else
815
819 #define ASSERT(a)
820 #endif
821 #endif
822
824 #define FX_MAX(a, b) (((a) > (b)) ? (a) : (b))
825
826 #define FX_MIN(a, b) (((a) < (b)) ? (a) : (b))
827
829 #define FX_PI 3.1415926535897932384626433832795f
830
832 #if _FX_WORDSIZE_ == _FX_W64_ && _FXM_PLATFORM_ == _FXM_PLATFORM_WINDOWS_
833 #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffffffffffL
834 #else
835 #define _FX_CRT_MALLOC_LIMIT_ 0x7fffffffL
836 #endif
837
838 //<<<+++OPENSOURCE_MUST_END
839
846
847 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
848 #if !defined(_FX_NO_ANSIC_)
849
853 #define FXSYS_sprintf sprintf
854
858 #ifdef _WIN32
859 #define FXSYS_snprintf _snprintf
860 #define FXSYS_vsnprintf _vsnprintf
861 #else
862 #define FXSYS_snprintf snprintf
863 #define FXSYS_vsnprintf vsnprintf
864 #endif
865
869 #define FXSYS_vsprintf vsprintf
870
874 #define FXSYS_strchr strchr
875
879 #define FXSYS_strlen strlen
880
884 #define FXSYS_strncmp strncmp
885
889 #define FXSYS_strcmp strcmp
890
894 #define FXSYS_strcpy strcpy
895
899 #define FXSYS_strncpy strncpy
900
904 #define FXSYS_strstr strstr
905 #else
906 int FXSYS_sprintf(char* buffer, const char* format, ...);
907 int FXSYS_vsprintf(char *buffer, const char *format, va_list args);
908 char* FXSYS_strchr(const char* str, int ch);
909 long FXSYS_strlen(const char* str);
910 int FXSYS_strncmp(const char* str1, const char* str2, size_t len);
911 int FXSYS_strcmp(const char* str1, const char* str2);
912 char* FXSYS_strcpy(char* dest, const char* src);
913 char* FXSYS_strncpy(char* dest, const char* src, size_t len);
914 char* FXSYS_strstr(const char *string, const char *strFind);
915 #endif
916 //<<<+++OPENSOURCE_MUST_END
917
924 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
925 #if !defined(_FX_NO_ANSIC_) && !defined(__EMSCRIPTEN__)
926
930 #define FXSYS_FILE FILE
931
935 #define FXSYS_fopen fopen
936
940 #define FXSYS_fclose fclose
941
945 #define FXSYS_SEEK_END SEEK_END
946
950 #define FXSYS_SEEK_SET SEEK_SET
951
955 #define FXSYS_fseek fseek
956
960 #define FXSYS_ftell ftell
961
965 #define FXSYS_fread fread
966
970 #define FXSYS_fwrite fwrite
971
975 #define FXSYS_fprintf fprintf
976
980 #define FXSYS_fflush fflush
981 #else
982 #define FXSYS_FILE void
983 FXSYS_FILE* FXSYS_fopen(const char* filename, const char* mode);
984 int FXSYS_fclose(FXSYS_FILE*);
985 #define FXSYS_SEEK_END 2
986 #define FXSYS_SEEK_SET 0
987 int FXSYS_fseek(FXSYS_FILE*, long, int);
988 long FXSYS_ftell(FXSYS_FILE*);
989 size_t FXSYS_fread(void*, size_t, size_t, FXSYS_FILE*);
990 long FXSYS_fwrite(const void*, long, long, FXSYS_FILE*);
991 int FXSYS_fprintf(FXSYS_FILE*, const char*, ...);
992 int FXSYS_fflush(FXSYS_FILE*);
993 #endif
994
995 // For now, we provide wide-string file name support for Windows only
996 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_
997
1001 #ifdef _NATIVE_WCHAR_T_DEFINED
1002 #define FXSYS_wfopen(f, m) _wfopen((const wchar_t*)(f), (const wchar_t*)(m))
1003 #else
1004 #define FXSYS_wfopen _wfopen
1005 #endif
1006 #else
1007 FXSYS_FILE* FXSYS_wfopen(FX_LPCWSTR filename, FX_LPCWSTR mode);
1008 #endif
1009
1016
1017 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1018 /* Basic wide string operations, not available in ADS/RVCT/PACC/Android/MIPS_SDE */
1019 #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_
1020 #ifdef _NATIVE_WCHAR_T_DEFINED
1021 #define FXSYS_wcslen(str) wcslen((wchar_t*)(str))
1022 #define FXSYS_wcscmp(str1, str2) wcscmp((wchar_t*)(str1), (wchar_t*)(str2))
1023 #else
1024
1028 #define FXSYS_wcslen wcslen
1029
1033 #define FXSYS_wcscmp wcscmp
1034 #endif
1035 #else
1036 size_t FXSYS_wcslen(const wchar_t*);
1037 int FXSYS_wcscmp(const wchar_t*, const wchar_t*);
1038 #endif
1039
1040 /* Some other wide string functions, not available in ADS/RVCT/GCCE/PACC/Android/MIPS_SDE */
1041 #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_
1042 #ifdef _NATIVE_WCHAR_T_DEFINED
1043 #define FXSYS_wcschr(str, ch) (FX_LPCWSTR)wcschr((wchar_t*)(str), ch)
1044 #define FXSYS_wcsstr(str1, str2) (FX_LPCWSTR)wcsstr((wchar_t*)(str1), (wchar_t*)(str2))
1045 #define FXSYS_wcsncmp(str1, str2, n) wcsncmp((wchar_t*)(str1), (wchar_t*)(str2), n)
1046 #else
1047
1051 #define FXSYS_wcschr wcschr
1052
1056 #define FXSYS_wcsstr wcsstr
1057
1061 #define FXSYS_wcsncmp wcsncmp
1062 #endif
1063
1067 #define FXSYS_vswprintf vswprintf
1068 #else
1069 wchar_t* FXSYS_wcschr(const wchar_t*, wchar_t);
1070 wchar_t* FXSYS_wcsstr(const wchar_t*, const wchar_t*);
1071 int FXSYS_wcsncmp(const wchar_t*, const wchar_t*, size_t);
1072 #if _FX_OS_ != _FX_ANDROID_
1073 int FXSYS_vswprintf(wchar_t*, const wchar_t*, va_list);
1074 #else
1075 #define FXSYS_vswprintf vswprintf
1076 #endif
1077 #endif
1078
1079 #if !defined(_FX_NO_ANSIC_) && _FX_COMPILER_ != _FX_TMS470_
1080
1084 #define FXSYS_mbstowcs mbstowcs
1085
1089 #define FXSYS_wcstombs wcstombs
1090 #else
1091 size_t FXSYS_mbstowcs(wchar_t *dest, const char *src, size_t n);
1092 size_t FXSYS_wcstombs(char *dest, const wchar_t *src, size_t n);
1093 #endif
1094 //<<<+++OPENSOURCE_MUST_END
1095
1098 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1103
1104 #if !defined(_FX_NO_ANSIC_)
1105
1109 #define FXSYS_memcmp memcmp
1110
1114 #define FXSYS_memcpy memcpy
1115
1121 #define FXSYS_memmove memmove
1122
1126 #define FXSYS_memset memset
1127
1131 #define FXSYS_memchr memchr
1132 #else
1133 int FXSYS_memcmp(const void*, const void*, size_t);
1134 void* FXSYS_memcpy(void*, const void*, size_t);
1135 void* FXSYS_memmove(void*, const void*, size_t);
1136 void* FXSYS_memset(void*, int, size_t);
1137 void* FXSYS_memchr(const void*, int, size_t);
1138 #endif
1139
1142 /* Others */
1143 #if !defined(_FX_NO_ANSIC_)
1144
1148 #define FXSYS_qsort qsort
1149 #else
1150 void FXSYS_qsort(void*, unsigned, unsigned, int (*)(const void*, const void*));
1151 #endif
1152
1153 #if _FX_OS_ != _FX_WIN32_MOBILE_ && !defined(_FX_NO_ANSIC_) && _FX_OS_ != _FX_SYMBIAN_
1154
1158 #define FXSYS_bsearch bsearch
1159 #else
1160 /* WinCE doesn't support bsearch. The bsearch function comes with Symbian also has crash problem. */
1161 void * FXSYS_bsearch(const void *key, const void *base, size_t num, size_t width, int (*compare)(const void *, const void *));
1162 #endif
1163
1164 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1165 /* On Windows platform, we can replace more system calls */
1166
1171 #define FXSYS_itoa _itoa
1172
1176 #define FXSYS_strlwr _strlwr
1177
1181 #define FXSYS_strupr _strupr
1182
1186 #define FXSYS_stricmp _stricmp
1187
1188 #ifdef _NATIVE_WCHAR_T_DEFINED
1189 #define FXSYS_wcsicmp(str1, str2) _wcsicmp((wchar_t*)(str1), (wchar_t*)(str2))
1190 #define FXSYS_WideCharToMultiByte(p1, p2, p3, p4, p5, p6, p7, p8) WideCharToMultiByte(p1, p2, (const wchar_t*)(p3), p4, p5, p6, p7, p8)
1191 #define FXSYS_MultiByteToWideChar(p1, p2, p3, p4, p5, p6) MultiByteToWideChar(p1, p2, p3, p4, (wchar_t*)(p5), p6)
1192 #define FXSYS_wcslwr(str) _wcslwr((wchar_t*)(str))
1193 #define FXSYS_wcsupr(str) _wcsupr((wchar_t*)(str))
1194 #else
1195
1199 #define FXSYS_wcsicmp _wcsicmp
1200
1204 #define FXSYS_WideCharToMultiByte WideCharToMultiByte
1205
1209 #define FXSYS_MultiByteToWideChar MultiByteToWideChar
1210
1214 #define FXSYS_wcslwr _wcslwr
1215
1219 #define FXSYS_wcsupr _wcsupr
1220 #endif
1221
1222 #ifndef _FX_WINAPI_PARTITION_DESKTOP_
1223 int FXSYS_IntersectRect(struct FX_RECT*, const struct FX_RECT*, const struct FX_RECT*);
1224 int FXSYS_GetACP(void);
1225 FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1226 FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1227 #else
1228
1232 #define FXSYS_GetFullPathName GetFullPathName
1233
1237 #define FXSYS_GetModuleFileName GetModuleFileName
1238
1242 #define FXSYS_GetACP GetACP
1243 #endif
1244 #else
1245 char* FXSYS_itoa(int value, char* string, int radix);
1246 int FXSYS_GetACP(void);
1247 int FXSYS_WideCharToMultiByte(FX_DWORD codepage, FX_DWORD dwFlags, const wchar_t* wstr, int wlen,
1248 char* buf, int buflen, const char* default_str, int* pUseDefault);
1249 int FXSYS_MultiByteToWideChar(FX_DWORD codepage, FX_DWORD dwFlags, const char* bstr, int blen,
1250 wchar_t* buf, int buflen);
1251 FX_DWORD FXSYS_GetFullPathName(const char* filename, FX_DWORD buflen, char* buf, char** filepart);
1252 FX_DWORD FXSYS_GetModuleFileName(void* hModule, char* buf, FX_DWORD bufsize);
1253
1254 char* FXSYS_strlwr(char* str);
1255 char* FXSYS_strupr(char* str);
1256 int FXSYS_stricmp(const char*, const char*);
1257 int FXSYS_wcsicmp(const wchar_t *string1, const wchar_t *string2);
1258
1259 wchar_t* FXSYS_wcslwr(wchar_t* str);
1260 wchar_t* FXSYS_wcsupr(wchar_t* str);
1261 #endif
1262 //<<<+++OPENSOURCE_MUST_END
1263
1264 //*****************************************************************************
1265 //* Memory utilities
1266 //*****************************************************************************
1271
1284 void* FXSYS_memcpy32(void* dst, const void* src, size_t size);
1285
1302 FX_INT32 FXSYS_memcmp32(const void* buf1, const void* buf2, size_t size);
1303
1315 void* FXSYS_memset32(void* dst, FX_INT32 v, size_t size);
1316
1328 void* FXSYS_memset8(void* dst, FX_BYTE v, size_t size);
1329
1339 void* FXSYS_memmove32(void* dst, const void* src, size_t size);
1341 //<<<+++OPENSOURCE_MUST_END
1342
1343 //<<<+++OPENSOURCE_MUST_BEGIN
1344 #ifdef __cplusplus
1345 }
1346 #endif
1347 //<<<+++OPENSOURCE_MUST_END
1348
1349 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1354
1355 #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_METROWERKS_
1356 #ifdef __cplusplus
1357 extern "C" {
1358 #endif
1359
1360 /* Metrowerks for Palm OS (9.3) doesn't support standard math.h */
1361 extern double __ieee754_pow(double, double);
1362 extern double __ieee754_sqrt(double);
1363 extern double __fabs(double);
1364 extern double __ieee754_atan2(double, double);
1365 extern double __ceil(double);
1366 extern double __floor(double);
1367 extern double __cos(double);
1368 extern double __ieee754_acos(double);
1369 extern double __sin(double);
1370 extern double __ieee754_log(double);
1371 extern double __ieee754_log10(double);
1372
1373 #define FXSYS_pow(x, y) __ieee754_pow(x, y)
1374 #define FXSYS_sqrt(x) __ieee754_sqrt(x)
1375 #define FXSYS_fabs(x) __fabs(x)
1376 #define FXSYS_atan2(x, y) __ieee754_atan2(x, y)
1377 #define FXSYS_ceil(x) __ceil(x)
1378 #define FXSYS_floor(x) __floor(x)
1379 #define FXSYS_cos(x) __cos(x)
1380 #define FXSYS_acos(x) __ieee754_acos(x)
1381 #define FXSYS_sin(x) __sin(x)
1382 #define FXSYS_log(x) __ieee754_log(x)
1383 #define FXSYS_log10(x) __ieee754_log10(x)
1384
1385 #ifdef __cplusplus
1386 }
1387 #endif
1388 #else
1389 #include <math.h>
1390 #if _FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN64_ || _FX_OS_ == _FX_LINUX_DESKTOP_
1391
1395 #define FXSYS_pow powf
1396
1400 #define FXSYS_sqrt sqrtf
1401
1405 #define FXSYS_fabs fabsf
1406
1410 #define FXSYS_atan2 atan2f
1411
1415 #define FXSYS_ceil ceilf
1416
1420 #define FXSYS_floor floorf
1421
1425 #define FXSYS_cos cosf
1426
1430 #define FXSYS_acos acosf
1431
1435 #define FXSYS_sin sinf
1436
1440 #define FXSYS_log logf
1441
1445 #define FXSYS_log10 log10f
1446
1450 #define FXSYS_fmod fmodf
1451 #else
1452 #define FXSYS_pow(a, b) (FX_FLOAT)pow(a, b)
1453 #define FXSYS_sqrt(a) (FX_FLOAT)sqrt(a)
1454 #define FXSYS_fabs(a) (FX_FLOAT)fabs(a)
1455 #define FXSYS_atan2(a, b) (FX_FLOAT)atan2(a, b)
1456 #define FXSYS_ceil(a) (FX_FLOAT)ceil(a)
1457 #define FXSYS_floor(a) (FX_FLOAT)floor(a)
1458 #define FXSYS_cos(a) (FX_FLOAT)cos(a)
1459 #define FXSYS_acos(a) (FX_FLOAT)acos(a)
1460 #define FXSYS_sin(a) (FX_FLOAT)sin(a)
1461 #define FXSYS_log(a) (FX_FLOAT)log(a)
1462 #define FXSYS_log10(a) (FX_FLOAT)log10(a)
1463 #define FXSYS_fmod(a, b) (FX_FLOAT)fmod(a, b)
1464 #endif
1465 #endif
1466
1467 #if !defined(_FX_NO_ANSIC_)
1468
1472 #define FXSYS_abs abs
1473 #else
1474 #define FXSYS_abs(a) ((a)<0?-(a):(a))
1475 #endif
1476
1478 //<<<+++OPENSOURCE_MUST_END
1479
1480 //<<<+++OPENSOURCE_MUST_BEGIN
1481 #ifdef __cplusplus
1482 extern "C" {
1483 #endif
1484 //<<<+++OPENSOURCE_MUST_END
1485
1486 //<<<+++OPENSOURCE_MUST_BEGIN LIC==FOXIT
1487 #ifdef _FX_NO_GLOBAL_
1488 /* If platform doesn't support global variable, then we have to get from static functions */
1490 void FXSYS_SetStaticPointer1(void*);
1492 void* FXSYS_GetStaticPointer1(void);
1494 void FXSYS_SetStaticPointer2(void*);
1496 void* FXSYS_GetStaticPointer2(void);
1497 #endif
1498
1499 /* CPU byte order */
1500 #if _FX_ENDIAN_ == _FX_BIG_ENDIAN_
1501 #define _FX_MSB_FIRST_
1502 #define FXDWORD_FROM_LSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1503 #define FXDWORD_FROM_MSBFIRST(i) (i)
1504 #else
1505 #define _FX_LSB_FIRST_
1506 #define FXDWORD_FROM_LSBFIRST(i) (i)
1507 #define FXDWORD_FROM_MSBFIRST(i) ( ((FX_BYTE)(i) << 24) | ((FX_BYTE)((i) >> 8) << 16) | ((FX_BYTE)((i) >> 16) << 8) | (FX_BYTE)((i) >> 24) )
1508 #endif
1509
1510 #if _FX_CPU_ == _FX_X86_ || _FX_CPU_ == _FX_X64_ || _FX_CPU_ == _FX_ARM64_ || \
1511 _FX_CPU_ == _FX_MIPS64_ || _FX_CPU_ == _FX_LOONGARCH64_
1512 #define FXDWORD_GET_LSBFIRST(p) (*(FX_DWORD*)(p))
1513 #else
1514 #define FXDWORD_GET_LSBFIRST(p) ((((FX_LPBYTE)(p))[3] << 24) | (((FX_LPBYTE)(p))[2] << 16) | (((FX_LPBYTE)(p))[1] << 8) | (((FX_LPBYTE)(p))[0]))
1515 #endif
1516
1517 #define FXDWORD_GET_MSBFIRST(p) ((((FX_LPBYTE)(p))[0] << 24) | (((FX_LPBYTE)(p))[1] << 16) | (((FX_LPBYTE)(p))[2] << 8) | (((FX_LPBYTE)(p))[3]))
1518
1519 #define FXSYS_HIBYTE(word) ((FX_BYTE)((word) >> 8))
1520 #define FXSYS_LOBYTE(word) ((FX_BYTE)(word))
1521 #define FXSYS_HIWORD(dword) ((FX_WORD)((dword) >> 16))
1522 #define FXSYS_LOWORD(dword) ((FX_WORD)(dword))
1523
1525 #define FXSYS_strtol strtol
1526
1534 FX_INT32 FXSYS_atoi(FX_LPCSTR str);
1542 FX_INT32 FXSYS_wtoi(FX_LPCWSTR str);
1550 FX_INT64 FXSYS_atoi64(FX_LPCSTR str);
1558 FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str);
1568 FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix);
1578 FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix);
1586 int FXSYS_round(FX_FLOAT f);
1588 #define FXSYS_Mul(a, b) ((a) * (b))
1589
1590 #define FXSYS_Div(a, b) ((a) / (b))
1591
1592 #define FXSYS_MulDiv(a, b, c) ((a) * (b) / (c))
1593
1594 #define FXSYS_sqrt2(a, b) (FX_FLOAT)FXSYS_sqrt((a)*(a) + (b)*(b))
1595
1596 //*****************************************************************************
1597 //* Multiple thread controls
1598 //*****************************************************************************
1600 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1601 typedef CRITICAL_SECTION FX_MUTEX;
1602 FX_DEFINEHANDLE(FX_RWLOCK)
1603 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_ == _FX_LINUX_EMBEDDED_ || _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_ || _FX_OS_ == _FX_ANDROID_
1604 #include <pthread.h>
1605 typedef pthread_mutex_t FX_MUTEX;
1606 #if _FX_OS_ == _FX_ANDROID_
1607 FX_DEFINEHANDLE(FX_RWLOCK)
1608 #else
1609 typedef pthread_rwlock_t FX_RWLOCK;
1610 #endif
1611 #else
1612 FX_DEFINEHANDLE(FX_MUTEX)
1613 FX_DEFINEHANDLE(FX_RWLOCK)
1614 #endif
1615 // The following five functions are defined in fx_process.h, please refer there.
1616 FX_BOOL FX_Mutex_Initialize(FX_MUTEX* pMutex);
1617 void FX_Mutex_Destroy(FX_MUTEX* pMutex);
1618 FX_BOOL FX_Mutex_TryLock(FX_MUTEX* pMutex);
1619 void FX_Mutex_Lock(FX_MUTEX* pMutex);
1620 void FX_Mutex_Unlock(FX_MUTEX* pMutex);
1621
1622 #define FX_CRITICAL_SECTION FX_MUTEX
1623 #define FX_InitializeCriticalSection(a) FX_Mutex_Initialize(a)
1624 #define FX_DeleteCriticalSection(a) FX_Mutex_Destroy(a)
1625 #define FX_TryEnterCriticalSection(a) FX_Mutex_TryLock(a)
1626 #define FX_EnterCriticalSection(a) FX_Mutex_Lock(a)
1627 #define FX_LeaveCriticalSection(a) FX_Mutex_Unlock(a)
1628
1630 #if (_FX_OS_ == _FX_WIN32_DESKTOP_ || _FX_OS_ == _FX_WIN32_MOBILE_ || _FX_OS_ == _FX_WIN64_) && !defined(_FX_NO_WINDOWS_)
1631 typedef void* FX_SPINLOCK;
1632 #elif _FX_OS_ == _FX_LINUX_DESKTOP_ || _FX_OS_==_FX_LINUX_EMBEDDED_
1633 #ifdef _FX_SPINLOCK_USEGCCCAS_
1634 typedef size_t FX_SPINLOCK;
1635 #else
1636 #ifndef _CHROME_PNACL_
1637 typedef pthread_spinlock_t FX_SPINLOCK;
1638 #else
1639 typedef size_t FX_SPINLOCK;
1640 #endif
1641 #endif
1642 #elif _FX_OS_ == _FX_MACOSX_ || _FX_OS_ == _FX_IOS_
1643 typedef OSSpinLock FX_SPINLOCK;
1644 #else // android/embeded linux/other os
1645 FX_DEFINEHANDLE(FX_SPINLOCK)
1646 #endif
1647 //<<<+++OPENSOURCE_MUST_END
1648
1649 //<<<+++OPENSOURCE_MUST_BEGIN
1650 #ifdef __cplusplus
1651 };
1652 #endif
1653 //<<<+++OPENSOURCE_MUST_END
1654
1655 #if _FX_OS_ == _FX_PALMOS_ && _FX_COMPILER_ == _FX_PACC_
1656 #include <errtrycatch.h>
1657 #define setjmp ErrSetJump
1658 #define longjmp ErrLongJump
1659 #define jmp_buf ErrJumpBuf
1660 #else
1661 #include <setjmp.h>
1662 #endif
1663
1664 #if _FX_OS_ == _FX_MACOSX_
1665 #include <Carbon/Carbon.h>
1666 #elif _FX_OS_ == _FX_IOS_
1667 #include <CoreText/CoreText.h>
1668 #include <CoreGraphics/CoreGraphics.h>
1669 #endif
1670 //<<<+++OPENSOURCE_MUST_END
1671 //<<<+++OPENSOURCE_MUST_BEGIN
1672 #endif /* _FPDF_SYSTEM_H_ */
1673 //<<<+++OPENSOURCE_MUST_END
1674
1677 //<<<+++OPENSOURCE_END
FX_Mutex_Unlock
void FX_Mutex_Unlock(FX_MUTEX *pMutex)
Unlock a mutex.
FX_BYTE
unsigned char FX_BYTE
Byte (8 bits).
Definition: fx_system.h:665
FX_LPCWORD
unsigned short const * FX_LPCWORD
Pointer to a WORD.
Definition: fx_system.h:681
FX_DWORD
unsigned long FX_DWORD
32-bit unsigned integer.
Definition: fx_system.h:726
FXSYS_i64tow
FX_LPCWSTR FXSYS_i64tow(FX_INT64 value, FX_LPWSTR str, int radix)
Convert an integer to an wide string.
FXSYS_stricmp
#define FXSYS_stricmp
Compare two ANSIC strings. case-insensitive.
Definition: fx_system.h:1186
FX_ERR
int FX_ERR
Error indicator.
Definition: fx_system.h:694
FXSYS_fprintf
#define FXSYS_fprintf
Print formatted data to a file.
Definition: fx_system.h:975
FXSYS_memcmp32
FX_INT32 FXSYS_memcmp32(const void *buf1, const void *buf2, size_t size)
Compare data in two buffers.
FX_LPCVOID
void const * FX_LPCVOID
Pointer to any constant type.
Definition: fx_system.h:656
FXSYS_round
int FXSYS_round(FX_FLOAT f)
Get nearest integer.
FX_WCHAR
wchar_t FX_WCHAR
Compiler dependant Unicode character (16-bit for Microsoft Compiler, 32-bit for gcc).
Definition: fx_system.h:732
FXSYS_atoi64
FX_INT64 FXSYS_atoi64(FX_LPCSTR str)
Convert an ANSI string to an integer.
FXSYS_memcpy
#define FXSYS_memcpy
Copy from one buffer to another.
Definition: fx_system.h:1114
FX_INTPTR
INT_PTR FX_INTPTR
Signed integral type for pointer precision.
Definition: fx_system.h:750
FXSYS_strlwr
#define FXSYS_strlwr
Convert a ANSIC string to lowercase.
Definition: fx_system.h:1176
FXSYS_atoi
FX_INT32 FXSYS_atoi(FX_LPCSTR str)
Convert an ANSI string to an integer.
FXSYS_memset8
void * FXSYS_memset8(void *dst, FX_BYTE v, size_t size)
Set buffer data to specified value.
FXSYS_wcscmp
#define FXSYS_wcscmp
Compare wide-character strings.
Definition: fx_system.h:1033
FXSYS_memchr
#define FXSYS_memchr
Search for a byte in a memory block.
Definition: fx_system.h:1131
FXSYS_wcsncmp
#define FXSYS_wcsncmp
Compare characters of two wide-character strings.
Definition: fx_system.h:1061
FXSYS_vswprintf
#define FXSYS_vswprintf
Write formatted output wide character string using a pointer to a list of arguments.
Definition: fx_system.h:1067
FXSYS_strchr
#define FXSYS_strchr
Find a character in a ANSIC string.
Definition: fx_system.h:874
FXSYS_strlen
#define FXSYS_strlen
Get the length of a ANSIC string.
Definition: fx_system.h:879
FXSYS_memset32
void * FXSYS_memset32(void *dst, FX_INT32 v, size_t size)
Set buffer data to specified value.
FXSYS_wcslwr
#define FXSYS_wcslwr
Convert a wide-character string to lowercase.
Definition: fx_system.h:1214
FX_CHAR
char FX_CHAR
8-bit Windows (ANSI) character.
Definition: fx_system.h:701
FXSYS_strncpy
#define FXSYS_strncpy
Copy an ANSIC string with length limitation.
Definition: fx_system.h:899
FX_LPDWORD
unsigned long * FX_LPDWORD
Pointer to a DWORD.
Definition: fx_system.h:728
FX_LPWSTR
wchar_t * FX_LPWSTR
Pointer to Unicode characters.
Definition: fx_system.h:734
FX_LPSTR
char * FX_LPSTR
Pointer to 8-bit Windows (ANSI) characters.
Definition: fx_system.h:703
FX_LPVOID
void * FX_LPVOID
Pointer to any type.
Definition: fx_system.h:654
FXSYS_memmove
#define FXSYS_memmove
Moves one buffer to another. If some regions of the source area and the destination overlap,...
Definition: fx_system.h:1121
FXSYS_wtoi
FX_INT32 FXSYS_wtoi(FX_LPCWSTR str)
Convert a wide string to an integer.
FXSYS_itoa
#define FXSYS_itoa
Convert an integer to a ANSIC string.
Definition: fx_system.h:1171
FX_DEFINEHANDLE
#define FX_DEFINEHANDLE(name)
Macro to define a handle type.
Definition: fx_system.h:772
FX_Mutex_Destroy
void FX_Mutex_Destroy(FX_MUTEX *pMutex)
Destroy a mutex.
FX_SPINLOCK
void * FX_SPINLOCK
Definition for spinlock.
Definition: fx_system.h:1631
FXSYS_wcslen
#define FXSYS_wcslen
Get the length of a wide-character string.
Definition: fx_system.h:1028
FX_POSITION
void * FX_POSITION
A value used to denote the position of an element in a collection.
Definition: fx_system.h:658
FX_INT32
int FX_INT32
32-bit signed integer.
Definition: fx_system.h:683
FXSYS_wtoi64
FX_INT64 FXSYS_wtoi64(FX_LPCWSTR str)
Convert a wide string to an integer.
FXSYS_memmove32
void * FXSYS_memmove32(void *dst, const void *src, size_t size)
Move source buffer data into destination.
FX_Mutex_TryLock
FX_BOOL FX_Mutex_TryLock(FX_MUTEX *pMutex)
Try to lock a mutex.
FX_SHORT
short FX_SHORT
Short integer (16 bits).
Definition: fx_system.h:675
FXSYS_WideCharToMultiByte
#define FXSYS_WideCharToMultiByte
Maps a wide-character string to a character string.
Definition: fx_system.h:1204
FXSYS_fopen
#define FXSYS_fopen
Open a file.
Definition: fx_system.h:935
FXSYS_bsearch
#define FXSYS_bsearch
Performs a binary search of a sorted array. A generic algorithm.
Definition: fx_system.h:1158
FXSYS_GetFullPathName
#define FXSYS_GetFullPathName
Get the full path and file name of a specified file.
Definition: fx_system.h:1232
FX_LPCWSTR
wchar_t const * FX_LPCWSTR
Pointer to constant Unicode characters.
Definition: fx_system.h:736
FX_Mutex_Initialize
FX_BOOL FX_Mutex_Initialize(FX_MUTEX *pMutex)
Initialize a mutex.
FXSYS_assert
#define FXSYS_assert
Assertion.
Definition: fx_system.h:804
FXSYS_memset
#define FXSYS_memset
Use given character to initialize the buffer.
Definition: fx_system.h:1126
FXSYS_GetACP
#define FXSYS_GetACP
Retrieve the current ANSI code-page identifier for the system.
Definition: fx_system.h:1242
FXSYS_wfopen
#define FXSYS_wfopen
Open a file using wide-string parameters. Only supported on Windows platforms now.
Definition: fx_system.h:1004
FX_WORD
unsigned short FX_WORD
16-bit unsigned integer.
Definition: fx_system.h:677
FXSYS_fread
#define FXSYS_fread
Reads data from a file.
Definition: fx_system.h:965
FXSYS_fclose
#define FXSYS_fclose
Close a file.
Definition: fx_system.h:940
FXSYS_memcmp
#define FXSYS_memcmp
Compares two buffers.
Definition: fx_system.h:1109
FXSYS_wcsicmp
#define FXSYS_wcsicmp
Compare two wide character strings. case-insensitive.
Definition: fx_system.h:1199
FX_LPCSTR
char const * FX_LPCSTR
Pointer to constant 8-bit Windows (ANSI) characters.
Definition: fx_system.h:705
FX_LPCBYTE
unsigned char const * FX_LPCBYTE
Pointer to a constant FX_BYTE.
Definition: fx_system.h:669
FXSYS_strncmp
#define FXSYS_strncmp
Compare characters of two ANSIC strings.
Definition: fx_system.h:884
FXSYS_FILE
#define FXSYS_FILE
File structure.
Definition: fx_system.h:930
FXSYS_fflush
#define FXSYS_fflush
Flush file.
Definition: fx_system.h:980
FX_UINTPTR
UINT_PTR FX_UINTPTR
Unsigned integral type for pointer precision.
Definition: fx_system.h:752
FXSYS_vsprintf
#define FXSYS_vsprintf
Write formatted output using a pointer to a list of arguments.
Definition: fx_system.h:869
FXSYS_qsort
#define FXSYS_qsort
Performs a quick sort. A generic algorithm.
Definition: fx_system.h:1148
FX_UINT32
FX_DWORD FX_UINT32
unsigned 32bits integer.
Definition: fx_system.h:767
FXSYS_ftell
#define FXSYS_ftell
Gets the current position of a file pointer.
Definition: fx_system.h:960
FX_FLOAT
float FX_FLOAT
32-bit floating-point number.
Definition: fx_system.h:685
FX_UINT16
unsigned short FX_UINT16
Unsigned 16bits integer.
Definition: fx_system.h:673
FXSYS_MultiByteToWideChar
#define FXSYS_MultiByteToWideChar
Maps a character string to a wide-character string.
Definition: fx_system.h:1209
FX_INT8
signed char FX_INT8
Signed 8bits integer.
Definition: fx_system.h:661
FX_QWORD
FX_UINT64 FX_QWORD
unsigned quad-word integer.
Definition: fx_system.h:769
FXSYS_sprintf
#define FXSYS_sprintf
Write formatted data to a ANSIC string.
Definition: fx_system.h:853
FX_UINT8
unsigned char FX_UINT8
Unsigned 8bits integer.
Definition: fx_system.h:663
FXSYS_strstr
#define FXSYS_strstr
Find a substring.
Definition: fx_system.h:904
FXSYS_wcstombs
#define FXSYS_wcstombs
Converts a sequence of wide characters to a corresponding sequence of multi-byte characters.
Definition: fx_system.h:1089
FX_Mutex_Lock
void FX_Mutex_Lock(FX_MUTEX *pMutex)
Lock a mutex.
FXSYS_mbstowcs
#define FXSYS_mbstowcs
Converts a sequence of multi-byte characters to a corresponding sequence of wide characters.
Definition: fx_system.h:1084
FX_BOOL
int FX_BOOL
Boolean variable (should be TRUE or FALSE).
Definition: fx_system.h:691
FX_LPWORD
unsigned short * FX_LPWORD
Pointer to a WORD.
Definition: fx_system.h:679
FX_INT16
short FX_INT16
Signed 16bits integer.
Definition: fx_system.h:671
FX_LPBYTE
unsigned char * FX_LPBYTE
Pointer to a FX_BYTE.
Definition: fx_system.h:667
FXSYS_strcpy
#define FXSYS_strcpy
Copy an ANSIC string.
Definition: fx_system.h:894
FX_RECT
Definition: fx_coordinates.h:596
FXSYS_wcsupr
#define FXSYS_wcsupr
Convert a wide-character string to uppercase.
Definition: fx_system.h:1219
FXSYS_fwrite
#define FXSYS_fwrite
Writes data to a file.
Definition: fx_system.h:970
FXSYS_wcschr
#define FXSYS_wcschr
Find a wide-character in a wide-character string.
Definition: fx_system.h:1051
FXSYS_strupr
#define FXSYS_strupr
Convert a ANSIC string to uppercase.
Definition: fx_system.h:1181
FXSYS_GetModuleFileName
#define FXSYS_GetModuleFileName
Get the fully-qualified path for specified module.
Definition: fx_system.h:1237
FXSYS_wcsstr
#define FXSYS_wcsstr
Find a sub-wide-character-string.
Definition: fx_system.h:1056
FXSYS_fseek
#define FXSYS_fseek
Moves the file pointer to a specified location.
Definition: fx_system.h:955
FX_MUTEX
CRITICAL_SECTION FX_MUTEX
Definition for mutex/critical section and read-write lock.
Definition: fx_system.h:1601
FXSYS_i64toa
FX_LPCSTR FXSYS_i64toa(FX_INT64 value, FX_LPSTR str, int radix)
Convert an integer to an ANSI string.
FXSYS_strcmp
#define FXSYS_strcmp
Compare ANSIC strings.
Definition: fx_system.h:889
FXSYS_memcpy32
void * FXSYS_memcpy32(void *dst, const void *src, size_t size)
Copy buffer data from source to destination.