diff --git a/.github/workflows/sanity.yml b/.github/workflows/sanity.yml index f460931..ac37323 100644 --- a/.github/workflows/sanity.yml +++ b/.github/workflows/sanity.yml @@ -6,7 +6,7 @@ jobs: strategy: fail-fast: false matrix: - os: [macos-latest, ubuntu-latest, ubuntu-16.04] + os: [macos-latest, ubuntu-latest, ubuntu-18.04] cc: [gcc, clang] include: - os: macos-latest @@ -33,4 +33,4 @@ jobs: uses: actions/upload-artifact@v1 with: name: sameboy-canary-${{ matrix.os }}-${{ matrix.cc }} - path: build/bin \ No newline at end of file + path: build/bin diff --git a/Core/save_state.c b/Core/save_state.c index 14cc5db..04ed4af 100644 --- a/Core/save_state.c +++ b/Core/save_state.c @@ -9,6 +9,15 @@ #define BESS_NAME "SameBoy v" GB_VERSION #endif +_Static_assert((GB_SECTION_OFFSET(core_state) & 7) == 0, "Section core_state is not aligned"); +_Static_assert((GB_SECTION_OFFSET(dma) & 7) == 0, "Section dma is not aligned"); +_Static_assert((GB_SECTION_OFFSET(mbc) & 7) == 0, "Section mbc is not aligned"); +_Static_assert((GB_SECTION_OFFSET(hram) & 7) == 0, "Section hram is not aligned"); +_Static_assert((GB_SECTION_OFFSET(timing) & 7) == 0, "Section timing is not aligned"); +_Static_assert((GB_SECTION_OFFSET(apu) & 7) == 0, "Section apu is not aligned"); +_Static_assert((GB_SECTION_OFFSET(rtc) & 7) == 0, "Section rtc is not aligned"); +_Static_assert((GB_SECTION_OFFSET(video) & 7) == 0, "Section video is not aligned"); + typedef struct __attribute__((packed)) { uint32_t magic; uint32_t size; diff --git a/Core/save_state.h b/Core/save_state.h index 79e8c06..4572a72 100644 --- a/Core/save_state.h +++ b/Core/save_state.h @@ -10,7 +10,7 @@ as anonymous enums inside unions */ #define GB_SECTION(name, ...) __attribute__ ((aligned (8))) __VA_ARGS__ #else -#define GB_SECTION(name, ...) __attribute__ ((aligned (8))) union {uint8_t name##_section_start; struct {__VA_ARGS__};}; uint8_t name##_section_end[0] +#define GB_SECTION(name, ...) union __attribute__ ((aligned (8))) {uint8_t name##_section_start; struct {__VA_ARGS__};}; uint8_t name##_section_end[0] #define GB_SECTION_OFFSET(name) (offsetof(GB_gameboy_t, name##_section_start)) #define GB_SECTION_SIZE(name) (offsetof(GB_gameboy_t, name##_section_end) - offsetof(GB_gameboy_t, name##_section_start)) #define GB_GET_SECTION(gb, name) ((void*)&((gb)->name##_section_start))