7 Commits
3.2.1 ... main

Author SHA1 Message Date
eebd5e8517 add rpi model 3b+ to tested list 2022-06-10 20:19:39 +03:00
7044d546ea rename ui names for cpu freq/temp 2022-06-10 20:14:06 +03:00
765e3de1e7 fix temp meter duplication 2022-06-10 20:12:16 +03:00
637550ed51 disclaimer 2022-06-07 20:14:57 +03:00
fc016ae780 new screenshot 2022-06-07 22:36:05 +03:00
36260b5814 CPU Temperature and Frequency meter for Linux platform 2022-06-07 22:16:47 +03:00
611ea4606f Prevent null pointer dereference on early error
If a fatal error occurs before CRT_init has been called, CRT_done
dereferences NULL in CRT_colors.

Simply check if CRT_crashSettings is not NULL, which is eventually
set when CRT_init has been called.

If it is not set, then do not try to disable ncurses.

Proof of Concept (on Linux):

$ ./configure --with-proc=/var/empty
$ make
$ ./htop
2022-06-03 20:11:24 +02:00
12 changed files with 1989 additions and 1439 deletions

1671
CRT.c

File diff suppressed because it is too large Load Diff

34
CRT.h
View File

@ -15,8 +15,8 @@ in the source distribution for its full text.
#include "ProvideCurses.h" #include "ProvideCurses.h"
#include "Settings.h" #include "Settings.h"
typedef enum TreeStr_
typedef enum TreeStr_ { {
TREE_STR_VERT, TREE_STR_VERT,
TREE_STR_RTEE, TREE_STR_RTEE,
TREE_STR_BEND, TREE_STR_BEND,
@ -28,7 +28,8 @@ typedef enum TreeStr_ {
LAST_TREE_STR LAST_TREE_STR
} TreeStr; } TreeStr;
typedef enum ColorScheme_ { typedef enum ColorScheme_
{
COLORSCHEME_DEFAULT, COLORSCHEME_DEFAULT,
COLORSCHEME_MONOCHROME, COLORSCHEME_MONOCHROME,
COLORSCHEME_BLACKONWHITE, COLORSCHEME_BLACKONWHITE,
@ -39,7 +40,8 @@ typedef enum ColorScheme_ {
LAST_COLORSCHEME LAST_COLORSCHEME
} ColorScheme; } ColorScheme;
typedef enum ColorElements_ { typedef enum ColorElements_
{
RESET_COLOR, RESET_COLOR,
DEFAULT_COLOR, DEFAULT_COLOR,
FUNCTION_BAR, FUNCTION_BAR,
@ -64,6 +66,8 @@ typedef enum ColorElements_ {
METER_VALUE_WARN, METER_VALUE_WARN,
LED_COLOR, LED_COLOR,
UPTIME, UPTIME,
TEMP,
FREQ,
BATTERY, BATTERY,
TASKS_RUNNING, TASKS_RUNNING,
SWAP, SWAP,
@ -148,24 +152,24 @@ typedef enum ColorElements_ {
LAST_COLORELEMENT LAST_COLORELEMENT
} ColorElements; } ColorElements;
void CRT_fatalError(const char* note) ATTR_NORETURN; void CRT_fatalError(const char *note) ATTR_NORETURN;
#ifdef NDEBUG #ifdef NDEBUG
# define CRT_debug(...) #define CRT_debug(...)
#else #else
void CRT_debug_impl(const char* file, size_t lineno, const char* func, const char* fmt, ...) ATTR_FORMAT(printf, 4, 5); void CRT_debug_impl(const char *file, size_t lineno, const char *func, const char *fmt, ...) ATTR_FORMAT(printf, 4, 5);
# define CRT_debug(...) CRT_debug_impl(__FILE__, __LINE__, __func__, __VA_ARGS__) #define CRT_debug(...) CRT_debug_impl(__FILE__, __LINE__, __func__, __VA_ARGS__)
#endif #endif
void CRT_handleSIGSEGV(int signal) ATTR_NORETURN; void CRT_handleSIGSEGV(int signal) ATTR_NORETURN;
#define KEY_WHEELUP KEY_F(30) #define KEY_WHEELUP KEY_F(30)
#define KEY_WHEELDOWN KEY_F(31) #define KEY_WHEELDOWN KEY_F(31)
#define KEY_RECLICK KEY_F(32) #define KEY_RECLICK KEY_F(32)
#define KEY_SHIFT_TAB KEY_F(33) #define KEY_SHIFT_TAB KEY_F(33)
#define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A')) #define KEY_ALT(x) (KEY_F(64 - 26) + ((x) - 'A'))
extern const char* CRT_degreeSign; extern const char *CRT_degreeSign;
#ifdef HAVE_LIBNCURSESW #ifdef HAVE_LIBNCURSESW
@ -173,9 +177,9 @@ extern bool CRT_utf8;
#endif #endif
extern const char* const* CRT_treeStr; extern const char *const *CRT_treeStr;
extern const int* CRT_colors; extern const int *CRT_colors;
extern int CRT_cursorX; extern int CRT_cursorX;
@ -187,7 +191,7 @@ extern ColorScheme CRT_colorScheme;
void CRT_setMouse(bool enabled); void CRT_setMouse(bool enabled);
void CRT_init(const Settings* settings, bool allowUnicode); void CRT_init(const Settings *settings, bool allowUnicode);
void CRT_done(void); void CRT_done(void);

29
FreqMeter.c Normal file
View File

@ -0,0 +1,29 @@
#include "FreqMeter.h"
#include "CRT.h"
#include "Object.h"
#include "Platform.h"
#include "XUtils.h"
static const int FreqMeter_attributes[] = {
FREQ};
static void FreqMeter_updateValues(Meter *this)
{
float freq = Platform_getFreq();
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1lf GHz", freq);
}
const MeterClass FreqMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete},
.updateValues = FreqMeter_updateValues,
.defaultMode = TEXT_METERMODE,
.maxItems = 1,
.total = 100.0,
.attributes = FreqMeter_attributes,
.name = "Freq",
.uiName = "CPU Frequency",
.caption = "CPU/Frequency: "};

8
FreqMeter.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef HEADER_FreqMeter
#define HEADER_FreqMeter
#include "Meter.h"
extern const MeterClass FreqMeter_class;
#endif

View File

@ -82,6 +82,8 @@ myhtopsources = \
TasksMeter.c \ TasksMeter.c \
TraceScreen.c \ TraceScreen.c \
UptimeMeter.c \ UptimeMeter.c \
FreqMeter.c \
TempMeter.c \
UsersTable.c \ UsersTable.c \
Vector.c \ Vector.c \
XUtils.c XUtils.c
@ -144,6 +146,8 @@ myhtopheaders = \
TasksMeter.h \ TasksMeter.h \
TraceScreen.h \ TraceScreen.h \
UptimeMeter.h \ UptimeMeter.h \
FreqMeter.h \
TempMeter.h \
UsersTable.h \ UsersTable.h \
Vector.h \ Vector.h \
XUtils.h XUtils.h

135
README
View File

@ -8,7 +8,22 @@
[![Packaging status](https://repology.org/badge/tiny-repos/htop.svg)](https://repology.org/project/htop/versions) [![Packaging status](https://repology.org/badge/tiny-repos/htop.svg)](https://repology.org/project/htop/versions)
[![License: GPL v2+](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](COPYING?raw=true) [![License: GPL v2+](https://img.shields.io/badge/License-GPL%20v2+-blue.svg)](COPYING?raw=true)
![Screenshot of htop](docs/images/screenshot.png?raw=true) ![Screenshot of htop](https://i.imgur.com/dCSsvSv.png)
## **Warning!**
This fork was created for personal use; correct operation is not guaranteed.
<details>
<summary>Tested on</summary>
- Manjaro ARM Minimal (Raspberry Pi 4)
- Debian 11 (Raspberry Pi 4)
- Ubuntu Server 22.04 (Raspberry Pi 4)
- Raspbian 64bit (Raspberry Pi 3B+)
- Arch Linux (x86 PC), used for the screenshot above
</details>
## Introduction ## Introduction
@ -30,55 +45,66 @@ For more information and details visit [htop.dev](https://htop.dev).
## Build instructions ## Build instructions
### Prerequisite ### Prerequisite
List of build-time dependencies: List of build-time dependencies:
* standard GNU autotools-based C toolchain
- C99 compliant compiler - standard GNU autotools-based C toolchain
- `autoconf` - C99 compliant compiler
- `autotools` - `autoconf`
* `ncurses` - `autotools`
- `ncurses`
**Note about `ncurses`:** **Note about `ncurses`:**
> `htop` requires `ncurses` 6.0. Be aware the appropriate package is sometimes still called libncurses5 (on Debian/Ubuntu). Also `ncurses` usually comes in two flavours: > `htop` requires `ncurses` 6.0. Be aware the appropriate package is sometimes still called libncurses5 (on Debian/Ubuntu). Also `ncurses` usually comes in two flavours:
>* With Unicode support. >
>* Without Unicode support. >- With Unicode support.
>- Without Unicode support.
> >
> This is also something that is reflected in the package name on Debian/Ubuntu (via the additional 'w' - 'w'ide character support). > This is also something that is reflected in the package name on Debian/Ubuntu (via the additional 'w' - 'w'ide character support).
List of additional build-time dependencies (based on feature flags): List of additional build-time dependencies (based on feature flags):
* `sensors`
* `hwloc` - `sensors`
* `libcap` (v2.21 or later) - `hwloc`
* `libnl-3` - `libcap` (v2.21 or later)
- `libnl-3`
Install these and other required packages for C development from your package manager. Install these and other required packages for C development from your package manager.
**Debian/Ubuntu** **Debian/Ubuntu**
~~~ shell ~~~ shell
sudo apt install libncursesw5-dev autotools-dev autoconf build-essential sudo apt install libncursesw5-dev autotools-dev autoconf build-essential
~~~ ~~~
**Fedora/RHEL** **Fedora/RHEL**
~~~ shell ~~~ shell
sudo dnf install ncurses-devel automake autoconf gcc sudo dnf install ncurses-devel automake autoconf gcc
~~~ ~~~
**Archlinux/Manjaro** **Archlinux/Manjaro**
~~~ shell ~~~ shell
sudo pacman -S ncurses automake autoconf gcc sudo pacman -S ncurses automake autoconf gcc
~~~ ~~~
**macOS** **macOS**
~~~ shell ~~~ shell
brew install ncurses automake autoconf gcc brew install ncurses automake autoconf gcc
~~~ ~~~
### Compile from source: ### Compile from source
To compile from source, download from the Git repository (`git clone` or downloads from [GitHub releases](https://github.com/htop-dev/htop/releases/)), then run: To compile from source, download from the Git repository (`git clone` or downloads from [GitHub releases](https://github.com/htop-dev/htop/releases/)), then run:
~~~ shell ~~~ shell
./autogen.sh && ./configure && make ./autogen.sh && ./configure && make
~~~ ~~~
### Install ### Install
To install on the local system run `make install`. By default `make install` installs into `/usr/local`. To change this path use `./configure --prefix=/some/path`. To install on the local system run `make install`. By default `make install` installs into `/usr/local`. To change this path use `./configure --prefix=/some/path`.
### Build Options ### Build Options
@ -87,80 +113,85 @@ To install on the local system run `make install`. By default `make install` ins
#### Generic #### Generic
* `--enable-unicode`: - `--enable-unicode`:
enable Unicode support enable Unicode support
- dependency: *libncursesw* - dependency: *libncursesw*
- default: *yes* - default: *yes*
* `--enable-affinity`: - `--enable-affinity`:
enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc enable `sched_setaffinity(2)` and `sched_getaffinity(2)` for affinity support; conflicts with hwloc
- default: *check* - default: *check*
* `--enable-hwloc`: - `--enable-hwloc`:
enable hwloc support for CPU affinity; disables affinity support enable hwloc support for CPU affinity; disables affinity support
- dependency: *libhwloc* - dependency: *libhwloc*
- default: *no* - default: *no*
* `--enable-static`: - `--enable-static`:
build a static htop binary; hwloc and delay accounting are not supported build a static htop binary; hwloc and delay accounting are not supported
- default: *no* - default: *no*
* `--enable-debug`: - `--enable-debug`:
Enable asserts and internal sanity checks; implies a performance penalty Enable asserts and internal sanity checks; implies a performance penalty
- default: *no* - default: *no*
#### Performance Co-Pilot #### Performance Co-Pilot
* `--enable-pcp`: - `--enable-pcp`:
enable Performance Co-Pilot support via a new pcp-htop utility enable Performance Co-Pilot support via a new pcp-htop utility
- dependency: *libpcp* - dependency: *libpcp*
- default: *no* - default: *no*
#### Linux #### Linux
* `--enable-sensors`: - `--enable-sensors`:
enable libsensors(3) support for reading temperature data enable libsensors(3) support for reading temperature data
- dependencies: *libsensors-dev*(build-time), at runtime *libsensors* is loaded via `dlopen(3)` if available - dependencies: *libsensors-dev*(build-time), at runtime *libsensors* is loaded via `dlopen(3)` if available
- default: *check* - default: *check*
* `--enable-capabilities`: - `--enable-capabilities`:
enable Linux capabilities support enable Linux capabilities support
- dependency: *libcap* - dependency: *libcap*
- default: *check* - default: *check*
* `--with-proc`: - `--with-proc`:
location of a Linux-compatible proc filesystem location of a Linux-compatible proc filesystem
- default: */proc* - default: */proc*
* `--enable-openvz`: - `--enable-openvz`:
enable OpenVZ support enable OpenVZ support
- default: *no* - default: *no*
* `--enable-vserver`: - `--enable-vserver`:
enable VServer support enable VServer support
- default: *no* - default: *no*
* `--enable-ancient-vserver`: - `--enable-ancient-vserver`:
enable ancient VServer support (implies `--enable-vserver`) enable ancient VServer support (implies `--enable-vserver`)
- default: *no* - default: *no*
* `--enable-delayacct`: - `--enable-delayacct`:
enable Linux delay accounting support enable Linux delay accounting support
- dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3* - dependencies: *pkg-config*(build-time), *libnl-3* and *libnl-genl-3*
- default: *check* - default: *check*
## Runtime dependencies
## Runtime dependencies:
`htop` has a set of fixed minimum runtime dependencies, which is kept as minimal as possible: `htop` has a set of fixed minimum runtime dependencies, which is kept as minimal as possible:
* `ncurses` libraries for terminal handling (wide character support).
### Runtime optional dependencies: - `ncurses` libraries for terminal handling (wide character support).
### Runtime optional dependencies
`htop` has a set of fixed optional dependencies, depending on build/configure option used: `htop` has a set of fixed optional dependencies, depending on build/configure option used:
#### Linux #### Linux
* `libdl`, if not building a static binary, is always required when support for optional dependencies (i.e. `libsensors`, `libsystemd`) is present.
* `libcap`, user-space interfaces to POSIX 1003.1e capabilities, is always required when `--enable-capabilities` was used to configure `htop`. - `libdl`, if not building a static binary, is always required when support for optional dependencies (i.e. `libsensors`, `libsystemd`) is present.
* `libsensors`, readout of temperatures and CPU speeds, is optional even when `--enable-sensors` was used to configure `htop`. - `libcap`, user-space interfaces to POSIX 1003.1e capabilities, is always required when `--enable-capabilities` was used to configure `htop`.
* `libsystemd` is optional when `--enable-static` was not used to configure `htop`. If building statically and `libsystemd` is not found by `configure`, support for the systemd meter is disabled entirely. - `libsensors`, readout of temperatures and CPU speeds, is optional even when `--enable-sensors` was used to configure `htop`.
- `libsystemd` is optional when `--enable-static` was not used to configure `htop`. If building statically and `libsystemd` is not found by `configure`, support for the systemd meter is disabled entirely.
`htop` checks for the availability of the actual runtime libraries as `htop` runs. `htop` checks for the availability of the actual runtime libraries as `htop` runs.
#### BSD #### BSD
On most BSD systems `kvm` is a requirement to read kernel information. On most BSD systems `kvm` is a requirement to read kernel information.
More information on required and optional dependencies can be found in [configure.ac](configure.ac). More information on required and optional dependencies can be found in [configure.ac](configure.ac).
## Usage ## Usage
See the manual page (`man htop`) or the help menu (**F1** or **h** inside `htop`) for a list of supported key commands. See the manual page (`man htop`) or the help menu (**F1** or **h** inside `htop`) for a list of supported key commands.
## Support ## Support

File diff suppressed because it is too large Load Diff

29
TempMeter.c Normal file
View File

@ -0,0 +1,29 @@
#include "TempMeter.h"
#include "CRT.h"
#include "Object.h"
#include "Platform.h"
#include "XUtils.h"
static const int TempMeter_attributes[] = {
TEMP};
static void TempMeter_updateValues(Meter *this)
{
float temp_c = Platform_getTemp();
xSnprintf(this->txtBuffer, sizeof(this->txtBuffer), "%.1lf °C", temp_c);
}
const MeterClass TempMeter_class = {
.super = {
.extends = Class(Meter),
.delete = Meter_delete},
.updateValues = TempMeter_updateValues,
.defaultMode = TEXT_METERMODE,
.maxItems = 1,
.total = 100.0,
.attributes = TempMeter_attributes,
.name = "Temp",
.uiName = "CPU Temperature",
.caption = "CPU/Temperature: "};

8
TempMeter.h Normal file
View File

@ -0,0 +1,8 @@
#ifndef HEADER_TempMeter
#define HEADER_TempMeter
#include "Meter.h"
extern const MeterClass TempMeter_class;
#endif

View File

@ -17,60 +17,61 @@ in the source distribution for its full text.
#include "Compat.h" #include "Compat.h"
#include "Macros.h" #include "Macros.h"
void fail(void) ATTR_NORETURN; void fail(void) ATTR_NORETURN;
void* xMalloc(size_t size) ATTR_ALLOC_SIZE1(1) ATTR_MALLOC; void *xMalloc(size_t size) ATTR_ALLOC_SIZE1(1) ATTR_MALLOC;
void* xMallocArray(size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(1, 2) ATTR_MALLOC; void *xMallocArray(size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(1, 2) ATTR_MALLOC;
void* xCalloc(size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(1, 2) ATTR_MALLOC; void *xCalloc(size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(1, 2) ATTR_MALLOC;
void* xRealloc(void* ptr, size_t size) ATTR_ALLOC_SIZE1(2); void *xRealloc(void *ptr, size_t size) ATTR_ALLOC_SIZE1(2);
void* xReallocArray(void* ptr, size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(2, 3); void *xReallocArray(void *ptr, size_t nmemb, size_t size) ATTR_ALLOC_SIZE2(2, 3);
void* xReallocArrayZero(void* ptr, size_t prevmemb, size_t newmemb, size_t size) ATTR_ALLOC_SIZE2(3, 4); void *xReallocArrayZero(void *ptr, size_t prevmemb, size_t newmemb, size_t size) ATTR_ALLOC_SIZE2(3, 4);
/* /*
* String_startsWith gives better performance if strlen(match) can be computed * String_startsWith gives better performance if strlen(match) can be computed
* at compile time (e.g. when they are immutable string literals). :) * at compile time (e.g. when they are immutable string literals). :)
*/ */
static inline bool String_startsWith(const char* s, const char* match) { static inline bool String_startsWith(const char *s, const char *match)
{
return strncmp(s, match, strlen(match)) == 0; return strncmp(s, match, strlen(match)) == 0;
} }
bool String_contains_i(const char* s1, const char* s2, bool multi); bool String_contains_i(const char *s1, const char *s2, bool multi);
static inline bool String_eq(const char* s1, const char* s2) { static inline bool String_eq(const char *s1, const char *s2)
{
return strcmp(s1, s2) == 0; return strcmp(s1, s2) == 0;
} }
char* String_cat(const char* s1, const char* s2) ATTR_MALLOC; char *String_cat(const char *s1, const char *s2) ATTR_MALLOC;
char* String_trim(const char* in) ATTR_MALLOC; char *String_trim(const char *in) ATTR_MALLOC;
char** String_split(const char* s, char sep, size_t* n); char **String_split(const char *s, char sep, size_t *n);
void String_freeArray(char** s); void String_freeArray(char **s);
char* String_readLine(FILE* fd) ATTR_MALLOC; char *String_readLine(FILE *fd) ATTR_MALLOC;
/* Always null-terminates dest. Caller must pass a strictly positive size. */ /* Always null-terminates dest. Caller must pass a strictly positive size. */
size_t String_safeStrncpy(char* restrict dest, const char* restrict src, size_t size); size_t String_safeStrncpy(char *restrict dest, const char *restrict src, size_t size);
ATTR_FORMAT(printf, 2, 3) ATTR_FORMAT(printf, 2, 3)
int xAsprintf(char** strp, const char* fmt, ...); int xAsprintf(char **strp, const char *fmt, ...);
ATTR_FORMAT(printf, 3, 4) ATTR_FORMAT(printf, 3, 4)
int xSnprintf(char* buf, size_t len, const char* fmt, ...); int xSnprintf(char *buf, size_t len, const char *fmt, ...);
char* xStrdup(const char* str) ATTR_NONNULL ATTR_MALLOC; char *xStrdup(const char *str) ATTR_NONNULL ATTR_MALLOC;
void free_and_xStrdup(char** ptr, const char* str); void free_and_xStrdup(char **ptr, const char *str);
char* xStrndup(const char* str, size_t len) ATTR_NONNULL ATTR_MALLOC; char *xStrndup(const char *str, size_t len) ATTR_NONNULL ATTR_MALLOC;
ssize_t xReadfile(const char* pathname, void* buffer, size_t count); ssize_t xReadfile(const char *pathname, void *buffer, size_t count);
ssize_t xReadfileat(openat_arg_t dirfd, const char* pathname, void* buffer, size_t count); ssize_t xReadfileat(openat_arg_t dirfd, const char *pathname, void *buffer, size_t count);
#endif #endif

File diff suppressed because it is too large Load Diff

View File

@ -34,10 +34,9 @@ in the source distribution for its full text.
/* GNU/Hurd does not have PATH_MAX in limits.h */ /* GNU/Hurd does not have PATH_MAX in limits.h */
#ifndef PATH_MAX #ifndef PATH_MAX
#define PATH_MAX 4096 #define PATH_MAX 4096
#endif #endif
extern const ScreenDefaults Platform_defaultScreens[]; extern const ScreenDefaults Platform_defaultScreens[];
extern const unsigned int Platform_numberOfDefaultScreens; extern const unsigned int Platform_numberOfDefaultScreens;
@ -46,90 +45,98 @@ extern const SignalItem Platform_signals[];
extern const unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
extern const MeterClass* const Platform_meterTypes[]; extern const MeterClass *const Platform_meterTypes[];
bool Platform_init(void); bool Platform_init(void);
void Platform_done(void); void Platform_done(void);
extern bool Running_containerized; extern bool Running_containerized;
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action *keys);
int Platform_getUptime(void); int Platform_getUptime(void);
void Platform_getLoadAverage(double* one, double* five, double* fifteen); float Platform_getTemp(void);
float Platform_getFreq(void);
void Platform_getLoadAverage(double *one, double *five, double *fifteen);
int Platform_getMaxPid(void); int Platform_getMaxPid(void);
double Platform_setCPUValues(Meter* this, unsigned int cpu); double Platform_setCPUValues(Meter *this, unsigned int cpu);
void Platform_setMemoryValues(Meter* this); void Platform_setMemoryValues(Meter *this);
void Platform_setSwapValues(Meter* this); void Platform_setSwapValues(Meter *this);
void Platform_setZramValues(Meter* this); void Platform_setZramValues(Meter *this);
void Platform_setZfsArcValues(Meter* this); void Platform_setZfsArcValues(Meter *this);
void Platform_setZfsCompressedArcValues(Meter* this); void Platform_setZfsCompressedArcValues(Meter *this);
char* Platform_getProcessEnv(pid_t pid); char *Platform_getProcessEnv(pid_t pid);
char* Platform_getInodeFilename(pid_t pid, ino_t inode); char *Platform_getInodeFilename(pid_t pid, ino_t inode);
FileLocks_ProcessData* Platform_getProcessLocks(pid_t pid); FileLocks_ProcessData *Platform_getProcessLocks(pid_t pid);
void Platform_getPressureStall(const char* file, bool some, double* ten, double* sixty, double* threehundred); void Platform_getPressureStall(const char *file, bool some, double *ten, double *sixty, double *threehundred);
bool Platform_getDiskIO(DiskIOData* data); bool Platform_getDiskIO(DiskIOData *data);
bool Platform_getNetworkIO(NetworkIOData* data); bool Platform_getNetworkIO(NetworkIOData *data);
void Platform_getBattery(double* percent, ACPresence* isOnAC); void Platform_getBattery(double *percent, ACPresence *isOnAC);
static inline void Platform_getHostname(char* buffer, size_t size) { static inline void Platform_getHostname(char *buffer, size_t size)
{
Generic_hostname(buffer, size); Generic_hostname(buffer, size);
} }
static inline void Platform_getRelease(char** string) { static inline void Platform_getRelease(char **string)
{
*string = Generic_uname(); *string = Generic_uname();
} }
#ifdef HAVE_LIBCAP #ifdef HAVE_LIBCAP
#define PLATFORM_LONG_OPTIONS \ #define PLATFORM_LONG_OPTIONS \
{"drop-capabilities", optional_argument, 0, 160}, {"drop-capabilities", optional_argument, 0, 160},
#else #else
#define PLATFORM_LONG_OPTIONS #define PLATFORM_LONG_OPTIONS
#endif #endif
void Platform_longOptionsUsage(const char* name); void Platform_longOptionsUsage(const char *name);
CommandLineStatus Platform_getLongOption(int opt, int argc, char** argv); CommandLineStatus Platform_getLongOption(int opt, int argc, char **argv);
static inline void Platform_gettime_realtime(struct timeval* tv, uint64_t* msec) { static inline void Platform_gettime_realtime(struct timeval *tv, uint64_t *msec)
{
Generic_gettime_realtime(tv, msec); Generic_gettime_realtime(tv, msec);
} }
static inline void Platform_gettime_monotonic(uint64_t* msec) { static inline void Platform_gettime_monotonic(uint64_t *msec)
{
Generic_gettime_monotonic(msec); Generic_gettime_monotonic(msec);
} }
static inline Hashtable* Platform_dynamicMeters(void) { return NULL; } static inline Hashtable *Platform_dynamicMeters(void) { return NULL; }
static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable* table) { } static inline void Platform_dynamicMetersDone(ATTR_UNUSED Hashtable *table) {}
static inline void Platform_dynamicMeterInit(ATTR_UNUSED Meter* meter) { } static inline void Platform_dynamicMeterInit(ATTR_UNUSED Meter *meter) {}
static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter* meter) { } static inline void Platform_dynamicMeterUpdateValues(ATTR_UNUSED Meter *meter) {}
static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter* meter, ATTR_UNUSED RichString* out) { } static inline void Platform_dynamicMeterDisplay(ATTR_UNUSED const Meter *meter, ATTR_UNUSED RichString *out) {}
static inline Hashtable* Platform_dynamicColumns(void) { return NULL; } static inline Hashtable *Platform_dynamicColumns(void) { return NULL; }
static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable* table) { } static inline void Platform_dynamicColumnsDone(ATTR_UNUSED Hashtable *table) {}
static inline const char* Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; } static inline const char *Platform_dynamicColumnInit(ATTR_UNUSED unsigned int key) { return NULL; }
static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process* proc, ATTR_UNUSED RichString* str, ATTR_UNUSED unsigned int key) { return false; } static inline bool Platform_dynamicColumnWriteField(ATTR_UNUSED const Process *proc, ATTR_UNUSED RichString *str, ATTR_UNUSED unsigned int key) { return false; }
#endif #endif