Source-Changes-HG archive

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

[src/trunk]: src/external/bsd/jemalloc - descend to build libjemalloc



details:   https://anonhg.NetBSD.org/src/rev/8dba25a6d2bc
branches:  trunk
changeset: 997554:8dba25a6d2bc
user:      christos <christos%NetBSD.org@localhost>
date:      Tue Mar 12 15:13:25 2019 +0000

description:
- descend to build libjemalloc
- namespace protect all functions __je
- provide getters and setters for malloc_conf and malloc_message

diffstat:

 external/bsd/jemalloc/Makefile                    |    5 +
 external/bsd/jemalloc/dist/src/jemalloc.c         |   67 +++++++--
 external/bsd/jemalloc/include/jemalloc/jemalloc.h |   65 +++++----
 external/bsd/jemalloc/lib/Makefile                |    4 +-
 external/bsd/jemalloc/lib/Makefile.inc            |    4 +-
 external/bsd/jemalloc/lib/jemalloc_stub.c         |  141 ++++++++++++++++++++++
 6 files changed, 236 insertions(+), 50 deletions(-)

diffs (truncated from 366 to 300 lines):

diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/Makefile
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/jemalloc/Makefile    Tue Mar 12 15:13:25 2019 +0000
@@ -0,0 +1,5 @@
+#      $NetBSD: Makefile,v 1.1 2019/03/12 15:13:25 christos Exp $
+
+SUBDIR=        lib
+
+.include <bsd.subdir.mk>
diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/dist/src/jemalloc.c
--- a/external/bsd/jemalloc/dist/src/jemalloc.c Tue Mar 12 15:11:13 2019 +0000
+++ b/external/bsd/jemalloc/dist/src/jemalloc.c Tue Mar 12 15:13:25 2019 +0000
@@ -20,24 +20,31 @@
 #include "jemalloc/internal/ticker.h"
 #include "jemalloc/internal/util.h"
 
-__weak_alias(mallocx, je_mallocx)
-__weak_alias(rallocx, je_rallocx)
-__weak_alias(xallocx, je_xallocx)
-__weak_alias(sallocx, je_sallocx)
-__weak_alias(dallocx, je_dallocx)
-__weak_alias(sdallocx, je_sdallocx)
-__weak_alias(nallocx, je_nallocx)
-
-__weak_alias(mallctl, je_mallctl)
-__weak_alias(mallctlnametomib, je_mallctlnametomib)
-__weak_alias(mallctlbymib, je_mallctlbymib)
-
-__weak_alias(malloc_stats_print, je_malloc_stats_print)
-__weak_alias(malloc_usable_size, je_malloc_usable_size)
-
-__weak_alias(malloc_message, je_malloc_message)
-
-__weak_alias(malloc_conf, je_malloc_conf)
+#ifdef JEMALLOC_WEAK_NOSTD
+__weak_alias(mallocx, __je_mallocx)
+__weak_alias(rallocx, __je_rallocx)
+__weak_alias(xallocx, __je_xallocx)
+__weak_alias(sallocx, __je_sallocx)
+__weak_alias(dallocx, __je_dallocx)
+__weak_alias(sdallocx, __je_sdallocx)
+__weak_alias(nallocx, __je_nallocx)
+
+__weak_alias(mallctl, __je_mallctl)
+__weak_alias(mallctlnametomib, __je_mallctlnametomib)
+__weak_alias(mallctlbymib, __je_mallctlbymib)
+
+__weak_alias(malloc_stats_print, __je_malloc_stats_print)
+__weak_alias(malloc_usable_size, __je_malloc_usable_size)
+
+__weak_alias(malloc_message, __je_malloc_message)
+__weak_alias(malloc_conf, __je_malloc_conf)
+
+__weak_alias(malloc_message_get, __je_malloc_message_get)
+__weak_alias(malloc_conf_get, __je_malloc_conf_get)
+
+__weak_alias(malloc_message_set, __je_malloc_message_set)
+__weak_alias(malloc_conf_set, __je_malloc_conf_set)
+#endif
 
 /******************************************************************************/
 /* Data. */
@@ -3354,4 +3361,28 @@
        ctl_postfork_child(tsd_tsdn(tsd));
 }
 
+void (*
+je_malloc_message_get(void))(void *, const char *)
+{
+       return je_malloc_message;
+}
+
+void
+je_malloc_message_set(void (*m)(void *, const char *))
+{
+       je_malloc_message = m;
+}
+
+const char *
+je_malloc_conf_get(void)
+{
+       return je_malloc_conf;
+}
+
+void
+je_malloc_conf_set(const char *m)
+{
+       je_malloc_conf = m;
+}
+
 /******************************************************************************/
diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/include/jemalloc/jemalloc.h
--- a/external/bsd/jemalloc/include/jemalloc/jemalloc.h Tue Mar 12 15:11:13 2019 +0000
+++ b/external/bsd/jemalloc/include/jemalloc/jemalloc.h Tue Mar 12 15:13:25 2019 +0000
@@ -64,48 +64,51 @@
 #ifndef JEMALLOC_NO_RENAME
 #  define je_aligned_alloc aligned_alloc
 #  define je_calloc calloc
+#  define je_free free
+#  define je_malloc malloc
+#  define je_posix_memalign posix_memalign
+#  define je_realloc realloc
+#  define je_valloc valloc
+
+# ifndef JEMALLOC_PROTECT_NOSTD
 #  define je_dallocx dallocx
-#  define je_free free
 #  define je_mallctl mallctl
 #  define je_mallctlbymib mallctlbymib
 #  define je_mallctlnametomib mallctlnametomib
-#  define je_malloc malloc
 #  define je_malloc_conf malloc_conf
+#  define je_malloc_conf_get malloc_conf_get
+#  define je_malloc_conf_set malloc_conf_set
 #  define je_malloc_message malloc_message
+#  define je_malloc_message_get malloc_message_get
+#  define je_malloc_message_set malloc_message_set
 #  define je_malloc_stats_print malloc_stats_print
 #  define je_malloc_usable_size malloc_usable_size
 #  define je_mallocx mallocx
 #  define je_nallocx nallocx
-#  define je_posix_memalign posix_memalign
 #  define je_rallocx rallocx
-#  define je_realloc realloc
 #  define je_sallocx sallocx
 #  define je_sdallocx sdallocx
 #  define je_xallocx xallocx
-#  define je_valloc valloc
-#endif
-
-#ifdef JEMALLOC_WEAK_NOSTD
-
-#undef je_mallocx
-#undef je_rallocx
-#undef je_xallocx
-#undef je_sallocx
-#undef je_dallocx
-#undef je_sdallocx
-#undef je_nallocx
-
-#undef je_mallctl
-#undef je_mallctlnametomib
-#undef je_mallctlbymib
-
-#undef je_malloc_stats_print
-#undef je_malloc_usable_size
-
-#undef je_malloc_message
-
-#undef je_malloc_conf
-
+# else
+#  define je_dallocx           __je_dallocx
+#  define je_mallctl           __je_mallctl
+#  define je_mallctlbymib      __je_mallctlbymib
+#  define je_mallctlnametomib  __je_mallctlnametomib
+#  define je_malloc_conf       __je_malloc_conf
+#  define je_malloc_conf_get   __je_malloc_conf_get
+#  define je_malloc_conf_set   __je_malloc_conf_set
+#  define je_malloc_message    __je_malloc_message
+#  define je_malloc_message_get        __je_malloc_message_get
+#  define je_malloc_message_set        __je_malloc_message_set
+#  define je_malloc_stats_print        __je_malloc_stats_print
+#  define je_malloc_usable_size        __je_malloc_usable_size
+#  define je_mallocx           __je_mallocx
+#  define je_nallocx           __je_nallocx
+#  define je_rallocx           __je_rallocx
+#  define je_sallocx           __je_sallocx
+#  define je_sdallocx          __je_sdallocx
+#  define je_xallocx           __je_xallocx
+# endif
 #endif
 
 #include <stdlib.h>
@@ -241,6 +244,12 @@
 extern JEMALLOC_EXPORT const char      *je_malloc_conf;
 extern JEMALLOC_EXPORT void            (*je_malloc_message)(void *cbopaque,
     const char *s);
+extern JEMALLOC_EXPORT const char      *je_malloc_conf_get(void);
+extern JEMALLOC_EXPORT void            je_malloc_conf_set(const char *);
+extern JEMALLOC_EXPORT void            (*je_malloc_message_get(void))
+    (void *cbopaque, const char *s);
+extern JEMALLOC_EXPORT void            je_malloc_message_set(
+    void (*)(void *cbopaque, const char *s));
 
 JEMALLOC_EXPORT JEMALLOC_ALLOCATOR JEMALLOC_RESTRICT_RETURN
     void JEMALLOC_NOTHROW      *je_malloc(size_t size)
diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/lib/Makefile
--- a/external/bsd/jemalloc/lib/Makefile        Tue Mar 12 15:11:13 2019 +0000
+++ b/external/bsd/jemalloc/lib/Makefile        Tue Mar 12 15:13:25 2019 +0000
@@ -1,10 +1,10 @@
-# $NetBSD: Makefile,v 1.2 2019/03/04 19:41:37 christos Exp $
+# $NetBSD: Makefile,v 1.3 2019/03/12 15:13:25 christos Exp $
 
 WARNS?= 5
 .include <bsd.init.mk>
 
 LIB=jemalloc
 
-.include "Makefile.inc"
+SRCS=jemalloc_stub.c
 
 .include <bsd.lib.mk>
diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/lib/Makefile.inc
--- a/external/bsd/jemalloc/lib/Makefile.inc    Tue Mar 12 15:11:13 2019 +0000
+++ b/external/bsd/jemalloc/lib/Makefile.inc    Tue Mar 12 15:13:25 2019 +0000
@@ -1,4 +1,4 @@
-#      $NetBSD: Makefile.inc,v 1.5 2019/03/10 15:32:42 christos Exp $
+#      $NetBSD: Makefile.inc,v 1.6 2019/03/12 15:13:25 christos Exp $
 
 JEMALLOC:=${.PARSEDIR}/..
 
@@ -39,7 +39,7 @@
 .PATH.3: ${JEMALLOC}/dist/doc
 .for i in ${JEMALLOC_SRCS}
 CPPFLAGS.${i}+=-I${JEMALLOC}/include -DJEMALLOC_NO_PRIVATE_NAMESPACE \
-    -DJEMALLOC_WEAK_NOSTD -DJEMALLOC_DEBUG
+    -DJEMALLOC_PROTECT_NOSTD -DJEMALLOC_DEBUG
 COPTS.${i}+= -fvisibility=hidden -funroll-loops 
 .endfor
 
diff -r 61e4d784e5bd -r 8dba25a6d2bc external/bsd/jemalloc/lib/jemalloc_stub.c
--- /dev/null   Thu Jan 01 00:00:00 1970 +0000
+++ b/external/bsd/jemalloc/lib/jemalloc_stub.c Tue Mar 12 15:13:25 2019 +0000
@@ -0,0 +1,141 @@
+/*-
+ * Copyright (c) 2019 The NetBSD Foundation, Inc.
+ * All rights reserved.
+ *
+ * This code is derived from software contributed to The NetBSD Foundation
+ * by Christos Zoulas.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE NETBSD FOUNDATION, INC. AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE FOUNDATION OR CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
+ * POSSIBILITY OF SUCH DAMAGE.
+ */
+#include <malloc.h>
+
+void *__je_mallocx(size_t, int);
+void *
+mallocx(size_t l, int f)
+{
+       return __je_mallocx(l, f);
+}
+
+void *__je_rallocx(void *, size_t, int);
+void *
+rallocx(void *p, size_t l, int f)
+{
+       return __je_rallocx(p, l, f);
+}
+
+size_t __je_xallocx(void *, size_t, size_t, int);
+size_t 
+xallocx(void *p, size_t l, size_t s, int f)
+{
+       return __je_xallocx(p, l, s, f);
+}
+
+size_t __je_sallocx(const void *, int);
+size_t
+sallocx(const void *p, int f)
+{
+       return __je_sallocx(p, f);
+}
+
+void __je_dallocx(void *, int);
+void 
+dallocx(void *p, int f)
+{
+       __je_dallocx(p, f);
+}
+
+void __je_sdallocx(void *, size_t, int);
+void 
+sdallocx(void *p, size_t l, int f)
+{
+       __je_sdallocx(p, l, f);
+}
+
+size_t __je_nallocx(size_t, int);
+size_t
+nallocx(size_t l, int f)



Home | Main Index | Thread Index | Old Index