From patchwork Mon Jan 9 23:25:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jeff Johnston X-Patchwork-Id: 90594 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp325405qgi; Mon, 9 Jan 2017 15:25:44 -0800 (PST) X-Received: by 10.84.232.201 with SMTP id x9mr341035plm.102.1484004343734; Mon, 09 Jan 2017 15:25:43 -0800 (PST) Return-Path: Received: from sourceware.org (server1.sourceware.org. [209.132.180.131]) by mx.google.com with ESMTPS id z4si41064pgb.25.2017.01.09.15.25.43 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 09 Jan 2017 15:25:43 -0800 (PST) Received-SPF: pass (google.com: domain of newlib-return-14262-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) client-ip=209.132.180.131; Authentication-Results: mx.google.com; dkim=pass header.i=@sourceware.org; spf=pass (google.com: domain of newlib-return-14262-patch=linaro.org@sourceware.org designates 209.132.180.131 as permitted sender) smtp.mailfrom=newlib-return-14262-patch=linaro.org@sourceware.org DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:message-id:in-reply-to:references :subject:mime-version:content-type; q=dns; s=default; b=HokTngYZ C0ILfGb4nULWA9b3wXzXAfvedVrex6d5CrFCuHdlIHHA/Jgu0klpMsBDRiIXvbMs Pw47D4tQPDd2VxW8yHepdU7xaz4YBQF98rsTKvwFrAPgF5lT/941imDYQI0UN/Af dKDvSpZR2yPS1tvcVb71Tr01CWUJKTM3SZg= 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:date:from:to:message-id:in-reply-to:references :subject:mime-version:content-type; s=default; bh=m0MbuzyVMySiRs SRezXIL5Vrfuc=; b=s7NmqePTosSWgstiylRyv2gz6k5alGnvmgvv53jEqNMJIH Fwp0gBP/ciAVjSRAbtOUTm2K5PnLHLql00Tue5Mvvu+DLhZt5gEMyjrtKk61l0ku 7VCGzXC8LiIjgUAQ3lSllUsasRErnl53H9AuS6gB0l9m5MSig+0DcvBrDolVI= Received: (qmail 28888 invoked by alias); 9 Jan 2017 23:25:36 -0000 Mailing-List: contact newlib-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: newlib-owner@sourceware.org Delivered-To: mailing list newlib@sourceware.org Received: (qmail 28118 invoked by uid 89); 9 Jan 2017 23:25:35 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-5.1 required=5.0 tests=BAYES_00, RP_MATCHES_RCVD, SPF_HELO_PASS autolearn=ham version=3.3.2 spammy=johnston, sk:jjohnst, U*jjohnstn, Johnston X-HELO: mx6-phx2.redhat.com Received: from mx6-phx2.redhat.com (HELO mx6-phx2.redhat.com) (209.132.183.39) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 09 Jan 2017 23:25:25 +0000 Received: from zmail20.collab.prod.int.phx2.redhat.com (zmail20.collab.prod.int.phx2.redhat.com [10.5.83.23]) by mx6-phx2.redhat.com (8.14.4/8.14.4) with ESMTP id v09NPPlb036926 for ; Mon, 9 Jan 2017 18:25:25 -0500 Date: Mon, 9 Jan 2017 18:25:24 -0500 (EST) From: Jeff Johnston To: newlib@sourceware.org Message-ID: <210267905.11859124.1484004324939.JavaMail.zimbra@redhat.com> In-Reply-To: <2021529125.11840789.1483997239353.JavaMail.zimbra@redhat.com> References: <4f36fc7b-ea55-8b4a-e786-e28d7dcc23e0@somniumtech.com> <20170109152258.GD4007@calimero.vinschen.de> <2021529125.11840789.1483997239353.JavaMail.zimbra@redhat.com> Subject: Re: Use of #if DEBUG in reent.h MIME-Version: 1.0 X-IsSubscribed: yes Patch attached. I will check in if no objections. It was only used for debugging the _REENT_CHECK macros so I renamed it _REENT_CHECK_DEBUG. -- Jeff J. ----- Original Message ----- > Hmm, I appear to have put that code in ages ago (2008) because it originally > had asserts in > place by default from code changes in 2002. Not sure anyone ever used this. > > I think the choice of DEBUG was unfortunate and non-standard so, yes, > I think renaming it makes sense with at least an under-score. The flag was > meant to be a switch, opposite to NDEBUG to turn on use of the asserts so > #ifdef should be used. I will post a patch shortly. > > -- Jeff J. > > ----- Original Message ----- > > Jeff? > > > > Thanks, > > Corinna > > > > On Jan 3 16:41, Joe Seymour wrote: > > > Users can enable assertions in newlib/libc/include/sys/reent.h by > > > defining the macro DEBUG. As DEBUG is a relatively obvious and general > > > purpose name, it is also used by other projects. I've seen it used by > > > the Atmel Software Framework (ASF) and some TI Energia projects. A web > > > search finds a few more examples: > > > > > > https://forum.pjrc.com/threads/19916-reent-h-space-problems-or-just-my-pc > > > http://forum.arduino.cc/index.php?topic=151655.0 > > > > > > Actually, these are all examples of projects that have been seen to fail > > > to build with the following error: > > > > > > > include\sys\reent.h:458:10: error: #if with no expression > > > > > > This occurs when DEBUG is defined but has no value. Which seems to > > > happen with the following test case: > > > > > > > #define DEBUG > > > > #include > > > > > > Notably, I don't see an error if I remove the #define and instead pass > > > -DDEBUG (with no value) to my gcc build [msp430-elf-gcc (GCC) 7.0.0 > > > 20161220]. > > > > > > My initial reaction to seeing the error message was that this was a bug > > > in reent.h, which should use #ifdef DEBUG instead. Unfortunately if you > > > do that then "#define DEBUG 0" and -DDEBUG=0 result in debug being > > > turned on, which seems undesirable. This leads me to believe that the > > > use of #if DEBUG is deliberate and not considered a bug? > > > > > > I mention this here because I couldn't find any previous discussion of > > > it on this list, and as it has been discussed elsewhere I think there's > > > value in having a definitive statement about it here. > > > > > > Again for the record, I'll ask whether "#if DEBUG" could be changed to > > > "#if _SYS_REENT_H_DEBUG", or similar? That would avoid the error and the > > > naming conflict. I'm assuming that the examples listed above aren't > > > trying to turn newlib assertions on. I suspect that at the very least > > > DEBUG has been used for long enough that there's a stronger argument for > > > keeping it the same than for changing it to something else? > > > > > > Thanks, > > > > > > Joe Seymour > > > > -- > > Corinna Vinschen > > Cygwin Maintainer > > Red Hat > > > >From 81b770557b3390a4cac631a9662e56a553b97305 Mon Sep 17 00:00:00 2001 From: Jeff Johnston Date: Mon, 9 Jan 2017 18:21:19 -0500 Subject: [PATCH] Fix sys/reent.h to remove use of DEBUG flag. - use of DEBUG flag is non-standard and interferes with other project's using same flag - change to be _REENT_CHECK_DEBUG which means the flag is allowing debugging of _REENT_CHECK macros - use #ifdef instead of #if --- newlib/libc/include/sys/reent.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/newlib/libc/include/sys/reent.h b/newlib/libc/include/sys/reent.h index e1ed8b4..8b67889 100644 --- a/newlib/libc/include/sys/reent.h +++ b/newlib/libc/include/sys/reent.h @@ -454,8 +454,8 @@ extern const struct __sFILE_fake __sf_fake_stderr; (var)->_stderr = (__FILE *)&__sf_fake_stderr; \ } -/* Only built the assert() calls if we are built with debugging. */ -#if DEBUG +/* Only add assert() calls if we are specified to debug. */ +#ifdef _REENT_CHECK_DEBUG #include #define __reent_assert(x) assert(x) #else -- 2.5.5