From owner-freebsd-arch@FreeBSD.ORG Tue Dec 17 16:49:34 2013 Return-Path: Delivered-To: freebsd-arch@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 700A8F8D; Tue, 17 Dec 2013 16:49:34 +0000 (UTC) Received: from mail-qe0-x22b.google.com (mail-qe0-x22b.google.com [IPv6:2607:f8b0:400d:c02::22b]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id 1C2FF163E; Tue, 17 Dec 2013 16:49:34 +0000 (UTC) Received: by mail-qe0-f43.google.com with SMTP id 2so5387462qeb.2 for ; Tue, 17 Dec 2013 08:49:33 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:sender:in-reply-to:references:date:message-id:subject :from:to:cc:content-type; bh=kJmXE/dsufofGeBQKbi0pAq1JVAWiGxV3zzir2eqaTk=; b=RW6t/DJLxynRKipVqMNOvr5VW2s5xrgW869XnJ1+/xoY8mPMi6ZEdV+M40wOE+G7K4 0NWjQIzlLIu8GLgoGOw7v36yHCVDX/tztZgY1JXAGjJD3L7+1ZVbnM6rD+y9bB5TYvB0 g0Dv12rBpq31r/CA1Q1gr8HvcAJ5YazLgnn9tL3XjwfV04eKrfgI3P6BSWjZCEDp+rHC oQOYUrqhU7LTNNZYjnaGhswwG/qS2XUj7bPCiRo6h7pIkonqgsCF6/eKWlnjJ7XSxepP VTTRdXf9BzUfEbf+3WXIfrRQB+JPzHR4exXhUjrcP1O30RcMOESFvgCCfB0sxWShOOj0 Uz3Q== MIME-Version: 1.0 X-Received: by 10.49.131.5 with SMTP id oi5mr44956882qeb.38.1387298973336; Tue, 17 Dec 2013 08:49:33 -0800 (PST) Sender: adrian.chadd@gmail.com Received: by 10.224.53.200 with HTTP; Tue, 17 Dec 2013 08:49:33 -0800 (PST) In-Reply-To: <9C1291B5-215B-440E-B8B0-6308840F755C@bsdimp.com> References: <9C1291B5-215B-440E-B8B0-6308840F755C@bsdimp.com> Date: Tue, 17 Dec 2013 08:49:33 -0800 X-Google-Sender-Auth: pNqZBSUyn5i-bR7fzL_SaF8dhw8 Message-ID: Subject: Re: Using sys/types.h types in sys/socket.h From: Adrian Chadd To: Warner Losh Content-Type: text/plain; charset=ISO-8859-1 Cc: Bruce Evans , "freebsd-arch@freebsd.org" X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.17 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 17 Dec 2013 16:49:34 -0000 On 17 December 2013 07:42, Warner Losh 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... > > Warner Right. I was hoping for something dirty but not namespace pollution-y. > 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? Yeah, the FD is an int. I can easily put that at the end and order it more appropriately. > To avoid namespace pollution, you'll need to include sys/_types.h use __uint32_t and __uintptr_t respectively. You'd also need > #if __BSD_VISIBLE > #ifndef _UINT32_T_DECLARED > typedef __uint32_t uint32_t; > #define _UINT32_T_DECLARED > #endif > and similar for __uintptr_t. thankfully, sys/_stdint.h already does this dance to avoid namespace pollution, so you just need a few lines at the top of socket.h to do this righ. Ok. I really dislike how the sendfile stuff is in sys/socket.h. It really should be in its own header file so it doesn't pollute sys/socket.h. I wish I had found this sendfile dirtiness all out before 10.0-RELEASE so we could've just make a clean break. I'll evaluate possibly doing it in -HEAD at some point soon. -a