BUILD: Overhaul how we determine the need for aligned mem access

Also add some comments explaining what is going on and why.
This commit is contained in:
Max Horn 2011-05-05 13:43:30 +02:00
parent e013a51604
commit 63a69b4f1e

104
configure vendored
View file

@ -158,7 +158,7 @@ _translation=yes
# Default platform settings # Default platform settings
_backend=sdl _backend=sdl
_endian=unknown _endian=unknown
_need_memalign=no _need_memalign=yes
_have_x86=no _have_x86=no
_arm_asm=no _arm_asm=no
_verbose_build=no _verbose_build=no
@ -1741,7 +1741,6 @@ if test -n "$_host"; then
case "$_host" in case "$_host" in
android | android-v7a) android | android-v7a)
_unix=yes _unix=yes
_need_memalign=yes
# we link a .so as default # we link a .so as default
LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic,--no-undefined" LDFLAGS="$LDFLAGS -shared -Wl,-Bsymbolic,--no-undefined"
HOSTEXEPRE=lib HOSTEXEPRE=lib
@ -1755,15 +1754,12 @@ if test -n "$_host"; then
;; ;;
arm-linux|arm*-linux-gnueabi|arm-*-linux) arm-linux|arm*-linux-gnueabi|arm-*-linux)
_unix=yes _unix=yes
_need_memalign=yes
;; ;;
arm-riscos|linupy) arm-riscos|linupy)
DEFINES="$DEFINES -DLINUPY" DEFINES="$DEFINES -DLINUPY"
_unix=yes _unix=yes
_need_memalign=yes
;; ;;
bfin*) bfin*)
_need_memalign=yes
;; ;;
caanoo) caanoo)
# This uses the GPH backend. # This uses the GPH backend.
@ -1778,7 +1774,6 @@ if test -n "$_host"; then
CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
ASFLAGS="$ASFLAGS" ASFLAGS="$ASFLAGS"
_unix=yes _unix=yes
_need_memalign=yes
_backend="gph" _backend="gph"
_build_hq_scalers=no _build_hq_scalers=no
_vkeybd=yes _vkeybd=yes
@ -1795,7 +1790,6 @@ if test -n "$_host"; then
DEFINES="$DEFINES -DUNIX -DDINGUX -DDISABLE_DOSBOX_OPL -DREDUCE_MEMORY_USAGE" DEFINES="$DEFINES -DUNIX -DDINGUX -DDISABLE_DOSBOX_OPL -DREDUCE_MEMORY_USAGE"
ASFLAGS="$ASFLAGS" ASFLAGS="$ASFLAGS"
CXXFLAGS="$CXXFLAGS -msoft-float -mips32" CXXFLAGS="$CXXFLAGS -msoft-float -mips32"
_need_memalign=yes
_backend="dingux" _backend="dingux"
_mt32emu=no _mt32emu=no
_vkeybd=yes _vkeybd=yes
@ -1810,7 +1804,6 @@ if test -n "$_host"; then
dreamcast) dreamcast)
DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE" DEFINES="$DEFINES -DDISABLE_DEFAULT_SAVEFILEMANAGER -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE"
CXXFLAGS="$CXXFLAGS -O3 -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks" CXXFLAGS="$CXXFLAGS -O3 -funroll-loops -fschedule-insns2 -fomit-frame-pointer -fdelete-null-pointer-checks"
_need_memalign=yes
_backend="dc" _backend="dc"
_build_scalers=no _build_scalers=no
_mad=yes _mad=yes
@ -1825,7 +1818,6 @@ if test -n "$_host"; then
DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE -DSTREAM_AUDIO_FROM_DISK" DEFINES="$DEFINES -DREDUCE_MEMORY_USAGE -DSTREAM_AUDIO_FROM_DISK"
DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU" DEFINES="$DEFINES -DDISABLE_DOSBOX_OPL -DDISABLE_SID -DDISABLE_NES_APU"
DEFINES="$DEFINES -DDISABLE_COMMAND_LINE" DEFINES="$DEFINES -DDISABLE_COMMAND_LINE"
_need_memalign=yes
add_line_to_config_h '#define DISABLE_TEXT_CONSOLE' add_line_to_config_h '#define DISABLE_TEXT_CONSOLE'
_backend="ds" _backend="ds"
_build_scalers=no _build_scalers=no
@ -1833,7 +1825,6 @@ if test -n "$_host"; then
_port_mk="backends/platform/ds/ds.mk" _port_mk="backends/platform/ds/ds.mk"
;; ;;
gamecube) gamecube)
_need_memalign=yes
_backend="wii" _backend="wii"
_build_scalers=no _build_scalers=no
_mt32emu=no _mt32emu=no
@ -1857,7 +1848,6 @@ if test -n "$_host"; then
ASFLAGS="$ASFLAGS -mfloat-abi=soft" ASFLAGS="$ASFLAGS -mfloat-abi=soft"
LDFLAGS="$LDFLAGS -static" LDFLAGS="$LDFLAGS -static"
_unix=yes _unix=yes
_need_memalign=yes
_backend="gph" _backend="gph"
_build_hq_scalers=no _build_hq_scalers=no
_vkeybd=yes _vkeybd=yes
@ -1876,7 +1866,6 @@ if test -n "$_host"; then
CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s" CXXFLAGS="$CXXFLAGS -mcpu=arm926ej-s -mtune=arm926ej-s"
ASFLAGS="$ASFLAGS -mfloat-abi=soft" ASFLAGS="$ASFLAGS -mfloat-abi=soft"
_unix=yes _unix=yes
_need_memalign=yes
_backend="gph" _backend="gph"
_build_hq_scalers=no _build_hq_scalers=no
_vkeybd=yes _vkeybd=yes
@ -1888,7 +1877,6 @@ if test -n "$_host"; then
iphone) iphone)
DEFINES="$DEFINES -DIPHONE" DEFINES="$DEFINES -DIPHONE"
_unix=yes _unix=yes
_need_memalign=yes
_backend="iphone" _backend="iphone"
_build_hq_scalers=no _build_hq_scalers=no
_seq_midi=no _seq_midi=no
@ -1896,7 +1884,6 @@ if test -n "$_host"; then
m68k-atari-mint) m68k-atari-mint)
DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE" DEFINES="$DEFINES -DSYSTEM_NOT_SUPPORTING_D_TYPE"
_unix=yes _unix=yes
_need_memalign=yes
_ranlib=m68k-atari-mint-ranlib _ranlib=m68k-atari-mint-ranlib
_ar="m68k-atari-mint-ar cru" _ar="m68k-atari-mint-ar cru"
_seq_midi=no _seq_midi=no
@ -1910,13 +1897,11 @@ if test -n "$_host"; then
mips-sgi*) mips-sgi*)
LDFLAGS="$LDFLAGS -static-libgcc" LDFLAGS="$LDFLAGS -static-libgcc"
LIBS="$LIBS -laudio" LIBS="$LIBS -laudio"
_need_memalign=yes
;; ;;
motoezx) motoezx)
DEFINES="$DEFINES -DMOTOEZX" DEFINES="$DEFINES -DMOTOEZX"
ASFLAGS="$ASFLAGS -mfpu=vfp" ASFLAGS="$ASFLAGS -mfpu=vfp"
_unix=yes _unix=yes
_need_memalign=yes
_backend="linuxmoto" _backend="linuxmoto"
_build_hq_scalers=no _build_hq_scalers=no
_mt32emu=no _mt32emu=no
@ -1928,7 +1913,6 @@ if test -n "$_host"; then
DEFINES="$DEFINES -DMOTOMAGX" DEFINES="$DEFINES -DMOTOMAGX"
ASFLAGS="$ASFLAGS -mfpu=vfp" ASFLAGS="$ASFLAGS -mfpu=vfp"
_unix=yes _unix=yes
_need_memalign=yes
_backend="linuxmoto" _backend="linuxmoto"
_build_hq_scalers=no _build_hq_scalers=no
_mt32emu=no _mt32emu=no
@ -1943,7 +1927,6 @@ if test -n "$_host"; then
LDFLAGS="$LDFLAGS -L$N64SDK/hkz-libn64 -L$N64SDK/lib" LDFLAGS="$LDFLAGS -L$N64SDK/hkz-libn64 -L$N64SDK/lib"
LDFLAGS="$LDFLAGS -T n64ld_cpp.x -Xlinker -Map -Xlinker scummvm.map" LDFLAGS="$LDFLAGS -T n64ld_cpp.x -Xlinker -Map -Xlinker scummvm.map"
_backend="n64" _backend="n64"
_need_memalign=yes
_mt32emu=no _mt32emu=no
_build_scalers=no _build_scalers=no
_indeo3=no _indeo3=no
@ -1962,7 +1945,6 @@ if test -n "$_host"; then
neuros) neuros)
DEFINES="$DEFINES -DNEUROS" DEFINES="$DEFINES -DNEUROS"
_unix=yes _unix=yes
_need_memalign=yes
_backend='null' _backend='null'
_build_hq_scalers=no _build_hq_scalers=no
_mt32emu=no _mt32emu=no
@ -1978,7 +1960,6 @@ if test -n "$_host"; then
CXXFLAGS="$CXXFLAGS -march=armv7-a -mtune=cortex-a8 -mfpu=neon" CXXFLAGS="$CXXFLAGS -march=armv7-a -mtune=cortex-a8 -mfpu=neon"
ASFLAGS="$ASFLAGS -mfloat-abi=soft" ASFLAGS="$ASFLAGS -mfloat-abi=soft"
_unix=yes _unix=yes
_need_memalign=yes
_backend="openpandora" _backend="openpandora"
_build_hq_scalers=yes _build_hq_scalers=yes
_vkeybd=no _vkeybd=no
@ -1987,14 +1968,11 @@ if test -n "$_host"; then
_port_mk="backends/platform/openpandora/op-bundle.mk" _port_mk="backends/platform/openpandora/op-bundle.mk"
;; ;;
ppc-amigaos) ppc-amigaos)
# AmigaOS exec allocates memory always in an aligned way
_need_memalign=yes
;; ;;
ps2) ps2)
# TODO: complete this # TODO: complete this
DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL" DEFINES="$DEFINES -DDISABLE_TEXT_CONSOLE -DDISABLE_COMMAND_LINE -DDISABLE_DOSBOX_OPL"
DEFINES="$DEFINES -DDISABLE_SID -DDISABLE_NES_APU" DEFINES="$DEFINES -DDISABLE_SID -DDISABLE_NES_APU"
_need_memalign=yes
_backend="ps2" _backend="ps2"
_build_scalers=no _build_scalers=no
_mt32emu=no _mt32emu=no
@ -2021,7 +1999,6 @@ if test -n "$_host"; then
fi fi
;; ;;
psp) psp)
_need_memalign=yes
_backend="psp" _backend="psp"
_build_scalers=no _build_scalers=no
_mt32emu=no _mt32emu=no
@ -2032,14 +2009,12 @@ if test -n "$_host"; then
ASFLAGS="$ASFLAGS -mfpu=vfp" ASFLAGS="$ASFLAGS -mfpu=vfp"
HOSTEXEEXT=".so" HOSTEXEEXT=".so"
_unix=yes _unix=yes
_need_memalign=yes
_backend="samsungtv" _backend="samsungtv"
_mt32emu=no _mt32emu=no
_vkeybd=yes _vkeybd=yes
;; ;;
webos) webos)
_unix=yes _unix=yes
_need_memalign=yes
_backend="webos" _backend="webos"
_port_mk="backends/platform/webos/webos.mk" _port_mk="backends/platform/webos/webos.mk"
_build_scalers=no _build_scalers=no
@ -2050,7 +2025,6 @@ if test -n "$_host"; then
_keymapper=yes _keymapper=yes
;; ;;
wii) wii)
_need_memalign=yes
_backend="wii" _backend="wii"
_build_scalers=no _build_scalers=no
_port_mk="backends/platform/wii/wii.mk" _port_mk="backends/platform/wii/wii.mk"
@ -2065,7 +2039,6 @@ if test -n "$_host"; then
;; ;;
wince) wince)
LDFLAGS="$LDFLAGS -Wl,--stack,65536" LDFLAGS="$LDFLAGS -Wl,--stack,65536"
_need_memalign=yes
_tremolo=yes _tremolo=yes
_backend="wince" _backend="wince"
_mt32emu=no _mt32emu=no
@ -2075,33 +2048,42 @@ if test -n "$_host"; then
echo "WARNING: Unknown target, continuing with auto-detected values" echo "WARNING: Unknown target, continuing with auto-detected values"
;; ;;
esac esac
fi
else #
# # Check whether memory alignment is required
# Check whether memory alignment is required #
# # For some CPU types, unaligned memory access is either not supported at
echo_n "Alignment required... " # all (and so leads to a crash), requires a super-slow emulation via an
case $_host_cpu in # exception handler, or just results in incorrect results.
alpha*) # On the other hand, accessing data in a manner that works regardless of
# Hardcode alignment requirements for Alpha processsors # alignment can be a lot slower than regular access, so we don't want
_need_memalign=yes # to use it if we don't have to.
;; #
arm*) # So we do the following: First, for CPU families where we know whether
_need_memalign=yes # unaligned access is safe & fast, we enable / disable unaligned access
;; # accordingly.
mips*) # Otherwise, for cross compiled builds we just disable memory alignment.
# Hardcode alignment requirements for MIPS processsors. # For native builds, we run some test code that detects whether unaligned
# While these can emulate unaligned memory access, this # access is supported (and is supported without an exception handler).
# emulation is rather slow. #
_need_memalign=yes # NOTE: The only kinds of unaligned access we allow are for 2 byte and
;; # 4 byte loads / stores. No promises are made for bigger sizes, such as
sh*) # 8 or 16 byte loads, for which various architectures (e.g. x86 and PowerPC)
# Hardcode alignment requirements for SH processsors. # behave differently than for the smaller sizes).
# While these can emulate unaligned memory access, this echo_n "Alignment required... "
# emulation is rather slow. case $_host_cpu in
_need_memalign=yes alpha* | arm* | bfin* | hp* | mips* | sh* | sparc* | ia64 | nv1*)
;; # Unaligned access is not supported or extremely slow.
*) _need_memalign=yes
;;
i[3-6]86 | x86_64 | ppc*)
# Unaligned access should work reasonably well
_need_memalign=no
;;
*)
if test -z "$_host"; then
# NOT in cross-compiling mode:
# Try to auto-detect.... # Try to auto-detect....
cat > $TMPC << EOF cat > $TMPC << EOF
#include <stdlib.h> #include <stdlib.h>
@ -2117,13 +2099,14 @@ int main(int argc, char **argv) {
return 0; return 0;
} }
EOF EOF
_need_memalign=yes
cc_check_no_clean && $TMPO$HOSTEXEEXT && _need_memalign=no cc_check_no_clean && $TMPO$HOSTEXEEXT && _need_memalign=no
cc_check_clean cc_check_clean
;; fi
esac ;;
echo "$_need_memalign" esac
fi echo "$_need_memalign"
define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT'
# #
# Backend related stuff # Backend related stuff
@ -2292,9 +2275,6 @@ case $_endian in
;; ;;
esac esac
define_in_config_h_if_yes $_need_memalign 'SCUMM_NEED_ALIGNMENT'
if test "$_unix" = yes ; then if test "$_unix" = yes ; then
DEFINES="$DEFINES -DUNIX" DEFINES="$DEFINES -DUNIX"
add_line_to_config_mk 'UNIX = 1' add_line_to_config_mk 'UNIX = 1'