Skip to content

Commit

Permalink
textproc/randlm: fix build on powerpc*
Browse files Browse the repository at this point in the history
rdtsc() is available only on amd64 / i386.
  • Loading branch information
pkubaj committed Feb 21, 2022
1 parent d9e5933 commit 2988f60
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 3 deletions.
1 change: 0 additions & 1 deletion textproc/randlm/Makefile
Expand Up @@ -14,7 +14,6 @@ LICENSE_FILE= ${WRKSRC}/COPYING

BROKEN_aarch64= fails to compile: invalid output constraint =a in assembler
BROKEN_armv6= fails to compile: invalid output constraint =a in assembler
BROKEN_powerpc64= fails to compile: 'itr' does not name a type
BROKEN_riscv64= fails to compile: invalid output constraint =a in assembler

BUILD_DEPENDS= ${LOCALBASE}/include/google/sparse_hash_map:devel/sparsehash
Expand Down
22 changes: 20 additions & 2 deletions textproc/randlm/files/patch-src-LDHT-Util.h
@@ -1,5 +1,5 @@
--- src/LDHT/Util.h.orig 2012-03-30 14:53:05.000000000 +0400
+++ src/LDHT/Util.h 2014-08-30 18:08:50.000000000 +0400
--- src/LDHT/Util.h.orig 2012-03-30 10:53:05 UTC
+++ src/LDHT/Util.h
@@ -10,6 +10,10 @@
#include <cstdlib>
#include <cstring>
Expand All @@ -11,3 +11,21 @@

#define V(expr) std::cerr << __FILE__ << ":" \
<< __LINE__ << " " \
@@ -43,6 +47,9 @@ class Util { (public)
static uint64_t hash(uint64_t a, uint64_t b, uint64_t P, uint8_t* e);
static uint64_t hash(uint64_t a, uint64_t b, uint64_t P, uint64_t e);
static inline uint64_t rdtsc() {
+#if defined(__powerpc__)
+ return __builtin_readcyclecounter();
+#else
uint32_t lo, hi;
__asm__ __volatile__(
"xorl %%eax,%%eax\n"
@@ -52,6 +59,7 @@ class Util { (public)
:
: "%ebx", "%ecx");
return static_cast<uint64_t>(hi) << 32 | lo;
+#endif
};
};

0 comments on commit 2988f60

Please sign in to comment.