summaryrefslogtreecommitdiffstats
path: root/jemalloc/src
diff options
context:
space:
mode:
authorJason Evans <jasone@canonware.com>2010-01-03 19:59:20 (GMT)
committerJason Evans <jasone@canonware.com>2010-01-03 19:59:20 (GMT)
commit9ad48230ed38ee606ceb2212ebccd9411cafb29c (patch)
treeb2c5f530dea6b2468d4e4c7d615a8acaac1722f9 /jemalloc/src
parentbf10ae64a79da39b6ff5a23337ead4ddf393364a (diff)
downloadjemalloc-9ad48230ed38ee606ceb2212ebccd9411cafb29c.zip
jemalloc-9ad48230ed38ee606ceb2212ebccd9411cafb29c.tar.gz
jemalloc-9ad48230ed38ee606ceb2212ebccd9411cafb29c.tar.bz2
Simplify JEMALLOC_ATTR_* macros to become JEMALLOC_ATTR().
Use JEMALLOC_ATTR(tls_model("initial-exec)) instead of -ftls-model=initial-exec so that libjemalloc_pic.a can be directly linked into another library without needing linker options changes. Add attributes to malloc, calloc, and posix_memalign, for compatibility with glibc's declarations. Add function prototypes for the standard malloc(3) API.
Diffstat (limited to 'jemalloc/src')
-rw-r--r--jemalloc/src/jemalloc.c35
-rw-r--r--jemalloc/src/jemalloc.h8
-rw-r--r--jemalloc/src/jemalloc_defs.h.in13
-rw-r--r--jemalloc/src/mtrgraph.c6
-rw-r--r--jemalloc/src/mtrplay.c4
5 files changed, 41 insertions, 25 deletions
diff --git a/jemalloc/src/jemalloc.c b/jemalloc/src/jemalloc.c
index 41a95d7..e53d9de 100644
--- a/jemalloc/src/jemalloc.c
+++ b/jemalloc/src/jemalloc.c
@@ -739,7 +739,8 @@ static unsigned ncpus;
static malloc_mutex_t trace_mtx;
static unsigned trace_next_tid = 1;
-static unsigned __thread trace_tid;
+static unsigned __thread trace_tid
+ JEMALLOC_ATTR(tls_model("initial-exec"));
/* Used to cause trace_cleanup() to be called. */
static pthread_key_t trace_tsd;
#endif
@@ -1008,12 +1009,14 @@ static malloc_mutex_t arenas_lock; /* Protects arenas initialization. */
* Map of pthread_self() --> arenas[???], used for selecting an arena to use
* for allocations.
*/
-static __thread arena_t *arenas_map;
+static __thread arena_t *arenas_map
+ JEMALLOC_ATTR(tls_model("initial-exec"));
#endif
#ifdef JEMALLOC_TCACHE
/* Map of thread-specific caches. */
-static __thread tcache_t *tcache_tls;
+static __thread tcache_t *tcache_tls
+ JEMALLOC_ATTR(tls_model("initial-exec"));
/*
* Same contents as tcache, but initialized such that the TSD destructor is
@@ -1041,8 +1044,11 @@ static
#ifndef NO_TLS
__thread
#endif
- bool mmap_unaligned;
-
+ bool mmap_unaligned
+#ifndef NO_TLS
+ JEMALLOC_ATTR(tls_model("initial-exec"))
+#endif
+ ;
#ifdef JEMALLOC_STATS
/* Chunk statistics. */
static chunk_stats_t stats_chunks;
@@ -1749,8 +1755,8 @@ extent_szad_comp(extent_node_t *a, extent_node_t *b)
}
/* Wrap red-black tree macros in functions. */
-rb_wrap(static JEMALLOC_UNUSED, extent_tree_szad_, extent_tree_t, extent_node_t,
- link_szad, extent_szad_comp)
+rb_wrap(static JEMALLOC_ATTR(unused), extent_tree_szad_, extent_tree_t,
+ extent_node_t, link_szad, extent_szad_comp)
#endif
static inline int
@@ -1763,8 +1769,8 @@ extent_ad_comp(extent_node_t *a, extent_node_t *b)
}
/* Wrap red-black tree macros in functions. */
-rb_wrap(static JEMALLOC_UNUSED, extent_tree_ad_, extent_tree_t, extent_node_t,
- link_ad, extent_ad_comp)
+rb_wrap(static JEMALLOC_ATTR(unused), extent_tree_ad_, extent_tree_t,
+ extent_node_t, link_ad, extent_ad_comp)
/*
* End extent tree code.
@@ -2322,8 +2328,8 @@ arena_chunk_comp(arena_chunk_t *a, arena_chunk_t *b)
}
/* Wrap red-black tree macros in functions. */
-rb_wrap(static JEMALLOC_UNUSED, arena_chunk_tree_dirty_, arena_chunk_tree_t,
- arena_chunk_t, link_dirty, arena_chunk_comp)
+rb_wrap(static JEMALLOC_ATTR(unused), arena_chunk_tree_dirty_,
+ arena_chunk_tree_t, arena_chunk_t, link_dirty, arena_chunk_comp)
static inline int
arena_run_comp(arena_chunk_map_t *a, arena_chunk_map_t *b)
@@ -2338,7 +2344,7 @@ arena_run_comp(arena_chunk_map_t *a, arena_chunk_map_t *b)
}
/* Wrap red-black tree macros in functions. */
-rb_wrap(static JEMALLOC_UNUSED, arena_run_tree_, arena_run_tree_t,
+rb_wrap(static JEMALLOC_ATTR(unused), arena_run_tree_, arena_run_tree_t,
arena_chunk_map_t, link, arena_run_comp)
static inline int
@@ -2370,7 +2376,7 @@ arena_avail_comp(arena_chunk_map_t *a, arena_chunk_map_t *b)
}
/* Wrap red-black tree macros in functions. */
-rb_wrap(static JEMALLOC_UNUSED, arena_avail_tree_, arena_avail_tree_t,
+rb_wrap(static JEMALLOC_ATTR(unused), arena_avail_tree_, arena_avail_tree_t,
arena_chunk_map_t, link, arena_avail_comp)
static inline void
@@ -6086,6 +6092,7 @@ MALLOC_OUT:
* Begin malloc(3)-compatible functions.
*/
+JEMALLOC_ATTR(malloc)
void *
malloc(size_t size)
{
@@ -6142,6 +6149,7 @@ RETURN:
return (ret);
}
+JEMALLOC_ATTR(nonnull(1))
int
posix_memalign(void **memptr, size_t alignment, size_t size)
{
@@ -6217,6 +6225,7 @@ RETURN:
return (ret);
}
+JEMALLOC_ATTR(malloc)
void *
calloc(size_t num, size_t size)
{
diff --git a/jemalloc/src/jemalloc.h b/jemalloc/src/jemalloc.h
index 94bb752..c7f556b 100644
--- a/jemalloc/src/jemalloc.h
+++ b/jemalloc/src/jemalloc.h
@@ -6,8 +6,14 @@ extern "C" {
#include "jemalloc_defs.h"
-size_t malloc_usable_size(const void *ptr);
+void *malloc(size_t size) JEMALLOC_ATTR(malloc);
+void *calloc(size_t num, size_t size) JEMALLOC_ATTR(malloc);
+int posix_memalign(void **memptr, size_t alignment, size_t size)
+ JEMALLOC_ATTR(nonnull(1));
+void *realloc(void *ptr, size_t size);
+void free(void *ptr);
+size_t malloc_usable_size(const void *ptr);
#ifdef JEMALLOC_TCACHE
void malloc_tcache_flush(void);
#endif
diff --git a/jemalloc/src/jemalloc_defs.h.in b/jemalloc/src/jemalloc_defs.h.in
index e785826..ef663fc 100644
--- a/jemalloc/src/jemalloc_defs.h.in
+++ b/jemalloc/src/jemalloc_defs.h.in
@@ -36,12 +36,13 @@
*/
#undef CPU_SPINWAIT
-/*
- * Attribute with which to mark potentially unused functions. For gcc this is:
- *
- * __attribute__((unused))
- */
-#undef JEMALLOC_UNUSED
+/* Defined if __attribute__((...)) syntax is supported. */
+#undef JEMALLOC_HAVE_ATTR
+#ifdef JEMALLOC_HAVE_ATTR
+# define JEMALLOC_ATTR(s) __attribute__((s))
+#else
+# define JEMALLOC_ATTR(s)
+#endif
/*
* JEMALLOC_DEBUG enables assertions and other sanity checks, and disables
diff --git a/jemalloc/src/mtrgraph.c b/jemalloc/src/mtrgraph.c
index 04e6631..cc17be2 100644
--- a/jemalloc/src/mtrgraph.c
+++ b/jemalloc/src/mtrgraph.c
@@ -65,7 +65,7 @@ cacheComp(AllocationCacheRecord *a, AllocationCacheRecord *b)
}
}
-rb_wrap(static JEMALLOC_UNUSED, cache_tree_, AllocationCache,
+rb_wrap(static JEMALLOC_ATTR(unused), cache_tree_, AllocationCache,
AllocationCacheRecord, link, cacheComp)
// Parse utrace records. Following are prototypical examples of each type of
@@ -324,7 +324,7 @@ genOutput(FILE *outfile, const char *fileType, bool legend,
fprintf(stderr,
"mtrgraph: Trace record %"PRIu64
" realloc()s unknown object 0x%"PRIx64"\n",
- i, trace->trace[i].oldAddr);
+ i, (uint64_t)trace->trace[i].oldAddr);
rVal = true;
goto RETURN;
}
@@ -429,7 +429,7 @@ genOutput(FILE *outfile, const char *fileType, bool legend,
fprintf(stderr,
"mtrgraph: Trace record %"PRIu64
" free()s unknown object 0x%"PRIx64"\n",
- i, trace->trace[i].oldAddr);
+ i, (uint64_t)trace->trace[i].oldAddr);
rVal = true;
goto RETURN;
}
diff --git a/jemalloc/src/mtrplay.c b/jemalloc/src/mtrplay.c
index 2ed2a6c..776ca26 100644
--- a/jemalloc/src/mtrplay.c
+++ b/jemalloc/src/mtrplay.c
@@ -43,8 +43,8 @@ record_comp(record_t *a, record_t *b)
return (1);
}
-rb_wrap(static JEMALLOC_UNUSED, record_tree_, record_tree_t, record_t, link,
- record_comp)
+rb_wrap(static JEMALLOC_ATTR(unused), record_tree_, record_tree_t, record_t,
+ link, record_comp)
static record_t *rec_stack = NULL;