From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.1 (2015-04-28) on dcvr.yhbt.net X-Spam-Level: X-Spam-ASN: AS31976 209.132.180.0/23 X-Spam-Status: No, score=-2.4 required=3.0 tests=AWL,BAYES_00,BODY_8BITS, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, RCVD_IN_DNSWL_MED,SPF_HELO_PASS,SPF_PASS shortcircuit=no autolearn=ham autolearn_force=no version=3.4.1 Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dcvr.yhbt.net (Postfix) with ESMTPS id 76BF81F85E for ; Thu, 12 Jul 2018 17:52:43 +0000 (UTC) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; q=dns; s=default; b=TSwuEEOaXk5ZoJ4d 3r0/AUtYNY4wduhcIHmjNKMmD4keXj1M3uM8UgeVGcbjFkNvwmVrxkdXIhwmN1qO RnrJ9XZqAp8r+oOgfw7HYosr62iIWDPrZiG4/t7oTu1/jQHf6npYqYAEBQsWzSt4 nlQFZjOOpVCQi+GDbErCkWAkrBc= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:subject:to:references:from:message-id:date :mime-version:in-reply-to:content-type :content-transfer-encoding; s=default; bh=YMBkU+xhTbuGuV9N7F8eXI ARW40=; b=E955Y1kLD4CF3eIU0T7bVIwXk+kM4IwBbN65Ca7x2k8sROH18HIQfx u1ZSApk+WFxwQDpJg7769RGw4LzcWCoZuLmZxVftVsbgGJzyq778i/iKrUd/4SFx uUkbzC3rO0aHoqk9t2BZksX7xnHDIkk8OPm4dpF6HN6VCm6hq6/TE= Received: (qmail 87753 invoked by alias); 12 Jul 2018 17:52:41 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Received: (qmail 86842 invoked by uid 89); 12 Jul 2018 17:52:40 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mail-ua0-f195.google.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=subject:to:references:from:openpgp:autocrypt:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=HteVqwHj2s7cgPMK4MqdpWnkhiu8jWWSzn093qnfniM=; b=YLjZIbxl06nRA08Ql8Xe86Ij8ujewJGcVeHWQsHeeNnCQa+2Ngh/s/EiKZrcMl+CQ5 HIa5cSKs2fWLaTEnKGHiMb5eFAPltdAIcKngeWVJHS02JEYPte3X5KPpKOG/RKb9zCaF 099YYqKO8ryassXyGdIQxzkZ3XK/HjyvO2LSQ= Subject: Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions To: Florian Weimer , libc-alpha@sourceware.org References: <1517591084-11347-1-git-send-email-adhemerval.zanella@linaro.org> <1517591084-11347-2-git-send-email-adhemerval.zanella@linaro.org> From: Adhemerval Zanella Openpgp: preference=signencrypt Message-ID: Date: Thu, 12 Jul 2018 14:52:32 -0300 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.8.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit 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 .  */ >> -#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.