top(1): further unconditionally assume we're on FreeBSD

This commit is contained in:
Eitan Adler 2018-05-21 04:40:20 +00:00
parent 419fab3b14
commit 5ef89dbfa7
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=333962
4 changed files with 22 additions and 62 deletions

View File

@ -10,6 +10,8 @@
*
* loaddouble(la) - convert load_avg to double.
* intload(i) - convert integer to load_avg.
*
* $FreeBSD$
*/
/*
@ -19,39 +21,19 @@
*
* Defined types: load_avg for load averages, pctcpu for cpu percentages.
*/
#if defined(__mips__) && !(defined(__NetBSD__) || defined(__FreeBSD__))
#if defined(__mips__) && defined(__FreeBSD__)
# include <sys/fixpoint.h>
# if defined(FBITS) && !defined(FSCALE)
# define FSCALE (1 << FBITS) /* RISC/os on mips */
# endif
#endif
#ifdef FSCALE
# define FIXED_LOADAVG FSCALE
# define FIXED_PCTCPU FSCALE
#endif
#define FIXED_LOADAVG FSCALE
#define FIXED_PCTCPU FSCALE
#ifdef ibm032
# undef FIXED_LOADAVG
# undef FIXED_PCTCPU
# define FIXED_PCTCPU PCT_SCALE
#endif
typedef long pctcpu;
#define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
#ifdef FIXED_PCTCPU
typedef long pctcpu;
# define pctdouble(p) ((double)(p) / FIXED_PCTCPU)
#else
typedef double pctcpu;
# define pctdouble(p) (p)
#endif
#ifdef FIXED_LOADAVG
typedef fixpt_t load_avg;
# define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
# define intload(i) ((int)((i) * FIXED_LOADAVG))
#else
typedef double load_avg;
# define loaddouble(la) (la)
# define intload(i) ((double)(i))
#endif
typedef fixpt_t load_avg;
#define loaddouble(la) ((double)(la) / FIXED_LOADAVG)
#define intload(i) ((int)((i) * FIXED_LOADAVG))

View File

@ -905,7 +905,7 @@ get_process_info(struct system_info *si, struct process_select *sel,
/* remember active and total counts */
si->p_total = total_procs;
si->p_active = pref_len = active_procs;
si->p_pactive = pref_len = active_procs;
/* pass back a handle */
handle.next_proc = pref;

View File

@ -31,18 +31,12 @@ struct statics
* the system_info struct is filled in by a machine dependent routine.
*/
#ifdef p_active /* uw7 define macro p_active */
#define P_ACTIVE p_pactive
#else
#define P_ACTIVE p_active
#endif
struct system_info
{
int last_pid;
double load_avg[NUM_AVERAGES];
int p_total;
int P_ACTIVE; /* number of procs considered "active" */
int p_pactive; /* number of procs considered "active" */
int *procstates;
int *cpustates;
int *memory;

View File

@ -403,7 +403,7 @@ char *argv[];
if (getuid() == 0)
{
/* be very un-nice! */
(void) nice(-20);
nice(-20);
}
else
{
@ -589,25 +589,13 @@ char *argv[];
}
/* hold interrupt signals while setting up the screen and the handlers */
#ifdef SIGHOLD
sighold(SIGINT);
sighold(SIGQUIT);
sighold(SIGTSTP);
#else
old_sigmask = sigblock(Smask(SIGINT) | Smask(SIGQUIT) | Smask(SIGTSTP));
#endif
init_screen();
signal(SIGINT, leave);
signal(SIGQUIT, leave);
signal(SIGTSTP, tstop);
signal(SIGWINCH, top_winch);
#ifdef SIGRELSE
sigrelse(SIGINT);
sigrelse(SIGQUIT);
sigrelse(SIGTSTP);
#else
(void) sigsetmask(old_sigmask);
#endif
sigsetmask(old_sigmask);
if (warnings)
{
fputs("....", stderr);
@ -689,7 +677,7 @@ char *argv[];
/* determine number of processes to actually display */
/* this number will be the smallest of: active processes,
number user requested, number current screen accomodates */
active_procs = system_info.P_ACTIVE;
active_procs = system_info.p_pactive;
if (active_procs > topn)
{
active_procs = topn;
@ -779,18 +767,14 @@ char *argv[];
fflush(stdout);
/* default the signal handler action */
(void) signal(SIGTSTP, SIG_DFL);
signal(SIGTSTP, SIG_DFL);
/* unblock the signal and send ourselves one */
#ifdef SIGRELSE
sigrelse(SIGTSTP);
#else
(void) sigsetmask(sigblock(0) & ~(1 << (SIGTSTP - 1)));
#endif
(void) kill(0, SIGTSTP);
sigsetmask(sigblock(0) & ~(1 << (SIGTSTP - 1)));
kill(0, SIGTSTP);
/* reset the signal handler */
(void) signal(SIGTSTP, tstop);
signal(SIGTSTP, tstop);
/* reinit screen */
reinit_screen();
@ -807,7 +791,7 @@ char *argv[];
max_topn = display_resize();
/* reset the signal handler */
(void) signal(SIGWINCH, top_winch);
signal(SIGWINCH, top_winch);
reset_display();
winchflag = 0;
@ -885,7 +869,7 @@ char *argv[];
show_help();
top_standout("Hit any key to continue: ");
fflush(stdout);
(void) read(0, &ch, 1);
read(0, &ch, 1);
break;
case CMD_errors: /* show errors */
@ -903,7 +887,7 @@ char *argv[];
show_errors();
top_standout("Hit any key to continue: ");
fflush(stdout);
(void) read(0, &ch, 1);
read(0, &ch, 1);
}
break;