v4l2codecs: Fix compilation error on FreeBSD

This commit does the following things to fix compilation on FreeBSD:

1. Add required typedefs to linux/types-compat.h.
2. Remove unnecessary include linux/ioctl.h and replace linux/types.h
   with linux/types-compat.h. Both files do not exist on FreeBSD.
3. Check the header including makedev macro. FreeBSD does not have
   sys/sysmacros.h, and including it unconditionally causes error.

Part-of: <https://gitlab.freedesktop.org/gstreamer/gst-plugins-bad/-/merge_requests/1259>
This commit is contained in:
Ting-Wei Lan 2020-05-10 17:38:11 +08:00 committed by GStreamer Merge Bot
parent 12edc0d9b8
commit d10e2381c7
4 changed files with 21 additions and 2 deletions

View file

@ -18,6 +18,10 @@
* Boston, MA 02110-1301, USA.
*/
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "gstv4l2codecdevice.h"
#include "linux/media.h"
@ -25,7 +29,14 @@
#include <gudev/gudev.h>
#include <sys/ioctl.h>
#include <sys/stat.h>
#if HAVE_MAKEDEV_IN_MKDEV
#include <sys/mkdev.h>
#elif HAVE_MAKEDEV_IN_SYSMACROS
#include <sys/sysmacros.h>
#elif HAVE_MAKEDEV_IN_TYPES
#include <sys/types.h>
#endif
#include <unistd.h>
#define GST_CAT_DEFAULT gstv4l2codecs_debug

View file

@ -24,8 +24,7 @@
#include <stdint.h>
#define __user
#endif
#include <linux/ioctl.h>
#include <linux/types.h>
#include "linux/types-compat.h"
struct media_device_info {
char driver[16];

View file

@ -46,7 +46,9 @@
# endif
#endif
typedef gint8 __s8;
typedef guint8 __u8;
typedef gint16 __s16;
typedef guint16 __u16;
typedef gint32 __s32;
typedef guint32 __u32;

View file

@ -21,6 +21,13 @@ else
if get_option('v4l2codecs').enabled() and not have_v4l2
error('V4L2i CODECs is requested but kernel headers were not found')
endif
# Find makedev in various header files. Different operating systems put the
# macro in different header files.
foreach name: ['mkdev', 'sysmacros', 'types']
have_makedev = cc.has_header_symbol('sys/@0@.h'.format(name), 'makedev')
cdata.set10('HAVE_MAKEDEV_IN_' + name.to_upper(), have_makedev)
endforeach
endif