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=-3.6 required=3.0 tests=AWL,BAYES_00,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 9809F1F90A for ; Thu, 12 Jul 2018 16:46:35 +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=If8x53sPs/jJ55DF 4cJTtwK9dHWJqT1drYLMVH4Yx9eBhN5Jc8kb02Vq+VPerrTH+9zG0jJMDdmyTBcj cC+YeFzIe7/bR55UXYaWfbqmJxDQiEcQ7LMooLccMA7FSShm4uKA32q4N7EzMhjC zPLLYrZz3ErAhYhXMzRE4tGLlDU= 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=nO33viYDv6OW0k4DdB+twr h65aI=; b=mRGbUjyMr81ZCRjQ2Iq8P2gu33Kmg578NCWDOhcHsfk0wHmCW+X09e hMnqdICh2hFl44wwfU05gQD7dnUdapb0TL1l0kdLv//3awd8siKg56m3kg06N+26 2Onc6fPNAg0D+a8QULWbBQ8cNGmJHfjEkWN8w9CtUZKjatXqdLZ1w= Received: (qmail 86216 invoked by alias); 12 Jul 2018 16:46:33 -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 86157 invoked by uid 89); 12 Jul 2018 16:46:23 -0000 Authentication-Results: sourceware.org; auth=none X-HELO: mx1.redhat.com Subject: Re: [PATCH v8 1/8] nptl: Add C11 threads thrd_* functions To: Adhemerval Zanella , 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: Florian Weimer Message-ID: Date: Thu, 12 Jul 2018 18:46:19 +0200 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: <1517591084-11347-2-git-send-email-adhemerval.zanella@linaro.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit 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)? > 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. > 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. > 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? Thanks, Florian