Files
2016-11-18 22:39:22 +01:00

109 lines
3.0 KiB
Plaintext

$NetBSD: patch-ad,v 1.6 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
--- libv4l2/libv4l2.c.orig 2008-09-03 10:23:46.000000000 +0000
+++ libv4l2/libv4l2.c
@@ -59,7 +59,11 @@
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>
+#ifdef __linux__
#include <syscall.h>
+#else
+#include <sys/syscall.h>
+#endif
#include <fcntl.h>
#include <string.h>
#include <unistd.h>
@@ -69,6 +73,14 @@
#include "libv4l2.h"
#include "libv4l2-priv.h"
+#ifdef __sun
+#define __off_t off_t
+#endif
+
+#ifndef MAP_ANONYMOUS
+#define MAP_ANONYMOUS MAP_ANON
+#endif
+
/* Note these flags are stored together with the flags passed to v4l2_fd_open()
in v4l2_dev_info's flags member, so care should be taken that the do not
use the same bits! */
@@ -154,7 +166,7 @@ static int v4l2_map_buffers(int index)
break;
}
- devices[index].frame_pointers[i] = (void *)syscall(SYS_mmap2, NULL,
+ devices[index].frame_pointers[i] = mmap(NULL,
(size_t)buf.length, PROT_READ|PROT_WRITE, MAP_SHARED, devices[index].fd,
(__off_t)(buf.m.offset >> MMAP2_PAGE_SHIFT));
if (devices[index].frame_pointers[i] == MAP_FAILED) {
@@ -408,14 +420,22 @@ int v4l2_open (const char *file, int ofl
mode_t mode;
va_start (ap, oflag);
- mode = va_arg (ap, mode_t);
+ mode = (mode_t)va_arg (ap, int);
+#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
+#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)
@@ -584,7 +604,11 @@ int v4l2_dup(int fd)
int index;
if ((index = v4l2_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++;
@@ -871,7 +895,7 @@ int v4l2_ioctl (int fd, unsigned long in
but we need the buffer _now_ to write our converted data
to it! */
if (devices[index].convert_mmap_buf == MAP_FAILED) {
- devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2,
+ devices[index].convert_mmap_buf = mmap(NULL,
(size_t)(
devices[index].no_frames *
V4L2_FRAME_BUF_SIZE),
@@ -995,7 +1019,7 @@ void *v4l2_mmap(void *start, size_t leng
return MAP_FAILED;
}
- return (void *)syscall(SYS_mmap2, start, length, prot, flags, fd,
+ return mmap(start, length, prot, flags, fd,
(__off_t)(offset >> MMAP2_PAGE_SHIFT));
}
@@ -1012,7 +1036,7 @@ void *v4l2_mmap(void *start, size_t leng
}
if (devices[index].convert_mmap_buf == MAP_FAILED) {
- devices[index].convert_mmap_buf = (void *)syscall(SYS_mmap2, NULL,
+ devices[index].convert_mmap_buf = mmap(NULL,
(size_t)(
devices[index].no_frames *
V4L2_FRAME_BUF_SIZE),