mesa/src/util
Jonas Pfeil fbaf5955ee ralloc: Make sure ralloc() allocations match malloc()'s alignment.
The header of ralloc needs to be aligned, because the compiler assumes
that malloc returns will be aligned to 8/16 bytes depending on the
platform, leading to degraded performance or alignment faults with ralloc.

Fixes SIGBUS on Raspberry Pi at high optimization levels.

This patch is not perfect for MSVC, as maybe in the future the alignment
for the most demanding data type might change to more than 8.

v2: Commit message reword/typo fix, and add a bigger explanation in the
    code (by anholt)

Signed-off-by: Jonas Pfeil <pfeiljonas@gmx.de>
Reviewed-by: Matt Turner <mattst88@gmail.com>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Cc: mesa-stable@lists.freedesktop.org
(cherry picked from commit cd2b55e536)

Squashed with

ralloc: don't leave out the alignment factor

Experimentation shows that without alignment factor gcc and clang choose
a factor of 16 even on IA-32, which doesn't match what malloc() uses (8).
The problem is it makes gcc assume the pointer is 16 byte aligned, so
with -O3 it starts using aligned SSE instructions that later fault,
so always specify a suitable alignment factor.

Cc: Jonas Pfeil <pfeiljonas@gmx.de>
Fixes: cd2b55e5 "ralloc: Make sure ralloc() allocations match malloc()'s alignment."
Bugzilla: https://bugs.freedesktop.org/show_bug.cgi?id=100049
Signed-off-by: Grazvydas Ignotas <notasas@gmail.com>
Tested by: Mike Lothian <mike@fireburn.co.uk>
Tested by: Jonas Pfeil <pfeiljonas@gmx.de>

(cherry picked from commit ff494fe999)
2017-03-16 01:33:52 +00:00
..
sha1 utils: really remove the __END_DECLS macro 2017-01-18 20:11:22 +00:00
tests/hash_table mesa: Add .gitignore entries for make check binaries 2016-05-25 09:41:44 -07:00
.gitignore mesa: Add .gitignore entries for make check binaries 2016-05-25 09:41:44 -07:00
Android.mk android: fix the building rules for Android 5.0 2015-04-22 15:53:35 +01:00
bitscan.c mesa/gallium: Move u_bit_scan{,64} from gallium to util. 2016-06-14 05:19:10 +02:00
bitscan.h radeonsi: make fix_fetch 64-bit 2017-01-16 18:07:08 +01:00
bitset.h util/bitset: Allow iterating over const bitsets 2016-03-24 15:20:44 -07:00
crc32.c util: import CRC32 implementation from gallium 2016-11-22 18:05:51 +01:00
crc32.h util: import CRC32 implementation from gallium 2016-11-22 18:05:51 +01:00
debug.c util: move brw_env_var_as_boolean() to util 2015-11-24 10:02:55 -05:00
debug.h util: Include <stdbool.h> in debug.h. 2015-11-24 10:05:32 -08:00
disk_cache.c util/disk_cache: use stat() to check if entry is a directory 2017-02-13 10:20:41 +00:00
disk_cache.h utils: build sha1/disk cache only with Android/Autoconf 2017-01-18 20:11:20 +00:00
format_r11g11b10f.h mesa: Fix uf10_to_f32() scale factor in the E == 0 and M != 0 case. 2016-08-17 17:26:11 -07:00
format_rgb9e5.h util/format: Use explicitly sized types 2016-08-05 09:07:04 -07:00
format_srgb.h util: Tiny optimisation for the linear→srgb conversion 2015-11-27 10:55:22 +01:00
format_srgb.py gallium: Move sRGB <-> RGB handling to libmesautil 2014-08-04 11:07:15 -07:00
half_float.c glsl: move half<->float convertion to util 2015-10-16 19:33:37 -04:00
half_float.h glsl: move half<->float convertion to util 2015-10-16 19:33:37 -04:00
hash_table.c util: add assert that key cannot be NULL on insertion 2016-08-22 07:37:55 +03:00
hash_table.h util: Move hash_table_call_foreach to util hash table 2016-09-12 10:48:35 +10:00
list.h util: fix list_is_singular() 2017-01-12 13:58:32 +11:00
macros.h mesa: removed redundant #else 2016-11-21 12:44:46 -06:00
Makefile.am util: import sha1 implementation from OpenBSD 2017-01-18 19:07:23 +00:00
Makefile.sources util: import sha1 implementation from OpenBSD 2017-01-18 19:07:23 +00:00
mesa-sha1.c util: import sha1 implementation from OpenBSD 2017-01-18 19:07:23 +00:00
mesa-sha1.h util/sha: do not wrap header inclusion in extern "C" 2016-03-09 17:16:50 +00:00
ralloc.c ralloc: Make sure ralloc() allocations match malloc()'s alignment. 2017-03-16 01:33:52 +00:00
ralloc.h ralloc: add a linear allocator as a child node of ralloc 2016-10-31 11:53:38 +01:00
register_allocate.c util/ra: (trivial) fix c99 loop variable initialization 2015-08-19 04:17:49 +02:00
register_allocate.h util/ra: Make allocating conflict lists optional 2015-08-18 17:48:53 -07:00
rgtc.c util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
rgtc.h util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
roundeven_test.c util: Add a roundeven test. 2015-03-18 21:06:26 -07:00
rounding.h util: try to use SSE instructions with MSVC and 32-bit gcc 2016-08-17 12:53:20 -06:00
SConscript util: import sha1 implementation from OpenBSD 2017-01-18 19:07:23 +00:00
set.c util/set: don't compare against deleted entries 2016-02-02 14:42:32 -05:00
set.h util/hash_set: Rework the API to know about hashing 2015-01-15 13:21:27 -08:00
simple_list.h mesa: Port a variant of 68afbe89c7 to util/ 2015-01-28 16:33:34 -08:00
slab.c util: remove unused variable 2016-10-07 21:24:50 +11:00
slab.h util/slab: re-design to allow migration between pools (v3) 2016-10-05 15:40:40 +02:00
string_to_uint_map.cpp mesa/glsl: Move string_to_uint_map into the util folder 2016-09-12 10:48:35 +10:00
string_to_uint_map.h mesa/glsl: Move string_to_uint_map into the util folder 2016-09-12 10:48:35 +10:00
strndup.c util: use strnlen() in strndup() implementations 2015-09-30 08:13:07 +02:00
strndup.h util: Fix strndup prototype on C++. 2015-09-29 16:01:56 +01:00
strtod.c mesa/main: free locale at exit 2015-06-29 09:06:40 -07:00
strtod.h mesa/main: free locale at exit 2015-06-29 09:06:40 -07:00
texcompress_rgtc_tmp.h util: move shared rgtc code to util (v2) 2014-09-17 11:27:25 +10:00
u_atomic.h util: use GCC atomic intrinsics with explicit memory model 2016-10-05 15:39:39 +02:00
u_atomic_test.c util: fix comment typo 2015-12-04 14:06:41 +00:00
u_endian.h u_endian: add android to glibc clause 2016-09-13 10:04:13 +10:00
u_vector.c util: add vector util code. 2016-10-19 09:05:25 +10:00
u_vector.h util: use STATIC_ASSERT instead of static_assert 2016-11-11 07:59:29 +02:00
vk_alloc.h util/vk_alloc: Add a vk_zalloc2 helper 2016-11-17 12:03:24 -08:00