* addr2line.c: Convert to ISO C90 prototypes, change PTR, remove
[deliverable/binutils-gdb.git] / binutils / unwind-ia64.c
index 5dcd2a786162ed1b2d702b4cfcede23f3b529b4b..7c06c7b49aef3f4687401f4084dddc3eeb13cd3f 100644 (file)
@@ -1,5 +1,5 @@
 /* unwind-ia64.c -- utility routines to dump IA-64 unwind info for readelf.
-   Copyright 2000, 2001 Free Software Foundation, Inc.
+   Copyright 2000, 2001, 2003 Free Software Foundation, Inc.
        Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
 
 This file is part of GNU Binutils.
@@ -33,26 +33,27 @@ Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
 
 static bfd_vma unw_rlen = 0;
 
-static void unw_print_brmask PARAMS ((char *, unsigned int));
-static void unw_print_grmask PARAMS ((char *, unsigned int));
-static void unw_print_frmask PARAMS ((char *, unsigned int));
-static void unw_print_abreg PARAMS ((char *, unsigned int));
-static void unw_print_xyreg PARAMS ((char *, unsigned int, unsigned int));
+static void unw_print_brmask (char *, unsigned int);
+static void unw_print_grmask (char *, unsigned int);
+static void unw_print_frmask (char *, unsigned int);
+static void unw_print_abreg (char *, unsigned int);
+static void unw_print_xyreg (char *, unsigned int, unsigned int);
 
 static void
-unw_print_brmask (cp, mask)
-     char * cp;
-     unsigned int mask;
+unw_print_brmask (char *cp, unsigned int mask)
 {
-  char *sep = "";
+  int sep = 0;
   int i;
 
   for (i = 0; mask && (i < 5); ++i)
     {
       if (mask & 1)
        {
-         cp += sprintf (cp, "%sb%u", sep, i + 1);
-         sep = ",";
+         if (sep)
+           *cp++ = ',';
+         *cp++ = 'b';
+         *cp++ = i + 1 + '0';
+         sep = 1;
        }
       mask >>= 1;
     }
@@ -60,49 +61,55 @@ unw_print_brmask (cp, mask)
 }
 
 static void
-unw_print_grmask (cp, mask)
-     char * cp;
-     unsigned int mask;
+unw_print_grmask (char *cp, unsigned int mask)
 {
-  char *sep = "";
+  int sep = 0;
   int i;
 
-  *cp = '\0';
   for (i = 0; i < 4; ++i)
     {
       if (mask & 1)
        {
-         cp += sprintf (cp, "%sr%u", sep, i + 4);
-         sep = ",";
+         if (sep)
+           *cp++ = ',';
+         *cp++ = 'r';
+         *cp++ = i + 4 + '0';
+         sep = 1;
        }
       mask >>= 1;
     }
+  *cp = '\0';
 }
 
 static void
-unw_print_frmask (cp, mask)
-     char * cp;
-     unsigned int mask;
+unw_print_frmask (char *cp, unsigned int mask)
 {
-  char *sep = "";
+  int sep = 0;
   int i;
 
-  *cp = '\0';
   for (i = 0; i < 20; ++i)
     {
       if (mask & 1)
        {
-         cp += sprintf (cp, "%sf%u", sep, (i < 4) ? (i + 2) : (i + 12));
-         sep = ",";
+         if (sep)
+           *cp++ = ',';
+         *cp++ = 'f';
+         if (i < 4)
+           *cp++ = i + 2 + '0';
+         else
+           {
+             *cp++ = (i + 2) / 10 + 1 + '0';
+             *cp++ = (i + 2) % 10 + '0';
+           }
+         sep = 1;
        }
       mask >>= 1;
     }
+  *cp = '\0';
 }
 
 static void
-unw_print_abreg (cp, abreg)
-     char * cp;
-     unsigned int abreg;
+unw_print_abreg (char *cp, unsigned int abreg)
 {
   static const char *special_reg[16] =
   {
@@ -132,10 +139,7 @@ unw_print_abreg (cp, abreg)
 }
 
 static void
-unw_print_xyreg (cp, x, ytreg)
-     char *        cp;
-     unsigned int x;
-     unsigned int ytreg;
+unw_print_xyreg (char *cp, unsigned int x, unsigned int ytreg)
 {
   switch ((x << 1) | ((ytreg >> 7) & 1))
     {
@@ -237,13 +241,13 @@ typedef bfd_vma unw_word;
     }                                                          \
   while (0)
 
-#define UNW_DEC_FRGR_MEM(fmt, grmask, frmask, arg)                             \
+#define UNW_DEC_FRGR_MEM(fmt, grmask, frmask, arg)                             \
   do                                                                           \
-    {                                                                          \
+    {                                                                          \
       char frstr[200], grstr[20];                                              \
-                                                                               \
-      unw_print_grmask (grstr, grmask);                                                \
-      unw_print_frmask (frstr, frmask);                                                \
+                                                                               \
+      unw_print_grmask (grstr, grmask);                                                \
+      unw_print_frmask (frstr, frmask);                                                \
       printf ("\t%s:frgr_mem(grmask=[%s],frmask=[%s])\n", fmt, grstr, frstr);  \
     }                                                                          \
   while (0)
@@ -345,8 +349,8 @@ typedef bfd_vma unw_word;
 #define UNW_DEC_SPILL_MASK(fmt, dp, arg)                                       \
   do                                                                           \
     {                                                                          \
-      static const char * spill_type = "-frb";                                 \
-      unsigned const char * imaskp = dp;                                       \
+      static const char *spill_type = "-frb";                                  \
+      unsigned const char *imaskp = dp;                                        \
       unsigned char mask = 0;                                                  \
       bfd_vma insn = 0;                                                                \
                                                                                \
@@ -375,13 +379,13 @@ typedef bfd_vma unw_word;
     }                                                                          \
   while (0)
 
-#define UNW_DEC_SPILL_PSPREL(fmt, t, abreg, pspoff, arg)                       \
+#define UNW_DEC_SPILL_PSPREL(fmt, t, abreg, pspoff, arg)                       \
   do                                                                           \
-    {                                                                          \
-      char regname[10];                                                                \
-                                                                               \
-      unw_print_abreg (regname, abreg);                                                \
-      printf ("\t%s:spill_psprel(reg=%s,t=%lu,pspoff=0x10-0x%lx)\n",           \
+    {                                                                          \
+      char regname[10];                                                                \
+                                                                               \
+      unw_print_abreg (regname, abreg);                                                \
+      printf ("\t%s:spill_psprel(reg=%s,t=%lu,pspoff=0x10-0x%lx)\n",           \
              fmt, regname, (unsigned long) t, 4*(unsigned long)pspoff);        \
     }                                                                          \
   while (0)
@@ -409,12 +413,12 @@ typedef bfd_vma unw_word;
     }                                                          \
   while (0)
 
-#define UNW_DEC_SPILL_SPREL_P(fmt, qp, t, abreg, spoff, arg)                       \
+#define UNW_DEC_SPILL_SPREL_P(fmt, qp, t, abreg, spoff, arg)                       \
   do                                                                               \
-    {                                                                              \
-      char regname[20];                                                                    \
-                                                                                   \
-      unw_print_abreg (regname, abreg);                                                    \
+    {                                                                              \
+      char regname[20];                                                                    \
+                                                                                   \
+      unw_print_abreg (regname, abreg);                                                    \
       printf ("\t%s:spill_sprel_p(qp=p%u,t=%lu,reg=%s,spoff=0x%lx)\n",             \
              fmt, qp, (unsigned long) t, regname, 4 * (unsigned long)spoff);       \
     }                                                                              \
@@ -526,39 +530,38 @@ typedef bfd_vma unw_word;
  *     UNW_DEC_SPILL_SPREL_P(fmt,qp,t,abreg,pspoff,arg)
  */
 
-static unw_word unw_decode_uleb128 PARAMS ((const unsigned char **));
-static const unsigned char *unw_decode_x1 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_x2 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_x3 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_x4 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_r1 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_r2 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_r3 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_p1 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_p2_p5 PARAMS ((const unsigned char *,
-                                                     unsigned int, void *));
-static const unsigned char *unw_decode_p6 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_p7_p10 PARAMS ((const unsigned char *,
-                                                      unsigned int, void *));
-static const unsigned char *unw_decode_b1 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_b2 PARAMS ((const unsigned char *,
-                                                  unsigned int, void *));
-static const unsigned char *unw_decode_b3_x4 PARAMS ((const unsigned char *,
-                                                     unsigned int, void *));
+static unw_word unw_decode_uleb128 (const unsigned char **);
+static const unsigned char *unw_decode_x1
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_x2
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_x3
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_x4
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_r1
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_r2
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_r3
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_p1
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_p2_p5
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_p6
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_p7_p10
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_b1
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_b2
+  (const unsigned char *, unsigned int, void *);
+static const unsigned char *unw_decode_b3_x4
+  (const unsigned char *, unsigned int, void *);
 
 static unw_word
-unw_decode_uleb128 (dpp)
-     const unsigned char **dpp;
+unw_decode_uleb128 (const unsigned char **dpp)
 {
   unsigned shift = 0;
   unw_word byte, result = 0;
@@ -581,10 +584,8 @@ unw_decode_uleb128 (dpp)
 }
 
 static const unsigned char *
-unw_decode_x1 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code ATTRIBUTE_UNUSED;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_x1 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unsigned char byte1, abreg;
   unw_word t, off;
@@ -601,10 +602,8 @@ unw_decode_x1 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_x2 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code ATTRIBUTE_UNUSED;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_x2 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unsigned char byte1, byte2, abreg, x, ytreg;
   unw_word t;
@@ -623,10 +622,8 @@ unw_decode_x2 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_x3 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code ATTRIBUTE_UNUSED;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_x3 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unsigned char byte1, byte2, abreg, qp;
   unw_word t, off;
@@ -647,10 +644,8 @@ unw_decode_x3 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_x4 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code ATTRIBUTE_UNUSED;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_x4 (const unsigned char *dp, unsigned int code ATTRIBUTE_UNUSED,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unsigned char byte1, byte2, byte3, qp, abreg, x, ytreg;
   unw_word t;
@@ -673,10 +668,7 @@ unw_decode_x4 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_r1 (dp, code, arg)
-     const unsigned char *dp;
-     unsigned int code;
-     void *arg;
+unw_decode_r1 (const unsigned char *dp, unsigned int code, void *arg)
 {
   int body = (code & 0x20) != 0;
   unw_word rlen;
@@ -687,10 +679,7 @@ unw_decode_r1 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_r2 (dp, code, arg)
-     const unsigned char *dp;
-     unsigned int code;
-     void *arg;
+unw_decode_r2 (const unsigned char *dp, unsigned int code, void *arg)
 {
   unsigned char byte1, mask, grsave;
   unw_word rlen;
@@ -705,10 +694,7 @@ unw_decode_r2 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_r3 (dp, code, arg)
-     const unsigned char *dp;
-     unsigned int code;
-     void *arg;
+unw_decode_r3 (const unsigned char *dp, unsigned int code, void *arg)
 {
   unw_word rlen;
 
@@ -718,10 +704,8 @@ unw_decode_r3 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_p1 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_p1 (const unsigned char *dp, unsigned int code,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unsigned char brmask = (code & 0x1f);
 
@@ -730,10 +714,8 @@ unw_decode_p1 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_p2_p5 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_p2_p5 (const unsigned char *dp, unsigned int code,
+                 void *arg ATTRIBUTE_UNUSED)
 {
   if ((code & 0x10) == 0)
     {
@@ -811,10 +793,8 @@ unw_decode_p2_p5 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_p6 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_p6 (const unsigned char *dp, unsigned int code,
+              void *arg ATTRIBUTE_UNUSED)
 {
   int gregs = (code & 0x10) != 0;
   unsigned char mask = (code & 0x0f);
@@ -827,10 +807,7 @@ unw_decode_p6 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_p7_p10 (dp, code, arg)
-     const unsigned char *dp;
-     unsigned int code;
-     void *arg;
+unw_decode_p7_p10 (const unsigned char *dp, unsigned int code, void *arg)
 {
   unsigned char r, byte1, byte2;
   unw_word t, size;
@@ -1003,10 +980,8 @@ unw_decode_p7_p10 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_b1 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_b1 (const unsigned char *dp, unsigned int code,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unw_word label = (code & 0x1f);
 
@@ -1018,10 +993,8 @@ unw_decode_b1 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_b2 (dp, code, arg)
-     const unsigned char * dp;
-     unsigned int         code;
-     void *                arg ATTRIBUTE_UNUSED;
+unw_decode_b2 (const unsigned char *dp, unsigned int code,
+              void *arg ATTRIBUTE_UNUSED)
 {
   unw_word t;
 
@@ -1031,10 +1004,7 @@ unw_decode_b2 (dp, code, arg)
 }
 
 static const unsigned char *
-unw_decode_b3_x4 (dp, code, arg)
-     const unsigned char *dp;
-     unsigned int code;
-     void *arg;
+unw_decode_b3_x4 (const unsigned char *dp, unsigned int code, void *arg)
 {
   unw_word t, ecount, label;
 
@@ -1071,7 +1041,7 @@ unw_decode_b3_x4 (dp, code, arg)
 }
 
 typedef const unsigned char *(*unw_decoder)
-     PARAMS ((const unsigned char *, unsigned int, void *));
+     (const unsigned char *, unsigned int, void *);
 
 static unw_decoder unw_decode_table[2][8] =
   {
@@ -1100,10 +1070,8 @@ static unw_decoder unw_decode_table[2][8] =
 
 /* Decode one descriptor and return address of next descriptor.  */
 const unsigned char *
-unw_decode (dp, inside_body, ptr_inside_body)
-     const unsigned char * dp;
-     int                   inside_body;
-     void *                ptr_inside_body;
+unw_decode (const unsigned char *dp, int inside_body,
+           void *ptr_inside_body)
 {
   unw_decoder decoder;
   unsigned char code;
This page took 0.039359 seconds and 4 git commands to generate.