Mark signal tables 'const'

Specifically, Platform_signals[] and Platform_numberOfSignals. Both are
not supposed to be mutable. Marking them 'const' puts them into rodata
sections in binary. And for Platform_numberOfSignals, this aids
optimization (aids only Link Time Optimization for now). :)

Signed-off-by: Kang-Che Sung <explorer09@gmail.com>
This commit is contained in:
Explorer09 2016-08-30 20:41:17 +08:00
parent cceab15b9d
commit 1f3d85b617
10 changed files with 20 additions and 20 deletions

View File

@ -33,7 +33,7 @@ in the source distribution for its full text.
ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 }; ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };
SignalItem Platform_signals[] = { const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
{ .name = " 1 SIGHUP", .number = 1 }, { .name = " 1 SIGHUP", .number = 1 },
{ .name = " 2 SIGINT", .number = 2 }, { .name = " 2 SIGINT", .number = 2 },
@ -69,7 +69,7 @@ SignalItem Platform_signals[] = {
{ .name = "31 SIGUSR2", .number = 31 }, { .name = "31 SIGUSR2", .number = 31 },
}; };
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
ProcessFieldData Process_fields[] = { ProcessFieldData Process_fields[] = {
[0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, }, [0] = { .name = "", .title = NULL, .description = NULL, .flags = 0, },

View File

@ -22,9 +22,9 @@ in the source distribution for its full text.
extern ProcessField Platform_defaultFields[]; extern ProcessField Platform_defaultFields[];
extern SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
extern ProcessFieldData Process_fields[]; extern ProcessFieldData Process_fields[];

View File

@ -43,7 +43,7 @@ ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_R
int Platform_numberOfFields = LAST_PROCESSFIELD; int Platform_numberOfFields = LAST_PROCESSFIELD;
SignalItem Platform_signals[] = { const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
{ .name = " 1 SIGHUP", .number = 1 }, { .name = " 1 SIGHUP", .number = 1 },
{ .name = " 2 SIGINT", .number = 2 }, { .name = " 2 SIGINT", .number = 2 },
@ -80,7 +80,7 @@ SignalItem Platform_signals[] = {
{ .name = "33 SIGLIBRT", .number = 33 }, { .name = "33 SIGLIBRT", .number = 33 },
}; };
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;

View File

@ -24,9 +24,9 @@ extern ProcessField Platform_defaultFields[];
extern int Platform_numberOfFields; extern int Platform_numberOfFields;
extern SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action* keys);

View File

@ -47,7 +47,7 @@ ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_R
int Platform_numberOfFields = LAST_PROCESSFIELD; int Platform_numberOfFields = LAST_PROCESSFIELD;
SignalItem Platform_signals[] = { const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
{ .name = " 1 SIGHUP", .number = 1 }, { .name = " 1 SIGHUP", .number = 1 },
{ .name = " 2 SIGINT", .number = 2 }, { .name = " 2 SIGINT", .number = 2 },
@ -84,7 +84,7 @@ SignalItem Platform_signals[] = {
{ .name = "31 SIGSYS", .number = 31 }, { .name = "31 SIGSYS", .number = 31 },
}; };
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
static Htop_Reaction Platform_actionSetIOPriority(State* st) { static Htop_Reaction Platform_actionSetIOPriority(State* st) {
Panel* panel = st->panel; Panel* panel = st->panel;

View File

@ -23,9 +23,9 @@ extern ProcessField Platform_defaultFields[];
extern int Platform_numberOfFields; extern int Platform_numberOfFields;
extern SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action* keys);

View File

@ -99,7 +99,7 @@ int Platform_numberOfFields = LAST_PROCESSFIELD;
/* /*
* See /usr/include/sys/signal.h * See /usr/include/sys/signal.h
*/ */
SignalItem Platform_signals[] = { const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
{ .name = " 1 SIGHUP", .number = 1 }, { .name = " 1 SIGHUP", .number = 1 },
{ .name = " 2 SIGINT", .number = 2 }, { .name = " 2 SIGINT", .number = 2 },
@ -136,7 +136,7 @@ SignalItem Platform_signals[] = {
{ .name = "32 SIGTHR", .number = 32 }, { .name = "32 SIGTHR", .number = 32 },
}; };
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); const unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem);
void Platform_setBindings(Htop_Action* keys) { void Platform_setBindings(Htop_Action* keys) {
(void) keys; (void) keys;

View File

@ -39,9 +39,9 @@ extern int Platform_numberOfFields;
/* /*
* See /usr/include/sys/signal.h * See /usr/include/sys/signal.h
*/ */
extern SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
void Platform_setBindings(Htop_Action* keys); void Platform_setBindings(Htop_Action* keys);

View File

@ -23,11 +23,11 @@ in the source distribution for its full text.
#include "UnsupportedProcess.h" #include "UnsupportedProcess.h"
}*/ }*/
SignalItem Platform_signals[] = { const SignalItem Platform_signals[] = {
{ .name = " 0 Cancel", .number = 0 }, { .name = " 0 Cancel", .number = 0 },
}; };
unsigned int Platform_numberOfSignals = sizeof(Platform_signals)/sizeof(SignalItem); 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 }; ProcessField Platform_defaultFields[] = { PID, USER, PRIORITY, NICE, M_SIZE, M_RESIDENT, STATE, PERCENT_CPU, PERCENT_MEM, TIME, COMM, 0 };

View File

@ -15,9 +15,9 @@ in the source distribution for its full text.
#include "SignalsPanel.h" #include "SignalsPanel.h"
#include "UnsupportedProcess.h" #include "UnsupportedProcess.h"
extern SignalItem Platform_signals[]; extern const SignalItem Platform_signals[];
extern unsigned int Platform_numberOfSignals; extern const unsigned int Platform_numberOfSignals;
extern ProcessField Platform_defaultFields[]; extern ProcessField Platform_defaultFields[];