pkgsrc-Changes-HG archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

[pkgsrc/trunk]: pkgsrc/devel/libarena Import libarena, a BSD-licensed memory ...



details:   https://anonhg.NetBSD.org/pkgsrc/rev/e53f399b601a
branches:  trunk
changeset: 538531:e53f399b601a
user:      bjs <bjs%pkgsrc.org@localhost>
date:      Tue Feb 12 02:40:37 2008 +0000

description:
Import libarena, a BSD-licensed memory allocator abstraction API.
Also included are four allocators which also serve as examples
as to how to use the interface.  AFAIK, it's sort of like vmem(9)
in userland (not that I know much about vmem, for the manpage
is quite terse, heh).

I imported this not as a dependency, but because I thought it
looked interesting, especially with regard to what's outlined
in the last paragraph.  I may use it in porting some linux audio
software at some point, though that's still a ways off ...

A short blurb:


Libarena is a custom memory allocator interface and implementation. Four
allocators are provided: flat LIFO arena allocator, object pool allocator
and two malloc(3) wrappers: one which returns the pointers unadulterated
and one which obeys the requested, arbitrary alignment. These can be used
directly, or through their exported prototype interfaces.

Libarena is meant to provide a baseline interface so allocator's can be
stacked, and to provide a simple and well defined interface for libraries
and applications without becoming mired in features or capabilities. It is
not meant to restrict or confine what custom allocators can actually
accomplish. For instance, the included pool and arena allocators include a
suite of string utilities which aren't available in the generic exportable
interface. Note that these string utilities are built upon a generic
interface (see util.h) which can take the prototypical allocation context,
so they are also available to any 3rd party compatible allocators.

Surprisingly few malloc(3) library "replacements" or plug-in interfaces
support a context pointer argument. They're useless for many or most of
the tasks where the ability to specify an alternate malloc(3) could
actually be useful, e.g. poor man's RAII. For network daemons especially
this feature is useful; all allocations for a particular session can be
freed simply by closing the lowest-level allocator object.

diffstat:

 devel/libarena/DESCR            |  22 ++++++++++++++++++++++
 devel/libarena/Makefile         |  39 +++++++++++++++++++++++++++++++++++++++
 devel/libarena/PLIST            |  12 ++++++++++++
 devel/libarena/distinfo         |   7 +++++++
 devel/libarena/patches/patch-aa |  24 ++++++++++++++++++++++++
 devel/libarena/patches/patch-ab |  19 +++++++++++++++++++
 6 files changed, 123 insertions(+), 0 deletions(-)

diffs (147 lines):

diff -r 58d21891c857 -r e53f399b601a devel/libarena/DESCR
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/DESCR      Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,22 @@
+Libarena is a custom memory allocator interface and implementation. Four
+allocators are provided: flat LIFO arena allocator, object pool allocator
+and two malloc(3) wrappers: one which returns the pointers unadulterated
+and one which obeys the requested, arbitrary alignment. These can be used
+directly, or through their exported prototype interfaces.
+
+Libarena is meant to provide a baseline interface so allocator's can be
+stacked, and to provide a simple and well defined interface for libraries
+and applications without becoming mired in features or capabilities. It is
+not meant to restrict or confine what custom allocators can actually
+accomplish. For instance, the included pool and arena allocators include a
+suite of string utilities which aren't available in the generic exportable
+interface. Note that these string utilities are built upon a generic
+interface (see util.h) which can take the prototypical allocation context,
+so they are also available to any 3rd party compatible allocators.
+
+Surprisingly few malloc(3) library "replacements" or plug-in interfaces
+support a context pointer argument. They're useless for many or most of
+the tasks where the ability to specify an alternate malloc(3) could
+actually be useful, e.g. poor man's RAII. For network daemons especially
+this feature is useful; all allocations for a particular session can be
+freed simply by closing the lowest-level allocator object.
diff -r 58d21891c857 -r e53f399b601a devel/libarena/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/Makefile   Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,39 @@
+# $NetBSD: Makefile,v 1.1.1.1 2008/02/12 02:40:37 bjs Exp $
+#
+
+DISTNAME=      libarena-snapshot
+PKGNAME=       libarena-${SNAPSHOT_DATE}
+CATEGORIES=    devel
+MASTER_SITES=  http://www.25thandclement.com/~william/projects/snapshots/
+EXTRACT_SUFX=  .tgz
+SNAPSHOT_DATE= 20080211
+
+MAINTAINER=    bjs%NetBSD.org@localhost
+HOMEPAGE=      http://www.25thandclement.com/~william/projects/libarena.html
+COMMENT=       Memory allocator API and implementation
+
+PKG_DESTDIR_SUPPORT=   user-destdir
+
+WRKSRC=                ${WRKDIR}/${PKGNAME_NOREV}
+
+BUILD_TARGET=  pic
+USE_FEATURES=  getenv vsnprintf # XXX strsep should be added to USE_FEATURES
+USE_LIBTOOL=   yes
+
+EGDIR=         ${PREFIX}/share/examples/${PKGBASE}
+
+pre-install:
+       ${INSTALL_LIB_DIR} ${DESTDIR}${PREFIX}/lib && \
+       ${INSTALL_DATA_DIR} ${DESTDIR}${PREFIX}/include/arena
+
+do-install:
+       for fn in `eval ls ${WRKSRC}/src/*.h`; do \
+           ${INSTALL_DATA} $$fn ${DESTDIR}${PREFIX}/include/arena; \
+       done
+       ${LIBTOOL} --mode=install ${INSTALL_LIB} \
+           ${WRKSRC}/src/${PKGBASE}.la ${DESTDIR}${PREFIX}/lib
+       ${INSTALL_DATA_DIR} ${DESTDIR}${EGDIR} && \
+       ${INSTALL_DATA} ${WRKSRC}/regress/stacked.c \
+           ${DESTDIR}${EGDIR}
+
+.include "../../mk/bsd.pkg.mk"
diff -r 58d21891c857 -r e53f399b601a devel/libarena/PLIST
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/PLIST      Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,12 @@
+@comment $NetBSD: PLIST,v 1.1.1.1 2008/02/12 02:40:37 bjs Exp $
+include/arena/align.h
+include/arena/arena.h
+include/arena/pool.h
+include/arena/proto.h
+include/arena/queue.h
+include/arena/rbits.h
+include/arena/util.h
+lib/libarena.la
+share/examples/libarena/stacked.c
+@dirrm include/arena
+@dirrm share/examples/libarena
diff -r 58d21891c857 -r e53f399b601a devel/libarena/distinfo
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/distinfo   Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,7 @@
+$NetBSD: distinfo,v 1.1.1.1 2008/02/12 02:40:37 bjs Exp $
+
+SHA1 (libarena-snapshot.tgz) = 05fb8556b1fe1a6fba6021a73a2bf552e64f98e3
+RMD160 (libarena-snapshot.tgz) = 44b06a6aab6b8579268d0b9d77658fd1239c3681
+Size (libarena-snapshot.tgz) = 22874 bytes
+SHA1 (patch-aa) = 7bfca72eedc7a3bd7b36acb718e57d5347762aa8
+SHA1 (patch-ab) = 56be16d641097e1ae6149e10aefb22837639dff3
diff -r 58d21891c857 -r e53f399b601a devel/libarena/patches/patch-aa
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/patches/patch-aa   Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,24 @@
+$NetBSD: patch-aa,v 1.1.1.1 2008/02/12 02:40:37 bjs Exp $
+
+--- src/util.c.orig    2008-02-11 03:01:04.000000000 -0500
++++ src/util.c
+@@ -23,11 +23,17 @@
+  * USE OR OTHER DEALINGS IN THE SOFTWARE.
+  * ==========================================================================
+  */
++#if defined(HAVE_NBCOMPAT_H)
++#include <nbcompat/config.h>
++#include <nbcompat/cdefs.h>
++#include <nbcompat/stdio.h>
++#include <nbcompat/string.h>
++#else
+ #include <stdio.h>    /* vsnprintf(3) */
+-#include <stdarg.h>   /* va_list va_copy va_start va_end */
+-
+ #include <string.h>   /* memchr(3) memcpy(3) strsep(3) strerror(3) */
++#endif
+ 
++#include <stdarg.h>   /* va_list va_copy va_start va_end */
+ #include <errno.h>    /* EFAULT errno */
+ 
+ #include "proto.h"    /* struct arena_prototype */
diff -r 58d21891c857 -r e53f399b601a devel/libarena/patches/patch-ab
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/devel/libarena/patches/patch-ab   Tue Feb 12 02:40:37 2008 +0000
@@ -0,0 +1,19 @@
+$NetBSD: patch-ab,v 1.1.1.1 2008/02/12 02:40:37 bjs Exp $
+
+--- src/pool.c.orig    2008-02-11 03:01:04.000000000 -0500
++++ src/pool.c
+@@ -23,7 +23,14 @@
+  * USE OR OTHER DEALINGS IN THE SOFTWARE.
+  * ==========================================================================
+  */
++#if defined(HAVE_NBCOMPAT_H)
++#include <nbcompat/config.h>
++#include <nbcompat/cdefs.h>
+ #include <stdio.h>
++#else
++#include <stdio.h>
++#endif
++
+ #include <stdlib.h>   /* size_t */
+ 
+ #ifdef _WIN32



Home | Main Index | Thread Index | Old Index