[vlc-commits] picture: ensure picture_t layout is fixed across languages and versions

Rémi Denis-Courmont git at videolan.org
Thu Jun 25 23:29:52 CEST 2015


vlc/vlc-2.2 | branch: master | Rémi Denis-Courmont <remi at remlab.net> | Fri Jun 26 00:27:15 2015 +0300| [0e3f56becd1fb803304f339346eb3a6413cf722f] | committer: Rémi Denis-Courmont

picture: ensure picture_t layout is fixed across languages and versions

Plugins should not access picture_t.gc, but they can access
picture_t.p_next or allocate a picture_t on stack, so we need to ensure
that the size of picture_t.gc matches.

> http://git.videolan.org/gitweb.cgi/vlc/vlc-2.2.git/?a=commit;h=0e3f56becd1fb803304f339346eb3a6413cf722f
---

 include/vlc_picture.h |    4 ++++
 src/misc/picture.c    |    8 ++++++++
 2 files changed, 12 insertions(+)

diff --git a/include/vlc_picture.h b/include/vlc_picture.h
index d3e3b99..dea3f7f 100644
--- a/include/vlc_picture.h
+++ b/include/vlc_picture.h
@@ -102,7 +102,11 @@ struct picture_t
     /** This way the picture_Release can be overloaded */
     struct
     {
+#if (defined (__LIBVLC__) && !defined (__PLUGIN__))
         atomic_uintptr_t refcount;
+#else
+        uintptr_t refcount_placeholder_keep_off;
+#endif
         void (*pf_destroy)( picture_t * );
         picture_gc_sys_t *p_sys;
     } gc;
diff --git a/src/misc/picture.c b/src/misc/picture.c
index 7c6fa6a..d7cc482 100644
--- a/src/misc/picture.c
+++ b/src/misc/picture.c
@@ -38,6 +38,14 @@
 #include <vlc_image.h>
 #include <vlc_block.h>
 
+#if (__STDC_VERSION__ >= 201112L)
+# include <stdalign.h>
+static_assert(sizeof (uintptr_t) == sizeof (atomic_uintptr_t),
+              "Please compile in C99 mode (or update to LibVLC 3.0).");
+static_assert(alignof (uintptr_t) == alignof (atomic_uintptr_t),
+              "Please compile in C99 mode (or update to LibVLC 3.0).");
+#endif
+
 /**
  * Allocate a new picture in the heap.
  *



More information about the vlc-commits mailing list