1
0
Fork 0
dosbox-staging/include
krcroft 902c678081 Make host-mem functions endian-safe and alignment-safe
The host_read*, and host_write* functions currently rely on
casting unaligned memory to translate from byte arrays into
higher-level types (like 16and 32bit ints), however this
approach is implementation specific, can cause undefined
behavior, and forces the compiler to use less efficient
aliasing rules.

Unaligned memory casts have historically been corrected by
expanding multi-byte types into their constituents bytes,
shifting them, and re-packing. They've also been solved using
union objects to access the same underlying memory for each
member (legal under C, but not C++). However, we use memcpy
which is compact, readable, universally compatible, and
compiles down efficient inline single-instructions; therefore
imparting no penalty.

This commit adds host_add* functions (for 16 and 32bit values)
that add a host-formatted value to the implied value at a
memory address.

This commit adds handling for quad-words as well: host_readq,
host_writeq, which we use in the cache, which otherwise suffers
from the same alignment issues.
2020-04-15 14:26:28 +02:00
..
.gitignore Import svn:ignore props to .gitignore files 2019-09-15 20:34:57 +02:00
bios.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
bios_disk.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
byteorder.h Create byteorder header for host_to_le functions 2020-04-15 00:01:25 +02:00
callback.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
compiler.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
control.h Change Config::PrintConfig to use std::string 2020-04-04 04:20:28 +02:00
cpu.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
cross.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
debug.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
dma.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
dos_inc.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
dos_system.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
dosbox.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
drives.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
fpu.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
hardware.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
inout.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
ipx.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
ipxserver.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
joystick.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
keyboard.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
logging.h Add DEBUG_LOG_MSG macro 2020-04-10 09:57:29 +02:00
Makefile.am Create byteorder header for host_to_le functions 2020-04-15 00:01:25 +02:00
mapper.h Add AUTOTYPE to DOSBox's programs 2020-04-04 04:10:06 +02:00
mem.h Make host-mem functions endian-safe and alignment-safe 2020-04-15 14:26:28 +02:00
midi.h Cleanup MIDI/ALSA-related logs 2020-03-27 00:54:11 +01:00
mixer.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
mouse.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
paging.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
pci_bus.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
pic.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
programs.h Inject newlines before displaying DOS prompt 2020-03-12 20:54:33 +01:00
regs.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
render.h Change bpp to unsigned int around render code 2020-03-28 05:41:04 +01:00
serialport.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
setup.h Prevent empty property names 2020-03-27 00:54:11 +01:00
shell.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
support.h Implement iround helper function 2020-04-14 06:28:08 +02:00
timer.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
types.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
vga.h Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
video.h Cleanup and document GFX_StartUpdate function 2020-03-27 00:54:11 +01:00