svn commit: r349233 - head/sys/sys

Bruce Evans brde at optusnet.com.au
Fri Jun 21 08:24:53 UTC 2019


On Thu, 20 Jun 2019, Warner Losh wrote:

> On Thu, Jun 20, 2019, 11:44 AM Bruce Evans <brde at optusnet.com.au> wrote:
>
>> On Thu, 20 Jun 2019, Alan Somers wrote:
>>
>>> On Thu, Jun 20, 2019 at 10:43 AM Bruce Evans <brde at optusnet.com.au>
>> wrote:
>>>> Summary: <sys/ioctl.h> and the headers that it includes should declare
>>>> minimal types to compile (so __int64_t is enough).  Most uses of this
>>>> header require including domain-specific headers which declare the
>>>> relevant data structures.
>>>
>>> Bruce, would you be satisfied by switching from <sys/types.h> to
>>> <sys/_types.h> and from int64_t to __int64_t?
>>
>> Not quite.  The kernel block number type is daddr_t, and [__]int64_t is
>> a hard coding of that.  Hard-coding of typedefs is good for reducing
>> namespace pollution, but it is not done for the nearby use of off_t.
>>
>> Unfortunately, daddr_t is only declared in <sys/types.h>.
>>
>> [... related type/units errors in ffs and ext2fs]
>> Using a generic int64_t type in all interfaces would avoid some of these
>> bugs, so I don't mind using it for the API.  Just add a note that it must
>> be large enough to represent all useful values of daddr_t.
>
> Maybe we should add a __daddr_t define to sys/_types.h? And the usual
> reshuffling. That would also fix the namespace pollution.

OK.  ABI's should use only fixed-width types to be stable, and APIs should
use only basic types to be stable, but avoiding typedefs (except to fixed-
width types) would be a larger project, with few existing examples.

Bruce


More information about the svn-src-head mailing list