1 /*
2  * Copyright (C) 2020 Linux Studio Plugins Project <https://lsp-plug.in/>
3  *           (C) 2020 Vladimir Sadovnikov <sadko4u@gmail.com>
4  *
5  * This file is part of lsp-plugins
6  * Created on: 10 авг. 2018 г.
7  *
8  * lsp-plugins is free software: you can redistribute it and/or modify
9  * it under the terms of the GNU Lesser General Public License as published by
10  * the Free Software Foundation, either version 3 of the License, or
11  * any later version.
12  *
13  * lsp-plugins is distributed in the hope that it will be useful,
14  * but WITHOUT ANY WARRANTY; without even the implied warranty of
15  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16  * GNU Lesser General Public License for more details.
17  *
18  * You should have received a copy of the GNU Lesser General Public License
19  * along with lsp-plugins. If not, see <https://www.gnu.org/licenses/>.
20  */
21 
22 #ifndef COMMON_TYPES_H_
23 #define COMMON_TYPES_H_
24 
25 #include <sys/types.h>
26 #include <stddef.h>
27 #include <stdint.h>
28 #include <string.h>
29 #include <stdint.h>
30 #include <limits.h>
31 
32 //-----------------------------------------------------------------------------
33 // Deny some compiler settings
34 #ifdef __FAST_MATH__
35     #error "-ffast-math compiler option is prohibited since it may cause some standard floating-point operations to work improperly. Please disable -ffast-math option and rebuild the project."
36 #endif /* __FAST_MATH__ */
37 
38 
39 //-----------------------------------------------------------------------------
40 // Detect build architecture
41 #if defined(__x86_64__) || defined(__x86_64) || defined(__amd64__) || defined(__amd64) || defined(_M_AMD64)
42     #define ARCH_X86
43     #define ARCH_X86_64
44 #elif defined(__i386__) || defined(__i386)
45     #define ARCH_X86
46     #define ARCH_I386
47 #elif defined(__aarch64__)
48     #define ARCH_AARCH64
49 #elif defined(__arm__) || defined(__arm) || defined(_M_ARM) || defined(_ARM)
50     #define ARCH_ARM
51 #elif defined(__PPC64__) || defined(__ppc64__) || defined(__ppc64) || defined(__powerpc64__) || defined(_ARCH_PPC64)
52     #define ARCH_PPC64
53 #elif defined(__PPC__) || defined(__ppc__) || defined(__powerpc__) || defined(__ppc) || defined(_M_PPC) || defined(_ARCH_PPC)
54     #define ARCH_PPC
55 #elif defined(__s390x__) || defined(__s390__) || defined(__zarch__)
56     #define ARCH_S390
57 #elif defined(__mips__) || defined(__mips) || defined(__MIPS__)
58     #define ARCH_MIPS
59 #elif defined(__sparc__) || defined(__sparc)
60     #define ARCH_SPARC
61 #elif defined(__riscv) && (__riscv_xlen == 64)
62     #define ARCH_RISCV
63     #define ARCH_RISCV64
64 #elif defined(__riscv) && (__riscv_xlen == 32)
65     #define ARCH_RISCV
66     #define ARCH_RISCV32
67 #endif
68 
69 //-----------------------------------------------------------------------------
70 // Detect endianess of architecture
71 #if (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__)
72     #define ARCH_LE
73 #elif (__BYTE_ORDER__ == __ORDER_BIG_ENDIAN__)
74     #define ARCH_BE
75 #endif
76 
77 //-----------------------------------------------------------------------------
78 // Detect bitness of architecture
79 #if defined(__WORDSIZE) && (__WORDSIZE == 64)
80     #define ARCH_64BIT
81     typedef uint64_t            umword_t;
82     typedef int64_t             smword_t;
83 #elif defined(__SIZE_WIDTH__) && (__SIZE_WIDTH__ == 64)
84     #define ARCH_64BIT
85     typedef uint64_t            umword_t;
86     typedef int64_t             smword_t;
87 #elif defined(__WORDSIZE) && (__WORDSIZE == 32)
88     #define ARCH_32BIT
89     typedef uint32_t            umword_t;
90     typedef int32_t             smword_t;
91 #elif defined(__SIZE_WIDTH__) && (__SIZE_WIDTH__ == 32)
92     #define ARCH_32BIT
93     typedef uint32_t            umword_t;
94     typedef int32_t             smword_t;
95 #else
96     #warning "Unsupported architecture bitness"
97 #endif /* __WORDSIZE, __SIZE_WIDTH__ */
98 
99 //-----------------------------------------------------------------------------
100 // Detect endianess and operations
101 #if defined(ARCH_X86) || defined(ARCH_X86_64)
102     #define IF_ARCH_X86(...)        __VA_ARGS__
103     #define ARCH_X86_ASM(...)       __asm__ __volatile__ ( __VA_ARGS__ )
104 #endif /* ARCH_X86 */
105 
106 #if defined(ARCH_I386)
107     #define IF_ARCH_I386(...)       __VA_ARGS__
108     #define ARCH_I386_ASM(...)      __asm__ __volatile__ ( __VA_ARGS__ )
109     #define ARCH_STRING             "i386"
110 #endif /* ARCH_X86 */
111 
112 #if defined(ARCH_X86_64)
113     #define IF_ARCH_X86_64(...)     __VA_ARGS__
114     #define ARCH_X86_64_ASM(...)    __asm__ __volatile__ ( __VA_ARGS__ )
115     #define ARCH_STRING             "x86_64"
116 #endif /* defined(ARCH_X86_64) */
117 
118 #if defined(ARCH_ARM)
119     #define IF_ARCH_ARM(...)            __VA_ARGS__
120     #define ARCH_ARM_ASM(...)           __asm__ __volatile__ ( __VA_ARGS__ )
121 
122     #if !defined(ARCH_BE) && !defined(ARCH_BE)
123         #define ARCH_LE
124     #endif
125 
126     #if (__ARM_ARCH == 7)
127         #define ARCH_ARM7
128         #define ARCH_STRING             "armv7a"
129         #define IF_ARCH_ARM7(...)        __VA_ARGS__
130         #define IF_ARCH_LEAST_ARM7(...)  __VA_ARGS__
131     #elif (__ARM_ARCH == 6)
132         #define ARCH_ARM6
133         #define ARCH_STRING             "armv6a"
134         #define IF_ARCH_ARM6(...)        __VA_ARGS__
135         #define IF_ARCH_LEAST_ARM6(...)  __VA_ARGS__
136     #else
137         #define ARCH_STRING             "arm-generic"
138     #endif
139 #endif /* defined(ARCH_ARM) */
140 
141 #if defined(ARCH_AARCH64)
142     #define IF_ARCH_AARCH64(...)        __VA_ARGS__
143     #define ARCH_AARCH64_ASM(...)       __asm__ __volatile__ ( __VA_ARGS__ )
144 
145     #if !defined(ARCH_BE) && !defined(ARCH_BE)
146         #define ARCH_LE
147     #endif
148 
149     #define ARCH_STRING                 "aarch64"
150 
151     #if (__ARM_ARCH == 8)
152         #define ARCH_ARM8
153         #define IF_ARCH_ARM8(...)        __VA_ARGS__
154     #endif
155 #endif /* defined(ARCH_AARCH64) */
156 
157 #if defined(ARCH_PPC)
158     #define IF_ARCH_PPC(...)            __VA_ARGS__
159     #define ARCH_PPC_ASM(...)           __asm__ __volatile__ ( __VA_ARGS__ )
160 
161     #define ARCH_STRING                 "ppc"
162 #endif /* defined(ARCH_PPC) */
163 
164 #if defined(ARCH_PPC64)
165     #define IF_ARCH_PPC64(...)          __VA_ARGS__
166     #define ARCH_PPC64_ASM(...)         __asm__ __volatile__ ( __VA_ARGS__ )
167 
168     #define ARCH_STRING                 "ppc64"
169 #endif /* defined(ARCH_PPC64) */
170 
171 #if defined(ARCH_S390)
172     #define IF_ARCH_S390(...)           __VA_ARGS__
173     #define ARCH_S390_ASM(...)          __asm__ __volatile__ ( __VA_ARGS__ )
174 
175     #define ARCH_STRING                 "S390"
176 #endif /* defined(ARCH_S390) */
177 
178 #if defined(ARCH_MIPS)
179     #define IF_ARCH_MIPS(...)           __VA_ARGS__
180     #define ARCH_MIPS_ASM(...)          __asm__ __volatile__ ( __VA_ARGS__ )
181 
182     #define ARCH_STRING                 "MIPS"
183 #endif /* defined(ARCH_MIPS) */
184 
185 #if defined(ARCH_SPARC)
186     #define IF_ARCH_SPARC(...)          __VA_ARGS__
187     #define ARCH_SPARC_ASM(...)         __asm__ __volatile__ ( __VA_ARGS__ )
188 
189     #define ARCH_STRING                 "SPARC"
190 #endif /* defined(ARCH_SPARC) */
191 
192 #if defined(ARCH_RISCV)
193     #define IF_ARCH_RISCV(...)            __VA_ARGS__
194     #define ARCH_RISCV_ASM(...)           __asm__ __volatile__ ( __VA_ARGS__ )
195 #endif /* ARCH_RISCV */
196 
197 #if defined(ARCH_RISCV64)
198     #define IF_ARCH_RISCV64(...)          __VA_ARGS__
199     #define ARCH_RISCV64_ASM(...)         __asm__ __volatile__ ( __VA_ARGS__ )
200 
201     #define ARCH_STRING                 "RISCV64"
202 #endif /* defined(ARCH_RISCV64) */
203 
204 #if defined(ARCH_RISCV32)
205     #define IF_ARCH_RISCV32(...)          __VA_ARGS__
206     #define ARCH_RISCV32_ASM(...)         __asm__ __volatile__ ( __VA_ARGS__ )
207 
208     #define ARCH_STRING                 "RISCV32"
209 #endif /* defined(ARCH_RISCV32) */
210 
211 #if defined(ARCH_LE)
212     #define __IF_LEBE(le, be)   le
213     #define __IF_LE(le)         le
214     #define __IF_BE(be)
215     #ifdef ARCH_BE
216         #undef ARCH_BE
217     #endif /* ARCH_BE */
218 #elif defined(ARCH_BE) /* ARCH_BE */
219     #define __IF_LEBE(le, be)   be
220     #define __IF_LE(le)
221     #define __IF_BE(be)         be
222 
223     #ifdef ARCH_LE
224         #undef ARCH_LE
225     #endif /* ARCH_LE */
226 #else
227     #warning "Could not detect endianess of the target architecture"
228 #endif /* ARCH_LE */
229 
230 #ifndef ARCH_STRING
231     #define ARCH_STRING                 "native"
232 #endif /* ARCH_STRING */
233 
234 //-----------------------------------------------------------------------------
235 // Detect build platform
236 #if defined(__unix__) || defined(unix) || defined(__unix)
237     #define PLATFORM_UNIX
238     #define IF_PLATFORM_UNIX(...)       __VA_ARGS__
239 #endif /* __unix__ */
240 
241 #if defined(__sun__) || defined(__sun) || defined(sun)
242     #define PLATFORM_SOLARIS
243     #define IF_PLATFORM_SOLARIS(...)    __VA_ARGS__
244 #endif /* __sun__ */
245 
246 #if defined(__linux__) || defined(__linux) || defined(linux)
247     #define PLATFORM_LINUX
248     #define IF_PLATFORM_LINUX(...)      __VA_ARGS__
249 #endif /* __linux__ */
250 
251 #if defined(__bsd__) || defined(__bsd) || defined(__FreeBSD__) || defined(freebsd) || defined(openbsd) || defined(bsdi) || defined(__darwin__) || defined(__DragonFly__)
252     #define PLATFORM_BSD
253     #define IF_PLATFORM_BSD(...)        __VA_ARGS__
254 #endif /* __bsd__ */
255 
256 #if defined(__macosx__) || defined(__APPLE__) || defined(__MACH__)
257     #define PLATFORM_MACOSX
258     #define IF_PLATFORM_MACOSX(...)     __VA_ARGS__
259 #endif /* __macosx__ */
260 
261 #if defined(PLATFORM_UNIX) || defined(PLATFORM_LINUX) || defined(PLATFORM_MACOSX) || defined(PLATFORM_BSD)
262     #define PLATFORM_UNIX_COMPATIBLE
263     #define PLATFORM_POSIX
264 
265     #define IF_PLATFORM_POSIX(...)      __VA_ARGS__
266 #endif /* unix-compatible platforms */
267 
268 #if defined(__WINDOWS__) || defined(__WIN32__) || defined(__WIN64__) || defined(_WIN64) || defined(_WIN32) || defined(__WINNT) || defined(__WINNT__)
269     #define PLATFORM_WINDOWS
270     #define IF_PLATFORM_WINDOWS(...)    __VA_ARGS__
271 #endif /* __macosx__ */
272 
273 // File separators for platform tuning
274 #if defined(PLATFORM_UNIX) || defined(PLATFORM_LINUX) || defined(PLATFORM_MACOSX)
275     #define FILE_SEPARATOR_C        '/'
276     #define FILE_SEPARATOR_S        "/"
277 #elif defined(PLATFORM_WINDOWS)
278     #define FILE_SEPARATOR_C      '\\'
279     #define FILE_SEPARATOR_S      "\\"
280 #endif /* */
281 
282 //-----------------------------------------------------------------------------
283 // Conditional assemblying
284 #define __ASM_EMIT(code)                        code "\n\t"
285 
286 #ifdef ARCH_32BIT
287     #define __ASM_EMIT32(code)                  code "\n\t"
288     #define __IF_32(...)                        __VA_ARGS__
289     #define __IF_32_64(a, b)                    a
290 
291     #ifdef LSP_PROFILING
292         #define __IF_32P(...)                       __VA_ARGS__
293         #define __ASM_EMIT32P(code)                 code "\n\t"
294     #else
295         #define __IF_32NP(...)                      __VA_ARGS__
296         #define __ASM_EMIT32NP(code)                code "\n\t"
297     #endif /* LSP_PROFILING */
298 #endif /* ARCH_32BIT */
299 
300 #ifdef ARCH_64BIT
301     #define __ASM_EMIT64(code)                  code "\n\t"
302     #define __IF_64(...)                        __VA_ARGS__
303     #define __IF_32_64(a, b)                    b
304     #ifdef LSP_PROFILING
305         #define __IF_64P(...)                       __VA_ARGS__
306         #define __ASM_EMIT64P(code)                 code "\n\t"
307     #else
308         #define __IF_64NP(...)                      __VA_ARGS__
309         #define __ASM_EMIT64NP(code)                code "\n\t"
310     #endif /* LSP_PROFILING */
311 #endif /* ARCH_32BIT */
312 
313 #ifdef LSP_PROFILING
314     #define __ASM_EMITP(code)                      code "\n\t"
315     #define __ASM_EMITNP(code)
316 #else
317     #define __ASM_EMITP(code)
318     #define __ASM_EMITNP(code)                     code "\n\t"
319 #endif /* LSP_PROFILING */
320 
321 #ifndef ARCH_X86_ASM
322     #define ARCH_X86_ASM(...)
323 #endif /* ARCH_X86_ASM */
324 
325 #ifndef ARCH_I386_ASM
326     #define ARCH_I386_ASM(...)
327 #endif /* ARCH_I386_ASM */
328 
329 #ifndef ARCH_X86_64_ASM
330     #define ARCH_X86_64_ASM(...)
331 #endif /* ARCH_I386_ASM */
332 
333 #ifndef ARCH_ARM_ASM
334     #define ARCH_ARM_ASM(...)
335 #endif /* ARCH_ARM_ASM */
336 
337 #ifndef ARCH_AARCH64_ASM
338     #define ARCH_AARCH64_ASM(...)
339 #endif /* ARCH_AARCH64_ASM */
340 
341 #ifndef ARCH_PPC64_ASM
342     #define ARCH_PPC64_ASM(...)
343 #endif /* ARCH_PPC64_ASM */
344 
345 #ifndef ARCH_PPC_ASM
346     #define ARCH_PPC_ASM(...)
347 #endif /* ARCH_PPC_ASM */
348 
349 #ifndef ARCH_S390_ASM
350     #define ARCH_S390_ASM(...)
351 #endif /* ARCH_S390_ASM */
352 
353 #ifndef ARCH_MIPS_ASM
354     #define ARCH_MIPS_ASM(...)
355 #endif /* ARCH_MIPS_ASM */
356 
357 #ifndef ARCH_SPARC_ASM
358     #define ARCH_SPARC_ASM(...)
359 #endif /* ARCH_SPARC_ASM */
360 
361 #ifndef ARCH_RISCV64_ASM
362     #define ARCH_RISCV64_ASM(...)
363 #endif /* ARCH_RISCV64_ASM */
364 
365 #ifndef ARCH_RISCV32_ASM
366     #define ARCH_RISCV32_ASM(...)
367 #endif /* ARCH_RISCV32_ASM */
368 
369 #define __ASM_ARG_TMP(var)                      __IF_32P("=&g"(var)) __IF_32NP("=&r"(var)) __IF_64("=&r"(var))
370 #define __ASM_ARG_RW(var)                       __IF_32P("+g"(var))  __IF_32NP("+r"(var))  __IF_64("+r"(var))
371 #define __ASM_ARG_RO(var)                       __IF_32P("g"(var))   __IF_32NP("r"(var))   __IF_64("r"(var))
372 
373 #define __lsp_forced_inline                 __attribute__ ((always_inline))
374 #define __lsp_aligned16                     __attribute__ ((aligned (16)))
375 #define __lsp_aligned32                     __attribute__ ((aligned (32)))
376 #define __lsp_aligned64                     __attribute__ ((aligned (64)))
377 #define __lsp_packed                        __attribute__ ((__packed__))
378 #define __lsp_aligned(bytes)                __attribute__ ((aligned (bytes)))
379 
380 //-----------------------------------------------------------------------------
381 // CPU extensions
382 
383 // Extensions for x86 architecture enabled by compiler
384 #ifdef ARCH_X86
385     #ifdef __SSE__
386         #define ARCH_X86_SSE
387     #endif /* __SSE__ */
388 
389     #ifdef __SSE2__
390         #define ARCH_X86_SSE2
391     #endif /* __SSE2__ */
392 
393     #ifdef __SSE3__
394         #define ARCH_X86_SSE3
395     #endif /* __SSE2__ */
396 
397     #ifdef __SSSE3__
398         #define ARCH_X86_SSSE3
399     #endif /* __SSE2__ */
400 
401     #ifdef __SSE4_1__
402         #define ARCH_X86_SSE4_1
403     #endif /* __SSE4_1__ */
404 
405     #ifdef __SSE4_2__
406         #define ARCH_X86_SSE4_2
407     #endif /* __SSE4_1__ */
408 
409     #ifndef LSP_NO_AVX /* Special directive that forces to disable AVX support */
410         #ifdef __AVX__
411             #define ARCH_X86_AVX
412             #ifdef ARCH_X86_64
413                 #define ARCH_X86_64_AVX
414             #else
415                 #define ARCH_I386_AVX
416             #endif
417         #endif /* __AVX__ */
418 
419         #ifdef __AVX2__
420             #define ARCH_X86_AVX2
421             #ifdef ARCH_X86_64
422                 #define ARCH_X86_64_AVX2
423             #else
424                 #define ARCH_I386_AVX2
425             #endif
426         #endif /* __AVX2__ */
427     #endif /* LSP_NO_AVX */
428 #endif /* ARCH_X86 */
429 
430 
431 //-----------------------------------------------------------------------------
432 // Define macros that may not be previously defined
433 #ifndef __ASM_EMIT32
434     #define __ASM_EMIT32(code)
435 #endif /* __ASM_EMIT32 */
436 
437 #ifndef __ASM_EMIT32P
438     #define __ASM_EMIT32P(code)
439 #endif /* __ASM_EMIT32P */
440 
441 #ifndef __ASM_EMIT32NP
442     #define __ASM_EMIT32NP(code)
443 #endif /* __ASM_EMIT32NP */
444 
445 #ifndef __ASM_EMIT64
446     #define __ASM_EMIT64(code)
447 #endif /* __ASM_EMIT64 */
448 
449 #ifndef __ASM_EMIT64P
450     #define __ASM_EMIT64P(code)
451 #endif /* __ASM_EMIT64P */
452 
453 #ifndef __ASM_EMIT64NP
454     #define __ASM_EMIT64NP(code)
455 #endif /* __ASM_EMIT64NP */
456 
457 #ifndef __IF_32
458     #define __IF_32(...)
459 #endif /* __IF_32 */
460 
461 #ifndef __IF_32P
462     #define __IF_32P(...)
463 #endif /* __IF_32 */
464 
465 #ifndef __IF_32NP
466     #define __IF_32NP(...)
467 #endif /* __IF_32 */
468 
469 #ifndef __IF_64
470     #define __IF_64(...)
471 #endif /* __IF_64 */
472 
473 //-----------------------------------------------------------------------------
474 // Default architectures
475 #ifndef IF_ARCH_X86
476     #define IF_ARCH_X86(...)
477 #endif /* IF_ARCH_X86 */
478 
479 #ifndef IF_ARCH_I386
480     #define IF_ARCH_I386(...)
481 #endif /* IF_ARCH_I386 */
482 
483 #ifndef IF_ARCH_X86_64
484     #define IF_ARCH_X86_64(...)
485 #endif /* IF_ARCH_X86_64 */
486 
487 #ifndef IF_ARCH_ARM
488     #define IF_ARCH_ARM(...)
489 #endif /* IF_ARCH_ARM */
490 
491 #ifndef IF_ARCH_ARM6
492     #define IF_ARCH_ARM6(...)
493 #endif /* IF_ARCH_ARM6 */
494 
495 #ifndef IF_ARCH_LEAST_ARM6
496     #define IF_ARCH_LEAST_ARM6(...)
497 #endif /* IF_ARCH_LEAST_ARM6 */
498 
499 #ifndef IF_ARCH_ARM7
500     #define IF_ARCH_ARM7(...)
501 #endif /* IF_ARCH_ARM7 */
502 
503 #ifndef IF_ARCH_LEAST_ARM7
504     #define IF_ARCH_LEAST_ARM7(...)
505 #endif /* IF_ARCH_LEAST_ARM7 */
506 
507 #ifndef IF_ARCH_ARM8
508     #define IF_ARCH_ARM8(...)
509 #endif /* IF_ARCH_ARM8 */
510 
511 #ifndef IF_ARCH_AARCH64
512     #define IF_ARCH_AARCH64(...)
513 #endif /* IF_ARCH_AARCH64 */
514 
515 #ifndef IF_ARCH_PPC
516     #define IF_ARCH_PPC(...)
517 #endif /* IF_ARCH_PPC */
518 
519 #ifndef IF_ARCH_PPC64
520     #define IF_ARCH_PPC64(...)
521 #endif /* IF_ARCH_PPC64 */
522 
523 #ifndef IF_ARCH_S390
524     #define IF_ARCH_S390(...)
525 #endif /* IF_ARCH_S390 */
526 
527 #ifndef IF_ARCH_MIPS
528     #define IF_ARCH_MIPS(...)
529 #endif /* IF_ARCH_MIPS */
530 
531 #ifndef IF_ARCH_SPARC
532     #define IF_ARCH_SPARC(...)
533 #endif /* IF_ARCH_SPARC */
534 
535 #ifndef IF_ARCH_RISCV64
536     #define IF_ARCH_RISCV64(...)
537 #endif /* IF_ARCH_RISCV64 */
538 
539 #ifndef IF_ARCH_RISCV32
540     #define IF_ARCH_RISCV32(...)
541 #endif /* IF_ARCH_RISCV32 */
542 
543 //-----------------------------------------------------------------------------
544 // Default platform
545 #ifndef IF_PLATFORM_UNIX
546     #define IF_PLATFORM_UNIX(...)
547 #endif /* IF_PLATFORM_UNIX */
548 
549 #ifndef IF_PLATFORM_SOLARIS
550     #define IF_PLATFORM_SOLARIS(...)
551 #endif /* IF_PLATFORM_SOLARIS */
552 
553 #ifndef IF_PLATFORM_LINUX
554     #define IF_PLATFORM_LINUX(...)
555 #endif /* IF_PLATFORM_LINUX */
556 
557 #ifndef IF_PLATFORM_BSD
558     #define IF_PLATFORM_BSD(...)
559 #endif /* IF_PLATFORM_BSD */
560 
561 #ifndef IF_PLATFORM_MACOSX
562     #define IF_PLATFORM_MACOSX(...)
563 #endif /* IF_PLATFORM_MACOSX */
564 
565 #ifndef IF_PLATFORM_POSIX
566     #define IF_PLATFORM_POSIX(...)
567 #endif /* IF_PLATFORM_POSIX */
568 
569 #ifndef IF_PLATFORM_WINDOWS
570     #define IF_PLATFORM_WINDOWS(...)
571 #endif /* IF_PLATFORM_WINDOWS */
572 
573 //-----------------------------------------------------------------------------
574 // Optimizations
575 #ifdef ARCH_I386
576     #define DEFAULT_ALIGN                   0x10
577     #define MINIMUM_ALIGN                   0x08
578 #endif /* ARCH_X86 */
579 
580 #ifdef ARCH_X86_64
581     #define DEFAULT_ALIGN                   0x10
582     #define MINIMUM_ALIGN                   0x08
583 #endif /* ARCH_X86 */
584 
585 #ifdef ARCH_ARCH_ARM
586     #define DEFAULT_ALIGN                   0x10
587     #define MINIMUM_ALIGN                   0x08
588 #endif /* ARCH_ARM */
589 
590 #ifdef ARCH_ARCH_AARCH64
591     #define DEFAULT_ALIGN                   0x10
592     #define MINIMUM_ALIGN                   0x08
593 #endif /* ARCH_ARM */
594 
595 #ifndef DEFAULT_ALIGN
596     #define DEFAULT_ALIGN                   0x10
597 #endif /* DEFAULT_ALIGN */
598 
599 #ifndef MINIMUM_ALIGN
600     #define MINIMUM_ALIGN                   DEFAULT_ALIGN
601 #endif /* DEFAULT_ALIGN */
602 
603 //-----------------------------------------------------------------------------
604 // Detect some libraries
605 #ifdef __GLIBC__
606     #define USE_GLIBC                           __GLIBC__
607 #endif /* GLIBC */
608 
609 //-----------------------------------------------------------------------------
610 // Type definitions
611 __IF_32( typedef        uint32_t            umword_t );
612 __IF_32( typedef        int32_t             smword_t );
613 __IF_64( typedef        uint64_t            umword_t );
614 __IF_64( typedef        int64_t             smword_t );
615 
616 #ifdef PLATFORM_LINUX
617     #include <linux/limits.h>
618 #endif /* __linux__ */
619 
620 //-----------------------------------------------------------------------------
621 // Character type sizes
622 #if (WCHAR_MAX >= 0x10000ul)
623     #define WCHART_32BIT
624 #else
625     #define WCHART_16BIT
626 #endif /* WCHAR_MAX */
627 
628 #endif /* COMMON_TYPES_H_ */
629