mirror of
https://github.com/ksherlock/mpw.git
synced 2024-11-22 00:32:44 +00:00
endian updates.
This commit is contained in:
parent
70c74d4bc9
commit
728de4ddaa
@ -53,7 +53,7 @@ CHECK_TYPE_SIZE("((struct stat *)0)->st_birthtime" STAT_ST_BIRTHTIME)
|
||||
SET(CMAKE_EXTRA_INCLUDE_FILES)
|
||||
|
||||
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_CURRENT_BINARY_DIR}/config.h)
|
||||
CONFIGURE_FILE(${CMAKE_CURRENT_SOURCE_DIR}/config.h.in ${CMAKE_BINARY_DIR}/config.h)
|
||||
|
||||
|
||||
add_subdirectory(bin)
|
||||
|
@ -3,6 +3,8 @@
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#if defined(HAVE_ENDIAN_H)
|
||||
#include <endian.h>
|
||||
#elif defined(HAVE_SYS_ENDIAN_H)
|
||||
@ -13,5 +15,43 @@
|
||||
#error missing endian.h
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
|
||||
#define bswap16 __builtin_bswap16
|
||||
#define bswap32 __builtin_bswap32
|
||||
#define bswap64 __builtin_bswap64
|
||||
|
||||
#if _BYTE_ORDER == _LITTLE_ENDIAN
|
||||
#define htobe16(x) bswap16((x))
|
||||
#define htobe32(x) bswap32((x))
|
||||
#define htobe64(x) bswap64((x))
|
||||
#define htole16(x) ((uint16_t)(x))
|
||||
#define htole32(x) ((uint32_t)(x))
|
||||
#define htole64(x) ((uint64_t)(x))
|
||||
|
||||
#define be16toh(x) bswap16((x))
|
||||
#define be32toh(x) bswap32((x))
|
||||
#define be64toh(x) bswap64((x))
|
||||
#define le16toh(x) ((uint16_t)(x))
|
||||
#define le32toh(x) ((uint32_t)(x))
|
||||
#define le64toh(x) ((uint64_t)(x))
|
||||
#else /* _BYTE_ORDER != _LITTLE_ENDIAN */
|
||||
#define htobe16(x) ((uint16_t)(x))
|
||||
#define htobe32(x) ((uint32_t)(x))
|
||||
#define htobe64(x) ((uint64_t)(x))
|
||||
#define htole16(x) bswap16((x))
|
||||
#define htole32(x) bswap32((x))
|
||||
#define htole64(x) bswap64((x))
|
||||
|
||||
#define be16toh(x) ((uint16_t)(x))
|
||||
#define be32toh(x) ((uint32_t)(x))
|
||||
#define be64toh(x) ((uint64_t)(x))
|
||||
#define le16toh(x) bswap16((x))
|
||||
#define le32toh(x) bswap32((x))
|
||||
#define le64toh(x) bswap64((x))
|
||||
#endif /* _BYTE_ORDER == _LITTLE_ENDIAN */
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
|
@ -32,8 +32,8 @@
|
||||
#include <unistd.h>
|
||||
#include <fcntl.h>
|
||||
|
||||
#include "config.h"
|
||||
|
||||
#include "config.h"
|
||||
#include <include/endian.h>
|
||||
|
||||
//using MacOS::macos_error_from_errno;
|
||||
//using MacOS::macos_error;
|
||||
@ -146,10 +146,7 @@ namespace native {
|
||||
int rv2 = ::getxattr(path_name.c_str(), "prodos.AuxType", &atype, 2, 0, 0);
|
||||
|
||||
if (rv1 == 1 && rv2 == 2) {
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
ftype = (ftype >> 8) | (ftype << 8);
|
||||
#endif
|
||||
|
||||
ftype = le16toh(ftype);
|
||||
|
||||
|
||||
memcpy(buffer, "pxxxpdos", 8);
|
||||
|
@ -55,6 +55,7 @@
|
||||
#include <macos/traps.h>
|
||||
|
||||
#include <config.h>
|
||||
#include <include/endian.h>
|
||||
|
||||
// yuck. TST.W d0
|
||||
extern "C" void cpuSetFlagsNZ00NewW(UWO res);
|
||||
@ -101,20 +102,6 @@ namespace {
|
||||
return trap & 0x0600;
|
||||
}
|
||||
|
||||
#if BYTE_ORDER == LITTLE_ENDIAN
|
||||
inline constexpr uint16_t host_to_big_endian_16(uint16_t x)
|
||||
{
|
||||
return (x << 8) | (x >> 8); // __builtin_bswap16(x);
|
||||
}
|
||||
#endif
|
||||
|
||||
#if BYTE_ORDER == BIG_ENDIAN
|
||||
inline constexpr uint16_t host_to_big_endian_16(uint16_t x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
namespace OS {
|
||||
@ -359,13 +346,13 @@ namespace ToolBox {
|
||||
uint16_t *code = (uint16_t *)memoryPointer(ToolGlue);
|
||||
|
||||
for (unsigned i = 0; i < 1024; ++i) {
|
||||
*code++ = host_to_big_endian_16(0xafff);
|
||||
*code++ = host_to_big_endian_16(0xa800 | i);
|
||||
*code++ = htobe16(0xafff);
|
||||
*code++ = htobe16(0xa800 | i);
|
||||
}
|
||||
|
||||
for (unsigned i = 0; i < 256; ++i) {
|
||||
*code++ = host_to_big_endian_16(0xafff);
|
||||
*code++ = host_to_big_endian_16(0xa000 | i);
|
||||
*code++ = htobe16(0xafff);
|
||||
*code++ = htobe16(0xa000 | i);
|
||||
}
|
||||
|
||||
// os return code... pull registers, TST.W d0, etc.
|
||||
|
@ -1,7 +1,7 @@
|
||||
#include "fpinfo.h"
|
||||
|
||||
#include <config.h>
|
||||
|
||||
#include <include/endian.h>
|
||||
|
||||
static_assert(sizeof(float) == 4, "Unexpected float size");
|
||||
static_assert(sizeof(double) == 8, "Unexpected double size");
|
||||
|
Loading…
Reference in New Issue
Block a user