From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 1791) id 43E163857428; Tue, 10 May 2022 18:19:44 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 43E163857428 Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: Adhemerval Zanella To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] elf: Use C11 atomics on _dl_mcount X-Act-Checkin: glibc X-Git-Author: Adhemerval Zanella X-Git-Refname: refs/heads/azanella/clang X-Git-Oldrev: 046853e6b8251995665dee03d09d97bf0db60426 X-Git-Newrev: fab9639153f51150300cfbfcbf6976549ad845b3 Message-Id: <20220510181944.43E163857428@sourceware.org> Date: Tue, 10 May 2022 18:19:44 +0000 (GMT) X-BeenThere: glibc-cvs@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Glibc-cvs mailing list List-Unsubscribe: , List-Archive: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 10 May 2022 18:19:44 -0000 https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=fab9639153f51150300cfbfcbf6976549ad845b3 commit fab9639153f51150300cfbfcbf6976549ad845b3 Author: Adhemerval Zanella Date: Thu Mar 10 09:32:38 2022 -0300 elf: Use C11 atomics on _dl_mcount Checked on x86_64-linux-gnu. Diff: --- elf/dl-profile.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/elf/dl-profile.c b/elf/dl-profile.c index ec57e3a965..06dbeec4b1 100644 --- a/elf/dl-profile.c +++ b/elf/dl-profile.c @@ -548,7 +548,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) size_t newfromidx; to_index = (data[narcs].self_pc / (HASHFRACTION * sizeof (*tos))); - newfromidx = catomic_exchange_and_add (&fromidx, 1) + 1; + newfromidx = atomic_fetch_and_acquire (&fromidx, 1) + 1; froms[newfromidx].here = &data[narcs]; froms[newfromidx].link = tos[to_index]; tos[to_index] = newfromidx; @@ -558,14 +558,14 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) /* If we still have no entry stop searching and insert. */ if (*topcindex == 0) { - unsigned int newarc = catomic_exchange_and_add (narcsp, 1); + unsigned int newarc = atomic_exchange_and_add (narcsp, 1) + 1; /* In rare cases it could happen that all entries in FROMS are occupied. So we cannot count this anymore. */ if (newarc >= fromlimit) goto done; - *topcindex = catomic_exchange_and_add (&fromidx, 1) + 1; + *topcindex = atomic_fetch_and_acquire (&fromidx, 1) + 1; fromp = &froms[*topcindex]; fromp->here = &data[newarc]; @@ -573,7 +573,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) data[newarc].self_pc = selfpc; data[newarc].count = 0; fromp->link = 0; - catomic_increment (&narcs); + atomic_fetch_and_acquire (&narcs, 1); break; } @@ -586,7 +586,7 @@ _dl_mcount (ElfW(Addr) frompc, ElfW(Addr) selfpc) } /* Increment the counter. */ - catomic_increment (&fromp->here->count); + atomic_fetch_and_acquire (&fromp->here->count, 1); done: ;