Using sys/types.h types in sys/socket.h
Warner Losh
imp at bsdimp.com
Wed Jan 8 00:22:20 UTC 2014
On Jan 7, 2014, at 2:20 PM, Adrian Chadd wrote:
> On 17 December 2013 07:42, Warner Losh <imp at bsdimp.com> wrote:
>> The tl;dr version: use sys/_types.h and use the usual conventions to avoid namespace pollution. I read Bruce's reply, and I think I'm saying the same things he is...
>
> Yup, I've done that bit.
>
>> Warner
>>
>> On Dec 17, 2013, at 1:23 AM, Adrian Chadd wrote:
>>
>>> Hi,
>>>
>>> I have a patch to implement some new sendfile functionality, but this
>>> involves adding stuff to sys/socket.h:
>>>
>>> Index: sys/sys/socket.h
>>> ===================================================================
>>> --- sys/sys/socket.h (revision 258883)
>>> +++ sys/sys/socket.h (working copy)
>>> @@ -577,11 +577,27 @@
>>> };
>>>
>>> /*
>>> + * sendfile(2) kqueue information
>>> + */
>>> +struct sf_hdtr_kq {
>>> + int kq_fd; /* kq fd to post completion events on */
>>> + uint32_t kq_flags; /* extra flags to pass in */
>>> + void *kq_udata; /* user data pointer */
>>> + uintptr_t kq_ident; /* ident (from userland?) */
>>> +};
>>
>> This is a terrible interface. Or I'd say that the ordering of the elements in this structure is suboptimal. Having the uint32_t in the middle like that causes badness. Guess not much can be done about that given that fd must be an int, eh?
>
> I'm open to an alternate interface that doesn't require new syscalls
> or syscall modification. Yeah, the definition of an fd here is an
> 'int'. I could always turn it into an int32_t to fix the size but
> would that be "ok" ?
I'm not sure it is worth fixing in this way, since it is counter to all the other uses of fd in the system, so maybe this is the best we can have given those constraints...
Warner
More information about the freebsd-arch
mailing list