Commit Graph

17 Commits

Author SHA1 Message Date
cousine
0e89998ee4 Add new mode to other platforms and indicate mac only support in README 2016-02-10 17:38:11 +02:00
Jasper Lievisse Adriaanse
52540329e5 Switch to using uvmexp which is the prefered way of retrieving memory information
Also fixup some page shifting and casting issues which led to incorrect
amounts of memory being displayed. This also fixes a crash with --colors (#20)
2015-03-01 13:45:31 +01:00
Pawel "l0ner" Soltys
87cc9b1ce8 Code Refactoring part 2: unified load_string() function on all platforms
All the platforms were using identical logic based on getloadavg() function to
get the load avg stats (except linux, which was using sinfo struct, but can use getloadavg() function). I've noticed this while working on NetBSD port.

Also: fixed a typo on freebsd.
2015-02-19 21:26:35 +01:00
Pawel "l0ner" Soltys
240752d800 Code Refactornig
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.
2015-02-19 19:47:45 +01:00
Pawel "l0ner" Soltys
1512a0bda0 NetBSD port.
NetBSD port shares with FreeBSD:
 - load_string()
 - getsysctl()

With OpenBSD:
 - error()
2015-02-16 23:29:27 +01:00
Pawel "l0ner" Soltys
91594b7a5a Use u_long for storing cpu stats instead of detecting architecture
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.
2015-02-16 18:38:21 +01:00
Pawel "l0ner" Soltys
80d70b7a4d fix for cpu systctl failing on 64 bit OpenBSD
On 64bit system KERN_CPTIME systctl gets returned as 64bit uint.
On 32bit system it's returned as 32bit uint. This is not documented anywhere
(or maybe I've missed it). I've added preprocessor test for 64bit system.
2015-02-12 20:00:30 +01:00
Pawel "l0ner" Soltys
d21be2b87c openbsd: use unsigned ints to store cpu stats 2015-02-01 17:29:04 +01:00
Pawel "l0ner" Soltys
a727edef8f Openbsd: output error message on error 2015-02-01 17:10:52 +01:00
Pawel "l0ner" Soltys
33eac9d16d openbsd: changed cpu stats errors 2015-02-01 17:09:21 +01:00
Pawel "l0ner" Soltys
c052f58eab Workaround for compilation on OpenBSD 5.6
On OpenBSD 5.6 sys/ucred.h uses NGROUP define, but misses include to
sys/param.h in which NGROUP is defined. sys/ucred.h is included in
sys/mount.h which we need to get the cached ram. Because of this include
chain our compilation will fail with missing NGROUP define. This can be
resolved by including in our code (and in correct order) system headers.
2015-01-26 20:25:00 +01:00
Pawel "l0ner" Soltys
d516985146 fix missing headers on OpenBSD 2015-01-21 13:43:42 +01:00
Pawel "l0ner" Soltys
9bd9e79d36 Strip unnecessary whitespaces 2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
3e7ce96903 removed junk, reindentation to adhere to style guidelines 2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
580b076b79 OpenBSD: missing headers, typos
cpu.h: underscores in get_cpu_count()
load.cc: underscores in get_cpu_count(), typos
memory.cc: missing headers
2015-01-20 15:03:49 +01:00
Pawel "l0ner" Soltys
112004f3db FreeBSD and OpenBSD ports
- 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
2015-01-20 15:03:48 +01:00
Pawel "l0ner" Soltys
8afed01977 Openbsd port. Should work. 2015-01-20 15:02:47 +01:00