public inbox for gcc-bugs@sourceware.org
help / color / mirror / Atom feed
* [Bug preprocessor/96952] New: __builtin_thread_pointer support cannot be probed
@ 2020-09-07 11:25 sorear at fastmail dot com
  2020-09-07 11:32 ` [Bug preprocessor/96952] " fw at gcc dot gnu.org
                   ` (9 more replies)
  0 siblings, 10 replies; 11+ messages in thread
From: sorear at fastmail dot com @ 2020-09-07 11:25 UTC (permalink / raw)
  To: gcc-bugs

https://gcc.gnu.org/bugzilla/show_bug.cgi?id=96952

            Bug ID: 96952
           Summary: __builtin_thread_pointer support cannot be probed
           Product: gcc
           Version: 10.2.0
            Status: UNCONFIRMED
          Severity: normal
          Priority: P3
         Component: preprocessor
          Assignee: unassigned at gcc dot gnu.org
          Reporter: sorear at fastmail dot com
  Target Milestone: ---

I would like to use __builtin_thread_pointer instead of inline asm to access
the thread pointer (concretely, in kernel or libc code for risc-v), but it's
only supported by extremely recent versions of gcc and clang.  So, I would like
to detect it at compile time, but this does not work:

#if __has_builtin(__builtin_thread_pointer)
void *get_tp() { return __builtin_thread_pointer(); }
#else
/* inline asm fallback */
#endif

x.c: In function 'get_tp':
x.c:2:25: error: '__builtin_thread_pointer' is not supported on this target
    2 | void *get_tp() { return __builtin_thread_pointer(); }
      |                         ^~~~~~~~~~~~~~~~~~~~~~~~~~

__has_builtin seems to be falsely returning true?

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2023-08-15  0:58 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-09-07 11:25 [Bug preprocessor/96952] New: __builtin_thread_pointer support cannot be probed sorear at fastmail dot com
2020-09-07 11:32 ` [Bug preprocessor/96952] " fw at gcc dot gnu.org
2020-09-07 12:10 ` jakub at gcc dot gnu.org
2020-09-07 16:09 ` bugdal at aerifal dot cx
2020-09-29  7:19 ` ebotcazou at gcc dot gnu.org
2020-09-29 14:43 ` bugdal at aerifal dot cx
2020-09-29 15:24 ` ebotcazou at gcc dot gnu.org
2020-09-29 16:21 ` redi at gcc dot gnu.org
2020-09-29 19:06 ` ebotcazou at gcc dot gnu.org
2020-09-29 19:36 ` redi at gcc dot gnu.org
2023-08-15  0:58 ` [Bug c/96952] " hpa at zytor dot com

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).