Remove building with NOCRYPTO option
[minix3.git] / external / bsd / elftoolchain / dist / libdwarf / dwarf_nametbl.m4
blobe381dace279d2330575301eec0abf9c47a9519f2
1 /*      $NetBSD: dwarf_nametbl.m4,v 1.2 2014/03/09 16:58:04 christos Exp $      */
3 /*-
4  * Copyright (c) 2009,2011 Kai Wang
5  * All rights reserved.
6  *
7  * Redistribution and use in source and binary forms, with or without
8  * modification, are permitted provided that the following conditions
9  * are met:
10  * 1. Redistributions of source code must retain the above copyright
11  *    notice, this list of conditions and the following disclaimer.
12  * 2. Redistributions in binary form must reproduce the above copyright
13  *    notice, this list of conditions and the following disclaimer in the
14  *    documentation and/or other materials provided with the distribution.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
17  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
18  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
19  * ARE DISCLAIMED.  IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
20  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
21  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
22  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
23  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
24  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
25  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
26  * SUCH DAMAGE.
27  *
28  * Id: dwarf_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy 
29  */
31 define(`MAKE_NAMETBL_API',`
32 int
33 dwarf_get_$1s(Dwarf_Debug dbg, Dwarf_$2 **$1s,
34     Dwarf_Signed *ret_count, Dwarf_Error *error)
36         Dwarf_Section *ds;
37         int ret;
39         if (dbg == NULL || $1s == NULL || ret_count == NULL) {
40                 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
41                 return (DW_DLV_ERROR);
42         }
44         if (dbg->dbg_$1s == NULL) {
45                 if ((ds = _dwarf_find_section(dbg, ".debug_$4")) != NULL) {
46                         ret = _dwarf_nametbl_init(dbg, &dbg->dbg_$1s, ds,
47                             error);
48                         if (ret != DW_DLE_NONE)
49                                 return (DW_DLV_ERROR);
50                 }
51                 if (dbg->dbg_$1s == NULL) {
52                         DWARF_SET_ERROR(dbg, error, DW_DLE_NO_ENTRY);
53                         return (DW_DLV_NO_ENTRY);
54                 }
55         }
57         *$1s = dbg->dbg_$1s->ns_array;
58         *ret_count = dbg->dbg_$1s->ns_len;
60         return (DW_DLV_OK);
63 int
64 dwarf_$3name(Dwarf_$2 $1, char **ret_name, Dwarf_Error *error)
66         Dwarf_Debug dbg;
68         dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
70         if ($1 == NULL || ret_name == NULL) {
71                 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
72                 return (DW_DLV_ERROR);
73         }
75         *ret_name = $1->np_name;
77         return (DW_DLV_OK);
80 int
81 dwarf_$1_die_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
82     Dwarf_Error *error)
84         Dwarf_NameTbl nt;
85         Dwarf_Debug dbg;
87         dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
89         if ($1 == NULL || ret_offset == NULL) {
90                 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
91                 return (DW_DLV_ERROR);
92         }
94         nt = $1->np_nt;
95         assert(nt != NULL);
97         *ret_offset = nt->nt_cu_offset + $1->np_offset;
99         return (DW_DLV_OK);
103 dwarf_$1_cu_offset(Dwarf_$2 $1, Dwarf_Off *ret_offset,
104     Dwarf_Error *error)
106         Dwarf_NameTbl nt;
107         Dwarf_Debug dbg;
109         dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
111         if ($1 == NULL || ret_offset == NULL) {
112                 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
113                 return (DW_DLV_ERROR);
114         }
116         nt = $1->np_nt;
117         assert(nt != NULL);
119         *ret_offset = nt->nt_cu_offset;
121         return (DW_DLV_OK);
125 dwarf_$1_name_offsets(Dwarf_$2 $1, char **ret_name, Dwarf_Off *die_offset,
126     Dwarf_Off *cu_offset, Dwarf_Error *error)
128         Dwarf_CU cu;
129         Dwarf_Debug dbg;
130         Dwarf_NameTbl nt;
132         dbg = $1 != NULL ? $1->np_nt->nt_cu->cu_dbg : NULL;
134         if ($1 == NULL || ret_name == NULL || die_offset == NULL ||
135             cu_offset == NULL) {
136                 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT);
137                 return (DW_DLV_ERROR);
138         }
140         nt = $1->np_nt;
141         assert(nt != NULL);
143         cu = nt->nt_cu;
144         assert(cu != NULL);
146         *ret_name = $1->np_name;
147         *die_offset = nt->nt_cu_offset + $1->np_offset;
148         *cu_offset = cu->cu_1st_offset;
150         return (DW_DLV_OK);
153 void
154 dwarf_$1s_dealloc(Dwarf_Debug dbg, Dwarf_$2 *$1s, Dwarf_Signed count)
157         (void) dbg;
158         (void) $1s;
159         (void) count;