Date: Sun, 15 Jan 2017 01:26:44 -0800 From: "Ngie Cooper (yaneurabeya)" <yaneurabeya@gmail.com> To: Bruce Evans <brde@optusnet.com.au> Cc: Ngie Cooper <ngie@freebsd.org>, src-committers <src-committers@freebsd.org>, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r312119 - head/sys/kern Message-ID: <53422412-6581-4C63-AD2F-8C3F5B4D4642@gmail.com> In-Reply-To: <20170115172228.U55241@besplex.bde.org> References: <201701140506.v0E56EHT068275@repo.freebsd.org> <20170115172228.U55241@besplex.bde.org>
next in thread | previous in thread | raw e-mail | index | archive | help
--Apple-Mail=_EC0928AB-B910-47A4-B5CE-0E75932072CE Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=utf-8 > On Jan 14, 2017, at 22:49, Bruce Evans <brde@optusnet.com.au> wrote: >=20 > On Sat, 14 Jan 2017, Ngie Cooper wrote: >=20 >> Log: >> encode_long, encode_timeval: mechanically replace `exp` with = `exponent` >>=20 >> 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) >=20 > But kern_acct.c doesn't include math.h. >=20 > This messes up the kernel sources to simplify abusing them in tests. >=20 > 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. >=20 >> = =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D >> --- 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; >>=20 >> /* >=20 > 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'. >=20 >> ... >> - 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)); >=20 > Here the expansion also broke the formatting. >=20 > 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. >=20 > 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. Thank you for the concerns. I=E2=80=99ve modified the approach based on = your recommendations above and submitted it as r312216. -Ngie --Apple-Mail=_EC0928AB-B910-47A4-B5CE-0E75932072CE Content-Transfer-Encoding: 7bit Content-Disposition: attachment; filename=signature.asc Content-Type: application/pgp-signature; name=signature.asc Content-Description: Message signed with OpenPGP using GPGMail -----BEGIN PGP SIGNATURE----- Comment: GPGTools - https://gpgtools.org iQIcBAEBCgAGBQJYe0BVAAoJEPWDqSZpMIYVx4EQAMY2HVJRY8sJdUntdKbCqxkB Fp2y6FlEGyQqaSIYFqlzW5cAG1JtxjcBalKpT8mcN13JoN36IBYslxUmLyvo2GF6 tfOfavAYgIqJGJcnwmTfoRj99O7FIk72L43FbRSh1BOO7CHbpIMY1miOPZJX2hmK 2DUFFbXxBNT3K/43VXdLCXqbiMz9JRbOw8zu94anTDOyf6KNZ7OeKWgmXErD2dR5 TEcdJHxfUD6CxsM8Sy2hJ4dYp+gMYMTHtQWHmh0MyQiVyKN8t53nW80ziyInkXII wV65aagnuDzCa1S3CnwtAvMePfw6487fMj2OyKU1G2MsspnrZHEfgfvVaHXkgFRD u757fbaGGgov4EELv1IMAd6BePJ9h4AkkwS0EethWOehZb1Q84S91tANimwDmMS8 tURdqlcYxH/6iqMPyZCv1Fee47VC40CY6dcj6wZPZQrBVAl4UI4cfbCgVfgTtQTF wTBm4ROjui5Pbf47r2I062vUMnjRG48SX1kH5JaTdOMOZnRbN5VVYJLUcyXG53wO oxyF4kFv/sqz0mUED4LJArK34Cz/V1XNnoc+jLZ/LGuIh/xGPOwIQu1Tv3885PH3 L4hgm8yDlDKI0Fg1AFwIPvpIm3hVmC2N0AZbec3seQrRyjbaWlXc4LfEI7D3bzwR iP54g1hLCzw+P0cL6NAt =DKD0 -----END PGP SIGNATURE----- --Apple-Mail=_EC0928AB-B910-47A4-B5CE-0E75932072CE--
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?53422412-6581-4C63-AD2F-8C3F5B4D4642>