mirror of
https://gitlab.freedesktop.org/gstreamer/gstreamer.git
synced 2024-11-19 16:21:17 +00:00
gst/gstregistrybinary.c: Align memory to the pointer size instead of always 32 bit. Fixes unaligned memory accesses o...
Original commit message from CVS: * gst/gstregistrybinary.c: (gst_registry_binary_write), (gst_registry_binary_check_magic), (gst_registry_binary_load_pad_template), (gst_registry_binary_load_feature), (gst_registry_binary_load_plugin): Align memory to the pointer size instead of always 32 bit. Fixes unaligned memory accesses on ia64 and friends. * gst/gstregistrybinary.h: Bump binary registry format version for this as it changes the format on those architectures that don't have unaligned access and 64 bit pointers.
This commit is contained in:
parent
b0346dff44
commit
79bd94558c
4 changed files with 34 additions and 17 deletions
15
ChangeLog
15
ChangeLog
|
@ -1,3 +1,18 @@
|
||||||
|
2008-03-23 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
|
* gst/gstregistrybinary.c: (gst_registry_binary_write),
|
||||||
|
(gst_registry_binary_check_magic),
|
||||||
|
(gst_registry_binary_load_pad_template),
|
||||||
|
(gst_registry_binary_load_feature),
|
||||||
|
(gst_registry_binary_load_plugin):
|
||||||
|
Align memory to the pointer size instead of always 32 bit. Fixes
|
||||||
|
unaligned memory accesses on ia64 and friends.
|
||||||
|
|
||||||
|
* gst/gstregistrybinary.h:
|
||||||
|
Bump binary registry format version for this as it changes the
|
||||||
|
format on those architectures that don't have unaligned access
|
||||||
|
and 64 bit pointers.
|
||||||
|
|
||||||
2008-03-22 Sebastian Dröge <slomo@circular-chaos.org>
|
2008-03-22 Sebastian Dröge <slomo@circular-chaos.org>
|
||||||
|
|
||||||
* docs/pwg/advanced-dparams.xml:
|
* docs/pwg/advanced-dparams.xml:
|
||||||
|
|
2
common
2
common
|
@ -1 +1 @@
|
||||||
Subproject commit 9a358e5cc3977fd6121f12dd25a358081fd77041
|
Subproject commit 4221e9dcb05faa6f6f7ba19bba32fe90da4577dd
|
|
@ -77,7 +77,7 @@
|
||||||
/* macros */
|
/* macros */
|
||||||
|
|
||||||
#define unpack_element(_inptr, _outptr, _element) \
|
#define unpack_element(_inptr, _outptr, _element) \
|
||||||
_outptr = (_element *)_inptr; \
|
_outptr = (_element *) _inptr; \
|
||||||
_inptr += sizeof (_element)
|
_inptr += sizeof (_element)
|
||||||
|
|
||||||
#define unpack_const_string(_inptr, _outptr) \
|
#define unpack_const_string(_inptr, _outptr) \
|
||||||
|
@ -89,11 +89,13 @@
|
||||||
_inptr += strlen(_outptr) + 1
|
_inptr += strlen(_outptr) + 1
|
||||||
|
|
||||||
#if !GST_HAVE_UNALIGNED_ACCESS
|
#if !GST_HAVE_UNALIGNED_ACCESS
|
||||||
# define alignment32(_address) (gsize)_address%4
|
# define ALIGNMENT (sizeof (void *))
|
||||||
# define align32(_ptr) _ptr += (( alignment32(_ptr) == 0) ? 0 : 4-alignment32(_ptr))
|
# define alignment(_address) (gsize)_address%ALIGNMENT
|
||||||
|
# define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr))
|
||||||
#else
|
#else
|
||||||
# define alignment32(_address) 0
|
# define ALIGNMENT 0
|
||||||
# define align32(_ptr) do {} while(0)
|
# define alignment(_address) 0
|
||||||
|
# define align(_ptr) do {} while(0)
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
|
||||||
|
@ -111,12 +113,12 @@ gst_registry_binary_write (GstRegistry * registry, const void *mem,
|
||||||
const gssize size, unsigned long *file_position, gboolean align)
|
const gssize size, unsigned long *file_position, gboolean align)
|
||||||
{
|
{
|
||||||
#if !GST_HAVE_UNALIGNED_ACCESS
|
#if !GST_HAVE_UNALIGNED_ACCESS
|
||||||
gchar padder[] = { 0, 0, 0, 0 };
|
gchar padder[ALIGN] = { 0, };
|
||||||
int padsize = 0;
|
int padsize = 0;
|
||||||
|
|
||||||
/* Padding to insert the struct that requiere word alignment */
|
/* Padding to insert the struct that requiere word alignment */
|
||||||
if ((align) && (alignment32 (*file_position) != 0)) {
|
if ((align) && (alignment (*file_position) != 0)) {
|
||||||
padsize = 4 - alignment32 (*file_position);
|
padsize = ALIGNMENT - alignment (*file_position);
|
||||||
if (write (registry->cache_file, padder, padsize) != padsize) {
|
if (write (registry->cache_file, padder, padsize) != padsize) {
|
||||||
GST_ERROR ("Failed to write binary registry padder");
|
GST_ERROR ("Failed to write binary registry padder");
|
||||||
return FALSE;
|
return FALSE;
|
||||||
|
@ -606,7 +608,7 @@ gst_registry_binary_check_magic (gchar ** in)
|
||||||
{
|
{
|
||||||
GstBinaryRegistryMagic *m;
|
GstBinaryRegistryMagic *m;
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_DEBUG ("Reading/casting for GstBinaryRegistryMagic at address %p", *in);
|
GST_DEBUG ("Reading/casting for GstBinaryRegistryMagic at address %p", *in);
|
||||||
unpack_element (*in, m, GstBinaryRegistryMagic);
|
unpack_element (*in, m, GstBinaryRegistryMagic);
|
||||||
|
|
||||||
|
@ -648,7 +650,7 @@ gst_registry_binary_load_pad_template (GstElementFactory * factory, gchar ** in)
|
||||||
GstBinaryPadTemplate *pt;
|
GstBinaryPadTemplate *pt;
|
||||||
GstStaticPadTemplate *template;
|
GstStaticPadTemplate *template;
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_DEBUG ("Reading/casting for GstBinaryPadTemplate at address %p", *in);
|
GST_DEBUG ("Reading/casting for GstBinaryPadTemplate at address %p", *in);
|
||||||
unpack_element (*in, pt, GstBinaryPadTemplate);
|
unpack_element (*in, pt, GstBinaryPadTemplate);
|
||||||
|
|
||||||
|
@ -714,7 +716,7 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
|
||||||
GstBinaryElementFactory *ef;
|
GstBinaryElementFactory *ef;
|
||||||
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
GstElementFactory *factory = GST_ELEMENT_FACTORY (feature);
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_LOG ("Reading/casting for GstBinaryElementFactory at address %p", *in);
|
GST_LOG ("Reading/casting for GstBinaryElementFactory at address %p", *in);
|
||||||
unpack_element (*in, ef, GstBinaryElementFactory);
|
unpack_element (*in, ef, GstBinaryElementFactory);
|
||||||
pf = (GstBinaryPluginFeature *) ef;
|
pf = (GstBinaryPluginFeature *) ef;
|
||||||
|
@ -739,7 +741,7 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
|
||||||
if (ef->nuriprotocols) {
|
if (ef->nuriprotocols) {
|
||||||
GST_DEBUG ("Reading %d UriTypes at address %p", ef->nuriprotocols, *in);
|
GST_DEBUG ("Reading %d UriTypes at address %p", ef->nuriprotocols, *in);
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
factory->uri_type = *((guint *) * in);
|
factory->uri_type = *((guint *) * in);
|
||||||
*in += sizeof (factory->uri_type);
|
*in += sizeof (factory->uri_type);
|
||||||
//unpack_element(*in, &factory->uri_type, factory->uri_type);
|
//unpack_element(*in, &factory->uri_type, factory->uri_type);
|
||||||
|
@ -761,7 +763,7 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
|
||||||
GstBinaryTypeFindFactory *tff;
|
GstBinaryTypeFindFactory *tff;
|
||||||
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
GstTypeFindFactory *factory = GST_TYPE_FIND_FACTORY (feature);
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
|
GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
|
||||||
unpack_element (*in, tff, GstBinaryTypeFindFactory);
|
unpack_element (*in, tff, GstBinaryTypeFindFactory);
|
||||||
pf = (GstBinaryPluginFeature *) tff;
|
pf = (GstBinaryPluginFeature *) tff;
|
||||||
|
@ -785,7 +787,7 @@ gst_registry_binary_load_feature (GstRegistry * registry, gchar ** in,
|
||||||
else if (GST_IS_INDEX_FACTORY (feature)) {
|
else if (GST_IS_INDEX_FACTORY (feature)) {
|
||||||
GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
|
GstIndexFactory *factory = GST_INDEX_FACTORY (feature);
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
|
GST_DEBUG ("Reading/casting for GstBinaryPluginFeature at address %p", *in);
|
||||||
unpack_element (*in, pf, GstBinaryPluginFeature);
|
unpack_element (*in, pf, GstBinaryPluginFeature);
|
||||||
|
|
||||||
|
@ -830,7 +832,7 @@ gst_registry_binary_load_plugin (GstRegistry * registry, gchar ** in)
|
||||||
GstPlugin *plugin = NULL;
|
GstPlugin *plugin = NULL;
|
||||||
guint i;
|
guint i;
|
||||||
|
|
||||||
align32 (*in);
|
align (*in);
|
||||||
GST_LOG ("Reading/casting for GstBinaryPluginElement at address %p", *in);
|
GST_LOG ("Reading/casting for GstBinaryPluginElement at address %p", *in);
|
||||||
unpack_element (*in, pe, GstBinaryPluginElement);
|
unpack_element (*in, pe, GstBinaryPluginElement);
|
||||||
|
|
||||||
|
|
|
@ -57,7 +57,7 @@
|
||||||
* This _must_ be updated whenever the registry format changes,
|
* This _must_ be updated whenever the registry format changes,
|
||||||
* we currently use the core version where this change happened.
|
* we currently use the core version where this change happened.
|
||||||
*/
|
*/
|
||||||
#define GST_MAGIC_BINARY_VERSION_STR ("0.10.18")
|
#define GST_MAGIC_BINARY_VERSION_STR ("0.10.18.1")
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* GST_MAGIC_BINARY_VERSION_LEN:
|
* GST_MAGIC_BINARY_VERSION_LEN:
|
||||||
|
|
Loading…
Reference in a new issue