1 /*****************************************************************************
2  *
3  * Copyright (c) 2008-2010, CoreCodec, Inc.
4  * All rights reserved.
5  *
6  * Redistribution and use in source and binary forms, with or without
7  * modification, are permitted provided that the following conditions are met:
8  *     * Redistributions of source code must retain the above copyright
9  *       notice, this list of conditions and the following disclaimer.
10  *     * Redistributions in binary form must reproduce the above copyright
11  *       notice, this list of conditions and the following disclaimer in the
12  *       documentation and/or other materials provided with the distribution.
13  *     * Neither the name of CoreCodec, Inc. nor the
14  *       names of its contributors may be used to endorse or promote products
15  *       derived from this software without specific prior written permission.
16  *
17  * THIS SOFTWARE IS PROVIDED BY CoreCodec, Inc. ``AS IS'' AND ANY
18  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20  * DISCLAIMED. IN NO EVENT SHALL CoreCodec, Inc. BE LIABLE FOR ANY
21  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
22  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
23  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
24  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
26  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27  *
28  ****************************************************************************/
29 
30 #ifndef __PORTAB_H
31 #define __PORTAB_H
32 
33 #if defined(__GNUC__) && defined(__palmos__)
34 #undef __WCHAR_TYPE__
35 #define __WCHAR_TYPE__ unsigned short
36 #endif
37 
38 #include <string.h>
39 #include <ctype.h>
40 #include <stdarg.h>
41 #include <stddef.h>
42 #include <limits.h>
43 
44 #undef INLINE
45 #undef NOINLINE
46 #undef IS_LITTLE_ENDIAN
47 #undef IS_BIG_ENDIAN
48 
49 #if defined(__palmos__)
50 
51 #define TARGET_PALMOS
52 #define NO_FLOATINGPOINT
53 #define CONFIG_BLOCK_RDONLY
54 
55 #elif defined(_EE)
56 
57 #define TARGET_PS2SDK
58 #define TARGET_DESKTOP
59 #define RESOURCE_COREC
60 
61 #elif defined(__SYMBIAN32__)
62 
63 #if defined(__SERIES60_3X__)
64 #define SYMBIAN90
65 #define SERIES60
66 #elif defined(__SERIES60_10__)
67 #define SYMBIAN60
68 #define SERIES60
69 #elif defined(__SERIES60_20__)
70 #define SYMBIAN70
71 #define SERIES60
72 #elif defined(__SERIES80__)
73 #define SYMBIAN70
74 #define SERIES80
75 #elif defined(__SERIES90__)
76 #define SYMBIAN70
77 #define SERIES90
78 #elif defined(__UIQ3__)
79 #define SYMBIAN90
80 #define UIQ
81 #elif defined(__UIQ__)
82 #define SYMBIAN70
83 #define UIQ
84 #endif
85 
86 #define TARGET_SYMBIAN
87 #ifndef UNICODE
88 #define UNICODE
89 #endif
90 
91 #ifdef __MARM__
92 #define ARM
93 #endif
94 
95 #elif defined(_WIN32_WCE)
96 
97 #if !defined(CONFIG_WINCE2) && (_WIN32_WCE>=200 && _WIN32_WCE<300)
98 #define CONFIG_WINCE2
99 #endif
100 
101 #if defined(WIN32_PLATFORM_WFSP)
102 #define TARGET_SMARTPHONE
103 #endif
104 
105 #define TARGET_WINCE
106 #define TARGET_WIN
107 
108 #ifndef UNICODE
109 #define UNICODE
110 #endif
111 
112 #elif defined(_WIN64)
113 
114 #define TARGET_WIN64
115 #define TARGET_WIN
116 #define TARGET_DESKTOP
117 
118 #elif defined(_WIN32)
119 
120 #define TARGET_WIN32
121 #define TARGET_WIN
122 #define TARGET_DESKTOP
123 
124 #elif defined(__APPLE__)
125 
126 #ifndef TARGET_IPHONE
127 #include <TargetConditionals.h> // iPhone information is defined within the SDK in which Xcode is pointed to
128 #endif
129 
130 #define TARGET_OSX
131 #undef UNICODE // tchar_t is UTF-8 for OS X
132 
133 #ifdef TARGET_OS_IPHONE // defined in TargetConditionals.h
134 #define TARGET_IPHONE
135 #define TARGET_IPHONE_SDK
136 
137 #if !TARGET_IPHONE_SIMULATOR
138 #define TARGET_IPHONE_DEVICE
139 #endif
140 
141 
142 #if defined(__arm__)
143 #define ARM
144 #endif
145 
146 #endif
147 
148 #ifndef TARGET_IPHONE
149 #define TARGET_DESKTOP // only for dekstop (not iPhone or Apple TV)
150 #endif
151 
152 #elif defined(__QNXNTO__)
153 
154 #if defined(__arm__)
155 #define ARM
156 #endif
157 #define TARGET_QNX
158 
159 #elif defined(__ANDROID__)
160 
161 #define TARGET_ANDROID
162 
163 #if defined(__arm__)
164 #define ARM
165 #endif
166 
167 #elif defined(__linux__) || defined(__CYGWIN__) || defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
168 
169 #define TARGET_LINUX
170 
171 #ifndef TARGET_QTOPIA // qtopia defines desktop manually
172 #define TARGET_DESKTOP // not necessarily
173 #endif
174 
175 #else
176 #error Platform not supported by Core-C!
177 #endif
178 
179 #if defined(__powerpc__) || defined(__PPC__) || defined(__POWERPC__)
180 #define POWERPC
181 #define IS_BIG_ENDIAN
182 #endif
183 
184 #if defined(__sparc)
185 #if defined(_LP64)
186 #define SPARC64
187 #define CPU_64BITS
188 #else
189 #define SPARC32
190 #endif
191 #define IS_BIG_ENDIAN
192 #endif
193 
194 #if defined(TARGET_LINUX) || defined(TARGET_ANDROID)
195 #if defined(__DragonFly__) || defined(__NetBSD__) || defined(__OpenBSD__)
196 #include <sys/endian.h>
197 #else
198 #include <endian.h>
199 #endif
200 #if __BYTE_ORDER == __LITTLE_ENDIAN
201 #define IS_LITTLE_ENDIAN
202 #elif __BYTE_ORDER == __BIG_ENDIAN
203 #define IS_BIG_ENDIAN
204 #endif
205 #endif
206 
207 #if defined(_M_X64) || defined(__amd64__)
208 #define IX86_64
209 #define CPU_64BITS
210 #endif
211 
212 #if defined(_M_IA64)
213 #define IA64
214 #define CPU_64BITS
215 #endif
216 
217 #if defined(__mips) && !defined(MIPS)
218 #define MIPS
219 #endif
220 
221 #ifdef MIPS
222 #if defined(__mips64) || defined(CONFIG_MIPS64)
223 #define MIPS64
224 #else
225 #define MIPS32
226 #endif
227 #endif
228 
229 #if defined(_M_IX86) || defined(__i386) || defined(__i686)
230 #define IX86
231 #endif
232 
233 #if !defined(IS_LITTLE_ENDIAN) && !defined(IS_BIG_ENDIAN)
234 #define IS_LITTLE_ENDIAN
235 #endif
236 
237 #define TICKSPERSEC			16384
238 #define TIMEPERSEC          (TICKSPERSEC>>4)
239 
240 #ifndef M_PI
241 #define M_PI    3.14159265358979323846264338327950288
242 #endif
243 
244 #ifdef _MSC_VER
245 
246 #define _CRTDBG_MAP_ALLOC
247 #include <stdlib.h>
248 #include <malloc.h>
249 #ifndef TARGET_WINCE
250 #include <crtdbg.h>
251 #endif
252 
253 #ifndef strncasecmp
254 #define strncasecmp(x,y,z) _strnicmp(x,y,z)
255 #endif
256 #ifndef strcasecmp
257 #define strcasecmp(x,y)    _stricmp(x,y)
258 #endif
259 #ifndef stricmp
260 #define stricmp(x,y)       _stricmp(x,y)
261 #endif
262 #ifndef strnicmp
263 #define strnicmp(x,y,z)    _strnicmp(x,y,z)
264 #endif
265 
266 #if _MSC_VER >= 1400
267 #pragma comment(linker, "/nodefaultlib:libc.lib")
268 #pragma comment(linker, "/nodefaultlib:libcd.lib")
269 //#pragma comment(linker, "/nodefaultlib:oldnames.lib")
270 #elif defined(_WIN32_WCE)
271 // allow evc3/evc4 compiling with vs2005 object files
272 #pragma comment(linker, "/nodefaultlib:libcmt.lib")
273 #pragma comment(linker, "/nodefaultlib:oldnames.lib")
274 #endif
275 
276 #ifndef alloca
277 #define alloca _alloca
278 #endif
279 
280 #ifndef inline
281 #define inline __inline
282 #endif
283 
284 #ifndef _UINTPTR_T_DEFINED
285 typedef unsigned int uintptr_t;
286 #define _UINTPTR_T_DEFINED
287 #endif
288 
289 #ifndef _INTPTR_T_DEFINED
290 typedef signed int intptr_t;
291 #define _INTPTR_T_DEFINED
292 #endif
293 
294 #if _MSC_VER >= 1400
295 #define NOINLINE __declspec(noinline)
296 #else
297 #define NOINLINE
298 #endif
299 
300 #define INLINE __forceinline
301 
302 #ifndef STDCALL
303 #define STDCALL __stdcall
304 #endif
305 
306 #ifndef CDECL
307 #define CDECL __cdecl
308 #endif
309 
310 #if !defined(COMPILER_MSVC)
311 #define COMPILER_MSVC
312 #endif
313 
314 #if defined(__cplusplus)
315 #define SORTPP_PASS // to avoid a problem if winnt.h is included after us
316 #define NOMINMAX // conflict with <algorithm>
317 #endif
318 
319 #else /* _MSC_VER */
320 
321 #include <stdlib.h>
322 
323 #if defined(TARGET_SYMBIAN)
324 
325 typedef signed long int32_t;
326 typedef unsigned long uint32_t;
327 typedef signed short int16_t;
328 typedef unsigned short uint16_t;
329 typedef signed char int8_t;
330 typedef unsigned char uint8_t;
331 typedef signed long long int64_t;
332 typedef unsigned long long uint64_t;
333 typedef uint32_t uintptr_t;
334 typedef int32_t intptr_t;
335 typedef signed int int_fast32_t;
336 typedef unsigned int uint_fast32_t;
337 typedef signed int int_fast16_t;
338 typedef unsigned int uint_fast16_t;
339 typedef signed char int_fast8_t;
340 typedef unsigned char uint_fast8_t;
341 typedef signed long long int_fast64_t;
342 typedef unsigned long long uint_fast64_t;
343 
344 #elif !defined(__GLIBC__) && !defined(__MINGW32__) && !defined(TARGET_PS2SDK) && !defined(TARGET_IPHONE) && !defined(TARGET_ANDROID) && !defined(__DragonFly__) && !defined(__QNXNTO__)
345 
346 #include <inttypes.h>
347 
348 #ifdef SPARC64
349   typedef int64_t int_fast32_t;
350   typedef uint64_t uint_fast32_t;
351   typedef int64_t int_fast16_t;
352   typedef uint64_t uint_fast16_t;
353 #else
354   typedef int32_t int_fast32_t;
355   typedef uint32_t uint_fast32_t;
356 # ifndef __APPLE__
357   typedef int32_t int_fast16_t;
358   typedef uint32_t uint_fast16_t;
359 # endif
360 #endif
361 
362 typedef int8_t int_fast8_t;
363 typedef uint8_t uint_fast8_t;
364 typedef int64_t int_fast64_t;
365 typedef uint64_t uint_fast64_t;
366 
367 #else
368 #include <stdint.h>
369 #endif
370 
371 #if defined(__GNUC__) && (__GNUC__ > 3 || __GNUC__ == 3 && __GNUC_MINOR__ > 0) && !defined(always_inline)
372 #define INLINE __attribute__((always_inline)) inline
373 #else
374 #define INLINE inline
375 #endif
376 
377 #if __GNUC__ >= 3
378   #define NOINLINE __attribute__((noinline))
379 #else
380   #define NOINLINE
381 #endif
382 
383 #if !defined(IX86) || defined(__CW32__)
384 #define __stdcall
385 #define __cdecl
386 #define STDCALL
387 #define CDECL
388 #else
389 #ifndef STDCALL
390 #define STDCALL __attribute__((stdcall))
391 #endif
392 #ifndef CDECL
393 #define CDECL __attribute__((cdecl))
394 #endif
395 #endif
396 
397 #if !defined(COMPILER_GCC) && defined(__GNUC__)
398 #define COMPILER_GCC
399 #endif
400 
401 #endif /* _MSC_VER */
402 
403 #if !defined(_STDINT_H) && !defined(_STDINT_H_) && !defined(_UINT64_T_DECLARED) && !defined(_STDINT_H_INCLUDED) // could be used elsewhere
404 
405 typedef signed long int32_t;
406 typedef unsigned long uint32_t;
407 typedef signed short int16_t;
408 typedef unsigned short uint16_t;
409 typedef signed char int8_t;
410 typedef unsigned char uint8_t;
411 typedef signed __int64 int64_t;
412 typedef unsigned __int64 uint64_t;
413 
414 #if defined(IX86_64) || defined(IA64)
415 typedef signed __int64 int_fast32_t;
416 typedef unsigned __int64 uint_fast32_t;
417 typedef signed __int64 int_fast16_t;
418 typedef unsigned __int64 uint_fast16_t;
419 typedef signed char int_fast8_t;
420 typedef unsigned char uint_fast8_t;
421 typedef signed __int64 int_fast64_t;
422 typedef unsigned __int64 uint_fast64_t;
423 #else
424 #if _MSC_VER >= 1400
425 typedef __w64 signed int int_fast32_t;
426 typedef __w64 unsigned int uint_fast32_t;
427 typedef __w64 signed int int_fast16_t;
428 typedef __w64 unsigned int uint_fast16_t;
429 #else
430 typedef signed int int_fast32_t;
431 typedef unsigned int uint_fast32_t;
432 typedef signed int int_fast16_t;
433 typedef unsigned int uint_fast16_t;
434 #endif
435 typedef signed char int_fast8_t;
436 typedef unsigned char uint_fast8_t;
437 typedef signed __int64 int_fast64_t;
438 typedef unsigned __int64 uint_fast64_t;
439 #endif
440 #endif
441 
442 #ifdef _MSC_VER
443 #define LL(x)   x##i64
444 #define ULL(x)  x##ui64
445 #define PRId64  "I64d"
446 #define PRIu64  "I64u"
447 #define PRIx64  "I64x"
448 #define TPRId64  L"I64d"
449 #define TPRIu64  L"I64u"
450 #define TPRIx64  L"I64x"
451 #else
452 #define LL(x)   x##ll
453 #define ULL(x)  x##ull
454 #ifndef PRId64
455 #define PRId64  "lld"
456 #endif
457 #ifndef PRIu64
458 #define PRIu64  "llu"
459 #endif
460 #ifndef PRIx64
461 #define PRIx64  "llx"
462 #endif
463 #define TPRId64  PRId64
464 #define TPRIu64  PRIu64
465 #define TPRIx64  PRIx64
466 #endif
467 
468 #define MAX_INT64 LL(0x7fffffffffffffff)
469 
470 #define MAX_TICK INT_MAX
471 
472 typedef int_fast32_t err_t;
473 typedef int_fast32_t bool_t;
474 typedef int_fast32_t tick_t;
475 typedef uint8_t boolmem_t; /* unsigned so ":1" bitmode should work */
476 typedef uint32_t fourcc_t;
477 typedef uint32_t rgbval_t;
478 
479 typedef struct cc_guid
480 {
481     uint32_t v1;
482     uint16_t v2;
483     uint16_t v3;
484     uint8_t v4[8];
485 } cc_guid;
486 
487 typedef struct cc_fraction
488 {
489 	int_fast32_t Num;
490 	int_fast32_t Den;
491 } cc_fraction;
492 
493 typedef struct cc_fraction64
494 {
495 	int_fast64_t Num;
496 	int_fast64_t Den;
497 } cc_fraction64;
498 
499 typedef struct cc_point
500 {
501 	int x;
502 	int y;
503 
504 } cc_point;
505 
506 typedef struct cc_point16
507 {
508 	int16_t x;
509 	int16_t y;
510 
511 } cc_point16;
512 
513 typedef struct cc_rect
514 {
515 	int x;
516 	int y;
517 	int Width;
518 	int Height;
519 
520 } cc_rect;
521 
522 #ifndef ZLIB_INTERNAL
523 
524 #undef T
525 #define TSIZEOF(name)	(sizeof(name)/sizeof(tchar_t))
526 
527 #if defined(UNICODE)
528 
529 #if defined(__GNUC__) && !defined(TARGET_SYMBIAN) && !defined(TARGET_PALMOS)
530 #include <wchar.h>
531 #endif
532 
533 #if defined(__GNUC__) && (__GNUC__<3) && defined(__cplusplus)
534 typedef __wchar_t tchar_t;
535 #else
536 typedef wchar_t tchar_t;
537 #endif
538 
539 #define tcsstr wcsstr
540 #define tcslen wcslen
541 #define tcschr wcschr
542 #define tcsrchr wcsrchr
543 #define tcscoll wcscoll
544 #define tcstod wcstod
545 #define tcscspn wcscspn
546 #define tcspbrk wcspbrk
547 #define tcstoul wcstoul
548 #define tcsftime wcsftime
549 #define T(a) L ## a
550 #else /* UNICODE */
551 typedef char tchar_t;
552 #define tcsstr strstr
553 #define tcslen strlen
554 #define tcschr strchr
555 #define tcsrchr strrchr
556 #define tcscoll strcoll
557 #define tcstod strtod
558 #define tcscspn strcspn
559 #define tcspbrk strpbrk
560 #define tcstoul strtoul
561 #define tcsftime strftime
562 #define T(a) a
563 #endif /* UNICODE */
564 
565 #define T__(x) T(x)
566 #endif
567 
568 #ifndef SIZEOF_WCHAR
569 #if defined(TARGET_OSX) || defined(TARGET_LINUX) || defined(TARGET_PS2SDK)
570 #define SIZEOF_WCHAR    4
571 #else
572 #define SIZEOF_WCHAR    2
573 #endif
574 #endif
575 
576 #if SIZEOF_WCHAR==2
577 typedef wchar_t utf16_t;
578 #else
579 typedef uint16_t utf16_t;
580 #endif
581 
582 #define tcscpy !UNSAFE!
583 #define tcscat !UNSAFE!
584 #define stprintf !UNSAFE!
585 #define vstprintf !UNSAFE!
586 
587 #if defined(_WIN32) || defined(TARGET_SYMBIAN)
588 #define DLLEXPORT __declspec(dllexport)
589 #define DLLIMPORT __declspec(dllimport)
590 #define DLLHIDDEN
591 #elif defined(__GNUC__) && ((__GNUC__*100 + __GNUC_MINOR__) >= 340)
592 #define DLLEXPORT __attribute__ ((visibility("default")))
593 #define DLLIMPORT __attribute__ ((visibility("default")))
594 #define DLLHIDDEN __attribute__ ((visibility("hidden")))
595 #else
596 #define DLLEXPORT
597 #define DLLIMPORT
598 #define DLLHIDDEN
599 #endif
600 
601 #ifdef __cplusplus
602 #define INTERNAL_C_API extern "C"
603 #else
604 #define INTERNAL_C_API extern
605 #endif
606 
607 
608 #if defined(TARGET_WINCE) && (defined(SH3) || defined(SH4) || defined(MIPS))
609 #define _INLINE
610 #define _CONST
611 #else
612 #define _INLINE INLINE
613 #define _CONST const
614 #endif
615 
616 /* todo: needs more testing, that nothing broke... */
617 #if defined(MAX_PATH)
618 #define MAXPATH MAX_PATH
619 #elif defined(PATH_MAX)
620 #define MAXPATH PATH_MAX
621 #else
622 #define MAXPATH 256
623 #endif
624 #define MAXPROTOCOL 16
625 
626 #if MAXPATH < 1024
627 #define MAXPATHFULL 1024
628 #else
629 #define MAXPATHFULL MAXPATH
630 #endif
631 
632 #define MAXPLANES 4
633 typedef void* planes[MAXPLANES];
634 typedef const void* constplanes[MAXPLANES];
635 #define CONST_CONSTPLANES(name) const void* const (name)[MAXPLANES]
636 #define CONSTPLANES(name) const void* (name)[MAXPLANES]
637 #define CONST_PLANES(name) void* const (name)[MAXPLANES]
638 
639 #define FOURCCBE(a,b,c,d) \
640 	(((uint8_t)(a) << 24) | ((uint8_t)(b) << 16) | \
641 	((uint8_t)(c) << 8) | ((uint8_t)(d) << 0))
642 
643 #define FOURCCLE(a,b,c,d) \
644 	(((uint8_t)(a) << 0) | ((uint8_t)(b) << 8) | \
645 	((uint8_t)(c) << 16) | ((uint8_t)(d)<< 24))
646 
647 #ifdef IS_BIG_ENDIAN
648 #define FOURCC(a,b,c,d) (fourcc_t)FOURCCBE(a,b,c,d)
649 #else
650 #define FOURCC(a,b,c,d) (fourcc_t)FOURCCLE(a,b,c,d)
651 #endif
652 
653 #if defined(TARGET_WINCE)
654 #undef strdup
655 #define strdup(x) _strdup(x)
656 #define wcscoll(x,y) tcscmp(x,y)
657 #endif
658 
659 #if defined(__CW32__)
660 void * __alloca(size_t size);
661 #ifndef alloca
662 #define alloca(size) __alloca(size)
663 #endif
664 #endif
665 
666 #if defined(__GNUC__)
667 
668 #ifndef alloca
669 #define alloca(size) __builtin_alloca(size)
670 #endif
671 
672 #if defined(TARGET_PALMOS)
673 extern int rand();
674 extern void srand(unsigned int);
675 extern void qsort(void* const base,size_t,size_t,int(*cmp)(const void*,const void*));
676 #endif
677 
678 #if defined(ARM) && !defined(TARGET_WINCE)
679 //fixed size stack:
680 //  symbian
681 //  palm os
682 #define SWAPSP
SwapSP(void * in)683 static INLINE void* SwapSP(void* in)
684 {
685 	void* out;
686 	asm volatile(
687 		"mov %0, sp\n\t"
688 		"mov sp, %1\n\t"
689 		: "=&r"(out) : "r"(in) : "cc");
690 	return out;
691 }
692 #endif
693 
694 #endif /* __GNUC__ */
695 
696 #if defined(TARGET_PALMOS) && defined(IX86)
697 extern void* malloc_palmos(size_t);
698 extern void* realloc_palmos(void*,size_t);
699 extern void free_palmos(void*);
700 #define malloc(n) malloc_palmos(n)
701 #define realloc(p,n) realloc_palmos(p,n)
702 #define free(p) free_palmos(p)
703 #endif
704 
705 #if defined(_MSC_VER) && defined(TARGET_WIN)
706 #if _MSC_VER >= 1800
707 #include <winapifamily.h>
708 #endif
709 #if !defined(WINAPI_FAMILY_PARTITION) || !defined(WINAPI_PARTITION_DESKTOP)
710 #define WINDOWS_DESKTOP 1
711 #elif defined(WINAPI_FAMILY_PARTITION)
712 #if defined(WINAPI_PARTITION_DESKTOP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_DESKTOP)
713 #define WINDOWS_DESKTOP 1
714 #elif defined(WINAPI_PARTITION_PHONE_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_PHONE_APP)
715 #define WINDOWS_PHONE 1
716 #elif defined(WINAPI_PARTITION_APP) && WINAPI_FAMILY_PARTITION(WINAPI_PARTITION_APP)
717 #define WINDOWS_UNIVERSAL 1
718 #endif
719 #endif
720 #ifdef WINDOWS_UNIVERSAL
721 #undef strdup
722 #define strdup _strdup
723 #endif
724 #endif
725 
726 #if defined(_MSC_VER) && defined(TARGET_WIN)
727 #define TRY_BEGIN __try {
728 #define TRY_END   ;} __except (1) {}
729 #define TRY_END_FUNC(func) ;} __except (1) { func; }
730 #else
731 #define TRY_BEGIN {
732 #define TRY_END   }
733 #define TRY_END_FUNC(func) }
734 #endif
735 
736 #ifndef NDEBUG
737 #if defined(TARGET_OSX)
738 #include <assert.h>
739 #elif !defined(TARGET_WINCE) && !defined(TARGET_PALMOS)
740 #include <assert.h>
741 #else
742 #ifdef LIBC_EXPORTS
743 #define ASSERT_DLL DLLEXPORT
744 #else
745 #define ASSERT_DLL
746 #endif
747 ASSERT_DLL void _Assert(const char* Exp, const char* File, int Line);
748 #define assert(x)   ((x) ? (void)0 : _Assert(#x, __FILE__, __LINE__))
749 #endif
750 #else // NDEBUG
751 #ifndef assert
752 #define assert(x)   ((void)0)
753 #endif
754 #endif // NDEBUG
755 
756 #if defined(__palmos__)
757 #if _MSC_VER > 1000
758 #pragma warning( disable:4068 4204 )
759 #endif
760 #undef BIG_ENDIAN
761 #define USE_TRAPS 0
762 #endif
763 
764 #if defined(COMPILER_GCC) && (!defined(TARGET_SYMBIAN) || defined(SYMBIAN90))
765 #define UNUSED_PARAM(x) (x) __attribute__ ((unused))
766 #elif (defined(TARGET_SYMBIAN) && !defined(ARM)) || defined(__cplusplus)
767 #define UNUSED_PARAM(x)
768 #else
769 #define UNUSED_PARAM(x) (x)
770 #endif
771 
772 #include "config.h"
773 #if defined(COREMAKE_CONFIG_HELPER)
774 #include "config_helper.h"
775 #else /* COREMAKE_CONFIG_HELPER */
776 #include "confhelper.h"
777 #endif /* COREMAKE_CONFIG_HELPER */
778 
779 #if defined(TARGET_IPHONE) && !defined(__ARM_NEON__)
780 #undef CONFIG_NEON
781 #endif
782 
783 #ifdef CONFIG_FILEPOS_64
784 typedef int_fast64_t filepos_t;
785 #define MAX_FILEPOS MAX_INT64
786 #else
787 typedef int_fast32_t filepos_t;
788 #define MAX_FILEPOS INT_MAX
789 #endif
790 
791 #define INVALID_FILEPOS_T  ((filepos_t)-1)
792 
793 typedef int systick_t;
794 #define INVALID_SYSTICK_T  ((int)-1)
795 
796 #if defined(CONFIG_SAFE_C)
797 // change the low level APIs to be safer on windows and other OSes
798 #include "banned.h"
799 #endif /* CONFIG_SAFE_C */
800 
801 #endif
802