Commit 3e5c5fb0 authored by Wim Taymans's avatar Wim Taymans

memory: expose default alignment

Export the gst_memory_alignment variable so that others can know the default
configured alignment of the system.
parent 7c475cc6
...@@ -68,13 +68,14 @@ ...@@ -68,13 +68,14 @@
*/ */
#ifdef HAVE_POSIX_MEMALIGN #ifdef HAVE_POSIX_MEMALIGN
#if defined(MEMORY_ALIGNMENT_MALLOC) #if defined(MEMORY_ALIGNMENT_MALLOC)
static size_t _gst_memory_alignment = 7; size_t gst_memory_alignment = 7;
#elif defined(MEMORY_ALIGNMENT_PAGESIZE) #elif defined(MEMORY_ALIGNMENT_PAGESIZE)
static size_t _gst_memory_alignment = 0; size_t gst_memory_alignment = 0;
#elif defined(MEMORY_ALIGNMENT) #elif defined(MEMORY_ALIGNMENT)
static size_t _gst_memory_alignment = MEMORY_ALIGNMENT - 1; size_t gst_memory_alignment = MEMORY_ALIGNMENT - 1;
#else #else
#error "No memory alignment configured" #error "No memory alignment configured"
size_t gst_memory_alignment = 0;
#endif #endif
#endif /* HAVE_POSIX_MEMALIGN */ #endif /* HAVE_POSIX_MEMALIGN */
...@@ -147,7 +148,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size) ...@@ -147,7 +148,7 @@ _default_mem_new_block (gsize maxsize, gsize align, gsize offset, gsize size)
guint8 *data; guint8 *data;
/* ensure configured alignment */ /* ensure configured alignment */
align |= _gst_memory_alignment; align |= gst_memory_alignment;
/* allocate more to compensate for alignment */ /* allocate more to compensate for alignment */
maxsize += align; maxsize += align;
/* alloc header and data in one block */ /* alloc header and data in one block */
...@@ -325,7 +326,7 @@ _gst_memory_init (void) ...@@ -325,7 +326,7 @@ _gst_memory_init (void)
#ifdef HAVE_GETPAGESIZE #ifdef HAVE_GETPAGESIZE
#ifdef MEMORY_ALIGNMENT_PAGESIZE #ifdef MEMORY_ALIGNMENT_PAGESIZE
_gst_memory_alignment = getpagesize () - 1; gst_memory_alignment = getpagesize () - 1;
#endif #endif
#endif #endif
......
...@@ -33,6 +33,8 @@ typedef struct _GstMemory GstMemory; ...@@ -33,6 +33,8 @@ typedef struct _GstMemory GstMemory;
typedef struct _GstMemoryInfo GstMemoryInfo; typedef struct _GstMemoryInfo GstMemoryInfo;
typedef struct _GstMemoryAllocator GstMemoryAllocator; typedef struct _GstMemoryAllocator GstMemoryAllocator;
extern gsize gst_memory_alignment;
/** /**
* GstMemoryFlags: * GstMemoryFlags:
* @GST_MEMORY_FLAG_READONLY: memory is readonly. It is not allowed to map the * @GST_MEMORY_FLAG_READONLY: memory is readonly. It is not allowed to map the
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment