]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/jemalloc/FREEBSD-diffs
Add flex 2.5.37 from flex.sourceforge.net to contrib.
[FreeBSD/FreeBSD.git] / contrib / jemalloc / FREEBSD-diffs
1 diff --git a/doc/jemalloc.xml.in b/doc/jemalloc.xml.in
2 index 0930580..d45fa3d 100644
3 --- a/doc/jemalloc.xml.in
4 +++ b/doc/jemalloc.xml.in
5 @@ -51,12 +51,23 @@
6      <para>This manual describes jemalloc @jemalloc_version@.  More information
7      can be found at the <ulink
8      url="http://www.canonware.com/jemalloc/">jemalloc website</ulink>.</para>
9 +
10 +    <para>The following configuration options are enabled in libc's built-in
11 +    jemalloc: <option>--enable-dss</option>,
12 +    <option>--enable-experimental</option>, <option>--enable-fill</option>,
13 +    <option>--enable-lazy-lock</option>, <option>--enable-munmap</option>,
14 +    <option>--enable-stats</option>, <option>--enable-tcache</option>,
15 +    <option>--enable-tls</option>, <option>--enable-utrace</option>, and
16 +    <option>--enable-xmalloc</option>.  Additionally,
17 +    <option>--enable-debug</option> is enabled in development versions of
18 +    FreeBSD (controlled by the <constant>MALLOC_PRODUCTION</constant> make
19 +    variable).</para>
20    </refsect1>
21    <refsynopsisdiv>
22      <title>SYNOPSIS</title>
23      <funcsynopsis>
24        <funcsynopsisinfo>#include &lt;<filename class="headerfile">stdlib.h</filename>&gt;
25 -#include &lt;<filename class="headerfile">jemalloc/jemalloc.h</filename>&gt;</funcsynopsisinfo>
26 +#include &lt;<filename class="headerfile">malloc_np.h</filename>&gt;</funcsynopsisinfo>
27        <refsect2>
28          <title>Standard API</title>
29          <funcprototype>
30 @@ -2173,4 +2184,16 @@ malloc_conf = "lg_chunk:24";]]></programlisting></para>
31      <para>The <function>posix_memalign<parameter/></function> function conforms
32      to IEEE Std 1003.1-2001 (&ldquo;POSIX.1&rdquo;).</para>
33    </refsect1>
34 +  <refsect1 id="history">
35 +    <title>HISTORY</title>
36 +    <para>The <function>malloc_usable_size<parameter/></function> and
37 +    <function>posix_memalign<parameter/></function> functions first appeared in
38 +    FreeBSD 7.0.</para>
39 +
40 +    <para>The <function>aligned_alloc<parameter/></function>,
41 +    <function>malloc_stats_print<parameter/></function>,
42 +    <function>mallctl*<parameter/></function>, and
43 +    <function>*allocm<parameter/></function> functions first appeared in
44 +    FreeBSD 10.0.</para>
45 +  </refsect1>
46  </refentry>
47 diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
48 index c606c12..0d46d9d 100644
49 --- a/include/jemalloc/internal/jemalloc_internal.h.in
50 +++ b/include/jemalloc/internal/jemalloc_internal.h.in
51 @@ -1,5 +1,8 @@
52  #ifndef JEMALLOC_INTERNAL_H
53  #define JEMALLOC_INTERNAL_H
54 +#include "libc_private.h"
55 +#include "namespace.h"
56 +
57  #include <math.h>
58  #ifdef _WIN32
59  #  include <windows.h>
60 @@ -54,6 +57,9 @@ typedef intptr_t ssize_t;
61  #endif
62  #include <fcntl.h>
63  
64 +#include "un-namespace.h"
65 +#include "libc_private.h"
66 +
67  #define        JEMALLOC_NO_DEMANGLE
68  #include "../jemalloc@install_suffix@.h"
69  
70 @@ -95,13 +101,7 @@ static const bool config_fill =
71      false
72  #endif
73      ;
74 -static const bool config_lazy_lock =
75 -#ifdef JEMALLOC_LAZY_LOCK
76 -    true
77 -#else
78 -    false
79 -#endif
80 -    ;
81 +static const bool config_lazy_lock = true;
82  static const bool config_prof =
83  #ifdef JEMALLOC_PROF
84      true
85 diff --git a/include/jemalloc/internal/mutex.h b/include/jemalloc/internal/mutex.h
86 index de44e14..564d604 100644
87 --- a/include/jemalloc/internal/mutex.h
88 +++ b/include/jemalloc/internal/mutex.h
89 @@ -43,9 +43,6 @@ struct malloc_mutex_s {
90  
91  #ifdef JEMALLOC_LAZY_LOCK
92  extern bool isthreaded;
93 -#else
94 -#  undef isthreaded /* Undo private_namespace.h definition. */
95 -#  define isthreaded true
96  #endif
97  
98  bool   malloc_mutex_init(malloc_mutex_t *mutex);
99 diff --git a/include/jemalloc/internal/private_namespace.h b/include/jemalloc/internal/private_namespace.h
100 index 903fb4d..d6638df 100644
101 --- a/include/jemalloc/internal/private_namespace.h
102 +++ b/include/jemalloc/internal/private_namespace.h
103 @@ -216,7 +216,6 @@
104  #define        iralloc JEMALLOC_N(iralloc)
105  #define        irallocx JEMALLOC_N(irallocx)
106  #define        isalloc JEMALLOC_N(isalloc)
107 -#define        isthreaded JEMALLOC_N(isthreaded)
108  #define        ivsalloc JEMALLOC_N(ivsalloc)
109  #define        jemalloc_postfork_child JEMALLOC_N(jemalloc_postfork_child)
110  #define        jemalloc_postfork_parent JEMALLOC_N(jemalloc_postfork_parent)
111 diff --git a/include/jemalloc/jemalloc.h.in b/include/jemalloc/jemalloc.h.in
112 index 31b1304..c3ef2f5 100644
113 --- a/include/jemalloc/jemalloc.h.in
114 +++ b/include/jemalloc/jemalloc.h.in
115 @@ -15,6 +15,7 @@ extern "C" {
116  #define        JEMALLOC_VERSION_GID "@jemalloc_version_gid@"
117  
118  #include "jemalloc_defs@install_suffix@.h"
119 +#include "jemalloc_FreeBSD.h"
120  
121  #ifdef JEMALLOC_EXPERIMENTAL
122  #define        ALLOCM_LG_ALIGN(la)     (la)
123 diff --git a/include/jemalloc/jemalloc_FreeBSD.h b/include/jemalloc/jemalloc_FreeBSD.h
124 new file mode 100644
125 index 0000000..9c97a13
126 --- /dev/null
127 +++ b/include/jemalloc/jemalloc_FreeBSD.h
128 @@ -0,0 +1,76 @@
129 +/*
130 + * Override settings that were generated in jemalloc_defs.h as necessary.
131 + */
132 +
133 +#undef JEMALLOC_OVERRIDE_VALLOC
134 +
135 +#ifndef MALLOC_PRODUCTION
136 +#define        JEMALLOC_DEBUG
137 +#endif
138 +
139 +/*
140 + * The following are architecture-dependent, so conditionally define them for
141 + * each supported architecture.
142 + */
143 +#undef CPU_SPINWAIT
144 +#undef JEMALLOC_TLS_MODEL
145 +#undef STATIC_PAGE_SHIFT
146 +#undef LG_SIZEOF_PTR
147 +#undef LG_SIZEOF_INT
148 +#undef LG_SIZEOF_LONG
149 +#undef LG_SIZEOF_INTMAX_T
150 +
151 +#ifdef __i386__
152 +#  define LG_SIZEOF_PTR                2
153 +#  define CPU_SPINWAIT         __asm__ volatile("pause")
154 +#  define JEMALLOC_TLS_MODEL   __attribute__((tls_model("initial-exec")))
155 +#endif
156 +#ifdef __ia64__
157 +#  define LG_SIZEOF_PTR                3
158 +#endif
159 +#ifdef __sparc64__
160 +#  define LG_SIZEOF_PTR                3
161 +#  define JEMALLOC_TLS_MODEL   __attribute__((tls_model("initial-exec")))
162 +#endif
163 +#ifdef __amd64__
164 +#  define LG_SIZEOF_PTR                3
165 +#  define CPU_SPINWAIT         __asm__ volatile("pause")
166 +#  define JEMALLOC_TLS_MODEL   __attribute__((tls_model("initial-exec")))
167 +#endif
168 +#ifdef __arm__
169 +#  define LG_SIZEOF_PTR                2
170 +#endif
171 +#ifdef __mips__
172 +#ifdef __mips_n64
173 +#  define LG_SIZEOF_PTR                3
174 +#else
175 +#  define LG_SIZEOF_PTR                2
176 +#endif
177 +#endif
178 +#ifdef __powerpc64__
179 +#  define LG_SIZEOF_PTR                3
180 +#elif defined(__powerpc__)
181 +#  define LG_SIZEOF_PTR                2
182 +#endif
183 +
184 +#ifndef JEMALLOC_TLS_MODEL
185 +#  define JEMALLOC_TLS_MODEL   /* Default. */
186 +#endif
187 +
188 +#define        STATIC_PAGE_SHIFT       PAGE_SHIFT
189 +#define        LG_SIZEOF_INT           2
190 +#define        LG_SIZEOF_LONG          LG_SIZEOF_PTR
191 +#define        LG_SIZEOF_INTMAX_T      3
192 +
193 +/* Disable lazy-lock machinery, mangle isthreaded, and adjust its type. */
194 +#undef JEMALLOC_LAZY_LOCK
195 +extern int __isthreaded;
196 +#define        isthreaded              ((bool)__isthreaded)
197 +
198 +/* Mangle. */
199 +#define        open                    _open
200 +#define        read                    _read
201 +#define        write                   _write
202 +#define        close                   _close
203 +#define        pthread_mutex_lock      _pthread_mutex_lock
204 +#define        pthread_mutex_unlock    _pthread_mutex_unlock
205 diff --git a/src/jemalloc.c b/src/jemalloc.c
206 index c117685..665d98f 100644
207 --- a/src/jemalloc.c
208 +++ b/src/jemalloc.c
209 @@ -8,6 +8,10 @@ malloc_tsd_data(, arenas, arena_t *, NULL)
210  malloc_tsd_data(, thread_allocated, thread_allocated_t,
211      THREAD_ALLOCATED_INITIALIZER)
212  
213 +/* Work around <http://llvm.org/bugs/show_bug.cgi?id=12623>: */
214 +const char     *__malloc_options_1_0 = NULL;
215 +__sym_compat(_malloc_options, __malloc_options_1_0, FBSD_1.0);
216 +
217  /* Runtime configuration options. */
218  const char     *je_malloc_conf;
219  bool   opt_abort =
220 @@ -453,7 +457,8 @@ malloc_conf_init(void)
221  #endif
222                             ;
223  
224 -                       if ((opts = getenv(envname)) != NULL) {
225 +                       if (issetugid() == 0 && (opts = getenv(envname)) !=
226 +                           NULL) {
227                                 /*
228                                  * Do nothing; opts is already initialized to
229                                  * the value of the MALLOC_CONF environment
230 diff --git a/src/mutex.c b/src/mutex.c
231 index 55e18c2..6b6f438 100644
232 --- a/src/mutex.c
233 +++ b/src/mutex.c
234 @@ -66,6 +66,17 @@ pthread_create(pthread_t *__restrict thread,
235  #ifdef JEMALLOC_MUTEX_INIT_CB
236  JEMALLOC_EXPORT int    _pthread_mutex_init_calloc_cb(pthread_mutex_t *mutex,
237      void *(calloc_cb)(size_t, size_t));
238 +
239 +__weak_reference(_pthread_mutex_init_calloc_cb_stub,
240 +    _pthread_mutex_init_calloc_cb);
241 +
242 +int
243 +_pthread_mutex_init_calloc_cb_stub(pthread_mutex_t *mutex,
244 +    void *(calloc_cb)(size_t, size_t))
245 +{
246 +
247 +       return (0);
248 +}
249  #endif
250  
251  bool
252 diff --git a/src/util.c b/src/util.c
253 index b3a0114..df1c5d5 100644
254 --- a/src/util.c
255 +++ b/src/util.c
256 @@ -58,6 +58,22 @@ wrtmessage(void *cbopaque, const char *s)
257  
258  JEMALLOC_EXPORT void   (*je_malloc_message)(void *, const char *s);
259  
260 +JEMALLOC_ATTR(visibility("hidden"))
261 +void
262 +wrtmessage_1_0(const char *s1, const char *s2, const char *s3,
263 +    const char *s4)
264 +{
265 +
266 +       wrtmessage(NULL, s1);
267 +       wrtmessage(NULL, s2);
268 +       wrtmessage(NULL, s3);
269 +       wrtmessage(NULL, s4);
270 +}
271 +
272 +void   (*__malloc_message_1_0)(const char *s1, const char *s2, const char *s3,
273 +    const char *s4) = wrtmessage_1_0;
274 +__sym_compat(_malloc_message, __malloc_message_1_0, FBSD_1.0);
275 +
276  /*
277   * Wrapper around malloc_message() that avoids the need for
278   * je_malloc_message(...) throughout the code.