fix 4 GB wrap-around in top

This commit is contained in:
albert 2003-09-06 05:11:04 +00:00
parent 28d744ee6a
commit 6dbef339c2
5 changed files with 14 additions and 9 deletions

3
NEWS
View File

@ -1,5 +1,8 @@
procps-3.1.11 --> procps-3.1.12 procps-3.1.11 --> procps-3.1.12
top: fixed 4 GB wrap-around
ps: comes with tests
man page: /var/run/utmp, not /etc/utmp #206583
required flags moved out of CFLAGS #205429 required flags moved out of CFLAGS #205429
RPM generation handles /lib64 RPM generation handles /lib64
WCHAN skips leading '.' WCHAN skips leading '.'

View File

@ -240,8 +240,7 @@ will be destroyed by init(8) if the parent process exits.
PROCESS FLAGS PROCESS FLAGS
FORKNOEXEC 1 forked but didn't exec FORKNOEXEC 1 forked but didn't exec
SUPERPRIV 2 used super-user privileges SUPERPRIV 4 used super-user privileges
DUMPCORE 4 dumped core
PROCESS STATE CODES PROCESS STATE CODES

10
top.c
View File

@ -71,7 +71,8 @@ static char Rc_name [OURPATHSZ];
static RCF_t Rc = DEF_RCFILE; static RCF_t Rc = DEF_RCFILE;
/* The run-time acquired page size */ /* The run-time acquired page size */
static int Page_size; static unsigned Page_size;
static unsigned page_to_kb_shift;
/* SMP, Irix/Solaris mode, Linux 2.5.xx support */ /* SMP, Irix/Solaris mode, Linux 2.5.xx support */
static int Cpu_tot, static int Cpu_tot,
@ -1567,6 +1568,11 @@ static void before (char *me)
/* get virtual page size -- nearing huge! */ /* get virtual page size -- nearing huge! */
Page_size = getpagesize(); Page_size = getpagesize();
i = Page_size;
while(i>1024){
i >>= 1;
page_to_kb_shift++;
}
} }
@ -2874,6 +2880,8 @@ static proc_t **summary_show (void)
} }
#define PAGES_2K(n) (unsigned)( (n) << page_to_kb_shift )
/* /*
* Display information for a single task row. */ * Display information for a single task row. */
static void task_show (const WIN_t *q, const proc_t *p) static void task_show (const WIN_t *q, const proc_t *p)

5
top.h
View File

@ -82,11 +82,6 @@
/* Yield table size as 'int' */ /* Yield table size as 'int' */
#define MAXTBL(t) (int)(sizeof(t) / sizeof(t[0])) #define MAXTBL(t) (int)(sizeof(t) / sizeof(t[0]))
/* Convert some proc stuff into vaules we can actually use */
#define BYTES_2K(n) (unsigned)( (n) >> 10 )
#define PAGES_2B(n) (unsigned)( (n) * Page_size )
#define PAGES_2K(n) BYTES_2K(PAGES_2B(n))
/* Used as return arguments in *some* of the sort callbacks */ /* Used as return arguments in *some* of the sort callbacks */
#define SORT_lt ( Frame_srtflg > 0 ? 1 : -1 ) #define SORT_lt ( Frame_srtflg > 0 ? 1 : -1 )
#define SORT_gt ( Frame_srtflg > 0 ? -1 : 1 ) #define SORT_gt ( Frame_srtflg > 0 ? -1 : 1 )

2
w.1
View File

@ -60,7 +60,7 @@ Show information about the specified user only.
.SH FILES .SH FILES
.TP .TP
.I /etc/utmp .I /var/run/utmp
information about who is currently logged on information about who is currently logged on
.TP .TP
.I /proc .I /proc