From owner-freebsd-arch@FreeBSD.ORG Wed Jan 8 00:46:35 2014 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 D2A874B1 for ; Wed, 8 Jan 2014 00:46:35 +0000 (UTC) Received: from mail-pa0-x235.google.com (mail-pa0-x235.google.com [IPv6:2607:f8b0:400e:c03::235]) (using TLSv1 with cipher ECDHE-RSA-RC4-SHA (128/128 bits)) (No client certificate requested) by mx1.freebsd.org (Postfix) with ESMTPS id A0744115C for ; Wed, 8 Jan 2014 00:46:35 +0000 (UTC) Received: by mail-pa0-f53.google.com with SMTP id hz1so1108374pad.26 for ; Tue, 07 Jan 2014 16:46:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=wemm.org; s=google; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type; bh=eEMBfUyPe8k6m8FwOtz/Q0OZQQMCssccoBHZSPysVTI=; b=AqTCMgVMeSUjWZA30sczANaMCPI3wc2oashagJFKuPvEzd2WsP/2bVYiBqth6Dv2tv J3/4h165ExKNXJyRUg2sf9nWVJg/72CQYVP5ZvU3okWdk+iXq6haAFzA4/flb9kEhuEl KGIh0zeuiOmd/cU7apu1BgQ7qpuRaukAaK0Gg= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:mime-version:in-reply-to:references:date :message-id:subject:from:to:cc:content-type; bh=eEMBfUyPe8k6m8FwOtz/Q0OZQQMCssccoBHZSPysVTI=; b=hOlajbPoJIaF51+qt3cblwPcdpSx1wEVTa5t88+j+V6HGZgRwIDW+6nHXd5WClRs/q 3SC9ZXWMSC3ZPxkrbYK6k9LOiO5cpsTtkxsLrYmnNDWalLnlX24fPJAp4peSPiMCKd7H d8cJ0F/GGcOwAA9MtjIMxTbH1QWEQ6ORuVo1A2wEqeyFX+0Ym4BZkbr2awdjZikPGV66 seBA5N+PGj+g+paQ/bEop6mOQYPJoI4jeL/Cf2v1MY0pyf8NVuM+M4fIrR+Mz0eOm7oj RMDw9142Z/XFnHTXlqJzQFPRyt3+Cnyw5D4NT5wOR2p1IVzSRF0YC1yaq4qCxRlkEr3j zXBA== X-Gm-Message-State: ALoCoQko28xkU+WTobeJdF8hfL+frI5unK0uJIGyReoVgo1bTjCzxwPXgN+sAr5Vawz1MiOObtRt MIME-Version: 1.0 X-Received: by 10.66.67.3 with SMTP id j3mr8891463pat.142.1389141995275; Tue, 07 Jan 2014 16:46:35 -0800 (PST) Received: by 10.66.162.3 with HTTP; Tue, 7 Jan 2014 16:46:35 -0800 (PST) In-Reply-To: <20131219154839.T23018@besplex.bde.org> References: <9C1291B5-215B-440E-B8B0-6308840F755C@bsdimp.com> <20131219154839.T23018@besplex.bde.org> Date: Tue, 7 Jan 2014 16:46:35 -0800 Message-ID: Subject: Re: Using sys/types.h types in sys/socket.h From: Peter Wemm To: Bruce Evans Content-Type: text/plain; charset=ISO-8859-1 Cc: Adrian Chadd , "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: Wed, 08 Jan 2014 00:46:36 -0000 On Wed, Dec 18, 2013 at 9:20 PM, Bruce Evans 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