1dnl $NetBSD: dwarf_pro_nametbl.m4,v 1.4 2024/03/03 17:37:32 christos Exp $ 2/*- 3 * Copyright (c) 2010 Kai Wang 4 * All rights reserved. 5 * 6 * Redistribution and use in source and binary forms, with or without 7 * modification, are permitted provided that the following conditions 8 * are met: 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions and the following disclaimer. 11 * 2. Redistributions in binary form must reproduce the above copyright 12 * notice, this list of conditions and the following disclaimer in the 13 * documentation and/or other materials provided with the distribution. 14 * 15 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 16 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 17 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 18 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 19 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 20 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 25 * SUCH DAMAGE. 26 * 27 * Id: dwarf_pro_nametbl.m4 2074 2011-10-27 03:34:33Z jkoshy 28 */ 29 30define(`MAKE_NAMETBL_PRO_API',` 31Dwarf_Unsigned 32dwarf_add_$1name(Dwarf_P_Debug dbg, Dwarf_P_Die die, char *$1_name, 33 Dwarf_Error *error) 34{ 35 Dwarf_NameTbl nt; 36 Dwarf_NamePair np; 37 38 if (dbg == NULL || die == NULL || $1_name == NULL) { 39 DWARF_SET_ERROR(dbg, error, DW_DLE_ARGUMENT); 40 return (0); 41 } 42 43 if (dbg->dbgp_$1s == NULL) { 44 dbg->dbgp_$1s = calloc(1, sizeof(struct _Dwarf_NameTbl)); 45 if (dbg->dbgp_$1s == NULL) { 46 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 47 return (0); 48 } 49 STAILQ_INIT(&dbg->dbgp_$1s->nt_nplist); 50 } 51 52 nt = dbg->dbgp_$1s; 53 54 if ((np = calloc(1, sizeof(struct _Dwarf_NamePair))) == NULL) { 55 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 56 return (0); 57 } 58 59 np->np_nt = nt; 60 np->np_die = die; 61 if ((np->np_name = strdup($1_name)) == NULL) { 62 free(np); 63 DWARF_SET_ERROR(dbg, error, DW_DLE_MEMORY); 64 return (0); 65 } 66 67 STAILQ_INSERT_TAIL(&nt->nt_nplist, np, np_next); 68 69 return (1); 70} 71') 72