public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
* mimicking gomp_thead(void) for OMPD-API implementation
@ 2022-06-02  9:13 Ahmed Sayed Mousse
  2022-06-02 14:41 ` Jakub Jelinek
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmed Sayed Mousse @ 2022-06-02  9:13 UTC (permalink / raw)
  To: gcc

Hi everyone,

               To implement the function ompd_get_thread_handle (…) from
the OMPD API. I need to get  the gomp_thread struct using thread context
and address space context and in order to do that I want to apply the
functionality of/mimic  gomp_thread(void) from lipgomp.h using callbacks
but I don't know which of those two approaches should I use or whether I
should use both.


#elif defined HAVE_TLS || defined USE_EMUTLS
extern __thread struct gomp_thread gomp_tls_data;
static inline struct gomp_thread *gomp_thread (void)
{
  return &gomp_tls_data;
}
#else
extern pthread_key_t gomp_tls_key;
static inline struct gomp_thread *gomp_thread (void)
{
  return pthread_getspecific (gomp_tls_key);
}
#endif


My current thought is to try looking for the gomp_tls_data symbol and if I
don't find it I go looking for the gomp_tls_key then use
pthread_getspecific() on it.


Here is the current approach I think about using:


    lookup('gomp_tls_data')

    if return code != ok)

        go to try_key

    .....


    go to allocation

    try_key:

    lookup('gomp_tls_key')


    .....


    allocation:


    .....


    end of function


If I should use both should I save the first lookup by saving the result of
the first condition, if defined HAVE_TLS || defined USE_EMUTLS,  from
runtime in the shared library and then check on that result?


like

#if defined HAVE_TLS || defined USE_EMUTLS

#define GOMPD_USE_TLS

#endif

Thanks.

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

end of thread, other threads:[~2022-06-02 14:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-06-02  9:13 mimicking gomp_thead(void) for OMPD-API implementation Ahmed Sayed Mousse
2022-06-02 14:41 ` Jakub Jelinek

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