diff --git a/.travis.yml b/.travis.yml index 38030785..2d8975e1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,4 +1,4 @@ -language: cpp +language: c matrix: include: @@ -7,18 +7,23 @@ matrix: addons: apt: sources: - - kubuntu-backports + - george-edison55-precise-backports - ubuntu-toolchain-r-test packages: - cmake - - gcc-4.9 - - g++-4.9 + - cmake-data + - gcc-6 + - g++-6 - os: osx + osx_image: xcode7 compiler: clang + before_install: + - brew upgrade + - brew install cmake script: - - if [ "$CC" = "gcc" ]; then export CC="gcc-4.9" CXX="g++-4.9"; fi + - if [ "$CC" = "gcc" ]; then export CC="gcc-6" CXX="g++-6"; fi - mkdir build - cd build - cmake .. diff --git a/CMakeLists.txt b/CMakeLists.txt index 94ca2593..cae90607 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,4 +1,4 @@ -cmake_minimum_required(VERSION 2.8.12) +cmake_minimum_required(VERSION 3.1) list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_SOURCE_DIR}/cmake") @@ -15,9 +15,9 @@ endif() list(APPEND REDREAM_LANGUAGES C CXX) if(WIN32) -list(APPEND REDREAM_LANGUAGES ASM_MASM) + list(APPEND REDREAM_LANGUAGES ASM_MASM) else() -list(APPEND REDREAM_LANGUAGES ASM) + list(APPEND REDREAM_LANGUAGES ASM) endif() project(redream ${REDREAM_LANGUAGES}) @@ -25,6 +25,9 @@ project(redream ${REDREAM_LANGUAGES}) # export compile_commands.json for clang-tidy set(CMAKE_EXPORT_COMPILE_COMMANDS ON) +set(CMAKE_C_STANDARD 11) +set(CMAKE_CXX_STANDARD 11) + #-------------------------------------------------- # config file #-------------------------------------------------- @@ -214,8 +217,8 @@ endif() # assign source groups for visual studio projects source_group_by_dir(REDREAM_SOURCES) -if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" STREQUAL "Clang") - set(REDREAM_COMPILE_FLAGS $<$:-std=c++11 -fno-operator-names> $<$:-std=c11> -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-strict-aliasing -D_GNU_SOURCE) +if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_C_COMPILER_ID}" MATCHES "Clang") + set(REDREAM_COMPILE_FLAGS -Wall -Wextra -Werror -Wno-unused-function -Wno-unused-parameter -Wno-unused-variable -Wno-strict-aliasing -D_GNU_SOURCE) # some flavors of GCC require this to be defined for the PR* macros in inttypes.h if("${CMAKE_C_COMPILER_ID}" STREQUAL "GNU") diff --git a/src/jit/backend/x64/x64_backend.cc b/src/jit/backend/x64/x64_backend.cc index 6c4bd23d..c07799c3 100644 --- a/src/jit/backend/x64/x64_backend.cc +++ b/src/jit/backend/x64/x64_backend.cc @@ -1,5 +1,7 @@ #include #include + +#define XBYAK_NO_OP_NAMES #include extern "C" { @@ -1450,10 +1452,10 @@ EMITTER(AND) { } if (x64_backend_can_encode_imm(instr->arg[1])) { - e.and (result, (uint32_t)ir_zext_constant(instr->arg[1])); + e.and_(result, (uint32_t)ir_zext_constant(instr->arg[1])); } else { const Xbyak::Reg b = x64_backend_register(backend, instr->arg[1]); - e.and (result, b); + e.and_(result, b); } } @@ -1466,10 +1468,10 @@ EMITTER(OR) { } if (x64_backend_can_encode_imm(instr->arg[1])) { - e.or (result, (uint32_t)ir_zext_constant(instr->arg[1])); + e.or_(result, (uint32_t)ir_zext_constant(instr->arg[1])); } else { const Xbyak::Reg b = x64_backend_register(backend, instr->arg[1]); - e.or (result, b); + e.or_(result, b); } } @@ -1482,10 +1484,10 @@ EMITTER(XOR) { } if (x64_backend_can_encode_imm(instr->arg[1])) { - e.xor (result, (uint32_t)ir_zext_constant(instr->arg[1])); + e.xor_(result, (uint32_t)ir_zext_constant(instr->arg[1])); } else { const Xbyak::Reg b = x64_backend_register(backend, instr->arg[1]); - e.xor (result, b); + e.xor_(result, b); } } @@ -1497,7 +1499,7 @@ EMITTER(NOT) { e.mov(result, a); } - e.not(result); + e.not_(result); } EMITTER(SHL) { diff --git a/src/jit/frontend/sh4/sh4_disasm.c b/src/jit/frontend/sh4/sh4_disasm.c index 32b06a4c..0b5eedec 100644 --- a/src/jit/frontend/sh4/sh4_disasm.c +++ b/src/jit/frontend/sh4/sh4_disasm.c @@ -22,7 +22,7 @@ static struct sh4_opdef s_opdefs[NUM_SH4_OPS] = { #include "jit/frontend/sh4/sh4_instr.inc" #undef SH4_INSTR }; -static struct sh4_opdef *s_opdef_lookup[UINT16_MAX] = {}; +static struct sh4_opdef *s_opdef_lookup[UINT16_MAX]; static void sh4_arg_mask(const char *instr_code, char c, uint16_t *mask, uint16_t *shift) { diff --git a/src/renderer/gl_backend.c b/src/renderer/gl_backend.c index 6ddbcb5b..c6878da6 100644 --- a/src/renderer/gl_backend.c +++ b/src/renderer/gl_backend.c @@ -268,7 +268,7 @@ static void rb_destroy_program(struct shader_program *program) { static bool rb_compile_program(struct shader_program *program, const char *header, const char *vertex_source, const char *fragment_source) { - char buffer[16384] = {0}; + char buffer[16384] = {}; memset(program, 0, sizeof(*program)); program->program = glCreateProgram(); diff --git a/src/sys/filesystem.c b/src/sys/filesystem.c index baae845e..32cee65e 100644 --- a/src/sys/filesystem.c +++ b/src/sys/filesystem.c @@ -7,7 +7,7 @@ #include "core/string.h" const char *fs_appdir() { - static char appdir[PATH_MAX] = {}; + static char appdir[PATH_MAX]; if (appdir[0]) { return appdir; diff --git a/src/ui/keycode.c b/src/ui/keycode.c index cdfa9d75..4569f915 100644 --- a/src/ui/keycode.c +++ b/src/ui/keycode.c @@ -319,7 +319,7 @@ static struct key keys[] = {{K_UNKNOWN, "unknown"}, {K_AXIS15, "axis15"}}; enum keycode get_key_by_name(const char *keyname) { - char buffer[256] = {0}; + char buffer[256] = {}; int len = 0; while (*keyname) {