Skip to content

Commit 073a8fb

Browse files
author
Santiago
committed
Fix MSVC build
1 parent c5e268a commit 073a8fb

File tree

3 files changed

+23
-12
lines changed

3 files changed

+23
-12
lines changed

librecomp/CMakeLists.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ project(librecomp)
44
set(CMAKE_CXX_STANDARD 20)
55
set(CMAKE_CXX_STANDARD_REQUIRED True)
66
set(CMAKE_CXX_EXTENSIONS OFF)
7+
set(CMAKE_C_STANDARD 11)
78

89
# Define the library
910
add_library(librecomp STATIC
@@ -46,11 +47,13 @@ target_include_directories(librecomp PRIVATE
4647
"${CMAKE_CURRENT_SOURCE_DIR}/include/librecomp"
4748
)
4849

49-
target_compile_options(librecomp PRIVATE
50-
# -Wall
51-
# -Wextra
52-
-Wno-unused-parameter
53-
)
50+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
51+
target_compile_options(librecomp PRIVATE
52+
# -Wall
53+
# -Wextra
54+
-Wno-unused-parameter
55+
)
56+
endif()
5457

5558
if (WIN32)
5659
add_compile_definitions(NOMINMAX)

librecomp/include/librecomp/rsp_vu_impl.hpp

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,12 @@ using u32 = uint32_t;
3636
#define DIVOUT vpu.divout
3737
#define DIVDP vpu.divdp
3838

39+
#ifdef _MSC_VER
40+
#define COUNT_LEADING_ZEROES __lzcnt
41+
#else
42+
#define COUNT_LEADING_ZEROES __builtin_clz
43+
#endif
44+
3945
auto RSP::r128::operator()(u32 index) const -> r128 {
4046
if constexpr (Accuracy::RSP::SISD) {
4147
r128 v{ *this };
@@ -1348,7 +1354,7 @@ auto RSP::VRCP(r128& vd, u8 de, cr128& vt) -> void {
13481354
} else if (input == -32768) {
13491355
result = 0xffff'0000;
13501356
} else {
1351-
u32 shift = __builtin_clz(data);
1357+
u32 shift = COUNT_LEADING_ZEROES(data);
13521358
u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22;
13531359
result = rspReciprocals[index];
13541360
result = (0x10000 | result) << 14;
@@ -1400,7 +1406,7 @@ auto RSP::VRSQ(r128& vd, u8 de, cr128& vt) -> void {
14001406
} else if (input == -32768) {
14011407
result = 0xffff'0000;
14021408
} else {
1403-
u32 shift = __builtin_clz(data);
1409+
u32 shift = COUNT_LEADING_ZEROES(data);
14041410
u32 index = (u64(data) << shift & 0x7fc0'0000) >> 22;
14051411
result = rspInverseSquareRoots[index & 0x1fe | shift & 1];
14061412
result = (0x10000 | result) << 14;

ultramodern/CMakeLists.txt

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ target_include_directories(ultramodern PUBLIC
2929
"${PROJECT_SOURCE_DIR}/../thirdparty/sse2neon"
3030
)
3131

32-
target_compile_options(ultramodern PRIVATE
33-
# -Wall
34-
# -Wextra
35-
-Wno-unused-parameter
36-
)
32+
if (NOT CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
33+
target_compile_options(ultramodern PRIVATE
34+
# -Wall
35+
# -Wextra
36+
-Wno-unused-parameter
37+
)
38+
endif()
3739

3840
if (WIN32)
3941
add_compile_definitions(NOMINMAX)

0 commit comments

Comments
 (0)