mirror of https://github.com/xzeldon/htop.git
Merge branch '0000/int-sizes/00' of https://github.com/mfwitten/htop into mfwitten-0000/int-sizes/00
This commit is contained in:
commit
72613a38f4
28
Process.c
28
Process.c
|
@ -55,7 +55,7 @@ void Process_setupColumnWidths() {
|
||||||
xSnprintf(Process_pidFormat, sizeof(Process_pidFormat), "%%%dd ", digits);
|
xSnprintf(Process_pidFormat, sizeof(Process_pidFormat), "%%%dd ", digits);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Process_humanNumber(RichString* str, unsigned long number, bool coloring) {
|
void Process_humanNumber(RichString* str, unsigned long long number, bool coloring) {
|
||||||
char buffer[11];
|
char buffer[11];
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
|
@ -71,48 +71,48 @@ void Process_humanNumber(RichString* str, unsigned long number, bool coloring) {
|
||||||
|
|
||||||
if (number < 1000) {
|
if (number < 1000) {
|
||||||
//Plain number, no markings
|
//Plain number, no markings
|
||||||
len = snprintf(buffer, 10, "%5lu ", number);
|
len = snprintf(buffer, 10, "%5llu ", number);
|
||||||
RichString_appendn(str, processColor, buffer, len);
|
RichString_appendn(str, processColor, buffer, len);
|
||||||
} else if (number < 100000) {
|
} else if (number < 100000) {
|
||||||
//2 digit MB, 3 digit KB
|
//2 digit MB, 3 digit KB
|
||||||
len = snprintf(buffer, 10, "%2lu", number/1000);
|
len = snprintf(buffer, 10, "%2llu", number/1000);
|
||||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||||
number %= 1000;
|
number %= 1000;
|
||||||
len = snprintf(buffer, 10, "%03lu ", number);
|
len = snprintf(buffer, 10, "%03llu ", number);
|
||||||
RichString_appendn(str, processColor, buffer, len);
|
RichString_appendn(str, processColor, buffer, len);
|
||||||
} else if (number < 1000 * ONE_K) {
|
} else if (number < 1000 * ONE_K) {
|
||||||
//3 digit MB
|
//3 digit MB
|
||||||
number /= ONE_K;
|
number /= ONE_K;
|
||||||
len = snprintf(buffer, 10, "%4luM ", number);
|
len = snprintf(buffer, 10, "%4lluM ", number);
|
||||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||||
} else if (number < 10000 * ONE_K) {
|
} else if (number < 10000 * ONE_K) {
|
||||||
//1 digit GB, 3 digit MB
|
//1 digit GB, 3 digit MB
|
||||||
number /= ONE_K;
|
number /= ONE_K;
|
||||||
len = snprintf(buffer, 10, "%1lu", number/1000);
|
len = snprintf(buffer, 10, "%1llu", number/1000);
|
||||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||||
number %= 1000;
|
number %= 1000;
|
||||||
len = snprintf(buffer, 10, "%03luM ", number);
|
len = snprintf(buffer, 10, "%03lluM ", number);
|
||||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||||
} else if (number < 100000 * ONE_K) {
|
} else if (number < 100000 * ONE_K) {
|
||||||
//2 digit GB, 1 digit MB
|
//2 digit GB, 1 digit MB
|
||||||
number /= 100 * ONE_K;
|
number /= 100 * ONE_K;
|
||||||
len = snprintf(buffer, 10, "%2lu", number/10);
|
len = snprintf(buffer, 10, "%2llu", number/10);
|
||||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||||
number %= 10;
|
number %= 10;
|
||||||
len = snprintf(buffer, 10, ".%1luG ", number);
|
len = snprintf(buffer, 10, ".%1lluG ", number);
|
||||||
RichString_appendn(str, processMegabytesColor, buffer, len);
|
RichString_appendn(str, processMegabytesColor, buffer, len);
|
||||||
} else if (number < 1000 * ONE_M) {
|
} else if (number < 1000 * ONE_M) {
|
||||||
//3 digit GB
|
//3 digit GB
|
||||||
number /= ONE_M;
|
number /= ONE_M;
|
||||||
len = snprintf(buffer, 10, "%4luG ", number);
|
len = snprintf(buffer, 10, "%4lluG ", number);
|
||||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||||
} else if (number < 10000 * ONE_M) {
|
} else if (number < 10000ULL * ONE_M) {
|
||||||
//1 digit TB, 3 digit GB
|
//1 digit TB, 3 digit GB
|
||||||
number /= ONE_M;
|
number /= ONE_M;
|
||||||
len = snprintf(buffer, 10, "%1lu", number/1000);
|
len = snprintf(buffer, 10, "%1llu", number/1000);
|
||||||
RichString_appendn(str, largeNumberColor, buffer, len);
|
RichString_appendn(str, largeNumberColor, buffer, len);
|
||||||
number %= 1000;
|
number %= 1000;
|
||||||
len = snprintf(buffer, 10, "%03luG ", number);
|
len = snprintf(buffer, 10, "%03lluG ", number);
|
||||||
RichString_appendn(str, processGigabytesColor, buffer, len);
|
RichString_appendn(str, processGigabytesColor, buffer, len);
|
||||||
} else {
|
} else {
|
||||||
//2 digit TB and above
|
//2 digit TB and above
|
||||||
|
@ -134,7 +134,7 @@ void Process_colorNumber(RichString* str, unsigned long long number, bool colori
|
||||||
processShadowColor = CRT_colors[PROCESS];
|
processShadowColor = CRT_colors[PROCESS];
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((long long) number == -1LL) {
|
if (number == ULLONG_MAX) {
|
||||||
int len = snprintf(buffer, 13, " no perm ");
|
int len = snprintf(buffer, 13, " no perm ");
|
||||||
RichString_appendn(str, CRT_colors[PROCESS_SHADOW], buffer, len);
|
RichString_appendn(str, CRT_colors[PROCESS_SHADOW], buffer, len);
|
||||||
} else if (number >= 100000LL * ONE_DECIMAL_T) {
|
} else if (number >= 100000LL * ONE_DECIMAL_T) {
|
||||||
|
|
10
Process.h
10
Process.h
|
@ -138,19 +138,19 @@ typedef struct ProcessClass_ {
|
||||||
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
|
#define Process_sortState(state) ((state) == 'I' ? 0x100 : (state))
|
||||||
|
|
||||||
|
|
||||||
#define ONE_K 1024L
|
#define ONE_K 1024UL
|
||||||
#define ONE_M (ONE_K * ONE_K)
|
#define ONE_M (ONE_K * ONE_K)
|
||||||
#define ONE_G (ONE_M * ONE_K)
|
#define ONE_G (ONE_M * ONE_K)
|
||||||
#define ONE_T ((long long)ONE_G * ONE_K)
|
#define ONE_T (1ULL * ONE_G * ONE_K)
|
||||||
|
|
||||||
#define ONE_DECIMAL_K 1000L
|
#define ONE_DECIMAL_K 1000UL
|
||||||
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
|
#define ONE_DECIMAL_M (ONE_DECIMAL_K * ONE_DECIMAL_K)
|
||||||
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
|
#define ONE_DECIMAL_G (ONE_DECIMAL_M * ONE_DECIMAL_K)
|
||||||
#define ONE_DECIMAL_T ((long long)ONE_DECIMAL_G * ONE_DECIMAL_K)
|
#define ONE_DECIMAL_T (1ULL * ONE_DECIMAL_G * ONE_DECIMAL_K)
|
||||||
|
|
||||||
void Process_setupColumnWidths(void);
|
void Process_setupColumnWidths(void);
|
||||||
|
|
||||||
void Process_humanNumber(RichString* str, unsigned long number, bool coloring);
|
void Process_humanNumber(RichString* str, unsigned long long number, bool coloring);
|
||||||
|
|
||||||
void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
|
void Process_colorNumber(RichString* str, unsigned long long number, bool coloring);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue