public inbox for gcc@gcc.gnu.org
 help / color / mirror / Atom feed
From: Ahmed Sayed Mousse <ahmedsayedmousse@gmail.com>
To: gcc@gcc.gnu.org
Subject: mimicking gomp_thead(void) for OMPD-API implementation
Date: Thu, 2 Jun 2022 11:13:11 +0200	[thread overview]
Message-ID: <CAG6G2yvhTZ=teWjFSX5keKOx8=AzoCLuVWmiyE7sASPJ4bKF7A@mail.gmail.com> (raw)

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.

             reply	other threads:[~2022-06-02 11:13 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-02  9:13 Ahmed Sayed Mousse [this message]
2022-06-02 14:41 ` Jakub Jelinek

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='CAG6G2yvhTZ=teWjFSX5keKOx8=AzoCLuVWmiyE7sASPJ4bKF7A@mail.gmail.com' \
    --to=ahmedsayedmousse@gmail.com \
    --cc=gcc@gcc.gnu.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: link
Be 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).