[PATCH 0/9] uapi: drm: fixes for userspace compilation

Gabriel Laskar gabriel at lse.epita.fr
Fri Nov 13 11:24:30 PST 2015


On Thu, 12 Nov 2015 19:34:18 +0000
Emil Velikov <emil.l.velikov at gmail.com> wrote:

> Hi Gabriel,
> 
> Interestingly enough we had a person (gaby) asking about this over at
> #dri-devel, and I forwarded him to the work of Mikko Rapeli. You don't
> happen to be that person do you ?

Yes, that's me.

> On 12 November 2015 at 18:14, Gabriel Laskar <gabriel at lse.epita.fr> wrote:
> > Public headers should use types from include/uapi/linux/types.h.
> >  
> Please don't do this. As mentioned to Mikko, these headers are meant
> to be used in more places than just Linux. All the compatibility is
> handled in drm.h so we might as well use it.

So, I have take a deeper look, and I think I now get it. On bsd, the
headers are taken from linux, and drm is ported from that, so we need,
in order to be nice to them to limit the linux specific parts to a
minimum.

So no more inclusion of linux/types.h inside all the drm headers, and
just in drm.h.

> That aside I'm a strong supporter of this type of work and I'm curious
> why Dave hasn't picked up the existing series ? Last time I've asked
> he did not have any objections.

Last patches send my Mikko were not picked, at least not these parts,
and I think this way is better, although it is a bigger change.

When including a drm header, even with drm.h used before, we have
errors related to the usage of types from stdint.h.

	$ cat test-drm.c 
	#include <drm.h>
	#include <qxl_drm.h>
	
	int main(void)
	{
	        return 0;
	}
	$ gcc -I /usr/include/libdrm -fsyntax-only test-drm.c 
	In file included from test-drm.c:1:0:
	/usr/include/libdrm/drm.h:132:2: error: unknown type name
	‘size_t’ size_t name_len;   /**< Length of name buffer */
	  ^
	/usr/include/libdrm/drm.h:134:2: error: unknown type name
	‘size_t’ size_t date_len;   /**< Length of date buffer */
	  ^
	/usr/include/libdrm/drm.h:136:2: error: unknown type name
	‘size_t’ size_t desc_len;   /**< Length of desc buffer */
	  ^
	/usr/include/libdrm/drm.h:146:2: error: unknown type name
	‘size_t’ size_t unique_len;   /**< Length of unique */
	  ^
	In file included from test-drm.c:2:0:
	/usr/include/libdrm/qxl_drm.h:51:2: error: unknown type name
	‘uint32_t’ uint32_t size;
	  ^
	/usr/include/libdrm/qxl_drm.h:52:2: error: unknown type name
	‘uint32_t’ uint32_t handle; /* 0 is an invalid handle */
	  ^
	/usr/include/libdrm/qxl_drm.h:56:2: error: unknown type name
	‘uint64_t’ uint64_t offset; /* use for mmap system call */
	  ^
	/usr/include/libdrm/qxl_drm.h:57:2: error: unknown type name
	‘uint32_t’ uint32_t handle;
	  ^
	[...]

There is 2 way to avoid that:

* include stdint.h in drm.h
* rename all the types to use __u{32,64} types that are already defined
  for the bsd guys inside drm.h

The first way is a small change, but we use the libc headers inside the
headers from the kernel. As we should have no dependencies, this is not
ideal.

On the other side, we rename the types, and it is working the same way
for bsd.

I realize that I have forgot to include one of my patches (Mikko
probably has the same, I don't remember, I'll check, and if that's the
case, I'll add his name to the commit) that fix the usage of size_t
into __kernel_size_t (and defines it for the bas path).

With those changes, do you think it'll be better?

tl;dr:

I will send a new patchset with no more inclusion of linux/types.h,
types changed from uint32_t to __u32 (and its friends) and size_t
changed into __kernel_size_t. And I'll retake a look on the other
patches to give credit for Mikko.

-- 
Gabriel Laskar


More information about the dri-devel mailing list