git: c7fe2fd1f660 - main - math/elpa: Unbreak on systems prior to 13.1

From: Yuri Victorovich <yuri_at_FreeBSD.org>
Date: Mon, 18 Jul 2022 06:52:39 UTC
The branch main has been updated by yuri:

URL: https://cgit.FreeBSD.org/ports/commit/?id=c7fe2fd1f66075a31d5b02046fea9e5ef583f2f6

commit c7fe2fd1f66075a31d5b02046fea9e5ef583f2f6
Author:     Yuri Victorovich <yuri@FreeBSD.org>
AuthorDate: 2022-07-18 05:21:33 +0000
Commit:     Yuri Victorovich <yuri@FreeBSD.org>
CommitDate: 2022-07-18 06:52:35 +0000

    math/elpa: Unbreak on systems prior to 13.1
    
    sched_getcpu() and sched_getaffinity() were added in 13.1
    but the code used them unconditionally.
    
    Reported by:    build failure
---
 math/elpa/Makefile                                    |  1 +
 .../files/patch-src_helpers_check__thread__affinity.c | 19 +++++++++++++++++--
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/math/elpa/Makefile b/math/elpa/Makefile
index bce7ed9c98b6..4be23de3c3c6 100644
--- a/math/elpa/Makefile
+++ b/math/elpa/Makefile
@@ -23,6 +23,7 @@ CONFIGURE_ARGS=	--disable-avx --disable-avx2 --disable-avx512 --disable-static \
 		--disable-c-tests
 
 CFLAGS+=	-I${WRKSRC} -I${WRKSRC}/private_modules
+CFLAGS+=	-DFREEBSD_OSVERSION=${OSVERSION}
 FCFLAGS+=	-I${WRKSRC} -I${WRKSRC}/private_modules
 LDFLAGS+=	-lutil
 
diff --git a/math/elpa/files/patch-src_helpers_check__thread__affinity.c b/math/elpa/files/patch-src_helpers_check__thread__affinity.c
index 40db36a7cd7d..5561d206753e 100644
--- a/math/elpa/files/patch-src_helpers_check__thread__affinity.c
+++ b/math/elpa/files/patch-src_helpers_check__thread__affinity.c
@@ -1,6 +1,6 @@
 --- src/helpers/check_thread_affinity.c.orig	2021-11-16 11:26:03 UTC
 +++ src/helpers/check_thread_affinity.c
-@@ -47,11 +47,14 @@
+@@ -47,29 +47,41 @@
  //
  // Author: Andreas Marek, MPCDF
  
@@ -15,12 +15,21 @@
 +#include <sys/cpuset.h>
  #include <unistd.h>
  
++#if FREEBSD_OSVERSION >= 1301000
++#  define HAVE_SCHED_FUNCS // sched_getcpu() and sched_getaffinity() were added in 13.1
++#endif
  
-@@ -60,11 +63,11 @@ void get_thread_affinity(int *cpu_id) {
+ void get_thread_affinity(int *cpu_id) {
++#if defined(HAVE_SCHED_FUNCS)
+   *cpu_id = sched_getcpu();
++#else
++  *cpu_id = 0;
++#endif
  }
  
  void get_process_affinity(int cpu_id) {
 -  cpu_set_t set;
++#if defined(HAVE_SCHED_FUNCS)
 +  cpuset_t set;
    int ret, i;
    int cpu;
@@ -30,3 +39,9 @@
    for (i=0; i < CPU_SETSIZE; i++)
      {
        cpu = CPU_ISSET(i, &set);
+       if (cpu == 1) { cpu_id = i; }
+     }
++#endif
+ }
+ 
+ void get_process_id(int *process_id, int *pprocess_id) {