From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTPS id 855B2385840C for ; Mon, 7 Aug 2023 13:15:55 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 855B2385840C Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1691414155; h=from:from:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type:in-reply-to:in-reply-to: references:references; bh=6WOzB5ec19GUP/1+RajGSlaEk8uNrVJh4XVY6WaUyp0=; b=E6iPspZRfb+h4lhgjmB4aeIupR+qkpUnvcW8hDw/FGU8vuCfetVVkxkAHCryvMBHZZqYBZ cbKJecvnGV+B0vREb86C6okD/sk/xNqBcv9Z/X9hRHynMoCw1WsC4V4pEWL3XybXOF2egK noW+mgX2fVG/XccS+msoTN/U0Zpaqf0= Received: from mimecast-mx02.redhat.com (66.187.233.73 [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-85-1xgJkKVQM26YZhlTmREfaQ-1; Mon, 07 Aug 2023 09:15:51 -0400 X-MC-Unique: 1xgJkKVQM26YZhlTmREfaQ-1 Received: from smtp.corp.redhat.com (int-mx02.intmail.prod.int.rdu2.redhat.com [10.11.54.2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 9A85738294AF; Mon, 7 Aug 2023 13:15:51 +0000 (UTC) Received: from calimero.vinschen.de (unknown [10.39.193.241]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 490AA40474E1; Mon, 7 Aug 2023 13:15:51 +0000 (UTC) Received: by calimero.vinschen.de (Postfix, from userid 500) id CDD24A80BDA; Mon, 7 Aug 2023 15:15:49 +0200 (CEST) Date: Mon, 7 Aug 2023 15:15:49 +0200 From: Corinna Vinschen To: Sebastian Huber Cc: newlib@sourceware.org Subject: Re: [PATCH 2/2] sys/cdefs.h: fix for use __restrict in C++ Message-ID: Reply-To: newlib@sourceware.org Mail-Followup-To: Sebastian Huber , newlib@sourceware.org References: <20230807092825.24459-1-sebastian.huber@embedded-brains.de> <20230807092825.24459-3-sebastian.huber@embedded-brains.de> MIME-Version: 1.0 In-Reply-To: <20230807092825.24459-3-sebastian.huber@embedded-brains.de> X-Scanned-By: MIMEDefang 3.1 on 10.11.54.2 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=utf-8 Content-Disposition: inline X-Spam-Status: No, score=-11.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH,DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,GIT_PATCH_0,RCVD_IN_DNSWL_NONE,RCVD_IN_MSPIKE_H4,RCVD_IN_MSPIKE_WL,SPF_HELO_NONE,SPF_NONE,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: Hi Sebastian, On Aug 7 11:28, Sebastian Huber wrote: > diff --git a/newlib/libc/include/sys/cdefs.h b/newlib/libc/include/sys/cdefs.h > index 808498c50b..cc1a8a1ccb 100644 > --- a/newlib/libc/include/sys/cdefs.h > +++ b/newlib/libc/include/sys/cdefs.h > @@ -412,17 +412,15 @@ > #endif > > /* > - * GCC 2.95 provides `__restrict' as an extension to C90 to support the > - * C99-specific `restrict' type qualifier. We happen to use `__restrict' as > - * a way to define the `restrict' type qualifier without disturbing older > - * software that is unaware of C99 keywords. > + * We use `__restrict' as a way to define the `restrict' type qualifier > + * without disturbing older software that is unaware of C99 keywords. > + * GCC also provides `__restrict' as an extension to support C99-style > + * restricted pointers in other language modes. > */ > -#if !(__GNUC__ == 2 && __GNUC_MINOR__ == 95) > -#if !defined(__STDC_VERSION__) || __STDC_VERSION__ < 199901 > -#define __restrict > -#else > +#if defined(__STDC_VERSION__) && __STDC_VERSION__ >= 199901 > #define __restrict restrict > -#endif > +#elif !__GNUC_PREREQ__(2, 95) > +#define __restrict > #endif > > /* Turns out, this leads to a build failuer in Cygwin. We have a definition in aio.h: int lio_listio (int, struct aiocb *__restrict const [__restrict], int, struct sigevent *__restrict); and a matching one in aio.cc: int lio_listio (int mode, struct aiocb *__restrict const aiolist[__restrict], int nent, struct sigevent *__restrict sig) The problem is the bracket expression. The restrict keyword is allowed in C90, but not in C++. GLibc has a special definition __restrict_arr in cdefs.h, which is used in the brackets of the above definition: /* ISO C99 also allows to declare arrays as non-overlapping. The syntax is array_name[restrict] GCC 3.1 and clang support this. This syntax is not usable in C++ mode. */ #if (__GNUC_PREREQ (3,1) || __clang_major__ >= 3) && !defined __cplusplus # define __restrict_arr __restrict #else # ifdef __GNUC__ # define __restrict_arr /* Not supported in old GCC. */ # else # if defined __STDC_VERSION__ && __STDC_VERSION__ >= 199901L # define __restrict_arr restrict # else /* Some other non-C99 compiler. */ # define __restrict_arr /* Not supported. */ # endif # endif #endif This doesn't exist in FreeBSD, though. Do you think it's ok to add it to our cdefs.h, nevertheless? Thanks, Corinna