Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in / Register
Toggle navigation
Menu
Open sidebar
adam.huang
htop
Commits
6fe06fb7
Commit
6fe06fb7
authored
Apr 06, 2018
by
Hisham Muhammad
Browse files
Portability: make list of default screens per-platform
parent
657836a2
Changes
17
Hide whitespace changes
Inline
Side-by-side
Settings.c
View file @
6fe06fb7
...
...
@@ -23,6 +23,12 @@ in the source distribution for its full text.
#include "Process.h"
#include <stdbool.h>
typedef struct {
const char* name;
const char* columns;
const char* sortKey;
} ScreenDefaults;
typedef struct {
int len;
char** names;
...
...
@@ -266,14 +272,11 @@ ScreenSettings* Settings_newScreen(Settings* this, const char* name, const char*
}
static
void
Settings_defaultScreens
(
Settings
*
this
)
{
Settings_newScreen
(
this
,
"Default"
,
"PID USER PRIORITY NICE M_SIZE M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command"
);
this
->
screens
[
0
]
->
sortKey
=
toFieldIndex
(
"PERCENT_CPU"
);
Settings_newScreen
(
this
,
"I/O"
,
"PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command"
);
this
->
screens
[
1
]
->
sortKey
=
toFieldIndex
(
"IO_RATE"
);
Settings_newScreen
(
this
,
"Perf Counters"
,
"PID USER PERCENT_CPU PROCESSOR MCYCLE MINSTR IPC PERCENT_MISS PERCENT_BMISS Command"
);
this
->
screens
[
2
]
->
sortKey
=
toFieldIndex
(
"MCYCLE"
);
Settings_newScreen
(
this
,
"L1 Data Cache"
,
"PID USER PERCENT_CPU L1DREADS L1DRMISSES L1DWRITES L1DWMISSES Command"
);
this
->
screens
[
3
]
->
sortKey
=
toFieldIndex
(
"L1DREADS"
);
for
(
unsigned
int
i
=
0
;
i
<
Platform_numberOfDefaultScreens
;
i
++
)
{
ScreenDefaults
*
defaults
=
&
Platform_defaultScreens
[
i
];
Settings_newScreen
(
this
,
defaults
->
name
,
defaults
->
columns
);
this
->
screens
[
0
]
->
sortKey
=
toFieldIndex
(
defaults
->
sortKey
);
}
}
static
bool
Settings_read
(
Settings
*
this
,
const
char
*
fileName
)
{
...
...
Settings.h
View file @
6fe06fb7
...
...
@@ -14,6 +14,12 @@ in the source distribution for its full text.
#include "Process.h"
#include <stdbool.h>
typedef
struct
{
const
char
*
name
;
const
char
*
columns
;
const
char
*
sortKey
;
}
ScreenDefaults
;
typedef
struct
{
int
len
;
char
**
names
;
...
...
darwin/Platform.c
View file @
6fe06fb7
...
...
@@ -36,7 +36,15 @@ typedef enum DarwinProcessFields {
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
ProcessField
Platform_defaultFields
[]
=
{
PID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
const
SignalItem
Platform_signals
[]
=
{
{
.
name
=
" 0 Cancel"
,
.
number
=
0
},
...
...
darwin/Platform.h
View file @
6fe06fb7
...
...
@@ -20,11 +20,14 @@ typedef enum DarwinProcessFields {
LAST_PROCESSFIELD
=
100
,
}
DarwinProcessField
;
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
extern
ProcessField
Platform_defaultFields
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
const
SignalItem
Platform_signals
[];
...
...
dragonflybsd/Platform.c
View file @
6fe06fb7
...
...
@@ -40,7 +40,15 @@ extern ProcessFieldData Process_fields[];
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
ProcessField
Platform_defaultFields
[]
=
{
PID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
int
Platform_numberOfFields
=
LAST_PROCESSFIELD
;
...
...
dragonflybsd/Platform.h
View file @
6fe06fb7
...
...
@@ -21,7 +21,9 @@ extern ProcessFieldData Process_fields[];
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
extern
ProcessField
Platform_defaultFields
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
int
Platform_numberOfFields
;
...
...
freebsd/Platform.c
View file @
6fe06fb7
...
...
@@ -39,6 +39,16 @@ extern ProcessFieldData Process_fields[];
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
ProcessField
Platform_defaultFields
[]
=
{
PID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
int
Platform_numberOfFields
=
LAST_PROCESSFIELD
;
...
...
freebsd/Platform.h
View file @
6fe06fb7
...
...
@@ -20,6 +20,10 @@ extern ProcessFieldData Process_fields[];
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
ProcessField
Platform_defaultFields
[];
extern
int
Platform_numberOfFields
;
...
...
linux/Platform.c
View file @
6fe06fb7
...
...
@@ -36,16 +36,13 @@ in the source distribution for its full text.
#include "BatteryMeter.h"
#include "LinuxProcess.h"
#include "SignalsPanel.h"
#include "Settings.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
,
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 };
int
Platform_numberOfFields
=
LAST_PROCESSFIELD
;
const
SignalItem
Platform_signals
[]
=
{
...
...
@@ -85,6 +82,31 @@ const SignalItem Platform_signals[] = {
{
.
name
=
"31 SIGSYS"
,
.
number
=
31
},
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID USER PRIORITY NICE M_SIZE M_RESIDENT M_SHARE STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
{
.
name
=
"I/O"
,
.
columns
=
"PID USER IO_PRIORITY IO_RATE IO_READ_RATE IO_WRITE_RATE PERCENT_SWAP_DELAY PERCENT_IO_DELAY Command"
,
.
sortKey
=
"IO_RATE"
,
},
{
.
name
=
"Perf Counters"
,
.
columns
=
"PID USER PERCENT_CPU PROCESSOR MCYCLE MINSTR IPC PERCENT_MISS PERCENT_BMISS Command"
,
.
sortKey
=
"MCYCLE"
,
},
{
.
name
=
"L1 Data Cache"
,
.
columns
=
"PID USER PERCENT_CPU L1DREADS L1DRMISSES L1DWRITES L1DWMISSES Command"
,
.
sortKey
=
"LD1READS"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
const
unsigned
int
Platform_numberOfSignals
=
sizeof
(
Platform_signals
)
/
sizeof
(
SignalItem
);
static
Htop_Reaction
Platform_actionSetIOPriority
(
State
*
st
)
{
...
...
linux/Platform.h
View file @
6fe06fb7
...
...
@@ -14,17 +14,20 @@ in the source distribution for its full text.
#include "BatteryMeter.h"
#include "LinuxProcess.h"
#include "SignalsPanel.h"
#include "Settings.h"
#ifndef CLAMP
#define CLAMP(x,low,high) (((x)>(high))?(high):(((x)<(low))?(low):(x)))
#endif
extern
ProcessField
Platform_defaultFields
[];
extern
int
Platform_numberOfFields
;
extern
const
SignalItem
Platform_signals
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
const
unsigned
int
Platform_numberOfSignals
;
void
Platform_setBindings
(
Htop_Action
*
keys
);
...
...
openbsd/Battery.h
View file @
6fe06fb7
...
...
@@ -12,5 +12,4 @@ in the source distribution for its full text.
void
Battery_getData
(
double
*
level
,
ACPresence
*
isOnAC
);
#endif
openbsd/Platform.c
View file @
6fe06fb7
...
...
@@ -92,7 +92,15 @@ static int percentages(int cnt, int64_t *out, int64_t *new, int64_t *old, int64_
return
(
total_change
);
}
ProcessField
Platform_defaultFields
[]
=
{
PID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
int
Platform_numberOfFields
=
LAST_PROCESSFIELD
;
...
...
openbsd/Platform.h
View file @
6fe06fb7
...
...
@@ -32,7 +32,9 @@ extern ProcessFieldData Process_fields[];
* The routine assumes modulo arithmetic. This function is especially
* useful on BSD machines for calculating cpu state percentages.
*/
extern
ProcessField
Platform_defaultFields
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
int
Platform_numberOfFields
;
...
...
solaris/Platform.c
View file @
6fe06fb7
...
...
@@ -103,7 +103,15 @@ const SignalItem Platform_signals[] = {
const
unsigned
int
Platform_numberOfSignals
=
sizeof
(
Platform_signals
)
/
sizeof
(
SignalItem
);
ProcessField
Platform_defaultFields
[]
=
{
PID
,
LWPID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID LWPID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
MeterClass
*
Platform_meterTypes
[]
=
{
&
CPUMeter_class
,
...
...
solaris/Platform.h
View file @
6fe06fb7
...
...
@@ -38,7 +38,9 @@ extern const SignalItem Platform_signals[];
extern
const
unsigned
int
Platform_numberOfSignals
;
extern
ProcessField
Platform_defaultFields
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
MeterClass
*
Platform_meterTypes
[];
...
...
unsupported/Platform.c
View file @
6fe06fb7
...
...
@@ -29,7 +29,15 @@ const SignalItem Platform_signals[] = {
const
unsigned
int
Platform_numberOfSignals
=
sizeof
(
Platform_signals
)
/
sizeof
(
SignalItem
);
ProcessField
Platform_defaultFields
[]
=
{
PID
,
USER
,
PRIORITY
,
NICE
,
M_SIZE
,
M_RESIDENT
,
STATE
,
PERCENT_CPU
,
PERCENT_MEM
,
TIME
,
COMM
,
0
};
ScreenDefaults
Platform_defaultScreens
[]
=
{
{
.
name
=
"Default"
,
.
columns
=
"PID LWPID USER PRIORITY NICE M_SIZE M_RESIDENT STATE PERCENT_CPU PERCENT_MEM TIME Command"
,
.
sortKey
=
"PERCENT_CPU"
,
},
};
const
unsigned
int
Platform_numberOfDefaultScreens
=
sizeof
(
Platform_defaultScreens
)
/
sizeof
(
ScreenDefaults
);
ProcessFieldData
Process_fields
[]
=
{
[
0
]
=
{
.
name
=
""
,
.
title
=
NULL
,
.
description
=
NULL
,
.
flags
=
0
,
},
...
...
unsupported/Platform.h
View file @
6fe06fb7
...
...
@@ -19,7 +19,9 @@ extern const SignalItem Platform_signals[];
extern
const
unsigned
int
Platform_numberOfSignals
;
extern
ProcessField
Platform_defaultFields
[];
extern
ScreenDefaults
Platform_defaultScreens
[];
extern
const
unsigned
int
Platform_numberOfDefaultScreens
;
extern
ProcessFieldData
Process_fields
[];
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment