From owner-svn-src-head@freebsd.org Sun Jan 15 06:49:35 2017 Return-Path: Delivered-To: svn-src-head@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 66B10CB1698; Sun, 15 Jan 2017 06:49:35 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail109.syd.optusnet.com.au (mail109.syd.optusnet.com.au [211.29.132.80]) by mx1.freebsd.org (Postfix) with ESMTP id 26F271849; Sun, 15 Jan 2017 06:49:34 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from besplex.bde.org (c122-106-153-191.carlnfd1.nsw.optusnet.com.au [122.106.153.191]) by mail109.syd.optusnet.com.au (Postfix) with ESMTPS id 762D3D64D15; Sun, 15 Jan 2017 17:49:33 +1100 (AEDT) Date: Sun, 15 Jan 2017 17:49:33 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Ngie Cooper cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r312119 - head/sys/kern In-Reply-To: <201701140506.v0E56EHT068275@repo.freebsd.org> Message-ID: <20170115172228.U55241@besplex.bde.org> References: <201701140506.v0E56EHT068275@repo.freebsd.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.2 cv=H7qr+6Qi c=1 sm=1 tr=0 a=Tj3pCpwHnMupdyZSltBt7Q==:117 a=Tj3pCpwHnMupdyZSltBt7Q==:17 a=kj9zAlcOel0A:10 a=sPGq-izdjwqvmuXUbnIA:9 a=CjuIK1q_8ugA:10 X-BeenThere: svn-src-head@freebsd.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: SVN commit messages for the src tree for head/-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 15 Jan 2017 06:49:35 -0000 On Sat, 14 Jan 2017, Ngie Cooper wrote: > Log: > encode_long, encode_timeval: mechanically replace `exp` with `exponent` > > This helps fix a -Wshadow issue with exp(3) with tests/sys/acct/acct_test, > which include math.h, which in turn defines exp(3) But kern_acct.c doesn't include math.h. This messes up the kernel sources to simplify abusing them in tests. The bug was only in the sed script in the makefile that translates kern_acct.c to convert.c. It converts 'log(' to 'syslog(', but is missing conversion of the exp identifier to sysexp. > ============================================================================== > --- head/sys/kern/kern_acct.c Sat Jan 14 05:02:53 2017 (r312118) > +++ head/sys/kern/kern_acct.c Sat Jan 14 05:06:14 2017 (r312119) > @@ -469,8 +469,8 @@ static uint32_t > encode_timeval(struct timeval tv) > { > int log2_s; > - int val, exp; /* Unnormalized value and exponent */ > - int norm_exp; /* Normalized exponent */ > + int val, exponent; /* Unnormalized value and exponent */ > + int norm_exponent; /* Normalized exponent */ > int shift; > > /* Now the bug is also bad style in the kernel sources. The regexp was too simple and munged norm_exp too, but not the exp's in comments. The comments are more banal than before now that they don't even expand 'exp' but just echo 'exponent'. > ... > - return (((FLT_MAX_EXP - 1 + exp + norm_exp) << (FLT_MANT_DIG - 1)) | > + return (((FLT_MAX_EXP - 1 + exponent + norm_exponent) << (FLT_MANT_DIG - 1)) | > ((shift > 0 ? val << shift : val >> -shift) & MANT_MASK)); Here the expansion also broke the formatting. The details of the abuse in the test program are that acct_test.c includes math.h and then includes then convert.c which is nearly a copy of the kernel source file. This takes clean include files and not enabling warnings about redundant declarations to have a chance of working. I use a similar hack to test libm, and didn't have to mess up the sources too much to make the translation not too hard. Files have to be copied just to make the include paths manageable, and to compile them all with the same CFLAGS since this is a performance test. The most complicated parts are to avoid library functions because they might not match the sources or were compiled with different CFLAGS. The sources are not well organized well enough for my preferred method of "cc ${CLAGS} *.c" to work. Bruce