From owner-freebsd-arch@FreeBSD.ORG Tue Dec 17 15:42:11 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 EF5D18F5 for ; Tue, 17 Dec 2013 15:42:10 +0000 (UTC) Received: from mail-ie0-f176.google.com (mail-ie0-f176.google.com [209.85.223.176]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id B4C3D1029 for ; Tue, 17 Dec 2013 15:42:10 +0000 (UTC) Received: by mail-ie0-f176.google.com with SMTP id at1so8490705iec.21 for ; Tue, 17 Dec 2013 07:42:09 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:subject:mime-version:content-type:from :in-reply-to:date:cc:content-transfer-encoding:message-id:references :to; bh=I03bQ3+UH67d+ODQdxZcrxce9g82B0gRgomsUqeVEN4=; b=bmN8El7R/6TngT/jsc4hA6VOvFa5P0soijeKLgs6DpjM/LxAX+xlTXMBrMzhY+lhVN hVIkUXl3VJIUUeQYcyCfx0PEdwdR7UKhxuE4v7JTVaLcvIjjZd0n4k3M4QnNm6sjk9Mb /U//JFii3QorVil5kyluMkgQQ8pDDisVEUi7ra1/aZb1e/v4j2IoDyuUWVltxr6GGZY0 iYCeb75/AH8OqCGXjAHEEoGh4GlMx7RjWBCni0i6OTpMPe2ZJ/dQb5lWv5vwWpi+uIxk K+Bsm1GdLYb4oIKwoN5oGqgFqvN3dWuL2D8Cqr5mO6/BpNtb4rFfGr9iKUWKQscdqpVS TD6g== X-Gm-Message-State: ALoCoQk12h/NzCIQ4s7Ec99iBloRjnnR/zA1ZAMNrhZisZRa4kwVKQK8ujWp8eCguIFGYHwpN+PU X-Received: by 10.50.141.133 with SMTP id ro5mr3620267igb.35.1387294929793; Tue, 17 Dec 2013 07:42:09 -0800 (PST) Received: from monkey-bot.int.fusionio.com ([209.117.142.2]) by mx.google.com with ESMTPSA id f5sm22278848igc.4.2013.12.17.07.42.08 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Tue, 17 Dec 2013 07:42:09 -0800 (PST) Sender: Warner Losh Subject: Re: Using sys/types.h types in sys/socket.h Mime-Version: 1.0 (Apple Message framework v1085) Content-Type: text/plain; charset=us-ascii From: Warner Losh In-Reply-To: Date: Tue, 17 Dec 2013 08:42:06 -0700 Content-Transfer-Encoding: quoted-printable Message-Id: <9C1291B5-215B-440E-B8B0-6308840F755C@bsdimp.com> References: To: Adrian Chadd X-Mailer: Apple Mail (2.1085) 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 15:42:11 -0000 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 On Dec 17, 2013, at 1:23 AM, Adrian Chadd wrote: > Hi, >=20 > I have a patch to implement some new sendfile functionality, but this > involves adding stuff to sys/socket.h: >=20 > Index: sys/sys/socket.h > =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D= =3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D > --- sys/sys/socket.h (revision 258883) > +++ sys/sys/socket.h (working copy) > @@ -577,11 +577,27 @@ > }; >=20 > /* > + * 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? 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. > +struct sf_hdtr_all { > + struct sf_hdtr hdtr; > + struct sf_hdtr_kq kq; > +}; > + > +/* > * Sendfile-specific flag(s) > */ > #define SF_NODISKIO 0x00000001 > #define SF_MNOWAIT 0x00000002 > #define SF_SYNC 0x00000004 > +#define SF_KQUEUE 0x00000008 >=20 > #ifdef _KERNEL > #define SFK_COMPAT 0x00000001 >=20 >=20 > ... now, uintptr_t upsets things, because we don't include sys/types.h > before sys/socket.h. >=20 > The POSIX spec for sys/socket.h doesn't mention a dependency on > sys/types.h and in fact says it should define a couple of types > itself. >=20 > = http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/sys_socket.h.html= >=20 > .. so, what suggestions do people have? I'd like to do this right and > not cause header pollution. >=20 > Thanks! >=20 >=20 > -a > _______________________________________________ > freebsd-arch@freebsd.org mailing list > http://lists.freebsd.org/mailman/listinfo/freebsd-arch > To unsubscribe, send any mail to = "freebsd-arch-unsubscribe@freebsd.org"