Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
wine-mirror
GitHub Repository: wine-mirror/wine
Path: blob/master/libs/tomcrypt/src/headers/tomcrypt_cfg.h
5971 views
1
/* LibTomCrypt, modular cryptographic library -- Tom St Denis
2
*
3
* LibTomCrypt is a library that provides various cryptographic
4
* algorithms in a highly modular and flexible manner.
5
*
6
* The library is free for all purposes without any express
7
* guarantee it works.
8
*/
9
10
/* This is the build config file.
11
*
12
* With this you can setup what to inlcude/exclude automatically during any build. Just comment
13
* out the line that #define's the word for the thing you want to remove. phew!
14
*/
15
16
#ifndef TOMCRYPT_CFG_H
17
#define TOMCRYPT_CFG_H
18
19
#if defined(_WIN32) || defined(_MSC_VER)
20
#define LTC_CALL __cdecl
21
#elif !defined(LTC_CALL)
22
#define LTC_CALL
23
#endif
24
25
#ifndef LTC_EXPORT
26
#define LTC_EXPORT
27
#endif
28
29
/* certain platforms use macros for these, making the prototypes broken */
30
#ifndef LTC_NO_PROTOTYPES
31
32
/* you can change how memory allocation works ... */
33
LTC_EXPORT void * LTC_CALL XMALLOC(size_t n);
34
LTC_EXPORT void * LTC_CALL XREALLOC(void *p, size_t n);
35
LTC_EXPORT void * LTC_CALL XCALLOC(size_t n, size_t s);
36
LTC_EXPORT void LTC_CALL XFREE(void *p);
37
38
LTC_EXPORT void LTC_CALL XQSORT(void *base, size_t nmemb, size_t size, int(*compar)(const void *, const void *));
39
40
41
/* change the clock function too */
42
LTC_EXPORT clock_t LTC_CALL XCLOCK(void);
43
44
/* various other functions */
45
LTC_EXPORT void * LTC_CALL XMEMCPY(void *dest, const void *src, size_t n);
46
LTC_EXPORT int LTC_CALL XMEMCMP(const void *s1, const void *s2, size_t n);
47
LTC_EXPORT void * LTC_CALL XMEMSET(void *s, int c, size_t n);
48
49
LTC_EXPORT int LTC_CALL XSTRCMP(const char *s1, const char *s2);
50
51
#endif
52
53
/* some compilers do not like "inline" (or maybe "static inline"), namely: HP cc, IBM xlc */
54
#if defined(__HP_cc) || defined(__xlc__)
55
#define LTC_INLINE
56
#elif defined(_MSC_VER)
57
#define LTC_INLINE __inline
58
#else
59
#define LTC_INLINE inline
60
#endif
61
62
/* type of argument checking, 0=default, 1=fatal and 2=error+continue, 3=nothing */
63
#ifndef ARGTYPE
64
#define ARGTYPE 4
65
#endif
66
67
#undef LTC_ENCRYPT
68
#define LTC_ENCRYPT 0
69
#undef LTC_DECRYPT
70
#define LTC_DECRYPT 1
71
72
/* Controls endianess and size of registers. Leave uncommented to get platform neutral [slower] code
73
*
74
* Note: in order to use the optimized macros your platform must support unaligned 32 and 64 bit read/writes.
75
* The x86 platforms allow this but some others [ARM for instance] do not. On those platforms you **MUST**
76
* use the portable [slower] macros.
77
*/
78
/* detect x86/i386 32bit */
79
#if defined(__i386__) || defined(__i386) || defined(_M_IX86)
80
#define ENDIAN_LITTLE
81
#define ENDIAN_32BITWORD
82
#define LTC_FAST
83
#endif
84
85
/* detect amd64/x64 */
86
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64)
87
#define ENDIAN_LITTLE
88
#define ENDIAN_64BITWORD
89
#define LTC_FAST
90
#endif
91
92
/* detect PPC32 */
93
#if defined(LTC_PPC32)
94
#define ENDIAN_BIG
95
#define ENDIAN_32BITWORD
96
#define LTC_FAST
97
#endif
98
99
/* detects MIPS R5900 processors (PS2) */
100
#if (defined(__R5900) || defined(R5900) || defined(__R5900__)) && (defined(_mips) || defined(__mips__) || defined(mips))
101
#define ENDIAN_64BITWORD
102
#if defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
103
#define ENDIAN_BIG
104
#endif
105
#define ENDIAN_LITTLE
106
#endif
107
#endif
108
109
/* detect AIX */
110
#if defined(_AIX) && defined(_BIG_ENDIAN)
111
#define ENDIAN_BIG
112
#if defined(__LP64__) || defined(_ARCH_PPC64)
113
#define ENDIAN_64BITWORD
114
#else
115
#define ENDIAN_32BITWORD
116
#endif
117
#endif
118
119
/* detect HP-UX */
120
#if defined(__hpux) || defined(__hpux__)
121
#define ENDIAN_BIG
122
#if defined(__ia64) || defined(__ia64__) || defined(__LP64__)
123
#define ENDIAN_64BITWORD
124
#else
125
#define ENDIAN_32BITWORD
126
#endif
127
#endif
128
129
/* detect Apple OS X */
130
#if defined(__APPLE__) && defined(__MACH__)
131
#if defined(__LITTLE_ENDIAN__) || defined(__x86_64__)
132
#define ENDIAN_LITTLE
133
#else
134
#define ENDIAN_BIG
135
#endif
136
#if defined(__LP64__) || defined(__x86_64__)
137
#define ENDIAN_64BITWORD
138
#else
139
#define ENDIAN_32BITWORD
140
#endif
141
#endif
142
143
/* detect SPARC and SPARC64 */
144
#if defined(__sparc__) || defined(__sparc)
145
#define ENDIAN_BIG
146
#if defined(__arch64__) || defined(__sparcv9) || defined(__sparc_v9__)
147
#define ENDIAN_64BITWORD
148
#else
149
#define ENDIAN_32BITWORD
150
#endif
151
#endif
152
153
/* detect IBM S390(x) */
154
#if defined(__s390x__) || defined(__s390__)
155
#define ENDIAN_BIG
156
#if defined(__s390x__)
157
#define ENDIAN_64BITWORD
158
#else
159
#define ENDIAN_32BITWORD
160
#endif
161
#endif
162
163
/* detect PPC64 */
164
#if defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__)
165
#define ENDIAN_64BITWORD
166
#if __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
167
#define ENDIAN_BIG
168
#elif __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
169
#define ENDIAN_LITTLE
170
#endif
171
#define LTC_FAST
172
#endif
173
174
/* endianness fallback */
175
#if !defined(ENDIAN_BIG) && !defined(ENDIAN_LITTLE)
176
#if defined(_BYTE_ORDER) && _BYTE_ORDER == _BIG_ENDIAN || \
177
defined(__BYTE_ORDER) && __BYTE_ORDER == __BIG_ENDIAN || \
178
defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__ || \
179
defined(__BIG_ENDIAN__) || \
180
defined(__ARMEB__) || defined(__THUMBEB__) || defined(__AARCH64EB__) || \
181
defined(_MIPSEB) || defined(__MIPSEB) || defined(__MIPSEB__)
182
#define ENDIAN_BIG
183
#elif defined(_BYTE_ORDER) && _BYTE_ORDER == _LITTLE_ENDIAN || \
184
defined(__BYTE_ORDER) && __BYTE_ORDER == __LITTLE_ENDIAN || \
185
defined(__BYTE_ORDER__) && __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__ || \
186
defined(__LITTLE_ENDIAN__) || \
187
defined(__ARMEL__) || defined(__THUMBEL__) || defined(__AARCH64EL__) || \
188
defined(_MIPSEL) || defined(__MIPSEL) || defined(__MIPSEL__)
189
#define ENDIAN_LITTLE
190
#else
191
#error Cannot detect endianness
192
#endif
193
#endif
194
195
/* ulong64: 64-bit data type */
196
#ifdef _MSC_VER
197
#define CONST64(n) n ## ui64
198
typedef unsigned __int64 ulong64;
199
#else
200
#define CONST64(n) n ## ULL
201
typedef unsigned long long ulong64;
202
#endif
203
204
/* ulong32: "32-bit at least" data type */
205
#if defined(__x86_64__) || defined(_M_X64) || defined(_M_AMD64) || \
206
defined(__powerpc64__) || defined(__ppc64__) || defined(__PPC64__) || \
207
defined(__s390x__) || defined(__arch64__) || defined(__aarch64__) || \
208
defined(__sparcv9) || defined(__sparc_v9__) || defined(__sparc64__) || \
209
defined(__ia64) || defined(__ia64__) || defined(__itanium__) || defined(_M_IA64) || \
210
defined(__LP64__) || defined(_LP64) || defined(__64BIT__)
211
typedef unsigned ulong32;
212
#if !defined(ENDIAN_64BITWORD) && !defined(ENDIAN_32BITWORD)
213
#define ENDIAN_64BITWORD
214
#endif
215
#else
216
typedef unsigned long ulong32;
217
#if !defined(ENDIAN_64BITWORD) && !defined(ENDIAN_32BITWORD)
218
#define ENDIAN_32BITWORD
219
#endif
220
#endif
221
222
#if defined(ENDIAN_64BITWORD) && !defined(_MSC_VER)
223
typedef unsigned long long ltc_mp_digit;
224
#else
225
typedef unsigned long ltc_mp_digit;
226
#endif
227
228
/* No asm is a quick way to disable anything "not portable" */
229
#ifdef LTC_NO_ASM
230
#define ENDIAN_NEUTRAL
231
#undef ENDIAN_32BITWORD
232
#undef ENDIAN_64BITWORD
233
#undef LTC_FAST
234
#define LTC_NO_ROLC
235
#define LTC_NO_BSWAP
236
#endif
237
238
/* No LTC_FAST if: explicitly disabled OR non-gcc/non-clang compiler OR old gcc OR using -ansi -std=c99 */
239
#if defined(LTC_NO_FAST) || (__GNUC__ < 4) || defined(__STRICT_ANSI__)
240
#undef LTC_FAST
241
#endif
242
243
#ifdef LTC_FAST
244
#define LTC_FAST_TYPE_PTR_CAST(x) ((LTC_FAST_TYPE*)(void*)(x))
245
#ifdef ENDIAN_64BITWORD
246
typedef ulong64 __attribute__((__may_alias__)) LTC_FAST_TYPE;
247
#else
248
typedef ulong32 __attribute__((__may_alias__)) LTC_FAST_TYPE;
249
#endif
250
#endif
251
252
#if !defined(ENDIAN_NEUTRAL) && (defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE)) && !(defined(ENDIAN_32BITWORD) || defined(ENDIAN_64BITWORD))
253
#error You must specify a word size as well as endianess in tomcrypt_cfg.h
254
#endif
255
256
#if !(defined(ENDIAN_BIG) || defined(ENDIAN_LITTLE))
257
#define ENDIAN_NEUTRAL
258
#endif
259
260
#if (defined(ENDIAN_32BITWORD) && defined(ENDIAN_64BITWORD))
261
#error Cannot be 32 and 64 bit words...
262
#endif
263
264
/* gcc 4.3 and up has a bswap builtin; detect it by gcc version.
265
* clang also supports the bswap builtin, and although clang pretends
266
* to be gcc (macro-wise, anyway), clang pretends to be a version
267
* prior to gcc 4.3, so we can't detect bswap that way. Instead,
268
* clang has a __has_builtin mechanism that can be used to check
269
* for builtins:
270
* http://clang.llvm.org/docs/LanguageExtensions.html#feature_check */
271
#ifndef __has_builtin
272
#define __has_builtin(x) 0
273
#endif
274
#if !defined(LTC_NO_BSWAP) && defined(__GNUC__) && \
275
((__GNUC__ * 100 + __GNUC_MINOR__ >= 403) || \
276
(__has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64)))
277
#define LTC_HAVE_BSWAP_BUILTIN
278
#endif
279
280