Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix build using newest gcc(10/11) with new msys/mingw toolchains #333

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 5 additions & 1 deletion cmake/boost.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -13,15 +13,19 @@ set(BOOST_NO_BOOST_CMAKE ON)

unset(Boost_INCLUDE_DIR CACHE)
# we might have boost in tree, so provide a hint and try again
set(BOOST_INCLUDEDIR "${PROJECT_SOURCE_DIR}/include")
set(BOOST_INCLUDEDIR "${PROJECT_SOURCE_DIR}/include/boost")
find_package(Boost ${BOOST_MINVERSION} QUIET)
if(NOT Boost_FOUND)
set(BOOST_INCLUDEDIR "${PROJECT_SOURCE_DIR}/include")
find_package(Boost ${BOOST_MINVERSION} QUIET)
if(NOT Boost_FOUND)
# otherwise check for Boost installed on the system
unset(BOOST_INCLUDEDIR)
find_package(Boost ${BOOST_MINVERSION} QUIET)
if(NOT Boost_FOUND)
message(FATAL_ERROR "Boost ${BOOST_MINVERSION} or later not found. Either install system packages if available, extract Boost headers to ${CMAKE_SOURCE_DIR}/include, or set the CMake BOOST_ROOT variable.")
endif()
endif()
endif()

message(STATUS "Boost version: ${Boost_MAJOR_VERSION}.${Boost_MINOR_VERSION}.${Boost_SUBMINOR_VERSION}")
Expand Down
16 changes: 8 additions & 8 deletions src/ue2common.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
#include <stdint.h>

/* ick */
#if defined(_WIN32)
#if defined(_MSC_VER)
#define ALIGN_ATTR(x) __declspec(align(x))
#else
#define ALIGN_ATTR(x) __attribute__((aligned((x))))
Expand All @@ -66,7 +66,7 @@ typedef signed int s32;
/* We append the 'a' for aligned, since these aren't common, garden variety
* 64 bit values. The alignment is necessary for structs on some platforms,
* so we don't end up performing accidental unaligned accesses. */
#if defined(_WIN32) && ! defined(_WIN64)
#if defined(_MSC_VER) && ! defined(_WIN64)
typedef unsigned long long ALIGN_ATTR(4) u64a;
typedef signed long long ALIGN_ATTR(4) s64a;
#else
Expand All @@ -83,7 +83,7 @@ typedef u32 ReportID;

/* Shorthand for attribute to mark a function as part of our public API.
* Functions without this attribute will be hidden. */
#if !defined(_WIN32)
#if !defined(_MSC_VER)
#define HS_PUBLIC_API __attribute__((visibility("default")))
#else
// TODO: dllexport defines for windows
Expand All @@ -93,14 +93,14 @@ typedef u32 ReportID;
#define ARRAY_LENGTH(a) (sizeof(a)/sizeof((a)[0]))

/** \brief Shorthand for the attribute to shut gcc about unused parameters */
#if !defined(_WIN32)
#if !defined(_MSC_VER)
#define UNUSED __attribute__ ((unused))
#else
#define UNUSED
#endif

/* really_inline forces inlining always */
#if !defined(_WIN32)
#if !defined(_MSC_VER)
#if defined(HS_OPTIMIZE)
#define really_inline inline __attribute__ ((always_inline, unused))
#else
Expand Down Expand Up @@ -130,7 +130,7 @@ typedef u32 ReportID;


// We use C99-style "restrict".
#ifdef _WIN32
#ifdef _MSC_VER
#ifdef __cplusplus
#define restrict
#else
Expand Down Expand Up @@ -186,7 +186,7 @@ typedef u32 ReportID;
#define LIMIT_TO_AT_MOST(a, b) (*(a) = MIN(*(a),(b)))
#define ENSURE_AT_LEAST(a, b) (*(a) = MAX(*(a),(b)))

#ifndef _WIN32
#ifndef _MSC_VER
#ifndef likely
#define likely(x) __builtin_expect(!!(x), 1)
#endif
Expand All @@ -199,7 +199,7 @@ typedef u32 ReportID;
#endif

#if !defined(RELEASE_BUILD) || defined(DEBUG)
#ifdef _WIN32
#ifdef _MSC_VER
#define PATH_SEP '\\'
#else
#define PATH_SEP '/'
Expand Down
12 changes: 6 additions & 6 deletions src/util/bitutils.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@
static really_inline
u32 clz32(u32 x) {
assert(x); // behaviour not defined for x == 0
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
unsigned long r;
_BitScanReverse(&r, x);
return 31 - r;
Expand All @@ -58,11 +58,11 @@ u32 clz32(u32 x) {
static really_inline
u32 clz64(u64a x) {
assert(x); // behaviour not defined for x == 0
#if defined(_WIN64)
#if defined(_WIN64) && defined(_MSC_VER)
unsigned long r;
_BitScanReverse64(&r, x);
return 63 - r;
#elif defined(_WIN32)
#elif defined(_WIN32) && defined(_MSC_VER)
unsigned long x1 = (u32)x;
unsigned long x2 = (u32)(x >> 32);
unsigned long r;
Expand All @@ -81,7 +81,7 @@ u32 clz64(u64a x) {
static really_inline
u32 ctz32(u32 x) {
assert(x); // behaviour not defined for x == 0
#if defined(_WIN32)
#if defined(_WIN32) && defined(_MSC_VER)
unsigned long r;
_BitScanForward(&r, x);
return r;
Expand All @@ -93,11 +93,11 @@ u32 ctz32(u32 x) {
static really_inline
u32 ctz64(u64a x) {
assert(x); // behaviour not defined for x == 0
#if defined(_WIN64)
#if defined(_WIN64) && defined(_MSC_VER)
unsigned long r;
_BitScanForward64(&r, x);
return r;
#elif defined(_WIN32)
#elif defined(_WIN32) && defined(_MSC_VER)
unsigned long r;
if (_BitScanForward(&r, (u32)x)) {
return (u32)r;
Expand Down
4 changes: 2 additions & 2 deletions src/util/cpuid_inline.h
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
#include "ue2common.h"
#include "cpuid_flags.h"

#if !defined(_WIN32) && !defined(CPUID_H_)
#if !defined(_MSC_VER) && !defined(CPUID_H_)
#include <cpuid.h>
/* system header doesn't have a header guard */
#define CPUID_H_
Expand All @@ -46,7 +46,7 @@ extern "C"
static inline
void cpuid(unsigned int op, unsigned int leaf, unsigned int *eax,
unsigned int *ebx, unsigned int *ecx, unsigned int *edx) {
#ifndef _WIN32
#if !defined(_MSC_VER)
__cpuid_count(op, leaf, *eax, *ebx, *ecx, *edx);
#else
int a[4];
Expand Down