Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 17 Apr 2012 22:05:55 +0000 (UTC)
From:      Jason Evans <jasone@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r234402 - in head/contrib/jemalloc: . doc include/jemalloc include/jemalloc/internal
Message-ID:  <201204172205.q3HM5to8001499@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jasone
Date: Tue Apr 17 22:05:55 2012
New Revision: 234402
URL: http://svn.freebsd.org/changeset/base/234402

Log:
  Import jemalloc b57d3ec571c6551231be62b7bf92c084a8c8291c (dev branch,
  prior to 3.0.0 release), which supports atomic operations based on atomic(9).
  This should fix build failures for several platforms.

Modified:
  head/contrib/jemalloc/FREEBSD-diffs
  head/contrib/jemalloc/VERSION
  head/contrib/jemalloc/doc/jemalloc.3
  head/contrib/jemalloc/include/jemalloc/internal/atomic.h
  head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
  head/contrib/jemalloc/include/jemalloc/jemalloc.h
  head/contrib/jemalloc/include/jemalloc/jemalloc_defs.h

Modified: head/contrib/jemalloc/FREEBSD-diffs
==============================================================================
--- head/contrib/jemalloc/FREEBSD-diffs	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/FREEBSD-diffs	Tue Apr 17 22:05:55 2012	(r234402)
@@ -45,17 +45,19 @@ index 98d0ba4..23d2152 100644
 +  </refsect1>
  </refentry>
 diff --git a/include/jemalloc/internal/jemalloc_internal.h.in b/include/jemalloc/internal/jemalloc_internal.h.in
-index aa21aa5..e0f5fed 100644
+index 905653a..b235a0d 100644
 --- a/include/jemalloc/internal/jemalloc_internal.h.in
 +++ b/include/jemalloc/internal/jemalloc_internal.h.in
-@@ -1,3 +1,6 @@
+@@ -1,5 +1,8 @@
+ #ifndef JEMALLOC_INTERNAL_H
+ #define JEMALLOC_INTERNAL_H
 +#include "libc_private.h"
 +#include "namespace.h"
 +
  #include <sys/mman.h>
  #include <sys/param.h>
  #include <sys/syscall.h>
-@@ -33,6 +36,9 @@
+@@ -35,6 +38,9 @@
  #include <pthread.h>
  #include <math.h>
  

Modified: head/contrib/jemalloc/VERSION
==============================================================================
--- head/contrib/jemalloc/VERSION	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/VERSION	Tue Apr 17 22:05:55 2012	(r234402)
@@ -1 +1 @@
-1.0.0-258-g9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa
+1.0.0-266-gb57d3ec571c6551231be62b7bf92c084a8c8291c

Modified: head/contrib/jemalloc/doc/jemalloc.3
==============================================================================
--- head/contrib/jemalloc/doc/jemalloc.3	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/doc/jemalloc.3	Tue Apr 17 22:05:55 2012	(r234402)
@@ -2,12 +2,12 @@
 .\"     Title: JEMALLOC
 .\"    Author: Jason Evans
 .\" Generator: DocBook XSL Stylesheets v1.76.1 <http://docbook.sf.net/>;
-.\"      Date: 04/16/2012
+.\"      Date: 04/17/2012
 .\"    Manual: User Manual
-.\"    Source: jemalloc 1.0.0-258-g9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa
+.\"    Source: jemalloc 1.0.0-266-gb57d3ec571c6551231be62b7bf92c084a8c8291c
 .\"  Language: English
 .\"
-.TH "JEMALLOC" "3" "04/16/2012" "jemalloc 1.0.0-258-g9ef7f5dc34" "User Manual"
+.TH "JEMALLOC" "3" "04/17/2012" "jemalloc 1.0.0-266-gb57d3ec571" "User Manual"
 .\" -----------------------------------------------------------------
 .\" * Define some portability stuff
 .\" -----------------------------------------------------------------
@@ -31,7 +31,7 @@
 jemalloc \- general purpose memory allocation functions
 .SH "LIBRARY"
 .PP
-This manual describes jemalloc 1\&.0\&.0\-258\-g9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa\&. More information can be found at the
+This manual describes jemalloc 1\&.0\&.0\-266\-gb57d3ec571c6551231be62b7bf92c084a8c8291c\&. More information can be found at the
 \m[blue]\fBjemalloc website\fR\m[]\&\s-2\u[1]\d\s+2\&.
 .PP
 The following configuration options are enabled in libc\*(Aqs built\-in jemalloc:

Modified: head/contrib/jemalloc/include/jemalloc/internal/atomic.h
==============================================================================
--- head/contrib/jemalloc/include/jemalloc/internal/atomic.h	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/include/jemalloc/internal/atomic.h	Tue Apr 17 22:05:55 2012	(r234402)
@@ -32,7 +32,8 @@ unsigned	atomic_sub_u(unsigned *p, unsig
 #if (defined(JEMALLOC_ENABLE_INLINE) || defined(JEMALLOC_ATOMIC_C_))
 /******************************************************************************/
 /* 64-bit operations. */
-#ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
+#if (LG_SIZEOF_PTR == 3 || LG_SIZEOF_INT == 3)
+#  ifdef __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8
 JEMALLOC_INLINE uint64_t
 atomic_add_uint64(uint64_t *p, uint64_t x)
 {
@@ -60,7 +61,7 @@ atomic_sub_uint64(uint64_t *p, uint64_t 
 
 	return (OSAtomicAdd64(-((int64_t)x), (int64_t *)p));
 }
-#elif (defined(__amd64__) || defined(__x86_64__))
+#  elif (defined(__amd64__) || defined(__x86_64__))
 JEMALLOC_INLINE uint64_t
 atomic_add_uint64(uint64_t *p, uint64_t x)
 {
@@ -87,7 +88,29 @@ atomic_sub_uint64(uint64_t *p, uint64_t 
 
 	return (x);
 }
-#elif (defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_8))
+#  elif (defined(JEMALLOC_ATOMIC9))
+JEMALLOC_INLINE uint64_t
+atomic_add_uint64(uint64_t *p, uint64_t x)
+{
+
+	/*
+	 * atomic_fetchadd_64() doesn't exist, but we only ever use this
+	 * function on LP64 systems, so atomic_fetchadd_long() will do.
+	 */
+	assert(sizeof(uint64_t) == sizeof(unsigned long));
+
+	return (atomic_fetchadd_long(p, (unsigned long)x) + x);
+}
+
+JEMALLOC_INLINE uint64_t
+atomic_sub_uint64(uint64_t *p, uint64_t x)
+{
+
+	assert(sizeof(uint64_t) == sizeof(unsigned long));
+
+	return (atomic_fetchadd_long(p, (unsigned long)(-(long)x)) - x);
+}
+#  elif (defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_8))
 JEMALLOC_INLINE uint64_t
 atomic_add_uint64(uint64_t *p, uint64_t x)
 {
@@ -101,8 +124,7 @@ atomic_sub_uint64(uint64_t *p, uint64_t 
 
 	return (__sync_sub_and_fetch(p, x));
 }
-#else
-#  if (LG_SIZEOF_PTR == 3)
+#  else
 #    error "Missing implementation for 64-bit atomic operations"
 #  endif
 #endif
@@ -164,6 +186,20 @@ atomic_sub_uint32(uint32_t *p, uint32_t 
 
 	return (x);
 }
+#elif (defined(JEMALLOC_ATOMIC9))
+JEMALLOC_INLINE uint32_t
+atomic_add_uint32(uint32_t *p, uint32_t x)
+{
+
+	return (atomic_fetchadd_32(p, x) + x);
+}
+
+JEMALLOC_INLINE uint32_t
+atomic_sub_uint32(uint32_t *p, uint32_t x)
+{
+
+	return (atomic_fetchadd_32(p, (uint32_t)(-(int32_t)x)) - x);
+}
 #elif (defined(JE_FORCE_SYNC_COMPARE_AND_SWAP_4))
 JEMALLOC_INLINE uint32_t
 atomic_add_uint32(uint32_t *p, uint32_t x)

Modified: head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h
==============================================================================
--- head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/include/jemalloc/internal/jemalloc_internal.h	Tue Apr 17 22:05:55 2012	(r234402)
@@ -1,3 +1,5 @@
+#ifndef JEMALLOC_INTERNAL_H
+#define JEMALLOC_INTERNAL_H
 #include "libc_private.h"
 #include "namespace.h"
 
@@ -165,6 +167,10 @@ static const bool config_ivsalloc =
 #endif
     ;
 
+#ifdef JEMALLOC_ATOMIC9
+#include <machine/atomic.h>
+#endif
+
 #if (defined(JEMALLOC_OSATOMIC) || defined(JEMALLOC_OSSPIN))
 #include <libkern/OSAtomic.h>
 #endif
@@ -874,3 +880,4 @@ malloc_tsd_funcs(JEMALLOC_INLINE, thread
 
 #undef JEMALLOC_H_INLINES
 /******************************************************************************/
+#endif /* JEMALLOC_INTERNAL_H */

Modified: head/contrib/jemalloc/include/jemalloc/jemalloc.h
==============================================================================
--- head/contrib/jemalloc/include/jemalloc/jemalloc.h	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/include/jemalloc/jemalloc.h	Tue Apr 17 22:05:55 2012	(r234402)
@@ -7,12 +7,12 @@ extern "C" {
 #include <limits.h>
 #include <strings.h>
 
-#define	JEMALLOC_VERSION "1.0.0-258-g9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa"
+#define	JEMALLOC_VERSION "1.0.0-266-gb57d3ec571c6551231be62b7bf92c084a8c8291c"
 #define	JEMALLOC_VERSION_MAJOR 1
 #define	JEMALLOC_VERSION_MINOR 0
 #define	JEMALLOC_VERSION_BUGFIX 0
-#define	JEMALLOC_VERSION_NREV 258
-#define	JEMALLOC_VERSION_GID "9ef7f5dc34ff02f50d401e41c8d9a4a928e7c2aa"
+#define	JEMALLOC_VERSION_NREV 266
+#define	JEMALLOC_VERSION_GID "b57d3ec571c6551231be62b7bf92c084a8c8291c"
 
 #include "jemalloc_defs.h"
 #include "jemalloc_FreeBSD.h"

Modified: head/contrib/jemalloc/include/jemalloc/jemalloc_defs.h
==============================================================================
--- head/contrib/jemalloc/include/jemalloc/jemalloc_defs.h	Tue Apr 17 21:55:35 2012	(r234401)
+++ head/contrib/jemalloc/include/jemalloc/jemalloc_defs.h	Tue Apr 17 22:05:55 2012	(r234402)
@@ -48,6 +48,9 @@
  */
 #define CPU_SPINWAIT __asm__ volatile("pause")
 
+/* Defined if the equivalent of FreeBSD's atomic(9) functions are available. */
+#define JEMALLOC_ATOMIC9 1
+
 /*
  * Defined if OSAtomic*() functions are available, as provided by Darwin, and
  * documented in the atomic(3) manual page.
@@ -60,7 +63,7 @@
  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_4 not being defined (which means the
  * functions are defined in libgcc instead of being inlines)
  */
-#define JE_FORCE_SYNC_COMPARE_AND_SWAP_4 
+/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_4 */
 
 /*
  * Defined if __sync_add_and_fetch(uint64_t *, uint64_t) and
@@ -68,7 +71,7 @@
  * __GCC_HAVE_SYNC_COMPARE_AND_SWAP_8 not being defined (which means the
  * functions are defined in libgcc instead of being inlines)
  */
-#define JE_FORCE_SYNC_COMPARE_AND_SWAP_8 
+/* #undef JE_FORCE_SYNC_COMPARE_AND_SWAP_8 */
 
 /*
  * Defined if OSSpin*() functions are available, as provided by Darwin, and



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201204172205.q3HM5to8001499>