Skip to content

Commit

Permalink
devel/quickcpplib: fix on 32 bit platforms
Browse files Browse the repository at this point in the history
128 bit integers are only supported on 64 bit platforms.  Test for them
using the correct feature test macro to enable the port there.

Approved by:	portmgr (build fix blanket)
MFH:		2023Q4
See also:	ned14/quickcpplib#50
  • Loading branch information
clausecker committed Oct 27, 2023
1 parent 8266a26 commit 7e25442
Show file tree
Hide file tree
Showing 2 changed files with 66 additions and 2 deletions.
3 changes: 1 addition & 2 deletions devel/quickcpplib/Makefile
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
PORTNAME= quickcpplib
DISTVERSION= g20230614
PORTREVISION= 1
CATEGORIES= devel

MAINTAINER= yuri@FreeBSD.org
Expand All @@ -9,8 +10,6 @@ WWW= https://github.com/ned14/quickcpplib
LICENSE= APACHE20
LICENSE_FILE= ${WRKSRC}/Licence.txt

BROKEN_i386= complation fails: __int128 is not supported on this target

USES= cmake:testing

USE_GITHUB= yes
Expand Down
65 changes: 65 additions & 0 deletions devel/quickcpplib/files/patch-include_quickcpplib_uint128.hpp
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
--- include/quickcpplib/uint128.hpp.orig 2023-10-24 05:06:15 UTC
+++ include/quickcpplib/uint128.hpp
@@ -53,7 +53,7 @@ namespace integers128
#if defined(__SSE2__) || defined(_M_X64) || (defined(_M_IX86_FP) && _M_IX86_FP >= 2)
__m128i as_m128i;
#endif
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
unsigned __int128 as_uint128;
#endif
//! Default constructor, no bits set
@@ -100,7 +100,7 @@ namespace integers128
}
uint128 operator+=(const uint128 &v) noexcept
{
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 += v.as_uint128;
return *this;
#endif
@@ -118,7 +118,7 @@ namespace integers128
}
uint128 operator-=(const uint128 &v) noexcept
{
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 -= v.as_uint128;
return *this;
#endif
@@ -146,7 +146,7 @@ namespace integers128
{
if(!b)
throw std::domain_error("divide by zero");
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 %= b.as_uint128;
return *this;
#endif
@@ -169,7 +169,7 @@ namespace integers128
{
if(!b)
throw std::domain_error("divide by zero");
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 %= b;
return *this;
#endif
@@ -215,7 +215,7 @@ namespace integers128
}
uint128 operator<<=(uint8_t v) noexcept
{
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 <<= v;
return *this;
#endif
@@ -232,7 +232,7 @@ namespace integers128
}
uint128 operator>>=(uint8_t v) noexcept
{
-#if defined(__GNUC__) || defined(__clang__)
+#if defined(__SIZEOF_INT128__)
as_uint128 >>= v;
return *this;
#endif

0 comments on commit 7e25442

Please sign in to comment.