pkgsrc/graphics/libv4l/patches/patch-ad
2012-04-18 17:47:22 +00:00

91 lines
2.6 KiB
Text

$NetBSD: patch-ad,v 1.5 2012/04/18 17:47:22 hans Exp $
* XXX
* `mode_t' is promoted to `int' when passwd through `...'.
--- 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,7 +420,7 @@ 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);
fd = syscall(SYS_open, file, oflag, mode);
@@ -584,7 +596,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 +887,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 +1011,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 +1028,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),