diff options
| author | Yuri Victorovich <yuri@FreeBSD.org> | 2021-04-22 15:12:26 -0700 |
|---|---|---|
| committer | Yuri Victorovich <yuri@FreeBSD.org> | 2021-04-22 15:16:46 -0700 |
| commit | c4254019d8e8aa636db96bcea5702e0a39880048 (patch) | |
| tree | f13f0d619ff6a7a8063c5c0e2c99b45210439075 /science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c | |
| parent | df8c2bb56456df2054bef0786f23521582f066af (diff) | |
science/mbdyn: Unbreak build by properly implementing get_nprocs() for FreeBSD.
It looks like it was only built for one CPU before and didn't fail.
Some change in the underlying libraries triggered the build to become
multi-CPU and it began failing because get_nprocs() wasn't available
for FreeBSD and also was't properly linked to the surrounding code.
Reported by: fallout
Diffstat (limited to 'science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c')
| -rw-r--r-- | science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c b/science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c new file mode 100644 index 000000000000..9aaa6e62bd02 --- /dev/null +++ b/science/mbdyn/files/patch-libraries_libobjs_get__nprocs.c @@ -0,0 +1,39 @@ +--- libraries/libobjs/get_nprocs.c.orig 2021-04-22 19:18:04 UTC ++++ libraries/libobjs/get_nprocs.c +@@ -39,10 +39,28 @@ + + #ifndef HAVE_GET_NPROCS + ++#if defined(__FreeBSD__) ++#include <sys/types.h> ++#include <sys/sysctl.h> ++#include <stdio.h> ++#include <stdlib.h> ++#endif ++ + /* GNU libc */ + int + get_nprocs(void) + { ++#if defined(__FreeBSD__) ++ static int name[2] = {CTL_HW, HW_NCPU}; ++ int32_t ncpu; ++ size_t size = sizeof(ncpu); ++ if (sysctl(name, sizeof(name)/sizeof(*name), &ncpu, &size, NULL, 0)) { ++ perror("unable to determine number of CPUs"); ++ abort(); ++ } ++ return (int)ncpu; ++ ++#else + #warning "pippero!!!" + #if defined(_SC_NPROCESSORS_ONLN) + /* POSIX.1. */ +@@ -65,6 +83,7 @@ get_nprocs(void) + #endif + /* we assume that there is at least one :) */ + return 1; ++#endif + } + + #endif /* HAVE_GET_NPROCS */ |
