Skip to content

Commit

Permalink
Added support for clang, plus fixed up some compile errors in C++11.
Browse files Browse the repository at this point in the history
  • Loading branch information
Niall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) committed Nov 17, 2012
1 parent 2835d88 commit 06f1c70
Show file tree
Hide file tree
Showing 5 changed files with 309 additions and 268 deletions.
10 changes: 8 additions & 2 deletions Readme.html
Original file line number Diff line number Diff line change
Expand Up @@ -61,6 +61,8 @@ <h2 style="text-decoration: none;">by Niall Douglas</h2>
<li>The ability to patch Windows binaries to replace the C memory allocation
API malloc, realloc(), free() et al such that by simply inserting nedmalloc.dll
into a process one realises performance improvements without recompilation.</li>
<li>On POSIX, it knows how to talk to valgrind so you can track memory
corruption and/or memory leaks.</li>
<li>A unique user mode page allocator implementation which delivers O(1) scaling
for blocks of any size, including an O(1) very fast realloc(). Improves medium
sized block (~1Mb) allocation speeds by about 25 times on current hardware.
Expand Down Expand Up @@ -444,17 +446,21 @@ <h2><a name="troubleshooting">D. Troubleshooting:</a></h2>
<h2><a name="changelog">E. ChangeLog:</a></h2>
<h3>v1.10 beta 4 ?:</h3>
<ul>
<li><span class="gitcommit">[master xxxxxxx]</span> Merged dlmalloc v2.8.6.</li>
<li><span class="gitcommit">[master 726d9c7]</span> Fixed memory corruption
introduced when creating more than two nedpool's (issue #7). Thanks to mxmauro
for reporting this.</li>
<li><span class="gitcommit">[master c191ea9]</span> Merged dlmalloc v2.8.6.</li>
<li><span class="gitcommit">[master xxxxxxx]</span> Added support for clang,
plus fixed up some compile errors in C++11.</li>
<li><span class="gitcommit">[master xxxxxxx]</span> Added support for
valgrind instrumentation so valgrind can track programs using nedmalloc.</li>
</ul>
<h3>v1.10 beta 3 17th July 2012:</h3>
<ul>
<li><span class="gitcommit">[master 5f26c1a]</span> Due to a bug introduced
in sha 7a9dd5c (17th April 2010), nedmalloc has never allocated more than a
single mspace when using the system pool. This effectively had disabled
concurrency for any allocation > THREADCACHEMAX (8Kb) which no doubt made
concurrency for any allocation &gt; THREADCACHEMAX (8Kb) which no doubt made
nedmalloc v1.10 betas 1 and 2 appear no faster than system allocators. My
thanks to the eagle eyes of Gavin Lambert for spotting this.</li>
</ul>
Expand Down
6 changes: 6 additions & 0 deletions SConscript
Original file line number Diff line number Diff line change
Expand Up @@ -129,4 +129,10 @@ objects = env.Object(source = sources) # + [nedmallocliblib]
scalingtest = env.Program("scalingtest", source = objects, LINKFLAGS=env['LINKFLAGSEXE'])
outputs['scalingtest']=(scalingtest, sources)

# issue 8
sources = [ "issue8.cpp" ]
objects = env.Object(source = sources) # + [nedmallocliblib]
issue8 = env.Program("issue8", source = objects, LINKFLAGS=env['LINKFLAGSEXE'])
outputs['issue8']=(issue8, sources)

Return("outputs")
29 changes: 27 additions & 2 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ AddOption('--static', dest='static', nargs='?', const=True, help='build a static
AddOption('--pgo', dest='pgo', nargs='?', const=True, help='build PGO instrumentation')
AddOption('--debugprint', dest='debugprint', nargs='?', const=True, help='enable lots of debug printing (windows only)')
AddOption('--fullsanitychecks', dest='fullsanitychecks', nargs='?', const=True, help='enable full sanity checking on every memory op')
AddOption('--useclang', dest='useclang', nargs='?', const=True, help='use clang if it is available')
AddOption('--force32', dest='force32', help='force 32 bit build on 64 bit machine')
AddOption('--sse', dest='sse', nargs=1, type='int', default=1, help='set SSE used (0-4) on 32 bit x86. Defaults to 1 (SSE1).')
AddOption('--replacesystemallocator', dest='replacesystemallocator', nargs='?', const=True, help='replace all usage of the system allocator in the process when loaded')
Expand Down Expand Up @@ -76,8 +77,19 @@ if sys.platform=="win32":
env['ENV']['PATH']=os.environ['PATH']
else:
# Test the build environment
def CheckHaveClang(cc):
cc.Message("Checking if clang is available ...")
try:
temp=env['CC']
except:
temp=[]
cc.env['CC']="clang"
result=cc.TryLink('int main(void) { return 0; }\n', '.c')
cc.env['CC']=temp
cc.Result(result)
return result
def CheckGCCHasVisibility(cc):
cc.Message("Checking for GCC global symbol visibility support...")
cc.Message("Checking for GCC global symbol visibility support ...")
try:
temp=cc.env['CPPFLAGS']
except:
Expand All @@ -98,7 +110,15 @@ else:
cc.env['CPPFLAGS']=temp
cc.Result(result)
return result
conf=Configure(env, { "CheckGCCHasVisibility" : CheckGCCHasVisibility, "CheckGCCHasCPP0xFeatures" : CheckGCCHasCPP0xFeatures } )
def CheckHaveValgrind(cc):
cc.Message("Checking if valgrind is available ...")
result=cc.TryLink('#include <valgrind/valgrind.h>\nint main(void) { VALGRIND_CREATE_MEMPOOL(0,0,0); return 0; }\n', '.c')
cc.Result(result)
return result
conf=Configure(env, { "CheckHaveClang" : CheckHaveClang, "CheckGCCHasVisibility" : CheckGCCHasVisibility, "CheckGCCHasCPP0xFeatures" : CheckGCCHasCPP0xFeatures, "CheckHaveValgrind" : CheckHaveValgrind } )
if env.GetOption('useclang') and conf.CheckHaveClang():
env['CC']="clang"
env['CCXX']="clang++"
assert conf.CheckCHeader("pthread.h")
if not conf.CheckLib("rt", "clock_gettime") and not conf.CheckLib("c", "clock_gettime"):
print "WARNING: Can't find clock_gettime() in librt or libc, code may not fully compile if your system headers say that this function is available"
Expand All @@ -114,6 +134,11 @@ else:
else:
print "Disabling C++0x support"

if conf.CheckHaveValgrind():
env['CPPDEFINES']+=["HAVE_VALGRIND"]
else:
print "Disabling valgrind support"

env=conf.Finish()

# Build
Expand Down
6 changes: 4 additions & 2 deletions nedmalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -848,10 +848,12 @@ namespace nedallocatorI

/* Roll on variadic templates is all I can say! */
#ifdef HAVE_CPP0XVARIADICTEMPLATES
template<class Base, template<class> class... policies> class policycompositor
template<class Impl, template<class> class... policies> class policycompositor;
template<class Impl, template<class> class A, template<class> class... policies> class policycompositor<Impl, A, policies...>
{
typedef policycompositor<Impl, policies...> temp;
public:
typedef policies<policies...> value;
typedef A<typename temp::value> value;
};
#else
template<class Impl,
Expand Down
Loading

0 comments on commit 06f1c70

Please sign in to comment.