File tree Expand file tree Collapse file tree 2 files changed +14
-1
lines changed
Expand file tree Collapse file tree 2 files changed +14
-1
lines changed Original file line number Diff line number Diff line change 2424#define USE_SPIN_LOCKS 0 // Ensure we use pthread_mutex_t.
2525#endif
2626
27+ #ifndef MALLOC_ALIGNMENT
28+ #include <stddef.h>
29+ /* `malloc`ed pointers must be aligned at least as strictly as max_align_t. */
30+ #define MALLOC_ALIGNMENT (__alignof__(max_align_t))
31+ /*
32+ Emscripten aligns even float128 to 64-bits, to save size and increase speed.
33+ See https://github.com/emscripten-core/emscripten/issues/10072
34+ */
35+ _Static_assert (MALLOC_ALIGNMENT == 8 , "max_align_t must be 8" );
2736#endif
2837
38+ #endif // __EMSCRIPTEN__
39+
2940
3041#define __THROW
3142#define __attribute_malloc__
Original file line number Diff line number Diff line change 3939 * malloc.
4040 */
4141
42+ #include < stddef.h>
4243#include < stdint.h>
4344#include < unistd.h>
4445#include < memory.h>
@@ -60,7 +61,8 @@ extern "C"
6061
6162// Configuration: specifies the minimum alignment that malloc()ed memory outputs. Allocation requests with smaller alignment
6263// than this will yield an allocation with this much alignment.
63- #define MALLOC_ALIGNMENT 8
64+ #define MALLOC_ALIGNMENT alignof (max_align_t )
65+ _Static_assert(alignof (max_align_t ) == 8, "max_align_t must be correct");
6466
6567#define EMMALLOC_EXPORT __attribute__ ((weak, __visibility__(" default" )))
6668
You can’t perform that action at this time.
0 commit comments