v4l2: Add types compatiblity for other OS
authorNicolas Dufresne <nicolas.dufresne@collabora.com>
Sun, 16 Mar 2014 14:26:04 +0000 (15:26 +0100)
committerNicolas Dufresne <nicolas.dufresne@collabora.com>
Sun, 16 Mar 2014 16:32:03 +0000 (17:32 +0100)
Adds type compatiblity with other OS like BSD. This uses types mapping macro to
avoid conflict with existing defined types. We resuse glib types as these are
already available on supported platforms. This is GCC only because of the
le32 type that uses bitwise attribute.

https://bugzilla.gnome.org/show_bug.cgi?id=726453

sys/v4l2/ext/types-compat.h [new file with mode: 0644]
sys/v4l2/ext/videodev2.h

diff --git a/sys/v4l2/ext/types-compat.h b/sys/v4l2/ext/types-compat.h
new file mode 100644 (file)
index 0000000..2748248
--- /dev/null
@@ -0,0 +1,47 @@
+/*
+ * Copyright (C) 2014 Collabora Ltd.
+ *     Author: Nicolas Dufresne <nicolas@ndufresne.ca>
+ *
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Library General Public
+ * License as published by the Free Software Foundation; either
+ * version 2 of the License, or (at your option) any later version.
+ *
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
+ * Library General Public License for more details.
+ *
+ * You should have received a copy of the GNU Library General Public
+ * License along with this library; if not, write to the
+ * Free Software Foundation, Inc., 51 Franklin St, Fifth Floor,
+ * Boston, MA 02110-1301, USA.
+ *
+ */
+
+#include <glib.h>
+
+#ifndef __TYPES_COMPAT_H__
+#define __TYPES_COMPAT_H__
+
+/* From linux/types.h */
+#ifdef __CHECKER__
+#define __bitwise__ __attribute__((bitwise))
+#else
+#define __bitwise__
+#endif
+#ifdef __CHECK_ENDIAN__
+#define __bitwise __bitwise__
+#else
+#define __bitwise
+#endif
+
+#define __u64 guint64
+#define __u32 guint32
+#define __u16 guint16
+#define __u8 guint8
+#define __s64 gint64
+#define __s32 gint32
+#define __le32 guint32 __bitwise
+
+#endif /* __TYPES_COMPAT_H__ */
index 44d9414..2b4d1f5 100644 (file)
@@ -58,8 +58,8 @@
 
 #include <sys/time.h>
 #include <sys/ioctl.h>
-#include <linux/types.h>
 
+#include "ext/types-compat.h"
 #include "ext/v4l2-common.h"
 #include "ext/v4l2-controls.h"