From ebc535469955c61d690f55fd93fef77c6d3c77a4 Mon Sep 17 00:00:00 2001 From: albert <> Date: Thu, 16 Jan 2003 08:03:40 +0000 Subject: [PATCH] KLONG --- proc/ksym.c | 10 +++++----- proc/procps.h | 25 +++++++++++++++++++++++++ proc/readproc.c | 4 ++-- proc/readproc.h | 3 ++- 4 files changed, 34 insertions(+), 8 deletions(-) diff --git a/proc/ksym.c b/proc/ksym.c index ce43db61..21d9c96a 100644 --- a/proc/ksym.c +++ b/proc/ksym.c @@ -105,7 +105,7 @@ typedef struct symb { const char *name; - unsigned long addr; + unsigned KLONG addr; } symb; static const symb fail = { "?", 0 }; @@ -185,7 +185,7 @@ static void chop_version(char *arg){ /***********************************/ -static const symb *search(unsigned long address, symb *idx, unsigned count){ +static const symb *search(unsigned KLONG address, symb *idx, unsigned count){ unsigned left; unsigned mid; unsigned right; @@ -289,7 +289,7 @@ bypass: char *saved; if(!*endp) return 1; saved = endp; - ksyms_index[ksyms_count].addr = strtoul(endp, &endp, 16); + ksyms_index[ksyms_count].addr = STRTOUKL(endp, &endp, 16); if(endp==saved || *endp != ' ') goto bad_parse; endp++; ksyms_index[ksyms_count].name = endp; @@ -392,7 +392,7 @@ good_match:; } return 1; /* success */ } - sysmap_index[sysmap_count].addr = strtoul(endp, &endp, 16); + sysmap_index[sysmap_count].addr = STRTOUKL(endp, &endp, 16); if(*endp != ' ') goto bad_parse; endp++; if(!strchr(SYMBOL_TYPE_CHARS, *endp)) goto bad_parse; @@ -561,7 +561,7 @@ const char * read_wchan_file(unsigned pid){ #define MAX_OFFSET (0x1000*sizeof(long)) /* past this is generally junk */ /* return pointer to temporary static buffer with function name */ -const char * wchan(unsigned long address, unsigned pid) { +const char * wchan(unsigned KLONG address, unsigned pid) { const symb *mod_symb; const symb *map_symb; const symb *good_symb; diff --git a/proc/procps.h b/proc/procps.h index 06c6642f..bcda598c 100644 --- a/proc/procps.h +++ b/proc/procps.h @@ -9,6 +9,31 @@ #define EXTERN_C_END #endif +// Some ports make the mistake of running a 32-bit userspace +// on a 64-bit kernel. Shame on them. It's not at all OK to +// make everything "long long", since that causes unneeded +// slowness on 32-bit hardware. +// +// SPARC: 32-bit kernel is an ex-penguin, so use "long long". +// +// MIPS: Used for embedded systems and obsolete hardware. +// Oh, there's a 64-bit version? SGI is headed toward IA-64, +// so don't worry about 64-bit MIPS. +// +// PowerPC: Big ugly problem! Macs are popular. :-/ +// +// Unknown: HP-PA-RISC, zSeries, and x86-64 +// +#if defined(__sparc__) // || defined(__mips__) || defined(__powerpc__) +#define KLONG long long // not typedef; want "unsigned KLONG" to work +#define KLF "L" +#define STRTOUKL strtoull +#else +#define KLONG long +#define KLF "l" +#define STRTOUKL strtoul +#endif + #if !defined(restrict) && __STDC_VERSION__ < 199901 #if __GNUC__ > 2 || __GNUC_MINOR__ >= 92 // maybe 92 or 95 ? #define restrict __restrict__ diff --git a/proc/readproc.c b/proc/readproc.c index 806b5a76..ca6e2fa8 100644 --- a/proc/readproc.c +++ b/proc/readproc.c @@ -200,9 +200,9 @@ static void stat2proc(const char* S, proc_t *restrict P) { "%Lu " /* start_time */ "%lu " "%ld " - "%lu %lu %lu %lu %lu %lu " + "%lu %"KLF"u %"KLF"u %"KLF"u %"KLF"u %"KLF"u " "%*s %*s %*s %*s " /* discard, no RT signals & Linux 2.1 used hex */ - "%lu %lu %lu " + "%"KLF"u %lu %lu " "%d %d " "%lu %lu", &P->state, diff --git a/proc/readproc.h b/proc/readproc.h index 5452ae0f..5ddba15b 100644 --- a/proc/readproc.h +++ b/proc/readproc.h @@ -102,7 +102,8 @@ typedef struct proc_t { cmin_flt, /* cumulative min_flt of process and child processes */ cmaj_flt, /* cumulative maj_flt of process and child processes */ nswap, /* ? */ - cnswap, /* cumulative nswap ? */ + cnswap; /* cumulative nswap ? */ + unsigned KLONG start_code, /* address of beginning of code segment */ end_code, /* address of end of code segment */ start_stack, /* address of the bottom of stack for the process */