unofficial mirror of libc-alpha@sourceware.org
 help / color / mirror / Atom feed
From: Adhemerval Zanella <adhemerval.zanella@linaro.org>
To: Florian Weimer <fweimer@redhat.com>, libc-alpha@sourceware.org
Subject: Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions
Date: Thu, 12 Jul 2018 14:52:32 -0300	[thread overview]
Message-ID: <c834f9a0-0441-35f4-abff-4a283a2baf25@linaro.org> (raw)
In-Reply-To: <c6e9640b-182a-71ac-2417-838fdeeb2465@redhat.com>



On 12/07/2018 13:46, Florian Weimer wrote:
> On 02/02/2018 06:04 PM, Adhemerval Zanella wrote:
> 
>> diff --git a/include/stdc-predef.h b/include/stdc-predef.h
>> index c569759..c2ab78a 100644
>> --- a/include/stdc-predef.h
>> +++ b/include/stdc-predef.h
>> @@ -57,7 +57,4 @@
>>      - 3 additional Zanabazar Square characters */
>>   #define __STDC_ISO_10646__        201706L
>>   -/* We do not support C11 <threads.h>.  */
>> -#define __STDC_NO_THREADS__        1
> 
> Should we do this only if we know that the compiler has _Thread_local support (based on a GCC and __cplusplus version check)?

It seems reasonable, since its a installed header.  Do we need to 
check for __cplusplus too? Shouldn't __GNUC_PREREQ (4.9) be suffice?

> 
>> diff --git a/nptl/descr.h b/nptl/descr.h
>> index 64ba29e..f00e2c0 100644
>> --- a/nptl/descr.h
>> +++ b/nptl/descr.h
>> @@ -371,6 +371,8 @@ struct pthread
>>        to the function.  */
>>     void *(*start_routine) (void *);
>>     void *arg;
>> +  /* Indicates whether is a C11 thread created by thrd_creat.  */
>> +  bool c11;
>>       /* Debug state.  */
>>     td_eventbuf_t eventbuf;
> 
> Can you move the new member towards the end of the struct?  I'm worried about the ABI implications.

Right, I will do it.

> 
>> diff --git a/nptl/pthread_create.c b/nptl/pthread_create.c
>> index caaf07c..74e773a 100644
>> --- a/nptl/pthread_create.c
>> +++ b/nptl/pthread_create.c
>> @@ -460,7 +460,19 @@ START_THREAD_DEFN
>>         LIBC_PROBE (pthread_start, 3, (pthread_t) pd, pd->start_routine, pd->arg);
>>           /* Run the code the user provided.  */
>> -      THREAD_SETMEM (pd, result, pd->start_routine (pd->arg));
>> +      void *ret;
>> +      if (pd->c11)
>> +    {
>> +      /* The function pointer of the c11 thread start is cast to an incorrect
>> +         type on __pthread_create_2_1 call, however it is casted back to correct
>> +         one so the call behavior is well-defined (it is assumed that pointers
>> +         to void are able to represent all values of int.  */
>> +      int (*start)(void*) = (int (*) (void*)) pd->start_routine;
>> +      ret = (void*) (intptr_t) start (pd->arg);
> 
> (I think this required on m68k, where void * and int are returned in different registers.)
> 
>> +int
>> +thrd_join (thrd_t thr, int *res)
>> +{
>> +  void *pthread_res;
>> +  int err_code = __pthread_join (thr, &pthread_res);
>> +  if (res)
>> +   *res = (int)((uintptr_t) pthread_res);
>> +
>> +  return thrd_err_map (err_code);
>> +}
> 
> Slight inconsistency with intptr_t above.

Indeed, it seems there is no need to cast.

> 
>> diff --git a/sysdeps/nptl/threads.h b/sysdeps/nptl/threads.h
>> new file mode 100644
>> index 0000000..6adcac4
>> --- /dev/null
>> +++ b/sysdeps/nptl/threads.h
> 
> Should this be nptl/threads.h, not sysdeps/nptl/threads.h?

Right, I will move it.

  reply	other threads:[~2018-07-12 17:52 UTC|newest]

Thread overview: 80+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-02-02 17:04 [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions Adhemerval Zanella
2018-02-08 13:49   ` Gabriel F. T. Gomes
2018-02-09 10:56     ` Adhemerval Zanella
2018-02-26 12:28       ` Gabriel F. T. Gomes
2018-07-06 12:46   ` Florian Weimer
2018-07-10 19:26     ` Adhemerval Zanella
2018-07-11 15:49       ` Szabolcs Nagy
2018-07-11 16:24         ` Adhemerval Zanella
2018-07-12 12:18           ` Florian Weimer
2018-07-12 17:38             ` Adhemerval Zanella
2018-07-13  7:03               ` Florian Weimer
2018-07-12 16:46   ` Florian Weimer
2018-07-12 17:52     ` Adhemerval Zanella [this message]
2018-07-12 18:24       ` Florian Weimer
2018-07-12 19:19         ` Adhemerval Zanella
2018-07-12 19:26           ` Florian Weimer
2018-07-12 19:41             ` Adhemerval Zanella
2018-07-12 19:32       ` Adhemerval Zanella
2018-07-12 19:35         ` Florian Weimer
2018-07-12 19:43           ` Adhemerval Zanella
2018-07-13  9:45   ` Florian Weimer
2018-07-13 12:59     ` Adhemerval Zanella
2018-07-13 13:04       ` Florian Weimer
2018-07-13 13:18         ` Adhemerval Zanella
2018-07-13 13:21           ` Florian Weimer
2018-07-13  9:48   ` Florian Weimer
2018-07-25  7:20   ` Andreas Schwab
2018-07-25  7:38     ` Florian Weimer
2018-07-25 10:29     ` Joseph Myers
2018-02-02 17:04 ` [PATCH v8 2/8] nptl: Add C11 threads mtx_* functions Adhemerval Zanella
2018-07-06 12:51   ` Florian Weimer
2018-07-10 12:35     ` Adhemerval Zanella
2018-07-12 18:39       ` Florian Weimer
2018-07-12 20:30         ` Adhemerval Zanella
2018-07-12 20:38           ` Florian Weimer
2018-07-13 13:08             ` Adhemerval Zanella
2018-07-13 13:10               ` Florian Weimer
2018-07-24 12:04   ` Adhemerval Zanella
2018-07-24 16:04     ` Carlos O'Donell
2018-02-02 17:04 ` [PATCH v8 3/8] nptl: Add C11 threads call_once functions Adhemerval Zanella
2018-07-13  9:32   ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 4/8] nptl: Add C11 threads cnd_* functions Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 5/8] nptl: Add C11 threads tss_* functions Adhemerval Zanella
2018-07-12 16:48   ` Florian Weimer
2018-07-12 20:32     ` Adhemerval Zanella
2018-07-12 20:37       ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 6/8] nptl: Add abilist symbols for C11 threads Adhemerval Zanella
2018-07-13  9:50   ` Florian Weimer
2018-07-13 15:49     ` Adhemerval Zanella
2018-07-13 17:49       ` Florian Weimer
2018-07-13 18:47         ` Adhemerval Zanella
2018-07-13 19:56           ` Florian Weimer
2018-07-13 21:09             ` Adhemerval Zanella
2018-07-14 13:50               ` Florian Weimer
2018-07-18 17:40         ` Joseph Myers
2018-07-18 20:02           ` Adhemerval Zanella
2018-07-18 21:19           ` Florian Weimer
2018-02-02 17:04 ` [PATCH v8 7/8] nptl: Add test cases for ISO " Adhemerval Zanella
2018-07-13  9:31   ` Florian Weimer
2018-07-13 13:10     ` Adhemerval Zanella
2018-07-13 13:11       ` Florian Weimer
2018-07-13 13:29         ` Adhemerval Zanella
2018-07-17 13:53           ` Adhemerval Zanella
2018-02-02 17:04 ` [PATCH v8 8/8] Add manual documentation for threads.h Adhemerval Zanella
2018-06-27 13:39 ` [PATCH v8 0/8] Add support for ISO C threads.h Adhemerval Zanella
2018-07-19 17:46   ` Adhemerval Zanella
2018-07-19 18:43     ` Carlos O'Donell
2018-07-19 19:12       ` Rical Jasan
2018-07-19 19:58         ` Adhemerval Zanella
2018-07-21  0:26           ` Rical Jasan
2018-07-21  2:11             ` Carlos O'Donell
2018-07-21  6:22               ` Rical Jasan
2018-07-21 13:40                 ` Adhemerval Zanella
2018-07-19 21:26       ` Joseph Myers
2018-07-20 12:32         ` Adhemerval Zanella
2018-07-20 13:22           ` Rical Jasan
2018-07-20 13:54             ` Rical Jasan
2018-07-20 14:04               ` Carlos O'Donell
2018-07-20 15:02             ` [PATCH v8 0/8] Add support for ISO C threads.h [thrd_exit] Rical Jasan

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

  List information: https://www.gnu.org/software/libc/involved.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=c834f9a0-0441-35f4-abff-4a283a2baf25@linaro.org \
    --to=adhemerval.zanella@linaro.org \
    --cc=fweimer@redhat.com \
    --cc=libc-alpha@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: 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).