procps/procps-3.2.7-terabyte.dif

103 lines
4.0 KiB
Plaintext

--- top.c
+++ top.c 2009-03-11 15:27:05.180786112 +0100
@@ -89,6 +89,10 @@ static int Monpidsidx = 0;
static char Msg_delayed [SMLBUFSIZ];
static int Msg_awaiting = 0;
+ /* Show memory by default as kB */
+static int shift = 10;
+#define S(X) (unsigned long)(((unsigned long long)(X)<<10)>>shift)
+
// This is the select() timeout. Clear it in sig handlers to avoid a race.
// (signal happens just as we are about to select() and thus does not
// break us out of the select(), causing us to delay until timeout)
@@ -3038,10 +3042,33 @@ skip:
// Display Memory and Swap stats
meminfo();
if (CHKw(Curwin, View_MEMORY) && (Screen_rows > Msg_row+3)) {
- show_special(0, fmtmk(MEMORY_line1
- , kb_main_total, kb_main_used, kb_main_free, kb_main_buffers));
- show_special(0, fmtmk(MEMORY_line2
- , kb_swap_total, kb_swap_used, kb_swap_free, kb_main_cached));
+ const char *line1, *line2;
+ if (kb_main_total > 9999999)
+ shift = 20;
+ if (kb_main_total > 9999999999)
+ shift = 30;
+ switch (shift) {
+ case 20:
+ line1 = MEMORY_line1m;
+ line2 = MEMORY_line2m;
+ break;
+ case 30:
+ line1 = MEMORY_line1g;
+ line2 = MEMORY_line2g;
+ break;
+ case 0:
+ line1 = MEMORY_line1b;
+ line2 = MEMORY_line2b;
+ break;
+ default:
+ case 10:
+ line1 = MEMORY_line1k;
+ line2 = MEMORY_line2k;
+ }
+ show_special(0, fmtmk(line1
+ , S(kb_main_total), S(kb_main_used), S(kb_main_free), S(kb_main_buffers)));
+ show_special(0, fmtmk(line2
+ , S(kb_swap_total), S(kb_swap_used), S(kb_swap_free), S(kb_main_cached)));
Msg_row += 2;
}
--- top.h
+++ top.h 2009-03-11 15:14:15.888001315 +0100
@@ -392,17 +392,29 @@ typedef struct WIN_t {
" %#4.1f%% \02us,\03 %#4.1f%% \02sy,\03 %#4.1f%% \02ni,\03 %#4.1f%% \02id,\03 %#4.1f%% \02wa,\03 %#4.1f%% \02hi,\03 %#4.1f%% \02si\03\n"
#define STATES_line2x7 "%s\03" \
"%#5.1f%%\02us,\03%#5.1f%%\02sy,\03%#5.1f%%\02ni,\03%#5.1f%%\02id,\03%#5.1f%%\02wa,\03%#5.1f%%\02hi,\03%#5.1f%%\02si,\03%#5.1f%%\02st\03\n"
+#define MEMORY_line1b "Mem: \03" \
+ " %8lub \02total,\03 %8lub \02used,\03 %8lub \02free,\03 %8lub \02buffers\03\n"
+#define MEMORY_line2b "Swap:\03" \
+ " %8lub \02total,\03 %8lub \02used,\03 %8lub \02free,\03 %8lub \02cached\03\n"
#ifdef CASEUP_SUMMK
-#define MEMORY_line1 "Mem: \03" \
+#define MEMORY_line1k "Mem: \03" \
" %8luK \02total,\03 %8luK \02used,\03 %8luK \02free,\03 %8luK \02buffers\03\n"
-#define MEMORY_line2 "Swap:\03" \
+#define MEMORY_line2k "Swap:\03" \
" %8luK \02total,\03 %8luK \02used,\03 %8luK \02free,\03 %8luK \02cached\03\n"
#else
-#define MEMORY_line1 "Mem: \03" \
+#define MEMORY_line1k "Mem: \03" \
" %8luk \02total,\03 %8luk \02used,\03 %8luk \02free,\03 %8luk \02buffers\03\n"
-#define MEMORY_line2 "Swap:\03" \
+#define MEMORY_line2k "Swap:\03" \
" %8luk \02total,\03 %8luk \02used,\03 %8luk \02free,\03 %8luk \02cached\03\n"
#endif
+#define MEMORY_line1m "Mem: \03" \
+ " %8luM \02total,\03 %8luM \02used,\03 %8luM \02free,\03 %8luM \02buffers\03\n"
+#define MEMORY_line2m "Swap:\03" \
+ " %8luM \02total,\03 %8luM \02used,\03 %8luM \02free,\03 %8luM \02cached\03\n"
+#define MEMORY_line1g "Mem: \03" \
+ " %8luG \02total,\03 %8luG \02used,\03 %8luG \02free,\03 %8luG \02buffers\03\n"
+#define MEMORY_line2g "Swap:\03" \
+ " %8luG \02total,\03 %8luG \02used,\03 %8luG \02free,\03 %8luG \02cached\03\n"
// Keyboard Help specially formatted string(s) --
// see 'show_special' for syntax details + other cautions.
--- vmstat.c
+++ vmstat.c 2009-03-11 15:43:01.476001363 +0100
@@ -164,9 +164,9 @@ static void new_header(void){
////////////////////////////////////////////////////////////////////////////
-static unsigned long unitConvert(unsigned int size){
- float cvSize;
- cvSize=(float)size/dataUnit*((statMode==SLABSTAT)?1:1024);
+static unsigned long unitConvert(unsigned long size){
+ long double cvSize;
+ cvSize=(long double)size/dataUnit*((statMode==SLABSTAT)?1:1024);
return ((unsigned long) cvSize);
}