Date: Sun, 23 Jun 2013 10:44:28 +1000 (EST) From: Bruce Evans <brde@optusnet.com.au> To: Garrett Cooper <yaneurabeya@gmail.com> Cc: src-committers <src-committers@FreeBSD.org>, svn-src-all <svn-src-all@FreeBSD.org>, Hiroki Sato <hrs@FreeBSD.org>, hiren panchasara <hiren@FreeBSD.org>, Glen Barber <gjb@FreeBSD.org>, Steven Hartland <killing@multiplay.co.uk>, svn-src-head <svn-src-head@FreeBSD.org>, Rick Macklem <rmacklem@FreeBSD.org> Subject: Re: svn commit: r252074 - head/sys/fs/nfsclient Message-ID: <20130623093034.A923@besplex.bde.org> In-Reply-To: <337C6949-87B6-442A-ADD6-9F12766E9919@gmail.com> References: <201306212246.r5LMkHBY070137@svn.freebsd.org><20130622042219.GC1888@glenbarber.us> <CALCpEUF__sJqEgzkx5v88c4FZTyOiKOEQuebWFJ09Bk8n-Y1jA@mail.gmail.com> <28B87860D4194B3DA2E6A992537142B1@multiplay.co.uk> <337C6949-87B6-442A-ADD6-9F12766E9919@gmail.com>
next in thread | previous in thread | raw e-mail | index | archive | help
On Sat, 22 Jun 2013, Garrett Cooper wrote: > On Jun 22, 2013, at 11:22 AM, Steven Hartland wrote: > >> I thought the use of PRIu64 was frowned on? > > It is in FreeBSD, unlike Linux (for better or for worse). It should be cast with either intmax_t or uintmax_t and use %jd or %ju. Do you mean that this mistake is not even possible in Linux (the kernel)? Linux-2.6.10 has no references to PRI* or SCN*. It doesn't even have stdint.h. The PRI* and SCN* bugs are in inttypes.h. In C99, <inttypes.h> is a historical wrapper for <stdint.h> that adds these bugs and prototypes for strtoimax() and friends. In the kernel, these files really shouldn't be used. Even in FreeBSD, it takes extra work to get these bugs. <sys/stdint.h> is standard pollution in <sys/systm.h>, but inttypes.h has to be included directly about 30 files in /sys include it under any name. Almost half of these are userland applications so they have the excuse that <inttypes.h> is a Standard header. Some of the includes, not counted in the 30, are in comments. 1 of the 30 is is an include of the nonstandard header <sys/inttypes.h>. This file doesn't exist in FreeBSD. Including it only defeats simple greps. It doesn't break the build since the include is in code ifdefed for NetBSD and OpenBSD. sys/inttypes.h existed in FreeBSD until 2001. It was removed then as part of implementing the C99 headers <stdint.h> and <inttypes.h>. I think <inttypes.h> was the old name, and exists now mainly to hold historical mistakes, while <stdint.h> is a C99 invention to clean up some of the mistakes, but unfortunately it wasn't possible to clean them all. Before 2001, FreeBSD used only the older name inttypes.h, but only had the important parts of <stdint.h> in it, and of course didn't have PRI* or SCN*. The <sys> part of <stdint.h> was created essentially by renaming sys/inttypes.h to sys/stdint.h in 2001. This means that there is no supported kernel include file containing the PRI* and SCN* mistakes. But all arches have a <machine/_inttypes.h> for exporting these mistakes to userland. 15 of the 30 files are chummy with this implemntation detail and include <machine/_inttypes.h> directly, presumably so that they can have more style bugs by using PRI*. All 15 of these files are relatively new. <machine/_inttypes.h> was not referenced in the kernel for several years after it was created. Bruce
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20130623093034.A923>