0003-libv4lsyscall-priv.h-Use-off_t-instead-of-__off_t.patch 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108
  1. From 87369a8d190a182ee087cec5164e4c9586b0d80e Mon Sep 17 00:00:00 2001
  2. From: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  3. Date: Wed, 28 Oct 2015 09:27:47 +0100
  4. Subject: [PATCH] libv4lsyscall-priv.h: Use off_t instead of __off_t
  5. __off_t is a kernel internal symbol, which happens to be user-visible
  6. with glibc, but not necessarily with other C libraries such as
  7. musl. In v4l-utils code, it's mainly used for the mmap() prototype,
  8. but the mmap() manpage really uses off_t, not __off_t.
  9. Switching from __off_t to off_t allows the code to build properly with
  10. musl.
  11. Signed-off-by: Thomas Petazzoni <thomas.petazzoni@free-electrons.com>
  12. ---
  13. lib/libv4l1/v4l1compat.c | 3 +--
  14. lib/libv4l2/v4l2convert.c | 5 ++---
  15. lib/libv4lconvert/libv4lsyscall-priv.h | 11 +++--------
  16. 3 files changed, 6 insertions(+), 13 deletions(-)
  17. diff --git a/lib/libv4l1/v4l1compat.c b/lib/libv4l1/v4l1compat.c
  18. index 97e8c4e..e5c9e56 100644
  19. --- a/lib/libv4l1/v4l1compat.c
  20. +++ b/lib/libv4l1/v4l1compat.c
  21. @@ -29,7 +29,6 @@
  22. #include <stdarg.h>
  23. #include <fcntl.h>
  24. #include <libv4l1.h>
  25. -#include "../libv4lconvert/libv4lsyscall-priv.h" /* for __off_t */
  26. #include <sys/ioctl.h>
  27. #include <sys/mman.h>
  28. @@ -119,7 +118,7 @@ LIBV4L_PUBLIC ssize_t read(int fd, void *buffer, size_t n)
  29. }
  30. LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd,
  31. - __off_t offset)
  32. + off_t offset)
  33. {
  34. return v4l1_mmap(start, length, prot, flags, fd, offset);
  35. }
  36. diff --git a/lib/libv4l2/v4l2convert.c b/lib/libv4l2/v4l2convert.c
  37. index a6dc30e..7b7e253 100644
  38. --- a/lib/libv4l2/v4l2convert.c
  39. +++ b/lib/libv4l2/v4l2convert.c
  40. @@ -39,7 +39,6 @@
  41. #include <string.h>
  42. #include <sys/ioctl.h>
  43. #include <sys/mman.h>
  44. -#include "../libv4lconvert/libv4lsyscall-priv.h"
  45. #include <linux/videodev2.h>
  46. #include <libv4l2.h>
  47. @@ -151,14 +150,14 @@ LIBV4L_PUBLIC ssize_t read(int fd, void *buffer, size_t n)
  48. }
  49. LIBV4L_PUBLIC void *mmap(void *start, size_t length, int prot, int flags, int fd,
  50. - __off_t offset)
  51. + off_t offset)
  52. {
  53. return v4l2_mmap(start, length, prot, flags, fd, offset);
  54. }
  55. #if defined(linux) && defined(__GLIBC__)
  56. LIBV4L_PUBLIC void *mmap64(void *start, size_t length, int prot, int flags, int fd,
  57. - __off64_t offset)
  58. + off64_t offset)
  59. {
  60. return v4l2_mmap(start, length, prot, flags, fd, offset);
  61. }
  62. diff --git a/lib/libv4lconvert/libv4lsyscall-priv.h b/lib/libv4lconvert/libv4lsyscall-priv.h
  63. index f548fb2..f87eff4 100644
  64. --- a/lib/libv4lconvert/libv4lsyscall-priv.h
  65. +++ b/lib/libv4lconvert/libv4lsyscall-priv.h
  66. @@ -59,11 +59,6 @@
  67. #define _IOC_SIZE(cmd) IOCPARM_LEN(cmd)
  68. #define MAP_ANONYMOUS MAP_ANON
  69. #define MMAP2_PAGE_SHIFT 0
  70. -typedef off_t __off_t;
  71. -#endif
  72. -
  73. -#if defined(ANDROID)
  74. -typedef off_t __off_t;
  75. #endif
  76. #undef SYS_OPEN
  77. @@ -95,15 +90,15 @@ typedef off_t __off_t;
  78. #if defined(__FreeBSD__)
  79. #define SYS_MMAP(addr, len, prot, flags, fd, off) \
  80. __syscall(SYS_mmap, (void *)(addr), (size_t)(len), \
  81. - (int)(prot), (int)(flags), (int)(fd), (__off_t)(off))
  82. + (int)(prot), (int)(flags), (int)(fd), (off_t)(off))
  83. #elif defined(__FreeBSD_kernel__)
  84. #define SYS_MMAP(addr, len, prot, flags, fd, off) \
  85. syscall(SYS_mmap, (void *)(addr), (size_t)(len), \
  86. - (int)(prot), (int)(flags), (int)(fd), (__off_t)(off))
  87. + (int)(prot), (int)(flags), (int)(fd), (off_t)(off))
  88. #else
  89. #define SYS_MMAP(addr, len, prot, flags, fd, off) \
  90. syscall(SYS_mmap2, (void *)(addr), (size_t)(len), \
  91. - (int)(prot), (int)(flags), (int)(fd), (__off_t)((off) >> MMAP2_PAGE_SHIFT))
  92. + (int)(prot), (int)(flags), (int)(fd), (off_t)((off) >> MMAP2_PAGE_SHIFT))
  93. #endif
  94. #define SYS_MUNMAP(addr, len) \
  95. --
  96. 2.6.2