summaryrefslogtreecommitdiffstats
path: root/linux
diff options
context:
space:
mode:
authorNathan Scott <nathans@redhat.com>2020-09-09 16:56:04 +1000
committerNathan Scott <nathans@redhat.com>2020-09-09 16:56:04 +1000
commitc5808c56db166528ae7e74cedb51cc466f973b9f (patch)
treeb0364c031595aacc8db222885bebb8390983429e /linux
parent8ec5d4a3a07fe9a3c556a4abeac6645a7bb2235e (diff)
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.
Diffstat (limited to 'linux')
-rw-r--r--linux/LinuxProcessList.c6
-rw-r--r--linux/LinuxProcessList.h4
-rw-r--r--linux/Platform.c4
-rw-r--r--linux/Platform.h4
4 files changed, 1 insertions, 17 deletions
diff --git a/linux/LinuxProcessList.c b/linux/LinuxProcessList.c
index a6fdada8..c9303a04 100644
--- a/linux/LinuxProcessList.c
+++ b/linux/LinuxProcessList.c
@@ -42,10 +42,6 @@ in the source distribution for its full text.
#include <linux/taskstats.h>
#endif
-#ifndef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-#endif
-
static ssize_t xread(int fd, void *buf, size_t count) {
// Read some bytes. Retry on EINTR and when we don't get as many bytes as we requested.
size_t alreadyRead = 0;
@@ -194,7 +190,7 @@ ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, ui
fclose(file);
- pl->cpuCount = MAX(cpus - 1, 1);
+ pl->cpuCount = MAXIMUM(cpus - 1, 1);
this->cpus = xCalloc(cpus, sizeof(CPUData));
for (int i = 0; i < cpus; i++) {
diff --git a/linux/LinuxProcessList.h b/linux/LinuxProcessList.h
index d689d4ac..aa7317ab 100644
--- a/linux/LinuxProcessList.h
+++ b/linux/LinuxProcessList.h
@@ -92,10 +92,6 @@ typedef struct LinuxProcessList_ {
#define PROC_LINE_LENGTH 4096
#endif
-#ifndef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-#endif
-
ProcessList* ProcessList_new(UsersTable* usersTable, Hashtable* pidWhiteList, uid_t userId);
void ProcessList_delete(ProcessList* pl);
diff --git a/linux/Platform.c b/linux/Platform.c
index d48dc764..ffe5c5c2 100644
--- a/linux/Platform.c
+++ b/linux/Platform.c
@@ -33,10 +33,6 @@ in the source distribution for its full text.
#include <stdlib.h>
-#ifndef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-#endif
-
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, (int)M_SHARE, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
//static ProcessField defaultIoFields[] = { PID, IO_PRIORITY, USER, IO_READ_RATE, IO_WRITE_RATE, IO_RATE, COMM, 0 };
diff --git a/linux/Platform.h b/linux/Platform.h
index 922a3392..9f0ee7fd 100644
--- a/linux/Platform.h
+++ b/linux/Platform.h
@@ -13,10 +13,6 @@ in the source distribution for its full text.
#include "LinuxProcess.h"
#include "SignalsPanel.h"
-#ifndef CLAMP
-#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
-#endif
-
extern ProcessField Platform_defaultFields[];
extern int Platform_numberOfFields;

© 2014-2024 Faster IT GmbH | imprint | privacy policy