1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2 * Mupen64plus-core - osal/preproc.h *
3 * Mupen64Plus homepage: https://mupen64plus.org/ *
4 * Copyright (C) 2009 Richard Goedeken *
5 * *
6 * This program is free software; you can redistribute it and/or modify *
7 * it under the terms of the GNU General Public License as published by *
8 * the Free Software Foundation; either version 2 of the License, or *
9 * (at your option) any later version. *
10 * *
11 * This program is distributed in the hope that it will be useful, *
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
14 * GNU General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU General Public License *
17 * along with this program; if not, write to the *
18 * Free Software Foundation, Inc., *
19 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
20 * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
21
22/* this header file is for system-dependent #defines, #includes, and typedefs */
23
24#if !defined (OSAL_PREPROC_H)
25#define OSAL_PREPROC_H
26
27#if _MSC_VER
28
29 /* macros */
30 #define OSAL_BREAKPOINT_INTERRUPT __debugbreak();
31 #define ALIGN(BYTES,DATA) __declspec(align(BYTES)) DATA
32 #define osal_inline __inline
33
34 #define OSAL_WARNING_PUSH __pragma(warning(push))
35 #define OSAL_WARNING_POP __pragma(warning(pop))
36 #define OSAL_NO_WARNING_FPTR_VOIDP_CAST __pragma(warning(disable:4055 4152))
37
38 /* string functions */
39 #define osal_insensitive_strcmp(x, y) _stricmp(x, y)
40 #define snprintf _snprintf
41 #define strdup _strdup
42
43 /* for isnan() */
44 #include <float.h>
45
46#else /* Not WIN32 */
47 /* for strcasecmp */
48 #include <strings.h>
49
50 /* macros */
51 #define OSAL_BREAKPOINT_INTERRUPT __asm__(" int $3; ");
52 #define ALIGN(BYTES,DATA) DATA __attribute__((aligned(BYTES)))
53 #define osal_inline inline
54
55 #define OSAL_WARNING_PUSH _Pragma("GCC diagnostic push")
56 #define OSAL_WARNING_POP _Pragma("GCC diagnostic pop")
57 #define OSAL_NO_WARNING_FPTR_VOIDP_CAST _Pragma("GCC diagnostic ignored \"-Wpedantic\"")
58
59 /* string functions */
60 #define osal_insensitive_strcmp(x, y) strcasecmp(x, y)
61
62#endif
63
64/* sign-extension macros */
65#define SE8(a) ((int64_t) ((int8_t) (a)))
66#define SE16(a) ((int64_t) ((int16_t) (a)))
67#define SE32(a) ((int64_t) ((int32_t) (a)))
68
69#if !defined(M64P_BIG_ENDIAN)
70 #if defined(__GNUC__) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 3))
71 #define tohl(x) __builtin_bswap32((x))
72 #else
73 #define tohl(x) \
74 ( \
75 (((x) & 0x000000FF) << 24) | \
76 (((x) & 0x0000FF00) << 8) | \
77 (((x) & 0x00FF0000) >> 8) | \
78 (((x) & 0xFF000000) >> 24) \
79 )
80 #endif
81 #define S8 3
82 #define S16 2
83 #define Sh16 1
84#else
85 #define tohl(x) (x)
86 #define S8 0
87 #define S16 0
88 #define Sh16 0
89#endif
90
91#define fromhl(x) tohl((x))
92
93#endif /* OSAL_PREPROC_H */
94
95