mk_Gcursor_i.c 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  1. /* libunwind - a platform-independent unwind library
  2. Copyright (C) 2003 Hewlett-Packard Co
  3. Contributed by David Mosberger-Tang <davidm@hpl.hp.com>
  4. This file is part of libunwind.
  5. Permission is hereby granted, free of charge, to any person obtaining
  6. a copy of this software and associated documentation files (the
  7. "Software"), to deal in the Software without restriction, including
  8. without limitation the rights to use, copy, modify, merge, publish,
  9. distribute, sublicense, and/or sell copies of the Software, and to
  10. permit persons to whom the Software is furnished to do so, subject to
  11. the following conditions:
  12. The above copyright notice and this permission notice shall be
  13. included in all copies or substantial portions of the Software.
  14. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
  15. EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
  16. MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
  17. NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
  18. LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
  19. OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
  20. WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. */
  21. /* Utility to generate cursor_i.h. */
  22. #include <stdio.h>
  23. #include "libunwind_i.h"
  24. #ifdef offsetof
  25. # undef offsetof
  26. #endif
  27. #define offsetof(type,field) ((char *) &((type *) 0)->field - (char *) 0)
  28. static struct
  29. {
  30. const char name[256];
  31. unsigned long value;
  32. }
  33. tab[] =
  34. {
  35. { "IP_OFF", offsetof (struct cursor, ip) },
  36. { "PR_OFF", offsetof (struct cursor, pr) },
  37. { "BSP_OFF", offsetof (struct cursor, bsp) },
  38. { "PSP_OFF", offsetof (struct cursor, psp) },
  39. { "PFS_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_PFS]) },
  40. { "RNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_RNAT]) },
  41. { "UNAT_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_UNAT]) },
  42. { "LC_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_LC]) },
  43. { "FPSR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_FPSR]) },
  44. { "B1_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B1]) },
  45. { "B2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B2]) },
  46. { "B3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B3]) },
  47. { "B4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B4]) },
  48. { "B5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_B5]) },
  49. { "F2_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F2]) },
  50. { "F3_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F3]) },
  51. { "F4_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F4]) },
  52. { "F5_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F5]) },
  53. { "FR_LOC_OFF", offsetof (struct cursor, loc[IA64_REG_F16]) },
  54. { "LOC_SIZE",
  55. (offsetof (struct cursor, loc[1]) - offsetof (struct cursor, loc[0]))
  56. },
  57. { "SIGCONTEXT_ADDR_OFF", offsetof (struct cursor, sigcontext_addr) },
  58. };
  59. static const char *tabs = "\t\t\t\t\t\t\t\t\t\t";
  60. int
  61. main (int argc, char **argv)
  62. {
  63. const char *space;
  64. int i, num_tabs;
  65. size_t len;
  66. printf ("#ifndef cursor_i_h\n");
  67. printf ("#define cursor_i_h\n\n");
  68. printf ("/*\n * DO NOT MODIFY\n *\n * This file was generated by "
  69. "%s.\n *\n */\n\n", argv[0]);
  70. for (i = 0; i < (int) (sizeof (tab) / sizeof (tab[0])); ++i)
  71. {
  72. if (tab[i].name[0] == '\0')
  73. printf ("\n");
  74. else
  75. {
  76. len = strlen (tab[i].name);
  77. num_tabs = (40 - len) / 8;
  78. if (num_tabs <= 0)
  79. space = " ";
  80. else
  81. space = strchr(tabs, '\0') - (40 - len) / 8;
  82. printf ("#define %s%s%lu\t/* 0x%lx */\n",
  83. tab[i].name, space, tab[i].value, tab[i].value);
  84. }
  85. }
  86. printf ("\n#endif /* cursor_i_h */\n");
  87. return 0;
  88. }