]> granicus.if.org Git - procps-ng/commitdiff
KLONG
authoralbert <>
Thu, 16 Jan 2003 08:03:40 +0000 (08:03 +0000)
committeralbert <>
Thu, 16 Jan 2003 08:03:40 +0000 (08:03 +0000)
proc/ksym.c
proc/procps.h
proc/readproc.c
proc/readproc.h

index ce43db61ca9f31de71b8ec4944ae8c1c64b66742..21d9c96a4f36be7797e4aad3d5100f967eb25f58 100644 (file)
 
 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;
index 06c6642fc93fa60985722f6a1c15c4084fda4236..bcda598c9e5e8f7c4f706fd10e423fb0e5c145e6 100644 (file)
@@ -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__
index 806b5a76c88f9d11f7a58b233d9c04157f9bd005..ca6e2fa8d3b769465362f5580fd689686badde5d 100644 (file)
@@ -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,
index 5452ae0f8252b8a27eefb009700a49f0d8352b04..5ddba15b8089e1f5083fb5291551706b74c72a07 100644 (file)
@@ -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 */