$NetBSD: patch-ad,v 1.3 2008/09/13 17:59:27 jmcneill Exp $

--- libv4l2/libv4l2.c.orig	2008-09-03 06:23:46.000000000 -0400
+++ libv4l2/libv4l2.c	2008-09-13 13:50:47.000000000 -0400
@@ -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,10 @@
 #include "libv4l2.h"
 #include "libv4l2-priv.h"
 
+#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 +162,7 @@
       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) {
@@ -871,7 +879,7 @@
 	   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 +1003,7 @@
       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 +1020,7 @@
   }
 
   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),
