aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--config.h.in7
-rw-r--r--configure.ac1
-rw-r--r--lib/libv4l1/libv4l1.c3
-rw-r--r--lib/libv4l1/v4l1compat.c3
-rw-r--r--lib/libv4l2/libv4l2.c3
-rw-r--r--lib/libv4l2/v4l2convert.c5
-rw-r--r--m4/mode_t.m426
7 files changed, 43 insertions, 5 deletions
diff --git a/config.h.in b/config.h.in
index 9202d65b..c8337f66 100644
--- a/config.h.in
+++ b/config.h.in
@@ -70,6 +70,10 @@
/* Define to the version of this package. */
#undef PACKAGE_VERSION
+/* Define to the type that is the result of default argument promotions of
+ type mode_t. */
+#undef PROMOTED_MODE_T
+
/* Define to 1 if you have the ANSI C header files. */
#undef STDC_HEADERS
@@ -78,3 +82,6 @@
/* Version number of package */
#undef VERSION
+
+/* Define to `int' if <sys/types.h> does not define. */
+#undef mode_t
diff --git a/configure.ac b/configure.ac
index ba68c827..568a2fc5 100644
--- a/configure.ac
+++ b/configure.ac
@@ -48,6 +48,7 @@ AC_PROG_LIBTOOL
#AC_PROG_GREP
#AC_PROG_SED
#AC_PROG_MKDIR_P
+gl_PROMOTED_TYPE_MODE_T
# Check host os
case "$host_os" in
diff --git a/lib/libv4l1/libv4l1.c b/lib/libv4l1/libv4l1.c
index 2e7494ba..7fa929b1 100644
--- a/lib/libv4l1/libv4l1.c
+++ b/lib/libv4l1/libv4l1.c
@@ -47,6 +47,7 @@
in turn will call v4l1_open, so therefor v4l1_open (for example) may not
use the regular open()!
*/
+#include <config.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -302,7 +303,7 @@ int v4l1_open(const char *file, int oflag, ...)
mode_t mode;
va_start(ap, oflag);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, PROMOTED_MODE_T);
fd = SYS_OPEN(file, oflag, mode);
diff --git a/lib/libv4l1/v4l1compat.c b/lib/libv4l1/v4l1compat.c
index 09e8cad1..2b49c882 100644
--- a/lib/libv4l1/v4l1compat.c
+++ b/lib/libv4l1/v4l1compat.c
@@ -21,6 +21,7 @@
#define _LARGEFILE64_SOURCE 1
+#include <config.h>
#include <stdlib.h>
#include <stdarg.h>
#include <fcntl.h>
@@ -50,7 +51,7 @@ LIBV4L_PUBLIC int open(const char *file, int oflag, ...)
mode_t mode;
va_start(ap, oflag);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, PROMOTED_MODE_T);
fd = v4l1_open(file, oflag, mode);
diff --git a/lib/libv4l2/libv4l2.c b/lib/libv4l2/libv4l2.c
index 9d3a0eff..dda99149 100644
--- a/lib/libv4l2/libv4l2.c
+++ b/lib/libv4l2/libv4l2.c
@@ -55,6 +55,7 @@
When modifications are made, one should be carefull that this behavior is
preserved.
*/
+#include <config.h>
#include <errno.h>
#include <stdarg.h>
#include <stdio.h>
@@ -561,7 +562,7 @@ int v4l2_open(const char *file, int oflag, ...)
mode_t mode;
va_start(ap, oflag);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, PROMOTED_MODE_T);
fd = SYS_OPEN(file, oflag, mode);
diff --git a/lib/libv4l2/v4l2convert.c b/lib/libv4l2/v4l2convert.c
index 9b232282..b9ecdc6c 100644
--- a/lib/libv4l2/v4l2convert.c
+++ b/lib/libv4l2/v4l2convert.c
@@ -22,6 +22,7 @@
#define _LARGEFILE64_SOURCE 1
+#include <config.h>
#include <stdarg.h>
#include <stdlib.h>
#include <fcntl.h>
@@ -62,7 +63,7 @@ LIBV4L_PUBLIC int open(const char *file, int oflag, ...)
mode_t mode;
va_start(ap, oflag);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, PROMOTED_MODE_T);
fd = SYS_OPEN(file, oflag, mode);
@@ -93,7 +94,7 @@ LIBV4L_PUBLIC int open64(const char *file, int oflag, ...)
mode_t mode;
va_start(ap, oflag);
- mode = va_arg(ap, mode_t);
+ mode = va_arg(ap, PROMOTED_MODE_T);
fd = open(file, oflag | O_LARGEFILE, mode);
diff --git a/m4/mode_t.m4 b/m4/mode_t.m4
new file mode 100644
index 00000000..40f612a6
--- /dev/null
+++ b/m4/mode_t.m4
@@ -0,0 +1,26 @@
+# mode_t.m4 serial 2
+dnl Copyright (C) 2009-2012 Free Software Foundation, Inc.
+dnl This file is free software; the Free Software Foundation
+dnl gives unlimited permission to copy and/or distribute it,
+dnl with or without modifications, as long as this notice is preserved.
+
+# For using mode_t, it's sufficient to use AC_TYPE_MODE_T and
+# include <sys/types.h>.
+
+# Define PROMOTED_MODE_T to the type that is the result of "default argument
+# promotion" (ISO C 6.5.2.2.(6)) of the type mode_t.
+AC_DEFUN([gl_PROMOTED_TYPE_MODE_T],
+[
+ AC_REQUIRE([AC_TYPE_MODE_T])
+ AC_CACHE_CHECK([for promoted mode_t type], [gl_cv_promoted_mode_t], [
+ dnl Assume mode_t promotes to 'int' if and only if it is smaller than 'int',
+ dnl and to itself otherwise. This assumption is not guaranteed by the ISO C
+ dnl standard, but we don't know of any real-world counterexamples.
+ AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
+ [[typedef int array[2 * (sizeof (mode_t) < sizeof (int)) - 1];]])],
+ [gl_cv_promoted_mode_t='int'],
+ [gl_cv_promoted_mode_t='mode_t'])
+ ])
+ AC_DEFINE_UNQUOTED([PROMOTED_MODE_T], [$gl_cv_promoted_mode_t],
+ [Define to the type that is the result of default argument promotions of type mode_t.])
+])

Privacy Policy