This is the mail archive of the
ecos-patches@sources.redhat.com
mailing list for the eCos project.
Patch: make minimum memory alignment configurable
- From: Eric Doenges <Eric dot Doenges at DynaPel dot com>
- To: eCos patches <ecos-patches at sources dot redhat dot com>
- Date: Tue, 30 Sep 2003 16:19:41 +0200
- Subject: Patch: make minimum memory alignment configurable
The included patch make the minimum memory alignment used by Doug Lea's
memory allocator (dlmalloc) configurable via the configuration tool.
This is necessary (for me) since some hardware units on my target
require memory allocated on 16 byte boundaries, but eCos does not seem
to provide posix_memalign() or something equivalent. While writing
a posix_memalign() implementation would clearly be the better solution,
this is much simpler and quicker.
--
--------------------------------------------------------------------
| Eric Doenges | DynaPel Laboratories GmbH |
| Tel: +49 89 962428 23 | Fraunhoferstrasse 9/2 |
| Fax: +49 89 962428 90 | D - 85737 Ismaning, Germany |
--------------------------------------------------------------------
Index: ChangeLog
===================================================================
RCS file: /cvs/ecos/ecos/packages/services/memalloc/common/current/ChangeLog,v
retrieving revision 1.27
diff -u -5 -b -r1.27 ChangeLog
--- ChangeLog 5 Feb 2003 01:10:12 -0000 1.27
+++ ChangeLog 30 Sep 2003 14:11:26 -0000
@@ -1,5 +1,10 @@
+2003-09-30 Eric Doenges <Eric.Doengea@DynaPel.com>
+
+ * cdl/memalloc.cdl, src/dlmalloc.cxx: Make the minimum memory
+ alignment a configuration option for Doug Lea's memory allocator.
+
2003-02-05 Jonathan Larmour <jifl@eCosCentric.com>
* include/memjoin.inl: Don't use default arg in definition.
2003-02-04 John Dallaway <jld@ecoscentric.com>
Index: cdl/memalloc.cdl
===================================================================
RCS file: /cvs/ecos/ecos/packages/services/memalloc/common/current/cdl/memalloc.cdl,v
retrieving revision 1.11
diff -u -5 -b -r1.11 memalloc.cdl
--- cdl/memalloc.cdl 23 May 2002 23:08:42 -0000 1.11
+++ cdl/memalloc.cdl 30 Sep 2003 14:11:26 -0000
@@ -182,10 +182,22 @@
This may be used to control whether memset() and memcpy()
are used within the implementation. The alternative is
to use some macro equivalents, which some people report
are faster in some circumstances."
}
+
+ cdl_option CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT {
+ display "Minimum alignment of allocated blocks"
+ flavor data
+ legal_values 3 to 10
+ default_value 3
+ description "
+ This option controls the minimum alignment that the
+ allocated memory blocks are aligned on, specified as
+ 2^N. Note that using large mininum alignments can lead
+ to excessive memory wastage."
+ }
}
cdl_component CYGPKG_MEMALLOC_ALLOCATOR_SEPMETA {
display "Variable block allocator with separate metadata"
flavor none
Index: src/dlmalloc.cxx
===================================================================
RCS file: /cvs/ecos/ecos/packages/services/memalloc/common/current/src/dlmalloc.cxx,v
retrieving revision 1.6
diff -u -5 -b -r1.6 dlmalloc.cxx
--- src/dlmalloc.cxx 23 May 2002 23:08:44 -0000 1.6
+++ src/dlmalloc.cxx 30 Sep 2003 14:11:26 -0000
@@ -493,10 +493,15 @@
typedef struct Cyg_Mempool_dlmalloc_Implementation::malloc_chunk* mchunkptr;
/* sizes, alignments */
#define SIZE_SZ (sizeof(INTERNAL_SIZE_T))
+
+#ifdef CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT
+#define MALLOC_ALIGNMENT (1<<(CYGNUM_MEMALLOC_ALLOCATOR_DLMALLOC_ALIGNMENT))
+#endif
+
#ifndef MALLOC_ALIGNMENT
#define MALLOC_ALIGN 8
#define MALLOC_ALIGNMENT (SIZE_SZ + SIZE_SZ)
#else
#define MALLOC_ALIGN MALLOC_ALIGNMENT