mirror of
https://git.wuffs.org/MWCC
synced 2025-12-12 06:45:17 +00:00
dump lots more code
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
#include "compiler/CompilerTools.h"
|
||||
#include "compiler/CInt64.h"
|
||||
#include "cos.h"
|
||||
|
||||
extern Boolean systemHandles;
|
||||
@@ -140,6 +141,7 @@ void AppendGListTargetEndianWord(GList *gl, SInt16 theword) {
|
||||
|
||||
ptr = *gl->data + gl->size;
|
||||
gl->size += 2;
|
||||
theword = CTool_EndianConvertWord16(theword);
|
||||
*(ptr++) = ((unsigned char *) &theword)[0];
|
||||
*(ptr++) = ((unsigned char *) &theword)[1];
|
||||
}
|
||||
@@ -170,6 +172,7 @@ void AppendGListTargetEndianLong(GList *gl, SInt32 theword) {
|
||||
|
||||
ptr = *gl->data + gl->size;
|
||||
gl->size += 4;
|
||||
theword = CTool_EndianConvertWord32(theword);
|
||||
*(ptr++) = ((unsigned char *) &theword)[0];
|
||||
*(ptr++) = ((unsigned char *) &theword)[1];
|
||||
*(ptr++) = ((unsigned char *) &theword)[2];
|
||||
@@ -1157,26 +1160,56 @@ short getbit(SInt32 l) {
|
||||
}
|
||||
}
|
||||
|
||||
#ifdef ENDIAN_CONVERSION
|
||||
UInt16 CTool_EndianConvertWord16(UInt16 theword) {
|
||||
UInt16 conv;
|
||||
((UInt8 *) &conv)[0] = ((UInt8 *) &theword)[1];
|
||||
((UInt8 *) &conv)[1] = ((UInt8 *) &theword)[0];
|
||||
return conv;
|
||||
}
|
||||
|
||||
UInt32 CTool_EndianConvertWord32(UInt32 theword) {
|
||||
UInt32 conv;
|
||||
((UInt8 *) &conv)[0] = ((UInt8 *) &theword)[3];
|
||||
((UInt8 *) &conv)[1] = ((UInt8 *) &theword)[2];
|
||||
((UInt8 *) &conv)[2] = ((UInt8 *) &theword)[1];
|
||||
((UInt8 *) &conv)[3] = ((UInt8 *) &theword)[0];
|
||||
return conv;
|
||||
}
|
||||
|
||||
void CTool_EndianConvertMem(UInt8 *data, short len) {
|
||||
UInt8 *a = data;
|
||||
UInt8 *b = data + len;
|
||||
while (--b > a) {
|
||||
UInt8 val = *b;
|
||||
*b = *a;
|
||||
*a++ = val;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
void CTool_EndianConvertWord64(CInt64 ci, char *result) {
|
||||
UInt32 buf[2];
|
||||
buf[0] = ci.hi;
|
||||
buf[1] = ci.lo;
|
||||
buf[0] = CTool_EndianConvertWord32(CTool_EndianReadWord32(&ci.hi));
|
||||
buf[1] = CTool_EndianConvertWord32(CInt64_GetULong(&ci));
|
||||
memcpy(result, buf, 8);
|
||||
}
|
||||
|
||||
#ifdef ENDIAN_CONVERSION
|
||||
UInt32 CTool_EndianReadWord32(void *ptr) {
|
||||
return *((UInt32 *) ptr);
|
||||
}
|
||||
#endif
|
||||
|
||||
UInt16 CTool_EndianConvertInPlaceWord16Ptr(UInt16 *x) {
|
||||
unsigned short v;
|
||||
v = *x;
|
||||
// this probably has a conversion on non-ppc
|
||||
*x = v;
|
||||
UInt16 v;
|
||||
*x = v = CTool_EndianConvertWord16(*x);
|
||||
return v;
|
||||
}
|
||||
|
||||
UInt32 CTool_EndianConvertInPlaceWord32Ptr(UInt32 *x) {
|
||||
unsigned long v;
|
||||
v = *x;
|
||||
// this probably has a conversion on non-ppc
|
||||
*x = v;
|
||||
UInt32 v;
|
||||
*x = v = CTool_EndianConvertWord32(*x);
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user