summaryrefslogtreecommitdiff
path: root/devel/libarena
diff options
context:
space:
mode:
authorbjs <bjs>2008-02-12 02:40:37 +0000
committerbjs <bjs>2008-02-12 02:40:37 +0000
commit0ae29a4b4ace59771bb6bbedcf95540ffd5e0f7d (patch)
tree14a8f8d99edb3b1437e9bbc8a3deeab950c2b39f /devel/libarena
parent4331bc34fc8d6f2ad8b8739f345884d84b07ac2b (diff)
downloadpkgsrc-0ae29a4b4ace59771bb6bbedcf95540ffd5e0f7d.tar.gz
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 (limited to 'devel/libarena')
-rw-r--r--devel/libarena/DESCR22
-rw-r--r--devel/libarena/Makefile39
-rw-r--r--devel/libarena/PLIST12
-rw-r--r--devel/libarena/distinfo7
-rw-r--r--devel/libarena/patches/patch-aa24
-rw-r--r--devel/libarena/patches/patch-ab19
6 files changed, 123 insertions, 0 deletions
diff --git a/devel/libarena/DESCR b/devel/libarena/DESCR
new file mode 100644
index 00000000000..4d5f9fab780
--- /dev/null
+++ b/devel/libarena/DESCR
@@ -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 --git a/devel/libarena/Makefile b/devel/libarena/Makefile
new file mode 100644
index 00000000000..791296ae3ea
--- /dev/null
+++ b/devel/libarena/Makefile
@@ -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
+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 --git a/devel/libarena/PLIST b/devel/libarena/PLIST
new file mode 100644
index 00000000000..f38488c7f1f
--- /dev/null
+++ b/devel/libarena/PLIST
@@ -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 --git a/devel/libarena/distinfo b/devel/libarena/distinfo
new file mode 100644
index 00000000000..2c04424f512
--- /dev/null
+++ b/devel/libarena/distinfo
@@ -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 --git a/devel/libarena/patches/patch-aa b/devel/libarena/patches/patch-aa
new file mode 100644
index 00000000000..62f2a0c38cc
--- /dev/null
+++ b/devel/libarena/patches/patch-aa
@@ -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 --git a/devel/libarena/patches/patch-ab b/devel/libarena/patches/patch-ab
new file mode 100644
index 00000000000..df4b554d1df
--- /dev/null
+++ b/devel/libarena/patches/patch-ab
@@ -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