8000 Fixed big endian handling when running without unaligned access. Addi… · coderforlife/ms-compress@e5d8cc5 · GitHub
[go: up one dir, main page]

Skip to content

Commit e5d8cc5

Browse files
committed
Fixed big endian handling when running without unaligned access. Additionally removed PDP endian code as there is no way to test it and may have been wrong. Also properly indented various other defines in the internal header.
Working on #32.
1 parent d70aefe commit e5d8cc5

File tree

1 file changed

+119
-135
lines changed

1 file changed

+119
-135
lines changed

include/mscomp/internal.h

Lines changed: 119 additions & 135 deletions
1E0A
Original file line numberDiff line numberDiff line change
@@ -52,97 +52,81 @@
5252
#endif
5353

5454
///// 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
5656
// 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)
5959
#if defined(_MSC_VER) || defined(_WIN32)
6060
#define MSCOMP_LITTLE_ENDIAN
6161
#elif defined(__BYTE_ORDER__)
6262
#if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
6363
#define MSCOMP_LITTLE_ENDIAN
6464
#elif __BYTE_ORDER__ == __ORDER_BIG_ENDIAN__
6565
#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
7066
#endif
7167
#elif defined(__LITTLE_ENDIAN__)
7268
#define MSCOMP_LITTLE_ENDIAN
7369
#elif defined(WORDS_BIGENDIAN) || defined(__BIG_ENDIAN__)
7470
#define MSCOMP_BIG_ENDIAN
7571
#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
7781
#if defined(__BYTE_ORDER)
7882
#if __BYTE_ORDER == __LITTLE_ENDIAN
7983
#define MSCOMP_LITTLE_ENDIAN
8084
#elif __BYTE_ORDER == __BIG_ENDIAN
8185
#define MSCOMP_BIG_ENDIAN
82-
#elif __BYTE_ORDER == __PDP_ENDIAN
83-
#define MSCOMP_PDP_ENDIAN
8486
#endif
8587
#elif defined(_BYTE_ORDER)
8688
#if _BYTE_ORDER == _LITTLE_ENDIAN
8789
#define MSCOMP_LITTLE_ENDIAN
8890
#elif _BYTE_ORDER == _BIG_ENDIAN
8991
#define MSCOMP_BIG_ENDIAN
90-
#elif _BYTE_ORDER == _PDP_ENDIAN
91-
#define MSCOMP_PDP_ENDIAN
9292
#endif
9393
#endif
9494
#endif
9595
#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+
96100

97101
///// Get ints from a byte stream /////
98102
// These assume that the byte stream is little-endian (except RAW which don't care)
99103
#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))
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)
146130
#endif
147131

148132
///// Determine the number of bits used by pointers /////
@@ -162,45 +146,45 @@
162146
// Note: most compilers define these for us, just MSVC doesn't define __SSE__/__SSE2__
163147
// However it does define __AVX__
164148
#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
171155
#endif
172156
#ifdef __SSE__
173-
#include <xmmintrin.h>
157+
#include <xmmintrin.h>
174158
#endif
175159

176160
///// Get NOINLINE, INLINE and FORCE_INLINE /////
177161
#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
181165
#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))
185169
#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
189173
#else
190-
#define NOINLINE
191-
#define INLINE
192-
#define FORCE_INLINE INLINE
174+
#define NOINLINE
175+
#define INLINE
176+
#define FORCE_INLINE INLINE
193177
#endif
194178

195179
///// Get RESTRICT /////
196180
#if defined(_MSC_VER)
197-
#define RESTRICT __restrict
181+
#define RESTRICT __restrict
198182
#elif defined(__GNUC__)
199-
#define RESTRICT __restrict__
183+
#define RESTRICT __restrict__
200184
#elif (__STDC_VERSION__ >= 199901L)
201-
#define RESTRICT restrict
185+
#define RESTRICT restrict
202186
#else
203-
#define RESTRICT
187+
#define RESTRICT
204188
#endif
205189
// typedef the most common restricted pointers
206190
typedef byte* RESTRICT rest_bytes;
@@ -377,60 +361,60 @@ typedef const_byte* RESTRICT const_rest_bytes;
377361

378362
///// Get SIZE_T format specifier /////
379363
#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"
381365
#else
382-
#define SSIZE_T_FMT "z"
366+
#define SSIZE_T_FMT "z"
383367
#endif
384368

385369
///// Compile it right /////
386370
#if defined(__cplusplus_cli)
387-
#pragma unmanaged
371+
#pragma unmanaged
388372
#endif
389373
#if defined(_MSC_VER) && defined(NDEBUG)
390-
#pragma optimize("t", on)
374+
#pragma optimize("t", on)
391375
#endif
392376
#if defined(__GNUC__) && defined(__MINGW32__)
393377
// GCC assumes a 16-byte aligned stack, Windows only guarantees 4-byte alignment, we need to tell
394378
// GCC to fix all entry points to have a 16-byte alignment (but once aligned, we are good to go).
395379
// ENTRY_POINT only needs to be used on functions that may use SSE instructions in their call stack
396380
// 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))
398382
#else
399-
#define ENTRY_POINT
383+
#define ENTRY_POINT
400384
#endif
401385

402386
///// Warning disable support /////
403387
#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+
#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))
412396
#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\"")
425409
#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()
434418
#endif
435419

436420
///// Compile-time assert /////
@@ -441,26 +425,26 @@ typedef const_byte* RESTRICT const_rest_bytes;
441425

442426
///// Error and Warning Messages /////
443427
#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
448432
#endif
449433

450434
#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
453437
#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)
456440
#endif
457441

458442
#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
461445
#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)
464448
#endif
465449

466450
///// Stream initialization and checking /////
@@ -530,20 +514,20 @@ typedef const_byte* RESTRICT const_rest_bytes;
530514
#define COPY_4x(out, in) (out)[0] = (in)[0]; (out)[1] = (in)[1]; (out)[2] = (in)[2]; (out)[3] = (in)[3]
531515

532516
#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)))
537521
#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)
540524
#endif
541525

542526
// COPY_128_FAST - Copy a 128-bit value from the pointer in to the pointer out
543527
#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)))
545529
#else
546-
#define COPY_128_FAST(out, in) COPY_4x32(out, in)
530+
#define COPY_128_FAST(out, in) COPY_4x32(out, in)
547531
#endif
548532

549533
#define FAST_COPY_ROOM 16

0 commit comments

Comments
 (0)
0