Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 7 Jan 2014 16:46:35 -0800
From:      Peter Wemm <peter@wemm.org>
To:        Bruce Evans <brde@optusnet.com.au>
Cc:        Adrian Chadd <adrian@freebsd.org>, "freebsd-arch@freebsd.org" <freebsd-arch@freebsd.org>
Subject:   Re: Using sys/types.h types in sys/socket.h
Message-ID:  <CAGE5yCp=UEQ-jbtect31T4G_dXxOvmBMPYzix-w%2B-QSLSA%2BU4A@mail.gmail.com>
In-Reply-To: <20131219154839.T23018@besplex.bde.org>
References:  <CAJ-Vmo=MWPQWfP9duWPPwaKee5Zp9Gemj3GKqE8=bxkjn_1YYA@mail.gmail.com> <9C1291B5-215B-440E-B8B0-6308840F755C@bsdimp.com> <CAJ-Vmokb-gcO%2BrEOn-uc42%2BPHzMMQsqBe0NcVtuNRKk7vuM5Qw@mail.gmail.com> <CAJ-Vmom%2BXMZgdKds88id9vhQar=P-bF3UpUFzk4E3KWUw%2BQacQ@mail.gmail.com> <20131219154839.T23018@besplex.bde.org>

next in thread | previous in thread | raw e-mail | index | archive | help
On Wed, Dec 18, 2013 at 9:20 PM, Bruce Evans <brde@optusnet.com.au> wrote:
> On Wed, 18 Dec 2013, Adrian Chadd wrote:
>
>> Ok, how about this:
>>
>> Index: sys/sys/socket.h
>> ===================================================================
>> --- sys/sys/socket.h    (revision 259475)
>> +++ sys/sys/socket.h    (working copy)
>> @@ -84,6 +84,16 @@
>> #endif
>> #endif
>>
>> +#ifndef _UINT32_T_DECLARED
>> +#define        _UINT32_T_DECLARED
>> +typedef __uint32_t     uint32_t;
>> +#endif
>> +
>> +#ifndef _UINTPTR_T_DECLARED
>> +#define _UINTPTR_T_DECLARED
>> +typedef __uintptr_t    uintptr_t;
>> +#endif
>> +
>> /*
>>  * Types
>>  */
>
>
> This seems to be correct, except the tab after the second #define is
> corrupt.  Actually, all the tabs are corrupt, but the first #define
> apparently started with a tab whose corruption made a larger mess.
>
> imp@ said, in a message that should have been killfiled due to top posting,
> that this should be under __BSD_VISIBLE.  That isn't strictly necessary,
> since POSIX allows names ending with _t, and it isn't very important for
> avoiding pollution since there aren't very many of them.
>
>
>> @@ -577,11 +587,27 @@
>> };
>>
>> /*
>> + * sendfile(2) kqueue information
>> + */
>> +struct sf_hdtr_kq {
>> +       int kq_fd;              /* kq fd to post completion events on */
>> +       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?) */
>> +};

Why can't he leave out the #ifdef/#define/typedefs and just declare it like:
  int kq_fd;
  __uint32_t kq_flags;
  void *kq_udata;
  __uintptr_t kq_ident;?

I know it doesn't look pretty, but surely that's less painful overall than the
#ifndef _UINTPTR_T_DECLARED
#define _UINTPTR_T_DECLARED
typedef __uintptr_t    uintptr_t;
#endif
thing..  We seem to do that elsewhere, eg:
struct stat {
        __dev_t   st_dev;               /* inode's device */
        ino_t     st_ino;               /* inode's number */
...
        fflags_t  st_flags;             /* user defined flags for file */
        __uint32_t st_gen;              /* file generation number */
        __int32_t st_lspare;
...

What's the correct threshold for using the _DECLARED guards vs using
the __ prefixed versions?

-- 
Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CAGE5yCp=UEQ-jbtect31T4G_dXxOvmBMPYzix-w%2B-QSLSA%2BU4A>