mirror of
https://github.com/mkxp-z/mkxp-z.git
synced 2025-03-28 14:56:22 +01:00
Merge pull request #236 from white-axe/endian
Some checks failed
Automatic Build / Ubuntu 22.04 x86_64 (push) Failing after 40s
Automatic Build / Ubuntu 22.04 armv7 (push) Failing after 34s
Automatic Build / Ubuntu 22.04 arm64 (push) Failing after 39s
Automatic Build / Ubuntu 22.04 armv6 (push) Failing after 37s
Automatic Build / Ubuntu 22.04 armv7-neon (push) Failing after 3s
Automatic Build / Ubuntu 22.04 power8le (push) Failing after 3s
Automatic Build / Ubuntu 22.04 power9le (push) Failing after 3s
Automatic Build / Ubuntu 22.04 riscv64 (push) Failing after 3s
Automatic Build / Ubuntu 22.04 s390x (push) Failing after 3s
Automatic Build / Windows (push) Has been cancelled
Automatic Build / macOS (push) Has been cancelled
Some checks failed
Automatic Build / Ubuntu 22.04 x86_64 (push) Failing after 40s
Automatic Build / Ubuntu 22.04 armv7 (push) Failing after 34s
Automatic Build / Ubuntu 22.04 arm64 (push) Failing after 39s
Automatic Build / Ubuntu 22.04 armv6 (push) Failing after 37s
Automatic Build / Ubuntu 22.04 armv7-neon (push) Failing after 3s
Automatic Build / Ubuntu 22.04 power8le (push) Failing after 3s
Automatic Build / Ubuntu 22.04 power9le (push) Failing after 3s
Automatic Build / Ubuntu 22.04 riscv64 (push) Failing after 3s
Automatic Build / Ubuntu 22.04 s390x (push) Failing after 3s
Automatic Build / Windows (push) Has been cancelled
Automatic Build / macOS (push) Has been cancelled
Implement serialization for big-endian platforms
This commit is contained in:
commit
68a344afcf
2 changed files with 61 additions and 34 deletions
45
.github/workflows/autobuild.yml
vendored
45
.github/workflows/autobuild.yml
vendored
|
@ -22,7 +22,6 @@ jobs:
|
|||
- uses: msys2/setup-msys2@v2
|
||||
with:
|
||||
msystem: mingw64
|
||||
# zip is just used for artifact compression at the end.
|
||||
install: >-
|
||||
base-devel
|
||||
git
|
||||
|
@ -32,13 +31,11 @@ jobs:
|
|||
mingw-w64-x86_64-meson
|
||||
mingw-w64-x86_64-autotools
|
||||
mingw-w64-x86_64-gcc
|
||||
zip
|
||||
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
windows/build-mingw64
|
||||
|
@ -73,16 +70,11 @@ jobs:
|
|||
cp ../../mkxp.json .
|
||||
cp -r ../../scripts .
|
||||
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
|
||||
cd ..
|
||||
# Zipping before uploading decreases the upload time considerably.
|
||||
# Unfortunately this results in double-zipping; tracked at:
|
||||
# https://github.com/actions/upload-artifact/issues/426
|
||||
zip -r artifact.zip artifact
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkxp-z.windows.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
|
||||
path: build/artifact.zip
|
||||
path: build/artifact
|
||||
|
||||
build-linux-native:
|
||||
name: Ubuntu 22.04 x86_64
|
||||
|
@ -94,9 +86,9 @@ jobs:
|
|||
length: 7
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
linux/build-x86_64
|
||||
|
@ -129,16 +121,11 @@ jobs:
|
|||
cp ../../mkxp.json .
|
||||
cp -r ../../scripts .
|
||||
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
|
||||
cd ..
|
||||
# Zipping before uploading preserves +x permissions.
|
||||
# Unfortunately this results in double-zipping; tracked at:
|
||||
# https://github.com/actions/upload-artifact/issues/426
|
||||
zip -r local.zip local
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkxp-z.linux.x86_64.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
|
||||
path: build/local.zip
|
||||
path: build/local
|
||||
|
||||
build-linux-cross:
|
||||
name: Ubuntu 22.04 ${{matrix.arch_mkxpz}}
|
||||
|
@ -190,9 +177,9 @@ jobs:
|
|||
length: 7
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
linux/build-${{matrix.arch_mkxpz}}
|
||||
|
@ -240,13 +227,11 @@ jobs:
|
|||
cp ../../mkxp.json .
|
||||
cp -r ../../scripts .
|
||||
cp ../../assets/LICENSE.mkxp-z-with-https.txt .
|
||||
cd ..
|
||||
zip -r local.zip local
|
||||
|
||||
- uses: actions/upload-artifact@v3
|
||||
- uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkxp-z.linux.${{matrix.arch_mkxpz}}.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
|
||||
path: build/local.zip
|
||||
path: build/local
|
||||
|
||||
build-macos:
|
||||
name: macOS
|
||||
|
@ -261,9 +246,9 @@ jobs:
|
|||
run: brew remove --force $(brew list)
|
||||
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- uses: actions/cache@v3
|
||||
- uses: actions/cache@v4
|
||||
with:
|
||||
path: |
|
||||
macos/Dependencies/build-macosx-x86_64
|
||||
|
@ -294,7 +279,7 @@ jobs:
|
|||
ditto -c -k --sequesterRsrc --keepParent Z-universal.app Z-universal.app.zip
|
||||
|
||||
- name: Upload archive
|
||||
uses: actions/upload-artifact@v3
|
||||
uses: actions/upload-artifact@v4
|
||||
with:
|
||||
name: mkxp-z.macos.${{github.event_name == 'pull_request' && format('PR{0}', github.event.number) || github.ref_name}}-${{steps.short-sha.outputs.sha}}
|
||||
path: build/Build/Products/Release/Z-universal.app.zip
|
||||
|
|
|
@ -23,14 +23,11 @@
|
|||
#define SERIALUTIL_H
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include <SDL_endian.h>
|
||||
|
||||
#if SDL_BYTEORDER != SDL_LIL_ENDIAN
|
||||
#error "Non little endian systems not supported"
|
||||
#endif
|
||||
|
||||
static inline int32_t
|
||||
readInt32(const char **dataP)
|
||||
{
|
||||
|
@ -39,23 +36,56 @@ readInt32(const char **dataP)
|
|||
memcpy(&result, *dataP, 4);
|
||||
*dataP += 4;
|
||||
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
# ifdef _MSC_VER
|
||||
static_assert(sizeof(unsigned long) == sizeof(int32_t), "unsigned long should be 32 bits");
|
||||
result = (int32_t)_byteswap_ulong((unsigned long)result);
|
||||
# else
|
||||
result = (int32_t)__builtin_bswap32((uint32_t)result);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static inline double
|
||||
readDouble(const char **dataP)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
uint64_t result;
|
||||
|
||||
memcpy(&result, *dataP, 8);
|
||||
*dataP += 8;
|
||||
|
||||
# ifdef _MSC_VER
|
||||
result = (uint64_t)_byteswap_uint64((unsigned __int64)result);
|
||||
# else
|
||||
result = __builtin_bswap64(result);
|
||||
# endif
|
||||
|
||||
return *(double *)&result;
|
||||
#else
|
||||
double result;
|
||||
|
||||
memcpy(&result, *dataP, 8);
|
||||
*dataP += 8;
|
||||
|
||||
return result;
|
||||
#endif
|
||||
}
|
||||
|
||||
static inline void
|
||||
writeInt32(char **dataP, int32_t value)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
# ifdef _MSC_VER
|
||||
static_assert(sizeof(unsigned long) == sizeof(int32_t), "unsigned long should be 32 bits");
|
||||
value = (int32_t)_byteswap_ulong((unsigned long)value);
|
||||
# else
|
||||
value = (int32_t)__builtin_bswap32((uint32_t)value);
|
||||
# endif
|
||||
#endif
|
||||
|
||||
memcpy(*dataP, &value, 4);
|
||||
*dataP += 4;
|
||||
}
|
||||
|
@ -63,7 +93,19 @@ writeInt32(char **dataP, int32_t value)
|
|||
static inline void
|
||||
writeDouble(char **dataP, double value)
|
||||
{
|
||||
#if SDL_BYTEORDER == SDL_BIG_ENDIAN
|
||||
uint64_t valueUint = *(uint64_t *)&value;
|
||||
|
||||
# ifdef _MSC_VER
|
||||
valueUint = (uint64_t)_byteswap_uint64((unsigned __int64)valueUint);
|
||||
# else
|
||||
valueUint = __builtin_bswap64(valueUint);
|
||||
# endif
|
||||
|
||||
memcpy(*dataP, &valueUint, 8);
|
||||
#else
|
||||
memcpy(*dataP, &value, 8);
|
||||
#endif
|
||||
*dataP += 8;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue