From mboxrd@z Thu Jan 1 00:00:00 1970 Return-path: Received: from perceval.ideasonboard.com ([95.142.166.194]:37797 "EHLO perceval.ideasonboard.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754155Ab2JSMTh (ORCPT ); Fri, 19 Oct 2012 08:19:37 -0400 From: Laurent Pinchart To: Mauro Carvalho Chehab Cc: linux-kernel@vger.kernel.org, Linux Media Mailing List Subject: [RFC] linux/time.h vs. sys/time.h mess (was [PATCH 1/2] [media] remove include/linux/dvb/dmx.h) Date: Fri, 19 Oct 2012 14:20:25 +0200 Message-ID: <1866001.vORa2QqSgB@avalon> In-Reply-To: <20121019082116.145ebe92@redhat.com> References: <1350643392-2193-1-git-send-email-mchehab@redhat.com> <20121019082116.145ebe92@redhat.com> MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="us-ascii" Sender: linux-media-owner@vger.kernel.org List-ID: Hi Mauro, (CC'ing LKML) On Friday 19 October 2012 08:21:16 Mauro Carvalho Chehab wrote: > Em Fri, 19 Oct 2012 07:43:11 -0300 > > Mauro Carvalho Chehab escreveu: > > -#include > > -#include > > - > > -#endif /*_DVBDMX_H_*/ > > Just to not discard a valid comment on IRC, Laurent proposed that we > should investigate if we can, instead, move: > > #include > > to both dmx.h and videodev2.h, letting it to be included by both userspace > and Kernelspace. > > I remember this used to cause compilation breakage in the past, as some > userspace programs need to include and this used to conflict > with . > > I'm not sure if this got fixed there. if so, Laurent has a point. It's still not solved, but that's what the proper fix should be. Several UAPI headers use struct timeval or struct timespec. Kernel code and user space code thus need to include the header(s) that define those structures, either directly or indirectly. In kernel space struct timeval and struct timespec are defined in include/uapi/linux/time.h. In user space they're defined in . No proper conditional compilation exists in those headers to guard against multiple definitions, so they can't be included together. On the kernel side isn't available, so we can include in the headers that use the timeval and timespec structures. This "self-contained" headers mechanism avoids forcing all users of those headers to explicitly include . However, this then breaks user space applications that include both and a kernel header that includes . The way we've dealt with that until now is by including either or depending on __KERNEL__ #ifdef __KERNEL__ #include #else #include #endif in our user-facing headers. The recent UAPI disintegration patches resulted in nearly empty headers in include/linux/ that just #include both and the corresponding UAPI header. For instance include/linux/videodev2.h is now just #ifndef __LINUX_VIDEODEV2_H #define __LINUX_VIDEODEV2_H #include /* need struct timeval */ #include #endif /* __LINUX_VIDEODEV2_H */ Patches have been posted to remove those headers and push the #include one level up, which breaks the "self-contained" headers concept. How could we fix this ? Are there legitimate users of in user space ? A quick grep in glibc doesn't reveal anything. -- Regards, Laurent Pinchart