public inbox for glibc-cvs@sourceware.org help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@sourceware.org> To: glibc-cvs@sourceware.org Subject: [glibc/azanella/clang] x86: Fix bsearch for compiler that do not define __USE_EXTERN_INLINES Date: Thu, 18 Apr 2024 19:30:29 +0000 (GMT) [thread overview] Message-ID: <20240418193029.A74A83858D3C@sourceware.org> (raw) https://sourceware.org/git/gitweb.cgi?p=glibc.git;h=dd727ee173ba60b492a1105693d11cf05c087276 commit dd727ee173ba60b492a1105693d11cf05c087276 Author: Adhemerval Zanella <adhemerval.zanella@linaro.org> Date: Thu Apr 18 16:27:11 2024 -0300 x86: Fix bsearch for compiler that do not define __USE_EXTERN_INLINES The bsearch is called early during process initialization on Intel platform, before TCB has been set up; and if compiler does not enable __extern_inline it might call the symbol which might use an invalid thread-pointer. Expand the bsearch implementation from stdlib-bsearch.h with a different name. Checked on x86_64-linux-gnu with Intel chip. Diff: --- sysdeps/x86/dl-cacheinfo.h | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/sysdeps/x86/dl-cacheinfo.h b/sysdeps/x86/dl-cacheinfo.h index 5a98f70364..1943dc7db6 100644 --- a/sysdeps/x86/dl-cacheinfo.h +++ b/sysdeps/x86/dl-cacheinfo.h @@ -98,6 +98,12 @@ static const struct intel_02_cache_info #define nintel_02_known (sizeof (intel_02_known) / sizeof (intel_02_known [0])) +/* The bsearch is called early during process initialization, before TCB has + been set up; and if compiler does not enable __extern_inline it might call + the symbol which might use an invalid thread-pointer. */ +#define bsearch bsearch_inline +#include <bits/stdlib-bsearch.h> + static int intel_02_known_compare (const void *p1, const void *p2) { @@ -214,8 +220,8 @@ intel_check_word (int name, unsigned int value, bool *has_level_2, struct intel_02_cache_info search; search.idx = byte; - found = bsearch (&search, intel_02_known, nintel_02_known, - sizeof (intel_02_known[0]), intel_02_known_compare); + found = bsearch_inline (&search, intel_02_known, nintel_02_known, + sizeof (intel_02_known[0]), intel_02_known_compare); if (found != NULL) { if (found->rel_name == folded_rel_name)
reply other threads:[~2024-04-18 19:30 UTC|newest] Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions: You may reply publicly to this message via plain-text email using any one of the following methods: * Save the following mbox file, import it into your mail client, and reply-to-all from there: mbox Avoid top-posting and favor interleaved quoting: https://en.wikipedia.org/wiki/Posting_style#Interleaved_style * Reply using the --to, --cc, and --in-reply-to switches of git-send-email(1): git send-email \ --in-reply-to=20240418193029.A74A83858D3C@sourceware.org \ --to=azanella@sourceware.org \ --cc=glibc-cvs@sourceware.org \ /path/to/YOUR_REPLY https://kernel.org/pub/software/scm/git/docs/git-send-email.html * If your mail client supports setting the In-Reply-To header via mailto: links, try the mailto: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox; as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).