All: Preliminary shift to C11
This commit is contained in:
parent
519968d37e
commit
9b07a63056
@ -22,14 +22,11 @@ if(NOT LIBMGBA_ONLY)
|
|||||||
set(BINARY_NAME ${BINARY_NAME} CACHE INTERNAL "Name of output binaries")
|
set(BINARY_NAME ${BINARY_NAME} CACHE INTERNAL "Name of output binaries")
|
||||||
endif()
|
endif()
|
||||||
|
|
||||||
set(CMAKE_C_STANDARD 99)
|
set(CMAKE_C_STANDARD 11)
|
||||||
if(NOT MSVC)
|
if(NOT MSVC)
|
||||||
set(CMAKE_C_STANDARD_REQUIRED ON)
|
set(CMAKE_C_STANDARD_REQUIRED ON)
|
||||||
set(CMAKE_C_EXTENSIONS OFF)
|
set(CMAKE_C_EXTENSIONS OFF)
|
||||||
if(SWITCH OR 3DS)
|
if(SWITCH OR 3DS OR (CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.3"))
|
||||||
set(CMAKE_C_STANDARD 11)
|
|
||||||
set(CMAKE_C_EXTENSIONS ON)
|
|
||||||
elseif(CMAKE_C_COMPILER_ID STREQUAL "GNU" AND CMAKE_C_COMPILER_VERSION VERSION_LESS "4.3")
|
|
||||||
set(CMAKE_C_EXTENSIONS ON)
|
set(CMAKE_C_EXTENSIONS ON)
|
||||||
endif()
|
endif()
|
||||||
set(WARNING_FLAGS "-Wall -Wextra -Wno-missing-field-initializers")
|
set(WARNING_FLAGS "-Wall -Wextra -Wno-missing-field-initializers")
|
||||||
|
@ -118,7 +118,7 @@ Controls are configurable in the settings menu. Many game controllers should be
|
|||||||
Compiling
|
Compiling
|
||||||
---------
|
---------
|
||||||
|
|
||||||
Compiling requires using CMake 3.1 or newer. GCC and Clang are both known to work to compile mGBA, but Visual Studio 2013 and older are known not to work. Support for Visual Studio 2015 and newer is coming soon.
|
Compiling requires using CMake 3.1 or newer. GCC, Clang and Visual Studio 2019 known to work to compile mGBA.
|
||||||
|
|
||||||
#### Docker building
|
#### Docker building
|
||||||
|
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
|
|
||||||
CXX_GUARD_START
|
CXX_GUARD_START
|
||||||
|
|
||||||
|
#include <assert.h>
|
||||||
#include <ctype.h>
|
#include <ctype.h>
|
||||||
#include <fcntl.h>
|
#include <fcntl.h>
|
||||||
#include <inttypes.h>
|
#include <inttypes.h>
|
||||||
|
@ -24,7 +24,6 @@ typedef THREAD_ENTRY (*ThreadEntry)(void*);
|
|||||||
typedef pthread_t Thread;
|
typedef pthread_t Thread;
|
||||||
typedef pthread_mutex_t Mutex;
|
typedef pthread_mutex_t Mutex;
|
||||||
typedef pthread_cond_t Condition;
|
typedef pthread_cond_t Condition;
|
||||||
typedef pthread_key_t ThreadLocal;
|
|
||||||
|
|
||||||
static inline int MutexInit(Mutex* mutex) {
|
static inline int MutexInit(Mutex* mutex) {
|
||||||
return pthread_mutex_init(mutex, 0);
|
return pthread_mutex_init(mutex, 0);
|
||||||
@ -104,6 +103,9 @@ static inline int ThreadSetName(const char* name) {
|
|||||||
#endif
|
#endif
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (__STDC_VERSION__ < 201112L) || (__STDC_NO_THREADS__ == 1)
|
||||||
|
typedef pthread_key_t ThreadLocal;
|
||||||
|
|
||||||
static inline void ThreadLocalInitKey(ThreadLocal* key) {
|
static inline void ThreadLocalInitKey(ThreadLocal* key) {
|
||||||
pthread_key_create(key, 0);
|
pthread_key_create(key, 0);
|
||||||
}
|
}
|
||||||
@ -115,6 +117,7 @@ static inline void ThreadLocalSetKey(ThreadLocal key, void* value) {
|
|||||||
static inline void* ThreadLocalGetValue(ThreadLocal key) {
|
static inline void* ThreadLocalGetValue(ThreadLocal key) {
|
||||||
return pthread_getspecific(key);
|
return pthread_getspecific(key);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
CXX_GUARD_END
|
CXX_GUARD_END
|
||||||
|
|
||||||
|
@ -16,7 +16,6 @@ typedef THREAD_ENTRY ThreadEntry(LPVOID);
|
|||||||
typedef HANDLE Thread;
|
typedef HANDLE Thread;
|
||||||
typedef CRITICAL_SECTION Mutex;
|
typedef CRITICAL_SECTION Mutex;
|
||||||
typedef CONDITION_VARIABLE Condition;
|
typedef CONDITION_VARIABLE Condition;
|
||||||
typedef DWORD ThreadLocal;
|
|
||||||
|
|
||||||
static inline int MutexInit(Mutex* mutex) {
|
static inline int MutexInit(Mutex* mutex) {
|
||||||
InitializeCriticalSection(mutex);
|
InitializeCriticalSection(mutex);
|
||||||
@ -89,6 +88,9 @@ static inline int ThreadSetName(const char* name) {
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#if (__STDC_VERSION__ < 201112L) || (__STDC_NO_THREADS__ == 1)
|
||||||
|
typedef DWORD ThreadLocal;
|
||||||
|
|
||||||
static inline void ThreadLocalInitKey(ThreadLocal* key) {
|
static inline void ThreadLocalInitKey(ThreadLocal* key) {
|
||||||
*key = TlsAlloc();
|
*key = TlsAlloc();
|
||||||
}
|
}
|
||||||
@ -100,5 +102,6 @@ static inline void ThreadLocalSetKey(ThreadLocal key, void* value) {
|
|||||||
static inline void* ThreadLocalGetValue(ThreadLocal key) {
|
static inline void* ThreadLocalGetValue(ThreadLocal key) {
|
||||||
return TlsGetValue(key);
|
return TlsGetValue(key);
|
||||||
}
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
@ -442,7 +442,7 @@ struct GBSerializedState {
|
|||||||
int32_t lastSample;
|
int32_t lastSample;
|
||||||
uint8_t sampleIndex;
|
uint8_t sampleIndex;
|
||||||
uint8_t reserved[3];
|
uint8_t reserved[3];
|
||||||
struct mStereoSample currentSamples[32];
|
struct mStereoSample currentSamples[GB_MAX_SAMPLES];
|
||||||
} audio2;
|
} audio2;
|
||||||
|
|
||||||
uint8_t oam[GB_SIZE_OAM];
|
uint8_t oam[GB_SIZE_OAM];
|
||||||
@ -473,6 +473,8 @@ struct GBSerializedState {
|
|||||||
};
|
};
|
||||||
#pragma pack(pop)
|
#pragma pack(pop)
|
||||||
|
|
||||||
|
static_assert(sizeof(struct GBSerializedState) == 0x11800, "GB savestate struct sized wrong");
|
||||||
|
|
||||||
bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state);
|
bool GBDeserialize(struct GB* gb, const struct GBSerializedState* state);
|
||||||
void GBSerialize(struct GB* gb, struct GBSerializedState* state);
|
void GBSerialize(struct GB* gb, struct GBSerializedState* state);
|
||||||
|
|
||||||
|
@ -402,7 +402,7 @@ struct GBASerializedState {
|
|||||||
int8_t chB[16];
|
int8_t chB[16];
|
||||||
} samples;
|
} samples;
|
||||||
|
|
||||||
struct mStereoSample currentSamples[16];
|
struct mStereoSample currentSamples[GBA_MAX_SAMPLES];
|
||||||
|
|
||||||
uint32_t reserved[12];
|
uint32_t reserved[12];
|
||||||
|
|
||||||
@ -414,6 +414,8 @@ struct GBASerializedState {
|
|||||||
uint8_t wram[SIZE_WORKING_RAM];
|
uint8_t wram[SIZE_WORKING_RAM];
|
||||||
};
|
};
|
||||||
|
|
||||||
|
static_assert(sizeof(struct GBASerializedState) == 0x61000, "GBA savestate struct sized wrong");
|
||||||
|
|
||||||
struct VDir;
|
struct VDir;
|
||||||
|
|
||||||
void GBASerialize(struct GBA* gba, struct GBASerializedState* state);
|
void GBASerialize(struct GBA* gba, struct GBASerializedState* state);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user