Skip to content

Commit

Permalink
Provide proper contemporary function prototypes for many of the funct…
Browse files Browse the repository at this point in the history
…ions

implemented in top(1), rather than relying on K&R prototypes, which can
cause problems on targets where there are multiple incompatible calling
conventions and the compiler requires argument information to select the
correct one.

(There's a bit more to do here, since it looks like top(1) also sometimes
provides prototypes for various curses functions rather than relying on
the header file...)

Sponsored by:	DARPA, AFRL
MFC after:	1 week
  • Loading branch information
rwatson committed Mar 26, 2017
1 parent d25646a commit abc58cc
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 15 deletions.
7 changes: 4 additions & 3 deletions contrib/top/machine.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,15 @@ struct process_select

/* routines defined by the machine dependent module */

char *format_header();
char *format_next_process();
char *format_header(char *uname_field);
char *format_next_process(caddr_t handle, char *(*get_userid)(int),
int flags);
void toggle_pcpustats(void);
void get_system_info(struct system_info *si);
int machine_init(struct statics *statics, char do_unames);
int proc_owner(int pid);

/* non-int routines typically used by the machine dependent module */
char *printable();
char *printable(char *string);

#endif /* MACHINE_H */
23 changes: 12 additions & 11 deletions contrib/top/top.c
Original file line number Diff line number Diff line change
Expand Up @@ -112,24 +112,25 @@ extern int io_compare();
#endif
time_t time();

caddr_t get_process_info();
caddr_t get_process_info(struct system_info *si, struct process_select *sel,
int (*compare)(const void *, const void *));

/* different routines for displaying the user's identification */
/* (values assigned to get_userid) */
char *username();
char *itoa7();

/* pointers to display routines */
void (*d_loadave)() = i_loadave;
void (*d_procstates)() = i_procstates;
void (*d_cpustates)() = i_cpustates;
void (*d_memory)() = i_memory;
void (*d_arc)() = i_arc;
void (*d_carc)() = i_carc;
void (*d_swap)() = i_swap;
void (*d_message)() = i_message;
void (*d_header)() = i_header;
void (*d_process)() = i_process;
void (*d_loadave)(int mpid, double *avenrun) = i_loadave;
void (*d_procstates)(int total, int *brkdn) = i_procstates;
void (*d_cpustates)(int *states) = i_cpustates;
void (*d_memory)(int *stats) = i_memory;
void (*d_arc)(int *stats) = i_arc;
void (*d_carc)(int *stats) = i_carc;
void (*d_swap)(int *stats) = i_swap;
void (*d_message)(void) = i_message;
void (*d_header)(char *text) = i_header;
void (*d_process)(int line, char *thisline) = i_process;

void reset_display(void);

Expand Down
2 changes: 1 addition & 1 deletion usr.bin/top/machine.c
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ static int pageshift; /* log base 2 of the pagesize */
((kip)->ki_swrss > (kip)->ki_rssize ? (kip)->ki_swrss - (kip)->ki_rssize : 0)

/* useful externals */
long percentages();
long percentages(int cnt, int *out, long *new, long *old, long *diffs);

#ifdef ORDER
/*
Expand Down

0 comments on commit abc58cc

Please sign in to comment.