From owner-freebsd-arch@FreeBSD.ORG Wed Jul 9 11:06:35 2014 Return-Path: Delivered-To: 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 814D569D; Wed, 9 Jul 2014 11:06:35 +0000 (UTC) Received: from mail110.syd.optusnet.com.au (mail110.syd.optusnet.com.au [211.29.132.97]) by mx1.freebsd.org (Postfix) with ESMTP id 018252EAD; Wed, 9 Jul 2014 11:06:34 +0000 (UTC) Received: from c122-106-147-133.carlnfd1.nsw.optusnet.com.au (c122-106-147-133.carlnfd1.nsw.optusnet.com.au [122.106.147.133]) by mail110.syd.optusnet.com.au (Postfix) with ESMTPS id BEA66780D56; Wed, 9 Jul 2014 21:06:31 +1000 (EST) Date: Wed, 9 Jul 2014 21:06:31 +1000 (EST) From: Bruce Evans X-X-Sender: bde@besplex.bde.org To: Bruce Evans Subject: Re: sys/proc.h inclusion of sys/time.h In-Reply-To: <20140709201148.W1201@besplex.bde.org> Message-ID: <20140709205126.V1201@besplex.bde.org> References: <53BC4F49.7000903@FreeBSD.org> <20140709201148.W1201@besplex.bde.org> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed X-Optus-CM-Score: 0 X-Optus-CM-Analysis: v=2.1 cv=U6SrU4bu c=1 sm=1 tr=0 a=7NqvjVvQucbO2RlWB8PEog==:117 a=PO7r1zJSAAAA:8 a=z5S34nFNDvQA:10 a=kj9zAlcOel0A:10 a=JzwRw_2MAAAA:8 a=M9_dusmLnZ1afHhWExwA:9 a=CjuIK1q_8ugA:10 Cc: arch@freebsd.org, Bryan Drewery X-BeenThere: freebsd-arch@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Discussion related to FreeBSD architecture List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 09 Jul 2014 11:06:35 -0000 On Wed, 9 Jul 2014, Bruce Evans wrote: > On Tue, 8 Jul 2014, Bryan Drewery wrote: > >> In r34924 sys/proc.h was changed to only include sys/time.h if not building >> in kernel. > ... >> struct proc { >> .. >> struct itimerval p_realtimer; /* (c) Alarm timer. */ >> >> This manifests when (hackishly) including sys/proc.h with _KERNEL defined: >> >>> In file included from >>> /root/svn/base/usr.sbin/tcpdump/tcpdump/../../../contrib/tcpdump/print-pflog.c:37: >>> /usr/include/sys/proc.h:524:19: error: field has incomplete type 'struct >>> itimerval' >>> struct itimerval p_realtimer; /* (c) Alarm timer. */ >> >> (Why am I doing this? I need PID_MAX and NO_PID for a tcpdump change I am >> testing that is intended for upstreaming. Perhaps I can use kern.pid_max in >> __FreeBSD__ and other hacks on other platforms, I have not yet decided on >> this.) > > Ah, you were chummy with the implementation, but not chummy enough to > know all the details of the kernel environment that must be duplicated > to use the hack of defining _KERNEL. It seems to be necessary to include > sys/param.h and define _KERNEL before that. There may be collateral > pollution and further chumminess to avoid problems with it. PS: in some old cleanups, proc.h caused similar problems but I was able to avoid them by not including it at all. It is less needed for abuse outside the kernel than most kernel headers. % diff -u2 ./kvm.c~ ./kvm.c % --- ./kvm.c~ Wed Jun 9 06:13:50 2004 % +++ ./kvm.c Wed Jun 9 06:13:51 2004 % @@ -46,10 +46,10 @@ % % #include % -#include % -#include These cleanups are mainly to combine with ones for sys/user.h. Here I mainly just wanted to sort it. but sys/proc.h dependend on the sys/time.h pollution in it. % +#include % #include % +#include % #include % #include % -#include % +#include % % #include % diff -u2 ./kvm_file.c~ ./kvm_file.c % --- ./kvm_file.c~ Fri Aug 1 21:47:20 2003 % +++ ./kvm_file.c Fri Aug 1 21:47:53 2003 % @@ -48,23 +48,14 @@ % */ % % -#include % -#include % -#include % +#include % #define _KERNEL % #include % #undef _KERNEL sys/param.h turns out to be mustly unnecessary here. Defining _KERNEL before including it was not needed partly because including it at all is not needed, except possibly for other things that are not needed. % -#include % -#include % -#include % -#include % - % -#include % -#include % - % #include % % +#include % #include % -#include % -#include % +#include % +#include % % #include "kvm_private.h" % diff -u2 ./kvm_i386.c~ ./kvm_i386.c % --- ./kvm_i386.c~ Thu Oct 11 20:18:31 2001 % +++ ./kvm_i386.c Sun Sep 8 01:05:29 2002 % @@ -52,5 +52,4 @@ % #include % #include % -#include % #include % #include % @@ -60,4 +59,5 @@ % % #include % +#include % #include % PS2: grepping for PID_MAX shows that ps used to use BSD_PID_MAX (defined as 99999. That was supposed to be a copy of the kernel PID_MAX, perhaps to avoid the namespace problem. It now uses kern.pid_max with a fallback to 99999. Bruce