$NetBSD: patch-am,v 1.4 2013/06/24 15:57:21 jperkin Exp $

* XXXX
* `mode_t' is promoted to `int' when passed through `...'.
* Fix SunOS 64-bit

--- libv4l1/v4l1compat.c.orig	2008-08-26 12:32:39.000000000 +0000
+++ libv4l1/v4l1compat.c
@@ -40,6 +40,10 @@
 #define LIBV4L_PUBLIC
 #endif
 
+#ifndef O_LARGEFILE
+#define O_LARGEFILE 0
+#endif
+
 LIBV4L_PUBLIC int open (const char *file, int oflag, ...)
 {
   int fd;
@@ -50,7 +54,7 @@ LIBV4L_PUBLIC int open (const char *file
     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));
 
     fd = v4l1_open(file, oflag, mode);
 
@@ -61,6 +65,7 @@ LIBV4L_PUBLIC int open (const char *file
   return fd;
 }
 
+#if !(defined(__sun) && defined(_LP64))
 LIBV4L_PUBLIC int open64 (const char *file, int oflag, ...)
 {
   int fd;
@@ -71,7 +76,7 @@ LIBV4L_PUBLIC int open64 (const char *fi
     mode_t mode;
 
     va_start (ap, oflag);
-    mode = va_arg (ap, mode_t);
+    mode = (mode_t)va_arg (ap, int);
 
     fd = v4l1_open(file, oflag | O_LARGEFILE, mode);
 
@@ -81,6 +86,7 @@ LIBV4L_PUBLIC int open64 (const char *fi
 
   return fd;
 }
+#endif
 
 LIBV4L_PUBLIC int close(int fd) {
   return v4l1_close(fd);
@@ -114,11 +120,13 @@ LIBV4L_PUBLIC void *mmap(void *start, si
   return v4l1_mmap(start, length, prot, flags, fd, offset);
 }
 
+#if !(defined(__sun) && defined(_LP64))
 LIBV4L_PUBLIC void *mmap64(void *start, size_t length, int prot, int flags, int fd,
   __off64_t offset)
 {
   return v4l1_mmap(start, length, prot, flags, fd, offset);
 }
+#endif
 
 LIBV4L_PUBLIC int munmap(void *start, size_t length)
 {
