52
52
#endif
53
53
54
54
///// Determine the endianness of the compilation, however this isn't very accurate /////
55
- // It would be much better to define MSCOMP_LITTLE_ENDIAN, MSCOMP_MSCOMP_BIG_ENDIAN, or PDP_ENDIAN yourself
55
+ // It would be much better to define MSCOMP_LITTLE_ENDIAN or MSCOMP_MSCOMP_BIG_ENDIAN yourself
56
56
// MSCOMP_LITTLE_ENDIAN is what the program is developed for and tested with
57
- // MSCOMP_BIG_ENDIAN and PDP_ENDIAN are untested
58
- #if !defined(MSCOMP_LITTLE_ENDIAN ) && !defined(MSCOMP_BIG_ENDIAN ) && !defined( MSCOMP_PDP_ENDIAN )
57
+ // MSCOMP_BIG_ENDIAN has been tested as well
58
+ #if !defined(MSCOMP_LITTLE_ENDIAN ) && !defined(MSCOMP_BIG_ENDIAN )
59
59
#if defined(_MSC_VER ) || defined(_WIN32 )
60
60
#define MSCOMP_LITTLE_ENDIAN
61
61
#elif defined(__BYTE_ORDER__ )
62
62
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
63
63
#define MSCOMP_LITTLE_ENDIAN
64
64
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
65
65
#define MSCOMP_BIG_ENDIAN
66
- #elif __BYTE_ORDER__ == __ORDER_PDP_ENDIAN__
67
- #define MSCOMP_PDP_ENDIAN
68
- #else
69
- #error unknown endian, define one of LITTLE_ENDIAN, BIG_ENDIAN, or PDP_ENDIAN
70
66
#endif
71
67
#elif defined(__LITTLE_ENDIAN__ )
72
68
#define MSCOMP_LITTLE_ENDIAN
73
69
#elif defined(WORDS_BIGENDIAN ) || defined(__BIG_ENDIAN__ )
74
70
#define MSCOMP_BIG_ENDIAN
75
71
#else
76
- #include <endian.h> // may also be in machine/endian.h (Mac OS and Open BSD) or sys/endian.h (non-open BSD)
72
+ #if defined(__APPLE__ )
73
+ #include <libkern/OSByteOrder.h>
74
+ #elif defined(__FreeBSD__ ) || defined(__NetBSD__ ) || defined(__OpenBSD__ ) || defined(__bsdi__ ) || defined(__DragonFly__ )
75
+ #include <sys/endian.h>
76
+ #elif defined(__sun ) || defined(sun )
77
+ #include <sys/byteorder.h>
78
+ #else
79
+ #include <endian.h>
80
+ #endif
77
81
#if defined(__BYTE_ORDER )
78
82
#if __BYTE_ORDER == __LITTLE_ENDIAN
79
83
#define MSCOMP_LITTLE_ENDIAN
80
84
#elif __BYTE_ORDER == __BIG_ENDIAN
81
85
#define MSCOMP_BIG_ENDIAN
82
- #elif __BYTE_ORDER == __PDP_ENDIAN
83
- #define MSCOMP_PDP_ENDIAN
84
86
#endif
85
87
#elif defined(_BYTE_ORDER )
86
88
#if _BYTE_ORDER == _LITTLE_ENDIAN
87
89
#define MSCOMP_LITTLE_ENDIAN
88
90
#elif _BYTE_ORDER == _BIG_ENDIAN
89
91
#define MSCOMP_BIG_ENDIAN
90
- #elif _BYTE_ORDER == _PDP_ENDIAN
91
- #define MSCOMP_PDP_ENDIAN
92
92
#endif
93
93
#endif
94
94
#endif
95
95
#endif
96
+ #if !defined(MSCOMP_LITTLE_ENDIAN ) && !defined(MSCOMP_BIG_ENDIAN )
97
+ #error unknown endian, define one of MSCOMP_LITTLE_ENDIAN or MSCOMP_BIG_ENDIAN
98
+ #endif
99
+
96
100
97
101
///// Get ints from a byte stream /////
98
102
// These assume that the byte stream is little-endian (except RAW which don't care)
99
103
#if defined(MSCOMP_WITH_UNALIGNED_ACCESS )
100
- #define GET_UINT16_RAW (x ) (*(const uint16_t*)(x))
101
- #define GET_UINT32_RAW (x ) (*(const uint32_t*)(x))
102
- #define SET_UINT16_RAW (x ,val ) (*(uint16_t*)(x) = (uint16_t)(val))
103
- #define SET_UINT32_RAW (x ,val ) (*(uint32_t*)(x) = (uint32_t)(val))
1E0A
104
- #if defined(MSCOMP_LITTLE_ENDIAN )
105
- #define GET_UINT16 (x ) (*(const uint16_t*)(x))
106
- #define GET_UINT32 (x ) (*(const uint32_t*)(x))
107
- #define SET_UINT16 (x ,val ) (*(uint16_t*)(x) = (uint16_t)(val))
108
- #define SET_UINT32 (x ,val ) (*(uint32_t*)(x) = (uint32_t)(val))
109
- #elif defined(MSCOMP_BIG_ENDIAN )
110
- // These could also use the without-unaligned-access versions always
111
- #define GET_UINT16 (x ) byte_swap(*(const uint16_t*)(x))
112
- #define GET_UINT32 (x ) byte_swap(*(const uint32_t*)(x))
113
- #define SET_UINT16 (x ,val ) (*(uint16_t*)(x) = byte_swap((uint16_t)(val)))
114
- #define SET_UINT32 (x ,val ) (*(uint32_t*)(x) = byte_swap((uint32_t)(val)))
115
- #elif defined(MSCOMP_PDP_ENDIAN ) // for 16-bit ints its the same as little-endian
116
- #define GET_UINT16 (x ) (*(const uint16_t*)(x))
117
- #define GET_UINT32 (x ) ((*(const uint16_t*)(x)<<16)|*(const uint16_t*)((x)+2))
118
- #define SET_UINT16 (x ,val ) (*(uint16_t*)(x) = (uint16_t)(val))
119
- #define SET_UINT32 (x ,val ) (*(uint16_t*)(x) = (uint16_t)((val) >> 16), *(((uint16_t*)(x))+1) = (uint16_t)(val))
120
- #else
121
- #error unknown endian, define one of MSCOMP_LITTLE_ENDIAN, MSCOMP_BIG_ENDIAN, or MSCOMP_PDP_ENDIAN
122
- #endif
123
- #else
124
- #define GET_UINT16_RAW (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8))
125
- #define GET_UINT32_RAW (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8)|(((byte*)(x))[2]<<16)|(((byte*)(x))[3]<<24))
126
- #define SET_UINT16_RAW (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8))
127
- #define SET_UINT32_RAW (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8), ((byte*)(x))[2]=(byte)((val)>>16), ((byte*)(x))[3]=(byte)((val)>>24))
128
- #if defined(MSCOMP_LITTLE_ENDIAN )
129
- #define GET_UINT16 (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8))
130
- #define GET_UINT32 (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8)|(((byte*)(x))[2]<<16)|(((byte*)(x))[3]<<24))
131
- #define SET_UINT16 (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8))
132
- #define SET_UINT32 (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8), ((byte*)(x))[2]=(byte)((val)>>16), ((byte*)(x))[3]=(byte)((val)>>24))
133
- #elif defined(MSCOMP_BIG_ENDIAN )
134
- #define GET_UINT16 (x ) ((((byte*)(x))[0]<<8)|((byte*)(x))[1])
135
- #define GET_UINT32 (x ) ((((byte*)(x))[0]<<24)|(((byte*)(x))[1]<<16)|(((byte*)(x))[2]<<8)|((byte*)(x))[3])
136
- #define SET_UINT16 (x ,val ) (((byte*)(x))[0]=(byte)((val)>>8), ((byte*)(x))[1]=(byte)((val)>>0))
137
- #define SET_UINT32 (x ,val ) (((byte*)(x))[0]=(byte)((val)>>24), ((byte*)(x))[1]=(byte)((val)>>16), ((byte*)(x))[2]=(byte)((val)>>8), ((byte*)(x))[3]=(byte)(val))
138
- #elif defined(MSCOMP_PDP_ENDIAN ) // for 16-bit ints its the same as little-endian
139
- #define GET_UINT16 (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8))
140
- #define GET_UINT32 (x ) ((((byte*)(x))[0]<<16)|(((byte*)(x))[1]<<24)|((byte*)(x))[2]|(((byte*)(x))[3]<<8))
141
- #define SET_UINT16 (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8))
142
- #define SET_UINT32 (x ,val ) (((byte*)(x))[0]=(byte)((val)>>16), ((byte*)(x))[1]=(byte)((val)>>24), ((byte*)(x))[2]=(byte)(val), ((byte*)(x))[3]=(byte)((val)>>8))
143
- #else
144
- #error unknown endian, define one of MSCOMP_LITTLE_ENDIAN, MSCOMP_BIG_ENDIAN, or MSCOMP_PDP_ENDIAN
145
- #endif
104
+ #define GET_UINT16_RAW (x ) (*(const uint16_t*)(x))
105
+ #define GET_UINT32_RAW (x ) (*(const uint32_t*)(x))
106
+ #define SET_UINT16_RAW (x ,val ) (*(uint16_t*)(x) = (uint16_t)(val))
107
+ #define SET_UINT32_RAW (x ,val ) (*(uint32_t*)(x) = (uint32_t)(val))
108
+ #if defined(MSCOMP_LITTLE_ENDIAN )
109
+ #define GET_UINT16 (x ) GET_UINT16_RAW(x)
110
+ #define GET_UINT32 (x ) GET_UINT32_RAW(x)
111
+ #define SET_UINT16 (x ,val ) SET_UINT16_RAW(x,val)
112
+ #define SET_UINT32 (x ,val ) SET_UINT32_RAW(x,val)
113
+ #elif defined(MSCOMP_BIG_ENDIAN )
114
+ // These could also use the without-unaligned-access versions always
115
+ #define GET_UINT16 (x ) byte_swap(*(const uint16_t*)(x))
116
+ #define GET_UINT32 (x ) byte_swap(*(const uint32_t*)(x))
117
+ #define SET_UINT16 (x ,val ) (*(uint16_t*)(x) = byte_swap((uint16_t)(val)))
118
+ #define SET_UINT32 (x ,val ) (*(uint32_t*)(x) = byte_swap((uint32_t)(val)))
119
+ #endif
120
+ #else // if MSCOMP_WITHOUT_UNALIGNED_ACCESS:
121
+ // When not using unaligned access, nothing needs to be done for different endians
122
+ #define GET_UINT16_RAW (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8))
123
+ #define GET_UINT32_RAW (x ) (((byte*)(x))[0]|(((byte*)(x))[1]<<8)|(((byte*)(x))[2]<<16)|(((byte*)(x))[3]<<24))
124
+ #define SET_UINT16_RAW (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8))
125
+ #define SET_UINT32_RAW (x ,val ) (((byte*)(x))[0]=(byte)(val), ((byte*)(x))[1]=(byte)((val)>>8), ((byte*)(x))[2]=(byte)((val)>>16), ((byte*)(x))[3]=(byte)((val)>>24))
126
+ #define GET_UINT16 (x ) GET_UINT16_RAW(x)
127
+ #define GET_UINT32 (x ) GET_UINT32_RAW(x)
128
+ #define SET_UINT16 (x ,val ) SET_UINT16_RAW(x,val)
129
+ #define SET_UINT32 (x ,val ) SET_UINT32_RAW(x,val)
146
130
#endif
147
131
148
132
///// Determine the number of bits used by pointers /////
162
146
// Note: most compilers define these for us, just MSVC doesn't define __SSE__/__SSE2__
163
147
// However it does define __AVX__
164
148
#if defined(_MSC_VER )
165
- #if defined(_M_AMD64 ) || defined(_M_X64 ) || (defined(_M_IX86_FP ) && _M_IX86_FP == 2 )
166
- #define __SSE2__
167
- #define __SSE__
168
- #elif defined(_M_IX86_FP ) && _M_IX86_FP == 1
169
- #define __SSE__
170
- #endif
149
+ #if defined(_M_AMD64 ) || defined(_M_X64 ) || (defined(_M_IX86_FP ) && _M_IX86_FP == 2 )
150
+ #define __SSE2__
151
+ #define __SSE__
152
+ #elif defined(_M_IX86_FP ) && _M_IX86_FP == 1
153
+ #define __SSE__
154
+ #endif
171
155
#endif
172
156
#ifdef __SSE__
173
- #include <xmmintrin.h>
157
+ #include <xmmintrin.h>
174
158
#endif
175
159
176
160
///// Get NOINLINE, INLINE and FORCE_INLINE /////
177
161
#if defined(_MSC_VER )
178
- #define NOINLINE __declspec(noinline)
179
- #define INLINE __inline
180
- #define FORCE_INLINE __forceinline
162
+ #define NOINLINE __declspec(noinline)
163
+ #define INLINE __inline
164
+ #define FORCE_INLINE __forceinline
181
165
#elif defined(__GNUC__ )
182
- #define NOINLINE __attribute__((noinline))
183
- #define INLINE inline
184
- #define FORCE_INLINE inline __attribute__((always_inline))
166
+ #define NOINLINE __attribute__((noinline))
167
+ #define INLINE inline
168
+ #define FORCE_INLINE inline __attribute__((always_inline))
185
169
#elif (__STDC_VERSION__ >= 199901L )
186
- #define NOINLINE
187
- #define INLINE inline
188
- #define FORCE_INLINE INLINE
170
+ #define NOINLINE
171
+ #define INLINE inline
172
+ #define FORCE_INLINE INLINE
189
173
#else
190
- #define NOINLINE
191
- #define INLINE
192
- #define FORCE_INLINE INLINE
174
+ #define NOINLINE
175
+ #define INLINE
176
+ #define FORCE_INLINE INLINE
193
177
#endif
194
178
195
179
///// Get RESTRICT /////
196
180
#if defined(_MSC_VER )
197
- #define RESTRICT __restrict
181
+ #define RESTRICT __restrict
198
182
#elif defined(__GNUC__ )
199
- #define RESTRICT __restrict__
183
+ #define RESTRICT __restrict__
200
184
#elif (__STDC_VERSION__ >= 199901L )
201
- #define RESTRICT restrict
185
+ #define RESTRICT restrict
202
186
#else
203
- #define RESTRICT
187
+ #define RESTRICT
204
188
#endif
205
189
// typedef the most common restricted pointers
206
190
typedef byte * RESTRICT rest_bytes ;
@@ -377,60 +361,60 @@ typedef const_byte* RESTRICT const_rest_bytes;
377
361
378
362
///// Get SIZE_T format specifier /////
379
363
#if defined(_WIN32 ) && (!defined(__USE_MINGW_ANSI_STDIO ) || __USE_MINGW_ANSI_STDIO != 1 )
380
- #define SSIZE_T_FMT "I"
364
+ #define SSIZE_T_FMT "I"
381
365
#else
382
- #define SSIZE_T_FMT "z"
366
+ #define SSIZE_T_FMT "z"
383
367
#endif
384
368
385
369
///// Compile it right /////
386
370
#if defined(__cplusplus_cli )
387
- #pragma unmanaged
371
+ #pragma unmanaged
388
372
#endif
389
373
#if defined(_MSC_VER ) && defined(NDEBUG )
390
- #pragma optimize("t", on)
374
+ #pragma optimize("t", on)
391
375
#endif
392
376
#if defined(__GNUC__ ) && defined(__MINGW32__ )
393
377
// GCC assumes a 16-byte aligned stack, Windows only guarantees 4-byte alignment, we need to tell
394
378
// GCC to fix all entry points to have a 16-byte alignment (but once aligned, we are good to go).
395
379
// ENTRY_POINT only needs to be used on functions that may use SSE instructions in their call stack
396
380
// and that can be called directly by outside code (export, callback, or main function).
397
- #define ENTRY_POINT __attribute__((force_align_arg_pointer))
381
+ #define ENTRY_POINT __attribute__((force_align_arg_pointer))
398
382
#else
399
- #define ENTRY_POINT
383
+ #define ENTRY_POINT
400
384
#endif
401
385
402
386
///// Warning disable support /////
403
387
#if defined(_MSC_VER )
404
- #define WARNINGS_PUSH () __pragma(warning(push))
405
- #define WARNINGS_POP () __pragma(warning(pop))
406
- #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT () __pragma(warning(disable:4127))
407
- #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR () __pragma(warning(disable:4706))
408
- #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW () __pragma(warning(disable:4309))
409
- #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED () __pragma(warning(disable:4512))
410
- #define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED () __pragma(warning(disable:4701 4703))
411
- #define WARNINGS_IGNORE_DIV_BY_0 () __pragma(warning(disable:4723 4724))
388
+
F438
span>#define WARNINGS_PUSH () __pragma(warning(push))
389
+ #define WARNINGS_POP () __pragma(warning(pop))
390
+ #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT () __pragma(warning(disable:4127))
391
+ #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR () __pragma(warning(disable:4706))
392
+ #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW () __pragma(warning(disable:4309))
393
+ #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED () __pragma(warning(disable:4512))
394
+ #define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED () __pragma(warning(disable:4701 4703))
395
+ #define WARNINGS_IGNORE_DIV_BY_0 () __pragma(warning(disable:4723 4724))
412
396
#elif defined(__GNUC__ ) && (__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 6 ))
413
- #define WARNINGS_PUSH () _Pragma("GCC diagnostic push")
414
- #define WARNINGS_POP () _Pragma("GCC diagnostic pop")
415
- #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT ()
416
- #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR()
417
- #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW () _Pragma("GCC diagnostic ignored \"-Woverflow\"")
418
- #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED ()
419
- # if __GNUC__ == 4 && __GNUC_MINOR__ >= 7
420
- # define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED () _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
421
- # else
422
- # define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED ()
423
- # endif
424
- #define WARNINGS_IGNORE_DIV_BY_0 () _Pragma("GCC diagnostic ignored \"-Wdiv-by-zero\"")
397
+ #define WARNINGS_PUSH () _Pragma("GCC diagnostic push")
398
+ #define WARNINGS_POP () _Pragma("GCC diagnostic pop")
399
+ #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT ()
400
+ #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR()
401
+ #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW () _Pragma("GCC diagnostic ignored \"-Woverflow\"")
402
+ #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED ()
403
+ # if __GNUC__ == 4 && __GNUC_MINOR__ >= 7
404
+ # define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED () _Pragma("GCC diagnostic ignored \"-Wmaybe-uninitialized\"")
405
+ # else
406
+ # define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED ()
407
+ # endif
408
+ #define WARNINGS_IGNORE_DIV_BY_0 () _Pragma("GCC diagnostic ignored \"-Wdiv-by-zero\"")
425
409
#else
426
- #define WARNINGS_PUSH ()
427
- #define WARNINGS_POP()
428
- #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT ()
429
- #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR()
430
- #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW ()
431
- #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED()
432
- #define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED ()
433
- #define WARNINGS_IGNORE_DIV_BY_0()
410
+ #define WARNINGS_PUSH ()
411
+ #define WARNINGS_POP()
412
+ #define WARNINGS_IGNORE_CONDITIONAL_EXPR_CONSTANT ()
413
+ #define WARNINGS_IGNORE_ASSIGNMENT_WITHIN_COND_EXPR()
414
+ #define WARNINGS_IGNORE_TRUNCATED_OVERFLOW ()
415
+ #define WARNINGS_IGNORE_ASSIGNMENT_OPERATOR_NOT_GENERATED()
416
+ #define WARNINGS_IGNORE_POTENTIAL_UNINIT_VALRIABLE_USED ()
417
+ #define WARNINGS_IGNORE_DIV_BY_0()
434
418
#endif
435
419
436
420
///// Compile-time assert /////
@@ -441,26 +425,26 @@ typedef const_byte* RESTRICT const_rest_bytes;
441
425
442
426
///// Error and Warning Messages /////
443
427
#if defined(MSCOMP_WITH_ERROR_MESSAGES ) || defined(MSCOMP_WITH_WARNING_MESSAGES )
444
- #include <stdio.h>
445
- #if _MSC_VER
446
- #define snprintf _snprintf
447
- #endif
428
+ #include <stdio.h>
429
+ #if _MSC_VER
430
+ #define snprintf _snprintf
431
+ #endif
448
432
#endif
449
433
450
434
#ifdef MSCOMP_WITH_ERROR_MESSAGES
451
- #define SET_ERROR (s , ...) snprintf(s->error, ARRAYSIZE(s->error), __VA_ARGS__)
452
- #define INIT_STREAM_ERROR_MESSAGE (s ) s->error[0] = 0
435
+ #define SET_ERROR (s , ...) snprintf(s->error, ARRAYSIZE(s->error), __VA_ARGS__)
436
+ #define INIT_STREAM_ERROR_MESSAGE (s ) s->error[0] = 0
453
437
#else
454
- #define SET_ERROR (s , ...)
455
- #define INIT_STREAM_ERROR_MESSAGE (s )
438
+ #define SET_ERROR (s , ...)
439
+ #define INIT_STREAM_ERROR_MESSAGE (s )
456
440
#endif
457
441
458
442
#ifdef MSCOMP_WITH_WARNING_MESSAGES
459
- #define SET_WARNING (s , ...) snprintf(s->warning, ARRAYSIZE(s->warning), __VA_ARGS__)
460
- #define INIT_STREAM_WARNING_MESSAGE (s ) s->warning[0] = 0
443
+ #define SET_WARNING (s , ...) snprintf(s->warning, ARRAYSIZE(s->warning), __VA_ARGS__)
444
+ #define INIT_STREAM_WARNING_MESSAGE (s ) s->warning[0] = 0
461
445
#else
462
- #define SET_WARNING (s , ...)
463
- #define INIT_STREAM_WARNING_MESSAGE (s )
446
+ #define SET_WARNING (s , ...)
447
+ #define INIT_STREAM_WARNING_MESSAGE (s )
464
448
#endif
465
449
466
450
///// Stream initialization and checking /////
@@ -530,20 +514,20 @@ typedef const_byte* RESTRICT const_rest_bytes;
530
514
#define COPY_4x (out , in ) (out)[0] = (in)[0]; (out)[1] = (in)[1]; (out)[2] = (in)[2]; (out)[3] = (in)[3]
531
515
532
516
#if defined(MSCOMP_WITH_UNALIGNED_ACCESS )
533
- // COPY_32 - Copy a 32-bit value from the pointer in to the pointer out
534
- #define COPY_32 (out , in ) *(uint32_t*)(out) = *(uint32_t*)(in)
535
- // COPY_4x32 - Copy 4 32-bit values from the pointer in to the pointer out
536
- #define COPY_4x32 (out , in ) COPY_4x(((uint32_t*)(out)), ((uint32_t*)(in)))
517
+ // COPY_32 - Copy a 32-bit value from the pointer in to the pointer out
518
+ #define COPY_32 (out , in ) *(uint32_t*)(out) = *(uint32_t*)(in)
519
+ // COPY_4x32 - Copy 4 32-bit values from the pointer in to the pointer out
520
+ #define COPY_4x32 (out , in ) COPY_4x(((uint32_t*)(out)), ((uint32_t*)(in)))
537
521
#else
538
- #define COPY_32 (out , in ) COPY_4x((byte*)(out), (byte*)(in))
539
- #define COPY_4x32 (out , in ) COPY_32(((uint32_t*)(out)), ((uint32_t*)(in))); COPY_32(((uint32_t*)(out))+1, ((uint32_t*)(in))+1); COPY_32(((uint32_t*)(out))+2, ((uint32_t*)(in))+2); COPY_32(((uint32_t*)(out))+3, ((uint32_t*)(in))+3)
522
+ #define COPY_32 (out , in ) COPY_4x((byte*)(out), (byte*)(in))
523
+ #define COPY_4x32 (out , in ) COPY_32(((uint32_t*)(out)), ((uint32_t*)(in))); COPY_32(((uint32_t*)(out))+1, ((uint32_t*)(in))+1); COPY_32(((uint32_t*)(out))+2, ((uint32_t*)(in))+2); COPY_32(((uint32_t*)(out))+3, ((uint32_t*)(in))+3)
540
524
#endif
541
525
542
526
// COPY_128_FAST - Copy a 128-bit value from the pointer in to the pointer out
543
527
#if defined(__SSE__ ) && defined(MSCOMP_WITH_UNALIGNED_ACCESS )
544
- #define COPY_128_FAST (out , in ) _mm_storeu_ps((float*)(out), _mm_loadu_ps((float*)(in)))
528
+ #define COPY_128_FAST (out , in ) _mm_storeu_ps((float*)(out), _mm_loadu_ps((float*)(in)))
545
529
#else
546
- #define COPY_128_FAST (out , in ) COPY_4x32(out, in)
530
+ #define COPY_128_FAST (out , in ) COPY_4x32(out, in)
547
531
#endif
548
532
549
533
#define FAST_COPY_ROOM 16
0 commit comments