Commit Graph

96 Commits

Author SHA1 Message Date
Christian Göttsche 436808ff99 Use RichString_appendnAscii where possible
`RichString_appendnAscii()` avoids a `strlen(3)` call over
` RichString_appendAscii()`.
Use the former where the length is available from a previous checked
`snprintf(3)` call.

Keep `RichString_appendAscii()` when passing a string literal and
rely on compilers to optimize the `strlen(3)` call away.
2021-04-26 17:51:45 +02:00
Christian Göttsche a11d01568c Use unsigned types for CPU counts and associated variables 2021-03-19 23:30:54 +01:00
Daniel Lange 9a893b9a07 Merge branch 'richstring_memset' of cgzones/htop 2021-03-19 09:58:04 +01:00
Graham Inggs ee97916fd5
Merge pull request #436 from cgzones/freebsd
FreeBSD: add support for CPU frequency and temperature
Tested on two physical systems running FreeBSD 12.1
2021-03-18 14:03:51 +02:00
Christian Göttsche 1e806f9899 RichString: do not unnecessarily clean whole buffer
The local stack buffer does not need to be cleaned to zeros when
  - just initialized, cause the length is set to 0 and the first
    character is set to '\0', so all printing functions will safely stop
  - no further used, i.e. the variable goes out of scope
2021-03-17 15:54:17 +01:00
Christian Göttsche 23797e730e CPUMeter_init: compactify branches 2021-03-12 17:43:23 +01:00
Christian Göttsche b862e36ee7 Separate data-update and drawing of header 2021-03-04 23:57:45 +01:00
Christian Göttsche 2d1042adb3 Save text buffer in Meter 2021-03-04 23:57:45 +01:00
Christian Göttsche fd2a0cf421 FreeBSD: add support for CPU frequency and temperature 2021-02-05 16:32:25 +01:00
Christian Göttsche d72b0a682e Mark several non-modified pointer variables const 2021-01-11 20:12:34 +01:00
Christian Göttsche 22da57d621 CPUMeter: drop minimum width of CPU usage in bar mode
The usage percentage is the first text, no need to set a minimum width.
The BarMeter does already add padding.
2020-12-20 16:55:17 +01:00
Christian Göttsche 157086e750 Split RichString_(append|appendn|write) into wide and ascii
RichString_writeFrom takes a top spot during performance analysis due to the
calls to mbstowcs() and iswprint().

Most of the time we know in advance that we are only going to print regular
ASCII characters.
2020-12-08 20:58:40 +01:00
Christian Göttsche e1ce141bc3 Use size_t as len type for Meter_UpdateValues
Most of the time the parameter is passed to snprintf type functions
2020-12-06 16:03:44 +01:00
Christian Göttsche b76eaf187a Dynamically load libsensors at runtime 2020-12-02 21:03:24 +01:00
Christian Goettsche f5c3349bdb IWYU update (FreeBSD) 2020-11-19 23:51:50 +01:00
Christian Göttsche 7cf5277594 IWYU update (Linux) 2020-11-19 23:51:50 +01:00
Christian Göttsche 1b225cd7a0 Show CPU temperature in CPU meter
Show the CPU temperature in the CPU meter, like CPU frequency, instead
of using an extra Meter.
2020-11-16 16:38:54 +01:00
Benny Baumann 45869513bf Embracing branches 2020-11-02 22:15:01 +01:00
Benny Baumann 61e14d4bb2 Spacing around operators 2020-11-02 22:15:01 +01:00
Christian Göttsche 43d274a617 Use integer type for item count instead of char 2020-10-31 18:36:55 +01:00
Benny Baumann 0f5262917f Make all required includes explicit
Information as seen by IWYU 0.12 + clang 9 on Linux
2020-10-18 20:09:05 +02:00
Benny Baumann 872e542f4e Rename StringUtils.[ch] to XUtils.[ch] 2020-10-16 20:30:21 +02:00
Benny Baumann c6f04a9c5d Move xAsprintf, xSnprintf and xStrdup to StringUtils.h 2020-10-16 20:29:45 +02:00
Christian Göttsche 9f5b50edd7 CPUMeter: avoid crashes and leaks in case the CPU count changes
E.g. if the HT/SMT mode changes

Use separate data for sub-meters
Do not reuse drawData for maintainability
2020-10-12 13:15:23 +02:00
Christian Göttsche 79ad39c718 Mark Object pointer to _display function const 2020-10-10 11:25:19 +02:00
Christian Göttsche ba282cfe19 Mark Object instances const 2020-10-07 13:01:53 +02:00
Christian Göttsche 08d85e6143 Mark Object classes and Object class fields const 2020-10-07 13:01:53 +02:00
Daniel Lange 079c2abf8e Update License consistently to GPLv2 as per COPYING file 2020-10-05 10:13:12 +02:00
Christian Göttsche 6db2d52261 Covert Meter attributes to file-local constant arrays 2020-09-29 10:44:42 +02:00
multi 9ee72568dc CPUMeter: add octuple-column CPU meters.
This is a straightforward extension of the existing multi-column CPU meter
code, which now allows for up CPU meters to be displayed in up to 16 columns.

This also adds the meter declarations to all the platform-specific code.
2020-09-28 14:35:35 +02:00
multi d22f6573f3 CPUMeter: refactor common CPU meter rendering code.
Instead of scanning the meter name to determine the number of columns in a
CPU meter, move the common code behind some wrapper functions, and specify the
number of columns as an explicit parameter when called from the wrappers.

While this does add a bit of code for all the necessary wrapper functions, this
should be less brittle in case of future changes to the CPU meter code.
2020-09-28 14:35:35 +02:00
Christian Göttsche edf1b10d2c Read CPU frequency from sysfs by default
Use the more portable sysfs node /sys/devices/system/cpu/cpuX/cpufreq/scaling_cur_freq
to get the CPU frequency.
In case of an error fall back to /proc/cpuinfo .

Also use a fixed width of 4 for the frequency to avoid position jumps
in case the frequency moves in the range 900-1100 MHz.
2020-09-24 20:11:28 +02:00
Benny Baumann 3c65d78d77 Update CPU freq display to use NAN on error 2020-09-24 18:06:36 +02:00
Benny Baumann ebcf924643 Use threshold for display of guest/steal/irq meters 2020-09-24 18:06:36 +02:00
Christian Hesse f805093589 align cpu id to right 2020-09-24 17:53:57 +02:00
Nathan Scott 4d6e4ef53c Merge branch 'master' of https://github.com/rgouicem/htop into rgouicem-master 2020-09-09 19:38:53 +10:00
Nathan Scott c5808c56db Consolidate repeated macro definitions into one header
The MIN, MAX, CLAMP, MINIMUM, and MAXIMUM macros appear
throughout the codebase with many re-definitions.  Make
a single copy of each in a common header file, and use
the BSD variants of MINIMUM/MAXIMUM due to conflicts in
the system <sys/param.h> headers.
2020-09-09 16:56:04 +10:00
Zev Weiss a1a027b9bd Axe automated header generation.
Reasoning:
 - implementation was unsound -- broke down when I added a fairly
   basic macro definition expanding to a struct initializer in a *.c
   file.

 - made it way too easy (e.g. via otherwise totally innocuous git
   commands) to end up with timestamps such that it always ran
   MakeHeader.py but never used its output, leading to overbuild noise
   when running what should be a null 'make'.

 - but mostly: it's just an awkward way of dealing with C code.
2020-09-03 11:58:58 -05:00
Redha Gouicem d0e8ff9319 fix unit (GHz -> MHz) 2020-08-31 14:09:22 +02:00
Redha Gouicem 0f5d2cd1e4 fixed compilation error 2020-08-31 13:32:29 +02:00
Redha Gouicem 293e3a2931 remove unused variable 2020-08-31 13:29:24 +02:00
Redha Gouicem 3ef5df25bc always display frequency in MHz 2020-08-28 12:15:32 +02:00
Nathan Scott 31391b206c Merge branch 'hishamhm-pull-1012' 2020-08-20 15:51:21 +10:00
Nathan Scott 6b443c5da9 Merge branch 'hishamhm-pull-932' 2020-08-20 14:47:07 +10:00
Nathan Scott a82fd262d7 Merge branch 'hishamhm-pull-960' 2020-08-20 14:19:53 +10:00
Nathan Scott b30c22d687 Merge branch 'hishamhm-pull-914' 2020-08-20 14:09:27 +10:00
Christoph Budziszewski b55f9320bc fixed x/y coordinate mixup 2020-06-12 23:53:05 +02:00
Christoph Budziszewski 7fdd8d3732 adding support for more than 2 smaller cpumeter columns 2020-06-11 23:21:52 +02:00
Christoph Budziszewski f74cde982f removed whitespace from end of lines 2020-06-11 23:00:16 +02:00
Daniel Flanagan dd33444f7e Clean up existing whitespace 2019-10-31 11:39:12 -05:00