diff options
author | Piotr Kubaj <pkubaj@FreeBSD.org> | 2021-09-12 21:06:06 +0000 |
---|---|---|
committer | Piotr Kubaj <pkubaj@FreeBSD.org> | 2021-09-12 21:06:06 +0000 |
commit | ff9319692d9e5399bc446413b48c01a60dc07db9 (patch) | |
tree | 65b4cc017e0837b4c08d66250244059efd112903 | |
parent | emulators/qemu50: fix build on powerpc (diff) |
security/masscan: fix build on powerpc*
Implement rdtsc, similar to ARM. Builds fine with clang.
-rw-r--r-- | security/masscan/Makefile | 6 | ||||
-rw-r--r-- | security/masscan/files/patch-src_smack1.c | 27 |
2 files changed, 25 insertions, 8 deletions
diff --git a/security/masscan/Makefile b/security/masscan/Makefile index 85aaa246e53d..8eb1c1fcf037 100644 --- a/security/masscan/Makefile +++ b/security/masscan/Makefile @@ -17,12 +17,6 @@ CFLAGS+= -Wno-format PLIST_FILES= bin/masscan man/man8/masscan.8.gz -.include <bsd.port.options.mk> - -.if ${ARCH} == powerpc64 || ${ARCH} == powerpc -USE_GCC= yes -.endif - do-install: ${INSTALL_PROGRAM} ${WRKSRC}/bin/masscan ${STAGEDIR}${PREFIX}/bin ${INSTALL_MAN} ${WRKSRC}/doc/masscan.8 ${STAGEDIR}${MANPREFIX}/man/man8 diff --git a/security/masscan/files/patch-src_smack1.c b/security/masscan/files/patch-src_smack1.c index 8a5448fd62dc..909d256435cf 100644 --- a/security/masscan/files/patch-src_smack1.c +++ b/security/masscan/files/patch-src_smack1.c @@ -1,6 +1,6 @@ --- src/smack1.c.orig 2021-01-31 09:13:30 UTC +++ src/smack1.c -@@ -119,8 +119,7 @@ +@@ -119,9 +119,8 @@ #elif defined(__FreeBSD__) #include <sys/types.h> #include <machine/cpufunc.h> @@ -10,12 +10,35 @@ unsigned long long rdtsc(void) { uint32_t pmccntr; -@@ -138,6 +137,10 @@ unsigned long long rdtsc(void) + uint32_t pmuseren; +@@ -138,6 +137,32 @@ unsigned long long rdtsc(void) } return 0; } +#elif defined(__aarch64__) +#define __rdtsc() 0 ++#elif defined(__powerpc64__) ++unsigned long long __rdtsc(void) ++{ ++ unsigned long long rval; ++ __asm__ __volatile__("mfspr %%r3, 268": "=r" (rval)); ++ return rval; ++} ++#elif defined(__powerpc__) ++unsigned long long __rdtsc(void) ++{ ++ unsigned int tmp; ++ union { unsigned long long complete; unsigned int part[2]; } ticks; ++ __asm__ ("0:" ++ "mftbu %[hi32]\n" ++ "mftb %[lo32]\n" ++ "mftbu %[tmp]\n" ++ "cmpw %[tmp],%[hi32]\n" ++ "bne 0b\n" ++ : [hi32] "=r"(ticks.part[0]), [lo32] "=r"(ticks.part[1]), ++ [tmp] "=r"(tmp)); ++ return ticks.complete; ++} +#else +#define __rdtsc rdtsc #endif |