From owner-svn-src-all@freebsd.org Tue Nov 27 16:20:01 2018 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id BCB07115274A; Tue, 27 Nov 2018 16:20:01 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from mail104.syd.optusnet.com.au (mail104.syd.optusnet.com.au [211.29.132.246]) by mx1.freebsd.org (Postfix) with ESMTP id B755D83D76; Tue, 27 Nov 2018 16:19:59 +0000 (UTC) (envelope-from brde@optusnet.com.au) Received: from [192.168.0.102] (c110-21-101-228.carlnfd1.nsw.optusnet.com.au [110.21.101.228]) by mail104.syd.optusnet.com.au (Postfix) with ESMTPS id DAB2E42BBDC; Wed, 28 Nov 2018 03:19:47 +1100 (AEDT) Date: Wed, 28 Nov 2018 03:19:46 +1100 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Eugene Grosbein cc: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: Re: svn commit: r341006 - head/sys/netgraph In-Reply-To: <201811270405.wAR45cmZ044829@repo.freebsd.org> Message-ID: <20181128023031.H1503@besplex.bde.org> References: <201811270405.wAR45cmZ044829@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=FNpr/6gs c=1 sm=1 tr=0 a=PalzARQSbocsUSjMRkwAPg==:117 a=PalzARQSbocsUSjMRkwAPg==:17 a=kj9zAlcOel0A:10 a=_EFF_ZO1fJkJcZhbPGAA:9 a=CjuIK1q_8ugA:10 X-Rspamd-Queue-Id: B755D83D76 X-Spamd-Result: default: False [-2.14 / 15.00]; ARC_NA(0.00)[]; NEURAL_HAM_MEDIUM(-0.85)[-0.852,0]; RCPT_COUNT_THREE(0.00)[4]; TO_DN_SOME(0.00)[]; FREEMAIL_FROM(0.00)[optusnet.com.au]; FROM_HAS_DN(0.00)[]; MIME_GOOD(-0.10)[text/plain]; R_SPF_ALLOW(-0.20)[+ip4:211.29.132.0/23]; DMARC_NA(0.00)[optusnet.com.au]; TO_MATCH_ENVRCPT_ALL(0.00)[]; NEURAL_HAM_LONG(-0.97)[-0.967,0]; IP_SCORE(-0.01)[country: AU(-0.04)]; MX_GOOD(-0.01)[extmail.optusnet.com.au]; NEURAL_HAM_SHORT(-0.00)[-0.001,0]; RCVD_NO_TLS_LAST(0.10)[]; RCVD_IN_DNSWL_LOW(-0.10)[246.132.29.211.list.dnswl.org : 127.0.5.1]; R_DKIM_NA(0.00)[]; FREEMAIL_ENVFROM(0.00)[optusnet.com.au]; ASN(0.00)[asn:4804, ipnet:211.28.0.0/14, country:AU]; RCVD_COUNT_TWO(0.00)[2]; FROM_EQ_ENVFROM(0.00)[] X-Rspamd-Server: mx1.freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 27 Nov 2018 16:20:02 -0000 On Tue, 27 Nov 2018, Eugene Grosbein wrote: > Log: > ng_source(4): correction after the change r340617 > > tv_usec has "long" type for all architecture in FreeBSD > and follows __LP64__. However, this is not true for tv_sec > that has "time_t" type. tv_usec actually has type suseconds_t. suseconds_t happens to be long on all arches in FreeBSD (it is declared in an MI header without any ifdef). Hard-coding it as long here and elsewhere defeats the reason for existence of suseconds_t. The most common hard-coding of it is probably using %ld format for printing it. However, the existence of suseconds_t is a historical bug (in POSIX). This bug was missing in POSIX Issue 4. tv_usec just had type long then. POSIX added suseconds_t and hangecd the type of tv_usec to suseconds_t in Issue 5, so now almost no one knows the type of tv_usec and messy ifdefs like the one here (but messier) are needed to parse and print it portably. I think suseconds_t came from SysV or XSI. BSD just used long before it was broken to POSIX spec. Similar typedefs and messy ifdefs are unfortunately needed for too many other POSIX types, but tv_usec is too limited to need the complications. This bug is still missing for tv_nsec. I think timespecs were a POSIX invention in 1988. POSIX introduced them and intentionally left out timevals designed timespecs a bit better than timevals since timevals are too limited and unportable. Unfortunately, many older APIs like select() were never updated to the 1980's, so when POSIX started supporting these in 2001 it had to standardize timevals, so now timevals are ever further from going away than in 1988. long for tv_usec and tv_nsec is a smaller historical bug. BSD carefully used long for too many integer types as late as 4.4BSD-Lite1, because very old versions of BSD (2.x?) supported 16-bit ints, and 16-bits is is often too small, and typedef poisoning wasn't very common in merely old versions. Also, support for ABIs was weak. NetBSD changed many of these longs to int or int32_t to support alpha and/or ABIs, and Lite2 obtained these changes from somewhere near NetBSD, and FreeBSD obtained them from Lite2 in 1996. E.g., pid_t went from long in Lite1 to int32_t in Lite2. long was far too large for pid_t and most other types if long is 64 bits or larger, and using it in structs gives unnecessarily MD ABIs. In modern POSIX, int must be at least 32 bits so most types can be plain int, but historical mistakes and ABIs prevent changing the excessively typedefed APIs. So on 64-bit arches, lots of space is wasted not just for 64-bit time_t, but also for 64-bit longs for tv_[nu]sec. 32-bit tv_[nu]sec wouldn't on 64-bit arches since the struct would be padded from 96 to 128 bits. On 32-bit arches with 64-bit time_t, the longs give a natural struct size of 96i bits, and this might be padded to 128 bits (wasting space), or left unpadded (giving worse alignment). Bruce