1
0
Fork 0
Commit graph

53 commits

Author SHA1 Message Date
krcroft
8d33524e25 Ignore re-assignment warnings in PVS-Studio 2020-04-15 14:26:29 +02:00
krcroft
54d805bd5c Simplify assignments with type-sized host reads 2020-04-15 14:26:29 +02:00
krcroft
7375db2a83 Use type-specific host conversion funcs 2020-04-15 14:26:29 +02:00
krcroft
f5f0449f17 Add host read-and-write funcs with index support 2020-04-15 14:26:29 +02:00
krcroft
090e039e29 Eliminate old host_to_le functions 2020-04-15 14:26:29 +02:00
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
Patryk Obara
c05bbafb5d Create byteorder header for host_to_le functions 2020-04-15 00:01:25 +02:00
Joshua Fern
f2029d71d8 Update copyright dates to 2020 2020-03-07 00:18:01 +01:00
Patryk Obara
c619445003 Avoid buffer underflow by copying all fields
This code made silent assumption that first fields in direntry are
exactly 14 bytes - this was fine, except would break as soon as anyone
would touch the struct (or e.g. if a compiler would lack support for
packed structures and inject some padding in there); rewrite the copy
code to follow the same pattern as other fields - now the code will be
fine even if someone will change fields in the direntry struct.

Fixes 2 PVS static analysis issues (buffer underflow on src and dst).
2020-02-23 01:13:11 +01:00
Patryk Obara
bdf67cdbcc Merge branch 'svn/trunk' r4330 2020-02-22 21:10:57 +01:00
Peter Veenstra
57bf045cc8 some big endian improvents and drive_fat fixes. (jmarsh)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4330
2020-02-22 12:06:40 +00:00
Patryk Obara
77c4523723 Byteswap captured audio samples on PPC
Fixes: #161
2020-02-08 14:56:14 +01:00
Patryk Obara
4d674102d0 Prevent unaligned memory access in adlib
This removes the last warnings in this area; in this case changing endianess
is not used for accessing emulated memory, just to flip few values to
low endian for storage.
2020-01-09 22:50:47 +01:00
krcroft
c9198b2944 Fix unsafe memory operations and warnings in the fatDrive class
- Move imageDiskList from pointer to vector of unique_ptr
- Replace string operations with size-limited versions
- Initialize members
- Eliminate unecessary casts
- Eliminate memory-leak on pointer assignment
2019-12-09 08:19:26 +01:00
Peter Veenstra
1fbaff47fc Update year and address of FSF
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4183
2019-01-25 14:09:58 +00:00
Peter Veenstra
5bb10db88b Time keeps on ticking
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4109
2018-05-29 12:58:58 +00:00
Peter Veenstra
6cf39c1fc6 Years update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@4021
2017-05-30 11:35:08 +00:00
Peter Veenstra
0f4c92ca32 Year update.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3878
2015-01-06 14:40:32 +00:00
Peter Veenstra
2fea508f7f Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3812
2013-01-15 09:03:13 +00:00
Peter Veenstra
999f33de27 Update year. Remove CVS tags
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3700
2011-04-26 09:34:55 +00:00
Peter Veenstra
a78b2c4f8b Update year
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3548
2010-02-11 13:36:50 +00:00
Peter Veenstra
16d14b78e1 Some year and version numbers
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3410
2009-05-27 09:15:42 +00:00
Peter Veenstra
c4d033cc79 Fix accidential mix up
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3378
2009-04-30 12:36:55 +00:00
Sjoerd van der Berg
88caf1dc71 Add compiler testing for always_inline attribute
Add compiler testing for fastcall attribute
Add the FASTCALL define to visual c
Remove some overkill inline routines
Make sure that all the inline routines in headers are static


Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3355
2009-04-25 16:25:03 +00:00
Peter Veenstra
e08ea925b7 pedantic warnings.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@3209
2008-08-24 16:43:06 +00:00
Peter Veenstra
a5ac3216ba Some more const stuff. Silences a few warnings and removes a few casts. Update description of dss.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2886
2007-06-14 08:23:46 +00:00
Peter Veenstra
779ab9f715 Add beta2 patch: Some hack to make SKYRICA work. (allocate a zero xms page to get a pointer to xms memory area)
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2736
2007-01-08 21:40:15 +00:00
Peter Veenstra
fdd16dea1a Happy New Year\!
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2728
2007-01-08 19:45:42 +00:00
Peter Veenstra
df67775306 time passes on and on....
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2480
2006-02-09 11:47:57 +00:00
Sebastian Strohhäcker
a708a1344f use RAM for PCJr graphics memory
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2409
2005-12-05 21:25:56 +00:00
Peter Veenstra
b2b5bfeb7e fix compilation with gcc 3.4
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2142
2005-03-24 21:41:26 +00:00
Peter Veenstra
b42c189ac6 new include system and a new RealSetVec function that returns the old value of the vector
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2134
2005-03-24 10:05:57 +00:00
Sjoerd van der Berg
4594c5a600 Add test for systems not support unaligned memory access. Rename the WLE functions to var_write
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2133
2005-03-24 09:20:47 +00:00
Peter Veenstra
2094d8b985 Year update
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@2106
2005-02-10 10:21:12 +00:00
Sjoerd van der Berg
f7a6317328 New memory handling using 1 big block of memory
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1920
2004-08-23 12:19:17 +00:00
Peter Veenstra
ca409fd57c Typo in preamble
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1899
2004-08-04 09:12:57 +00:00
Peter Veenstra
fcbd0fe854 Copyright to 2004
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1552
2004-01-10 14:03:36 +00:00
Sjoerd van der Berg
e23e7206e5 removed the physical page read function
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1445
2003-11-18 22:17:25 +00:00
Sjoerd van der Berg
f634f27924 Changes for new paging/memory functions
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1353
2003-10-22 14:25:52 +00:00
Ulf Wohlers
2daf8b32c7 Added MEM_AllocatedPages. Get amount of allocated pages of handle
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1148
2003-07-24 19:13:58 +00:00
Sjoerd van der Berg
7c02953cfc New direct mapping support
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1134
2003-07-14 12:43:51 +00:00
Sjoerd van der Berg
695d8e91d4 New headers and changes for new paging support.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1112
2003-07-14 08:16:04 +00:00
Sjoerd van der Berg
d5231d4351 Fix for Big Endian writing of variables
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1076
2003-06-19 15:36:08 +00:00
Sjoerd van der Berg
34eb272f95 Changed memory limits
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1056
2003-06-14 11:42:45 +00:00
Sjoerd van der Berg
81e9ba2cdf Added some functions for acessing values in an endian safe way.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@1033
2003-06-02 21:08:31 +00:00
Sjoerd van der Berg
52243ceaa4 Added total memory size call
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@966
2003-04-27 07:07:30 +00:00
Sjoerd van der Berg
16904a20b3 A20 line enabling and status functions.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@913
2003-04-13 18:29:42 +00:00
Sjoerd van der Berg
6ae8549b9e Special inline memory read/write handlers
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@876
2003-04-06 11:07:19 +00:00
Sjoerd van der Berg
dccb4e4e73 Support reading/writing memory on bigendian machines.
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@610
2002-12-30 21:53:44 +00:00
Sjoerd van der Berg
b950a89a3b Change the PAGE_SIZE #define to be a bit safer
Imported-from: https://svn.code.sf.net/p/dosbox/code-0/dosbox/trunk@344
2002-10-18 09:20:24 +00:00