pkgsrc/graphics/libv4l/patches/patch-ak
richard 4db36917d3 Add license and fix Linux build to use SYS_openat syscall when SYS_open
isn't available.

Also, videodev.h is expected in include/linux to build.

Upgrade to more current version next time around.
2016-09-08 15:43:12 +00:00

84 lines
2.1 KiB
Text

$NetBSD: patch-ak,v 1.5 2016/09/08 15:43:12 richard Exp $
* XXX
* 'mode_t' is promoted to `int' when passwd through `...'.
* if SYS_open doesn't exist, use SYS_openat
--- libv4l1/libv4l1.c.orig 2008-08-06 08:46:06.000000000 +0000
+++ libv4l1/libv4l1.c
@@ -44,12 +44,13 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
-#include <syscall.h>
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
+#ifdef __linux__
+#include <syscall.h>
/* These headers are not needed by us, but by linux/videodev2.h,
which is broken on some systems and doesn't include them itself :( */
#include <sys/time.h>
@@ -58,10 +59,24 @@
/* end broken header workaround includes */
#include <linux/videodev.h>
#include <linux/videodev2.h>
+#else
+#include <sys/syscall.h>
+#include <sys/ioctl.h>
+#include "videodev.h"
+#ifdef __sun
+#include <sys/videodev2.h>
+#else
+#include <sys/videoio.h>
+#endif
+#endif
#include <libv4l2.h>
#include "libv4l1.h"
#include "libv4l1-priv.h"
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
#define V4L1_SUPPORTS_ENUMINPUT 0x01
#define V4L1_SUPPORTS_ENUMSTD 0x02
#define V4L1_PIX_FMT_TOUCHED 0x04
@@ -267,13 +282,20 @@ int v4l1_open (const char *file, int ofl
mode_t mode;
va_start (ap, oflag);
- mode = va_arg (ap, mode_t);
+ mode = (sizeof (mode_t) < sizeof (int) ? (mode_t)va_arg (ap, int) : va_arg (ap, mode_t));
+#ifdef SYS_open
fd = syscall(SYS_open, file, oflag, mode);
-
+#else
+ fd = syscall(SYS_openat, AT_FDCWD, file, oflag, mode);
+#endif
va_end(ap);
} else
- fd = syscall(SYS_open, file, oflag);
+#ifdef SYS_open
+ fd = syscall(SYS_open, file, oflag);
+#else
+ fd = syscall(SYS_openat, AT_FDCWD, file, oflag);
+#endif
/* end of original open code */
if (fd == -1)
@@ -434,7 +456,11 @@ int v4l1_dup(int fd)
int index;
if ((index = v4l1_get_index(fd)) == -1)
+#ifdef __sun
+ return syscall(SYS_fcntl, fd, F_DUPFD, 0);
+#else
return syscall(SYS_dup, fd);
+#endif
devices[index].open_count++;