From fdadae67456901ae4fe64cbd4b7a988c0a29bf72 Mon Sep 17 00:00:00 2001 From: Alex Voicu Date: Fri, 12 Apr 2019 12:23:21 +0300 Subject: [PATCH] Fix Clang build Change-Id: I0b51699c0a1368cf5813bd9d3cd4479139d23d6a --- CMakeLists.txt | 7 +++++-- src/fmm.c | 1 + src/libhsakmt.h | 2 +- 3 files changed, 7 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e3141d3ccb..b8b565beab 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -63,7 +63,10 @@ set ( BUILD_VERSION_STRING "${BUILD_VERSION_MAJOR}.${BUILD_VERSION_MINOR}.${BUIL #set ( CMAKE_VERBOSE_MAKEFILE on ) ## Compiler flags -set (HSAKMT_C_FLAGS -fPIC -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wswitch-default -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wlogical-op -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=gnu99 -fvisibility=hidden) +set (HSAKMT_C_FLAGS -fPIC -W -Wall -Wextra -Wno-unused-parameter -Wformat-security -Wswitch-default -Wundef -Wshadow -Wpointer-arith -Wbad-function-cast -Wcast-qual -Wstrict-prototypes -Wmissing-prototypes -Wmissing-declarations -Wredundant-decls -Wunreachable-code -std=gnu99 -fvisibility=hidden) +if ( CMAKE_COMPILER_IS_GNUCC ) + set ( HSAKMT_C_FLAGS "${HSAKMT_C_FLAGS}" -Wlogical-op) +endif () if ( "${CMAKE_C_COMPILER_VERSION}" STRGREATER "4.8.0") set ( HSAKMT_C_FLAGS "${HSAKMT_C_FLAGS}" -Werror ) endif () @@ -133,7 +136,7 @@ add_custom_target ( build-dev -DHSAKMT_BIN_NAME="${HSAKMT}" WORKING_DIRECTORY ${DEV_BUILD_DIR} ) -## Custom targets for the devel package +## Custom targets for the devel package add_custom_target ( install-dev DEPENDS build-dev COMMAND make install WORKING_DIRECTORY ${DEV_BUILD_DIR} ) add_custom_target ( package-dev DEPENDS build-dev COMMAND rm -rf *.deb *.rpm *.tar.gz diff --git a/src/fmm.c b/src/fmm.c index 079ee55664..f335ef4293 100644 --- a/src/fmm.c +++ b/src/fmm.c @@ -277,6 +277,7 @@ static inline HsaSharedMemoryStruct *to_hsa_shared_memory_struct( return (HsaSharedMemoryStruct *)SharedMemoryHandle; } +__attribute__((unused)) static inline HsaSharedMemoryHandle *to_hsa_shared_memory_handle( HsaSharedMemoryStruct *SharedMemoryStruct) { diff --git a/src/libhsakmt.h b/src/libhsakmt.h index a34889c967..1a2ba979ff 100644 --- a/src/libhsakmt.h +++ b/src/libhsakmt.h @@ -67,7 +67,7 @@ extern int PAGE_SHIFT; #define ALIGN_UP(x,align) (((uint64_t)(x) + (align) - 1) & ~(uint64_t)((align)-1)) #define ALIGN_UP_32(x,align) (((uint32_t)(x) + (align) - 1) & ~(uint32_t)((align)-1)) #define PAGE_ALIGN_UP(x) ALIGN_UP(x,PAGE_SIZE) -#define BITMASK(n) (((n) < sizeof(1ULL) * CHAR_BIT ? (1ULL << (n)) : 0) - 1ULL) +#define BITMASK(n) ((n) ? (UINT64_MAX >> (sizeof(UINT64_MAX) * CHAR_BIT - n)) : n) #define ARRAY_LEN(array) (sizeof(array) / sizeof(array[0])) /* HSA Thunk logging usage */