Browse files

import latest top

  • Loading branch information...
1 parent c25b3bb commit 61668abc71b2dae2b0eee1502dd76a4ff58ce870 christos committed Jul 16, 2008
Showing with 27,183 additions and 0 deletions.
  1. +949 −0 external/bsd/top/dist/Changes
  2. +340 −0 external/bsd/top/dist/FAQ
  3. +54 −0 external/bsd/top/dist/INSTALL
  4. +30 −0 external/bsd/top/dist/LICENSE
  5. +92 −0 external/bsd/top/dist/
  6. +229 −0 external/bsd/top/dist/Porting
  7. +191 −0 external/bsd/top/dist/README
  8. +26 −0 external/bsd/top/dist/Y2K
  9. +1,193 −0 external/bsd/top/dist/ap_snprintf.c
  10. +5 −0 external/bsd/top/dist/boolean.h
  11. +376 −0 external/bsd/top/dist/color.c
  12. +91 −0 external/bsd/top/dist/color.h
  13. +1,034 −0 external/bsd/top/dist/commands.c
  14. +42 −0 external/bsd/top/dist/commands.h
  15. +10 −0 external/bsd/top/dist/config.amd64.make
  16. +10 −0 external/bsd/top/dist/config.amd64.makeinstall
  17. +5 −0 external/bsd/top/dist/config.default.makeinstall
  18. +1,407 −0 external/bsd/top/dist/config.guess
  19. +256 −0 external/bsd/top/dist/
  20. +10 −0 external/bsd/top/dist/config.sparcv9.make
  21. +10 −0 external/bsd/top/dist/config.sparcv9.makeinstall
  22. +1,504 −0 external/bsd/top/dist/config.sub
  23. +7,969 −0 external/bsd/top/dist/configure
  24. +529 −0 external/bsd/top/dist/
  25. +1,937 −0 external/bsd/top/dist/display.c
  26. +84 −0 external/bsd/top/dist/display.h
  27. +121 −0 external/bsd/top/dist/getopt.c
  28. +66 −0 external/bsd/top/dist/globalstate.h
  29. +2,001 −0 external/bsd/top/dist/hash.c
  30. +155 −0 external/bsd/top/dist/hash.h
  31. +666 −0 external/bsd/top/dist/hash.m4c
  32. +103 −0 external/bsd/top/dist/hash.m4h
  33. +251 −0 external/bsd/top/dist/install-sh
  34. +69 −0 external/bsd/top/dist/layout.h
  35. +89 −0 external/bsd/top/dist/loadavg.h
  36. +122 −0 external/bsd/top/dist/machine.h
  37. +729 −0 external/bsd/top/dist/machine/m_aix43.c
  38. +793 −0 external/bsd/top/dist/machine/m_aix5.c
  39. +988 −0 external/bsd/top/dist/machine/m_decosf1.c
  40. +14 −0 external/bsd/top/dist/machine/
  41. +1,780 −0 external/bsd/top/dist/machine/m_freebsd.c
  42. +134 −0 external/bsd/top/dist/machine/
  43. +701 −0 external/bsd/top/dist/machine/m_hpux10.c
  44. +18 −0 external/bsd/top/dist/machine/
  45. 0 external/bsd/top/dist/machine/m_hpux7.c
  46. 0 external/bsd/top/dist/machine/m_hpux8.c
  47. 0 external/bsd/top/dist/machine/m_hpux9.c
  48. 0 external/bsd/top/dist/machine/
  49. 0 external/bsd/top/dist/machine/m_irix5.c
  50. 0 external/bsd/top/dist/machine/m_irixsgi.c
  51. 0 external/bsd/top/dist/machine/m_linux.c
  52. 0 external/bsd/top/dist/machine/
  53. 0 external/bsd/top/dist/machine/m_linuxthr.c
  54. 0 external/bsd/top/dist/machine/
  55. 0 external/bsd/top/dist/machine/m_macosx.c
  56. 0 external/bsd/top/dist/machine/
  57. 0 external/bsd/top/dist/machine/m_netbsd.c
  58. 0 external/bsd/top/dist/machine/
  59. 0 external/bsd/top/dist/machine/m_sco5.c
  60. 0 external/bsd/top/dist/machine/
  61. 0 external/bsd/top/dist/machine/m_sunos4.c
  62. 0 external/bsd/top/dist/machine/
  63. 0 external/bsd/top/dist/machine/m_sunos5.c
  64. 0 external/bsd/top/dist/machine/
  65. 0 external/bsd/top/dist/machine/m_svr4.c
  66. 0 external/bsd/top/dist/machine/
  67. 0 external/bsd/top/dist/machine/m_svr5.c
  68. 0 external/bsd/top/dist/machine/
  69. 0 external/bsd/top/dist/message.h
  70. 0 external/bsd/top/dist/os.h
  71. 0 external/bsd/top/dist/screen.c
  72. 0 external/bsd/top/dist/screen.h
  73. 0 external/bsd/top/dist/sigconv.awk
  74. 0 external/bsd/top/dist/
  75. 0 external/bsd/top/dist/top.c
  76. 0 external/bsd/top/dist/top.h
  77. 0 external/bsd/top/dist/username.c
  78. 0 external/bsd/top/dist/username.h
  79. 0 external/bsd/top/dist/utils.c
  80. 0 external/bsd/top/dist/utils.h
  81. 0 external/bsd/top/dist/version.c
  82. 0 external/bsd/top/dist/version.h
Sorry, we could not display the entire diff because it was too big.
949 external/bsd/top/dist/Changes
@@ -0,0 +1,949 @@
+Tue May 6 2008 - wnl (3.8beta1)
+ Main code: fixed bugs in screen_cleareol and in display code. Fixed
+ bug in i_swap when all data is 0. Added ^W patch (from thaquis).
+ Fixed bug in xdprintf. Added command line options for the "t" and
+ "m" commands.
+ SunOS 5 changes: Support for showing individual threads. Redid
+ allocation of prpsinfo structures. Added a pidthr hash that uses
+ both pid and thread id for a key. Changed format_process_header
+ and format_next_process to use a table-driven method for generating
+ the columns. Status files from /proc (psinfo and lpsinfo) are now
+ cached to avoid repeatedly reopening them. Column showing number of
+ LWPs is now called "NLWP" and column showing lwpid is "LWP".
+ FreeBSD changes: Runtime check to ensure binary is running on
+ the same machine type it was compiled for. Lots of cleanup and
+ changed nearly everything to use sysctl rather than kvm, and
+ inability to open kvm is no longer fatal. Improved thread reporting:
+ disabled for 7.x and lower. Added lwpid hash for proper tracking
+ of threads. Changed format_process_header and format_next_process
+ to use a table-driven method for generating the columns.
+ Dec Alpha: configure uses compile-time options to properly trap
+ and handle exceptions from the Alpha FPU (from Brian Maly).
+Tue Feb 26 2008 - wnl (3.7)
+ Prepare for version 3.7 release.
+Fri Feb 1 2008 - wnl (3.7beta4)
+ Using the $ notation in printf formats for freebsd apparently was
+ causing problems on 64-bit systems. All such usage has been
+ removed and the process line is formatted piecemeal.
+Thu Dec 27 2007 - wnl (3.7beta3)
+ Improved function comments in display.c for message_error functions.
+ Changed some of the error messages in top.c to be more succint.
+Fri Dec 7 2007 - wnl (3.7beta3)
+ Changes to freebsd port: moved some functions up front to
+ eliminate forward references. Use sysctl to get all vm stats
+ information, as some of this isn't updated in the struct
+ vmmeter under FreeBSD 7.0. Added routines to support large-scale
+ sysctl access.
+Wed Nov 28 2007 - wnl (3.7beta3)
+ Changes to documentation: FAQ, README, man page.
+Tue Nov 27 2007 - wnl (3.7beta3)
+ For freebsd, added page faults, pageins, pageouts, and pages
+ freed to the kernel display line. These numbers reflect the
+ values presented in vmstat. For sunos5, added page faults,
+ pageins and pageouts to the kernel display line.
+Fri Nov 2 2007 - wnl (3.7beta3)
+ Added copyright notices to the top of every source and include file.
+ Added copyright information to the man page.
+ Removed a few outdated things from the manifest.
+ Minor changes to sigconv.awk.
+Sat Oct 27 2007 - wnl (3.7beta3)
+ Added check for sys_signame at configure time and if it is
+ present then it is used in commands.c to translate signal names
+ in to numbers.
+ Added alternate snprintf and vsnprintf functions from apache (in
+ ap_snprintf.c). Added configure magic to define and compile them in
+ where needed. Added check to configure for variadic macros.
+ Preprocessor defintion of dprintf (in utils.h) now depends on
+ support for variadic macros. Cleaned up m_linux code.
+Wed Oct 3 2007 - wnl (3.7beta3)
+ Lots of changes, thanks to Mark Wong. Most changes were to
+ clean the code up so that it would compile cleanly with -Wall
+ (all warnings). Changed function names in screen.c so that
+ they all start with "screen_". Isolated all interaction with
+ termcap to screen.c by adding a real function for cursor
+ addressing (in the past it was just a macro). Only screen.c
+ now needs to worry about defining templates for the termcap
+ functions. Added configure and preprocessor magic to ensure
+ that all the termcap functions used in the code are defined
+ with templates. Changed names of some other functions and
+ global variables to avoid name conflicts with functions in
+ curses and other well established libraries. Changed dprintf
+ macro to use variadic arguments so that the preprocessor can
+ gobble up the entire call when compiling without debugging
+ (this will have to be made more portable). All include files
+ are surrounded by #ifndef statements to accomodate multiple
+ inclusions. Platform module is now compiled with
+ -fno-strict-aliasing as some of the modules do type punning
+ that can confuse the optimizer.
+Wed Sep 26 2007 - wnl (3.7beta3)
+ For freebsd, priority is no longer normalized by PZERO. This
+ contradicts the behavior used by ps when it displays priority.
+ But normalizing by PZERO has become a bit of an anachronism
+ and it actually obscures the meaning of the priority without
+ adding any real value.
+Wed Sep 19 2007 - wnl (3.7beta3)
+ Many changes to improve the display of threads. Changed
+ process summary line to use the word "threads" when showing
+ individual threads. Added the system command to toggle the
+ display of system processes. Fixed bug in hash.c remove_pos.
+ For freebsd: count threads correctly when they are being
+ displayed, nice column is more closely in line with ps
+ (nothing fancy for real time processes), add two more process
+ states that didn't exist in older releases of freebsd (wait
+ and lock).
+ For linux: Threads done right. Now track individual threads
+ of multi-threaded processes separately so that we always know
+ their %cpu. Switch to format_process_header so that we can
+ change the column headings and remove the THR column when
+ displaying individual threads. Switched process (and thread)
+ tracking over to use generic hash table functions included
+ with the new version of top. Process states and total now
+ include threads when they are being shown. Added "SHR" column
+ to show the amount of shared memory per process. Improved
+ calculation of elapsed time and percent cpu to avoid
+ overflows. Remove weighted cpu calculations entirely as it is
+ an anachronism.
+ For Solaris: Moved check for libelf to accomodate older systems.
+Sun Sep 9 2007 - wnl (3.7beta2)
+ Documentation changes. Fixes to sunos5 port. Added display of
+ thread count and selection by command name to linux port. Removed
+ the use of inline functions from hash.c as that doesn't appear to
+ be very portable.
+Wed Sep 5 2007 - wnl (3.7beta1)
+ Fixed freebsd and linux configuration bugs. Added configuration
+ options for tweaking program defaults. Rewrote top level code
+ (top.c) from scratch, including command handling so that adding
+ new commands is much easier. Changed message-line handling to
+ ensure that the message is displayed for at least 5 seconds
+ regardless of the update frequency. Added a "miniupdate" that
+ occurs one second after the initial screen on systems that don't
+ already delay the first screen. The mini-update shows cpu state
+ percentages. Added ability to select output by command name on
+ some systems. Fixed color toggling via the "C" command. Added
+ long options via getopt_long to complement the existing single
+ character options. Added the freebsd "m" command to chose
+ alternate display modes. On freebsd this gives a process i/o
+ display. Added the freebsd "H" command to select the display of
+ individual threads. Added "-a" option ("all") to set number of
+ displays and number of processes to infinity (equivalent to
+ "-d all all"). Added dual architecture compilation for Solaris
+ to generate both a 32-bit and a 64-bit binary. This is on by
+ default when compiling on a 64-bit system and can be explicitly
+ set via "configure --enable-dualarch". Added uniform hashing
+ functions that use bucket hash for uint, pid, and string. Changed
+ username.c and the sunos and freebsd modules to use these functions.
+ Added the "kernel" information line to the display to show
+ statistics on what the kernel is doing (context switches, forks,
+ traps, etc.). This requires explicit support by the platform
+ module, currently only freebsd, linux, and sunos.
+Wed Apr 18 2007 - wnl (3.6.1)
+ Fixed a few bugs in sigconv.awk that were causing incorrect
+ results on FreeBSD. Changed to fix a few linux
+ problems: signal include file and /proc/1/stat.
+Fri Apr 13 2007 - wnl (3.6.1)
+ Removed the use of VPATH for compiling the system module and used
+ an explicit dependency in the Makefile instead. VPATH is now set
+ to just srcdir to ensure that top will compile correctly when
+ configured from a different directory. On systems without VPATH
+ support, top will still configure and compile, but only
+ from within the source directory. This fixes bug 1699526.
+Fri Feb 2 2007 - wnl (3.6.1)
+ Revised the way that configure figures out owner, group, and mode.
+ For systems that don't use the kernel, it tries to match install
+ settings to allow access to stuff in /proc. More importantly, if
+ mode is 755 then neither owner nor group are set. This fixes bug
+ 1631136. Added patch from to fix an occasional
+ core dump in m_decosf1.c. This checks return code from task_threads.
+ Made sure all get_system_info functions are declared void. Fixed
+ string termination bug. Cleaned up documetation for sunos5.
+Tue Aug 8 2006 - wnl (3.6.1)
+ For Solaris, changed the tag "swap" to "total swap" to clarify
+ what is beign displayed. Note that the calculations are still the
+ same: the display is just showing total rather than total - free.
+Thu Apr 27 2006 - wnl (3.6)
+ Added patches for linux-style sort shortcuts and for Unixware
+ support in configure (patch 1474427). Fixed sunos5 to do slow start
+ and to ensure cpucount is set (patch 1477386). Added pagination
+ routines to display.c and modified show_help to use it, since the
+ help screen is now longer than 24 lines. Applied patch for unixware
+ support that adds check for mas library (patch #1474423). Solaris
+ cpu percent now reflects a percentage of the entire server, rather
+ than a single cpu (bug 1478138).
+Mon Mar 27 2006 - wnl (3.6)
+ The production release of version 3.6. Fixed a minor scaling
+ bug in the decosf1 module. Support for MacOS X is officially
+ withdrawn although the macosx module is still part of the
+ distribution. Hopefully this is a temporary situation.
+ Documentation updated.
+Wed Feb 15 2006 - wnl (3.6beta5)
+ Minor changes to eliminate warnings from the Sun Studio compiler.
+ These were mostly sloppy argument declarations. I also added
+ message.h to provide an interface file for just the message
+ related functions of display.c.
+Mon Dec 26 2005 - wnl (3.6beta4)
+ Added new netbsd module, courtesy of Simon Burge.
+ Fixed a few bugs in SVR4 module and added its use to
+, thanks to Sanchet Dighe. Also ensured that the
+ novpath Makefile was in the distribution.
+ Fixed portability problem in display.c
+Mon Oct 24 2005 - wnl (3.6beta3)
+ Set up a color tagging mechanism in color.c to allow for the
+ dynamic creation of tag names to contol color highlighting.
+ These names are partially derived from the tags used to label
+ memory and swap information on the screen, thus are driven by
+ the machine module itself. Added -T option to list color
+ highlighting information. Help screen now includes the actual
+ list of sort order names. Incorporated some minor fixes to
+ the main code from the Freebsd source tree. Fixed bug #1324582.
+ Freebsd 5: removed WCPU column and added THR column. Display
+ for freebsd 4 and earlier unchanged since they don't track
+ threads in the kernel. Added LICENSE file to distribution.
+Wed Oct 12 2005 - wnl (3.6beta2)
+ Major overhaul to display.c. All lines of the display are
+ directly tracked and controlled via display_write and its
+ companion display_fmt. Added support for complete control
+ of ANSI color on the screen: this will be used in the future
+ to allow for full use of color everywhere on the screen.
+ Signal handling code now uses sigaction on all systems that
+ support it. Restored the freebsd module and did away with
+ freebsd4, and upgraded freebsd module to support 5.x.
+ Fix bug #1306099 (wio(wait) timer ignored on OSF1).
+Fri Sep 23 2005 - wnl (3.6beta1)
+ Fixed bugs #1266341 (compilation errors with gcc 4.x),
+ #1156464 (cpu% field for sunos), #1156243 (compilation
+ errors on AIX). Applied patches #1217855 (Solaris 10
+ xarch flag). Overhaul of sunos5 module, making code more
+ efficient and easier to follow. Got rid of need for MEMTYPE
+ type in utils.h. Changed all memory statistics data in the
+ module specification from an int to a long to better support
+ 64-bit systems with lots of memory. Moved all unused modules
+ out of the distribution (I will add them back in as needed).
+ Moved freebsd module to freebsd4 as it won't work with 5.x
+ (a new module will be necessary). Added support to configure
+ for makes that don't understand VPATH. Updated documentation:
+ man page, FAQ, README, INSTALL.
+Mon Jan 24 2005 - wnl (3.6alpha10)
+ Updated aix43 module with ANSI function declarations and fixed
+ declaration of get_system_info. Configure now uses irixsgi
+ module for irix6* systems. Updates to the following modules:
+ irixsgi, sunos5. Fixed null pointer bug in color.c. Removed
+ some useless code and definitions in display.c
+Sun Nov 28 2004 - wnl (3.6alpha9)
+ Replace AIX 5 module with alternate (bug 1056565).
+ Fixed vulnerability in use of snprintf.
+Fri Oct 22 2004 - wnl (3.6alpha8)
+ Support for linux 2.6, added more stuff to memory and swap lines.
+ Updated linuxthr module, which is only useful on 2.4 and earlier.
+ Added some color support back in (feature request 930588), but
+ still need to add it back to the per-process display. Added
+ OSF 5 support (untested).
+ Fixed bug 1017951 (invalid process count argument not caught)
+Tue Apr 20 2004 - wnl (3.6alpha7)
+ Added 64 bit support for AIX.
+Thu Apr 15 2004 - wnl (3.6alpha6)
+ Included fixes for decosf1 pid size and updated module. Also
+ added osf1 to list of recognized operating systems in
+Tue Mar 30 2004 - wnl (3.6alpha5)
+ Minor bug fixes and some code rearrangement. Changes to install
+ rule. Added several more platforms including: aix 4.2 thru 5,
+ MacOS 10, Dec OSF, HPUX 7 thru 11. Fixed the core dumping bug
+ in linux. Code cleanup, including sigdesc.h (by changing
+ sigconv.awk). Startup error messages are displayed on the
+ first screen rather than beforehand (no more pause). Cleaned
+ up interrupt handling to avoid a race condition. Eliminated
+ top.local.h. REMOVED Configure!!!
+Mon Mar 22 2004 - wnl (3.6alpha1)
+ Now using gnu autoconf. Eliminated the need for CFLAGS and LIBS
+ tags in the module source files. Autoconf tries to figure all
+ that out now. Machine module interface now uses flags to determine
+ if module supports sorting, selective display of idle processes,
+ viewing full commands. Added display of uptime for modules that
+ support it. Added display of full command lines for modules that
+ support it. 3.5 modules must be changed a bit to work for 3.6:
+ ORDER is no longer defined, and the module must fill in the
+ appropriate fields in struct statics to get the extra features.
+ Added a extenstion interface to allow for putting extra stuff
+ on the screen -- this is still half baked and not documented.
+Mon Feb 23 2004 - wnl (3.5)
+ Turned rc1 in to version 3.5. Only changes were to the FAQ.
+Mon Feb 2 2004 - wnl (3.5rc1)
+ Changed format_k (utils.c) to use MEMTYPE for its parameter.
+ On most systems this is a long, but if the module defines
+ USE_SIZE_T, this is set to be a size_t. The sunos5 module
+ now defines it, so that it will work correctly on 64-bit
+ machines. New "linuxthr" module for rolling up processes
+ that are really threads. Configure autodetects when running
+ on a 64-bit Solaris machine.
+Tue Dec 16 2003 - wnl (3.5beta13)
+ Improved linux module. For Solaris, changed "THR" column
+ heading to "LWP" since that's what they really are.
+Thu Mar 30 2000 - wnl (3.5beta12)
+ Updated modules: m_aix41.c, m_aix43.c, m_mtxinu.c, m_sco5.c,
+ and m_ultrix4.c.
+ Included m_irixsgi.c from some source that's been floating around
+ SGI. Don't yet know how it compares to m_irix62.
+Fri Mar 10 2000 - wnl (3.5beta11)
+ top.c: avoid potential loop if stdout gets closed, use macro
+ for p_active to avoid collision with system macros.
+ m_sunos5: widened some fields to accomodate 5.8.
+ m_decosf1: added ordering support
+ m_irix62_64: provides 64-bit module based on m_irix62.
+ m_irix62: skip bogus files in /proc directory
+ m_svr42MP and m_svr5: complete replacement with updated copies
+ m_mtxinu: complete replacement with updated copies
+ m_aix43: new module for 4.3
+ getans: replaced with a Bourne shell script
+Mon Mar 6 2000 - wnl (3.5beta10)
+ m_sunos5.c: workaround for curses bug: ensure that TERMINFO has
+ a value.
+Fri Jan 15 1999 - wnl (3.5beta10)
+ top.c: now check return code from read to avoid looping on eof.
+ top.c: delay of 0 now only valid for root.
+ decosf1.c: patches from Rainer Orth should fix most of the
+ problems with this module (including the display of certain
+ processes and runtime errors).
+ sunos5.c: Rainer insisted on putting the slash back in the
+ state field ("run/4") and widened the field to accomodate it.
+ aix.c: widened PID field for 6-digit pids (shortened NICE field)
+ module macosx added, thanks to Andrew Townley.
+Fri Dec 18 1998 - wnl (3.5beta9)
+ Configure checks status of "make" and complains if it fails.
+Thu Dec 17 1998 - wnl (3.5beta9)
+ Added module sco5 from Mike Hopkirk.
+ Added module netbsd132 from moto kawasaki.
+Sun Oct 25 1998 - wnl (3.5beta9)
+ Added Casper's patches for sunos5 for the following:
+ produce same results as swap -s (5.5 and higher),
+ don't use system_pages kstat when /dev/kmem can be opened,
+ skip . and .. when reading /proc, replace use of SOLARIS24
+ with OSREV.
+Fri Sep 11 1998 - wnl (3.5beta9)
+ Added workaround to getans for the absence of $< in SCO Unix.
+Wed Jul 1 1998 - wnl (3.5beta9)
+ Changed structure member "errno" to "errnum" in commands.c.
+ Replaced hpux10 module with one from John Haxby.
+Fri Apr 17 1998 - wnl (3.5beta8)
+ Moved definition of _KMEMUSER earlier in m_sunos5.c. This should
+ fix the compilation problem with gnu, obviating the need
+ for the fixinc.svr4 patch, but hopefully will not affect anything
+ else.
+ Added -DORDER to m_sunos4mp.c
+Tue Nov 18 1997 - wnl (3.5beta7)
+ Added gcc patch for fixinc.svr4 and changed INSTALL and
+ FAQ to refer to it.
+ Added NetBSD HP9000 fix. Hopefully it doesn't break other
+ NetBSD platforms.
+Fri Oct 24 1997 - wnl (3.5beta7)
+ Modified m_dcosx.c to change uses of procdir to xprocdir, avoiding
+ a name clash with an include file (Bryn Parrott)
+Sat Oct 11 1997 - wnl (3.5beta6)
+ Incorporated Casper's patches for Solaris 2.6 and for the multi-
+ processor bug ("kstat finds too many cpus").
+Sun Jan 20 1996 - wnl (3.5beta5)
+ Fixed Casper's m_sunos5 module: there was a poor interaction with
+ his use of OSREV and SunOS 5.5.1.
+Fri Dec 20 1996 - wnl (3.5beta4)
+ Replaced m_sunos5 with a reworked version by Casper Dik. This one
+ should work under 2.6 and may not require that top be run setuid
+ to root under 2.5 or 2.6. This also fixed a bug in m_sunos5 that
+ was introduced in beta3.
+ Fixed calculation of OSREV in Configure.
+Wed Nov 20 1996 - wnl (3.5beta3)
+ Incorporated contributed fixes to: bsdos2, irix62, freebsd20,
+ ultrix4, sunos5. Changed calculation of swap area in sunos5 (now
+ uses swapctl). sunos5 now understands idled processors. Changed
+ Configure to determine os revision using uname (when available)
+ and adding it to machine.c compiliation in Makefile as -DOSREV.
+ Changed calls to "exit" in modules to use "quit" instead.
+Oct 20 1996 - wnl (3.5beta3)
+ Removed "time" from list of ordering choices: there's no easy way
+ to get cpu time for all processes (it's in the u area).
+Fri Oct 18 1996 - wnl (3.5beta3)
+ hpux10 and hpux9: using a better means for determining when a
+ process is idle.
+ decosf1 now includes utils.h.
+Fri Sep 13 1996 - wnl (3.5beta2)
+ Fixed Configure to build Make.desc in such a way that doesn't
+ require a long argument to sed.
+Thu Sep 12 1996 - wnl (3.5beta2)
+ Fixed bug in display.c that affected empty cpustate names.
+ Created hpux1010 module - a variant of hpux10 that does not use
+ struct proc or struct user (suitable for HP/UX 10.10).
+Wed Sep 11 1996 - wnl (3.5beta2)
+ Changes to sunos5 module: Removed WCPU column since it is meaningless
+ on a SVR4-based system. Added THR column to show number of threads
+ for each process. This was not straightforward: the information is
+ not stored in prpsinfo but rather in prstatus.
+Tue Sep 10 1996 - wnl (3.5beta1)
+ Added patches for sunos4mp to provide order support.
+ Added irix62 module.
+ Changed prime.c to include stdio.h for printf prototype.
+ Added conditional code to os.h and utils.c to handle systems
+ where sys_errlist is defined in stdio.h (such as NetBSD).
+Mon Sep 09 1996 - wnl (3.5beta1)
+ Removed tar and shar rules from Makefile.X -- don't need them anymore.
+ Added -v option to display version number. Updated man page.
+Thu Aug 29 1996 - wnl (3.4)
+ Replaced modules (from Tim Pugh): next 32, next40.
+ Fixed bug in username.c: hashing negative uids.
+Thu Aug 22 1996 - wnl (3.4beta3)
+ Patched modules: ultrix4, sunos4, sunos5, utek, decosf1, irix5.
+ Added modules: next40, next32.
+ Fixed procstates update bug in display.c.
+ Fixed divide by zero bug in utils.c.
+ Fixed bad number in layout.h
+ Minor fixes to Configure.
+ Complete overhaul of FAQ.
+Tue Feb 13 1996 - wnl (3.4beta3)
+ Added convex module from Warren Vosper (originally written by
+ William Jones).
+Tue Feb 13 1996 - wnl (3.4beta2)
+ Fixed format_k in utils.c to calculate K and M values correctly.
+ Added check for gigabyte values ('G'). Changed sumamry_format
+ in display.c to use format_k where appropriate.
+ Changed creation of distribution tar file to place everything in
+ a top level directory.
+Tue Jan 30 1996 - wnl (3.4beta2)
+ Added m_aix41 module. Added new tag type to module comments:
+ TERMCAP, which defined the library to use for a termcap library.
+ If no TERMCAP tag is found in the module's initial comment, then
+ Configure will default to "-ltermcap". AIX needs this since it
+ put all the termcap routines in libcurses(!)
+ Added m_bsdos2 (found lingering in my mailbox).
+ Updated m_svr4 to include support for NCR multiprocessors.
+ Fixed small bug in utils.c
+Thu Jan 25 1996 - wnl (3.4beta1)
+ Fixed m_sunos5 invocation of gettimeofday to include "NULL" as
+ second argument. This provides compatability with the Posix-
+ compliant template provided with SunOS 5.5, but doesn't hurt
+ previous versions since they do bother with a template for that
+ function.
+ Made changes (recommended by net users) to hpux10, ultrix4,
+ netbsd10, aux3 (replaced aux31). Added module for linux.
+Fri Oct 10 1995 - wnl (3.4beta1)
+ Added user-contributed modules for SCO Unix, IRIX 5, HP/UX 10,
+ Pyramid DC/OSX. Changed Configure so that it runs in environments
+ whose c-shells have no 'eval'(!). Added support for multiple sort
+ ordering methods via the -o switch. This option requires support
+ from the machine dependent module: such support was added to
+ sunos5 (thus sunos54) and sunos4.
+ display.c: Changed CPU states display line to shorten the leading
+ tag if the data won't fit in the current width. Fixed a divide-by-
+ zero bug that affected ultrasparc servers (and potentially other
+ systems).
+ m_sunos5.c: Now asks the system for the correct pagesize rather than
+ assuming it is 4K.
+Thu Mar 2 1995 - wnl (3.3 RELEASE)
+ Added module netbsd10 and renamed netbsd to netbsd08. Changed
+ Configure so that it does not use an initial default module name.
+ Made other compatability fixes to Configure. Added comments to
+ decosf1 concerning optimizer bug. Other documentation changes.
+ Added use of "prime.c" to Configure script.
+Tue Feb 7 1995 - wnl (3.3beta6)
+ Still one more beta....
+ Fixes for sunos5 2.4 gcc core dump (it was an alignment problem).
+ Fixed and improvements for decosf1 (including use of format_k
+ for proper SIZE column formatting). Added modules freebsd20 and
+ ncr3000.
+Thu Feb 2 1995 - wnl (3.3beta5)
+ One more beta....
+ Fixed a few bugs in the sunos5 port pertaining to casting and
+ very large memory counts. Added "ifndef HAVE_GETOPT" to getopt.c
+ to provide for conditional compilation of the getopt function.
+ Those systems that have getopt in libc can add -DHAVE_GETOPT to
+ the CFLAGS line in the module to prevent the function from being
+ compiled. Added sunos54 module to accomodate SunOS 5.4
+ peculiarities. Added module for aux3.1.
+Wed Jan 4 1995 - wnl (3.3beta4)
+ This is really taking too long......sigh.
+ Fixed SIGWINCH handling once and for all. It now remembers the
+ number of processes you want displayed even thru window resizes.
+ Fixed buffer conflict in utils.c (itoa and itoa7).
+ Lots of small improvements to the various modules were made over
+ the past month: too numberous to list here. SunOS 5 module made
+ more secure thru use of seteuid calls (other SVR4 modules should
+ be modified similarly). One final MP fix to sunos5, too. Module
+ for decosf1 was modified to accomodate V3.0.
+Mon Apr 18 1994 - wnl (3.3beta3)
+ I think I finally got a sunos5 module that will work on MP
+ machines. Fixed cpu states figure in osmp41a so that
+ percentages never exceed 100%. Added shell script "install"
+ since Unix vendors can't seem to make up their minds on what
+ options they want to use for the one that comes with the OS.
+ Added netbsd modules from Christos. Fixed lots of other little
+ things over the past few months that I have long since forgotten.
+Wed Dec 15 1993 - wnl (3.3beta2)
+ Added module patches from various users: hpux9, sunos5.
+ Fixed bug with batch mode (screen_width wasn't getting set).
+ Changes to accomodate 64 bit machines.
+ Fixed some bugs in command parsing ("renice 19 " did something
+ unexpected).
+Mon Aug 30 1993 - wnl (3.3beta)
+ Added lots of little patches from various users.
+ Added routines to utils.c for intelligent formatting of kilobytes
+ and time. These are intended to be used in the modules when
+ formatting a process line. Added code to "summary_format" in
+ display.c to do intelligent formatting of memory quantities.
+ Redid display.c to allow for varying line widths and dynamic
+ reallocation of the screen buffer.
+ Added a SIGWINCH handler to top.c!
+ Added a constant, MAX_COLS, to top.h which defines the absolute
+ widest line we will ever allow. Changed allocations of "char fmt"
+ in all machine modules to use this constant rather than an abitrary
+ number.
+Fri Aug 13 1993 - wnl (3.3)
+ Changed return value definition of time-related functions in top.c,
+ display.c, and m_ultrix4.c to time_t (
+ Fixed bug in display.c: line_update when start != 0.
+Wed Aug 4 1993 - wnl (3.2 release)
+ Changes to Configure from Paul Vixie. Added modules for hpux9 and
+ bsd386.
+Tue Jul 13 1993 - wnl (3.1 release)
+ More small changes and minor bug fixes. Brought bsd44 up to date
+ and added a module for svr4.2. Changed shar packaging to use Rich
+ Salz's cshar stuff.
+Wed Jul 7 1993 - wnl (3.1BETA)
+ More changes and bug fixes to Configure. Applied some other
+ minor bug fixes and suggestions from the beta testers. Added
+ the "metatop" shell script and the "installmeta" rule to the
+ Makefile to make handling multiple machine models and OS versions
+ easier. Added INSTALL and FAQ files.
+Tue May 18 1993 - wnl (3.1BETA)
+ Changed Configure to be compatible with most SVR4 environments
+ (differing output from "ls -lg"). Also changed Configure,
+ Makefile.X, etc., to look for module files in the subdirectory
+ "machine" (thanks to Christos Zoulas).
+Tue Apr 20 1993 - wnl (3.1BETA)
+ Changed both occurences of "ls -1" in Configure to "ls". This
+ SHOULD produce the same result, and has the advantage that it
+ doesn't produce an error on a system 5 machine. Integrated other
+ changes recommended in the first round of beta testing.
+Wed Mar 10 1993 - wnl (3.1BETA)
+ MAJOR CHANGE: I have added a required function to all machine
+ dependent modules, called proc_owner. It takes a pid as an argument
+ and returns the uid of the process's owner. Such capability is
+ necessary for top to run securely as a set-uid program, something
+ that is needed for SVR4 implementations to read /proc. I have
+ retrofitted all modules except dgux with this function, but was
+ not able to test most of them. Top should now run securely as
+ a setuid program. Added 386bsd and sunos5 modules. Added sunos4mp
+ module for MP Suns.
+Sat Feb 20 1993 - wnl (3.1ALPHA)
+ Modified top.c and commands.c to compile correctly on System V
+ derived Unixes (especially SVR4), but in a way that doesn't rely
+ on an oracle-like declaration (that is, I don't use "ifdef SYSV").
+ Fixed some bugs in "Configure" and "getans". Added inspection of
+ env variable "TOP" for options, and made -I default to showing
+ idle processes. Added "u" command to change username restriction
+ on the fly. Created shell script "suntop" for poor multi-version
+ SunOS folks (like myself).
+Wed Jun 3 1992 - wnl (3.0)
+ "max_topn" wasn't being used everywhere it was supposed to be
+ in top.c. Many cosmetic changes, including copyright notices in
+ all the .c files. Version number is now handled by version.c and
+ reflects the current patchlevel (which is initially set to 0).
+ Changed Configure and Makefile to allow configurable variables for
+ certain commands: shell, cc, awk, install. Updated README and
+ Porting. Ready to release to the world!
+Mon May 18 1992 - wnl (2.9BETA)
+ Added modules provided by Christos Zoulas. Replaced screen.c
+ with one modified by Christos and that will appropriately select
+ and handle the sgtty, termio, or termios system. Integrated many
+ other changes recommended by Christos. Fixed (I hope) the "-b"
+ batch mode display bug. Had to change loadavg to load_avg to avoid
+ a conflict with 4.4BSD.
+Mon Apr 27 1992 - wnl (2.8BETA)
+ Added modules provided by Daniel Trinkle. Added patchlevel.h,
+ but the patch level is not yet reflected in the version number.
+ Cleaned up m_sunos4.c a little.
+Wed Apr 22 1992 - wnl (2.8BETA)
+ Major internal reorganization. All of the system dependent stuff
+ is now really and truly separated from everything else. The
+ system dependent functions are contained in a separate .c file
+ called a "module". The Configure script knows how to find and
+ set up these modules, but the human installer still needs to tell
+ Configure which module to use (no automagic determination of
+ machine type---sorry). Added -U option to specify one user's
+ processes, but there is no corresponding command...yet. Other
+ changes and improvements too numerous to mention here. Currently
+ there are only two modules: sunos4 and umax. But after this beta
+ release is sent around, I expect more to be written. I just hope
+ that the machine-dependent abstractions don't need to change in
+ the process.
+Thu Mar 26 1992 - wnl (2.7BETA)
+ Beta release with minimal architecture support. Updated README
+ and added a first cut at a Porting guide. Added ioctl TIOCGWINSZ
+ code from top2.5+ (courtesy of David MacKenzie). I didn't even
+ try porting the Ultrix support since I don't have access to an
+ Ultrix machine.
+Fri Oct 11 1991 - wnl (2.6)
+ This version was not widely released. It contained many changes.
+ Here are the major ones:
+ Put in Vixie's idle process hack.
+ Enhanced type field in new_message to handle delayed messages.
+ Changed u_process to automatically adjust for varying lines of
+ output. Management of screenbuf should now be completely contained
+ in display.c. Removed now extraneous code from CMD_number[12]
+ portion of command switch in top.c. This was the stuff that dealt
+ with zeroing out lines in screenbuf.
+ Finally made it all work correctly on a 386i. Problems I had to
+ overcome: kvm_nlist doesn't return 0 on success as advertised (it
+ returns 1 instead); the results of a kvm_nlist are different
+ (n_type can be zero even for a symbol that exists).
+ Serious rearrangement for processor dependent stuff. All nlists
+ are now in separate files with the suffix ".nlist". Most machine
+ specific code is in "machine.c" surrounded by appropriate ifdefs---
+ the goal is to eventually have all machine specific code in this
+ file. Managed to find a way to detect SunOS 4.x at compile-time:
+ this is contained in the include file "sun.h". Completely changed
+ the memory display line for SunOS 4.x---it now displays a far
+ more appropriate report.
+ Created the shell script "Configure" to aid in the configuration
+ step.
+ Fixed a bug in init_termcap: it will now tolerate an environment
+ which does not have TERM defined (thanks to Sam Horrocks for
+ pointing this out).
+Tue Aug 9 1988 - wnl (2.5)
+ Added changes to make top work under version 4.0 of the Sun
+ operating system. Changes were provided by Scott Alexander of the
+ University of Pennsylvania. Thanks! Compile with "-Dsunos4" to
+ get them. Virtual memory statistics are not readily accessible
+ under 4.0, so they don't show up in the output.
+Thu Jul 31 1987 - wnl (2.4)
+ Fixed a problem with the 4.0 Pyramid code. The label "cp_time"
+ doesn't exist in the 4.0 kernel anymore. I think the code Carl
+ sent me wants "percpu" instead. That is what I am using and it
+ appears to work. 375 code is still untested (at least by me).
+ Also picked a great deal of lint out of the source. Lint now only
+ complains about a very few nitpicky things (there are far too many
+ calls to "printf" to put a "(void)" in front of!), at least under
+ SunOS.
+Tue Jul 28 1987 - wnl (2.4a)
+ Added changes for a Symmetrics Computer Systems s/375 machine.
+ Changes were provided by Paul Vixie. Thanks! According to Mr.
+ Vixie: "These changes were not made at, by, or for SCS proper.
+ SCS would probably be interested in them, but so far only the
+ users' group has them. They were made in February, 1987, to
+ version 2.1 of the program, by Paul Vixie
+ (dual!ptsfa!vixie!paul@ucbvax.Berkeley.EDU)." His changes were
+ integrated into version 2.3 to make version 2.4.
+ The SCS peculiarities are summarized in Changes.scs.
+Tue Jun 9 1987 - wnl (2.3 for real)
+ Changed the includes for the extra code Carl sent me to only
+ compile on Version 4.0 Pyramid machines. This makes top still
+ compilable on pre-4.0 Pyramids. Specifically, this code is only
+ compiled when both "pyr" and "CPUFOUND" are defined.
+Wed Jun 3 1987 - wnl (2.3 with Pyramid additions)
+ It's been a month and I still haven't done anything about
+ distributing this version. However, Carl Gutekunst from Pyramid
+ has sent me some extra patches for some of the Pyramid code. I
+ just added those and will make them part of 2.3. This fixes the
+ following Pyramid problems: adds the inclusion of <sys/systm.h>,
+ uses the correct size for getting the kernel value _ccpu (this bug
+ affected the Vax version as well), sums the elements of the percpu
+ array to calculate a cp_time value (for OSx 4.0).
+Fri May 1 1987 - wnl (2.3)
+ I have finally finished all the changes for better support of
+ oddbal terminals. Added the low-level routine "clear_eol" which
+ makes handling terminals without "ce" easy: it uses spaces
+ instead. All direct uses of "clear_line" outside of screen.c have
+ been changed to use this primitive. A terminal with "os" is now
+ handled in such that all situations that need overwriting are
+ completely avoided (including several commands). This required
+ some changes to the way commands are translated into action (in
+ "top.c"). Made several important changes to display.c to prevent
+ overflowing of any of the fields. Specifically, more than 99
+ total processes and a cpu state that reaches 100%. Had to make a
+ small change to two casts in top.c, because the Sun 3.2 compiler
+ was giving warnings on them. Added the "-q" option which lets
+ root run top at a nice of -20 (in case he thinks he really needs it).
+Tue Dec 30 1986 - wnl (2.2)
+ I think I fixed a bug reported by Julian Onions at Nottingham.
+ Occasionally, top will core dump when the sprintf in either
+ i_process or u_process overflows due to an exceptionally
+ unrealistic time value. I think it highly unlikely that top can
+ get a bad proc structure (although I suppose it is possible), but
+ the process time is read from the user structure, and that can
+ sometimes be part garbage. So, "get_ucpu" checks the value it
+ returns to make sure its formatted form will not overflow the
+ sprintf. If this doesn't fix the bug, then more drastic measures
+ will be necessary. I plan to make this version the official
+ "top 2.2". [[ This version was never distributed very widely. ]]
+Tue Dec 2 1986 - wnl (2.2c)
+ Added to top.c the notion of a "failed command". When a command
+ produces a message (on the message line), an update does not
+ follow it. Before, the message was written and a new display was
+ shown---purposefully not overwriting the message. But the
+ improvements to handle overstriking terminals and terminals
+ without "ce" clear the screen before every display, which would
+ erase the message. Now, the message is displayed and top waits
+ another full time interval before updating the display. This
+ works much better all around.
+Mon Nov 24 1986 - wnl (2.2b)
+ Created a new file, utils.c, and made appropriate changes to
+ Makefile. This new file holds all utility functions that can and
+ may be used by more than one "module". Improved i_memory and
+ u_memory (display.c) so that screen updates for the values
+ displayed are only changed when necessary. Also made the line
+ look better: the last fixes made for a rather ugly display.
+ Added the locally defined constant "LoadMax" and added code to
+ top.c to send the cursor home after a space command is entered if
+ the load average is higher than "LoadMax". This provides visual
+ feedback on loaded systems.
+Mon Nov 3 1986 - wnl (2.2a)
+ Widened the format for memory usage so that it can display 5
+ digits. This makes that line look a little ugly---maybe I'll fix
+ that later. Screen handling now understands "os" and a missing
+ "ce". It treats them identically: clear the screen between each
+ display. Screen handling code now uses "cd" when appropriate
+ (i.e.: when user has shortened the screen). Made i_loadave clear
+ then screen and took out most of the explicit calls to "clear" in
+ top.c. This method is cleaner, especially in conjunction with
+ "os" handling. Added preprocessor variable "RANDOM_PW" for
+ systems that access the passwd file randomly (Sun's yp and 4.3).
+ With "RANDOM_PW" set, "getpwuid" is used instead of "getpwnam",
+ but uid->username mappings are still hashed internally (because
+ that is still faster than going to disk).
+Mon Oct 6 1986 - wnl (2.1)
+ A bug with the kill command was pointed out by "dciem!tim"---
+ specifying a signal by name did not work correctly. This bug has
+ been fixed with a simple change to commands.c. Another bug made
+ the cpu state percentages incorrect the first time they were
+ displayed. This bug has also been fixed (changed top.c).
+Thu Sep 4 1986 - wnl (2.0, at last)
+ This is the version that will (hopefully) get released to the
+ world as top 2.0.
+ Added the "r" and "k" commands for renice and kill, respectively.
+ This required adding a way to handle system call errors, and the
+ addition of the "e" command. Help screen and manual page were
+ changed to reflect this change. Changed all "#ifdef SUN" directives
+ to "#ifdef sun", and changed all "#ifdef PYRAMID" directives to
+ "#ifdef pyr". As much as I hate those choices of preprocessor
+ names (they too easily conflict with real variable names), it does
+ make automatic compilation possible---people don't have to change
+ the Makefile anymore for specific machines. The manual page was
+ changed to automatically incorporate the defaults as set in the
+ Makefile (including an infinite value for TOPN) and the way the
+ manual page is generated by the Makefile was changed to make
+ maintenance of this information automatic.
+Mon Jul 28 1986 - wnl (still pre 2.0)
+ Real close now. I put in a new definition for the macro "pagetok"
+ that does an explicit shift of a constant expression involving
+ PGSHIFT. Appropriate checks are made if PGSHIFT is to small.
+ "pagetok" is now used exclusively everywhere to convert kernel
+ clicks to kilobytes. I added a full blown interactive mode with
+ the ability to change some of the runtime parameters (how many to
+ display, time delay, etc.) while top is running. I also
+ incorporated a few ideas from the net: control characters in the
+ command name are replaced with '?'; the '-S' option makes the
+ swapper and pager visible; options have been added to control the
+ number of displays produced (this makes it easier to make
+ performance snapshots with top). I have also added the notion of
+ "infinite" values for number of processes and number of displays.
+ I fixed a long-standing bug in the uid to username mapping code
+ that was only aggravated on the pyramids: it was an ill-defined
+ expression (akin to i = i++). I tweaked the proc_compar routine
+ for qsort slightly so that stopped processes were more likely to
+ show up. Manual page was updated to reflect all changes
+ noticeable to the user.
+Tue Jul 1 1986 - wnl (pre 2.0 -- 1.9999?)
+ In the process of major revamping on the way to version 2.0.
+ I have completely done away with curses by adding my own screen
+ management routines in a separate file (screen.c). The rationale
+ for this is that top knows a whole lot more about what is and is
+ not redundant on the screen and can compare simple integer values
+ where curses would have to compare strings. This has turned out
+ to be a very big win speed-wise. The proc_compar routine for
+ sorting has been rewritten to include several more keys. I
+ decided this was necessary when I noticed that the "top" process
+ itself kept disappearing off the top 10 list on a Sun-3. All the
+ processes had the same percentage (0%) and the sort wasn't really
+ doing anything worthwhile. I changed the expression that computes
+ memory usage to use the ctob macro instead of just assuming that
+ pages were 512 bytes. More work still needs to be done before
+ this version is usable. I changed options-processing to use
+ getopt and added appropriate incantations to the Makefile.
+Wed Feb 20 1985 - wnl (still 1.8)
+ Put in the ifdef FOUR_ONE statements to make top still compilable
+ on a 4.1 system. Apparently, there are some users out there that
+ need this functionality. Oh well. I don't guarantee any of it,
+ since I can't test it. Made appropriate changes to README and
+ final installation related changes to Makefile.
+Sat Feb 2 1985 - wnl (1.8)
+ Removed all the ifdef FOUR_TWO statements and made "top" into a
+ 4.2 only program. If someone really wants to still run it on 4.1,
+ then they can do all the work. We don't have a 4.1 machine
+ anymore, so I don't even know if the thing still works under 4.1.
+ Cleaned up the Makefile and the README. Added installation rules
+ to the Makefile, as requested by several sites. Fixed a very
+ obscure divide-by-zero bug. Added a second "key" to the qsort
+ comparison function (proc_compar) so that comparisons are based on
+ cpu ticks if the percentages are equal (provided by Jonathon
+ Feiber at Sun).
+Tue Dec 11 1984 - wnl (1.7)
+ Added the virtual and real memory status line to the header area
+ (provided by Jonathon Feiber at Sun)
+Tue Nov 20 1984 - wnl (1.6)
+ Added an "exit" if sbrk's fail. Added changes from Jonathon
+ Feiber at Sun: ifdef SUN to make top work on Suns (they don't use
+ doubles in the proc structure), register declarations, check for
+ getting a user structure that has disappeared since the proc array
+ was read (it used to die, now it just shows the process as swapped).
+Tue Nov 13 1984 - wnl (1.5)
+ If the number of displayable processes ("active_procs") was less
+ than the number of requested processes ("topn"), top would
+ segmentation fault. This bug has been fixed. Thanks to Prentiss
+ Riddle at ut-sally for pointing out the existence of this bug.
+Tue Oct 23 1984 - wnl (1.4)
+ Finally fixed the hash table bug that caused processes owned by
+ root to sometimes appear with either no name or a different name
+ that had UID 0 (such as "operator"). Removed all the ifdef DEBUG
+ blocks to make top ready for distribution to the real world.
+Sun Apr 8 1984 - wnl (still 1.3)
+ Made some slight changes to the display format. It now looks more
+ aesthetically pleasing. Added some preprocessor constants so that
+ the two defaults (number of processes and seconds of delay) easier
+ to change.
+Thu Apr 5 1984 - wnl (1.3)
+ Changed the order in which things are done at initialization time.
+ This way, if an error occurs before starting the main loop, curses
+ will never get started. Also changed other error handlers so that
+ endwin() is called before any flavor of exit. Specifying a number
+ of processes that is more than the screen can handle is no longer
+ fatal. It displays a warning message and pretends the user
+ specified the maximum for the screen. Finally cured all the TSTP
+ blues (well, almost all). I removed my TSTP handler and convinced
+ the system to always use the one that curses sets up. Turns out
+ that "sleep" was stepping all over it during a pause. So, I don't
+ use sleep anymore. The only problem that remains with it now is
+ redrawing the old display before updating it after a pause.
+Tue Apr 3 1984 - wnl (from 1.0 to 1.2)
+ I changed the format of the TIME column from just "seconds" to
+ "minutes:seconds". I also made pausing work correctly. Screen
+ redraws with an up to date display. For compatibility with 4.2, I
+ changed the name of the "zero" function to "bzero". The makefile
+ has been altered to handle versions for 4.1 and 4.2, and README
+ has been updated to reflect these recent changes.
340 external/bsd/top/dist/FAQ
@@ -0,0 +1,340 @@
+ Version 3.8beta1
+ William LeFebvre
+ with much help from others
+ Frequently Asked Questions and their Answers
+ 1. What is top?
+ Top provies the user with a regularly updated display showing
+ information about the system and its top cpu-using processes. Think
+ of it as a full-screen "ps" output that gets updated at regular
+ intervals.
+ 2. Where do I get the latest version of top?
+ The official site for top is "" in the directory
+ "/pub/top". Top is also a SourceForge project, and the most recent
+ releases are available on any of the SourceForge mirrors. The
+ SourceForge project page is at
+ 3. Is there a web page for top?
+ Yes. Point your browser at It includes all
+ documentation, a nice interactive display which describes the various
+ components of the output of top, web-based retrieval of the package,
+ year 2000 information, and other neat stuff.
+ 4. Is there a mailing list or on-line bulletin board for top?
+ There is a mailing list used for general announcements regarding top,
+ including new releases. This mailing list is available to sourceforge
+ members and can be accessed from the unixtop sourceforge project
+ page. Visit SourceForge and search for the project "unixtop", then
+ click on "mailing lists". There are also on-line forums available
+ through SourceForge where members can post questions and comments.
+ 5. What about Year 2000 compliance?
+ Top did not experience any problems with the transition to the year
+ 2000. A full statement concerning top and the year 2000 can be found
+ in the file "Y2K" included with the distribution.
+ 6. Will there be another major release of top? Will there be a top
+ version 4?
+ I have some great ideas for the next major release of top, and I very
+ much want to make those ideas a reality. What I don't have much of
+ these days is free time. But I will keep poking at it and I hope to
+ have top version 4.0 ready by the fall of 2006.
+ 7. Does top really support multi-processor systems?
+ On platforms that support multiple processors, top is able to detect
+ and correctly summarize the information about those processors. What
+ top does not do is break down the cpu states summary (the third line
+ of the display) by cpu. Instead it collects the cpu state information
+ from all processors and combines them in to a single line. Some
+ vendors include a modified version of top that presents this
+ information for each cpu. Top 3.7 may have this functionality but it
+ is not present in the standard top 3.6 release.
+ 8. Is top under CVS control? Can I access the sources via SourceForge
+ CVS or Subversion?
+ I maintain top using subversion, not CVS. Although I utilize my own
+ private subversion repository, it is regularly mirrored in to the
+ SourceForge Subversion repository. You can access the SourceForge
+ repository here:
+ 9. We just upgraded our operating system to a new version and top broke.
+ What should we do?
+ Recompile it. Top is very sensitive to changes in internal kernel
+ data structures. It is not uncommon for a new version of the
+ operating system to include changes to kernel data structures.
+10. I just finished compiling top and it works fine for root, but when I
+ try to run it as a regular user it either complains about files it
+ can't open or it doesn't display all the information it should. Did I
+ do something wrong?
+ Well, you're just not done. On many operating systems today, access
+ to many of the kernel memory devices and other system files is
+ restricted to either root or a particular group. The configure script
+ figures this out (usually) and makes sure that the "install" rule in
+ the Makefile will install top so that anyone can run it successfully.
+ However, you have to *install* it first. Do this with the command
+ "make install".
+11. Top is (not) displaying idle processes and I don't (do) want it to.
+ This default has only changed about a dozen times, and I finally got
+ tired of people whining about it. Go read the manual page for the
+ current version and pay special attention to the description of the
+ "TOP" environment variable.
+12. We have so much memory in our machine that the memory status display
+ (the fourth line) ends up being longer than 80 characters. This
+ completely messes up top's output. Is there a patch?
+ Most modules have been changed to use new memory formatting functions
+ which will display large values in terms of megabytes instead of
+ kilobytes. This should fix all occurences of this problem. Also note
+ that newer versions of top can use columns beyond 79, and understand
+ window resizes. So you can always make your window wider.
+13. I tried to compile top with gcc and it doesn't work. I get
+ compilation errors in the include files, or I get an executable that
+ dumps core, or top displays incorrect numbers in some of the
+ displays. What's wrong?
+ Gnu CC likes very much to use its own include files. Not being a gcc
+ expert, I can't explain why it does this. But I can tell you that if
+ you upgrade your operating system (say from Solaris 2.6 to Solaris
+ 2.7) after installing gcc, then the include files that gcc uses will
+ be incorrect, especially those found in the "sys" directory. Your
+ choices are: (1) rebuild and reinstall the "standard" include files
+ for gcc (look for scripts in the distribution called "fixincludes"
+ and "fixinc.svr4"), (2) compile machine.c with
+ "CFLAGS=-I/usr/include" then make the rest of the object files
+ normally, or (3) use a different compiler.
+14. The cpu state percentages are all wrong, indicating that my machine
+ is using 95% system time when it is clearly idle. What's wrong?
+ This can happen if you compiled with gcc using the wrong include
+ files. See the previous question.
+15. This version of top does not show individual threads with the "t" or
+ "H" commands. Instead it says "command not available." Why?
+ Previous versions of top attempted to support the display of
+ individual threads under FreeBSD through the use of the "t" command.
+ However, the FreeBSD kernel does not supply sufficient or correct
+ information on the individual threads within a process. So the data
+ that was being displayed was incorrect and misleading. Therefore, top
+ version 3.8 disables the use of this command to prevent the display
+ of incorrect information. FreeBSD 8.0 will correctly report
+ per-thread information and top version 3.8 supports the use of the
+ "t" command for version 8.0.
+16. The "f" command (to display full command lines for the processes)
+ does not work and instead says "command not available". Why?
+ The current version of top is able to use sysctl to retrieve almost
+ all of the information it needs without having to open /dev/kmem. The
+ one piece of information not available via sysctl is the full command
+ line of each argument. If you run top as a regular user and it cannot
+ open /dev/kmem (in other words, it is not installed set-gid to the
+ kmem group) then it will disable the "f" command. Make sure the top
+ binary is installed with a group ownership of "kmem" and with the
+ set-gid bit on if you want the "f" command to work properly.
+17. I tried to configure top on my Mac OSX system and I got an error
+ claiming "macosx not supported". What up?
+ Since I don't have full time root access to a Mac OSX system I cannot
+ provide effective support for the platform. MacOSX uses Mach, and it
+ is very difficult to extract accurate system and process information
+ from the system. It takes a lot of trial and error, along with root
+ access. I have included the most up-to-date version of the macosx
+ module in the distribution, but I do not claim that it works. If you
+ want to try to use it, you can configure with "./configure
+ --with-module=macosx".
+18. I tried compiling top under SunOS version 4.1.x and it got compile
+ time errors or run time errors. Is there a patch?
+ If you try compiling top in a "System V environment" under SunOS
+ (that is, /usr/5bin is before /usr/bin on your path) then the
+ compilation may fail. This is mostly due to the fact that top thinks
+ its being compiled on a System V machine when it really isn't. The
+ only solution is to put /usr/bin and /usr/ucb before /usr/5bin on
+ your path and try again.
+ NOTE: the most common source of problems with top under Solaris is
+ the result of compiling it with the wrong front end. Make sure that
+ /usr/ucb is not on your path before attempting to compile top under
+ Solaris.
+19. Is there somewhere I can get a pre-compiled package?
+ Yes. Although I don't provide pre-compiled binaries, you can get a
+ Sun-style package from
+20. Under Solaris 2, when I type "make", the system says "language
+ optional software package not installed." What's going on?
+ You tried to compile with /usr/ucb/cc. Make sure /usr/ucb is not on
+ your path. Furthermore, you do not have a Sun compiler installed on
+ your system. You need a compiler to make top. Either Sun's C compiler
+ or the Gnu C compiler will work fine.
+21. Under Solaris 2, when I run top as root it only shows root processes,
+ or it only shows processes with a PID less than 1000. It refuses to
+ show anything else. What do I do?
+ You probably compiled it with /usr/ucb/cc instead of the real C
+ compiler. /usr/ucb/cc is a cc front end that compiles programs in BSD
+ source-level compatability mode. You do not want that. Make sure that
+ /usr/ucb is not on your path and try compiling top again.
+22. Under Solaris 2, I compiled top using what I am sure is the correct
+ compiler but when I try to run it it complains about missing dynamic
+ libraries. What is wrong?
+ Check to see if you have LD_LIBRARY_PATH defined in your shell. If
+ you do, make sure that /usr/ucblib is not on the path anywhere. Then
+ try compiling top again.
+23. Under Solaris 2, when I try to run top it complains that it can't
+ open the library "". So I changed the LIBS line in
+ m_sunos5.c to include -R/usr/ucblib to make sure that the dynamic
+ linker will look there when top runs. I figured this was just an
+ oversight. Was I right?
+ No, you were not right. As distributed, top requires no alterations
+ for successful compilation and operations under any release of
+ Solaris 2. You probably compiled top with /usr/ucb/cc instead of the
+ real C compiler. See FAQ 22 for more details.
+24. On my 64-bit system some processes show up with incorrect information
+ (such as zero memory).
+ If you are running a 64-bit system, then you need to make sure that
+ you are running the 64-bit top binary. Top's configure script
+ attempts to detect 64-bit systems, and will automatically generate
+ both 32-bit and 64-bit binaries on such systems. If you use or
+ install the 32-bit binary on a 64-bit system top will still run but
+ will not produce the correct results. This will also happen if you
+ configure your distribution on a 32-bit system then compile with that
+ configuration on a 64-bit system. You must configure and compile on
+ the same system. For Sparc systems the 32-bit binary will be created
+ in the subdirectory "sparcv7" and the 64-bit binary will be created
+ in the subdirectory "sparcv9". For Intel systems the directories will
+ be "i386" (32-bit) and "amd64" (64-bit). In all cases a copy of
+ /usr/lib/isaexec is made in the main directory and called "top". This
+ program will choose the correct binary to run from one of these
+ subdirectories. See isaexec(3c) for more details.
+25. Can I install both 32-bit and 64-bit binaries on a central file
+ server and have machines which mount it automatically use the correct
+ one?
+ Yes. If you configure and compile on a 64-bit system, top's configure
+ script and makefile will automatically create both 32-bit and 64-bit
+ binaries. The "install" rule in the makefile will install these
+ binaries in subdirectories of /usr/local/bin appropriate to the
+ architecture (sparcv7/sparcv9 or i386/amd64) then create a copy of
+ /usr/lib/isaexec named "top" in /usr/local/bin to ensure that the
+ appropriate is run when a user types "top". If you make sure that you
+ configure and compile on a 64-bit system, then "make install" will do
+ the right thing.
+26. This version of top show less available swap space than previous
+ versions. Why does it no longer match the output of the swap summary
+ produced with "swap -s"?
+ Starting with version 3.6 of top, the amount of swap space reported
+ by top has been changed to reflect only disk-based swap space. The
+ swap summary produced with "swap -s" also includes memory-based swap
+ space. This changed was made for several reasons. It makes the
+ display under Solaris more like those of other operating systems. The
+ display is more what users expect (except those used to previous
+ versions of top). Most importantly, "swap -s" gets its data via an
+ undocumented system interface. Now that top no longer displays that
+ data it can use publically documented and maintained system
+ interfaces to retrieve its data.
+27. When I run top on my SVR4-derived operating system, it displays all
+ the system information at the top but does not display any process
+ information (or only displays process information for my own
+ processes). Yet when I run it as root, everything works fine. What's
+ wrong?
+ Your system probably uses the pseudo file system "/proc", which is by
+ default only accessible by root. Top needs to be installed setuid
+ root on such systems if it is going to function correctly for normal
+ users.
+28. The memory display doesn't work right. Why?
+ This is a known bug with the svr42 module. The problem has been
+ traced down to a potential bug in the "mem" driver. The author of the
+ svr42 module is working on a fix.
+29. I'm still stuck. To whom do I report problems with top?
+ The most common problems are caused by top's sensitivity to internal
+ kernel data structures. So make sure that you are using the right
+ include files, and make sure that you test out top on the same
+ machine where you compiled it. Sun's BSD Source Compatability Mode is
+ also a common culprit. Make sure you aren't using either /usr/ucb/cc
+ or any of the libraries in /usr/ucblib. Finally, make sure you are
+ using the correct module. If there does not appear to be one
+ appropriate for your computer, then top probably will not work on
+ your system.
+ If after reading all of this file and checking everything you can you
+ are still stuck, then please use SourceForge to submit a support
+ request or a bug. Top is supported by the SourceForge project named
+ "unixtop". On SourceForge you will find defect tracking, a mailing
+ list, and on-line forums. You can also contact the author through
+ SourceForge.
54 external/bsd/top/dist/INSTALL
@@ -0,0 +1,54 @@
+ Version 3.8beta1
+ William LeFebvre
+ and a cast of many
+Configuration and installation of top is easy. Top version 3.6
+comes with a configure script generated by gnu autoconf. After
+unpacking the tar file, simply run "./configure". The script will
+automatically perform a series of checks on the system and determine
+what settings are appropriate for the Makefile and certain include
+files. Once configure completes, simply type "make install" and
+top will be compiled and installed. By default, the installation
+location is /usr/local/bin. You can change the destination location
+with the --prefix option to configure.
+In addition to the standard options, top's configure script supports
+the following:
+ --with-module=name
+ Force the use of a particular module. Modules are located
+ in the subdirectory "machine". A module's name is derived
+ from the file's basename without the leading "m_".
+ --with-ext=name
+ Compile with the extension "name", found in the subdirectory
+ "ext". At the present time, there are no extensions in the
+ standard distribution.
+ --enable-debug
+ --disable-debug
+ Default off. Include debugging output in the compilation,
+ which can be seen with the -D switch.
+ --enable-color
+ --disable-color
+ Default on. Include code that allows for the use of color
+ in the output display. Use --disable-color if you do not
+ want this feature compiled in to the code. The configure
+ script also recognizes the spelling "colour".
+ --enable-kill
+ --disable-kill
+ Default on. Include code that allows for renicing and sending
+ signals to processes from within top (the 'kill' and 'renice'
+ commands). Use --disable-kill if you do not want this feature
+ compiled in to the code.
30 external/bsd/top/dist/LICENSE
@@ -0,0 +1,30 @@
+Copyright (c) 1984 through 2008, William LeFebvre
+All rights reserved.
+Redistribution and use in source and binary forms, with or without
+modification, are permitted provided that the following conditions
+are met:
+ * Redistributions of source code must retain the above copyright
+notice, this list of conditions and the following disclaimer.
+ * Redistributions in binary form must reproduce the above
+copyright notice, this list of conditions and the following disclaimer
+in the documentation and/or other materials provided with the
+ * Neither the name of William LeFebvre nor the names of other
+contributors may be used to endorse or promote products derived from
+this software without specific prior written permission.
92 external/bsd/top/dist/
@@ -0,0 +1,92 @@
+# Makefile
+# This makefile was generated by configure from a definition.
+INC=boolean.h color.h commands.h config.h display.h globalstate.h hash.h \
+ loadavg.h machine.h message.h os.h screen.h sigdesc.h top.h username.h \
+ utils.h version.h
+SRC=color.c commands.c display.c hash.c screen.c top.c username.c utils.c version.c @SRC@
+OBJ=color.o commands.o display.o hash.o screen.o top.o username.o utils.o version.o @OBJ@
+DEFAULT_INCLUDES = -I. -I$(srcdir)
+BINARY = $@
+ $(LINK) $(OBJ) $(LIBS)
+# explicit dependency for the module appropriate to this machine
+m_@MODULE@.o: $(srcdir)/machine/m_@MODULE@.c
+ $(COMPILE) $(MODULE_CFLAGS) -o $@ -c $(srcdir)/machine/m_@MODULE@.c
+sigdesc.h: $(srcdir)/sigconv.awk $(SIGNAL)
+ $(AWK) -f $(srcdir)/sigconv.awk $(SIGNAL) >sigdesc.h
+install-man: $(MANPAGE)
+ mkdir -p $(DESTDIR)$(mandir)/man1
+ $(MANPAGE) $(DESTDIR)$(mandir)/man1/$(MANPAGE)
+distclean: clean
+ -rm -f Makefile config.status config.cache config.log config.h
+ autoheader
+ autoconf
+# Include file dependencies
+color.o: os.h config.h message.h color.h
+commands.o: os.h config.h sigdesc.h top.h machine.h globalstate.h \
+ boolean.h commands.h display.h utils.h version.h
+display.o: os.h config.h top.h machine.h screen.h layout.h display.h \
+ boolean.h utils.h color.h
+screen.o: os.h config.h top.h screen.h boolean.h
+top.o: os.h config.h top.h machine.h globalstate.h commands.h display.h \
+ screen.h boolean.h username.h utils.h version.h color.h
+username.o: os.h config.h top.h utils.h hash.h
+utils.o: os.h config.h top.h utils.h
+version.o: config.h top.h
+m_@MODULE@.o: top.h machine.h utils.h loadavg.h
229 external/bsd/top/dist/Porting
@@ -0,0 +1,229 @@
+Instructions for porting top to other architectures.
+This is still a preliminary document. Suggestions for improvement are
+most welcome.
+Before you embark on a port, please send me a mail message telling me
+what platform you are porting top to. There are three reasons for
+this: (1) I may already have a port, (2) module naming needs to be
+centralized, (3) I want to loosely track the various porting efforts.
+You do not need to wait for an "okay", but I do want to know that you
+are working on it. And of course, once it is finished, please send me
+the module files so that I can add them to the main distribution!
+There is one set of functions which extract all the information that
+top needs for display. These functions are collected in to one file.
+To make top work on a different architecture simply requires a
+different implementation of these functions. The functions for a
+given architecture "foo" are stored in a file called "m_foo.c". The
+Configure script looks for these files and lets the configurer choose
+one of them. This file is called a "module". The idea is that making
+top work on a different machine only requires one additional file and
+does not require changes to any existing files.
+A module template is included in the distribution, called "m-template".
+To write your own module, it is a good idea to start with this template.
+If you architecture is similar to one for which a module already
+exists, then you can start with that module instead. If you do so,
+remember to change the "AUTHOR" section at the top!
+The first comment in a module contains information which is extracted
+and used by Configure. This information is marked with words in all
+capitals (such as "SYNOPSIS:" and "LIBS:"). Go look at m-template: it
+is fairly self-explanatory. The text after "LIBS:" (on the same line)
+is extracted and included in the LIBS definition of the Makefile so
+that extra libraries which may be necessary on some machines (such as
+"-lkvm") can be specified in the module. The text after "CFLAGS:"
+(on the same line) is extracted and included as flags in the "CFLAGS"
+definition of the Makefile (thus in every compilation step). This is
+used for rare circumstances only: please don't abuse this hook.
+Some operating systems have idiosyncrasies which will affect the form
+and/or content of the information top displays. You may wish to
+document such anomalies in the top man page. This can be done by adding
+a file called m_{modulename}.man (where {modulename} is replaced with
+the name of the module). Configure will automatically add this file to
+the end of the man page. See for an example.
+A module is concerned with two structures:
+The statics struct is filled in by machine_init. Each item is a
+pointer to a list of character pointers. The list is terminated
+with a null pointer.
+struct statics
+ char **procstate_names; /* process state names */
+ char **cpustate_names; /* cpu state names */
+ char **memory_names; /* memory information names */
+The system_info struct is filled in by get_system_info and
+struct system_info
+ int last_pid; /* last pid assigned (0 means non-sequential assignment) */
+ double load_avg[NUM_AVERAGES]; /* see below */
+ int p_total; /* total number of processes */
+ int p_active; /* number of procs considered "active" */
+ int *procstates; /* array of process state counters */
+ int *cpustates; /* array of cpustate counters */
+ int *memory; /* memory information */
+The last three pointers each point to an array of integers. The
+length of the array is determined by the length of the corresponding
+_names array in the statics structure. Furthermore, if an entry in a
+_names array is the empty string ("") then the corresponding value in
+the value array will be skipped over. The display routine displays,
+for example, the string procstate_names[0] then the number
+procstates[0], then procstate_names[1], procstates[1], etc. until
+procstate_names[N] == NULL. This allows for a tremendous amount of
+flexibility in labeling the displayed values.
+"procstates" and "memory" are displayed as straight integer values.
+Values in "cpustates" are displayed as a percentage * 10. For
+example, the (integer) value 105 is displayed as 10.5%.
+These routines must be defined by the machine dependent module.
+int machine_init(struct statics *)
+ returns 0 on success and -1 on failure,
+ prints error messages
+char *format_header(char *)
+ Returns a string which should be used as the header for the
+ process display area. The argument is a string used to label
+ the username column (either "USERNAME" or "UID") and is always
+ 8 characters in length.
+void get_system_info(struct system_info *)
+caddr_t get_process_info(struct system_info *, int, int, int (*func)())
+ returns a handle to use with format_next_process
+char *format_next_process(caddr_t, char *(*func)())
+ returns string which describes next process
+int proc_compare(caddr_t, caddr_t)
+ qsort comparison function
+uid_t proc_owner(pid_t)
+ Returns the uid owner of the process specified by the pid argument.
+ This function is VERY IMPORTANT. If it fails to do its job, then
+ top may pose a security risk.
+get_process_info is called immediately after get_system_info. In
+fact, the two functions could be rolled in to one. The reason they
+are not is mostly historical.
+Top relies on the existence of a function called "setpriority" to
+change a process's priority. This exists as a kernel call on most 4.3
+BSD derived Unixes. If neither your operating system nor your C
+library supplies such a function, then you will need to add one to the
+module. It is defined as follows:
+ int setpriority (int dummy, int who, int niceval)
+ For the purposes of top, the first argument is meaningless.
+ The second is the pid and the third is the new nice value.
+ This function should behave just like a kernel call, setting
+ errno and returning -1 in case of an error. This function MUST
+ check to make sure that a non-root user does not specify a nice
+ value less than the process's current value. If it detects such
+ a condition, it should set errno to EACCES and return -1.
+ Other possible ERRNO values: ESRCH when pid "who" does not exist,
+ EPERM when the invoker is not root and not the same as the
+ process owner.
+Note that top checks process ownership and should never call setpriority
+when the invoker's uid is not root and not the same as the process's owner
+The file "machine.h" contains definitions which are useful to modules
+and to top.c (such as the structure definitions). You SHOULD NOT need
+to change it when porting to a new platform.
+Porting to a new platform should NOT require any changes to existing
+files. You should only need to add m_ files. If you feel you need a
+change in one of the existing files, please contact me so that we can
+discuss the details. I want to keep such changes as general as
+Changes were made to the module interface between 3.5 and 3.6. Here are
+the changes that need to be made to port a 3.5 module to 3.6:
+The array that stores memory statistics and is passed back in the system
+information structure as "memory" must now be an array of (signed) longs.
+This was done to more easily accomodate systems that have gigabytes of
+memory. Since the numbers are supposed to be kilobytes, a long can still
+represent up to 2 terabytes. Look for "int memory_stats[X]" (where "X"
+is some arbitrary number) and change it to "long memory_stats[X]". If
+the module support reporting swap information on a separate line, then
+its "swap_stats" array also needs to be an array of longs.
+The argument to proc_owner should be an int, as in "int pid". When it is
+used in proc_owner it should be cast as necessary. Many operating systems
+will require it to be cast to a pid_t before being compared to the appropriate
+element in the proc structure.
+In the function format_next_process, the last argument in the main call
+to sprintf is the string that contains the command for the process.
+Make sure that this last argument is enclosed in a call to "printable".
+For example: "printable(MPP(pp, p_comm))".
+The third argument to "get_process_info" needs to be changed to an integer,
+typically "int compare_index". The call to qsort in get_process_info may
+be guarded by "if (compare != NULL)". If it is, remove the if statement.
+The other changes to get_process_info depends on whether or not the module
+supports multiple sort orders.
+To support multiple keys:
+Create an array int (*proc_compares[])() and assign to it the list of
+comparison functions, NULL terminated. For example:
+int (*proc_compares[])() = {
+ compare_cpu,
+ compare_size,
+ compare_res,
+ compare_time,
+ NULL };
+In get_process_info there is a call to qsort which uses one of the
+functions in proc_compares. It should be changed so that its fourth
+argument is "proc_compares[compare_index]".
+If the module contains the function "proc_compare", it should be removed.
+There should also be a NULL-terminated array of strings which list the names
+for the sort keys, for example:
+char *ordernames[] =
+{"cpu", "size", "res", "time", NULL};
+To indicate that this module supports multiple sort keys, add the following
+line in machine_init:
+ statics->order_names = ordernames;
+If there is no support for multiple keys:
+Leave statics->order_names alone and call the comparison function of
+your choice in get_process_info, ignoring the third argument.
191 external/bsd/top/dist/README
@@ -0,0 +1,191 @@
+ Version 3.8beta1
+ William LeFebvre
+ and a cast of dozens
+If you do not want to read this entire file, then at least read
+the section at the end entitled "KNOWN PROBLEMS".
+If you are having any problems getting top to work, please read the
+file "FAQ" *before* contacting me. Thank you.
+"top" is a program that will give continual reports about the state of
+the system, including a list of the top cpu using processes. Version 3
+of "top" has three primary design goals: provide an accurate snapshot of
+the system and process state, not be one of the top processes itself, be
+as portable as possible.
+Version 3 has many bug fixes from version 2.5, and it has also been
+reorganized in a major way to make it easy to port to other platforms.
+All system dependent code is now contained in one file.
+Starting with version 3.6, top includes a "configure" script generated
+by Gnu's autoconf. This script MUST be run before attempting to
+compile top. It will explore the system and generate approriate
+contents for Makefile, config.h, and top.1.
+On some systems, top requires read access to the memory files
+"/dev/kmem" and "/dev/mem" as well as the system's kernel image. Most
+installations have these files protected from general access. These
+sites would have to install this program in the same way that programs
+such as "ps" are installed. On most systems with a /proc file system,
+top will try to read everything it can from /proc, but may need extra
+permissions to do so. The configure script will determine the
+permissions needed by the top binary, and a "make install" as root
+will get the binary installed correctly. Sometimes this requires that
+the binary be installed with set-group-id privileges and, in rare
+cases, set-user-id to root.
+CAVEAT: version 3 of top has internal commands that kill and renice
+processes. Although I have taken steps to insure that top makes
+appropriate checks with these commands, I cannot guarantee that these
+internal commands are totally secure. IF YOU INSTALL top SET-USER-ID
+TO ROOT, YOU DO SO AT YOUR OWN RISK! I realize that some operating
+systems will require top to run setuid root, and I will do everything
+I can to make sure that top is a secure setuid program.
+System support now takes the form of "modules". Adding support for a
+different architecture requires only adding a module. These modules
+are contained in the subdirectory "machine". The "configure" script
+automatically determines which module is approproate. However, it may
+not be able to determine what the correct module is. This can happen
+either because it doesn't know about the system or there is no module
+to support the system. In the former case, if you know which module
+to use, you can force "configure" to choose a particular module with
+the option "--with-module". For example, if you want to force the use
+of the svr4 module (which appears as "machine/m_svr4.c") then use
+"configure --with-module=svr4" to generate the correct Makefile. See
+the file "Porting" for a description of how to write your own module.
+To compile and install "top", read the file "INSTALL" and follow the
+directions and advice contained therein.
+If you make any kind of change to "top" that you feel would be
+beneficial to others who use this program, or if you find and fix a bug,
+please send me the change.
+Be sure to read the FAQ enclosed with the distrubution. It contains
+answers to the most commonly asked questions about the configuration,
+installation, and operation of top.
+Version 3.6 incorporated the idea of using ANSI color sequences to
+enhance information on the screen. By default, no color is used. But
+you can configure the use of color through the environment variable
+TOPCOLORS (or, for compatibility, TOPCOLOURS). The interface is
+identical to the one first implemented by, but
+the implementation is entirely different. The option -C can be used
+to diable the feature entirely.
+Any information at the top of the screen can be enhanced with color.
+However, due to implementation difficulties, the per-process area
+cannot be color-enhanced. A complete description of color support can
+be found in the man page. References for ANSI color codes can be
+found all over the Internet, but if you want a handy reference, look
+in color.h.
+Note that top is now a sourceforge project! Its project name is
+"unixtop" and you can access its project page here:
+On the project page you can find more information and access the
+official bug and feature request trackers. If you find a bug,
+want to request a feature, or need help, please submit a request
+to the appropriate tracker on sourceforge. Thank you.
+Subversion access is also provided by Sourceforge. If Subversion is
+installed on your system you can check out the project with the
+following command:
+ svn co unixtop
+There is also a web site dedicated to the project, and it is here:
+The latest version of "top" is available as a download through
+sourceforge. Start here to access the downloadable files:
+Gnu CC
+Compiling via Gnu CC continued to be the source of most of the
+questions I receive. By far the most common mistake made by those
+attempting to compile top with Gnu CC is out of date include files.
+When the operating system is upgraded, the include files that are part
+of the gcc package MUST also be updated. Gcc maintains its own
+include files. Even a minor OS upgrade can involve changes to some of
+the kernel's internal data structures, which are defined in include
+files in "sys". Top is very sensitive to these changes. If you are
+compiling with gcc and experience any sort of strange problems, please
+make sure the include files you are using are up to date BEFORE
+sending me a bug report. Look in the gcc source distribution for the
+shell script "fixincludes".
+MacOS X
+Since I don't have full time root access to a MacOS X system I cannot
+provide effective support for the platform. MacOS X uses Mach, and it
+is very difficult to extract accurate system and process information
+from the system. It takes a lot of trial and error, along with root
+access. I have included the most up-to-date version of the macosx module
+in the distribution, but I do not claim that it works. If you want to
+try to use it, you can configure with "./configure --with-module=macosx".
+HP/UX 10.10
+In their infinite wisdom, the folks at HP have decided that mere mortals
+such as you and I don't need to know what the kernel's proc structure looks
+like. To that end, they have removed all useful content from the include
+file <sys/proc.h> in version 10.10. As a result, top will not compile
+under 10.10. What HP is trying to accomplish with this move is to force
+iconoclasts such as myself to use "pstat" for collecting all process
+information. I have no immediate solution for this problem, but hope to
+obtain a sufficiently complete definition of "struct proc" at some point in
+the near future. Stay tuned.
+My perpetual thanks to all the people who have helped me support top
+on so many platforms. Without these people, top would not be what it
+is. Here is a partial list of contributors and other individuals.
+ Robert Boucher, Marc Cohen, David Cutter, Casper Dik,
+ Charles Hedrick, Andrew Herbert, Jeff Janvrin, Torsten Kasch,
+ Petri Kutvonen, William L. Jones, Tim Pugh, Steve Scherf,
+ Phillip Wu
+(My apologies if I missed anyone.)
+Top is distributed free of charge under the same terms as the BSD
+license. For an official statement, please refer to the file "LICENSE"
+which should be included with the source distribution.
+If you wish to contact me, please send a message to the sourceforge
+username "wnl".
+ William LeFebvre
+ U.S. Mail address:
+ William LeFebvre
+ 11585 Jones Bridge Road
+ Suite 420 PMB 139
+ Alpharetta, GA 30202
26 external/bsd/top/dist/Y2K
@@ -0,0 +1,26 @@
+Top and the Year 2000
+The software package top will not be affected by years numbering
+between 2000 and 2037. No portion of the top code stores dates on
+disk. All date processing in top is performed with functions from the
+Unix C library and Unix kernel. The specific functions are: time(2)
+and ctime(3S). These functions deal exclusively with conventional
+Unix time values (number of seconds since Midnight January 1, 1970
+GMT) and produce strings with a 4-digit year. At no point in the code
+for top are the last two digits used to represent a year.
+Top and the Year 2038
+In the year 2038 top will fail to represent the time of day correctly
+on 32-bit Unix operating systems. This is due to a limitation in the
+way Unix represents time. Top will only work on systems whose kernel
+call "time" and C library call "ctime" have been adjusted to represent
+time with a value greater than 32 bits. The exact date and time of
+this failure is 3:14:08 January 19, 2038 GMT. Note that this failure
+will only affect the display of the current time in the output from
+Please see the contents of the file "LICENSE" for further
1,193 external/bsd/top/dist/ap_snprintf.c
@@ -0,0 +1,1193 @@
+/* Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ *
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+ * This code is based on, and used with the permission of, the
+ * SIO stdio-replacement strx_* functions by Panos Tsirigotis
+ * <> for xinetd.
+ */
+#include "config.h"
+#include <stdio.h>
+#include <ctype.h>
+#include <sys/types.h>
+#include <stdarg.h>
+#include <string.h>
+#include <stdlib.h>
+#include <math.h>
+#include <netinet/in.h>
+#include <limits.h>
+typedef struct {
+ char *curpos;
+ char *endpos;
+} ap_vformatter_buff;
+#define API_EXPORT(type) type
+#define API_EXPORT_NONSTD(type) type
+#define ap_isalnum(c) (isalnum(((unsigned char)(c))))
+#define ap_isalpha(c) (isalpha(((unsigned char)(c))))
+#define ap_iscntrl(c) (iscntrl(((unsigned char)(c))))
+#define ap_isdigit(c) (isdigit(((unsigned char)(c))))
+#define ap_isgraph(c) (isgraph(((unsigned char)(c))))
+#define ap_islower(c) (islower(((unsigned char)(c))))
+#define ap_isprint(c) (isprint(((unsigned char)(c))))
+#define ap_ispunct(c) (ispunct(((unsigned char)(c))))
+#define ap_isspace(c) (isspace(((unsigned char)(c))))
+#define ap_isupper(c) (isupper(((unsigned char)(c))))
+#define ap_isxdigit(c) (isxdigit(((unsigned char)(c))))
+#define ap_tolower(c) (tolower(((unsigned char)(c))))
+#define ap_toupper(c) (toupper(((unsigned char)(c))))
+typedef enum {
+ NO = 0, YES = 1
+} boolean_e;
+#ifndef FALSE
+#define FALSE 0
+#ifndef TRUE
+#define TRUE 1
+#define AP_LONGEST_LONG long
+#define NUL '\0'
+#define WIDE_INT long
+typedef WIDE_INT wide_int;
+typedef unsigned WIDE_INT u_wide_int;
+typedef WIDEST_INT widest_int;
+#ifdef __TANDEM
+/* Although Tandem supports "long long" there is no unsigned variant. */
+typedef unsigned long u_widest_int;
+typedef unsigned WIDEST_INT u_widest_int;
+typedef int bool_int;
+#define S_NULL "(null)"
+#define S_NULL_LEN 6
+#define FLOAT_DIGITS 6
+ * NUM_BUF_SIZE is the size of the buffer used for arithmetic conversions
+ *
+ * XXX: this is a magic number; do not decrease it
+ */
+#define NUM_BUF_SIZE 512
+ * cvt.c - IEEE floating point formatting routines for FreeBSD
+ * from GNU libc-4.6.27. Modified to be thread safe.
+ */
+ * ap_ecvt converts to decimal
+ * the number of digits is specified by ndigit
+ * decpt is set to the position of the decimal point
+ * sign is set to 0 for positive, 1 for negative
+ */
+#define NDIG 80
+/* buf must have at least NDIG bytes */
+static char *ap_cvt(double arg, int ndigits, int *decpt, int *sign, int eflag, char *buf)
+ register int r2;
+ double fi, fj;
+ register char *p, *p1;
+ if (ndigits >= NDIG - 1)
+ ndigits = NDIG - 2;
+ r2 = 0;
+ *sign = 0;
+ p = &buf[0];
+ if (arg < 0) {
+ *sign = 1;
+ arg = -arg;
+ }
+ arg = modf(arg, &fi);
+ p1 = &buf[NDIG];
+ /*
+ * Do integer part
+ */
+ if (fi != 0) {
+ p1 = &buf[NDIG];
+ while (p1 > &buf[0] && fi != 0) {
+ fj = modf(fi / 10, &fi);
+ *--p1 = (int) ((fj + .03) * 10) + '0';
+ r2++;
+ }
+ while (p1 < &buf[NDIG])
+ *p++ = *p1++;
+ }
+ else if (arg > 0) {
+ while ((fj = arg * 10) < 1) {
+ arg = fj;
+ r2--;
+ }
+ }
+ p1 = &buf[ndigits];
+ if (eflag == 0)
+ p1 += r2;
+ *decpt = r2;
+ if (p1 < &buf[0]) {
+ buf[0] = '\0';
+ return (buf);
+ }
+ while (p <= p1 && p < &buf[NDIG]) {
+ arg *= 10;
+ arg = modf(arg, &fj);
+ *p++ = (int) fj + '0';
+ }
+ if (p1 >= &buf[NDIG]) {
+ buf[NDIG - 1] = '\0';
+ return (buf);
+ }
+ p = p1;
+ *p1 += 5;
+ while (*p1 > '9') {
+ *p1 = '0';
+ if (p1 > buf)
+ ++ * --p1;
+ else {
+ *p1 = '1';
+ (*decpt)++;
+ if (eflag == 0) {
+ if (p > buf)
+ *p = '0';
+ p++;
+ }
+ }
+ }
+ *p = '\0';
+ return (buf);
+static char *ap_ecvt(double arg, int ndigits, int *decpt, int *sign, char *buf)
+ return (ap_cvt(arg, ndigits, decpt, sign, 1, buf));
+static char *ap_fcvt(double arg, int ndigits, int *decpt, int *sign, char *buf)
+ return (ap_cvt(arg, ndigits, decpt, sign, 0, buf));
+ * ap_gcvt - Floating output conversion to
+ * minimal length string
+ */
+static char *ap_gcvt(double number, int ndigit, char *buf, boolean_e altform)
+ int sign, decpt;
+ register char *p1, *p2;
+ register int i;
+ char buf1[NDIG];
+ p1 = ap_ecvt(number, ndigit, &decpt, &sign, buf1);
+ p2 = buf;
+ if (sign)
+ *p2++ = '-';
+ for (i = ndigit - 1; i > 0 && p1[i] == '0'; i--)
+ ndigit--;
+ if ((decpt >= 0 && decpt - ndigit > 4)
+ || (decpt < 0 && decpt < -3)) { /* use E-style */
+ decpt--;
+ *p2++ = *p1++;
+ *p2++ = '.';
+ for (i = 1; i < ndigit; i++)
+ *p2++ = *p1++;
+ *p2++ = 'e';
+ if (decpt < 0) {
+ decpt = -decpt;
+ *p2++ = '-';
+ }
+ else
+ *p2++ = '+';
+ if (decpt / 100 > 0)
+ *p2++ = decpt / 100 + '0';
+ if (decpt / 10 > 0)
+ *p2++ = (decpt % 100) / 10 + '0';
+ *p2++ = decpt % 10 + '0';
+ }
+ else {
+ if (decpt <= 0) {
+ if (*p1 != '0')
+ *p2++ = '.';
+ while (decpt < 0) {
+ decpt++;
+ *p2++ = '0';
+ }
+ }
+ for (i = 1; i <= ndigit; i++) {
+ *p2++ = *p1++;
+ if (i == decpt)
+ *p2++ = '.';
+ }
+ if (ndigit < decpt) {
+ while (ndigit++ < decpt)
+ *p2++ = '0';
+ *p2++ = '.';
+ }
+ }
+ if (p2[-1] == '.' && !altform)
+ p2--;
+ *p2 = '\0';
+ return (buf);
+ * The INS_CHAR macro inserts a character in the buffer and writes
+ * the buffer back to disk if necessary
+ * It uses the char pointers sp and bep:
+ * sp points to the next available character in the buffer
+ * bep points to the end-of-buffer+1
+ * While using this macro, note that the nextb pointer is NOT updated.
+ *
+ * NOTE: Evaluation of the c argument should not have any side-effects
+ */
+#define INS_CHAR(c, sp, bep, cc) \
+ { \
+ if (sp >= bep) { \
+ vbuff->curpos = sp; \
+ if (flush_func(vbuff)) \
+ return -1; \
+ sp = vbuff->curpos; \
+ bep = vbuff->endpos; \
+ } \
+ *sp++ = (c); \
+ cc++; \
+ }
+#define NUM( c ) ( c - '0' )
+#define STR_TO_DEC( str, num ) \
+ num = NUM( *str++ ) ; \
+ while ( ap_isdigit( *str ) ) \
+ { \
+ num *= 10 ; \
+ num += NUM( *str++ ) ; \
+ }
+ * This macro does zero padding so that the precision
+ * requirement is satisfied. The padding is done by
+ * adding '0's to the left of the string that is going
+ * to be printed. We don't allow precision to be large
+ * enough that we continue past the start of s.
+ *
+ * NOTE: this makes use of the magic info that s is
+ * always based on num_buf with a size of NUM_BUF_SIZE.
+ */
+#define FIX_PRECISION( adjust, precision, s, s_len ) \
+ if ( adjust ) { \
+ int p = precision < NUM_BUF_SIZE - 1 ? precision : NUM_BUF_SIZE - 1; \
+ while ( s_len < p ) \
+ { \
+ *--s = '0' ; \
+ s_len++ ; \
+ } \
+ }
+ * Macro that does padding. The padding is done by printing
+ * the character ch.
+ */
+#define PAD( width, len, ch ) do \
+ { \
+ INS_CHAR( ch, sp, bep, cc ) ; \
+ width-- ; \
+ } \
+ while ( width > len )
+ * Prefix the character ch to the string str
+ * Increase length
+ * Set the has_prefix flag
+ */
+#define PREFIX( str, length, ch ) *--str = ch ; length++ ; has_prefix = YES
+ * Convert num to its decimal format.
+ * Return value:
+ * - a pointer to a string containing the number (no sign)
+ * - len contains the length of the string
+ * - is_negative is set to TRUE or FALSE depending on the sign
+ * of the number (always set to FALSE if is_unsigned is TRUE)
+ *
+ * The caller provides a buffer for the string: that is the buf_end argument
+ * which is a pointer to the END of the buffer + 1 (i.e. if the buffer
+ * is declared as buf[ 100 ], buf_end should be &buf[ 100 ])
+ *
+ * Note: we have 2 versions. One is used when we need to use quads
+ * (conv_10_quad), the other when we don't (conv_10). We're assuming the
+ * latter is faster.
+ */
+static char *conv_10(register wide_int num, register bool_int is_unsigned,
+ register bool_int *is_negative, char *buf_end,
+ register int *len)
+ register char *p = buf_end;
+ register u_wide_int magnitude;
+ if (is_unsigned) {
+ magnitude = (u_wide_int) num;
+ *is_negative = FALSE;
+ }
+ else {
+ *is_negative = (num < 0);
+ /*
+ * On a 2's complement machine, negating the most negative integer
+ * results in a number that cannot be represented as a signed integer.
+ * Here is what we do to obtain the number's magnitude:
+ * a. add 1 to the number
+ * b. negate it (becomes positive)
+ * c. convert it to unsigned
+ * d. add 1
+ */
+ if (*is_negative) {
+ wide_int t = num + 1;
+ magnitude = ((u_wide_int) -t) + 1;
+ }
+ else
+ magnitude = (u_wide_int) num;
+ }
+ /*
+ * We use a do-while loop so that we write at least 1 digit
+ */
+ do {
+ register u_wide_int new_magnitude = magnitude / 10;
+ *--p = (char) (magnitude - new_magnitude * 10 + '0');
+ magnitude = new_magnitude;
+ }
+ while (magnitude);
+ *len = buf_end - p;
+ return (p);
+static char *conv_10_quad(widest_int num, register bool_int is_unsigned,
+ register bool_int *is_negative, char *buf_end,
+ register int *len)
+ register char *p = buf_end;
+ u_widest_int magnitude;
+ /*
+ * We see if we can use the faster non-quad version by checking the
+ * number against the largest long value it can be. If <=, we
+ * punt to the quicker version.
+ */
+ if ((num <= ULONG_MAX && is_unsigned) || (num <= LONG_MAX && !is_unsigned))
+ return(conv_10( (wide_int)num, is_unsigned, is_negative,
+ buf_end, len));
+ if (is_unsigned) {
+ magnitude = (u_widest_int) num;
+ *is_negative = FALSE;
+ }
+ else {
+ *is_negative = (num < 0);
+ /*
+ * On a 2's complement machine, negating the most negative integer
+ * results in a number that cannot be represented as a signed integer.
+ * Here is what we do to obtain the number's magnitude:
+ * a. add 1 to the number
+ * b. negate it (becomes positive)
+ * c. convert it to unsigned
+ * d. add 1
+ */
+ if (*is_negative) {
+ widest_int t = num + 1;
+ magnitude = ((u_widest_int) -t) + 1;
+ }
+ else
+ magnitude = (u_widest_int) num;
+ }
+ /*
+ * We use a do-while loop so that we write at least 1 digit
+ */
+ do {
+ u_widest_int new_magnitude = magnitude / 10;
+ *--p = (char) (magnitude - new_magnitude * 10 + '0');
+ magnitude = new_magnitude;
+ }
+ while (magnitude);
+ *len = buf_end - p;
+ return (p);
+static char *conv_in_addr(struct in_addr *ia, char *buf_end, int *len)
+ unsigned addr = ntohl(ia->s_addr);
+ char *p = buf_end;
+ bool_int is_negative;
+ int sub_len;
+ p = conv_10((addr & 0x000000FF) , TRUE, &is_negative, p, &sub_len);
+ *--p = '.';
+ p = conv_10((addr & 0x0000FF00) >> 8, TRUE, &is_negative, p, &sub_len);
+ *--p = '.';
+ p = conv_10((addr & 0x00FF0000) >> 16, TRUE, &is_negative, p, &sub_len);
+ *--p = '.';
+ p = conv_10((addr & 0xFF000000) >> 24, TRUE, &is_negative, p, &sub_len);
+ *len = buf_end - p;
+ return (p);
+static char *conv_sockaddr_in(struct sockaddr_in *si, char *buf_end, int *len)
+ char *p = buf_end;
+ bool_int is_negative;
+ int sub_len;
+ p = conv_10(ntohs(si->sin_port), TRUE, &is_negative, p, &sub_len);
+ *--p = ':';
+ p = conv_in_addr(&si->sin_addr, p, &sub_len);
+ *len = buf_end - p;
+ return (p);
+ * Convert a floating point number to a string formats 'f', 'e' or 'E'.
+ * The result is placed in buf, and len denotes the length of the string
+ * The sign is returned in the is_negative argument (and is not placed
+ * in buf).
+ */
+static char *conv_fp(register char format, register double num,
+ boolean_e add_dp, int precision, bool_int *is_negative,
+ char *buf, int *len)
+ register char *s = buf;
+ register char *p;
+ int decimal_point;
+ char buf1[NDIG];
+ if (format == 'f')
+ p = ap_fcvt(num, precision, &decimal_point, is_negative, buf1);
+ else /* either e or E format */
+ p = ap_ecvt(num, precision + 1, &decimal_point, is_negative, buf1);
+ /*
+ * Check for Infinity and NaN
+ */
+ if (ap_isalpha(*p)) {
+ *len = strlen(strcpy(buf, p));
+ *is_negative = FALSE;
+ return (buf);
+ }
+ if (format == 'f') {
+ if (decimal_point <= 0) {
+ *s++ = '0';
+ if (precision > 0) {
+ *s++ = '.';
+ while (decimal_point++ < 0)
+ *s++ = '0';
+ }
+ else if (add_dp)
+ *s++ = '.';
+ }
+ else {
+ while (decimal_point-- > 0)
+ *s++ = *p++;
+ if (precision > 0 || add_dp)
+ *s++ = '.';
+ }
+ }
+ else {
+ *s++ = *p++;
+ if (precision > 0 || add_dp)
+ *s++ = '.';
+ }
+ /*
+ * copy the rest of p, the NUL is NOT copied
+ */
+ while (*p)
+ *s++ = *p++;
+ if (format != 'f') {
+ char temp[EXPONENT_LENGTH]; /* for exponent conversion */
+ int t_len;
+ bool_int exponent_is_negative;
+ *s++ = format; /* either e or E */
+ decimal_point--;
+ if (decimal_point != 0) {
+ p = conv_10((wide_int) decimal_point, FALSE, &exponent_is_negative,
+ &temp[EXPONENT_LENGTH], &t_len);
+ *s++ = exponent_is_negative ? '-' : '+';
+ /*
+ * Make sure the exponent has at least 2 digits
+ */
+ if (t_len == 1)
+ *s++ = '0';