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