|
From: | Eric Blake |
Subject: | Re: [PATC 7/9] Skipping drm build, unsupported |
Date: | Wed, 1 Jul 2020 09:16:34 -0500 |
User-agent: | Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.9.0 |
On 6/30/20 11:53 AM, Gerd Hoffmann wrote:
-util-obj-$(CONFIG_POSIX) += drm.o +util-obj-$(CONFIG_LINUX) += drm.oCan't see anything linux-specific there. Also note that FreeBSD (and possibly other *BSDs too) have drm support. So CONFIG_POSIX looks correct to me.This change was my suggestion; I assumed that "open /dev/dri/whatever" was Linux-specific. The specific thing that doesn't work on Haiku, or on Solaris for that matter, is that the code uses DT_CHR, which isn't in POSIX but is a Linux-and-BSDism.Ah, that is the problem. Yes, DT_CHR is an non-posix optimization which allows to get the file type directly, without another round-trip to the kernel. If that isn't available you can stat() the file and check ((st_mode & S_IFMT) == S_IFCHR) instead.
Even when d_type and DT_CHR is available, there are filesystems where the Linux kernel reports d_type of DT_UNKNOWN, and where you are best having that code also falling back to an fstat(). In short, any portable code that uses d_type should have fallback code for DT_UNKNOWN, at which point porting to systems without d_type is as easy as writing an accessor macro that returns d_type when it exists and DT_UNKNOWN where it doesn't.
-- Eric Blake, Principal Software Engineer Red Hat, Inc. +1-919-301-3226 Virtualization: qemu.org | libvirt.org
[Prev in Thread] | Current Thread | [Next in Thread] |