memory: expose default alignment

Export the gst_memory_alignment variable so that others can know the default
configured alignment of the system.
This commit is contained in:
Wim Taymans 2011-06-10 16:46:12 +02:00
parent 7c475cc60f
commit 3e5c5fb034
2 changed files with 8 additions and 5 deletions

View file

@ -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

View file

@ -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