Print this page
5383 5234 breaks build on sparc

@@ -24,10 +24,11 @@
  */
 /*
  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  * Copyright (c) 2014, Joyent, Inc. All rights reserved.
  * Copyright (c) 2013 by Delphix. All rights reserved.
+ * Copyright 2015 Gary Mills
  */
 
 #include <sys/types.h>
 #include <sys/utsname.h>
 #include <sys/sysmacros.h>

@@ -47,11 +48,13 @@
 
 #include "libproc.h"
 #include "Pcontrol.h"
 #include "P32ton.h"
 #include "Putil.h"
+#ifdef __x86
 #include "Pcore_linux.h"
+#endif
 
 /*
  * Pcore.c - Code to initialize a ps_prochandle from a core dump.  We
  * allocate an additional structure to hold information from the core
  * file, and attach this to the standard ps_prochandle in place of the

@@ -217,11 +220,11 @@
                         __priv_free_info(core->core_privinfo);
                 if (core->core_ppii != NULL)
                         free(core->core_ppii);
                 if (core->core_zonename != NULL)
                         free(core->core_zonename);
-#if defined(__i386) || defined(__amd64)
+#ifdef __x86
                 if (core->core_ldt != NULL)
                         free(core->core_ldt);
 #endif
 
                 free(core);

@@ -269,11 +272,11 @@
         }
         (void) strlcpy(s, core->core_zonename, n);
         return (s);
 }
 
-#if defined(__i386) || defined(__amd64)
+#ifdef __x86
 /*ARGSUSED*/
 static int
 Pldt_core(struct ps_prochandle *P, struct ssd *pldt, int nldt, void *data)
 {
         core_info_t *core = data;

@@ -303,11 +306,11 @@
         .pop_psinfo     = Ppsinfo_core,
         .pop_fini       = Pfini_core,
         .pop_platform   = Pplatform_core,
         .pop_uname      = Puname_core,
         .pop_zonename   = Pzonename_core,
-#if defined(__i386) || defined(__amd64)
+#ifdef __x86
         .pop_ldt        = Pldt_core
 #endif
 };
 
 /*

@@ -429,10 +432,12 @@
 err:
         dprintf("Pgrab_core: failed to read NT_LWPSTATUS\n");
         return (-1);
 }
 
+#ifdef __x86
+
 static void
 lx_prpsinfo32_to_psinfo(lx_prpsinfo32_t *p32, psinfo_t *psinfo)
 {
         psinfo->pr_flag = p32->pr_flag;
         psinfo->pr_pid = p32->pr_pid;

@@ -627,10 +632,12 @@
 err:
         dprintf("Pgrab_core: failed to read NT_PRSTATUS\n");
         return (-1);
 }
 
+#endif /* __x86 */
+
 static int
 note_psinfo(struct ps_prochandle *P, size_t nbytes)
 {
 #ifdef _LP64
         core_info_t *core = P->data;

@@ -825,11 +832,11 @@
 
         core->core_cred = pcrp;
         return (0);
 }
 
-#if defined(__i386) || defined(__amd64)
+#ifdef __x86
 static int
 note_ldt(struct ps_prochandle *P, size_t nbytes)
 {
         core_info_t *core = P->data;
         struct ssd *pldt;

@@ -1123,13 +1130,21 @@
  * Populate a table of function pointers indexed by Note type with our
  * functions to process each type of core file note:
  */
 static int (*nhdlrs[])(struct ps_prochandle *, size_t) = {
         note_notsup,            /*  0   unassigned              */
+#ifdef __x86
         note_linux_prstatus,            /*  1   NT_PRSTATUS (old)       */
+#else
+        note_notsup,            /*  1   NT_PRSTATUS (old)       */
+#endif
         note_notsup,            /*  2   NT_PRFPREG (old)        */
+#ifdef __x86
         note_linux_psinfo,              /*  3   NT_PRPSINFO (old)       */
+#else
+        note_notsup,            /*  3   NT_PRPSINFO (old)       */
+#endif
 #ifdef __sparc
         note_xreg,              /*  4   NT_PRXREG               */
 #else
         note_notsup,            /*  4   NT_PRXREG               */
 #endif

@@ -1144,11 +1159,11 @@
 #endif
 #else
         note_notsup,            /*  7   NT_GWINDOWS             */
         note_notsup,            /*  8   NT_ASRS                 */
 #endif
-#if defined(__i386) || defined(__amd64)
+#ifdef __x86
         note_ldt,               /*  9   NT_LDT                  */
 #else
         note_notsup,            /*  9   NT_LDT                  */
 #endif
         note_pstatus,           /* 10   NT_PSTATUS              */

@@ -2199,11 +2214,13 @@
         int i, notes, pagesize;
         uintptr_t addr, base_addr;
         struct stat64 stbuf;
         void *phbuf, *php;
         size_t nbytes;
+#ifdef __x86
         boolean_t from_linux = B_FALSE;
+#endif
 
         elf_file_t aout;
         elf_file_t core;
 
         Elf_Scn *scn, *intp_scn = NULL;

@@ -2447,13 +2464,15 @@
                         }
                         /*
                          * The presence of either of these notes indicates that
                          * the dump was generated on Linux.
                          */
+#ifdef __x86
                         if (nhdr.n_type == NT_PRSTATUS ||
                             nhdr.n_type == NT_PRPSINFO)
                                 from_linux = B_TRUE;
+#endif
                 } else {
                         (void) note_notsup(P, nhdr.n_descsz);
                 }
 
                 /*

@@ -2471,10 +2490,11 @@
                  * we have left to process.
                  */
                 nleft -= sizeof (nhdr) + namesz + descsz;
         }
 
+#ifdef __x86
         if (from_linux) {
                 size_t tcount, pid;
                 lwp_info_t *lwp;
 
                 P->status.pr_dmodel = core_info->core_dmodel;

@@ -2524,10 +2544,11 @@
 
                 /* set representative thread */
                 (void) memcpy(&P->status.pr_lwp, &lwp->lwp_status,
                     sizeof (P->status.pr_lwp));
         }
+#endif /* __x86 */
 
         if (nleft != 0) {
                 dprintf("Pgrab_core: note section malformed\n");
                 *perr = G_STRANGE;
                 goto err;