From 10587cb5ab12532727cf3e86f7c7bd2f4f78624a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 22 Oct 2015 23:32:27 +0200 Subject: [PATCH 1/6] Port non-VS inline asm to AT&T syntax This is much more liked by other compilers --- CMakeLists.txt | 4 +- src/addresses.h | 114 ++++++++++++++++++++++++------------------------ src/rct2.c | 4 +- 3 files changed, 61 insertions(+), 61 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 435325884e..fccdd91d99 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,8 @@ file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cu if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -masm=intel -fvar-tracking-assignments -std=gnu99") - set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11 -fvar-tracking-assignments -masm=intel") + set(CMAKE_C_FLAGS "-m32 -fvar-tracking-assignments -std=gnu99") + set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11 -fvar-tracking-assignments") set(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,-melf_i386") set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (UNIX) diff --git a/src/addresses.h b/src/addresses.h index 19eeb5c03c..1b69c339d4 100644 --- a/src/addresses.h +++ b/src/addresses.h @@ -698,23 +698,23 @@ static int RCT2_CALLPROC_X(int address, int _eax, int _ebx, int _ecx, int _edx, #else __asm__ ( "\ \n\ - push ebx \n\ - push ebp \n\ + push %%ebx \n\ + push %%ebp \n\ push %[address] \n\ - mov eax, %[_eax] \n\ - mov ebx, %[_ebx] \n\ - mov ecx, %[_ecx] \n\ - mov edx, %[_edx] \n\ - mov esi, %[_esi] \n\ - mov edi, %[_edi] \n\ - mov ebp, %[_ebp] \n\ - call [esp] \n\ + mov %[_eax], %%eax \n\ + mov %[_ebx], %%ebx \n\ + mov %[_ecx], %%ecx \n\ + mov %[_edx], %%edx \n\ + mov %[_esi], %%esi \n\ + mov %[_edi], %%edi \n\ + mov %[_ebp], %%ebp \n\ + call *(%%esp) \n\ lahf \n\ - add esp, 4 \n\ - pop ebp \n\ - pop ebx \n\ + add $4, %%esp \n\ + pop %%ebp \n\ + pop %%ebx \n\ /* Load result with flags */ \n\ - mov %[result], eax \n\ + mov %%eax, %[result] \n\ " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp), [result] "+m" (result) : : "eax","ecx","edx","esi","edi" @@ -817,70 +817,70 @@ static int RCT2_CALLFUNC_X(int address, int *_eax, int *_ebx, int *_ecx, int *_e __asm__ ( "\ \n\ /* Store C's base pointer*/ \n\ - push ebp \n\ - push ebx \n\ + push %%ebp \n\ + push %%ebx \n\ \n\ /* Store %[address] to call*/ \n\ push %[address] \n\ \n\ /* Set all registers to the input values*/ \n\ - mov eax, [%[_eax]] \n\ - mov eax, [eax] \n\ - mov ebx, [%[_ebx]] \n\ - mov ebx, [ebx] \n\ - mov ecx, [%[_ecx]] \n\ - mov ecx, [ecx] \n\ - mov edx, [%[_edx]] \n\ - mov edx, [edx] \n\ - mov esi, [%[_esi]] \n\ - mov esi, [esi] \n\ - mov edi, [%[_edi]] \n\ - mov edi, [edi] \n\ - mov ebp, [%[_ebp]] \n\ - mov ebp, [ebp] \n\ + mov %[_eax], %%eax \n\ + mov (%%eax), %%eax \n\ + mov %[_ebx], %%ebx \n\ + mov (%%ebx), %%ebx \n\ + mov %[_ecx], %%ecx \n\ + mov (%%ecx), %%ecx \n\ + mov %[_edx], %%edx \n\ + mov (%%edx), %%edx \n\ + mov %[_esi], %%esi \n\ + mov (%%esi), %%esi \n\ + mov %[_edi], %%edi \n\ + mov (%%edi), %%edi \n\ + mov %[_ebp], %%ebp \n\ + mov (%%ebp), %%ebp \n\ \n\ /* Call function*/ \n\ - call [esp] \n\ + call *(%%esp) \n\ \n\ /* Store output eax */ \n\ - push eax \n\ - push ebp \n\ - push ebx \n\ - mov ebp, [esp + 20] \n\ - mov ebx, [esp + 16] \n\ + push %%eax \n\ + push %%ebp \n\ + push %%ebx \n\ + mov 20(%%esp), %%ebp \n\ + mov 16(%%esp), %%ebx \n\ /* Get resulting ecx, edx, esi, edi registers*/ \n\ - mov eax, [%[_edi]] \n\ - mov [eax], edi \n\ - mov eax, [%[_esi]] \n\ - mov [eax], esi \n\ - mov eax, [%[_edx]] \n\ - mov [eax], edx \n\ - mov eax, [%[_ecx]] \n\ - mov [eax], ecx \n\ + mov %[_edi], %%eax \n\ + mov %%edi, (%%eax) \n\ + mov %[_esi], %%eax \n\ + mov %%esi, (%%eax) \n\ + mov %[_edx], %%eax \n\ + mov %%edx, (%%eax) \n\ + mov %[_ecx], %%eax \n\ + mov %%ecx, (%%eax) \n\ /* Pop ebx reg into ecx*/ \n\ - pop ecx \n\ - mov eax, [%[_ebx]] \n\ - mov [eax], ecx \n\ + pop %%ecx \n\ + mov %[_ebx], %%eax \n\ + mov %%ecx, (%%eax) \n\ \n\ /* Pop ebp reg into ecx */\n\ - pop ecx \n\ - mov eax, [%[_ebp]] \n\ - mov [eax], ecx \n\ + pop %%ecx \n\ + mov %[_ebp], %%eax \n\ + mov %%ecx, (%%eax) \n\ \n\ - pop eax \n\ + pop %%eax \n\ /* Get resulting eax register*/ \n\ - mov ecx, [%[_eax]] \n\ - mov [ecx], eax \n\ + mov %[_eax], %%ecx \n\ + mov %%eax, (%%ecx) \n\ \n\ /* Save flags as return in eax*/ \n\ lahf \n\ /* Pop address*/ \n\ - pop ebp \n\ + pop %%ebp \n\ \n\ - pop ebx \n\ - pop ebp \n\ + pop %%ebx \n\ + pop %%ebp \n\ /* Load result with flags */ \n\ - mov %[result], eax \n\ + mov %%eax, %[result] \n\ " : [address] "+m" (address), [_eax] "+m" (_eax), [_ebx] "+m" (_ebx), [_ecx] "+m" (_ecx), [_edx] "+m" (_edx), [_esi] "+m" (_esi), [_edi] "+m" (_edi), [_ebp] "+m" (_ebp), [result] "+m" (result) : diff --git a/src/rct2.c b/src/rct2.c index 154b1aab9c..560db3ab9a 100644 --- a/src/rct2.c +++ b/src/rct2.c @@ -228,8 +228,8 @@ void rct2_update() #else __asm__ ( "\ \n\ - mov eax, 0x009DE564 \n\ - mov [eax], esp \n\ + movl $0x009DE564, %%eax \n\ + movl %%esp, (%%eax) \n\ " : : : "eax" ); #endif From f8407176d14fa93a58eeb9398f46e05b1658f619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 22 Oct 2015 23:39:09 +0200 Subject: [PATCH 2/6] drop no longer needed debug switch for gcc --- CMakeLists.txt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index fccdd91d99..26f133133e 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -57,8 +57,8 @@ file(GLOB_RECURSE ORCT2_SOURCES "src/*.c" "src/*.cpp" "lib/argparse/*.c" "lib/cu if (UNIX) # force 32bit build for now and set necessary flags to compile code as is - set(CMAKE_C_FLAGS "-m32 -fvar-tracking-assignments -std=gnu99") - set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11 -fvar-tracking-assignments") + set(CMAKE_C_FLAGS "-m32 -std=gnu99") + set(CMAKE_CXX_FLAGS "-m32 -std=gnu++11") set(CMAKE_SHARED_LINKER_FLAGS "-m32 -Wl,-melf_i386") set(CMAKE_EXE_LINKER_FLAGS ${CMAKE_SHARED_LINKER_FLAGS}) endif (UNIX) From 11fb15bba78ce26c6d7fbc06092cfab72e34aec6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 22 Oct 2015 23:51:05 +0200 Subject: [PATCH 3/6] Add casts for types --- src/windows/editor_object_selection.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/windows/editor_object_selection.c b/src/windows/editor_object_selection.c index b6e064aed3..39efc7e727 100644 --- a/src/windows/editor_object_selection.c +++ b/src/windows/editor_object_selection.c @@ -1327,13 +1327,13 @@ static void window_editor_object_selection_paint(rct_window *w, rct_drawpixelinf width = w->width - w->widgets[WIDX_LIST].right - 6; // Skip object dat name - text = (char*)(highlightedEntry + 1); - datName = text; + text = (uint8*)(highlightedEntry + 1); + datName = (char*)text; do { text++; } while (*(text - 1) != 0); text += 4; - name = text; + name = (char*)text; RCT2_GLOBAL(0x009BC677, uint8) = 14; From ff19998846ac4d274165e30a77c07ba83ef7be8a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 22 Oct 2015 23:54:07 +0200 Subject: [PATCH 4/6] Add clang to travis matrix --- .travis.yml | 1 + install.sh | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index e4791043cd..e7f94d1820 100644 --- a/.travis.yml +++ b/.travis.yml @@ -17,6 +17,7 @@ cache: env: - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8" + - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=clang -DCMAKE_CXX_COMPILER=clang++" - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=OFF -DDISABLE_HTTP_TWITCH=ON -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8" - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=OFF -DDISABLE_HTTP_TWITCH=OFF -DCMAKE_C_COMPILER=gcc-4.8 -DCMAKE_CXX_COMPILER=g++-4.8" - OPENRCT2_CMAKE_OPTS="-DCMAKE_TOOLCHAIN_FILE=../CMakeLists_mingw.txt" TARGET=windows diff --git a/install.sh b/install.sh index df1fdcfa76..31acc48c72 100755 --- a/install.sh +++ b/install.sh @@ -174,7 +174,7 @@ elif [[ `uname` == "Linux" ]]; then "linux") sudo dpkg --add-architecture i386 sudo apt-get update - sudo apt-get install --no-install-recommends -y --force-yes cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 libcurl4-openssl-dev:i386 libcrypto++-dev:i386 + sudo apt-get install --no-install-recommends -y --force-yes cmake libsdl2-dev:i386 libsdl2-ttf-dev:i386 gcc-4.8 pkg-config:i386 g++-4.8-multilib gcc-4.8-multilib libjansson-dev:i386 libspeex-dev:i386 libspeexdsp-dev:i386 libcurl4-openssl-dev:i386 libcrypto++-dev:i386 clang download https://launchpad.net/ubuntu/+archive/primary/+files/libjansson4_2.7-1ubuntu1_i386.deb libjansson4_2.7-1ubuntu1_i386.deb download https://launchpad.net/ubuntu/+archive/primary/+files/libjansson-dev_2.7-1ubuntu1_i386.deb libjansson-dev_2.7-1ubuntu1_i386.deb sudo dpkg -i libjansson4_2.7-1ubuntu1_i386.deb From 5bc180a583c8fdbf2eaadbf6a5ab294e348db498 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Thu, 22 Oct 2015 23:59:10 +0200 Subject: [PATCH 5/6] Fixes for travis builds of new AT&T syntax --- CMakeLists_mingw.txt | 4 ++-- install.sh | 2 -- 2 files changed, 2 insertions(+), 4 deletions(-) diff --git a/CMakeLists_mingw.txt b/CMakeLists_mingw.txt index 4be930b8e4..d4817994d1 100644 --- a/CMakeLists_mingw.txt +++ b/CMakeLists_mingw.txt @@ -11,8 +11,8 @@ SET(PKG_CONFIG_EXECUTABLE ${COMPILER_PREFIX}-pkg-config) # potential flags to make code more similar to MSVC: # -fshort-wchar -fshort-enums -mms-bitfields # -set(CMAKE_C_FLAGS "-masm=intel -std=gnu99 -fpack-struct=1" CACHE STRING "" FORCE) -set(CMAKE_CXX_FLAGS "-masm=intel -std=c++0x -std=gnu++0x -fpack-struct=1" CACHE STRING "" FORCE) +set(CMAKE_C_FLAGS "-std=gnu99 -fpack-struct=1" CACHE STRING "" FORCE) +set(CMAKE_CXX_FLAGS "-std=c++0x -std=gnu++0x -fpack-struct=1" CACHE STRING "" FORCE) if(${ACTUAL_SYSTEM} MATCHES "Linux") set(CMAKE_SHARED_LINKER_FLAGS "-O3 -static-libgcc -static-libstdc++ -static -lpthread" CACHE STRING "" FORCE) else() diff --git a/install.sh b/install.sh index 31acc48c72..eb19e49d5e 100755 --- a/install.sh +++ b/install.sh @@ -180,8 +180,6 @@ elif [[ `uname` == "Linux" ]]; then sudo dpkg -i libjansson4_2.7-1ubuntu1_i386.deb sudo dpkg -i libjansson-dev_2.7-1ubuntu1_i386.deb sudo apt-get install -f - export CC=gcc-4.8 - export CXX=g++-4.8 ;; "windows") sudo apt-get update From 12d9278e1e8a710a3922fe75f6e841fb5dd647dc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Micha=C5=82=20Janiszewski?= Date: Fri, 23 Oct 2015 00:04:19 +0200 Subject: [PATCH 6/6] Use 'trusty' image for travis now that it's public Travis CI team has recently published beta image of Trusty for testing [1]. Switch to that image for CI builds in a non-hacky way. [1] http://blog.travis-ci.com/2015-10-14-opening-up-ubuntu-trusty-beta/ --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e7f94d1820..4a7ae74da1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -28,6 +28,7 @@ env: - OPENRCT2_CMAKE_OPTS="-DDISABLE_NETWORK=ON -DDISABLE_HTTP_TWITCH=ON" TARGET=docker32 sudo: required +dist: trusty services: - docker