FYI, in
https://lists.freebsd.org/pipermail/svn-ports-all/2015-January/082830.html
you can see the changes required to get kamailio 4.2.2 build as the freebsd port. Can you integrate those changes upstream ?
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24
Thanks for pointing out.
A clarification - that kind of define check was in two places, see next. The patch you refer to is updating on the second condition. The first one should stay?
``` #if defined (__OS_darwin) || defined (__OS_freebsd) #include <sys/param.h> #include <sys/sysctl.h> #else #include <unistd.h> #endif
int get_num_cpus() { int count = 0;
#if defined (__OS_darwin) || defined (__OS_freebsd) int nm[2]; size_t len;
```
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69491839
I only build-tested it, and only with the one condition removed.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69492290
The code was more or less found on various places on the net, here is a link I found searching now:
* http://stackoverflow.com/questions/150355/programmatically-find-the-number-o...
It is a bit old, indeed, but shows that bsd was using the same way as mac os x. I didn't have a *BSD at hand to try, though. Maybe the GNU extension with _SC_NPROCESSORS_ONLN got into *BSD, but wonder if the includes are not different, as for Linux.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69492771
The second suggestion in the stackoverflow link says to use boost. As kamailio already uses boost (?), that might be more portable ?
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69493052
Kamailio is written in C and don't want to mix it here.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69493188
Then the sysctl with HW_NCPU will do, as will the sysconf() call.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69495048
I tried to figure out if we need to adjust the condition for included files or let it as it is:
``` #if defined (__OS_darwin) || defined (__OS_freebsd) ```
A 'man sysconf' on darwin shows that it needs:
``` #include <unistd.h> ```
No *BSD around, but I guess it will be the same, therefore I think the guard for the includes needs to be updated as well. Would you have a possibility to test that it compiles?
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69498862
Same on FreeBSD: man sysconf says it needs unistd.h. So you can disable the __OS_freebsd in both cases.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69500584
Closed #24.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#event-217984186
Commits pushed to master and 4.2 branches.
--- Reply to this email directly or view it on GitHub: https://github.com/kamailio/kamailio/issues/24#issuecomment-69724499