From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from gnu.wildebeest.org (gnu.wildebeest.org [45.83.234.184]) by sourceware.org (Postfix) with ESMTPS id 93AB4385842A for ; Tue, 10 Oct 2023 13:43:37 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 93AB4385842A Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=klomp.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=klomp.org Received: from r6.localdomain (82-217-174-174.cable.dynamic.v4.ziggo.nl [82.217.174.174]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by gnu.wildebeest.org (Postfix) with ESMTPSA id 0286E3022F18; Tue, 10 Oct 2023 15:43:35 +0200 (CEST) Received: by r6.localdomain (Postfix, from userid 1000) id 296E63403F3; Tue, 10 Oct 2023 15:43:34 +0200 (CEST) From: Mark Wielaard To: elfutils-devel@sourceware.org Cc: hsm2@rice.edu, Mark Wielaard Subject: [PATCH 08/16] libcpu: Change calls for tsearch/tfind to eu_tsearch/eu_tfind. Date: Tue, 10 Oct 2023 15:42:52 +0200 Message-ID: <20231010134300.53830-8-mark@klomp.org> X-Mailer: git-send-email 2.41.0 In-Reply-To: <20231010134300.53830-1-mark@klomp.org> References: <301fac87e83ebbbd677750579ae9a3429b461bdf.camel@klomp.org> <20231010134300.53830-1-mark@klomp.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3033.6 required=5.0 tests=BAYES_00,GIT_PATCH_0,JMQ_SPF_NEUTRAL,KAM_DMARC_STATUS,RCVD_IN_BARRACUDACENTRAL,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: From: Heather McIntyre * libcpu/Makefile.am: Add USE_LOCKS condition for -pthread. * libcpu/i386_parse.y: Add eu-search.h and remove search.h. Change calls for tsearch/tfind to eu_tsearch/eu_tfind. Signed-off-by: Heather S. McIntyre Signed-off-by: Mark Wielaard --- libcpu/Makefile.am | 3 +++ libcpu/i386_parse.y | 48 ++++++++++++++++++++++----------------------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/libcpu/Makefile.am b/libcpu/Makefile.am index 4ba1be56..a51334b5 100644 --- a/libcpu/Makefile.am +++ b/libcpu/Makefile.am @@ -33,6 +33,9 @@ AM_CPPFLAGS += -I$(srcdir)/../libelf -I$(srcdir)/../libebl \ if BUILD_STATIC AM_CFLAGS += $(fpic_CFLAGS) endif +if USE_LOCKS + AM_CFLAGS += -pthread +endif AM_CFLAGS += -fdollars-in-identifiers LEXCOMPILE = $(LEX) $(LFLAGS) $(AM_LFLAGS) -P$( #include #include -#include +#include #include #include #include @@ -269,12 +269,12 @@ mask: kMASK kBITFIELD kNUMBER struct synonym *newp = xmalloc (sizeof (*newp)); newp->from = $2; newp->to = $3; - if (tfind (newp, &synonyms, compare_syn) != NULL) + if (eu_tfind (newp, &synonyms, compare_syn) != NULL) error (0, 0, "%d: duplicate definition for synonym '%s'", i386_lineno, $2); - else if (tsearch ( newp, &synonyms, compare_syn) == NULL) - error (EXIT_FAILURE, 0, "tsearch"); + else if (eu_tsearch ( newp, &synonyms, compare_syn) == NULL) + error (EXIT_FAILURE, 0, "eu_tsearch"); } | ; @@ -308,12 +308,12 @@ instr: bytes ':' bitfieldopt kID bitfieldopt optargs newp->bytes = $1; newp->mnemonic = $4; if (newp->mnemonic != (void *) -1l - && tfind ($4, &mnemonics, + && eu_tfind ($4, &mnemonics, (int (*)(const void *, const void *)) strcmp) == NULL) { - if (tsearch ($4, &mnemonics, + if (eu_tsearch ($4, &mnemonics, (int (*)(const void *, const void *)) strcmp) == NULL) - error (EXIT_FAILURE, errno, "tsearch"); + error (EXIT_FAILURE, errno, "eu_tsearch"); ++nmnemonics; } @@ -339,15 +339,15 @@ instr: bytes ':' bitfieldopt kID bitfieldopt optargs infname, i386_lineno - 1, $5->name); struct suffix search = { .name = $5->name }; - if (tfind (&search, &suffixes, compare_suf) + if (eu_tfind (&search, &suffixes, compare_suf) == NULL) { struct suffix *ns = xmalloc (sizeof (*ns)); ns->name = $5->name; ns->idx = ++nsuffixes; - if (tsearch (ns, &suffixes, compare_suf) + if (eu_tsearch (ns, &suffixes, compare_suf) == NULL) - error (EXIT_FAILURE, errno, "tsearch"); + error (EXIT_FAILURE, errno, "eu_tsearch"); } } @@ -374,7 +374,7 @@ bitfieldopt: kBITFIELD struct known_bitfield search; search.name = $1; struct known_bitfield **res; - res = tfind (&search, &bitfields, bitfield_compare); + res = eu_tfind (&search, &bitfields, bitfield_compare); if (res == NULL) { error (0, 0, "%d: unknown bitfield '%s'", @@ -437,7 +437,7 @@ bit: '0' struct known_bitfield search; search.name = $1; struct known_bitfield **res; - res = tfind (&search, &bitfields, bitfield_compare); + res = eu_tfind (&search, &bitfields, bitfield_compare); if (res == NULL) { error (0, 0, "%d: unknown bitfield '%s'", @@ -497,7 +497,7 @@ argcomp: kBITFIELD struct known_bitfield search; search.name = $1; struct known_bitfield **res; - res = tfind (&search, &bitfields, bitfield_compare); + res = eu_tfind (&search, &bitfields, bitfield_compare); if (res == NULL) { if (strcmp ($1, "ax") == 0) @@ -575,7 +575,7 @@ new_bitfield (char *name, unsigned long int num) newp->bits = num; newp->tmp = 0; - if (tfind (newp, &bitfields, bitfield_compare) != NULL) + if (eu_tfind (newp, &bitfields, bitfield_compare) != NULL) { error (0, 0, "%d: duplicated definition of bitfield '%s'", i386_lineno, name); @@ -584,7 +584,7 @@ new_bitfield (char *name, unsigned long int num) return; } - if (tsearch (newp, &bitfields, bitfield_compare) == NULL) + if (eu_tsearch (newp, &bitfields, bitfield_compare) == NULL) error (EXIT_FAILURE, errno, "%d: cannot insert new bitfield '%s'", i386_lineno, name); } @@ -813,7 +813,7 @@ fillin_arg (struct bitvalue *bytes, struct argname *name, struct synonym search = { .from = fieldname }; - struct synonym **res = tfind (&search, &synonyms, compare_syn); + struct synonym **res = eu_tfind (&search, &synonyms, compare_syn); if (res != NULL) fieldname = (*res)->to; @@ -914,26 +914,26 @@ find_numbers (void) if (runp->operands[i].fct != NULL) { struct argstring search = { .str = runp->operands[i].fct }; - if (tfind (&search, &fct_names[i], compare_argstring) == NULL) + if (eu_tfind (&search, &fct_names[i], compare_argstring) == NULL) { struct argstring *newp = xmalloc (sizeof (*newp)); newp->str = runp->operands[i].fct; newp->idx = 0; - if (tsearch (newp, &fct_names[i], compare_argstring) == NULL) - error (EXIT_FAILURE, errno, "tsearch"); + if (eu_tsearch (newp, &fct_names[i], compare_argstring) == NULL) + error (EXIT_FAILURE, errno, "eu_tsearch"); ++nfct_names[i]; } if (runp->operands[i].str != NULL) { search.str = runp->operands[i].str; - if (tfind (&search, &strs[i], compare_argstring) == NULL) + if (eu_tfind (&search, &strs[i], compare_argstring) == NULL) { struct argstring *newp = xmalloc (sizeof (*newp)); newp->str = runp->operands[i].str; newp->idx = 0; - if (tsearch (newp, &strs[i], compare_argstring) == NULL) - error (EXIT_FAILURE, errno, "tsearch"); + if (eu_tsearch (newp, &strs[i], compare_argstring) == NULL) + error (EXIT_FAILURE, errno, "eu_tsearch"); ++nstrs[i]; } } @@ -1206,7 +1206,7 @@ instrtable_out (void) if (instr->operands[i].fct != NULL) { struct argstring search = { .str = instr->operands[i].fct }; - struct argstring **res = tfind (&search, &fct_names[i], + struct argstring **res = eu_tfind (&search, &fct_names[i], compare_argstring); assert (res != NULL); idx = (*res)->idx; @@ -1217,7 +1217,7 @@ instrtable_out (void) if (instr->operands[i].str != NULL) { struct argstring search = { .str = instr->operands[i].str }; - struct argstring **res = tfind (&search, &strs[i], + struct argstring **res = eu_tfind (&search, &strs[i], compare_argstring); assert (res != NULL); idx = (*res)->idx; -- 2.41.0