vlc-gcc6-buildfixes.patch 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389
  1. From 66842e08e177e3c458fa0e4db970deae84feb625 Mon Sep 17 00:00:00 2001
  2. From: Jean-Baptiste Kempf <jb@videolan.org>
  3. Date: Tue, 26 May 2015 13:39:00 +0200
  4. Subject: [PATCH 01/13] Fix C++11 compilation of atomic
  5. Close #14569
  6. ---
  7. include/vlc_atomic.h | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++++
  8. 1 file changed, 72 insertions(+)
  9. Index: vlc-2.2.3/include/vlc_atomic.h
  10. ===================================================================
  11. --- vlc-2.2.3.orig/include/vlc_atomic.h
  12. +++ vlc-2.2.3/include/vlc_atomic.h
  13. @@ -26,13 +26,20 @@
  14. * Atomic operations do not require locking, but they are not very powerful.
  15. */
  16. -# if !defined (__cplusplus) && (__STDC_VERSION__ >= 201112L) \
  17. - && !defined (__STDC_NO_ATOMICS__)
  18. +/* Clang older versions support atomics but lacks the stdatomic.h header */
  19. +#if defined(__clang__)
  20. +# if !defined(__has_include) || !__has_include(<stdatomic.h>)
  21. +# define __STDC_NO_ATOMICS__ 1
  22. +# endif
  23. +#endif
  24. +# ifndef __cplusplus
  25. +# if (__STDC_VERSION__ >= 201112L) && !defined (__STDC_NO_ATOMICS__)
  26. /*** Native C11 atomics ***/
  27. -# include <stdatomic.h>
  28. +# include <stdatomic.h>
  29. -# else
  30. +# else
  31. +/*** Intel/GCC atomics ***/
  32. # define ATOMIC_FLAG_INIT false
  33. @@ -53,22 +60,6 @@
  34. # define atomic_is_lock_free(obj) \
  35. false
  36. -/* In principles, __sync_*() only supports int, long and long long and their
  37. - * unsigned equivalents, i.e. 4-bytes and 8-bytes types, although GCC also
  38. - * supports 1 and 2-bytes types. Some non-x86 architectures do not support
  39. - * 8-byte atomic types (or not efficiently). */
  40. -# if defined (_MSC_VER)
  41. -/* Some atomic operations of the Interlocked API are only
  42. - available for desktop apps. Thus we define the atomic types to
  43. - be at least 32 bits wide. */
  44. -typedef int_least32_t atomic_flag;
  45. -typedef int_least32_t atomic_bool;
  46. -typedef int_least32_t atomic_char;
  47. -typedef int_least32_t atomic_schar;
  48. -typedef uint_least32_t atomic_uchar;
  49. -typedef int_least32_t atomic_short;
  50. -typedef uint_least32_t atomic_ushort;
  51. -# else
  52. typedef bool atomic_flag;
  53. typedef bool atomic_bool;
  54. typedef char atomic_char;
  55. @@ -76,7 +67,6 @@ typedef signed char atomic_schar;
  56. typedef unsigned char atomic_uchar;
  57. typedef short atomic_short;
  58. typedef unsigned short atomic_ushort;
  59. -# endif
  60. typedef int atomic_int;
  61. typedef unsigned int atomic_uint;
  62. typedef long atomic_long;
  63. @@ -109,10 +99,6 @@ typedef ptrdiff_t atomic_ptrdiff
  64. typedef intmax_t atomic_intmax_t;
  65. typedef uintmax_t atomic_uintmax_t;
  66. -# if defined (__GCC_HAVE_SYNC_COMPARE_AND_SWAP_4) || (defined (__clang__) && (defined (__x86_64__) || defined (__i386__)))
  67. -
  68. -/*** Intel/GCC atomics ***/
  69. -
  70. # define atomic_store(object,desired) \
  71. do { \
  72. *(object) = (desired); \
  73. @@ -203,204 +189,7 @@ typedef uintmax_t atomic_uintmax
  74. # define atomic_flag_clear_explicit(object,order) \
  75. atomic_flag_clear(object)
  76. -# elif defined (__GNUC__)
  77. -
  78. -/*** No atomics ***/
  79. -
  80. -# define atomic_store(object,desired) \
  81. - do { \
  82. - typeof (object) _obj = (object); \
  83. - typeof (*object) _des = (desired); \
  84. - vlc_global_lock(VLC_ATOMIC_MUTEX); \
  85. - *_obj = _des; \
  86. - vlc_global_unlock(VLC_ATOMIC_MUTEX); \
  87. - } while (0)
  88. -# define atomic_store_explicit(object,desired,order) \
  89. - atomic_store(object,desired)
  90. -
  91. -# define atomic_load(object) \
  92. -({ \
  93. - typeof (object) _obj = (object); \
  94. - typeof (*object) _old; \
  95. - vlc_global_lock(VLC_ATOMIC_MUTEX); \
  96. - _old = *_obj; \
  97. - vlc_global_unlock(VLC_ATOMIC_MUTEX); \
  98. - _old; \
  99. -})
  100. -# define atomic_load_explicit(object,order) \
  101. - atomic_load(object)
  102. -
  103. -# define atomic_exchange(object,desired) \
  104. -({ \
  105. - typeof (object) _obj = (object); \
  106. - typeof (*object) _des = (desired); \
  107. - typeof (*object) _old; \
  108. - vlc_global_lock(VLC_ATOMIC_MUTEX); \
  109. - _old = *_obj; \
  110. - *_obj = _des; \
  111. - vlc_global_unlock(VLC_ATOMIC_MUTEX); \
  112. - _old; \
  113. -})
  114. -# define atomic_exchange_explicit(object,desired,order) \
  115. - atomic_exchange(object,desired)
  116. -
  117. -# define atomic_compare_exchange_strong(object,expected,desired) \
  118. -({ \
  119. - typeof (object) _obj = (object); \
  120. - typeof (object) _exp = (expected); \
  121. - typeof (*object) _des = (desired); \
  122. - bool ret; \
  123. - vlc_global_lock(VLC_ATOMIC_MUTEX); \
  124. - ret = *_obj == *_exp; \
  125. - if (ret) \
  126. - *_obj = _des; \
  127. - else \
  128. - *_exp = *_obj; \
  129. - vlc_global_unlock(VLC_ATOMIC_MUTEX); \
  130. - ret; \
  131. -})
  132. -# define atomic_compare_exchange_strong_explicit(object,expected,desired,order) \
  133. - atomic_compare_exchange_strong(object, expected, desired)
  134. -# define atomic_compare_exchange_weak(object,expected,desired) \
  135. - atomic_compare_exchange_strong(object, expected, desired)
  136. -# define atomic_compare_exchange_weak_explicit(object,expected,desired,order) \
  137. - atomic_compare_exchange_weak(object, expected, desired)
  138. -
  139. -# define atomic_fetch_OP(object,desired,op) \
  140. -({ \
  141. - typeof (object) _obj = (object); \
  142. - typeof (*object) _des = (desired); \
  143. - typeof (*object) _old; \
  144. - vlc_global_lock(VLC_ATOMIC_MUTEX); \
  145. - _old = *_obj; \
  146. - *_obj = (*_obj) op (_des); \
  147. - vlc_global_unlock(VLC_ATOMIC_MUTEX); \
  148. - _old; \
  149. -})
  150. -
  151. -# define atomic_fetch_add(object,operand) \
  152. - atomic_fetch_OP(object,operand,+)
  153. -# define atomic_fetch_add_explicit(object,operand,order) \
  154. - atomic_fetch_add(object,operand)
  155. -
  156. -# define atomic_fetch_sub(object,operand) \
  157. - atomic_fetch_OP(object,operand,-)
  158. -# define atomic_fetch_sub_explicit(object,operand,order) \
  159. - atomic_fetch_sub(object,operand)
  160. -
  161. -# define atomic_fetch_or(object,operand) \
  162. - atomic_fetch_OP(object,operand,|)
  163. -# define atomic_fetch_or_explicit(object,operand,order) \
  164. - atomic_fetch_or(object,operand)
  165. -
  166. -# define atomic_fetch_xor(object,operand) \
  167. - atomic_fetch_OP(object,operand,^)
  168. -# define atomic_fetch_xor_explicit(object,operand,order) \
  169. - atomic_fetch_sub(object,operand)
  170. -
  171. -# define atomic_fetch_and(object,operand) \
  172. - atomic_fetch_OP(object,operand,&)
  173. -# define atomic_fetch_and_explicit(object,operand,order) \
  174. - atomic_fetch_and(object,operand)
  175. -
  176. -# define atomic_flag_test_and_set(object) \
  177. - atomic_exchange(object, true)
  178. -
  179. -# define atomic_flag_test_and_set_explicit(object,order) \
  180. - atomic_flag_test_and_set(object)
  181. -
  182. -# define atomic_flag_clear(object) \
  183. - atomic_store(object, false)
  184. -
  185. -# define atomic_flag_clear_explicit(object,order) \
  186. - atomic_flag_clear(object)
  187. -
  188. -# elif defined (_MSC_VER)
  189. -
  190. -# include <windows.h>
  191. -
  192. -/*** Use the Interlocked API. ***/
  193. -
  194. -/* Define macros in order to dispatch to the correct function depending on the type.
  195. - Several ranges are need because some operations are not implemented for all types. */
  196. -# define atomic_type_dispatch_32_64(operation, object, ...) \
  197. - (sizeof(*object) == 4 ? operation((LONG *)object, __VA_ARGS__) : \
  198. - sizeof(*object) == 8 ? operation##64((LONGLONG *)object, __VA_ARGS__) : \
  199. - (abort(), 0))
  200. -
  201. -# define atomic_type_dispatch_16_64(operation, object, ...) \
  202. - (sizeof(*object) == 2 ? operation##16((short *)object, __VA_ARGS__) : \
  203. - atomic_type_dispatch_32_64(operation, object, __VA_ARGS__))
  204. -
  205. -# define atomic_type_dispatch_8_64(operation, object, ...) \
  206. - (sizeof(*object) == 1 ? operation##8((char *)object, __VA_ARGS__) : \
  207. - atomic_type_dispatch_16_64(operation, object, __VA_ARGS__))
  208. -
  209. -# define atomic_store(object,desired) \
  210. - atomic_type_dispatch_16_64(InterlockedExchange, object, desired)
  211. -# define atomic_store_explicit(object,desired,order) \
  212. - atomic_store(object, desired)
  213. -
  214. -# define atomic_load(object) \
  215. - atomic_type_dispatch_16_64(InterlockedCompareExchange, object, 0, 0)
  216. -# define atomic_load_explicit(object,order) \
  217. - atomic_load(object)
  218. -
  219. -# define atomic_exchange(object,desired) \
  220. - atomic_type_dispatch_16_64(InterlockedExchange, object, desired)
  221. -# define atomic_exchange_explicit(object,desired,order) \
  222. - atomic_exchange(object, desired)
  223. -
  224. -# define atomic_compare_exchange_strong(object,expected,desired) \
  225. - atomic_type_dispatch_16_64(InterlockedCompareExchange, object, *expected, desired) == *expected
  226. -# define atomic_compare_exchange_strong_explicit(object,expected,desired,order) \
  227. - atomic_compare_exchange_strong(object, expected, desired)
  228. -# define atomic_compare_exchange_weak(object,expected,desired) \
  229. - atomic_compare_exchange_strong(object, expected, desired)
  230. -# define atomic_compare_exchange_weak_explicit(object,expected,desired,order) \
  231. - atomic_compare_exchange_weak(object, expected, desired)
  232. -
  233. -# define atomic_fetch_add(object,operand) \
  234. - atomic_type_dispatch_32_64(InterlockedExchangeAdd, object, operand)
  235. -# define atomic_fetch_add_explicit(object,operand,order) \
  236. - atomic_fetch_add(object, operand)
  237. -
  238. -# define atomic_fetch_sub(object,operand) \
  239. - atomic_type_dispatch_32_64(InterlockedExchangeAdd, object, -(LONGLONG)operand)
  240. -# define atomic_fetch_sub_explicit(object,operand,order) \
  241. - atomic_fetch_sub(object, operand)
  242. -
  243. -# define atomic_fetch_or(object,operand) \
  244. - atomic_type_dispatch_8_64(InterlockedOr, object, operand)
  245. -# define atomic_fetch_or_explicit(object,operand,order) \
  246. - atomic_fetch_or(object, operand)
  247. -
  248. -# define atomic_fetch_xor(object,operand) \
  249. - atomic_type_dispatch_8_64(InterlockedXor, object, operand)
  250. -# define atomic_fetch_xor_explicit(object,operand,order) \
  251. - atomic_fetch_sub(object, operand)
  252. -
  253. -# define atomic_fetch_and(object,operand) \
  254. - atomic_type_dispatch_8_64(InterlockedAnd, object, operand)
  255. -# define atomic_fetch_and_explicit(object,operand,order) \
  256. - atomic_fetch_and(object, operand)
  257. -
  258. -# define atomic_flag_test_and_set(object) \
  259. - atomic_exchange(object, true)
  260. -
  261. -# define atomic_flag_test_and_set_explicit(object,order) \
  262. - atomic_flag_test_and_set(object)
  263. -
  264. -# define atomic_flag_clear(object) \
  265. - atomic_store(object, false)
  266. -
  267. -# define atomic_flag_clear_explicit(object,order) \
  268. - atomic_flag_clear(object)
  269. -
  270. -# else
  271. -# error FIXME: implement atomic operations for this compiler.
  272. -# endif
  273. -# endif
  274. +# endif /* !C11 */
  275. typedef atomic_uint_least32_t vlc_atomic_float;
  276. @@ -427,4 +216,9 @@ static inline void vlc_atomic_store_floa
  277. atomic_store(atom, u.i);
  278. }
  279. +# else /* C++ */
  280. +/*** Native C++11 atomics ***/
  281. +# include <atomic>
  282. +# endif /* C++ */
  283. +
  284. #endif
  285. Index: vlc-2.2.3/include/vlc_spu.h
  286. ===================================================================
  287. --- vlc-2.2.3.orig/include/vlc_spu.h
  288. +++ vlc-2.2.3/include/vlc_spu.h
  289. @@ -45,9 +45,6 @@ extern "C" {
  290. typedef struct spu_private_t spu_private_t;
  291. -/* Default subpicture channel ID */
  292. -#define SPU_DEFAULT_CHANNEL (1)
  293. -
  294. /**
  295. * Subpicture unit descriptor
  296. */
  297. Index: vlc-2.2.3/include/vlc_vout_osd.h
  298. ===================================================================
  299. --- vlc-2.2.3.orig/include/vlc_vout_osd.h
  300. +++ vlc-2.2.3/include/vlc_vout_osd.h
  301. @@ -26,12 +26,13 @@
  302. #ifndef VLC_VOUT_OSD_H
  303. #define VLC_VOUT_OSD_H 1
  304. -#include <vlc_spu.h>
  305. -
  306. #ifdef __cplusplus
  307. extern "C" {
  308. #endif
  309. +//* Default subpicture channel ID */
  310. +#define SPU_DEFAULT_CHANNEL (1)
  311. +
  312. /**
  313. * OSD menu position and picture type defines
  314. */
  315. Index: vlc-2.2.3/src/video_output/video_output.c
  316. ===================================================================
  317. --- vlc-2.2.3.orig/src/video_output/video_output.c
  318. +++ vlc-2.2.3/src/video_output/video_output.c
  319. @@ -43,6 +43,7 @@
  320. #include <vlc_vout.h>
  321. #include <vlc_filter.h>
  322. +#include <vlc_spu.h>
  323. #include <vlc_vout_osd.h>
  324. #include <vlc_image.h>
  325. Index: vlc-2.2.3/modules/gui/qt4/dialogs/messages.hpp
  326. ===================================================================
  327. --- vlc-2.2.3.orig/modules/gui/qt4/dialogs/messages.hpp
  328. +++ vlc-2.2.3/modules/gui/qt4/dialogs/messages.hpp
  329. @@ -28,8 +28,8 @@
  330. #include "util/singleton.hpp"
  331. #include "ui/messages_panel.h"
  332. #include <stdarg.h>
  333. -#include <vlc_atomic.h>
  334. #include <QMutex>
  335. +#include <QAtomicInt>
  336. class QTabWidget;
  337. class QPushButton;
  338. @@ -55,7 +55,7 @@ private:
  339. void sinkMessage( const MsgEvent * );
  340. bool matchFilter( const QString& );
  341. - atomic_uint verbosity;
  342. + QAtomicInt verbosity;
  343. static void MsgCallback( void *, int, const vlc_log_t *, const char *,
  344. va_list );
  345. Index: vlc-2.2.3/modules/gui/qt4/dialogs/messages.cpp
  346. ===================================================================
  347. --- vlc-2.2.3.orig/modules/gui/qt4/dialogs/messages.cpp
  348. +++ vlc-2.2.3/modules/gui/qt4/dialogs/messages.cpp
  349. @@ -143,7 +143,7 @@ MessagesDialog::~MessagesDialog()
  350. void MessagesDialog::changeVerbosity( int i_verbosity )
  351. {
  352. - atomic_store( &this->verbosity, i_verbosity );
  353. + verbosity = i_verbosity;
  354. }
  355. void MessagesDialog::updateConfig()
  356. @@ -337,7 +337,7 @@ void MessagesDialog::MsgCallback( void *
  357. {
  358. MessagesDialog *dialog = (MessagesDialog *)self;
  359. char *str;
  360. - int verbosity = atomic_load( &dialog->verbosity );
  361. + int verbosity = dialog->verbosity;
  362. if( verbosity < 0 || verbosity < (type - VLC_MSG_ERR)
  363. || unlikely(vasprintf( &str, format, ap ) == -1) )