Since the headers for cpu, memory and load functions are virtually the same for
all platforms, I've decided to move them into common/ dir and do some
refacotring:
* removed per-platform header files
* implemented get_cpu_count() function across all platforms. We are using it cpu
on every platform, yet not on every one this was implemented as a separate
function.
* removed platform detection through preprocessor from main: we don't need this
there anymore, since the headers are common for all platforms. CMake will
handle setting of correct source files for us now.
* Unified used defines for CPU states across all platforms and made linux use
them. Added some platform detection to cpu.h in order to set them correctly
across the platforms.
* moved getsysctl.h to common/ dir, since it's used on Net and Free BSD, and
thus become a common include.
As suggested to me by "Jasper Lievisse Adriaanse" in an email:
On 2015-02-16 09:02 Jasper Lievisse Adriaanse <jasper@openbsd.org> wrote:
> You can actually use 'long' instead of juggling between 64 and 32 bit return
> types. I've impemented something similiar for libgtop years ago and never had
> any issues when using 'long' for both 64 and 32 platforms. Here's the
> refernce: https://git.gnome.org/browse/libgtop/tree/sysdeps/openbsd/cpu.c#n62
This is a better idea than what I've implemented. Also this should resolve
eventual occurrence of "unable to get cpu stats" problem on 64bit platforms we
do not detect.
- Removed OpenBSD stuff from freebsd port
- Renamed bsd folder to freebsd since now it contains only
freebsd-relevant files.
- Changed CMake instructions to account for bsd port changes
- modified main source file to account for openbsd port