summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorJason Evans <je@fb.com>2013-12-10 22:23:10 (GMT)
committerJason Evans <je@fb.com>2013-12-10 22:35:34 (GMT)
commit6edc97db15311fdac189798ec24e3eb39dc75d8e (patch)
tree95c147eb16a37b37730cc713c4ced7a41ddb4755
parent736923254409aed1a4a226e0ba7429f573c1f372 (diff)
downloadjemalloc-6edc97db15311fdac189798ec24e3eb39dc75d8e.zip
jemalloc-6edc97db15311fdac189798ec24e3eb39dc75d8e.tar.gz
jemalloc-6edc97db15311fdac189798ec24e3eb39dc75d8e.tar.bz2
Fix inline-related macro issues.
Add JEMALLOC_INLINE_C and use it instead of JEMALLOC_INLINE in .c files, so that the annotated functions are always static. Remove SFMT's inline-related macros and use jemalloc's instead, so that there's no danger of interactions with jemalloc's definitions that disable inlining for debug builds.
-rw-r--r--include/jemalloc/internal/jemalloc_internal_macros.h18
-rw-r--r--src/ckh.c12
-rw-r--r--test/include/test/SFMT-alti.h15
-rw-r--r--test/include/test/SFMT-sse2.h9
-rw-r--r--test/include/test/SFMT.h16
-rw-r--r--test/src/SFMT.c38
6 files changed, 43 insertions, 65 deletions
diff --git a/include/jemalloc/internal/jemalloc_internal_macros.h b/include/jemalloc/internal/jemalloc_internal_macros.h
index 82f827d..70602ee 100644
--- a/include/jemalloc/internal/jemalloc_internal_macros.h
+++ b/include/jemalloc/internal/jemalloc_internal_macros.h
@@ -1,16 +1,18 @@
/*
- * JEMALLOC_ALWAYS_INLINE is used within header files for functions that are
- * static inline functions if inlining is enabled, and single-definition
- * library-private functions if inlining is disabled.
+ * JEMALLOC_ALWAYS_INLINE and JEMALLOC_INLINE are used within header files for
+ * functions that are static inline functions if inlining is enabled, and
+ * single-definition library-private functions if inlining is disabled.
*
- * JEMALLOC_ALWAYS_INLINE_C is for use in .c files, in which case the denoted
- * functions are always static, regardless of whether inlining is enabled.
+ * JEMALLOC_ALWAYS_INLINE_C and JEMALLOC_INLINE_C are for use in .c files, in
+ * which case the denoted functions are always static, regardless of whether
+ * inlining is enabled.
*/
#if defined(JEMALLOC_DEBUG) || defined(JEMALLOC_CODE_COVERAGE)
/* Disable inlining to make debugging/profiling easier. */
# define JEMALLOC_ALWAYS_INLINE
# define JEMALLOC_ALWAYS_INLINE_C static
# define JEMALLOC_INLINE
+# define JEMALLOC_INLINE_C static
# define inline
#else
# define JEMALLOC_ENABLE_INLINE
@@ -24,15 +26,16 @@
# define JEMALLOC_ALWAYS_INLINE_C static inline
# endif
# define JEMALLOC_INLINE static inline
+# define JEMALLOC_INLINE_C static inline
# ifdef _MSC_VER
# define inline _inline
# endif
#endif
#ifdef JEMALLOC_CC_SILENCE
-#define UNUSED JEMALLOC_ATTR(unused)
+# define UNUSED JEMALLOC_ATTR(unused)
#else
-#define UNUSED
+# define UNUSED
#endif
#define ZU(z) ((size_t)z)
@@ -42,4 +45,3 @@
#ifndef __DECONST
# define __DECONST(type, var) ((type)(uintptr_t)(const void *)(var))
#endif
-
diff --git a/src/ckh.c b/src/ckh.c
index 2f38348..04c5296 100644
--- a/src/ckh.c
+++ b/src/ckh.c
@@ -49,7 +49,7 @@ static void ckh_shrink(ckh_t *ckh);
* Search bucket for key and return the cell number if found; SIZE_T_MAX
* otherwise.
*/
-JEMALLOC_INLINE size_t
+JEMALLOC_INLINE_C size_t
ckh_bucket_search(ckh_t *ckh, size_t bucket, const void *key)
{
ckhc_t *cell;
@@ -67,7 +67,7 @@ ckh_bucket_search(ckh_t *ckh, size_t bucket, const void *key)
/*
* Search table for key and return cell number if found; SIZE_T_MAX otherwise.
*/
-JEMALLOC_INLINE size_t
+JEMALLOC_INLINE_C size_t
ckh_isearch(ckh_t *ckh, const void *key)
{
size_t hashes[2], bucket, cell;
@@ -88,7 +88,7 @@ ckh_isearch(ckh_t *ckh, const void *key)
return (cell);
}
-JEMALLOC_INLINE bool
+JEMALLOC_INLINE_C bool
ckh_try_bucket_insert(ckh_t *ckh, size_t bucket, const void *key,
const void *data)
{
@@ -120,7 +120,7 @@ ckh_try_bucket_insert(ckh_t *ckh, size_t bucket, const void *key,
* eviction/relocation procedure until either success or detection of an
* eviction/relocation bucket cycle.
*/
-JEMALLOC_INLINE bool
+JEMALLOC_INLINE_C bool
ckh_evict_reloc_insert(ckh_t *ckh, size_t argbucket, void const **argkey,
void const **argdata)
{
@@ -190,7 +190,7 @@ ckh_evict_reloc_insert(ckh_t *ckh, size_t argbucket, void const **argkey,
}
}
-JEMALLOC_INLINE bool
+JEMALLOC_INLINE_C bool
ckh_try_insert(ckh_t *ckh, void const**argkey, void const**argdata)
{
size_t hashes[2], bucket;
@@ -219,7 +219,7 @@ ckh_try_insert(ckh_t *ckh, void const**argkey, void const**argdata)
* Try to rebuild the hash table from scratch by inserting all items from the
* old table into the new.
*/
-JEMALLOC_INLINE bool
+JEMALLOC_INLINE_C bool
ckh_rebuild(ckh_t *ckh, ckhc_t *aTab)
{
size_t count, i, nins;
diff --git a/test/include/test/SFMT-alti.h b/test/include/test/SFMT-alti.h
index 3942bbc..2f86f67 100644
--- a/test/include/test/SFMT-alti.h
+++ b/test/include/test/SFMT-alti.h
@@ -52,12 +52,6 @@
#ifndef SFMT_ALTI_H
#define SFMT_ALTI_H
-inline static vector unsigned int vec_recursion(vector unsigned int a,
- vector unsigned int b,
- vector unsigned int c,
- vector unsigned int d)
- ALWAYSINLINE;
-
/**
* This function represents the recursion formula in AltiVec and BIG ENDIAN.
* @param a a 128-bit part of the interal state array
@@ -66,7 +60,8 @@ inline static vector unsigned int vec_recursion(vector unsigned int a,
* @param d a 128-bit part of the interal state array
* @return output
*/
-inline static vector unsigned int vec_recursion(vector unsigned int a,
+JEMALLOC_ALWAYS_INLINE
+static vector unsigned int vec_recursion(vector unsigned int a,
vector unsigned int b,
vector unsigned int c,
vector unsigned int d) {
@@ -100,7 +95,7 @@ inline static vector unsigned int vec_recursion(vector unsigned int a,
* This function fills the internal state array with pseudorandom
* integers.
*/
-inline static void gen_rand_all(sfmt_t *ctx) {
+JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
int i;
vector unsigned int r, r1, r2;
@@ -127,7 +122,7 @@ inline static void gen_rand_all(sfmt_t *ctx) {
* @param array an 128-bit array to be filled by pseudorandom numbers.
* @param size number of 128-bit pesudorandom numbers to be generated.
*/
-inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
+JEMALLOC_INLINE void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
int i, j;
vector unsigned int r, r1, r2;
@@ -178,7 +173,7 @@ inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
* @param array an 128-bit array to be swaped.
* @param size size of 128-bit array.
*/
-inline static void swap(w128_t *array, int size) {
+JEMALLOC_INLINE void swap(w128_t *array, int size) {
int i;
const vector unsigned char perm = ALTI_SWAP;
diff --git a/test/include/test/SFMT-sse2.h b/test/include/test/SFMT-sse2.h
index 1913180..0314a16 100644
--- a/test/include/test/SFMT-sse2.h
+++ b/test/include/test/SFMT-sse2.h
@@ -51,9 +51,6 @@
#ifndef SFMT_SSE2_H
#define SFMT_SSE2_H
-PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b, __m128i c,
- __m128i d, __m128i mask) ALWAYSINLINE;
-
/**
* This function represents the recursion formula.
* @param a a 128-bit part of the interal state array
@@ -63,7 +60,7 @@ PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b, __m128i c,
* @param mask 128-bit mask
* @return output
*/
-PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b,
+JEMALLOC_ALWAYS_INLINE __m128i mm_recursion(__m128i *a, __m128i *b,
__m128i c, __m128i d, __m128i mask) {
__m128i v, x, y, z;
@@ -84,7 +81,7 @@ PRE_ALWAYS static __m128i mm_recursion(__m128i *a, __m128i *b,
* This function fills the internal state array with pseudorandom
* integers.
*/
-inline static void gen_rand_all(sfmt_t *ctx) {
+JEMALLOC_INLINE void gen_rand_all(sfmt_t *ctx) {
int i;
__m128i r, r1, r2, mask;
mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
@@ -114,7 +111,7 @@ inline static void gen_rand_all(sfmt_t *ctx) {
* @param array an 128-bit array to be filled by pseudorandom numbers.
* @param size number of 128-bit pesudorandom numbers to be generated.
*/
-inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
+JEMALLOC_INLINE void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
int i, j;
__m128i r, r1, r2, mask;
mask = _mm_set_epi32(MSK4, MSK3, MSK2, MSK1);
diff --git a/test/include/test/SFMT.h b/test/include/test/SFMT.h
index 3dbf942..09c1607 100644
--- a/test/include/test/SFMT.h
+++ b/test/include/test/SFMT.h
@@ -66,22 +66,6 @@
#ifndef SFMT_H
#define SFMT_H
-#if defined(__GNUC__)
-#define ALWAYSINLINE __attribute__((always_inline))
-#else
-#define ALWAYSINLINE
-#endif
-
-#if defined(_MSC_VER)
- #if _MSC_VER >= 1200
- #define PRE_ALWAYS __forceinline
- #else
- #define PRE_ALWAYS inline
- #endif
-#else
- #define PRE_ALWAYS inline
-#endif
-
typedef struct sfmt_s sfmt_t;
uint32_t gen_rand32(sfmt_t *ctx);
diff --git a/test/src/SFMT.c b/test/src/SFMT.c
index bfd763c..9fade28 100644
--- a/test/src/SFMT.c
+++ b/test/src/SFMT.c
@@ -114,18 +114,18 @@ static uint32_t parity[4] = {PARITY1, PARITY2, PARITY3, PARITY4};
/*----------------
STATIC FUNCTIONS
----------------*/
-inline static int idxof(int i);
+JEMALLOC_INLINE_C int idxof(int i);
#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
-inline static void rshift128(w128_t *out, w128_t const *in, int shift);
-inline static void lshift128(w128_t *out, w128_t const *in, int shift);
+JEMALLOC_INLINE_C void rshift128(w128_t *out, w128_t const *in, int shift);
+JEMALLOC_INLINE_C void lshift128(w128_t *out, w128_t const *in, int shift);
#endif
-inline static void gen_rand_all(sfmt_t *ctx);
-inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size);
-inline static uint32_t func1(uint32_t x);
-inline static uint32_t func2(uint32_t x);
+JEMALLOC_INLINE_C void gen_rand_all(sfmt_t *ctx);
+JEMALLOC_INLINE_C void gen_rand_array(sfmt_t *ctx, w128_t *array, int size);
+JEMALLOC_INLINE_C uint32_t func1(uint32_t x);
+JEMALLOC_INLINE_C uint32_t func2(uint32_t x);
static void period_certification(sfmt_t *ctx);
#if defined(BIG_ENDIAN64) && !defined(ONLY64)
-inline static void swap(w128_t *array, int size);
+JEMALLOC_INLINE_C void swap(w128_t *array, int size);
#endif
#if defined(HAVE_ALTIVEC)
@@ -139,11 +139,11 @@ inline static void swap(w128_t *array, int size);
* in BIG ENDIAN machine.
*/
#ifdef ONLY64
-inline static int idxof(int i) {
+JEMALLOC_INLINE_C int idxof(int i) {
return i ^ 1;
}
#else
-inline static int idxof(int i) {
+JEMALLOC_INLINE_C int idxof(int i) {
return i;
}
#endif
@@ -157,7 +157,7 @@ inline static int idxof(int i) {
*/
#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
#ifdef ONLY64
-inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
+JEMALLOC_INLINE_C void rshift128(w128_t *out, w128_t const *in, int shift) {
uint64_t th, tl, oh, ol;
th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
@@ -172,7 +172,7 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
out->u[3] = (uint32_t)oh;
}
#else
-inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
+JEMALLOC_INLINE_C void rshift128(w128_t *out, w128_t const *in, int shift) {
uint64_t th, tl, oh, ol;
th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
@@ -196,7 +196,7 @@ inline static void rshift128(w128_t *out, w128_t const *in, int shift) {
* @param shift the shift value
*/
#ifdef ONLY64
-inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
+JEMALLOC_INLINE_C void lshift128(w128_t *out, w128_t const *in, int shift) {
uint64_t th, tl, oh, ol;
th = ((uint64_t)in->u[2] << 32) | ((uint64_t)in->u[3]);
@@ -211,7 +211,7 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
out->u[3] = (uint32_t)oh;
}
#else
-inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
+JEMALLOC_INLINE_C void lshift128(w128_t *out, w128_t const *in, int shift) {
uint64_t th, tl, oh, ol;
th = ((uint64_t)in->u[3] << 32) | ((uint64_t)in->u[2]);
@@ -238,7 +238,7 @@ inline static void lshift128(w128_t *out, w128_t const *in, int shift) {
*/
#if (!defined(HAVE_ALTIVEC)) && (!defined(HAVE_SSE2))
#ifdef ONLY64
-inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
+JEMALLOC_INLINE_C void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
w128_t *d) {
w128_t x;
w128_t y;
@@ -255,7 +255,7 @@ inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
^ (d->u[3] << SL1);
}
#else
-inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
+JEMALLOC_INLINE_C void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
w128_t *d) {
w128_t x;
w128_t y;
@@ -279,7 +279,7 @@ inline static void do_recursion(w128_t *r, w128_t *a, w128_t *b, w128_t *c,
* This function fills the internal state array with pseudorandom
* integers.
*/
-inline static void gen_rand_all(sfmt_t *ctx) {
+JEMALLOC_INLINE_C void gen_rand_all(sfmt_t *ctx) {
int i;
w128_t *r1, *r2;
@@ -306,7 +306,7 @@ inline static void gen_rand_all(sfmt_t *ctx) {
* @param array an 128-bit array to be filled by pseudorandom numbers.
* @param size number of 128-bit pseudorandom numbers to be generated.
*/
-inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
+JEMALLOC_INLINE_C void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
int i, j;
w128_t *r1, *r2;
@@ -340,7 +340,7 @@ inline static void gen_rand_array(sfmt_t *ctx, w128_t *array, int size) {
#endif
#if defined(BIG_ENDIAN64) && !defined(ONLY64) && !defined(HAVE_ALTIVEC)
-inline static void swap(w128_t *array, int size) {
+JEMALLOC_INLINE_C void swap(w128_t *array, int size) {
int i;
uint32_t x, y;