From 3e5c5fb034b68291126783207d6b8328bb4759cb Mon Sep 17 00:00:00 2001 From: Wim Taymans Date: Fri, 10 Jun 2011 16:46:12 +0200 Subject: [PATCH] memory: expose default alignment Export the gst_memory_alignment variable so that others can know the default configured alignment of the system. --- gst/gstmemory.c | 11 ++++++----- gst/gstmemory.h | 2 ++ 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/gst/gstmemory.c b/gst/gstmemory.c index 78794bb466..7985ec99a3 100644 --- a/gst/gstmemory.c +++ b/gst/gstmemory.c @@ -68,13 +68,14 @@ */ #ifdef HAVE_POSIX_MEMALIGN #if defined(MEMORY_ALIGNMENT_MALLOC) -static size_t _gst_memory_alignment = 7; +size_t gst_memory_alignment = 7; #elif defined(MEMORY_ALIGNMENT_PAGESIZE) -static size_t _gst_memory_alignment = 0; +size_t gst_memory_alignment = 0; #elif defined(MEMORY_ALIGNMENT) -static size_t _gst_memory_alignment = MEMORY_ALIGNMENT - 1; +size_t gst_memory_alignment = MEMORY_ALIGNMENT - 1; #else #error "No memory alignment configured" +size_t gst_memory_alignment = 0; #endif #endif /* HAVE_POSIX_MEMALIGN */ @@ -147,7 +148,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size) guint8 *data; /* ensure configured alignment */ - align |= _gst_memory_alignment; + align |= gst_memory_alignment; /* allocate more to compensate for alignment */ maxsize += align; /* alloc header and data in one block */ @@ -325,7 +326,7 @@ _gst_memory_init (void) #ifdef HAVE_GETPAGESIZE #ifdef MEMORY_ALIGNMENT_PAGESIZE - _gst_memory_alignment = getpagesize () - 1; + gst_memory_alignment = getpagesize () - 1; #endif #endif diff --git a/gst/gstmemory.h b/gst/gstmemory.h index 4f285ce5fa..452d1a4fff 100644 --- a/gst/gstmemory.h +++ b/gst/gstmemory.h @@ -33,6 +33,8 @@ typedef struct _GstMemory GstMemory; typedef struct _GstMemoryInfo GstMemoryInfo; typedef struct _GstMemoryAllocator GstMemoryAllocator; +extern gsize gst_memory_alignment; + /** * GstMemoryFlags: * @GST_MEMORY_FLAG_READONLY: memory is readonly. It is not allowed to map the