From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-lf1-f46.google.com (mail-lf1-f46.google.com [209.85.167.46]) by sourceware.org (Postfix) with ESMTPS id CD30B3858413 for ; Thu, 26 Aug 2021 23:29:11 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CD30B3858413 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=rtems.org Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-lf1-f46.google.com with SMTP id z2so10444495lft.1 for ; Thu, 26 Aug 2021 16:29:11 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:reply-to :from:date:message-id:subject:to:cc; bh=rCOgLH77XM1lzkThNX1WcjXq61K7t/XozMp86Wx4CSs=; b=i0Z/3xLvfuFEarL0oGA0tvZsL8z+B1G91mUT4hjcGXFN2nY+pUhgj8ECOrocs3aiKZ o1EUkbEl51heZQmnG9uSeVPQBErgeAHxDeWTq/7KOQysPzI2xgnUC7LKsYVnw8Hoq78K WqX+eYVP9L+zAzoQMX/ROLD2iSE8SoghgVp1IMobG9LHONR1TAOx/caX/o1lT33JVVIn dt1VUWvzRUoPYMFFxJqKq+yQfzsG8+roH0VDJDrVzzka7x7SRjLmf9L+/mUvqLg0qixU wOs/G13xOA+J3QzhlSsfBWm6jAY5toyZKi7OGRJX7rn2pzDkYI+WTvUK3XmitMoqDVOQ CYIQ== X-Gm-Message-State: AOAM532CCr++WFfdgPCXAWyziulXhljzisva8aW276Ln2s1KIn2VImW0 7fdnmMUH5Ir6jY1Uvt96V7+tWit9//JiSQ== X-Google-Smtp-Source: ABdhPJxUuRG2lLDO9SNSrYF3GYzaRHiXBIulmOAPc3sgvSxh6jBBwNK9bRSx4Hi4hS9sUFOOdsHCcw== X-Received: by 2002:a19:f11a:: with SMTP id p26mr4651414lfh.661.1630020549985; Thu, 26 Aug 2021 16:29:09 -0700 (PDT) Received: from mail-lj1-f173.google.com (mail-lj1-f173.google.com. [209.85.208.173]) by smtp.gmail.com with ESMTPSA id s11sm485851lji.92.2021.08.26.16.29.09 for (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Thu, 26 Aug 2021 16:29:09 -0700 (PDT) Received: by mail-lj1-f173.google.com with SMTP id s3so8103737ljp.11 for ; Thu, 26 Aug 2021 16:29:09 -0700 (PDT) X-Received: by 2002:a05:651c:1596:: with SMTP id h22mr5199431ljq.448.1630020549250; Thu, 26 Aug 2021 16:29:09 -0700 (PDT) MIME-Version: 1.0 References: <20210825191245.30049-1-joel@rtems.org> In-Reply-To: Reply-To: joel@rtems.org From: Joel Sherrill Date: Thu, 26 Aug 2021 18:28:57 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: Fw: [PATCH newlib 0/1] sys/signal.h needs sys/_intsup.h To: C Howland Cc: Newlib Content-Type: text/plain; charset="UTF-8" X-Spam-Status: No, score=-3031.2 required=5.0 tests=BAYES_00, FREEMAIL_FORGED_FROMDOMAIN, FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS, KAM_ASCII_DIVIDERS, KAM_DMARC_STATUS, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_PASS, TXREP autolearn=no autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on server2.sourceware.org X-BeenThere: newlib@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Newlib mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Aug 2021 23:29:13 -0000 On Wed, Aug 25, 2021 at 2:49 PM C Howland wrote: > > ------------------------------ > > *From:* Newlib on > > behalf of Joel Sherrill > > *Sent:* Wednesday, August 25, 2021 3:12 PM > > *To:* newlib@sourceware.org > > *Subject:* [PATCH newlib 0/1] sys/signal.h needs sys/_intsup.h > > > > > > > > Hi > > > > The recent addition of the sig2str block of code for definitions and > > prototypes resulted in the following one line program not compiling > > for RTEMS targets: > > > > #include > > > > Turned out that __STDINT_EXP used to conditionalize the definition > > of SIG2STR_MAX isn't defined unless is included. > > I guess the test code got lucky. > > > > It's a simple patch that needed more background and investigation > > than code. > > > > Is it safe to assume that including each POSIX and Standard C Library file > > independently should compile? If so, I will file a ticket to at least at > > those to the RTEMS compile only tests like the ones we have that check > > a method can be used per the specific includes in the POSIX specification. > > > > While I would think that #include on any "top level" include file > would have to compile on its own, sys/signal.h does not fall under that > umbrella. That is, I don't think any valid use would call for > #include > rather than > #include > So I think the real question is whether the latter works. Yes. And after tearing into the code that didn't compile, I discovered that #include does compile unless you add -ffreestanding. When you add that, newlib's stdint.h does not get used. Instead gcc's version does and that does not define __STDINT_EXP. This is gcc's stdint.h: ==================================== #ifndef _GCC_WRAP_STDINT_H #if __STDC_HOSTED__ # if defined __cplusplus && __cplusplus >= 201103L # undef __STDC_LIMIT_MACROS # define __STDC_LIMIT_MACROS # undef __STDC_CONSTANT_MACROS # define __STDC_CONSTANT_MACROS # endif # include_next #else # include "stdint-gcc.h" #endif #define _GCC_WRAP_STDINT_H #endif ==================================== We recently added this to sys/signal.h: #if __STDINT_EXP(INT_MAX) > 0x7fff #define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("4294967295") - 1) #else #define SIG2STR_MAX (sizeof("RTMAX+") + sizeof("65535") - 1) #endif And -ffreestanding breaks that. I see two solutions: (1) Add __STDINT_EXP to gcc's stdint-gcc.h (2) Switch that #if to something else I think something like this is an OK substitute works equivalently: #if __SIZEOF_INT__ > 2 And toss my initial patch. > By "top level" include I mean one that is intended to be directly > included by a user program, as opposed to indirectly included through > another include (as one would expect sys/signal.h to be nested to > ). Yes. I should have been clearer. That's what I was wondering if was a good test case. > I'm not saying it is not a good idea that it can compile standalone, > but that I don't think it should be viewed as a requirement for every file > under include, especially most of them under sys. There are some under sys > that are called to be directly included by user programs, specifically > sys/types.h, but the vast majority are not, intended to be nested from > other system includes. So making test cases to specifically test for this > does not actually seem to be a good general idea for all include files, but > maybe only a subset. I was only thinking of ones called out in POSIX or C. Those often are listed as single includes in the specifications of the methods. --joel > Aside from that general-approach thinking, something seems very > strange here. sys/signal.h does include stdint.h and stdint.h does include > sys/_intsup.h. So something about your test case failing seems like it has > to be wrong. (I am not set up to compile with the current version, so I > can't easily check it.) > Craig > > > Sorry this slipped through. > > > > --joel > > > > Joel Sherrill (1): > > sys/signal.h: is needed for __STDINT_EXP > > > > newlib/libc/include/sys/signal.h | 4 ++++ > > 1 file changed, 4 insertions(+) > > > > -- > > 2.24.4 > > > > > > ------------------------------ > >