diff --git a/benchmarks/libcpucycles/Makefile b/benchmarks/libcpucycles/Makefile index 4ed732450f6e..d77797b1a73b 100644 --- a/benchmarks/libcpucycles/Makefile +++ b/benchmarks/libcpucycles/Makefile @@ -1,40 +1,40 @@ PORTNAME= libcpucycles DISTVERSION= 20240318 -PORTREVISION= 1 +PORTREVISION= 2 CATEGORIES= benchmarks devel MASTER_SITES= https://cpucycles.cr.yp.to/ MAINTAINER= fuz@FreeBSD.org COMMENT= Microlibrary for counting CPU cycles WWW= https://cpucycles.cr.yp.to/ LICENSE= PD USES= python:build shebangfix USE_LDCONFIG= yes SHEBANG_FILES= configure scripts-build/* HAS_CONFIGURE= yes CONFIGURE_ARGS= --host=${ARCH} ALL_TARGET= default CFLAGS+= -fPIC -fwrapv -fvisibility=hidden _STAGE= ${WRKSRC}/build/0/package pre-configure: ${ECHO} ${CC} ${CPPFLAGS} ${CFLAGS} ${LDFLAGS} >${WRKSRC}/compilers/default # no staging support for some reason do-install: ${INSTALL_MAN} ${_STAGE}/man/man1/cpucycles-info.1 ${STAGEDIR}${PREFIX}/share/man/man1/ ${INSTALL_MAN} ${_STAGE}/man/man3/cpucycles.3 ${STAGEDIR}${PREFIX}/share/man/man3/ ${INSTALL_DATA} ${_STAGE}/include/cpucycles.h ${STAGEDIR}${PREFIX}/include/ for lib in ${_STAGE}/lib/libcpucycles* ; \ do \ ${INSTALL_LIB} $$lib ${STAGEDIR}${PREFIX}/lib/ ; \ done ${INSTALL_PROGRAM} ${_STAGE}/bin/cpucycles-info ${STAGEDIR}${PREFIX}/bin/ do-test: ${SETENVI} LD_LIBRARY_PATH=${STAGEDIR}${PREFIX}/lib ${STAGEDIR}${PREFIX}/bin/cpucycles-info .include diff --git a/benchmarks/libcpucycles/files/patch-cpucycles_wrapper.c b/benchmarks/libcpucycles/files/patch-cpucycles_wrapper.c index 40c74c029cd0..703b4a0763c3 100644 --- a/benchmarks/libcpucycles/files/patch-cpucycles_wrapper.c +++ b/benchmarks/libcpucycles/files/patch-cpucycles_wrapper.c @@ -1,11 +1,54 @@ ---- cpucycles/wrapper.c.orig 2024-10-29 18:59:34 UTC +--- cpucycles/wrapper.c.orig 2024-03-18 00:15:33 UTC +++ cpucycles/wrapper.c -@@ -26,7 +26,7 @@ void cpucycles_tracesetup(void) +@@ -16,6 +16,12 @@ + #include + #include + #include ++ ++#ifdef __FreeBSD__ ++#include ++#include ++#endif ++ + #include "cpucycles.h" + #include "cpucycles_internal.h" + +@@ -26,7 +32,7 @@ void cpucycles_tracesetup(void) tracesetup = 1; } -static jmp_buf crash_jmp; +static sigjmp_buf crash_jmp; static void crash(int s) { +@@ -81,6 +87,21 @@ static double osfreq(void) + if (s > 0) return result; + } + ++#ifdef __FreeBSD__ ++ { ++ int freq; ++ size_t len = sizeof freq; ++ char *freqctl; ++ ++ if (asprintf(&freqctl, "dev.cpu.%d.freq", sched_getcpu())) { ++ if (sysctlbyname(freqctl, &freq, &len, NULL, 0) == 0) { ++ free(freqctl); ++ return 1e6 * freq; ++ } else ++ free(freqctl); ++ } ++ } ++#else + f = fopen("/sys/devices/system/cpu/cpu0/cpufreq/scaling_setspeed", "r"); + if (f) { + s = fscanf(f,"%lf",&result); +@@ -163,6 +184,7 @@ static double osfreq(void) + pclose(f); + if (result) return 1000000.0 * result; + } ++#endif /* defined(__FreeBSD__) */ + + x = getenv("cpucyclespersecond"); + if (x) {