From 6c851767259e97738f6c52f28ee538c275de6401 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Sebastian=20Dr=C3=B6ge?= Date: Sun, 23 Mar 2008 11:29:54 +0000 Subject: [PATCH] gst/gstregistrybinary.c: Align memory to the pointer size even if the architecture allows unaligned memory access. Un... Original commit message from CVS: * gst/gstregistrybinary.c: (gst_registry_binary_write): Align memory to the pointer size even if the architecture allows unaligned memory access. Unaligned memory access usually comes with performance penality. --- ChangeLog | 7 +++++++ gst/gstregistrybinary.c | 14 +++----------- 2 files changed, 10 insertions(+), 11 deletions(-) diff --git a/ChangeLog b/ChangeLog index 3215a3dea4..2672ac8e1e 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,10 @@ +2008-03-23 Sebastian Dröge + + * gst/gstregistrybinary.c: (gst_registry_binary_write): + Align memory to the pointer size even if the architecture allows + unaligned memory access. Unaligned memory access usually comes with + performance penality. + 2008-03-23 Sebastian Dröge * gst/gstregistrybinary.c: (gst_registry_binary_write), diff --git a/gst/gstregistrybinary.c b/gst/gstregistrybinary.c index 9df54028af..e3736c5bfa 100644 --- a/gst/gstregistrybinary.c +++ b/gst/gstregistrybinary.c @@ -88,15 +88,9 @@ _outptr = g_strdup ((gchar *)_inptr); \ _inptr += strlen(_outptr) + 1 -#if !GST_HAVE_UNALIGNED_ACCESS -# define ALIGNMENT (sizeof (void *)) -# define alignment(_address) (gsize)_address%ALIGNMENT -# define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr)) -#else -# define ALIGNMENT 0 -# define alignment(_address) 0 -# define align(_ptr) do {} while(0) -#endif +#define ALIGNMENT (sizeof (void *)) +#define alignment(_address) (gsize)_address%ALIGNMENT +#define align(_ptr) _ptr += (( alignment(_ptr) == 0) ? 0 : ALIGNMENT-alignment(_ptr)) /* Registry saving */ @@ -112,7 +106,6 @@ inline static gboolean gst_registry_binary_write (GstRegistry * registry, const void *mem, const gssize size, unsigned long *file_position, gboolean align) { -#if !GST_HAVE_UNALIGNED_ACCESS gchar padder[ALIGN] = { 0, }; int padsize = 0; @@ -125,7 +118,6 @@ gst_registry_binary_write (GstRegistry * registry, const void *mem, } *file_position = *file_position + padsize; } -#endif if (write (registry->cache_file, mem, size) != size) { GST_ERROR ("Failed to write binary registry element");