added alignment test
and fix an incorrect alignment check in cwksp which was failing on m68kdev
parent
9b97fdf74f
commit
e89e847820
|
@ -80,6 +80,26 @@ extern "C" {
|
|||
#endif
|
||||
|
||||
|
||||
/*-**************************************************************
|
||||
* Alignment check
|
||||
*****************************************************************/
|
||||
|
||||
/* C11 support */
|
||||
#if defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)
|
||||
|
||||
#include <stdalign.h>
|
||||
# define MEM_ALIGN_COND(T) alignof(T)
|
||||
|
||||
#elif defined(__GNUC__) || defined(_MSC_VER)
|
||||
|
||||
# define MEM_ALIGN_COND(T) __alignof(T)
|
||||
|
||||
#else
|
||||
|
||||
# define MEM_ALIGN_COND(T) 1 /* most likely incorrect, just to pass tests */
|
||||
|
||||
#endif
|
||||
|
||||
/*-**************************************************************
|
||||
* Memory I/O API
|
||||
*****************************************************************/
|
||||
|
|
|
@ -422,8 +422,8 @@ MEM_STATIC void* ZSTD_cwksp_reserve_object(ZSTD_cwksp* ws, size_t bytes) {
|
|||
DEBUGLOG(5,
|
||||
"cwksp: reserving %p object %zd bytes (rounded to %zd), %zd bytes remaining",
|
||||
alloc, bytes, roundedBytes, ZSTD_cwksp_available_space(ws) - roundedBytes);
|
||||
assert(((size_t)alloc & (sizeof(void*)-1)) == 0);
|
||||
assert((bytes & (sizeof(void*)-1)) == 0);
|
||||
assert((size_t)alloc % MEM_ALIGN_COND(void*) == 0);
|
||||
assert(bytes % MEM_ALIGN_COND(void*) == 0);
|
||||
ZSTD_cwksp_assert_internal_consistency(ws);
|
||||
/* we must be in the first phase, no advance is possible */
|
||||
if (ws->phase != ZSTD_cwksp_alloc_objects || end > ws->workspaceEnd) {
|
||||
|
|
Loading…
Reference in New Issue