forked from len0rd/rockbox
quake: fix errorneous endian-correcting reads
ef9ee89
introduced Read{Big,Little}{Short,Long,Float} functions to safely
read a value in memory. These incorrectly take char*, which causes them to
output erroneous 0xff bytes when given bytes with bit 7 set.
Change-Id: I9531172301aecfdacae405d2f782f662608ce6df
This commit is contained in:
parent
7bef453e03
commit
7e4902bf6b
3 changed files with 23 additions and 19 deletions
|
@ -96,21 +96,21 @@ extern int (*LittleLong) (int l);
|
|||
extern float (*BigFloat) (float l);
|
||||
extern float (*LittleFloat) (float l);
|
||||
|
||||
#define LittleShortUnaligned(x) ReadLittleShort(((char*)(&(x))))
|
||||
#define BigShortUnaligned(x) ReadBigShort(((char*)&(x)))
|
||||
#define LittleLongUnaligned(x) ReadLittleLong(((char*)&(x)))
|
||||
#define BigLongUnaligned(x) ReadBigLong(((char*)&(x)))
|
||||
#define LittleFloatUnaligned(x) ReadLittleFloat(((char*)&(x)))
|
||||
#define BigFloatUnaligned(x) ReadBigFloat(((char*)&(x))
|
||||
#define LittleShortUnaligned(x) ReadLittleShort(((unsigned char*)(&(x))))
|
||||
#define BigShortUnaligned(x) ReadBigShort(((unsigned char*)&(x)))
|
||||
#define LittleLongUnaligned(x) ReadLittleLong(((unsigned char*)&(x)))
|
||||
#define BigLongUnaligned(x) ReadBigLong(((unsigned char*)&(x)))
|
||||
#define LittleFloatUnaligned(x) ReadLittleFloat(((unsigned char*)&(x)))
|
||||
#define BigFloatUnaligned(x) ReadBigFloat(((unsigned char*)&(x))
|
||||
|
||||
|
||||
// for unaligned
|
||||
short ReadBigShort (char *l);
|
||||
short ReadLittleShort (char *l);
|
||||
int ReadBigLong (char *l);
|
||||
int ReadLittleLong (char *l);
|
||||
float ReadBigFloat (char *l);
|
||||
float ReadLittleFloat (char *l);
|
||||
short ReadBigShort (unsigned char *l);
|
||||
short ReadLittleShort (unsigned char *l);
|
||||
int ReadBigLong (unsigned char *l);
|
||||
int ReadLittleLong (unsigned char *l);
|
||||
float ReadBigFloat (unsigned char *l);
|
||||
float ReadLittleFloat (unsigned char *l);
|
||||
|
||||
//============================================================================
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue