From patchwork Tue May 12 13:54:20 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Arjun Shankar X-Patchwork-Id: 471360 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org 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 ozlabs.org (Postfix) with ESMTPS id 06B4A140077 for ; Tue, 12 May 2015 23:54:33 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=wvdRXkVn; dkim-atps=neutral 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:subject:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=isv rpmEB7udg8fuv4dwzYtZ6k/uGV+FG57fZdLEL/KZSZcdrmWlOcIaBeBQHOUulnLq jFraN9b/C6cYBIBZtqjOZdfsIqOX8s3SDQQKzzo2M+dOtwDuTDL9tIYC4BlPO3x/ w4+EffsvLr7bmr/Co4lMBF48uOkgxxubjlUj/D44= 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:subject:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=POMQtBwzA 5CTbFTMHOOKzz2KFF4=; b=wvdRXkVnBc8MUwe/OPHtLILPKyzwFeOFjmIaQlHwI Me/egx76Fgt/7S9Qiq4kVfwiqDA5GA6+tGBrLF0GB+6nSpafXyMLWCkp8f/eLlXK 16sCAM8d5yxFaD9JycJBQ256+ysgz9Wm/RpNF5khCenLfABwlAcF2OlN/wh2uwRl wQ= Received: (qmail 22600 invoked by alias); 12 May 2015 13:54:27 -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 Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 22590 invoked by uid 89); 12 May 2015 13:54:26 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.9 required=5.0 tests=BAYES_00, SPF_PASS, T_RP_MATCHES_RCVD autolearn=ham version=3.3.2 X-HELO: aloka.lostca.se Date: Tue, 12 May 2015 13:54:20 +0000 From: Arjun Shankar To: libc-alpha@sourceware.org Subject: [RFC] [PATCH] Ensure `wint_t' is defined before use in include/stdio.h Message-ID: <20150512135420.GA53143@aloka.lostca.se> MIME-Version: 1.0 Content-Disposition: inline User-Agent: Mutt/1.5.23 (2014-03-12) While trying to get nptl/tst-initializers1.c to include the test skeleton, I came across a couple of speed bumps. Firstly: after making the appropriate changes to the test, running `make check' led to this error: > In file included from ../malloc/malloc.h:24:0, .. > from tst-initializers1.c:60: > ../include/stdio.h:111:1: error: unknown type name `wint_t' > extern wint_t __getwc_unlocked (FILE *__fp); So, `wint_t' is used before being defined. Question: Why did test-skeleton.c not cause this error in any of the other tests that include it? Anyway, I noticed include/stdio.h includes stddef.h, which in turn defines `wint_t', but only if `__need_wint_t' is defined. So I put in a `#define __need_wint_t' before the include to get rid of the error. Is that the correct fix? A subsequent `make && make check' led to this second error: > from tst-initializers1-c89.c:1: > ../test-skeleton.c: In function `main': > ../test-skeleton.c:356:11: error: `for' loop initial declarations are only > allowed in C99 mode > for (struct temp_name_list *n = temp_name_list; Although there seem to be several other C89 no-noes in test-skeleton.c, I needed only to fix this specific one for gcc-4.8.3 to stop complaining. And finally: The attached patch was tested on x86_64 with no regressions. ChangeLog: 2015-05-12 Arjun Shankar * include/stdio.h: Define __need_wint_t. * test-skeleton.c: Avoid `for' loop initial declaration. * Use test-skeleton.c. --- include/stdio.h | 1 + nptl/tst-initializers1.c | 7 +++++-- test-skeleton.c | 3 ++- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/include/stdio.h b/include/stdio.h index 0010607..043b2b5 100644 --- a/include/stdio.h +++ b/include/stdio.h @@ -76,6 +76,7 @@ extern FILE *__old_tmpfile (void); # define __need_size_t +# define __need_wint_t # include /* Generate a unique file name (and possibly open it). */ extern int __path_search (char *__tmpl, size_t __tmpl_len, diff --git a/nptl/tst-initializers1.c b/nptl/tst-initializers1.c index e09f7a9..5119ebf 100644 --- a/nptl/tst-initializers1.c +++ b/nptl/tst-initializers1.c @@ -30,8 +30,8 @@ pthread_rwlock_t rwl_writer = PTHREAD_RWLOCK_WRITER_NONRECURSIVE_INITIALIZER_NP; pthread_cond_t cond = PTHREAD_COND_INITIALIZER; -int -main (void) +static int +do_test (void) { if (mtx_normal.__data.__kind != PTHREAD_MUTEX_TIMED_NP) return 1; @@ -55,3 +55,6 @@ main (void) return 7; return 0; } + +#define TEST_FUNCTION do_test () +#include "../test-skeleton.c" diff --git a/test-skeleton.c b/test-skeleton.c index 43fc236..1332c94 100644 --- a/test-skeleton.c +++ b/test-skeleton.c @@ -352,8 +352,9 @@ main (int argc, char *argv[]) if (temp_name_list != NULL) { + struct temp_name_list *n; fprintf (f, "temp_files=(\n"); - for (struct temp_name_list *n = temp_name_list; + for (n = temp_name_list; n != NULL; n = (struct temp_name_list *) n->q.q_forw) fprintf (f, " '%s'\n", n->name);